coloredl.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/coloredl.h
00003  * \brief MGUI::FORM_COLOR_EDIT_LIST class definitions
00004  *
00005  * \if NODOC
00006  * $Id: coloredl.h_v 1.5 2005/03/31 16:57:07 fileserver!dwilliss Exp $
00007  *
00008  * $Log: coloredl.h_v $
00009  * Revision 1.5  2005/03/31 16:57:07  fileserver!dwilliss
00010  * Rename one of our types to MIUNICODE because it conflicted with a Microsoft #define
00011  *
00012  * Revision 1.4  2003/10/03 19:58:19  linux32build!build
00013  * Doxygen
00014  *
00015  * Revision 1.3  2003/09/15 13:49:32  fileserver!dwilliss
00016  * Doxygen
00017  *
00018  * Revision 1.2  2002/10/09 16:57:45  mju
00019  * Moved to 'mgui' folder.
00020  *
00021  * Revision 1.1  2002/08/13 16:39:27  mju
00022  * Initial revision
00023  * \endif
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 //! Form for color edit list.
00049 //! This form includes a list showing color name and sample,
00050 //! and a set of controls to "edit" the selected color.
00051 class FORM_COLOR_EDIT_LIST : public MGUI::FORM {
00052    public:
00053 
00054       //! Color editing capabilities.
00055       enum CAP {
00056          CAP_NoTransparent,         //!< No transparency
00057          CAP_AllowTransparent,      //!< Allow transparency on/off control
00058          CAP_AllowTransparency,     //!< Allow transparency percentage control
00059          CAP_FromForm               //!< Used in item construction to obtain capability from form
00060          };
00061 
00062       //! Form layout.
00063       enum LAYOUT {
00064          LAYOUT_Vertical,           //!< Item edit controls below list
00065          LAYOUT_Horizontal          //!< Item edit controls to right of list
00066          };
00067 
00068       class ITEM {
00069          public:
00070 
00071             //! Construct item with name from resource lookup.
00072             ITEM (
00073                const char *name,
00074                const COLOR& color,
00075                CAP capability = CAP_FromForm
00076                );
00077 
00078             //! Construct item with MIUNICODE name.
00079             ITEM (
00080                const MIUNICODE *name,
00081                const COLOR& color,
00082                CAP capability = CAP_FromForm
00083                );
00084 
00085             //! Construct item with name from resource lookup.
00086             ITEM (
00087                const char *name,
00088                UINT32 colorref,
00089                CAP capability = CAP_FromForm
00090                );
00091 
00092             //! Construct item with MIUNICODE name.
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       //! Constructor.
00110       FORM_COLOR_EDIT_LIST (
00111          );
00112 
00113       //! Destructor.
00114       virtual ~FORM_COLOR_EDIT_LIST (
00115          );
00116 
00117       //! Add item to list.
00118       //! @return Item ID for use when retrieve color.
00119       int AddItem (
00120          const ITEM& item
00121          );
00122 
00123       //! Create the form.
00124       //! Note that if transparency on/off or percentage controls are required for any
00125       //! item in the list the desired capability must be specified when creating the form.
00126       void Create (
00127          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane for form
00128          int listrows,                          //!< Number of visible rows in color list
00129          CAP capability = CAP_NoTransparent,    //!< Edit capabilities
00130          LAYOUT layout = LAYOUT_Vertical
00131          );
00132 
00133       //! Get color for specified item.
00134       //! @return Reference to color
00135       const COLOR& GetItemColor (
00136          int itemid                       //!< Item ID (from AddItem())
00137          );
00138 
00139       //! Get color reference for specified item.
00140       //! @return Color reference
00141       UINT32 GetItemColorRef (
00142          int itemid                       //!< Item ID (from AddItem())
00143          );
00144 
00145       //! Determine if form has been created.
00146       //! @return true if created, false if not.
00147       virtual bool IsCreated (
00148          ) const;
00149 
00150       //! Determine if form is enabled for keyboard or mouse input.
00151       //! @return true if enabled, false if not, or if not yet created.
00152       virtual bool IsEnabled (
00153          ) const;
00154 
00155       //! Set whether mouse or keyboard input to form is allowed.
00156       virtual void SetEnabled (
00157          bool enabled = true
00158          );
00159 
00160       //! Set color for specified item
00161       void SetItemColor (
00162          int itemid,                      //!< Item ID from AddItem()
00163          const COLOR& color,              //!< New color to set
00164          bool notify = true               //!< Call OnChangeItemColor() if 'true' and color changed
00165          );
00166 
00167       //! Set whether form is visible or not.
00168       virtual void SetVisible (
00169          bool visible = true
00170          );
00171 
00172    protected:
00173 
00174       //! Called when item color changed.
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 //! Template version of color editor list.
00201 template <class _T> class FORM_COLOR_EDIT_LIST_T : public MGUI::FORM_COLOR_EDIT_LIST {
00202    public:
00203 
00204       //! Constructor.
00205       FORM_COLOR_EDIT_LIST_T (
00206          ): m_pContainer(0), m_pfOnChangeItemColor(0) { }
00207 
00208       //! Create the form.
00209       void Create (
00210          MGUI::LAYOUT_PANE& ParentPane,
00211          _T *pContainer,                        //!< Pointer to callback container class
00212          int listrows,                          //!< Number of visible rows in color list
00213          CAP capability = CAP_NoTransparent,    //!< Edit capabilities
00214          LAYOUT layout = LAYOUT_Vertical
00215          ) {
00216          m_pContainer = pContainer;
00217          FORM_COLOR_EDIT_LIST::Create(ParentPane,listrows,capability,layout);
00218          }
00219 
00220       //! Set container function to call when item color changed.
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 }  // End namespace MGUI
00239 
00240 #endif   // INC_MGUI_COLOREDL_H

Generated on Wed May 31 15:26:43 2006 for TNTsdk by  doxygen 1.3.8-20040913