ctrl.h

Go to the documentation of this file.
00001 /** 
00002  * \file mgui/ctrl.h
00003  * \brief Definitions for MGUI::CTRL classes.
00004  *
00005  * \if NODOC
00006  * $Id: ctrl.h_v 1.61 2005/05/10 15:27:21 mju Exp $
00007  *
00008  * $Log: ctrl.h_v $
00009  * Revision 1.61  2005/05/10 15:27:21  mju
00010  * Make button.getValue non-inline for MFC.
00011  *
00012  * Revision 1.60  2005/03/31 16:57:07  fileserver!dwilliss
00013  * Rename one of our types to MIUNICODE because it conflicted with a Microsoft #define
00014  *
00015  * Revision 1.59  2005/03/11 18:56:54  mju
00016  * Add value member for togglebutton so retains state after control destroyed.
00017  *
00018  * Revision 1.58  2004/10/13 22:18:04  mju
00019  * Use mistring for labels instead of unicode*.
00020  *
00021  * Revision 1.57  2004/10/06 23:43:12  dfriberg
00022  * Fixed ordered list comment (doxygen)
00023  *
00024  * Revision 1.56  2004/10/04 15:26:23  mju
00025  * Use mistring in togglebutton_t.
00026  *
00027  * Revision 1.55  2004/08/19 13:46:08  mju
00028  * Change tooltipctrl to match base create fn to avoid annoying warnings.
00029  *
00030  * Revision 1.54  2004/07/27 13:42:09  mju
00031  * Add groupbox.setlabeltext.
00032  *
00033  * Revision 1.53  2004/07/26 15:10:45  mju
00034  * Add ability to specify width in pixels for text fields.
00035  *
00036  * Revision 1.52  2004/06/23 20:51:37  dwilliss
00037  * Added activate members to edit templates
00038  *
00039  * Revision 1.51  2004/05/28 21:43:47  mju
00040  * Change separator to take length and add create method using text.
00041  *
00042  * Revision 1.50  2004/04/08 21:23:19  mju
00043  * Change setfocus to v_setfocus.
00044  *
00045  * Revision 1.49  2004/03/30 17:26:10  vdronov
00046  * CTRL_SEPARATOR class added
00047  *
00048  * Revision 1.48  2004/03/15 17:45:57  dwilliss
00049  * Added a SetMaxLength() method to edit controls
00050  *
00051  * Revision 1.47  2003/12/18 13:43:44  mju
00052  * Simplify 'edit' templates by making ctor take pContainer and using SetFunc...
00053  *   methods to set functions.  This allows use of base Create() methods.
00054  * Add OnUserEdit for edit_number.
00055  *
00056  * Revision 1.46  2003/12/12 18:49:36  mju
00057  * Move 'selection' methods to edit_base.
00058  * Add set/clear selection methods to ctrl_text.
00059  *
00060  * Revision 1.45  2003/12/12 15:30:23  mju
00061  * Change CB_valuechanged parm.
00062  *
00063  * Revision 1.44  2003/12/11 20:57:27  mju
00064  * Need OnUserEdit in FORM_EDIT_STRING.
00065  *
00066  * Revision 1.43  2003/12/11 18:38:58  mju
00067  * Add OnUserEdit for form_edit_string too.
00068  *
00069  * Revision 1.42  2003/12/11 18:27:10  mju
00070  * Don't call pfOnUserEdit if null.
00071  *
00072  * Revision 1.41  2003/12/11 15:40:06  mju
00073  * For edit controls make base overridables private as don't need to call from derived.
00074  *
00075  * Revision 1.40  2003/11/14 16:14:21  dwilliss
00076  * Added MISTRING versions of label create and set methods to allow TEXTIDs
00077  * Should deprecate the plain MIUNICODE versions?  Not sure, leave `em for now.
00078  *
00079  * Revision 1.39  2003/11/03 18:47:53  mju
00080  * Make edit::getValue methods non-inline and non-const so can update to lateset edits.
00081  *
00082  * Revision 1.38  2003/10/27 16:16:06  mju
00083  * For 'edit' controls, move Get/SetModify to base and implement for X also.
00084  *
00085  * Revision 1.37  2003/10/02 16:19:23  linux32build!build
00086  * Doxygen fix
00087  *
00088  * Revision 1.36  2003/10/01 22:32:38  dwilliss
00089  * doxygen
00090  *
00091  * Revision 1.35  2003/09/15 13:49:32  fileserver!dwilliss
00092  * Doxygen
00093  *
00094  * Revision 1.34  2003/08/19 22:39:21  msmith
00095  * CTRL_LABEL for MFC now does multiline text and icons.
00096  *
00097  * Revision 1.33  2003/08/01 16:54:03  scowan
00098  * Added ctrl label create icon methods.
00099  *
00100  * Revision 1.32  2003/06/30 15:01:52  scowan
00101  * Moved ctrl text clear method from an inline.
00102  *
00103  * Revision 1.31  2003/04/15 16:42:32  mju
00104  * Include rect.h.
00105  *
00106  * Revision 1.30  2003/04/09 20:48:09  dwilliss
00107  * Don't use _T in templates.  Mac's ctype.h defines a global _T
00108  *
00109  * Revision 1.29  2003/01/27 18:54:19  mju
00110  * Move POINT defn to layout.h.
00111  *
00112  * Revision 1.28  2003/01/16 21:35:11  mju
00113  * Move listbox/combobox hdrs to end as need ctrl first.
00114  *
00115  * Revision 1.27  2003/01/16 21:13:10  mju
00116  * Move listbox/combobox defns to own headers.
00117  *
00118  * Revision 1.24  2002/12/02 17:13:19  mju
00119  * Add GetBackgroundColor.
00120  *
00121  * Revision 1.23  2002/11/18 21:54:05  mju
00122  * Add listbox X callbacks.
00123  *
00124  * Revision 1.22  2002/10/14 19:16:31  mju
00125  * Only define togglebutton::style_RadioFirst for MFC.
00126  *
00127  * Revision 1.21  2002/10/11 19:40:34  dwilliss
00128  * Get rid of KEYSTATE_Alt
00129  *
00130  * Revision 1.20  2002/10/11 16:14:51  mju
00131  * Change CTRL to have pointer instead of reference to actual control for MFC.
00132  * This allows the definition of the MFC control to be in the implementation module.
00133  *
00134  * Revision 1.19  2002/10/11 14:49:18  dwilliss
00135  * Moved the KEYSTATE enum to here
00136  *
00137  * Revision 1.18  2002/10/09 16:51:18  mju
00138  * Forward declare TEXTSTYLE.
00139  *
00140  * Revision 1.17  2002/10/09 15:33:21  mju
00141  * Moved to 'mgui' folder.
00142  *
00143  * Revision 1.16  2002/10/09 15:26:17  dwilliss
00144  * Added some methods and a flag to CTRL_TEXT
00145  *
00146  * Revision 1.15  2002/09/17 17:13:03  scowan
00147  * Removed mgui namespace qualifier on a ctor declaration.
00148  *
00149  * Revision 1.13  2002/08/09 13:29:57  mju
00150  * Add const getcombobox method.
00151  *
00152  * Revision 1.12  2002/07/09 15:39:58  dwilliss
00153  * Added an InvalidateRect method to match the MFC one
00154  *
00155  * Revision 1.11  2002/06/06 20:56:44  mju
00156  * Don't inline combo/listbox methods.
00157  *
00158  * Revision 1.9  2002/01/03 15:10:16  mju
00159  * Allow GROUPBOX cast to PANE in X too.
00160  *
00161  * Revision 1.8  2001/12/19 21:01:05  mju
00162  * Change comments for OnPressed regarding base class method.
00163  *
00164  * Revision 1.7  2001/12/18 23:07:58  mju
00165  * Add listheight for X ComboBox so will remember preferred size.
00166  *
00167  * Revision 1.6  2001/12/18 18:25:01  mju
00168  * Add FORM_EDIT_STRING::ClearValue().
00169  *
00170  * Revision 1.4  2001/12/14 18:52:11  mju
00171  * ICONID is now an enum.
00172  *
00173  * Revision 1.3  2001/12/13 17:00:05  mju
00174  * MGUI unification with X.
00175  *
00176  * Revision 1.2  2001/12/05 21:55:27  mju
00177  * Include MFC header when building for such.
00178  *
00179  * Revision 1.1  2001/12/03 17:38:38  mju
00180  * Initial revision
00181  * \endif
00182 **/
00183 
00184 #ifndef  INC_MGUI_CTRL_H
00185 #define  INC_MGUI_CTRL_H
00186 
00187 #ifndef INC_MGUI_FORM_H
00188 #include <mgui/form.h>
00189 #endif
00190 
00191 #ifndef  INC_MI32_RANGE_H
00192 #include <mi32/range.h>
00193 #endif
00194 
00195 #ifndef  INC_MI32_RECT_H
00196 #include <mi32/rect.h>
00197 #endif
00198 
00199 #ifndef  INC_MI32_LATLONFM_H
00200 #include <mi32/latlonfm.h>
00201 #endif
00202 
00203 #ifndef  INC_MI32_UNITCONV_H
00204 #include <mi32/unitconv.h>
00205 #endif
00206 
00207 #ifndef  INC_MI32_SIMPLEAR_H
00208 #include <mi32/simplear.h>
00209 #endif
00210 
00211 #ifndef  INC_MI32_ICONID_H
00212 #include <mi32/iconid.h>
00213 #endif
00214 
00215 struct TEXTSTYLE;
00216 
00217 namespace MGUI {
00218 
00219 
00220 //===================================================================================================================
00221 //! Enum used to specify which keys are pressed during a message handler.
00222 //! NOTE:  These are exactly equivilant to some Windows constants.
00223 //! The Alt KEYSTATE is not here because there is no mask for it in X
00224 enum KEYSTATE {
00225    KEYSTATE_None     = 0x0000,
00226    KEYSTATE_Ctrl     = 0x0002,
00227    KEYSTATE_Control  = 0x0002,
00228    KEYSTATE_Shift    = 0x0004
00229    };
00230 
00231 DEFINE_ENUM_OP_BITWISE(MGUI::KEYSTATE);
00232 
00233 //===================================================================================================================
00234 //! Base class for "single" graphical user interface controls.
00235 //!
00236 //! There are two basic types of 'controls' which can be used in user interface implementation,
00237 //! controls which the user can interact with and 'static' controls which the user cannot change
00238 //! directly.
00239 //!
00240 //! All controls which the user can manipulate also encapsulate information about the current
00241 //! 'state' of the control (except for MGUI::CTRL_PUSHBUTTON as explained below).  There are three ways
00242 //! to use each of these controls in a program (in order of convenience):
00243 //!
00244 //!      -# If changing the state of a control has no other immediate effect then the control class
00245 //!         may be used directly and the state information retrieved when needed, such as when the
00246 //!         user presses 'OK' on the dialog.  This option is not available for MGUI::CTRL_PUSHBUTTON as
00247 //!         pressing a button must always have some other affect and MGUI::CTRL_PUSHBUTTON contains no
00248 //!         'state' information.
00249 //!      -# Use the template version of the control and specify a callback 'container' and callback
00250 //!         method pointer for the control.  This allows the callback to be a method of the 'container'
00251 //!         class (usually the dialog, page or main window) thus allowing access to other controls in
00252 //!         the container.  This is similar to MFC message maps and avoids the common need to include
00253 //!         a reference or pointer to the container in a subclass.  Templates for controls with a
00254 //!         single On... virtual method will generally include the container and method pointer as
00255 //!         parameters to the Create() methods.  Templates for controls with multiple On... virtual
00256 //!         methods will generally have a SetFunc... method for each corresponding On... virtual
00257 //!         method in their base class and will not override the Create() methods.
00258 //!      -# Inherit from the control class and override the On... virtual method to perform task
00259 //!         specific processing.  This is simplest if no reference to the containing dialog or
00260 //!         window is necessary.  Also for some control types, the template version itself may be
00261 //!         inherited from to override other virtual methods, such as MGUI::CTRL_EDIT_... validation
00262 //!         methods.
00263 //!
00264 class CTRL : public MGUI::FORM {
00265    public:
00266 
00267       //! Destructor.
00268       virtual ~CTRL (
00269          ) = 0;
00270 
00271       //! Get interface 'background' color.
00272       static const COLOR& GetBackgroundColor (
00273          );
00274 
00275    #ifdef WIN32_MFC
00276       //! Get "client rectangle" for the primary control window (MFC only).
00277       void GetClientRect (
00278          LPRECT lpRect
00279          ) const { m_pWnd->GetClientRect(lpRect); }
00280    #endif
00281 
00282    #ifdef WIN32_MFC
00283       //! Get the CWnd of the primary control (MFC only).
00284       CWnd* GetCWnd (
00285          ) { return (m_pWnd); }
00286    #endif
00287 
00288    #ifdef X_NATIVE
00289       //! Get the Widget for the control or container if multiple controls (X only).
00290       //! The widget should only be used for attachment, do not assume the
00291       //! widget is of a particular type.
00292       Widget GetWidget (
00293          ) { return (m_widget); }
00294    #endif
00295 
00296    #ifdef WIN32_MFC
00297       //! Invalidate the entire client area (MFC only).
00298       //! This will force it to redraw the next WM_PAINT message occurs.
00299       void Invalidate (
00300          bool erase = true
00301          ) { m_pWnd->Invalidate(erase); }
00302    #endif
00303 
00304    #ifdef WIN32_MFC
00305       //! Invalidate a rectangle in the client area (MFC only).
00306       //! This will force it to redraw the next WM_PAINT message occurs.
00307       void InvalidateRect (
00308          const LRECT2D& lrect,
00309          bool erase = true
00310          ) { 
00311          CRect rect(lrect.xinit, lrect.yinit, lrect.xlast, lrect.ylast);
00312          m_pWnd->InvalidateRect(rect, erase); 
00313          }
00314    #endif
00315 
00316       //! Determine if control has been created.
00317       //! @return true if created, false if not.
00318       virtual bool IsCreated (
00319          ) const;
00320 
00321       //! Determine if control is enabled for keyboard or mouse input.
00322       //! @return true if enabled, false if not, or if not yet created.
00323       virtual bool IsEnabled (
00324          ) const;
00325 
00326    #ifdef WIN32_MFC
00327       //! Called to process messages before translation (MFC only).
00328       //! Allows a control to trap messages before they get passed.  Should return
00329       //! 'true' if the message was translated and should not be dispatched or
00330       //! 'false' if the message was not handled and should be dispatched.
00331       //! The control must also be added to the root layout's pretranslation list via
00332       //! MGUI::LAYOUT_PANE_BASE::PreTransListAddCtrl().  This should be done in the
00333       //! control's Create() method.
00334       virtual bool PreTranslateMessageHook (
00335          MSG *pMsg
00336          ) { return (false); }
00337    #endif
00338 
00339       //! Set whether mouse or keyboard input to control is allowed.
00340       virtual void SetEnabled (
00341          bool enabled = true
00342          );
00343 
00344    #ifdef WIN32_MFC
00345       //! Allow the window to be redrawn (MFC only).
00346       void SetRedraw (
00347          bool redraw = true
00348          ) { m_pWnd->SetRedraw(redraw); }
00349    #endif
00350 
00351       //! Set whether control is visible or not.
00352       virtual void SetVisible (
00353          bool visible = true
00354          );
00355 
00356    #ifdef WIN32_MFC
00357       //! Generate a WM_PAINT message if the window needs to be updated
00358       void UpdateWindow (
00359          ) { m_pWnd->UpdateWindow(); }
00360    #endif
00361 
00362    protected:
00363 
00364    #ifdef WIN32_MFC
00365       CWnd *m_pWnd;           //!< Pointer to actual control in derived class
00366 
00367       //! Constructor (MFC version).
00368       CTRL (
00369          CWnd& wnd
00370          ): m_pWnd(&wnd) { }
00371 
00372       CTRL (
00373          CWnd *pWnd
00374          ): m_pWnd(pWnd) { }
00375 
00376    #endif
00377 
00378    #ifdef X_NATIVE
00379       Widget m_widget;
00380 
00381       //! Constructor (X version).
00382       CTRL (
00383          ): m_widget(0) { }
00384 
00385       //! Add 'Destroy' callback for widget.
00386       void AddDestroyCallback (
00387          );
00388 
00389       //! Called if widgets are destroyed before CTRL class instance.
00390       //! Will not be called if CTRL class instance is destroyed before widgets.
00391       //! Usually just sets widgets to NULL so won't be referenced in destructor.
00392       //! Derived class must call corresponding base class method AFTER performing its own processing.
00393       virtual void OnDestroy (
00394          );
00395    #endif
00396 
00397    private:
00398       #ifndef GENERATING_DOXYGEN_OUTPUT
00399 
00400    #ifdef X_NATIVE
00401       static void CB_Destroy (Widget, CTRL*, void*);
00402    #endif
00403 
00404       // MGUI::FORM overrides.
00405       virtual void v_SetFocus () const;
00406 
00407       CTRL (const CTRL&);
00408       CTRL& operator= (const CTRL&);
00409       #endif // GENERATING_DOXYGEN_OUTPUT
00410    };
00411 
00412 
00413 //===================================================================================================================
00414 //! Non-editable label control.
00415 class CTRL_LABEL : public MGUI::CTRL {
00416    public:
00417 
00418       enum STYLE {
00419          STYLE_LeftNoWrap,                      //!< Left-justify text without word wrapping
00420          STYLE_Left,                            //!< Left-justify, MFC may word-wrap if too long
00421          STYLE_Center,                          //!< Center, MFC may word-wrap if too long
00422          STYLE_Right                            //!< Right-justify, MFC may word-wrap if too long
00423          };
00424 
00425       //! Constructor.
00426       CTRL_LABEL (
00427          )
00428       #ifdef WIN32_MFC
00429          :
00430          m_icon(0),
00431          CTRL(m_ctrl)
00432       #endif
00433          { }
00434 
00435       ~CTRL_LABEL (
00436          );
00437 
00438       //! Create control with label from resource lookup.
00439       void Create (
00440          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00441          const char* label,                     //!< Label string for resource lookup
00442          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00443          STYLE style = STYLE_LeftNoWrap
00444          );
00445 
00446       //! Create control with MISTRING or TEXTID label.
00447       void Create (
00448          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00449          const MISTRING& label,                 //!< Label string (allows TEXTID)
00450          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00451          STYLE style = STYLE_LeftNoWrap
00452          );
00453 
00454       //! Create control with ICONID
00455       void Create (
00456          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00457          ICONID iconid,                         //!< ICON to use as the label
00458          const char *tooltip,
00459          int iconsize = 0
00460          );
00461 
00462       //! Create control with ICONID with MISTRING or TEXTID tooltip
00463       void Create (
00464          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00465          ICONID iconid,                         //!< ICON to use as the label
00466          const MISTRING& tooltip,               //!< tooltip string (allows TEXTID)
00467          int iconsize = 0
00468          );
00469 
00470    #ifdef WIN32_MFC
00471       //! Get reference to MFC control (MFC only).
00472       CStatic& GetCtrl (
00473          ) { return (m_ctrl); }
00474    #endif
00475 
00476       //! Set new label from resource lookup.
00477       void SetLabel (
00478          const char *string
00479          );
00480 
00481       //! Set new label from Unicode string.
00482       void SetLabel (
00483          const MISTRING& string
00484          );
00485 
00486    private:
00487       #ifndef GENERATING_DOXYGEN_OUTPUT
00488 
00489    #ifdef WIN32_MFC
00490       CStatic m_ctrl;
00491       HICON m_icon;
00492 
00493       void CreateIconWin (
00494          MGUI::LAYOUT_PANE_BASE& ParentPane,
00495          ICONID iconid,
00496          const CString& label,
00497          int iconsize
00498          );
00499 
00500       void CreateWin (
00501          MGUI::LAYOUT_PANE_BASE& ParentPane,
00502          const CString& label,
00503          MGUI::LAYOUT_SIZEALIGN sizealign,
00504          STYLE style
00505          );
00506    #endif
00507 
00508    #ifdef X_NATIVE
00509       bool CreateIcon (
00510          MGUI::LAYOUT_PANE_BASE& ParentPane,
00511          ICONID iconid,
00512          const char *name,
00513          int iconsize
00514          );
00515 
00516       void CreateX (
00517          MGUI::LAYOUT_PANE_BASE& ParentPane,
00518          XTARGS& args,
00519          const char *name,
00520          MGUI::LAYOUT_SIZEALIGN sizealign,
00521          STYLE style
00522          );
00523    #endif
00524 
00525       CTRL_LABEL (const CTRL_LABEL&);
00526       CTRL_LABEL& operator= (const CTRL_LABEL&);
00527       #endif // GENERATING_DOXYGEN_OUTPUT
00528    };
00529 
00530 
00531 //===================================================================================================================
00532 //!   Group Box control, equivalent to XmFrame.
00533 class CTRL_GROUPBOX : public MGUI::CTRL {
00534    public:
00535 
00536       //! Constructor.
00537       CTRL_GROUPBOX (
00538          );
00539 
00540       //! Destructor.
00541       virtual ~CTRL_GROUPBOX (
00542          );
00543 
00544       //! Cast to MGUI::LAYOUT_PANE_BASE& for use as parent to other controls.
00545       operator MGUI::LAYOUT_PANE_BASE& (
00546          ) { return (m_GroupBoxPane); }
00547 
00548       //! Create control with no label.
00549       void Create (
00550          MGUI::LAYOUT_PANE_BASE& ParentPane, //!< Parent pane
00551          MGUI::LAYOUT_ORIENTATION orientation = MGUI::LAYOUT_ORIENTATION_Vertical,
00552          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00553          int ChildSpacing = 4,               //!< Spacing between children of group box
00554          int ExtraBorder = 0                 //!< Extra border around inside of group box, in addition to ChildSpacing
00555          );
00556 
00557       //! Create control with label from resource lookup.
00558       void Create (
00559          MGUI::LAYOUT_PANE_BASE& ParentPane, //!< Parent pane
00560          const char* string,                 //!< Label string for resource lookup
00561          MGUI::LAYOUT_ORIENTATION orientation = MGUI::LAYOUT_ORIENTATION_Vertical,
00562          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00563          int ChildSpacing = 4,               //!< Spacing between children of group box
00564          int ExtraBorder = 0                 //!< Extra border around inside of group box, in addition to ChildSpacing
00565          );
00566 
00567       //! Create control with Unicode label.
00568       void Create (
00569          MGUI::LAYOUT_PANE_BASE& ParentPane, //!< Parent pane
00570          const MISTRING& string,             //!< Label string
00571          MGUI::LAYOUT_ORIENTATION orientation = MGUI::LAYOUT_ORIENTATION_Vertical,
00572          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize,
00573          int ChildSpacing = 4,               //!< Spacing between children of group box
00574          int ExtraBorder = 0                 //!< Extra border around inside of group box, in addition to ChildSpacing
00575          );
00576 
00577    #ifdef WIN32_MFC
00578       //! Get reference to MFC control (MFC only).
00579       CButton& GetCtrl (
00580          ) { return (m_ctrl); }
00581    #endif
00582 
00583       //! Get layout pane to invoke options on it.
00584       MGUI::LAYOUT_PANE_BASE& GetPane (
00585          ) { return (m_GroupBoxPane); }
00586 
00587       void SetLabelText (
00588          const MISTRING& label
00589          );
00590 
00591    private:
00592 
00593       #ifndef GENERATING_DOXYGEN_OUTPUT
00594       class LAYOUT_PANE : public MGUI::LAYOUT_PANE_BASE {
00595          public:
00596             LAYOUT_PANE (
00597                ) { }
00598             virtual ~LAYOUT_PANE (
00599                ) { }
00600             void Create (
00601                #ifdef WIN32_MFC
00602                MGUI::LAYOUT_PANE_BASE& ParentPane,
00603                CButton& ctrl,
00604                #else
00605                Widget FrameWidget,
00606                #endif
00607                MGUI::LAYOUT_ORIENTATION orientation,
00608                MGUI::LAYOUT_SIZEALIGN sizealign,
00609                int ChildSpacing,
00610                int ExtraBorder,
00611                int TopExtra
00612                );
00613          private:
00614             LAYOUT_PANE (const LAYOUT_PANE&);
00615             LAYOUT_PANE& operator= (const LAYOUT_PANE&);
00616          };
00617 
00618       LAYOUT_PANE m_GroupBoxPane;
00619 
00620    #ifdef WIN32_MFC
00621       CButton m_ctrl;
00622 
00623       void CreateWin (
00624          MGUI::LAYOUT_PANE_BASE& ParentPane,
00625          const CString& label,
00626          MGUI::LAYOUT_ORIENTATION orientation,
00627          MGUI::LAYOUT_SIZEALIGN sizealign,
00628          int ChildSpacing,
00629          int ExtraBorder
00630          );
00631    #endif   // WIN32_MFC
00632 
00633    #ifdef X_NATIVE
00634       Widget m_label;
00635       void CreateX (
00636          MGUI::LAYOUT_PANE_BASE& ParentPane,
00637          MGUI::LAYOUT_ORIENTATION orientation,
00638          MGUI::LAYOUT_SIZEALIGN sizealign,
00639          int ChildSpacing,
00640          int ExtraBorder
00641          );
00642    #endif
00643 
00644       CTRL_GROUPBOX (const CTRL_GROUPBOX&);
00645       CTRL_GROUPBOX& operator= (const CTRL_GROUPBOX&);
00646       #endif // GENERATING_DOXYGEN_OUTPUT
00647    };
00648 
00649 
00650 //===================================================================================================================
00651 //! PushButton control supporting both text and icon buttons.
00652 class CTRL_PUSHBUTTON : public MGUI::CTRL {
00653    public:
00654 
00655       //! Constructor.
00656       CTRL_PUSHBUTTON (
00657          )
00658       #ifdef WIN32_MFC
00659          : CTRL(m_ctrl), m_ctrl(*this), m_hIcon(0)
00660       #endif
00661          { }
00662 
00663       //! Destructor.
00664       virtual ~CTRL_PUSHBUTTON (
00665          );
00666 
00667       //! Create control with label from resource lookup.
00668       void Create (
00669          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00670          const char* label,                     //!< Label string for resource lookup
00671          bool large = false,                    //!< Create large buttons (for dialogs)
00672          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00673          );
00674 
00675       //! Create control with Unicode label.
00676       void Create (
00677          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00678          const MISTRING& label,                 //!< Label string
00679          bool large = false,                    //!< Create large buttons (for dialogs)
00680          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00681          );
00682 
00683       //! Create control with icon and ToolTip from resource lookup.
00684       void Create (
00685          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00686          ICONID iconid,                         //!< Icon ID
00687          const char* tooltip,                   //!< ToolTip string for resource lookup
00688          int iconsize = 0                       //!< Icon size, 0 for default
00689          );
00690 
00691       //! Create control with icon and ToolTip from resource lookup.
00692       void Create (
00693          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00694          ICONID iconid,                         //!< Icon ID
00695          const MISTRING& tooltip,               //!< ToolTip string
00696          int iconsize = 0                       //!< Icon size, 0 for default
00697          );
00698 
00699    #ifdef WIN32_MFC
00700       //! Get reference to MFC control (MFC only).
00701       CButton& GetCtrl (
00702          ) { return (m_ctrl); }
00703    #endif
00704 
00705    protected:
00706 
00707       //! Called when button is pushed.
00708       virtual void OnPressed (
00709          ) = 0;
00710 
00711    private:
00712       #ifndef GENERATING_DOXYGEN_OUTPUT
00713 
00714    #ifdef WIN32_MFC
00715       class MyButton : public CButton {
00716          public:
00717             MyButton (
00718                CTRL_PUSHBUTTON& guictrl
00719                ): m_guictrl(guictrl)
00720                { }
00721          protected:
00722             afx_msg void OnClicked ();
00723             DECLARE_MESSAGE_MAP()
00724          private:
00725             CTRL_PUSHBUTTON& m_guictrl;
00726          friend class MGUI::CTRL_PUSHBUTTON;
00727          };
00728       friend class MyButton;
00729 
00730       MyButton m_ctrl;
00731       HICON m_hIcon;
00732    #endif   // WIN32_MFC
00733 
00734    #ifdef X_NATIVE
00735       static void CB_PushButton (Widget, CTRL_PUSHBUTTON*, void*);
00736 
00737       bool CreateIcon (
00738          LAYOUT_PANE_BASE& ParentPane,
00739          ICONID iconid,
00740          const char *name,
00741          int iconsize
00742          );
00743 
00744       void CreateWidget (
00745          LAYOUT_PANE_BASE& ParentPane,
00746          XTARGS& args,
00747          const char *name,
00748          bool large = false
00749          );
00750    #endif   // X_NATIVE
00751 
00752       CTRL_PUSHBUTTON (const CTRL_PUSHBUTTON&);
00753       CTRL_PUSHBUTTON& operator= (const CTRL_PUSHBUTTON&);
00754    #endif // GENERATING_DOXYGEN_OUTPUT
00755    };
00756 
00757 
00758 //-------------------------------------------------------------------------------------------------------------------
00759 //! Convenience template for PushButton control to allow method in container class to be called.
00760 //! This template allows a method in a 'container' class to be called when the button is pressed,
00761 //! rather than requiring that a subclass be defined with the OnPressed() virtual method overridden.
00762 template <class _CT> class CTRL_PUSHBUTTON_T : public MGUI::CTRL_PUSHBUTTON {
00763    public:
00764 
00765       //! Constructor.
00766       explicit CTRL_PUSHBUTTON_T (
00767          ): m_pContainer(0), m_pfOnPressed(0) { }
00768 
00769       //! Create control with label from resource lookup.
00770       void Create (
00771          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00772          const char* label,                     //!< Label string for resource lookup
00773          _CT *pContainer,                       //!< Pointer to callback container class
00774          void (_CT::*pfOnPressed)(),            //! Callback function pointer
00775          bool large = false,                    //!< Create large buttons (for dialogs)
00776          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00777          ) {
00778          m_pContainer = pContainer;
00779          m_pfOnPressed = pfOnPressed;
00780          CTRL_PUSHBUTTON::Create(ParentPane,label,large,sizealign);
00781          }
00782 
00783       //! Create control with Unicode label.
00784       void Create (
00785          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00786          const MISTRING& label,                 //!< Label string
00787          _CT *pContainer,                       //!< Pointer to callback container class
00788          void (_CT::*pfOnPressed)(),            //! Callback function pointer
00789          bool large = false,                    //!< Create large buttons (for dialogs)
00790          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00791          ) {
00792          m_pContainer = pContainer;
00793          m_pfOnPressed = pfOnPressed;
00794          CTRL_PUSHBUTTON::Create(ParentPane,label,large,sizealign);
00795          }
00796 
00797       //! Create control with icon and ToolTip from resource lookup.
00798       void Create (
00799          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00800          ICONID iconid,                         //!< Icon ID
00801          const char* tooltip,                   //!< ToolTip string for resource lookup
00802          _CT *pContainer,                       //!< Pointer to callback container class
00803          void (_CT::*pfOnPressed)(),               //! Callback function pointer
00804          int iconsize = 0                       //!< Icon size, 0 for default
00805          ) {
00806          m_pContainer = pContainer;
00807          m_pfOnPressed = pfOnPressed;
00808          CTRL_PUSHBUTTON::Create(ParentPane,iconid,tooltip,iconsize);
00809          }
00810 
00811       //! Create control with icon and ToolTip from resource lookup.
00812       void Create (
00813          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00814          ICONID iconid,                         //!< Icon ID
00815          const MISTRING& tooltip,               //!< ToolTip string
00816          _CT *pContainer,                       //!< Pointer to callback container class
00817          void (_CT::*pfOnPressed)(),            //! Callback function pointer
00818          int iconsize = 0                       //!< Icon size, 0 for default
00819          ) {
00820          m_pContainer = pContainer;
00821          m_pfOnPressed = pfOnPressed;
00822          CTRL_PUSHBUTTON::Create(ParentPane,iconid,tooltip,iconsize);
00823          }
00824 
00825    private:
00826       #ifndef GENERATING_DOXYGEN_OUTPUT
00827       _CT *m_pContainer;
00828       void (_CT::*m_pfOnPressed)();
00829 
00830       virtual void OnPressed (
00831          ) { (m_pContainer->*m_pfOnPressed)(); }
00832       #endif // GENERATING_DOXYGEN_OUTPUT
00833    };
00834 
00835 
00836 //===================================================================================================================
00837 //! Toggle button control supporting both "checkbox" and "radio" behavior with text and icon buttons.
00838 //! Note that in the X version radio behavior between buttons is NOT enforced by this control.  For
00839 //! portability it is recommended that the MGUI::FORM_RADIOBUTTONS class be used to manage a set of
00840 //! radio buttons or that the code enforce radio behavior itself for more complex cases.
00841 class CTRL_TOGGLEBUTTON : public MGUI::CTRL {
00842    public:
00843 
00844       enum STYLE {
00845          STYLE_Check,                           //!< Checkbox style
00846          STYLE_Radio,                           //!< Radiobutton style
00847    #ifdef WIN32_MFC
00848          STYLE_RadioFirst                       //!< Radiobutton style, first in radio group (MFC only)
00849    #endif
00850          };
00851 
00852       //! Constructor.
00853       CTRL_TOGGLEBUTTON (
00854          ):
00855          m_value(false)
00856       #ifdef WIN32_MFC
00857          , CTRL(m_ctrl), m_ctrl(*this), m_hIcon(0)
00858       #endif
00859          { }
00860 
00861       //! Destructor.
00862       virtual ~CTRL_TOGGLEBUTTON (
00863          );
00864 
00865       //! Create with label from resource lookup.
00866       void Create (
00867          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00868          const char* label,                     //!< Label string for resource lookup
00869          STYLE style = STYLE_Check,             //!< Toggle style
00870          bool dftvalue = false,                 //!< Default value
00871          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00872          );
00873 
00874       //! Create with Unicode label.
00875       void Create (
00876          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00877          const MISTRING& label,                 //!< Label string
00878          STYLE style = STYLE_Check,             //!< Toggle style
00879          bool dftvalue = false,                 //!< Default value
00880          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
00881          );
00882 
00883       //! Create icon togglebutton with ToolTip from resource lookup.
00884       void Create (
00885          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00886          ICONID iconid,                         //!< Icon ID
00887          const char* tooltip,                   //!< ToolTip string
00888          STYLE style = STYLE_Check,             //!< Toggle style
00889          bool dftvalue = false,                 //!< Default value
00890          int iconsize = 0                       //!< Icon size, 0 for default
00891          );
00892 
00893       //! Create icon togglebutton with Unicode ToolTip.
00894       void Create (
00895          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00896          ICONID iconid,                         //!< Icon ID
00897          const MISTRING& tooltip,                  //!< ToolTip string
00898          STYLE style = STYLE_Check,             //!< Toggle style
00899          bool dftvalue = false,                 //!< Default value
00900          int iconsize = 0                       //!< Icon size, 0 for default
00901          );
00902 
00903    #ifdef WIN32_MFC
00904       //! Get reference to MFC control (MFC only).
00905       CButton& GetCtrl (
00906          ) { return (m_ctrl); }
00907    #endif
00908 
00909       //! Get current toggle setting.
00910       bool GetValue (
00911          ) const
00912          #ifdef X_NATIVE
00913             { return (m_value); }
00914          #else
00915             ;
00916          #endif
00917 
00918       //! Set control value.
00919       void SetValue (
00920          bool value,                            //!< Value to set
00921          bool notify = true                     //!< If true call OnChangeValue() if value changed
00922          );
00923 
00924    protected:
00925 
00926       //! Called when button is pushed.
00927       virtual void OnPressed (
00928          );
00929 
00930    private:
00931       #ifndef GENERATING_DOXYGEN_OUTPUT
00932 
00933       bool m_value;
00934 
00935    #ifdef WIN32_MFC
00936       class MyButton : public CButton {
00937          public:
00938             MyButton (
00939                CTRL_TOGGLEBUTTON& guictrl
00940                ): m_guictrl(guictrl)
00941                { }
00942          protected:
00943             afx_msg void OnClicked ();
00944             DECLARE_MESSAGE_MAP()
00945          private:
00946             CTRL_TOGGLEBUTTON& m_guictrl;
00947          friend class MGUI::CTRL_TOGGLEBUTTON;
00948          };
00949       friend class MyButton;
00950 
00951       MyButton m_ctrl;
00952       HICON m_hIcon;
00953    #endif   // WIN32_MFC
00954 
00955    #ifdef X_NATIVE
00956       static void CB_ToggleButton (Widget, CTRL_TOGGLEBUTTON*, void*);
00957 
00958       bool CreateIcon (
00959          MGUI::LAYOUT_PANE_BASE& ParentPane,
00960          ICONID iconid,
00961          const char *name,
00962          STYLE style,
00963          bool dftvalue,
00964          int iconsize
00965          );
00966 
00967       void CreateWidget (
00968          MGUI::LAYOUT_PANE_BASE& ParentPane,
00969          XTARGS& args,
00970          const char* label,
00971          STYLE style,
00972          bool dftvalue
00973          );
00974    #endif   // X_NATIVE
00975 
00976       CTRL_TOGGLEBUTTON (const CTRL_TOGGLEBUTTON&);
00977       CTRL_TOGGLEBUTTON& operator= (const CTRL_TOGGLEBUTTON&);
00978       #endif // GENERATING_DOXYGEN_OUTPUT
00979    };
00980 
00981 
00982 //-------------------------------------------------------------------------------------------------------------------
00983 //! Convenience template for Toggle button to allow method in container class to be called.
00984 template <class _CT> class CTRL_TOGGLEBUTTON_T : public MGUI::CTRL_TOGGLEBUTTON {
00985    public:
00986 
00987       //! Constructor.
00988       explicit CTRL_TOGGLEBUTTON_T (
00989          ): m_pContainer(0), m_pfOnPressed(0) { }
00990 
00991       //! Create with label from resource lookup.
00992       void Create (
00993          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
00994          const char* label,                     //!< Label string for resource lookup
00995          _CT *pContainer,                       //!< Pointer to callback container class
00996          void (_CT::*pfOnPressed)(),               //! Callback function pointer
00997          STYLE style = STYLE_Check,             //!< Toggle style
00998          bool dftvalue = false,                 //!< Default value
00999          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
01000          ) {
01001          m_pContainer = pContainer;
01002          m_pfOnPressed = pfOnPressed;
01003          CTRL_TOGGLEBUTTON::Create(ParentPane,label,style,dftvalue,sizealign);
01004          }
01005 
01006       //! Create with Unicode label.
01007       void Create (
01008          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01009          const MISTRING& label,                 //!< Label string
01010          _CT *pContainer,                       //!< Pointer to callback container class
01011          void (_CT::*pfOnPressed)(),               //! Callback function pointer
01012          STYLE style = STYLE_Check,             //!< Toggle style
01013          bool dftvalue = false,                 //!< Default value
01014          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
01015          ) {
01016          m_pContainer = pContainer;
01017          m_pfOnPressed = pfOnPressed;
01018          CTRL_TOGGLEBUTTON::Create(ParentPane,label,style,dftvalue,sizealign);
01019          }
01020 
01021       //! Create icon with ToolTip from resource lookup.
01022       void Create (
01023          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01024          ICONID iconid,                         //!< Icon ID
01025          const char* tooltip,                   //!< ToolTip string
01026          _CT *pContainer,                       //!< Pointer to callback container class
01027          void (_CT::*pfOnPressed)(),               //! Callback function pointer
01028          STYLE style = STYLE_Check,             //!< Toggle style
01029          bool dftvalue = false,                 //!< Default value
01030          int iconsize = 0                       //!< Icon size, 0 for default
01031          ) {
01032          m_pContainer = pContainer;
01033          m_pfOnPressed = pfOnPressed;
01034          CTRL_TOGGLEBUTTON::Create(ParentPane,iconid,tooltip,style,dftvalue,iconsize);
01035          }
01036 
01037       //! Create icon with Unicode ToolTip.
01038       void Create (
01039          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01040          ICONID iconid,                         //!< Icon ID
01041          const MISTRING& tooltip,                  //!< ToolTip string
01042          _CT *pContainer,                       //!< Pointer to callback container class
01043          void (_CT::*pfOnPressed)(),               //! Callback function pointer
01044          STYLE style = STYLE_Check,             //!< Toggle style
01045          bool dftvalue = false,                 //!< Default value
01046          int iconsize = 0                       //!< Icon size, 0 for default
01047          ) {
01048          m_pContainer = pContainer;
01049          m_pfOnPressed = pfOnPressed;
01050          CTRL_TOGGLEBUTTON::Create(ParentPane,iconid,tooltip,style,dftvalue,iconsize);
01051          }
01052 
01053    private:
01054       #ifndef GENERATING_DOXYGEN_OUTPUT
01055       _CT *m_pContainer;
01056       void (_CT::*m_pfOnPressed)();
01057 
01058       virtual void OnPressed (
01059          ) { (m_pContainer->*m_pfOnPressed)(); }
01060       #endif // GENERATING_DOXYGEN_OUTPUT
01061    };
01062 
01063 
01064 //===================================================================================================================
01065 //! Base class for 'edit' controls.
01066 class CTRL_EDIT_BASE : public MGUI::CTRL {
01067    public:
01068 
01069       //! Constructor.
01070       CTRL_EDIT_BASE (
01071          );
01072 
01073       //! Destructor.
01074       ~CTRL_EDIT_BASE (
01075          );
01076 
01077       //! Clear the current selection
01078       void ClearSelection (
01079          )
01080       #ifdef WIN32_MFC
01081          { m_ctrl.Clear(); }
01082       #endif
01083          ;
01084 
01085       //! Copy the current selection to the clipboard
01086       void CopySelection (
01087          )
01088       #ifdef WIN32_MFC
01089          { m_ctrl.Copy(); }
01090       #endif
01091          ;
01092 
01093       //! Cut the current selection to the clipboard
01094       void CutSelection (
01095          )
01096       #ifdef WIN32_MFC
01097          { m_ctrl.Cut(); }
01098       #endif
01099          ;
01100 
01101    #ifdef WIN32_MFC
01102       //! Get reference to MFC control (MFC only).
01103       CEdit& GetCtrl (
01104          ) { return (m_ctrl); }
01105    #endif
01106 
01107       //! Returns true if contents of the edit-control have been modified by user, false if not.
01108       //! Use SetModify() to reset.
01109       const bool GetModify (
01110          ) const {
01111       #ifdef WIN32_MFC
01112          return (m_ctrl.GetModify() != FALSE);
01113       #else
01114          return (m_UserEdited);
01115       #endif
01116          }
01117 
01118       //! Get the current selection of the edit control.
01119       //!   If nStartChar == nEndChar, nothing is selected.
01120       void GetSelection (
01121          int& nStartChar,     //!< Receives the first character in the current selection
01122          int& nEndChar        //!< Receives the first non-selected character past the end of the current selection
01123          ) const
01124       #ifdef WIN32_MFC
01125          { m_ctrl.GetSel(nStartChar,nEndChar); }
01126       #endif
01127          ;
01128 
01129       //! Set the maximim text length in characters
01130       void SetMaxLength (
01131          int length
01132          );
01133 
01134       //! Set or clear the "modified" state of the edit control.
01135       void SetModify (
01136          bool modified = true
01137          ) {
01138       #ifdef WIN32_MFC
01139          m_ctrl.SetModify(modified);
01140       #else
01141          m_UserEdited = modified;
01142       #endif
01143          }
01144 
01145       //! Set whether value is read-only or not.
01146       void SetReadOnly (
01147          bool ReadOnly = true                //!< True if read only, false if not
01148          ) {
01149       #ifdef WIN32_MFC
01150          m_ctrl.SetReadOnly(ReadOnly);
01151       #else
01152          MxSetTextEditable(m_widget,!ReadOnly);
01153       #endif
01154          }
01155 
01156       //! Select range of characters in string.
01157       void SetSelection (
01158          int StartChar = 0,                  //!< Starting character position in string, 0 for beginning
01159          int EndChar = -1,                   //!< Ending character position, -1 for end of string
01160          bool NoScroll = true                //!< Indicates whether to scroll caret into view
01161          )
01162       #ifdef WIN32_MFC
01163          { m_ctrl.SetSel(StartChar,EndChar,NoScroll); }
01164       #endif
01165          ;
01166 
01167       //! Set set of 'valid' or 'invalid' characters.
01168       //! This does not alter the current contents, if any.
01169       void SetValidChars (
01170          const MIUNICODE* string,               //!< Characters valid or invalid to enter
01171          bool invert = false                 //!< Allow all but specified characters
01172          );
01173 
01174    protected:
01175 
01176    #ifdef WIN32_MFC
01177       class MyEdit : public CEdit {
01178          public:
01179             MyEdit (
01180                CTRL_EDIT_BASE& guictrl
01181                ): m_guictrl(guictrl)
01182                { }
01183             virtual ~MyEdit (
01184                ) { }
01185             virtual BOOL PreCreateWindow (CREATESTRUCT& cs);
01186          protected:
01187             afx_msg void OnChange ();
01188             afx_msg void OnKillFocus ();
01189             DECLARE_MESSAGE_MAP()
01190          private:
01191             #ifndef GENERATING_DOXYGEN_OUTPUT
01192             CTRL_EDIT_BASE& m_guictrl;
01193             #endif // GENERATING_DOXYGEN_OUTPUT
01194          };
01195       friend class MyEdit;
01196       MyEdit m_ctrl;
01197    #endif
01198 
01199    #ifdef X_NATIVE
01200       bool m_UserEdited;
01201    #endif
01202       bool m_HasValue;
01203 
01204       //! Check that all characters in string are in valid set.
01205       //!   @return 'true' if valid, 'false' if not
01206       bool CheckValidChars (
01207          MISTRING& string                       //!< String to be checked
01208          ) const;
01209 
01210       void CreateCtrl (
01211          LAYOUT_PANE_BASE& ParentPane,
01212          int width,                             //!< Width in 'typical' characters
01213          int height,                            //!< Height in text lines, 0 for single-line edit
01214          bool RightJustify,
01215          bool ReadOnly,
01216          bool Opaque,
01217          bool WidthInPixels,
01218          LAYOUT_SIZEALIGN sizealign
01219          );
01220 
01221       bool GetEditStr (
01222          MISTRING& str
01223          ) const;
01224 
01225       // Send value change notification via OnChangeValue.
01226       void NotifyChanged (
01227          ) { OnChangeValue(); }
01228 
01229       //! Called internally to update text control from specified string.
01230       void UpdateCtrl (
01231          const MISTRING& string
01232          );
01233 
01234       //! Called internally to update control-specific data from edit control.
01235       //! Derived class must call corresponding base class method AFTER performing its own processing.
01236       virtual void UpdateValue (bool notify = true);
01237 
01238    private:
01239    #ifndef GENERATING_DOXYGEN_OUTPUT
01240 
01241    #ifdef X_NATIVE
01242       Widget m_TraversalWidget;
01243       XmTraversalDirection m_TraversalDir;
01244       bool m_InternalModify;
01245       int m_MaxLength;
01246    #endif
01247 
01248       bool m_ValidInvert;
01249       MISTRING m_ValidChars;
01250 
01251    #ifdef X_NATIVE
01252       static void CB_Activate (Widget, CTRL_EDIT_BASE*, void*);
01253       static void CB_Focus (Widget, CTRL_EDIT_BASE*, void*);
01254       static void CB_LosingFocus (Widget, CTRL_EDIT_BASE*, void*);
01255       static void CB_ModifyVerify (Widget, CTRL_EDIT_BASE*, void*);
01256       static void CB_ValueChanged (Widget, CTRL_EDIT_BASE*, XmAnyCallbackStruct*);
01257    #endif
01258 
01259       CTRL_EDIT_BASE (const CTRL_EDIT_BASE&);
01260       CTRL_EDIT_BASE& operator= (const CTRL_EDIT_BASE&);
01261    #endif // GENERATING_DOXYGEN_OUTPUT
01262 
01263       // CTRL_EDIT_BASE Overridables
01264 
01265       //! Called when user presses <Enter> in edit control.
01266       virtual void OnActivate ();
01267 
01268       //! Called when value is changed after validation.
01269       //! If the user modifies the text in the edit control this will not be called until the control loses "focus".
01270       virtual void OnChangeValue ();
01271 
01272       //! Called when user modifies the text in the edit control.
01273       //! The actual value does not get updated until the control loses focus or GetValue() is called.
01274       virtual void OnUserEdit ();
01275 
01276    };
01277 
01278 
01279 //===================================================================================================================
01280 //! String 'edit' control.
01281 class CTRL_EDIT_STRING : public MGUI::CTRL_EDIT_BASE {
01282    public:
01283 
01284       enum FLAGS {
01285          FLAG_Default =       0x0000,
01286          FLAG_RightJustify =  0x0001,     //!< Right-justify value, default is to left-justify
01287          FLAG_ReadOnly =      0x0002,     //!< User cannot change value
01288          FLAG_Opaque =        0x0004,     //!< Show '*'s for password input
01289          FLAG_WidthInPixels = 0x0008,     //!< Width specified in pixels
01290          };
01291 
01292       //! Constructor.
01293       CTRL_EDIT_STRING (
01294          );
01295 
01296       //! Destructor.
01297       virtual ~CTRL_EDIT_STRING (
01298          );
01299 
01300       //! Clear to empty string.
01301       void ClearValue (
01302          bool notify = true                     //!< Call OnChangeValue() if control has already been created
01303          );
01304 
01305       //! Create control.
01306       void Create (
01307          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01308          int maxlen,                            //!< Maximum number of characters allowed in string, not including termination
01309          int width = 0,                         //!< Width in 'typical' characters, minimum if can expand based on sizealign
01310          FLAGS flags = FLAG_Default,
01311          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedHeight
01312          );
01313 
01314       //! Get current string value.
01315       const MISTRING& GetValue (
01316          );
01317 
01318       //! Read value from INI file.
01319       //! If Create() has already been performed the control's state will be updated.
01320       void IniRead (
01321          INIHANDLE IniHandle,                //!< Handle to INI file to read from, 0 for default
01322          const char *IniGroup,               //!< INI group to read from
01323          const char *IniField,               //!< INI field to read from
01324          bool notify = true                  //!< Call OnChangeValue() if control has already been created
01325          );
01326 
01327       //! Write current value to INI file.
01328       void IniWrite (
01329          INIHANDLE IniHandle,                //!< Handle to INI file to read from, 0 for default
01330          const char *IniGroup,               //!< INI group to read from
01331          const char *IniField                //!< INI field to read from
01332          ) const { ::IniWrite(IniHandle,IniGroup,IniField,m_value); }
01333 
01334       //! Set current string value with validation.
01335       //! OnValidate() will be called and if valid, the string will be updated.
01336       //! No comparison is made with the current string value.
01337       void SetValue (
01338          const MIUNICODE* string,               //!< New string to set
01339          bool notify = true                  //!< Call OnChangeValue() if string actually updated
01340          );
01341 
01342    protected:
01343 
01344       //! Validate the string and alter if possible/necessary.
01345       //! Derived class must call corresponding base class method BEFORE performing its own processing.
01346       //!   @return 'true' if string could be validated, 'false' if not
01347       virtual bool OnValidate (
01348          MISTRING& string                    //!< String to be validated
01349          );
01350 
01351    private:
01352       #ifndef GENERATING_DOXYGEN_OUTPUT
01353 
01354       MISTRING m_value;
01355 
01356       //! Called internally to update control-specific data from edit control.
01357       virtual void UpdateValue (bool notify = true);
01358 
01359       CTRL_EDIT_STRING (const CTRL_EDIT_STRING&);
01360       CTRL_EDIT_STRING& operator= (const CTRL_EDIT_STRING&);
01361       #endif // GENERATING_DOXYGEN_OUTPUT
01362    };
01363 
01364 DEFINE_ENUM_OPERATORS(MGUI::CTRL_EDIT_STRING::FLAGS);
01365 
01366 
01367 //-------------------------------------------------------------------------------------------------------------------
01368 //! Convenience template for String 'edit' control to allow method in container class to be called.
01369 template <class _CT> class CTRL_EDIT_STRING_T : public MGUI::CTRL_EDIT_STRING {
01370    public:
01371 
01372       //! Constructor.
01373       explicit CTRL_EDIT_STRING_T (
01374          _CT *pContainer
01375          ): m_pContainer(pContainer), m_pfOnChangeValue(0), m_pfOnUserEdit(0), m_pfOnValidate(0), m_pfOnActivate(0)
01376          { }
01377 
01378       //! Set container pointer.
01379       //! Container may also be specified in constructor.
01380       void SetContainer (
01381          _CT *pContainer
01382          ) { m_pContainer = pContainer; }
01383 
01384       //! Set container method to call for OnActivate().
01385       void SetFuncActivate (
01386          void (_CT::*pfOnActivate)()
01387          ) { m_pfOnActivate = pfOnActivate; };
01388 
01389       //! Set container method to call for OnChangeValue().
01390       void SetFuncChangeValue (
01391          void (_CT::*pfOnChangeValue)()
01392          ) { m_pfOnChangeValue = pfOnChangeValue; };
01393 
01394       //! Set container method to call for OnUserEdit().
01395       void SetFuncUserEdit (
01396          void (_CT::*pfOnUserEdit)()
01397          ) { m_pfOnUserEdit = pfOnUserEdit; };
01398 
01399       //! Set container method to call for OnValidate().
01400       void SetFuncValidate (
01401          bool (_CT::*pfOnValidate)(MISTRING& string)
01402          ) { m_pfOnValidate = pfOnValidate; };
01403 
01404    private:
01405       #ifndef GENERATING_DOXYGEN_OUTPUT
01406       _CT *m_pContainer;
01407       void (_CT::*m_pfOnChangeValue)();
01408       void (_CT::*m_pfOnUserEdit)();
01409       bool (_CT::*m_pfOnValidate)(MISTRING&);
01410       void (_CT::*m_pfOnActivate)();
01411 
01412       virtual void OnChangeValue (
01413          ) { if (m_pfOnChangeValue != 0) (m_pContainer->*m_pfOnChangeValue)(); }
01414 
01415       virtual void OnActivate (
01416          ) { if (m_pfOnActivate != 0) (m_pContainer->*m_pfOnActivate)(); }
01417 
01418       virtual void OnUserEdit (
01419          ) { if (m_pfOnUserEdit != 0) (m_pContainer->*m_pfOnUserEdit)(); }
01420 
01421       virtual bool OnValidate (
01422          MISTRING& str
01423          ) {
01424          if (m_pfOnValidate != 0) return((m_pContainer->*m_pfOnValidate)(str));
01425          return (CTRL_EDIT_STRING::OnValidate(str));
01426          }
01427       #endif // GENERATING_DOXYGEN_OUTPUT
01428    };
01429 
01430 
01431 //===================================================================================================================
01432 //! Form consisting of label and string edit field.
01433 class FORM_EDIT_STRING : public MGUI::FORM_COMPOSITE {
01434    public:
01435       //! Constructor.
01436       FORM_EDIT_STRING (
01437          );
01438 
01439       //! Destructor.
01440       virtual ~FORM_EDIT_STRING (
01441          );
01442 
01443       //! Clear to empty string.
01444       void ClearValue (
01445          bool notify = true                     //!< Call OnChangeValue() if control has already been created
01446          ) { m_editctrl.ClearValue(notify); }
01447 
01448       //! Create form with label from resource lookup.
01449       void Create (
01450          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01451          const char *label,                     //!< Label
01452          int maxlen,                            //!< Maximum number of characters allowed in string, not including termination
01453          int width = 0,                         //!< Width in 'typical' characters, minimum if can expand based on sizing
01454          MGUI::CTRL_EDIT_STRING::FLAGS flags = MGUI::CTRL_EDIT_STRING::FLAG_Default,
01455          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedHeight,
01456          MGUI::CTRL_LABEL::STYLE labelstyle = MGUI::CTRL_LABEL::STYLE_LeftNoWrap
01457          );
01458 
01459       //! Create form with Unicode label.
01460       void Create (
01461          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< Parent pane
01462          const MISTRING& label,                 //!< Label
01463          int maxlen,                            //!< Maximum number of characters allowed in string, not including termination
01464          int width = 0,                         //!< Width in 'typical' characters, minimum if can expand based on sizing
01465          MGUI::CTRL_EDIT_STRING::FLAGS flags = MGUI::CTRL_EDIT_STRING::FLAG_Default,
01466          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedHeight,
01467          MGUI::CTRL_LABEL::STYLE labelstyle = MGUI::CTRL_LABEL::STYLE_LeftNoWrap
01468          );
01469 
01470       //! Retrieve string "edit" control for form.
01471       MGUI::CTRL_EDIT_STRING& GetEditCtrl (
01472          ) { return (m_editctrl); }
01473 
01474       //! Retrieve label control for form.
01475       //! Usually the label control is only retrieved for alignment purposes.
01476       MGUI::CTRL_LABEL& GetLabel (
01477          ) { return (m_label); }
01478 
01479       //! Get current string value.
01480       const MISTRING& GetValue (
01481          ) { return (m_editctrl.GetValue()); }
01482 
01483       //! Read value from INI file.
01484       //! If Create() has already been performed the control's state will be updated.
01485       void IniRead (
01486          INIHANDLE IniHandle,                //!< Handle to INI file to read from, 0 for default
01487          const char *IniGroup,               //!< INI group to read from
01488          const char *IniField,               //!< INI field to read from
01489          bool notify = true                  //!< Call OnChangeValue() if control has already been created
01490          ) { m_editctrl.IniRead(IniHandle,IniGroup,IniField,notify); }
01491 
01492       //! Write current value to INI file.
01493       void IniWrite (
01494          INIHANDLE IniHandle,                //!< Handle to INI file to write to, 0 for default
01495          const char *IniGroup,               //!< INI group to write to
01496          const char *IniField                //!< INI field to write to
01497          ) const { m_editctrl.IniWrite(IniHandle,IniGroup,IniField); }
01498 
01499       //! Set label text using string from resource lookup.
01500       void SetLabel (
01501          const char *label                   //!< New label text
01502          ) { m_label.SetLabel(label); }
01503 
01504       //! Set label text from Unicode string.
01505       void SetLabel (
01506          const MISTRING& label                  //!< New label text
01507          ) { m_label.SetLabel(label); }
01508 <