00001
00038 #ifndef INC_RVC_UIFORMDBFIELDPICKLIST_H
00039 #define INC_RVC_UIFORMDBFIELDPICKLIST_H
00040
00041 #ifndef INC_MGUI_TREE_H
00042 #include <mgui/tree.h>
00043 #endif
00044
00045 #ifndef INC_MGUI_COMBOBOX_H
00046 #include <mgui/combobox.h>
00047 #endif
00048
00049 #ifndef INC_MGUI_IMAGELST_H
00050 #include <mgui/imagelst.h>
00051 #endif
00052
00053 #ifndef INC_RVC_DBTABLE_H
00054 #include <rvc/dbtable.h>
00055 #endif
00056
00057
00058 #ifndef GENERATING_DOXYGEN_OUTPUT
00059 class SERIALIZERITEM;
00060 #endif
00061
00062
00063 namespace RVC {
00064 namespace UI {
00065
00066
00068 class FORM_DB_FIELD_PICKLIST : public MGUI::FORM_COMPOSITE {
00069 public:
00070
00071 enum FORMSTYLE {
00072 FORMSTYLE_SelectSingle = 0x0000,
00073 FORMSTYLE_SelectMulti = 0x0001,
00074 FORMSTYLE_ComboBox = 0x0002,
00075 FORMSTYLE_AllowSelectNone = 0x0004,
00076 FORMSTYLE_UseGroupBox = 0x0008,
00077 FORMSTYLE_NoEditSettings = 0x0010,
00078 };
00079
00080 class SETTINGS {
00081 public:
00082 static const SERIALIZERITEM* SerialGetItemDef ();
00083
00084 SETTINGS ();
00085 ~SETTINGS ();
00086
00087 INT32 GetFieldNumDisplay (
00088 ) const { return (m_FieldNumDisplay); }
00089 INT32 GetFieldNumGroupBy (
00090 ) const { return (m_FieldNumGroupBy); }
00091 INT32 GetFieldNumSortBy (
00092 ) const { return (m_FieldNumSortBy); }
00093 const LPOINT2D& GetGridSize (
00094 ) const { return (m_GridSize); }
00095 bool GetStyleSampleShow (
00096 ) const { return (m_StyleSampleShow); }
00097 INT32 GetStyleSampleSize (
00098 ) const { return (m_StyleSampleSize); }
00099 bool IsChanged (
00100 ) const { return (m_IsChanged); }
00101 bool IsEqual (
00102 const SETTINGS& rhs
00103 ) const;
00104 void ResetChanged (
00105 ) { m_IsChanged = false; }
00106 void SetFieldNumDisplay (
00107 INT32 FieldNumDisplay
00108 ) { if (FieldNumDisplay != m_FieldNumDisplay) {m_IsChanged = true; m_FieldNumDisplay = FieldNumDisplay; } }
00109 void SetFieldNumGroupBy (
00110 INT32 FieldNumGroupBy
00111 ) { if (FieldNumGroupBy != m_FieldNumGroupBy) {m_IsChanged = true; m_FieldNumGroupBy = FieldNumGroupBy; } }
00112 void SetFieldNumSortBy (
00113 INT32 FieldNumSortBy
00114 ) { if (FieldNumSortBy != m_FieldNumSortBy) {m_IsChanged = true; m_FieldNumSortBy = FieldNumSortBy; } }
00115 void SetGridSize (
00116 INT32 x,
00117 INT32 y
00118 ) { if (x != m_GridSize.x || y != m_GridSize.y) { m_IsChanged = true; m_GridSize.x = x; m_GridSize.y = y; } }
00119 void SetGridSize (
00120 const LPOINT2D& GridSize
00121 ) { if (GridSize != m_GridSize) { m_IsChanged = true; m_GridSize = GridSize; } }
00122 void SetStyleSampleShow (
00123 bool StyleSampleShow
00124 ) { if (StyleSampleShow != m_StyleSampleShow) { m_IsChanged = true; m_StyleSampleShow = StyleSampleShow; } }
00125 void SetStyleSampleSize (
00126 INT32 StyleSampleSize
00127 ) { if (StyleSampleSize != m_StyleSampleSize) { m_IsChanged = true; m_StyleSampleSize = StyleSampleSize; } }
00128 private:
00129 #ifndef GENERATING_DOXYGEN_OUTPUT
00130 typedef SETTINGS THISCLASS;
00131 bool m_IsChanged;
00132 bool m_StyleSampleShow;
00133 INT32 m_StyleSampleSize;
00134 INT32 m_FieldNumDisplay;
00135 INT32 m_FieldNumSortBy;
00136 INT32 m_FieldNumGroupBy;
00137 LPOINT2D m_GridSize;
00138 #endif
00139 };
00140
00143 static int DlgEditSettings (
00144 MDLGPARENT dlgparent,
00145 const RVC::DBTABLE& TableFor,
00146 INT32 FieldNumFor,
00147 FORM_DB_FIELD_PICKLIST::SETTINGS& settings,
00148 bool ForGrouping = false
00149 );
00150
00152 FORM_DB_FIELD_PICKLIST ();
00153
00155 virtual ~FORM_DB_FIELD_PICKLIST ();
00156
00158 ERRVALUE Create (
00159 MGUI::LAYOUT_PANE_BASE& ParentPane,
00160 const MISTRING& label,
00161 const RVC::DBTABLE& TableFor,
00162 INT32 FieldNumFor,
00163 FORMSTYLE FormStyle,
00164 MGUI::LAYOUT_SIZEALIGN SizeAlign = MGUI::LAYOUT_SIZEALIGN_Expand
00165 );
00166
00168 ERRVALUE Create (
00169 MGUI::LAYOUT_PANE_BASE& ParentPane,
00170 const MISTRING& label,
00171 const RVC::DBTABLE& TableFor,
00172 INT32 FieldNumFor,
00173 const SETTINGS& settings,
00174 FORMSTYLE FormStyle,
00175 MGUI::LAYOUT_SIZEALIGN SizeAlign = MGUI::LAYOUT_SIZEALIGN_Expand
00176 );
00177
00179 const SETTINGS& GetSettings (
00180 ) const { return (m_Settings); }
00181
00183 const RVC::DBTABLE& GetTablePickFrom (
00184 ) const;
00185
00187 ERRVALUE GetValueSelected (
00188 RVC::DBTABLE::RECORD& RecordRet,
00189 INT32 FieldNumRet
00190 ) const;
00191
00193 bool HasSelection (
00194 ) const;
00195
00197 bool IsValueSelected (
00198 const RVC::DBTABLE::RECORD& RecordTest,
00199 INT32 FieldNumTest
00200 ) const;
00201
00203 void SetDelegateOnChangeSelection (
00204 DELEGATE_VOID_NOPARMS delegate
00205 ) { m_DelegateOnChangeSelection = delegate; }
00206
00208 ERRVALUE SetValueSelected (
00209 const RVC::DBTABLE::RECORD& RecordSet,
00210 INT32 FieldNumSet,
00211 bool notify = true
00212 );
00213
00214 private:
00215 #ifndef GENERATING_DOXYGEN_OUTPUT
00216
00217 typedef FORM_DB_FIELD_PICKLIST THISCLASS;
00218
00219 class SET_VALUE;
00220 class PICKLIST;
00221
00222 FORMSTYLE m_FormStyle;
00223 SETTINGS m_Settings;
00224 RVC::DBTABLE m_TableFor;
00225 INT32 m_FieldNumFor;
00226 PICKLIST *m_pPickList;
00227 MGUI::CTRL_GROUPBOX m_GroupBox;
00228 MGUI::CTRL_PUSHBUTTON m_BtnSelectAll;
00229 MGUI::CTRL_PUSHBUTTON m_BtnClearAll;
00230 MGUI::CTRL_TREE m_Tree;
00231 MGUI::FORM_COMBOBOX m_Cbx;
00232 MGUI::IMAGELIST m_ImageList;
00233 int m_IconIdxOff;
00234 int m_IconIdxOn;
00235 RVC::DBTABLE_STYLE *m_pTableStyle;
00236 RVC::DBTABLE::RECORD m_RecordStyle;
00237 INT32 m_FieldNumStyleIdx;
00238 INT32 m_FieldNumStyleName;
00239 RVC::STYLE *m_pObjStyle;
00240 RVC::STYLETYPE m_StyleType;
00241 bool m_CanShowStyle;
00242 bool m_HasPointStyle;
00243 bool m_HasLineStyle;
00244 bool m_HasPolygonStyle;
00245 UINT8 m_MaxStyleCount;
00246 BITSET m_SelectedSet;
00247 INT32 m_AddNone;
00248 INT32 m_SelectedIdx;
00249 mutable SET_VALUE *m_pSetValuesSelected;
00250 DELEGATE_VOID_NOPARMS m_DelegateOnChangeSelection;
00251
00252 ERRVALUE AddIdxToSet (INT32 idx) const;
00253 void ClearValueSets ();
00254 MGUI::CTRL_TREE::ITEMHND GetTreeItemHndFromIdx (INT32 idx) const
00255 { return (m_Tree.FindChildByID(MGUI::CTRL_TREE::ITEMHND_Root,idx,true)); }
00256 void DoPopupRightClick (MGUI::CTRL& MenuParent, const LPOINT2D& pt);
00257 void LoadSettings ();
00258 void NotifyChangeSelection ();
00259 void OnBtnClearAll ();
00260 void OnBtnSelectAll ();
00261 void OnCbxSelection ();
00262 MGUI::CUSTOMDRAW::RETVALUE OnTreeCustomDraw (MGUI::CUSTOMDRAW_TREE& CustomDraw);
00263 bool OnTreePointerButtonDown (MGUI::CTRL_TREE::ITEMHND hndItem, MGUI::CTRL_TREE::HITRESULT HitResult, const LPOINT2D& pt, MGUI::POINTERBUTTON button, MGUI::KEYSTATE keystate);
00264 bool OnTreePointerButtonUp (MGUI::CTRL_TREE::ITEMHND hndItem, MGUI::CTRL_TREE::HITRESULT HitResult, const LPOINT2D& pt, MGUI::POINTERBUTTON button, MGUI::KEYSTATE keystate);
00265 void OnTreeSize (int xsize, int ysize);
00266 void SaveSettings ();
00267 void SetSelectedIdx (INT32 SelectedIdx);
00268 void SetupTree ();
00269 ERRVALUE SetupTreeHierarchical ();
00270 ERRVALUE SetupStyleType ();
00271 bool ShowStyleSample (MGUI::CUSTOMDRAW_TREE& CustomDraw, const LRECT2D& rect, RVC::STYLETYPE StyleType, INT32 FieldNumStyleIdx, INT32 FieldNumStyleName);
00272
00273 #endif
00274 };
00275 #ifndef GENERATING_DOXYGEN_OUTPUT
00276 DEFINE_ENUM_OP_BITWISE(FORM_DB_FIELD_PICKLIST::FORMSTYLE)
00277 #endif
00278
00279 inline bool operator== (
00280 const FORM_DB_FIELD_PICKLIST::SETTINGS& lhs,
00281 const FORM_DB_FIELD_PICKLIST::SETTINGS& rhs
00282 ) { return (lhs.IsEqual(rhs)); }
00283
00284 inline bool operator!= (
00285 const FORM_DB_FIELD_PICKLIST::SETTINGS& lhs,
00286 const FORM_DB_FIELD_PICKLIST::SETTINGS& rhs
00287 ) { return (!lhs.IsEqual(rhs)); }
00288
00289
00290
00291 }
00292 }
00293
00294 #endif // INC_RVC_UIFORMDBFIELDPICKLIST_H