00001
00030 #ifndef INC_GRE_UIGADGETSCALEBAR_H
00031 #define INC_GRE_UIGADGETSCALEBAR_H
00032
00033 #ifndef INC_MGUI_GADGET_H
00034 #include <mgui/gadget.h>
00035 #endif
00036
00037 #ifndef INC_MI32_UOM_H
00038 #include <mi32/uom.h>
00039 #endif
00040
00041 #ifndef INC_MI32_ELEMSTYL_H
00042 #include <mi32/elemstyl.h>
00043 #endif
00044
00045
00046 #ifndef GENERATING_DOXYGEN_OUTPUT
00047 namespace GRE {
00048 class VIEW;
00049 class MSG;
00050 }
00051 #endif
00052
00053 namespace GRE {
00054 namespace UI {
00055
00056
00057
00058 class GADGET_SCALEBAR : public MGUI::GADGET {
00059 public:
00060
00061 enum STYLE {
00062 STYLE_UnitSingle = 0x0000,
00063 STYLE_UnitDual = 0x8000,
00064 STYLE_UnitCombined = 0x4000,
00065 STYLE_LabelAbove = 0x0000,
00066 STYLE_LabelBelow = 0x2000,
00067 STYLE_Box = 0,
00068 STYLE_IBeam = 1,
00069 STYLE_UBeam = 2,
00070 STYLE_DualCombinedBeams = STYLE_UnitCombined | STYLE_IBeam,
00071 STYLE_MASK_Shape = 0x00FF
00072 };
00073
00074 class SETTINGS {
00075 public:
00076
00077 enum STEP {
00078 STEP_1_2_5 = 0,
00079 STEP_10_25_50 = 1,
00080 };
00081
00082 SETTINGS ();
00083 ~SETTINGS ();
00084
00085 STYLE GetBarStyle () const
00086 { return (m_BarStyle); }
00087
00088 const COLOR& GetColorBar () const
00089 { return (m_ColorBar); }
00090
00091 const COLOR& GetColorFrame () const
00092 { return (m_ColorFrame); }
00093
00094 GADGET::PLACEMENT GetGadgetPlacement () const
00095 { return (m_Placement); }
00096
00097 UINT16 GetMaxLength () const
00098 { return (m_MaxLength); }
00099
00100 STEP GetStep () const
00101 { return (m_Step); }
00102
00103 const COLOR& GetTextColorBG () const
00104 { return (m_TextStyle.BGColor); }
00105
00106 const COLOR& GetTextColorFG () const
00107 { return (m_TextStyle.FGColor); }
00108
00109 const MISTRING& GetTextFont () const
00110 { return (m_TextStyle.fontname); }
00111
00112 UINT16 GetTextSize () const
00113 { return (static_cast<UINT16>(m_TextStyle.Height)); }
00114
00115 UOM::SYSTEMID GetUnitSystemId1 () const
00116 { return (m_UnitSystemId1); }
00117
00118 UOM::SYSTEMID GetUnitSystemId2 () const
00119 { return (m_UnitSystemId2); }
00120
00121 bool HasDualUnits () const;
00122
00123 void IniRead (INIHANDLE inihnd, const char *inigroup);
00124 void IniWrite (INIHANDLE inihnd, const char *inigroup) const;
00125
00126 void SetBarStyle (
00127 STYLE BarStyle
00128 ) { m_BarStyle = BarStyle; }
00129
00130 void SetColorBar (
00131 const COLOR& ColorBar
00132 ) { m_ColorBar = ColorBar; }
00133
00134 void SetColorFrame (
00135 const COLOR& ColorFrame
00136 ) { m_ColorFrame = ColorFrame; }
00137
00138 void SetGadgetPlacement (
00139 GADGET::PLACEMENT Placement
00140 ) { m_Placement = Placement; }
00141
00142 void SetMaxLength (
00143 UINT16 MaxLength
00144 ) { m_MaxLength = MaxLength; }
00145
00146 void SetStep (
00147 STEP step
00148 ) { m_Step = step; }
00149
00150 void SetTextColorBG (
00151 const COLOR& color
00152 );
00153
00154 void SetTextColorFG (
00155 const COLOR& color
00156 ) { m_TextStyle.FGColor = color; }
00157
00158 void SetTextFont (
00159 const MISTRING& FontName
00160 ) { m_TextStyle.fontname = FontName; }
00161
00162 void SetTextSize (
00163 UINT16 TextSize
00164 ) { m_TextStyle.Height = TextSize; }
00165
00166 const TEXTSTYLE& GetTextStyle () const
00167 { return (m_TextStyle); }
00168
00169 void SetUnitSystems (
00170 UOM::SYSTEMID UnitSystemId1,
00171 UOM::SYSTEMID UnitSystemId2
00172 ) { m_UnitSystemId1 = UnitSystemId1; m_UnitSystemId2 = UnitSystemId2; }
00173
00174 private:
00175 #ifndef GENERATING_DOXYGEN_OUTPUT
00176 TEXTSTYLE m_TextStyle;
00177 COLOR m_ColorFrame;
00178 COLOR m_ColorBar;
00179 GADGET::PLACEMENT m_Placement;
00180 STYLE m_BarStyle;
00181 UINT16 m_MaxLength;
00182 STEP m_Step;
00183 UOM::SYSTEMID m_UnitSystemId1;
00184 UOM::SYSTEMID m_UnitSystemId2;
00185 #endif
00186 };
00187
00189 GADGET_SCALEBAR (
00190 MGUI::TOOLCANVAS *pCanvas,
00191 VIEW *view
00192 );
00193
00195 ~GADGET_SCALEBAR ();
00196
00197 private:
00198 #ifndef GENERATING_DOXYGEN_OUTPUT
00199 class DLG_SETTINGS;
00200
00201 class BAR {
00202 public:
00203 enum PARTS {
00204 PART_Frame = 0x01,
00205 PART_Inside = 0x02,
00206 PART_Label = 0x04,
00207 PARTS_All = 0xFF
00208 };
00209
00210 BAR (
00211 bool IsSecond
00212 );
00213 INT16 Calc (
00214 const SETTINGS& Settings,
00215 MGD::DEVICE& device,
00216 double scale
00217 );
00218 void CalcSample (
00219 const SETTINGS& Settings,
00220 STYLE BarStyle,
00221 const LRECT2D& rect
00222 );
00223 void Draw (
00224 const SETTINGS& Settings,
00225 MGD::CONTEXT *gc,
00226 MGUI::POINT pos,
00227 UINT8 parts = PARTS_All
00228 ) const;
00229 UINT16 GetLengthInPixels () const
00230 { return (m_LengthInPixels); }
00231 private:
00232 bool m_IsSecond;
00233 bool m_LabelBelow;
00234 STYLE m_Style;
00235 UINT16 m_LengthInPixels;
00236 INT16 m_BarCenterY;
00237 INT16 m_LabelBaseY;
00238 MISTRING m_Label;
00239 };
00240
00241 VIEW *m_view;
00242 SETTINGS m_Settings;
00243 BAR m_Bar1;
00244 BAR m_Bar2;
00245
00246 static void GRECB_View (const GRE::MSG *pMsg, void *vpGadget);
00247
00248 void GetScaleStr (UOM::SYSTEMID UnitSystem, MISTRING& str) const;
00249
00250
00251 virtual MGUI::POINT v_ComputeSize ();
00252 virtual int v_DlgEditSettings (MDLGPARENT dlgparent);
00253 virtual void v_Draw (MGD::CONTEXT *gc, MGUI::CANVAS::DEVICETYPE DeviceType);
00254 virtual bool v_OnToolTipRequest (MGUI::CTRL_TOOLTIP& tooltip, MGUI::POINT& ptCanvas);
00255 #endif
00256 };
00257
00258 #ifndef GENERATING_DOXYGEN_OUTPUT
00259 DEFINE_ENUM_OP_BITWISE(GADGET_SCALEBAR::STYLE)
00260 #endif
00261
00262
00263
00264 }
00265 }
00266
00267 #endif // INC_GRE_UIGADGETSCALEBAR_H