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.4 2003/10/03 19:58:19 linux32build!build Exp $
00007  *
00008  * $Log: coloredl.h_v $
00009  * Revision 1.4  2003/10/03 19:58:19  linux32build!build
00010  * Doxygen
00011  *
00012  * Revision 1.3  2003/09/15 13:49:32  fileserver!dwilliss
00013  * Doxygen
00014  *
00015  * Revision 1.2  2002/10/09 16:57:45  mju
00016  * Moved to 'mgui' folder.
00017  *
00018  * Revision 1.1  2002/08/13 16:39:27  mju
00019  * Initial revision
00020  * \endif
00021 **/
00022 
00023 #ifndef  INC_MGUI_COLOREDL_H
00024 #define  INC_MGUI_COLOREDL_H
00025 
00026 #ifndef  INC_MGUI_CTRL_H
00027 #include <mgui/ctrl.h>
00028 #endif
00029 
00030 #ifndef  INC_MGUI_GRID_H
00031 #include <mgui/grid.h>
00032 #endif
00033 
00034 #ifndef  INC_MGUI_COLORSEL_H
00035 #include <mgui/colorsel.h>
00036 #endif
00037 
00038 #ifndef  INC_MI32_MILIST_H
00039 #include <mi32/milist.h>
00040 #endif
00041 
00042 
00043 namespace MGUI {
00044 
00045 //! Form for color edit list.
00046 //! This form includes a list showing color name and sample,
00047 //! and a set of controls to "edit" the selected color.
00048 class FORM_COLOR_EDIT_LIST : public MGUI::FORM {
00049    public:
00050 
00051       //! Color editing capabilities.
00052       enum CAP {
00053          CAP_NoTransparent,         //!< No transparency
00054          CAP_AllowTransparent,      //!< Allow transparency on/off control
00055          CAP_AllowTransparency,     //!< Allow transparency percentage control
00056          CAP_FromForm               //!< Used in item construction to obtain capability from form
00057          };
00058 
00059       //! Form layout.
00060       enum LAYOUT {
00061          LAYOUT_Vertical,           //!< Item edit controls below list
00062          LAYOUT_Horizontal          //!< Item edit controls to right of list
00063          };
00064 
00065       class ITEM {
00066          public:
00067 
00068             //! Construct item with name from resource lookup.
00069             ITEM (
00070                const char *name,
00071                const COLOR& color,
00072                CAP capability = CAP_FromForm
00073                );
00074 
00075             //! Construct item with UNICODE name.
00076             ITEM (
00077                const UNICODE *name,
00078                const COLOR& color,
00079                CAP capability = CAP_FromForm
00080                );
00081 
00082             //! Construct item with name from resource lookup.
00083             ITEM (
00084                const char *name,
00085                UINT32 colorref,
00086                CAP capability = CAP_FromForm
00087                );
00088 
00089             //! Construct item with UNICODE name.
00090             ITEM (
00091                const UNICODE *name,
00092                UINT32 colorref,
00093                CAP capability = CAP_FromForm
00094                );
00095 
00096          private:
00097             #ifndef GENERATING_DOXYGEN_OUTPUT
00098             MISTRING m_name;
00099             COLOR m_color;
00100             CAP m_cap;
00101 
00102             friend class FORM_COLOR_EDIT_LIST;
00103             #endif // GENERATING_DOXYGEN_OUTPUT
00104          };
00105 
00106       //! Constructor.
00107       FORM_COLOR_EDIT_LIST (
00108          );
00109 
00110       //! Destructor.
00111       virtual ~FORM_COLOR_EDIT_LIST (
00112          );
00113 
00114       //! Add item to list.
00115       //! @return Item ID for use when retrieve color.
00116       int AddItem (
00117          const ITEM& item
00118          );
00119 
00120       //! Create the form.
00121       //! Note that if transparency on/off or percentage controls are required for any
00122       //! item in the list the desired capability must be specified when creating the form.
00123       void Create (
00124          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane for form
00125          int listrows,                          //!< Number of visible rows in color list
00126          CAP capability = CAP_NoTransparent,    //!< Edit capabilities
00127          LAYOUT layout = LAYOUT_Vertical
00128          );
00129 
00130       //! Get color for specified item.
00131       //! @return Reference to color
00132       const COLOR& GetItemColor (
00133          int itemid                       //!< Item ID (from AddItem())
00134          );
00135 
00136       //! Get color reference for specified item.
00137       //! @return Color reference
00138       UINT32 GetItemColorRef (
00139          int itemid                       //!< Item ID (from AddItem())
00140          );
00141 
00142       //! Determine if form has been created.
00143       //! @return true if created, false if not.
00144       virtual bool IsCreated (
00145          ) const;
00146 
00147       //! Determine if form is enabled for keyboard or mouse input.
00148       //! @return true if enabled, false if not, or if not yet created.
00149       virtual bool IsEnabled (
00150          ) const;
00151 
00152       //! Set whether mouse or keyboard input to form is allowed.
00153       virtual void SetEnabled (
00154          bool enabled = true
00155          );
00156 
00157       //! Set color for specified item
00158       void SetItemColor (
00159          int itemid,                      //!< Item ID from AddItem()
00160          const COLOR& color,              //!< New color to set
00161          bool notify = true               //!< Call OnChangeItemColor() if 'true' and color changed
00162          );
00163 
00164       //! Set whether form is visible or not.
00165       virtual void SetVisible (
00166          bool visible = true
00167          );
00168 
00169    protected:
00170 
00171       //! Called when item color changed.
00172       virtual void OnChangeItemColor (
00173          int itemid,
00174          const COLOR& color
00175          );
00176 
00177    private:
00178       #ifndef GENERATING_DOXYGEN_OUTPUT
00179 
00180       MILIST<ITEM> m_ItemList;
00181       CTRL_GRID_T<FORM_COLOR_EDIT_LIST> m_ColorList;
00182       FORM_COLORSELECTOR_T<FORM_COLOR_EDIT_LIST> m_ColorSel;
00183 
00184       CAP m_cap;
00185 
00186       ITEM* GetColorListItemPtr (int itemnum) {
00187          return (static_cast<ITEM*>(reinterpret_cast<void*>(m_ColorList.GetItemData(itemnum))));
00188          }
00189       int InsertItem (ITEM&);
00190       bool OnColorListItemDraw (MGUI::CTRL_GRID::CUSTOMDRAW&);
00191       void OnColorListItemSelect (int itemnum, int subitem);
00192       void OnColorSelChangeColor ();
00193       #endif // GENERATING_DOXYGEN_OUTPUT
00194    };
00195 
00196 
00197 //! Template version of color editor list.
00198 template <class _T> class FORM_COLOR_EDIT_LIST_T : public MGUI::FORM_COLOR_EDIT_LIST {
00199    public:
00200 
00201       //! Constructor.
00202       FORM_COLOR_EDIT_LIST_T (
00203          ): m_pContainer(0), m_pfOnChangeItemColor(0) { }
00204 
00205       //! Create the form.
00206       void Create (
00207          MGUI::LAYOUT_PANE& ParentPane,
00208          _T *pContainer,                        //!< Pointer to callback container class
00209          int listrows,                          //!< Number of visible rows in color list
00210          CAP capability = CAP_NoTransparent,    //!< Edit capabilities
00211          LAYOUT layout = LAYOUT_Vertical
00212          ) {
00213          m_pContainer = pContainer;
00214          FORM_COLOR_EDIT_LIST::Create(ParentPane,listrows,capability,layout);
00215          }
00216 
00217       //! Set container function to call when item color changed.
00218       void SetChangeItemColorFunc (
00219          void (_T::*pfChangeItemColor)(int itemnum, const COLOR& color)
00220          ) { m_pfChangeItemColor = pfChangeItemColor; }
00221 
00222    private:
00223       #ifndef GENERATING_DOXYGEN_OUTPUT
00224       _T *m_pContainer;
00225       void (_T::*m_pfOnChangeItemColor)(int, const COLOR&);
00226 
00227       virtual void OnChangeItemColor (
00228          int itemnum,
00229          const COLOR& color
00230          ) { if (pfOnChangeItem != 0) m_pContainer->*m_pfOnChangeItemColor)(itemnum,color); }
00231       #endif // GENERATING_DOXYGEN_OUTPUT
00232 
00233    };
00234 
00235 }  // End namespace MGUI
00236 
00237 #endif   // INC_MGUI_COLOREDL_H

Generated on Tue Dec 14 13:18:15 2004 for TNTsdk by  doxygen 1.3.8-20040913