]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/mBarRange.h
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / mBarRange.h
1
2
3 #ifndef __mBAR__RANGE__
4 #define __mBAR__RANGE__
5
6
7 //-----------------------------------------------------------------------------
8 // Includes
9 //-----------------------------------------------------------------------------
10 #include "wx/colordlg.h"
11
12
13 // ----------------------------------------------------------------------------
14 // wx headers inclusion.
15 // For compilers that support precompilation, includes <wx/wx.h>.
16 // ----------------------------------------------------------------------------
17 #include <wx/wxprec.h>
18 #ifdef __BORLANDC__
19 #pragma hdrstop
20 #endif
21 #ifndef WX_PRECOMP
22 #include <wx/wx.h>
23 #endif
24 #include "marTypes.h"
25
26 //----------------------------------------------------------------------------
27 //DECLARING THE NEW EVENT
28 //wxEVT_TSBAR= event of the two side bar
29 //----------------------------------------------------------------------------
30
31 BEGIN_DECLARE_EVENT_TYPES()
32  DECLARE_EVENT_TYPE(wxEVT_TSBAR,-1) 
33 DECLARE_EVENT_TYPE(wxEVT_TSBAR_ACTUAL,-1)
34 //DECLARE_EXPORTED_EVENT_TYPE(MARACASVISULIB_EXPORTS,wxEVT_TSBAR_ACTUAL,-1)
35 //extern creaMaracasVisu_EXPORT const wxEventType wxEVT_TSBAR_ACTUAL;
36  DECLARE_EVENT_TYPE(wxEVT_TSBAR_START,-1)
37  DECLARE_EVENT_TYPE(wxEVT_TSBAR_END,-1)
38  DECLARE_EVENT_TYPE(wxEVT_TSBAR_MOVED,-1)
39  DECLARE_EVENT_TYPE(wxEVT_SELECTION_END,-1)
40 END_DECLARE_EVENT_TYPES()
41
42
43
44
45 //-------------------------------------------------------------------------------------------------------------
46 // Enum declarations
47 //-------------------------------------------------------------------------------------------------------------
48 /** Command IDs used by pColorPoint */
49 enum
50 {
51         cntID_CHANGE_COLOR = 7000,
52         cntID_ENABLE_ACTUAL,    
53         cntID_MOVABLE_ACTUAL_BAR,
54 };
55
56
57 class creaMaracasVisu_EXPORT mBarRange :public  wxScrolledWindow{
58 public:
59         //------------------------------------
60         //Constructors & Destructors
61         //------------------------------------
62         mBarRange(wxWindow *parent, int w, int h/*, bool theOrientation, bool useWithActualDrawed*/);
63         ~mBarRange();
64         //------------------------------------
65         // Bar Methods
66         //------------------------------------
67         void Refresh(bool eraseBackground = true, const wxRect* rect = NULL);
68         void OnPaint( wxPaintEvent &WXUNUSED(event) );
69         void OnSize( wxSizeEvent &WXUNUSED(event) );
70         void RefreshHorizontalView();
71         void RefreshVerticalView();
72         void RefreshForce();
73         void OnMouseMove(wxMouseEvent& event );
74         void onKey(wxKeyEvent& event);
75
76         void DrawBar();
77         //------------------------------------
78         // Getters & Setters
79         //------------------------------------
80         //Actual triangle
81         int GetPixelActual();
82         void SetPixelActual(int i);
83
84         //Start of the bar
85         int GetPixelStart();
86         void SetPixelStart(int i);
87
88         //End of the bar
89         int GetPixelEnd();
90         void SetPixelEnd(int i);
91
92         //Logical Max
93         double GetMax();
94         void SetMax(double i);
95
96         //Logical Min
97         double GetMin();
98         void SetMin(double i);
99
100         //Rectangule Height
101         int GetHeight();
102         void SetHeight(int h);
103
104         //Width
105         int GetWidth();
106         void SetWidth(int w);
107
108         int filtreValue(int value);
109         
110         //Logical Start
111         int GetStart();
112         void SetStart(int newstart);
113
114         //Logical End
115         int GetEnd();
116         void SetEnd(int newend);
117
118         //logical actual
119         int GetActual();
120         void SetActual(int newactual);
121
122
123         //The triangles half width managment
124         int GetTrianglesHalfWidth();
125         void SetTrianglesHalfWidth(int nwTriHalfWidth);
126         
127
128         //Orientation (false for vertical, true is default for horizontal)
129         bool GetOrientation();
130         void SetOrientation(bool orientation);
131
132         //Manage the property of the actual triangle to be between de start and the end
133         bool GetInRangeProperty();
134         void SetInRangeProperty(bool in);
135
136         //Inform if the actual triangle is between the start and the end triangles
137         bool IsActualInRange();
138
139         /*
140         * Sets the property for viewing or not the bar labels information
141         */
142         void setVisibleLabels (bool setVisible);
143
144         /*
145         * Sets the property for viewing or not the bar labels information
146         * return _visibleLables The state of visible labels or not 
147         */
148         bool getIfVisibleLabels ();
149
150         /*
151         * Sets the represented minimum and maximunm values
152         * param minRealValue The minimum represented value (real value)
153         * param maxRealValue The maximum represented value (real value)
154         */
155         void setRepresentedValues(double minRealValue,double maxRealValue);
156
157         /**
158         * Sets the device start drawing left-superior (pixel) start point 
159         * param deviceStart_x Pixel start for x-coord
160         * param deviceStart_y Pixel start for y-coord
161         */
162         void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
163
164
165         /*
166         * Set active state 
167         * param activeNow The new state
168         */
169         void setActiveStateTo (bool activeNow);
170         
171         /*
172         * Gets the active state of the bar
173         *  return isActive The actual state
174         */
175         bool isActive();
176
177         /*
178         * Gets the real-x value to draw a vertical line
179         * return realX_vertical_line The real x value for the vertical line
180         */
181         int     getRealX_vertical_line();
182
183         /*
184         * Sets the real-x value to draw a vertical line
185         * param realX_vertical_line The new real x value for the vertical line
186         */
187         void setRealX_vertical_line(int newReal_x);
188
189         //*******************************************************************************************************
190         // Event methods
191         //*******************************************************************************************************
192
193         /**
194         * Shows the popup menu 
195         */
196         void onShowPopupMenu (wxMouseEvent& event);
197         /**
198         * Reacts to the cntID_CHANGE_COLOR wxCommandEvent and adds a color degrade point to the color bar.
199         * param & anEvent The wxCommandEvent actioned event 
200         */
201         void onChangePartColor ( wxCommandEvent& anEvent );
202
203
204         /**
205         * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
206         * param & anEvent The wxCommandEvent actioned event 
207         */
208         void onEnableRange_Actual ( wxCommandEvent& anEvent );
209
210         /**
211         * Reacts to the cntID_MOVABLE_ACTUAL_BAR wxCommandEvent by enabling or disabling the property of moving the actual triangle with the bar, just when it is inside of it.
212         * param & anEvent The wxCommandEvent actioned event 
213         */
214         void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
215
216         /*
217         * Gets the device value form the end of this panel to the end of the drawing area in the device in pixels
218         * return deviceEndMargin The value asigned to the right margin
219         */
220         int     getDeviceEndX();
221         
222
223         /*
224         * Sets the new device (deviceEndMargin) value form the end of this panel to the end of the drawing area in the device
225         * param newDeviceEnd_pixels The new pixel value to asign to the right(horizontal view), underneath(vertical view) margin in pixels
226         */
227         void setDeviceEndMargin(int newDeviceEnd_pixels);
228
229         /*
230         * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
231         * return clickedX The x-coord pixel value
232         */
233         int getClickedX();
234
235         /*
236         * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
237         * param nwClickX The x-coord pixel value
238         */
239         void setClickedX(int nwClickX);
240
241         /*
242         * Gets the start porcentage with respect to the represented values of the bar
243         * return The porcentage represented by the start  showing point
244         */
245         float getStartShowPorcentage();
246
247         /*
248         * Gets the end porcentage with respect to the represented values of the bar
249         * return The porcentage represented by the end showing point
250         */
251         float getEndShowPorcentage();
252
253         /*
254         * Gets the actual porcentage with respect to the represented values of the bar
255         * return The porcentage represented by the actual  showing point
256         */
257         float getActualShowPorcentage();
258
259         /*
260         * Gets the logic value of a pixel point that comes in the coords of the container panel.
261     * param thePixel Is the pixel to convert
262         * return Is the correspondig value to the given pixel-value in logic bar coords
263         */
264         int getLogicValueofPixel(int thePixel);
265
266
267         /*
268         * Sets the condition for knowing if the actual triangle is being drawed or not
269         * param drawActual The condition to set for drawing or not the actual control (true for drawing)
270         */
271         void setIfWithActualDrawed(bool drawActual);
272
273         /*
274         * Gets the condition for knowing if the actual triangle is being drawed or not
275         * return withActualDrawed The condition for drawing or not the actual control
276         */
277         bool getIfWithActualDrawed();
278
279         /*
280         * Method that creates and send the given id-event to the event handler
281         * param theEventType Is the event id type identification for generating the event
282         */
283         void createAndSendEvent(WXTYPE theEventType);
284
285         /*
286         * Sets the background color od the bar
287         * theColor The color to set to the backgroundColor
288         */
289         void setBackgroundColor(wxColour theColor);
290
291         /*
292         * Sets the guide line color
293         * param theNwGuideLineColor The color to set to the guideLineColor
294         */
295         void setGuideLineColour(wxColour theNwGuideLineColor);
296
297
298         /*
299         * Gets the guide line color
300         * return guideLineColor The color of the guideLine
301         */
302         wxColour getGuideLineColour();
303
304         void onLeftClicDown(wxMouseEvent& event );
305
306         void onLeftClickUp(wxMouseEvent& event );
307
308
309 private:
310         //Rectangle width
311         int                        _w;
312         //Rectangle Height
313         int                        _h;
314         //Actual value
315         int                        _actual;
316         //Start of the rectangule
317         int                        _start;
318         //End of the rectangule
319         int                        _end;
320         //Logical Max
321         double                        _max;
322         //Logical Min
323         double                                             _min;
324         //Initial point when moving the rectangule bar according to bar reference 
325         int                                                _initialPoint;
326         /*
327         * Represents the id of the selected moving part of the bar where:
328         * 1 is for Start triangle, 2 for end triangle, 3 for actual triangle and 4 for the bar
329         */
330         int                                                _selectionMoveId;
331
332         //orientation of the rectangle is true when is horizontal and is the default value
333         bool                                            _orientation;
334
335         /*
336         * The property for identifying if the actual triangle needs to be or not between the limit triangles
337         */
338         bool                                            _in_rangeProperty;
339
340         /*
341         * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
342         */
343         bool                                            _moveActualWithBar;
344
345         /*
346         * The property for setting visible or not the bar labels information
347         */
348         bool                                       _visibleLables;
349         /*
350         * X-Coord for left-superior device visible drawing
351         */
352         wxCoord                                         deviceStart_x;  
353
354         /*
355         * Y-Coord for left-superior device visible drawing
356         */
357         wxCoord                                         deviceStart_y;
358
359         /*
360         * X-Coord for right device margin
361         */
362         wxCoord                                         deviceEndMargin;        
363
364         /*
365         * Represents the active state of the bar
366         */
367         bool activeState;
368
369         /*
370         * Represents the option of activating or not the drawing of the actual triangle, that in default value is true for drawing it
371         * The dafault value is true (use the actual triangle)
372         */
373         bool withActualDrawed;
374
375         /*
376         * The colour of the start triangle
377         */          
378         wxColour start_Colour;
379
380         /*
381         * The colour of the actual triangle
382         */          
383         wxColour actual_Colour;
384
385         /*
386         * The colour of the end triangle
387         */          
388         wxColour end_Colour;
389
390         /*
391         * The colour of the bar
392         */          
393         wxColour bar_Colour;
394         /*
395         * Represents the real-x value to draw a vertical line
396         */
397         int                     realX_vertical_line;
398
399         /*
400         * Represents the last clickedX coord inside the bar.
401         */
402         int                     clickedX;
403
404         /*
405         * Represents the orientation for the numbers view label in the information bitmap.
406         * Where  -4:left, -6:right, -8:up, -2: down respect to the bar
407         */
408         int                     numberOrientation;      
409         /*
410         * Represents the logic initial reference start point used for dragging
411         */
412         int                     logicInitial_start;
413         /*
414         * Represents the logic intial reference end point used for dragging
415         */
416         int                     logicInitial_end;
417         /*
418         * Represents the logic initial reference actual point used for dragging
419         */
420         int                     logicInitial_actual;
421
422         /*
423         * Represents the pixel value assigned to as half of the width of the triangles 
424         */
425         int                     trianglesHalfWidth;
426
427         /*
428         * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
429         */
430         wxColour        backgroundColor;
431         /*
432         * Represents the color of the dot-line use as guides. The default color is RED. 
433         */
434         wxColour        guideLineColor;
435
436
437         bool acceptedClick;
438         
439
440         /*
441         * The color bar pop menu
442         */
443         wxMenu b_popmenu; 
444         //the bar bitmap device
445         wxBitmap        *_bitmap_bar;
446         //the info bitmap device 
447         wxBitmap        *_bitmap_info;
448         DECLARE_CLASS(BarRange)
449         // any class wishing to process wxWindows events must use this macro
450         DECLARE_EVENT_TABLE()
451 };
452
453
454
455 #endif
456
457
458