3 #ifndef __mBAR__RANGE__
4 #define __mBAR__RANGE__
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
10 #include "wx/colordlg.h"
13 // ----------------------------------------------------------------------------
14 // wx headers inclusion.
15 // For compilers that support precompilation, includes <wx/wx.h>.
16 // ----------------------------------------------------------------------------
17 #include <wx/wxprec.h>
26 //----------------------------------------------------------------------------
27 //DECLARING THE NEW EVENT
28 //wxEVT_TSBAR= event of the two side bar
29 //----------------------------------------------------------------------------
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()
45 //-------------------------------------------------------------------------------------------------------------
47 //-------------------------------------------------------------------------------------------------------------
48 /** Command IDs used by pColorPoint */
51 cntID_CHANGE_COLOR = 7000,
53 cntID_MOVABLE_ACTUAL_BAR,
57 class creaMaracasVisu_EXPORT mBarRange :public wxScrolledWindow{
59 //------------------------------------
60 //Constructors & Destructors
61 //------------------------------------
62 mBarRange(wxWindow *parent, int w, int h);
64 //------------------------------------
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();
73 void OnMouseMove(wxMouseEvent& event );
74 void onKey(wxKeyEvent& event);
77 //------------------------------------
79 //------------------------------------
82 void SetPixelActual(int i);
86 void SetPixelStart(int i);
90 void SetPixelEnd(int i);
94 void SetMax(double i);
98 void SetMin(double i);
102 void SetHeight(int h);
106 void SetWidth(int w);
108 int filtreValue(int value);
112 void SetStart(int newstart);
116 void SetEnd(int newend);
120 void SetActual(int newactual);
123 //The triangles half width managment
124 int GetTrianglesHalfWidth();
125 void SetTrianglesHalfWidth(int nwTriHalfWidth);
128 //Orientation (false for vertical, true is default for horizontal)
129 bool GetOrientation();
130 void SetOrientation(bool orientation);
132 //Manage the property of the actual triangle to be between de start and the end
133 bool GetInRangeProperty();
134 void SetInRangeProperty(bool in);
136 //Inform if the actual triangle is between the start and the end triangles
137 bool IsActualInRange();
140 * Sets the property for viewing or not the bar labels information
142 void setVisibleLabels (bool setVisible);
145 * Sets the property for viewing or not the bar labels information
146 * return _visibleLables The state of visible labels or not
148 bool getIfVisibleLabels ();
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)
155 void setRepresentedValues(double minRealValue,double maxRealValue);
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
162 void setDeviceBlitStart ( wxCoord deviceStart_x, wxCoord deviceStart_y );
167 * param activeNow The new state
169 void setActiveStateTo (bool activeNow);
172 * Gets the active state of the bar
173 * return isActive The actual state
178 * Gets the real-x value to draw a vertical line
179 * return realX_vertical_line The real x value for the vertical line
181 int getRealX_vertical_line();
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
187 void setRealX_vertical_line(int newReal_x);
189 //*******************************************************************************************************
191 //*******************************************************************************************************
194 * Shows the popup menu
196 void onShowPopupMenu (wxMouseEvent& event);
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
201 void onChangePartColor ( wxCommandEvent& anEvent );
205 * Reacts to the cntID_ENABLE_ACTUAL wxCommandEvent enables the actual to be between the the range.
206 * param & anEvent The wxCommandEvent actioned event
208 void onEnableRange_Actual ( wxCommandEvent& anEvent );
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
214 void onMovable_ActualWithBar ( wxCommandEvent& anEvent );
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
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
227 void setDeviceEndMargin(int newDeviceEnd_pixels);
230 * Gets the last clickedX pixel coord inside the bar with respect to the container panel.
231 * return clickedX The x-coord pixel value
236 * Sets the last clickedX pixel coord inside the bar with respect to the container panel.
237 * param nwClickX The x-coord pixel value
239 void setClickedX(int nwClickX);
242 * Gets the start porcentage with respect to the represented values of the bar
243 * return The porcentage represented by the start showing point
245 float getStartShowPorcentage();
248 * Gets the end porcentage with respect to the represented values of the bar
249 * return The porcentage represented by the end showing point
251 float getEndShowPorcentage();
254 * Gets the actual porcentage with respect to the represented values of the bar
255 * return The porcentage represented by the actual showing point
257 float getActualShowPorcentage();
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
264 int getLogicValueofPixel(int thePixel);
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)
271 void setIfWithActualDrawed(bool drawActual);
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
277 bool getIfWithActualDrawed();
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
283 void createAndSendEvent(WXTYPE theEventType);
286 * Sets the background color od the bar
287 * theColor The color to set to the backgroundColor
289 void setBackgroundColor(wxColour theColor);
292 * Sets the guide line color
293 * param theNwGuideLineColor The color to set to the guideLineColor
295 void setGuideLineColour(wxColour theNwGuideLineColor);
299 * Gets the guide line color
300 * return guideLineColor The color of the guideLine
302 wxColour getGuideLineColour();
304 void onLeftClicDown(wxMouseEvent& event );
306 void onLeftClickUp(wxMouseEvent& event );
316 //Start of the rectangule
318 //End of the rectangule
324 //Initial point when moving the rectangule bar according to bar reference
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
330 int _selectionMoveId;
332 //orientation of the rectangle is true when is horizontal and is the default value
336 * The property for identifying if the actual triangle needs to be or not between the limit triangles
338 bool _in_rangeProperty;
341 * The property for setting the acutal triangle to move with the bar keeping proportions with the limits
343 bool _moveActualWithBar;
346 * The property for setting visible or not the bar labels information
350 * X-Coord for left-superior device visible drawing
352 wxCoord deviceStart_x;
355 * Y-Coord for left-superior device visible drawing
357 wxCoord deviceStart_y;
360 * X-Coord for right device margin
362 wxCoord deviceEndMargin;
365 * Represents the active state of the bar
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)
373 bool withActualDrawed;
376 * The colour of the start triangle
378 wxColour start_Colour;
381 * The colour of the actual triangle
383 wxColour actual_Colour;
386 * The colour of the end triangle
391 * The colour of the bar
395 * Represents the real-x value to draw a vertical line
397 int realX_vertical_line;
400 * Represents the last clickedX coord inside the bar.
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
408 int numberOrientation;
410 * Represents the logic initial reference start point used for dragging
412 int logicInitial_start;
414 * Represents the logic intial reference end point used for dragging
416 int logicInitial_end;
418 * Represents the logic initial reference actual point used for dragging
420 int logicInitial_actual;
423 * Represents the pixel value assigned to as half of the width of the triangles
425 int trianglesHalfWidth;
428 * Represents the background color of the panel (this) where the bar is. The default color is the imediately parent background color
430 wxColour backgroundColor;
432 * Represents the color of the dot-line use as guides. The default color is RED.
434 wxColour guideLineColor;
441 * The color bar pop menu
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()