formrastervalue.h

Go to the documentation of this file.
00001 /** 
00002  * \file mgui/formrastervalue.h 
00003  * \brief Definitions for MGUI::FORM_EDIT_RASTER_VALUE classes.
00004  *
00005  * \if NODOC
00006  * $Id: formrastervalue.h_v 1.4 2003/11/04 13:20:30 mju Exp $
00007  *
00008  * $Log: formrastervalue.h_v $
00009  * Revision 1.4  2003/11/04 13:20:30  mju
00010  * GetValue can't be const.
00011  *
00012  * Revision 1.3  2003/10/01 22:32:27  dwilliss
00013  * doxygen
00014  *
00015  * Revision 1.2  2003/09/30 15:31:32  scowan
00016  * Fixed virtual method override.
00017  *
00018  * Revision 1.1  2003/09/29 22:59:06  scowan
00019  * Initial revision
00020  * \endif
00021  *
00022 **/
00023 
00024 #ifndef  INC_MGUI_FORM_EDIT_RASTER_VALUE_H
00025 #define  INC_MGUI_FORM_EDIT_RASTER_VALUE_H
00026 
00027 #ifndef INC_MGUI_FORM_H
00028 #include <mgui/form.h>
00029 #endif
00030 
00031 #ifndef  INC_MGUI_CTRL_H
00032 #include <mgui/ctrl.h>
00033 #endif
00034 
00035 #ifndef  INC_RVC_IMAGE_H
00036 #include <rvc/image.h>
00037 #endif
00038 
00039 namespace MGUI {
00040 
00041 //:>===================================================================================================================
00042 //! Form consisting of label and string edit field.
00043 class FORM_EDIT_RASTER_VALUE : public MGUI::FORM_COMPOSITE {
00044    public:
00045       //! Constructor.
00046       FORM_EDIT_RASTER_VALUE (
00047          );
00048 
00049       //! Destructor.
00050       virtual ~FORM_EDIT_RASTER_VALUE (
00051          );
00052 
00053       //! Create form with label from resource lookup.
00054       void Create (
00055          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00056          const MISTRING& label,                 //!< Label
00057          RVC::IMAGE::CELLTYPE CellType,
00058          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00059          MGUI::CTRL_LABEL::STYLE labelstyle = MGUI::CTRL_LABEL::STYLE_LeftNoWrap
00060          );
00061 
00062       //! Retrieve label control for form.
00063       //! Usually the label control is only retrieved for alignment purposes.
00064       MGUI::CTRL_LABEL& GetLabel (
00065          ) { return (m_label); }
00066 
00067       //! Get current raster value.
00068       void GetValue (
00069          ANYRASTVALUE& value
00070          );
00071          
00072       void SetCellType (
00073          RVC::IMAGE::CELLTYPE CellType
00074          );
00075 
00076       //! Set label text using string from resource lookup.
00077       void SetLabel (
00078          const MISTRING& label               //!< New label text
00079          ) { m_label.SetLabel(label); }
00080 
00081       //! Set current string value with validation.
00082       //! OnValidate() will be called and if valid, the string will be updated.
00083       //! No comparison is made with the current string value.
00084       void SetValue (
00085          const ANYRASTVALUE& value,          //!< New value to set
00086          bool notify = true                  //!< Call OnChangeValue() if string actually updated
00087          );
00088 
00089    protected:
00090 
00091       //! Called when value is changed after validation.
00092       //! Derived class must call corresponding base class method BEFORE performing its own processing.
00093       //! If the user modifies the text in the edit control this will not be called until the control loses "focus".
00094       virtual void v_OnChangeValue ();
00095 
00096    private:
00097       RVC::IMAGE::CELLTYPE m_CellType;
00098       CTRL_LABEL m_label;
00099       FORM_EDIT_NUMBER_T<FORM_EDIT_RASTER_VALUE> m_Value1;
00100       FORM_EDIT_NUMBER_T<FORM_EDIT_RASTER_VALUE> m_Value2;
00101       FORM_EDIT_NUMBER_T<FORM_EDIT_RASTER_VALUE> m_Value3;
00102       FORM_EDIT_NUMBER_T<FORM_EDIT_RASTER_VALUE> m_Value4;
00103       
00104       void OnValueChanged ();
00105    };
00106 
00107 
00108 //:>-------------------------------------------------------------------------------------------------------------------
00109 // Convenience template for FORM_EDIT_RASTER_VALUE to allow method in container class to be called.
00110 template <class _CT> class FORM_EDIT_RASTER_VALUE_T : public MGUI::FORM_EDIT_RASTER_VALUE {
00111    public:
00112 
00113       //! Constructor.
00114       explicit FORM_EDIT_RASTER_VALUE_T (
00115          ): m_pContainer(0), m_pfOnChangeValue(0)
00116          { }
00117 
00118       //! Create form with label from resource lookup.
00119       void Create (
00120          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00121          const MISTRING& label,                 //!< Label
00122          RVC::IMAGE::CELLTYPE CellType,
00123          _CT *pContainer,                       //!< Pointer to container
00124          void (_CT::*pfOnChangeValue)(),              //!< Function to call when value changed, NULL for none
00125          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00126          MGUI::CTRL_LABEL::STYLE labelstyle = MGUI::CTRL_LABEL::STYLE_LeftNoWrap
00127          ) {
00128          m_pContainer = pContainer;
00129          m_pfOnChangeValue = pfOnChangeValue;
00130          FORM_EDIT_RASTER_VALUE::Create(ParentPane,label,CellType,sizealign,labelstyle);
00131          }
00132 
00133    private:
00134 
00135       _CT *m_pContainer;
00136       void (_CT::*m_pfOnChangeValue)();
00137 
00138       virtual void v_OnChangeValue (
00139          ) { if (m_pfOnChangeValue != 0) (m_pContainer->*m_pfOnChangeValue)(); }
00140    };
00141 
00142 }  // End of MGUI namespace
00143 
00144 #endif      // INC_MGUI_FORM_EDIT_RASTER_VALUE_H

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