00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef INC_MGUI_COLOREDL_H
00027 #define INC_MGUI_COLOREDL_H
00028
00029 #ifndef INC_MGUI_CTRL_H
00030 #include <mgui/ctrl.h>
00031 #endif
00032
00033 #ifndef INC_MGUI_GRID_H
00034 #include <mgui/grid.h>
00035 #endif
00036
00037 #ifndef INC_MGUI_COLORSEL_H
00038 #include <mgui/colorsel.h>
00039 #endif
00040
00041 #ifndef INC_MI32_MILIST_H
00042 #include <mi32/milist.h>
00043 #endif
00044
00045
00046 namespace MGUI {
00047
00048
00049
00050
00051 class FORM_COLOR_EDIT_LIST : public MGUI::FORM {
00052 public:
00053
00054
00055 enum CAP {
00056 CAP_NoTransparent,
00057 CAP_AllowTransparent,
00058 CAP_AllowTransparency,
00059 CAP_FromForm
00060 };
00061
00062
00063 enum LAYOUT {
00064 LAYOUT_Vertical,
00065 LAYOUT_Horizontal
00066 };
00067
00068 class ITEM {
00069 public:
00070
00071
00072 ITEM (
00073 const char *name,
00074 const COLOR& color,
00075 CAP capability = CAP_FromForm
00076 );
00077
00078
00079 ITEM (
00080 const MIUNICODE *name,
00081 const COLOR& color,
00082 CAP capability = CAP_FromForm
00083 );
00084
00085
00086 ITEM (
00087 const char *name,
00088 UINT32 colorref,
00089 CAP capability = CAP_FromForm
00090 );
00091
00092
00093 ITEM (
00094 const MIUNICODE *name,
00095 UINT32 colorref,
00096 CAP capability = CAP_FromForm
00097 );
00098
00099 private:
00100 #ifndef GENERATING_DOXYGEN_OUTPUT
00101 MISTRING m_name;
00102 COLOR m_color;
00103 CAP m_cap;
00104
00105 friend class FORM_COLOR_EDIT_LIST;
00106 #endif // GENERATING_DOXYGEN_OUTPUT
00107 };
00108
00109
00110 FORM_COLOR_EDIT_LIST (
00111 );
00112
00113
00114 virtual ~FORM_COLOR_EDIT_LIST (
00115 );
00116
00117
00118
00119 int AddItem (
00120 const ITEM& item
00121 );
00122
00123
00124
00125
00126 void Create (
00127 MGUI::LAYOUT_PANE_BASE& ParentPane,
00128 int listrows,
00129 CAP capability = CAP_NoTransparent,
00130 LAYOUT layout = LAYOUT_Vertical
00131 );
00132
00133
00134
00135 const COLOR& GetItemColor (
00136 int itemid
00137 );
00138
00139
00140
00141 UINT32 GetItemColorRef (
00142 int itemid
00143 );
00144
00145
00146
00147 virtual bool IsCreated (
00148 ) const;
00149
00150
00151
00152 virtual bool IsEnabled (
00153 ) const;
00154
00155
00156 virtual void SetEnabled (
00157 bool enabled = true
00158 );
00159
00160
00161 void SetItemColor (
00162 int itemid,
00163 const COLOR& color,
00164 bool notify = true
00165 );
00166
00167
00168 virtual void SetVisible (
00169 bool visible = true
00170 );
00171
00172 protected:
00173
00174
00175 virtual void OnChangeItemColor (
00176 int itemid,
00177 const COLOR& color
00178 );
00179
00180 private:
00181 #ifndef GENERATING_DOXYGEN_OUTPUT
00182
00183 MILIST<ITEM> m_ItemList;
00184 CTRL_GRID_T<FORM_COLOR_EDIT_LIST> m_ColorList;
00185 FORM_COLORSELECTOR_T<FORM_COLOR_EDIT_LIST> m_ColorSel;
00186
00187 CAP m_cap;
00188
00189 ITEM* GetColorListItemPtr (int itemnum) {
00190 return (static_cast<ITEM*>(reinterpret_cast<void*>(m_ColorList.GetItemData(itemnum))));
00191 }
00192 int InsertItem (ITEM&);
00193 bool OnColorListItemDraw (MGUI::CTRL_GRID::CUSTOMDRAW&);
00194 void OnColorListItemSelect (int itemnum, int subitem);
00195 void OnColorSelChangeColor ();
00196 #endif // GENERATING_DOXYGEN_OUTPUT
00197 };
00198
00199
00200
00201 template <class _T> class FORM_COLOR_EDIT_LIST_T : public MGUI::FORM_COLOR_EDIT_LIST {
00202 public:
00203
00204
00205 FORM_COLOR_EDIT_LIST_T (
00206 ): m_pContainer(0), m_pfOnChangeItemColor(0) { }
00207
00208
00209 void Create (
00210 MGUI::LAYOUT_PANE& ParentPane,
00211 _T *pContainer,
00212 int listrows,
00213 CAP capability = CAP_NoTransparent,
00214 LAYOUT layout = LAYOUT_Vertical
00215 ) {
00216 m_pContainer = pContainer;
00217 FORM_COLOR_EDIT_LIST::Create(ParentPane,listrows,capability,layout);
00218 }
00219
00220
00221 void SetChangeItemColorFunc (
00222 void (_T::*pfChangeItemColor)(int itemnum, const COLOR& color)
00223 ) { m_pfChangeItemColor = pfChangeItemColor; }
00224
00225 private:
00226 #ifndef GENERATING_DOXYGEN_OUTPUT
00227 _T *m_pContainer;
00228 void (_T::*m_pfOnChangeItemColor)(int, const COLOR&);
00229
00230 virtual void OnChangeItemColor (
00231 int itemnum,
00232 const COLOR& color
00233 ) { if (pfOnChangeItem != 0) m_pContainer->*m_pfOnChangeItemColor)(itemnum,color); }
00234 #endif // GENERATING_DOXYGEN_OUTPUT
00235
00236 };
00237
00238 }
00239
00240 #endif // INC_MGUI_COLOREDL_H