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