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

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