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