layout.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/layout.h 
00003  * \brief MGUI::LAYOUT class definitions
00004  *
00005  * \if NODOC
00006  * $Id: layout.h_v 1.29 2004/07/28 20:52:23 mju Exp $
00007  *
00008  * $Log: layout.h_v $
00009  * Revision 1.29  2004/07/28 20:52:23  mju
00010  * Change page.create to use mistring.
00011  *
00012  * Revision 1.28  2004/07/26 15:10:28  mju
00013  * Add setminimumsize for equalizer.
00014  *
00015  * Revision 1.27  2004/04/01 21:02:59  dwilliss
00016  * Added SML interface hook method
00017  *
00018  * Revision 1.26  2004/01/12 15:37:48  mju
00019  * Fix comments.
00020  *
00021  * Revision 1.25  2003/10/10 13:05:45  mju
00022  * Include milist header.
00023  *
00024  * Revision 1.24  2003/10/03 19:41:36  linux32build!build
00025  * Doxygen
00026  *
00027  * Revision 1.23  2003/09/25 21:25:01  dwilliss
00028  * Don't capitalize enum any more. Genitor needed it, doxygen doesn't like it.
00029  *
00030  * Revision 1.22  2003/09/15 15:57:37  dwilliss
00031  * Fixed mismatched #ifdefs from Doxygen cleanup
00032  *
00033  * Revision 1.21  2003/09/15 13:49:32  fileserver!dwilliss
00034  * Doxygen
00035  *
00036  * Revision 1.20  2003/04/09 20:51:18  dwilliss
00037  * Don't use _T in templates. Mac's ctype.h defines a global _T
00038  *
00039  * Revision 1.19  2003/03/04 22:35:20  scowan
00040  * Fixed destroy callback for X.
00041  *
00042  * Revision 1.18  2003/03/04 21:45:11  mju
00043  * Make PaneWidget private and add protected method to set.
00044  *
00045  * Revision 1.17  2003/01/27 18:54:34  mju
00046  * Add ComputeText... methods usable for X.
00047  *
00048  * Revision 1.16  2002/12/11 15:21:57  mju
00049  * Move contrib stuff here.
00050  *
00051  * Revision 1.15  2002/10/10 14:24:23  mju
00052  * Only do defns for X/MFC.
00053  *
00054  * Revision 1.14  2002/10/09 15:11:35  mju
00055  * Moved to mgui folder.
00056  *
00057  * Revision 1.13  2002/09/09 14:31:13  mju
00058  * Remove deprecated stuff.
00059  *
00060  * Revision 1.12  2002/08/13 21:01:33  mju
00061  * Use mi32 instead of miwin.
00062  *
00063  * Revision 1.11  2002/08/08 22:04:03  mju
00064  * Add book/page methods for determine/setting active page and enabling/disabling.
00065  *
00066  * Revision 1.10  2002/08/08 17:06:32  mju
00067  * Add GetDlgParent method.
00068  *
00069  * Revision 1.9  2002/07/31 21:34:27  mju
00070  * Automatically add expanding whitespace at end of page pane unless turned off.
00071  *
00072  * Revision 1.8  2002/07/31 21:01:46  mju
00073  * Change PAGECB to not expect 3rd parm to be pointer to page.
00074  *
00075  * Revision 1.7  2001/12/20 21:26:54  mju
00076  * Enum docs.
00077  *
00078  * Revision 1.6  2001/12/18 16:34:32  mju
00079  * Add PANE_BASE::UpdateLayout().
00080  *
00081  * Revision 1.5  2001/12/17 18:51:46  mju
00082  * Add EQUALIZER::SetEqualize method.
00083  *
00084  * Revision 1.4  2001/12/17 16:44:59  dwilliss
00085  * Fixed typo in an enum.
00086  *
00087  * Revision 1.3  2001/12/14 18:52:24  mju
00088  * Remove inline.
00089  *
00090  * Revision 1.2  2001/12/14 15:55:29  mju
00091  * Add X private items.
00092  *
00093  * Revision 1.1  2001/12/13 16:59:56  mju
00094  * Initial revision
00095  * \endif
00096 **/
00097 
00098 #if !defined(INC_MGUI_LAYOUT_H) && (defined(X_NATIVE) || defined(WIN32_MFC))
00099 #define  INC_MGUI_LAYOUT_H
00100 
00101 #if !defined(INC_MI32_STDAFX_H) && defined(WIN32_MFC)
00102 #include <mi32/stdafx.h>
00103 #endif
00104 
00105 #ifndef INC_MI32_STDDEFNS_H
00106 #include <mi32/stddefns.h>
00107 #endif
00108 
00109 #ifndef INC_MI32_MILIST_H
00110 #include <mi32/milist.h>
00111 #endif
00112 
00113 #if !defined(INC_MI32_XDEFNS_H) && defined(X_NATIVE)
00114 #include <mi32/xdefns.h>
00115 #endif
00116 
00117 #if !defined(INC_MI32_XMIPANE_H) && defined(X_NATIVE)
00118 #include <mi32/xmipane.h>
00119 #endif
00120 
00121 #ifndef INC_MI32_I18N_H
00122 #include <mi32/i18n.h>
00123 #endif
00124 
00125 #if !defined(INC_MI32_WINRESID_H) && defined(WIN32_MFC)
00126 #include <mi32/winresid.h>
00127 #endif
00128 
00129 #ifndef INC_MI32_SIMPLEAR_H
00130 #include <mi32/simplear.h>
00131 #endif
00132 
00133 
00134 #ifndef GENERATING_DOXYGEN_OUTPUT
00135 
00136 class SML_GUI_INTERFACE_BASE;
00137 
00138 #ifdef WIN32_MFC
00139 
00140 #include <afxtempl.h>
00141 namespace ETSLayout {
00142 
00143 //! Controls whether the Icon is automatically set to IDR_MAINFRAME
00144 #define _AUTO_SET_ICON
00145 
00146 //! Forward class declarations
00147 class ETSLayoutPropertySheet;
00148 
00149 //! Default border between panes.
00150 const int nDefaultBorder = 5;
00151 
00152 //! Minimum size for non-ABSOLUTE_... items.
00153 const int MINCONSTRAIN = 5;
00154 
00155 class ETSLayoutMgr {
00156    public:
00157       
00158       enum layResizeMode {
00159          GREEDY            = 0,        //!< Will eat up as much as it can
00160          ABSOLUTE_HORZ     = 1 << 0,   //!< Horizontal size is absolute
00161          RELATIVE_HORZ     = 1 << 1,   //!< Horizontal size in percent
00162          ABSOLUTE_VERT     = 1 << 2,   //!< Vertical size is absolute
00163          RELATIVE_VERT     = 1 << 3,   //!< Vertical size in percent
00164 
00165          NORESIZE          = ABSOLUTE_HORZ | ABSOLUTE_VERT,
00166 
00167          SIZE_MASK         = NORESIZE,
00168 
00169          ALIGN_LEFT        = 1 << 4,   //!< following only for NORESIZE
00170          ALIGN_RIGHT       = 1 << 5,
00171          ALIGN_TOP         = 1 << 6,
00172          ALIGN_BOTTOM      = 1 << 7,
00173 
00174          ALIGN_HCENTER     = ALIGN_LEFT | ALIGN_RIGHT,   
00175          ALIGN_VCENTER     = ALIGN_TOP | ALIGN_BOTTOM,
00176 
00177          ALIGN_CENTER      = ALIGN_HCENTER | ALIGN_VCENTER,
00178          ALIGN_MASK        = ALIGN_CENTER,
00179 
00180          FILL_HORZ         = 1 << 8,   //!< Fill remaining space if any and if no greedy/relative items
00181          FILL_VERT         = 1 << 9,
00182          FILL_BOTH         = FILL_HORZ | FILL_VERT,
00183       
00184          IGNORE_NONVISIBLE = 1 << 14   //!< Ignore nonvisible items in layout
00185          };
00186 
00187       enum layOrientation {
00188          HORIZONTAL,
00189          VERTICAL
00190          };
00191 
00192       //! Base class for all kind of panes. 
00193       class PaneBase {
00194          friend class ETSLayoutMgr;
00195          friend class CPaneBase;
00196          friend class CPane;
00197 
00198          public:
00199 
00200             //! Constructor.
00201             PaneBase (
00202                ETSLayoutMgr *pMgr
00203                ) { m_pMgr = pMgr; }
00204 
00205             //! Destructor.
00206             virtual ~PaneBase(
00207                ) { }
00208 
00209             //! Add alignment modes if none previously set.
00210             void addAlignmentModes (
00211                DWORD modeResize
00212                ) { if ((m_modeResize & ALIGN_MASK) == 0) m_modeResize |= (modeResize & ALIGN_MASK); }
00213 
00214             //! Determine how much of the given space this pane would like to receive in horizontal direction.
00215             virtual int getConstrainHorz (int sizeParent) = 0;
00216 
00217             //! Determine how much of the given space this pane would like to receive in vertical direction.
00218             virtual int getConstrainVert (int sizeParent) = 0;
00219 
00220             /**
00221              * Determine how much of the given space this pane
00222              * minimally need. This would be an absolute Value if 
00223              * the mode contains ABSOLUTE_HORZ or an explicit minimum
00224              * value, else MINCONSTRAIN
00225              */
00226             virtual int getMinConstrainHorz () = 0;
00227 
00228             /**
00229              * Determine if there is an restriction for maximum
00230              * space this pane needs. Return -1 for unrestricted (GREEDY
00231              * or RELATIVE)
00232              */
00233             virtual int getMaxConstrainHorz () = 0;
00234 
00235             /**
00236              * Determine how much of the given space this pane
00237              * minimally need. This would be an absolute Value if 
00238              * the mode contains ABSOLUTE_VERT or an explicit minimum
00239              * value, else MINCONSTRAIN
00240              */
00241             virtual int getMinConstrainVert () = 0;
00242 
00243             /**
00244              * Determine if there is an restriction for maximum
00245              * space this pane needs. Return -1 for unrestricted (GREEDY
00246              * or RELATIVE)
00247              */
00248             virtual int getMaxConstrainVert () = 0;
00249 
00250             //! Determine if pane has opposite orientation from that specified.
00251             virtual bool hasOppositeOrientation (layOrientation orientation) const;
00252 
00253             //! Determine if pane has any currently-visible items.
00254             virtual bool isVisible () const = 0;
00255 
00256             //! Do actual resize operation after the caller computed a new area for this pane
00257             virtual bool resizeTo (CRect& rcNewArea) = 0;
00258 
00259             //! Set control 'enabled' state.
00260             virtual void setEnabled (bool enabled) = 0;
00261 
00262             //! Set control 'visible' state.
00263             virtual void setVisible (bool visible) = 0;
00264 
00265             virtual void updateSizeSecondary ();
00266 
00267             /**
00268              * Returs the Resize Mode of this pane
00269              */
00270             DWORD modeResize() { return m_modeResize; };
00271 
00272          protected:
00273 
00274             DWORD m_modeResize;                 //!< How this Item will be resized, a combination of the flags above
00275             ETSLayoutMgr *m_pMgr;               //!< Pointer to LayoutManager
00276          };    //! PaneBase end
00277 
00278       /**
00279        * CPaneBase represents an autopointer to a PaneBase. Use this and you won't have to worry
00280        * about cleaning up any Panes. Also this autopointer lets you return Pane objects
00281        * from function without using pointers (at least you won't see them :) )
00282        */
00283 
00284       class CPaneBase {
00285          protected:
00286             struct PaneHolder {
00287                PaneHolder (PaneBase* pPane );
00288                ~PaneHolder ();
00289 
00290                void AddRef ();
00291                void Release ();
00292 
00293                PaneBase *m_pPane;
00294                long m_nRefCount;
00295                };    //! PaneHolder end
00296 
00297             PaneHolder*    m_pPaneHolder;
00298 
00299          public:
00300             //! Standardconstructor
00301             CPaneBase ();
00302             CPaneBase (PaneBase* pPane);
00303             CPaneBase (const CPaneBase& rhs);
00304 
00305             ~CPaneBase ();
00306 
00307             void operator= (PaneBase* pPane);
00308             void operator= (const CPaneBase& rhs);
00309             PaneBase* operator-> () const;
00310             PaneBase* GetPaneBase () { return operator->(); }
00311 
00312             bool IsValid() const { return (m_pPaneHolder != 0); }
00313             operator !() const   { return (m_pPaneHolder == 0); }
00314          };    //! CPaneBase end
00315 
00316       class Pane;
00317 
00318       class CPane : public CPaneBase {
00319          public:
00320             //! Standardconstructor
00321             CPane( );
00322             CPane( Pane* pPane );
00323             CPane( const CPane& rhs );
00324 
00325             ~CPane();
00326 
00327             void operator=( Pane* pPane );
00328             void operator=( const CPane& rhs );
00329             Pane* operator->() const;
00330             Pane* GetPane()         { return operator->(); }
00331 
00332             CPaneBase ConvertBase() const;
00333 
00334             CPane& operator<< ( const CPane pPane );
00335             CPane& operator<< ( const CPaneBase pItem );
00336          };    //! CPane end
00337 
00338 
00339       /**
00340        * PaneItem represents a single control
00341        */
00342       class PaneItem : public PaneBase {
00343          friend class ETSLayoutMgr;
00344          friend class Pane;
00345          protected:
00346             /**
00347              * Creates a new PaneItem from a Control. If sizeX or sizeY are 0
00348              * and modeResize is ABSOLUTE will copy the current dimensions of
00349              * the control to m_sizeX/Y. So the appearance does not change
00350              * from the Dialog Editor
00351              */
00352             PaneItem( CWnd* pWnd, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);
00353 
00354             /**
00355              * If your control is not mapped you can name it by its ChildID. Pass
00356              * the pMgr to receive the CWnd* of nID. 
00357              * The rest as stated above
00358              */
00359             PaneItem( UINT nID, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);
00360 
00361          public:
00362             virtual int getConstrainHorz(int sizeParent);
00363             virtual int getConstrainVert(int sizeParent);
00364             virtual int getMinConstrainHorz();
00365             virtual int getMinConstrainVert();
00366             virtual int getMaxConstrainHorz();
00367             virtual int getMaxConstrainVert();
00368             virtual bool isVisible () const;
00369             virtual bool resizeTo(CRect& rcNewArea);
00370             virtual void setEnabled (bool enabled);
00371             virtual void setVisible (bool visible);
00372 
00373             bool  isDummy()            { return (m_hwndCtrl == 0);   }
00374 
00375          protected:
00376             friend class ETSLayoutPropertySheet;
00377 
00378             /**
00379              * The horizontal size of the control (see m_modeResize)
00380              */
00381             int            m_sizeX;
00382             int            m_sizeXMin;
00383 
00384             /**
00385              * The vertical size of the control (see m_modeResize)
00386              */
00387             int            m_sizeY;
00388             int            m_sizeYMin;
00389 
00390             /**
00391              * Child Control pointer
00392              */
00393             HWND        m_hwndCtrl;
00394 
00395             /**
00396              * Combo box needs special treatment
00397              */
00398             bool        m_bComboSpecial;
00399 
00400          private:
00401             #ifndef GENERATING_DOXYGEN_OUTPUT
00402             void ComputeSizeXY();
00403             #endif // GENERATING_DOXYGEN_OUTPUT
00404          };    //! PaneItem end
00405 
00406 
00407       /**
00408        * This class encapsulates a Subpane (and indeed the root Pane too)
00409        * it is a container of PaneBase* which it will recursivly resize
00410        */
00411       class Pane : public PaneBase {
00412          friend class ETSLayoutMgr;
00413          friend class CPaneBase;
00414          friend class CPane;
00415          friend class ETSLayoutPropertySheet;
00416            
00417          protected:
00418             /**
00419              * Tell the pane in which direction it is positioned. A HORIZONTAL pane
00420              * arranges it's subpanes from left to right, a VERTICAL from top to bottom
00421              */
00422             Pane (ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, bool IgnoreNonVisible = false);
00423 
00424          public:
00425             /**
00426              * If your control is not mapped you can name it by its ChildID. Pass
00427              * the pMgr to receive the CWnd* of nID. 
00428              * The rest as stated above
00429              */
00430             bool addItem( UINT nID, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);
00431 
00432             /**
00433              * Creates a new PaneItem from an Control. If sizeX or sizeY are 0
00434              * and modeResize is ABSOLUTE will copy the current dimensions of
00435              * the control to m_sizeX/Y. So the appearance does not change
00436              * from the Dialog Editor
00437              */
00438             bool addItem( CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);
00439 
00440             /**
00441              * Add a whitespace Item (paneNull) of variable size with
00442              * a minimum size of 0
00443              */
00444             bool addItemGrowing();
00445 
00446             /**
00447              * Add a whitespace Item (paneNull) with fixed size
00448              */
00449             bool addItemFixed(int size);
00450 
00451             /**
00452              * Add a whitespace Item (paneNull) of fixed size based on the
00453              * current layout (as in the dialog template). Based on the layout
00454              * of the pane vertical or horizontal spacing is considered
00455              *
00456              * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
00457              */
00458             bool addItemSpaceBetween( CWnd* pWndFirst, CWnd* pWndSecond );
00459             bool addItemSpaceBetween( UINT nIDFirst, UINT nIDSecond );
00460 
00461             /**
00462              * Add a whitespace Item (paneNull) of fixed size based on the
00463              * size of another item
00464              */
00465             bool addItemSpaceLike( CWnd* pWnd );
00466             bool addItemSpaceLike( UINT nID );
00467 
00468             /**
00469              * Add an item to the pane, appending at the end. This may be either obtained
00470              * by a call to ETSLayoutMgr::item() or one of the ETSLayoutMgr::paneXXX() calls
00471              */
00472             bool addPane( CPaneBase pItem );
00473             bool addPane( CPane pSubpane, layResizeMode modeResize, int sizeSecondary /* = 0 */);
00474 
00475             virtual int getConstrainHorz (int sizeParent);
00476             virtual int getConstrainVert (int sizeParent);
00477             virtual int getMinConstrainHorz ();
00478             virtual int getMinConstrainVert ();
00479             virtual int getMaxConstrainHorz ();
00480             virtual int getMaxConstrainVert ();
00481             virtual bool hasOppositeOrientation (layOrientation orientation) const;
00482             virtual bool isVisible () const;
00483             virtual bool resizeTo (CRect& rcNewArea);
00484             virtual void setEnabled (bool enabled);
00485             virtual void setVisible (bool visible);
00486 
00487             /**
00488              * The destructor takes care of destroying all Subpanes and items
00489              */
00490             virtual ~Pane();
00491 
00492             /**
00493              * Access to the orientation of this pane
00494              */
00495             layOrientation getOrientation() { return m_Orientation; };
00496 
00497          protected:
00498 
00499             //! Recursively update secondary pane sizes.
00500             virtual void updateSizeSecondary();
00501 
00502             layOrientation m_Orientation;    //!< Pane orientation
00503 
00504             /**
00505              * This array holds the pointers to the Items/SubPanes
00506              */
00507             CArray<CPaneBase, CPaneBase>  m_paneItems;
00508 
00509             int m_sizeSecondary;             //!< Size in secondary direction
00510             int m_sizeBorder;                //!< Space between child items
00511             int m_sizeExtraBorder;           //!< Extra space around border
00512 
00513          private:
00514             #ifndef GENERATING_DOXYGEN_OUTPUT
00515             int countGreedyItems () const;
00516 
00517             bool resizeToAbsolute (int& availSpace, CArray<int,int>& sizePrimary, CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
00518             
00519             bool resizeToRelative (int& availSpace, CArray<int,int>& sizePrimary, CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
00520 
00521             bool resizeToGreedy (int& availSpace, int nGreedy, CArray<int,int>& sizePrimary, CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
00522             #endif // GENERATING_DOXYGEN_OUTPUT
00523 
00524          };    // Pane end
00525 
00526 
00527       /**
00528        * This class encapsulates a Subpane which is a Tab
00529        * it will use calls to AdjustRect to position it's
00530        * childs
00531        */
00532       class PaneTab : public Pane {
00533          friend class ETSLayoutMgr;
00534 
00535          protected:
00536             /**
00537              * Tell the pane in which direction it is positioned. A HORIZONTAL pane
00538              * arranges it's subpanes from left to right, a VERTICAL from top to bottom
00539              */
00540             PaneTab( CTabCtrl* pTab, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 );
00541 
00542          public:
00543             virtual int getConstrainHorz(int sizeParent);
00544             virtual int getConstrainVert(int sizeParent);
00545             virtual int getMinConstrainHorz();
00546             virtual int getMinConstrainVert();
00547             virtual int getMaxConstrainHorz();
00548             virtual int getMaxConstrainVert();
00549             virtual bool isVisible () const;
00550             virtual bool resizeTo(CRect& rcNewArea);
00551             virtual void setEnabled (bool enabled);
00552             virtual void setVisible (bool visible);
00553 
00554          private:
00555             #ifndef GENERATING_DOXYGEN_OUTPUT
00556             CTabCtrl* m_pTab;
00557             #endif // GENERATING_DOXYGEN_OUTPUT
00558          };    //! PaneTab end
00559 
00560       /**
00561        * This class encapsulates a Subpane which is a Static
00562        * it will use calls to AdjustRect to position it's
00563        * childs
00564        */
00565       class PaneCtrl : public Pane {
00566          friend class ETSLayoutMgr;
00567          protected:
00568             /**
00569              * Tell the pane in which direction it is positioned. A HORIZONTAL pane
00570              * arranges it's subpanes from left to right, a VERTICAL from top to bottom
00571              */
00572             PaneCtrl( CWnd* pCtrl, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0);
00573             PaneCtrl( UINT nID, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0 );
00574 
00575          public:
00576 
00577             virtual int getConstrainHorz(int sizeParent);
00578             virtual int getConstrainVert(int sizeParent);
00579             virtual int getMinConstrainHorz();
00580             virtual int getMinConstrainVert();
00581             virtual int getMaxConstrainHorz();
00582             virtual int getMaxConstrainVert();
00583             virtual bool isVisible () const;
00584             virtual bool resizeTo(CRect& rcNewArea);
00585             virtual void setEnabled (bool enabled);
00586             virtual void setVisible (bool visible);
00587 
00588          private:
00589             #ifndef GENERATING_DOXYGEN_OUTPUT
00590             HWND m_hwndCtrl;
00591             int m_sizeTopExtra;
00592             #endif // GENERATING_DOXYGEN_OUTPUT
00593          };    //! PaneCtrl end
00594 
00595       //! Constructor.
00596       ETSLayoutMgr (CWnd* pWnd) : m_pWnd(pWnd), m_RootBorders(5,5,5,5) { }
00597 
00598       virtual ~ETSLayoutMgr();
00599 
00600       virtual CRect GetRect() { CRect r; m_pWnd->GetClientRect(r); return r; };
00601       CWnd* m_pWnd;
00602       CWnd* GetWnd()    { return m_pWnd; };
00603 
00604       void  setRootBorders (int left, int top, int right, int bottom) { m_RootBorders.SetRect(left,top,right,bottom); }
00605 
00606       /**
00607        * Pass this for a pseudo Pane with no content
00608        */
00609       static CWnd*   paneNull;
00610 
00611       /**
00612        * Loads the current position and size from the registry using a supplied
00613        * key. Will be loaded with AfxGetApp()->WriteProfileXXX(). You may
00614        * specify a subfolder (e.g. Load( _CT("MyDialog\\Layout") ); ). Will
00615        * load the following keys:
00616        *
00617        * - lpstrRegKey+"SizeX";
00618        * - lpstrRegKey+"SizeY";
00619        * - lpstrRegKey+"PosX";
00620        * - lpstrRegKey+"PosY";
00621        *
00622        * Is automatically called during OnActivate() if key specified in
00623        * constructor.
00624        */
00625       bool Load(LPCTSTR lpstrRegKey);
00626 
00627       /**
00628        * Store the current position and size to the registry using a supplied
00629        * key. Will be stored with AfxGetApp()->WriteProfileXXX(). You may
00630        * specify a subfolder (e.g. Save( _CT("MyDialog\\Layout") ); ). Will
00631        * create the following keys:
00632        *
00633        * - lpstrRegKey+"SizeX";
00634        * - lpstrRegKey+"SizeY";
00635        * - lpstrRegKey+"PosX";
00636        * - lpstrRegKey+"PosY";
00637        *
00638        * Is automatically called during DestroyWindow() if key specified in
00639        * constructor.
00640        */
00641       bool Save(LPCTSTR lpstrRegKey);
00642 
00643       /**
00644        * Updates the layout after you specify the new
00645        * layout
00646        */
00647       virtual void UpdateLayout();
00648 
00649       virtual void UpdateLayout(CPane p) {
00650          if(m_RootPane.IsValid()) {
00651             //! free old root
00652             m_RootPane = 0;
00653             }
00654          m_RootPane = p;
00655          UpdateLayout();
00656          }
00657 
00658       /**
00659        * Does the actual Layout, called from OnSize()
00660        * Default implementation does nothing.
00661        */
00662       virtual void Layout(CRect& rcClient);
00663 
00664       /**
00665        * Erasing only the these parts of the client area where
00666        * there is no child window. Extra-code for group-boxes 
00667        * included!
00668        */
00669       void EraseBkgnd(CDC* pDC);
00670 
00671       /**
00672        * Helperfunctions for the stream-interface. For usage see sample Application
00673        * and/or documentation.
00674        */
00675 
00676       /**
00677        * Create a new Pane. You may specify the resize
00678        * mode for both directions. If you add modes for the secondary direction
00679        * (i.e. *_VERT for a HORIZONTAL pane) then sizeSecondary is used as it's
00680        * size. If you do not specify sizeSecondary and the mode is ABSOLUTE_VERT
00681        * it will be computed as the maximum Height of all SubPanes (the same is
00682        * true for VERTICAL panes and subpanes with *_HORZ)
00683        */
00684       CPane pane( layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);
00685 
00686       /**
00687        * Create one of the special control panes. Parameter are like pane(). For
00688        * additional information see documentation
00689        */
00690       CPane paneTab( CTabCtrl* pTab, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);
00691       CPane paneCtrl( UINT nID, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);
00692       CPane paneCtrl( CWnd* pCtrl, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);
00693 
00694       /**
00695        * Creates a new PaneItem for an Control. If sizeX or sizeY are 0
00696        * and modeResize is ABSOLUTE will copy the current dimensions of
00697        * the control to m_sizeX/Y. So the appearance does not change
00698        * from the Dialog Editor. size*Min = -1 means: do not make smaller
00699        * than in Dialog Template.
00700        */
00701       CPaneBase item(UINT nID, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);
00702       CPaneBase item(CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);
00703 
00704       /**
00705        * Add a whitespace Item (paneNull) of variable size with
00706        * a minimum size of 0
00707        */
00708       CPaneBase itemGrowing(layOrientation orientation);
00709 
00710       /**
00711        * Add a whitespace Item (paneNull) with fixed size
00712        */
00713       CPaneBase itemFixed(layOrientation orientation, int sizePrimary);
00714 
00715       /**
00716        * Add a whitespace Item (paneNull) of fixed size based on the
00717        * current layout (as in the dialog template). Based on the layout
00718        * of the pane vertical or horizontal spacing is considered
00719        *
00720        * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
00721        */
00722       CPaneBase itemSpaceBetween( layOrientation orientation, CWnd* pWndFirst, CWnd* pWndSecond );
00723       CPaneBase itemSpaceBetween( layOrientation orientation, UINT nIDFirst, UINT nIDSecond );
00724 
00725       /**
00726        * Add a whitespace Item (paneNull) of fixed size based on the
00727        * size of another item
00728        */
00729       CPaneBase itemSpaceLike( layOrientation orientation, CWnd* pWnd );
00730       CPaneBase itemSpaceLike( layOrientation orientation, UINT nID );
00731 
00732    protected:
00733 
00734       CPane m_RootPane;                //!< Holder for root pane, set in InitDialog()
00735       CString m_strRegStore;           //!< Registry key for storing size
00736       CRect m_RootBorders;             //!< Borders around root
00737 
00738       //! Create a root pane
00739       CPane CreateRoot (
00740          layOrientation orientation,
00741          int sizeBorder = nDefaultBorder,
00742          int sizeExtraBorder = 0,
00743          bool IgnoreNonVisible = false
00744          ) {
00745          if (m_RootPane.IsValid()) {
00746             //! free old root
00747             m_RootPane = 0;
00748             }
00749          m_RootPane = new Pane(this, orientation, sizeBorder, sizeExtraBorder, IgnoreNonVisible);
00750          return m_RootPane;
00751          }
00752 
00753    };    //! ETSLayoutMgr end
00754 
00755 
00756 inline ETSLayoutMgr::layResizeMode operator| (
00757    const ETSLayoutMgr::layResizeMode lhs, 
00758    const ETSLayoutMgr::layResizeMode rhs
00759    ) {
00760    return (static_cast<ETSLayoutMgr::layResizeMode>((DWORD)lhs | (DWORD)rhs));
00761    }
00762 
00763 inline ETSLayoutMgr::layResizeMode& operator|= (
00764    ETSLayoutMgr::layResizeMode& lhs, 
00765    const ETSLayoutMgr::layResizeMode rhs
00766    ) {
00767    lhs = static_cast<ETSLayoutMgr::layResizeMode>((DWORD)lhs | (DWORD)rhs);
00768    return (lhs);
00769    }
00770 
00771 inline ETSLayoutMgr::layResizeMode operator& (
00772    const ETSLayoutMgr::layResizeMode lhs, 
00773    const ETSLayoutMgr::layResizeMode rhs
00774    ) {
00775    return (static_cast<ETSLayoutMgr::layResizeMode>((DWORD)lhs & (DWORD)rhs));
00776    }
00777 
00778 inline ETSLayoutMgr::layResizeMode& operator&= (
00779    ETSLayoutMgr::layResizeMode& lhs, 
00780    const ETSLayoutMgr::layResizeMode rhs
00781    ) {
00782    lhs = static_cast<ETSLayoutMgr::layResizeMode>((DWORD)lhs & (DWORD)rhs);
00783    return (lhs);
00784    }
00785 
00786 
00787 /**
00788  * Base class for the Layout function. Derive your own class
00789  * from this or derive it from CDialog and modify _all_
00790  * references to CDialog to ETSLayoutDialog
00791  */
00792 class ETSLayoutDialog : public CDialog, protected ETSLayoutMgr {
00793    public:
00794 
00795       //! Construction
00796       ETSLayoutDialog(UINT nID, CWnd* pParent = NULL, LPCTSTR strName = NULL, bool bGripper = true);   //! standard constructor
00797 
00798    protected:
00799       //! Generated message map functions
00800       //!{{AFX_MSG(ETSLayoutDialog)
00801       afx_msg void OnSize(UINT nType, int cx, int cy);
00802       afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
00803       afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00804       virtual BOOL OnInitDialog();
00805       afx_msg void OnDestroy();
00806       //!}}AFX_MSG
00807       DECLARE_MESSAGE_MAP()
00808 
00809       virtual CRect GetRect();
00810 
00811       bool     m_bGripper;
00812       CStatusBar  m_StatusBar;
00813    };    //! ETSLayoutDialog end
00814 
00815 
00816 /**
00817  * Base class for the Layout function. Derive your own class
00818  * from this or derive it from CDialog and modify _all_
00819  * references to CFormView to ETSLayoutFormView
00820  */
00821 class ETSLayoutFormView : public CFormView, public ETSLayoutMgr {
00822    DECLARE_DYNAMIC(ETSLayoutFormView)
00823 
00824    public:
00825 
00826       //! Constructor.
00827       ETSLayoutFormView(UINT nID, LPCTSTR strName = NULL);
00828 
00829       //! Destructor.
00830       virtual ~ETSLayoutFormView();
00831 
00832    protected:
00833 
00834       //! Generated message map functions
00835       //!{{AFX_MSG(ETSLayoutDialog)
00836       afx_msg void OnSize(UINT nType, int cx, int cy);
00837       afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00838       afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
00839       //!}}AFX_MSG
00840       DECLARE_MESSAGE_MAP()
00841    };    //! ETSLayoutFormView end
00842 
00843 
00844 /**
00845  * Base class for the Layout function. Derive your own class
00846  * from this or derive it from CBCGDialogBar/CDialogBar and 
00847  * modify _all_  references to CBCGDialogBar/CDialogBar to 
00848  * ETSLayoutDialogBar
00849  */
00850 class ETSLayoutDialogBar : public CDialogBar, protected ETSLayoutMgr {
00851    public:
00852 
00853       //! Constructor.
00854       ETSLayoutDialogBar();
00855 
00856       //! ClassWizard generated virtual function overrides
00857       //!{{AFX_VIRTUAL(ETSLayoutDialogBar)
00858       virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
00859       //!}}AFX_VIRTUAL
00860 
00861       /**
00862        * Override this to define Layout
00863        */
00864       virtual BOOL Initialize() { return false; };
00865 
00866       virtual void UpdateLayout();
00867 
00868    protected:
00869       //! Generated message map functions
00870       //!{{AFX_MSG(ETSLayoutDialogBar)
00871       afx_msg void OnSize(UINT nType, int cx, int cy);
00872       afx_msg void OnDestroy();
00873       afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00874       //!}}AFX_MSG
00875       LRESULT OnInitDialog(WPARAM, LPARAM);
00876       DECLARE_MESSAGE_MAP()
00877 
00878       virtual CRect GetRect();
00879       bool  m_bInitialized;
00880    };    //! ETSLayoutDialogBar end
00881 
00882 
00883 
00884 /**************************************************
00885  ** ! the code is only tested for modal sheets ! **
00886  **************************************************/
00887 
00888 
00889 /**
00890  * Resizable PropertySheet. Use this class standalone
00891  * or as your base class (instead CProptertySheet)
00892  */
00893 class ETSLayoutPropertySheet : public CPropertySheet, protected ETSLayoutMgr {
00894    DECLARE_DYNAMIC(ETSLayoutPropertySheet)
00895 
00896    public:
00897 
00898       //! Default constructor.
00899       ETSLayoutPropertySheet();
00900 
00901       ETSLayoutPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);
00902 
00903       ETSLayoutPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);
00904 
00905       void  SetAutoDestroy()     { m_bAutoDestroy = true; }
00906       void  SetAutoDestroyPages()   { m_bAutoDestroyPages = true; }
00907       void  ModelessWithButtons()   { m_bModelessButtons = true; }
00908 
00909       virtual void AddMainArea(CPane paneRoot, CPaneBase itemTab);
00910       virtual void AddButtons(CPane paneBottom);
00911        
00912       //! ClassWizard generated virtual function overrides
00913       //!{{AFX_VIRTUAL(ETSLayoutPropertySheet)
00914       public:
00915       virtual BOOL OnInitDialog();
00916       virtual void PostNcDestroy();
00917       //!}}AFX_VIRTUAL
00918 
00919    //! Implementation
00920    public:
00921       virtual ~ETSLayoutPropertySheet();
00922 
00923       //! Generated message map functions
00924    protected:
00925       //!{{AFX_MSG(ETSLayoutPropertySheet)
00926       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00927       afx_msg void OnSize(UINT nType, int cx, int cy);
00928       afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
00929       afx_msg void OnDestroy();
00930       afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00931       //!}}AFX_MSG
00932       DECLARE_MESSAGE_MAP()
00933 
00934       void Resize(int cx, int cy);
00935 
00936 
00937       void     Init(LPCTSTR strName, bool bGripper);
00938       CRect    m_rcStart;
00939       CRect    m_rcPage;
00940       bool     m_bGripper;
00941       CStatusBar  m_StatusBar;
00942       CPaneBase   m_ItemTab;
00943       bool     m_bAutoDestroy;
00944       bool     m_bAutoDestroyPages;
00945       bool     m_bModelessButtons;
00946 
00947    friend class ETSLayoutPropertyPage;
00948    };    //! ETSLayoutPropertySheet end
00949 
00950 
00951 /**
00952  * Base class for the Layout function. Derive your own class
00953  * from this or derive it from CPropertyPage and 
00954  * modify _all_  references to CPropertyPage to 
00955  * ETSLayoutPropertyPage
00956  */
00957 class ETSLayoutPropertyPage : public CPropertyPage, protected ETSLayoutMgr {
00958    friend class ETSLayoutPropertySheet;
00959 
00960    DECLARE_DYNCREATE(ETSLayoutPropertyPage)
00961 
00962    public:
00963       ETSLayoutPropertyPage( );
00964       ETSLayoutPropertyPage( UINT nIDTemplate, UINT nIDCaption = 0 );
00965       ETSLayoutPropertyPage( LPCTSTR lpszTemplateName, UINT nIDCaption = 0 );
00966 
00967       ~ETSLayoutPropertyPage();
00968 
00969    //! Overrides
00970       //! ClassWizard generated virtual function overrides
00971       //!{{AFX_VIRTUAL(ETSLayoutPropertyPage)
00972       public:
00973       virtual BOOL OnSetActive();
00974       //!}}AFX_VIRTUAL
00975 
00976    //! Implementation
00977    protected:
00978       //! Generated message map functions
00979       //!{{AFX_MSG(ETSLayoutPropertyPage)
00980       afx_msg void OnSize(UINT nType, int cx, int cy);
00981       afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
00982       virtual BOOL OnInitDialog();
00983       afx_msg BOOL OnEraseBkgnd(CDC* pDC);
00984       afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
00985       afx_msg void OnDestroy();
00986       afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
00987       //!}}AFX_MSG
00988       DECLARE_MESSAGE_MAP()
00989 
00990       virtual CRect GetRect();
00991       bool m_bLockMove;
00992       bool m_bResetBuddyOnNextTimeVisible;
00993    };    //! ETSLayoutPropertyPage end
00994 
00995 
00996 }  //! End of ETSLayout namespace
00997 using namespace ETSLayout;
00998 
00999 #endif
01000 #endif // GENERATING_DOXYGEN_OUTPUT
01001 
01002 
01003 namespace MGUI {
01004 
01005 // Forward declarations
01006 class TOOLTIPCTRL;
01007 class LAYOUT_PANE_ROOT;
01008 class LAYOUT_PANE_MAIN;
01009 class LAYOUT_PAGE;
01010 class CTRL;
01011 
01012 //===================================================================================================================
01013 //! Class to contain X/Y coordinates of a point in a window, on the screen, etc.
01014 //! Often instances of this class are passed by value since the total size is 4 bytes
01015 //! which actually results in smaller and more efficient code in the called function
01016 //! due to direct access on stack rather than through pointer/reference indirection.
01017 class POINT {
01018    public:
01019 
01020       INT16 m_x;                       //!< Point X coordinate
01021       INT16 m_y;                       //!< Point Y coordinate
01022 
01023       //! Default construction, initializes to arbitrary point.
01024       POINT (
01025          ): m_x(-32768), m_y(-32768) { }
01026 
01027       //! Construct from X, Y values.
01028       POINT (
01029          INT16 x,
01030          INT16 y
01031          ): m_x(x), m_y(y) { }
01032    };
01033 
01034 //---------------------------------------------------------------------------------------------------------
01035 
01036 
01037 enum LAYOUT_ORIENTATION {
01038    LAYOUT_ORIENTATION_Horizontal =     0,    //!< Horizontal layout, automatic LtoR/RtoL based on locale
01039    LAYOUT_ORIENTATION_Vertical =       1,    //!< Vertical top-to-bottom layout
01040    LAYOUT_ORIENTATION_HorizontalLtoR = 2,    //!< Horizontal left-to-right layout
01041    LAYOUT_ORIENTATION_HorizontalRtoL = 3,    //!< Horizontal right-to-left layout
01042    };
01043 
01044 enum LAYOUT_SIZEALIGN {
01045    LAYOUT_SIZEALIGN_Expand =           0x0000,     //!< Expand both horizontal and vertical to fill space
01046    LAYOUT_SIZEALIGN_FixedWidth =       0x0001,     //!< Fixed width, height can expand
01047    LAYOUT_SIZEALIGN_RelativeWidth =    0x0002,     //!< Relative width as percentage of available space
01048    LAYOUT_SIZEALIGN_FixedHeight =      0x0004,     //!< Fixed height, width can expand
01049    LAYOUT_SIZEALIGN_RelativeHeight =   0x0008,     //!< Relative height as percentage of available space
01050    LAYOUT_SIZEALIGN_FixedSize =        0x0005,     //!< Both width and height fixed
01051    LAYOUT_SIZEALIGN_AlignLeft =        0x0010,     //!< Align with left edge of available space
01052    LAYOUT_SIZEALIGN_AlignRight =       0x0020,     //!< Align with right edge of available space
01053    LAYOUT_SIZEALIGN_AlignTop =         0x0040,     //!< Align with top edge of available space
01054    LAYOUT_SIZEALIGN_AlignBottom =      0x0080,     //!< Align with bottom edge of available space
01055    LAYOUT_SIZEALIGN_CenterHorz =       0x0030,     //!< Center horizontally in available space
01056    LAYOUT_SIZEALIGN_CenterVert =       0x00C0,     //!< Center vertically in available space
01057    LAYOUT_SIZEALIGN_Center =           0x00F0,     //!< Center both horizontal and vertically
01058    LAYOUT_SIZEALIGN_IgnoreNonVisible = 0x4000,     //!< Ignore nonvisible items in layout
01059    };
01060 DEFINE_ENUM_OPERATORS(LAYOUT_SIZEALIGN);
01061 
01062 
01063 //---------------------------------------------------------------------------------------------------------
01064 
01065 //! Layout pane base class, not intended to be used directly.
01066 class LAYOUT_PANE_BASE {
01067    public:
01068 
01069    #ifdef WIN32_MFC
01070       //! Constructor (MFC version).
01071       LAYOUT_PANE_BASE (
01072          CWnd *RootWnd = 0
01073          ): m_RootPane(0) { }
01074    #endif
01075 
01076    #ifdef X_NATIVE
01077       //! Constructor (X version).
01078       LAYOUT_PANE_BASE (
01079          ): m_PaneWidget(0) { }
01080    #endif
01081 
01082       //! Destructor.
01083       virtual ~LAYOUT_PANE_BASE (
01084          ) = 0;
01085 
01086    #ifdef WIN32_MFC
01087       //! Cast to CWnd* so can use pane as parent for MFC Create() methods.
01088       operator CWnd* (
01089          ) { return (GetRootWnd()); }
01090    #endif
01091 
01092    #ifdef WIN32_MFC
01093       //! Add item to pane (MFC only).
01094       void AddItem (
01095          CWnd *ItemWnd,
01096          MGUI::LAYOUT_SIZEALIGN sizealign
01097          );
01098    #endif
01099 
01100       //! Add automatically expanding whitespace item.
01101       void AddSpaceExpanding (
01102          ) {
01103          #ifdef WIN32_MFC
01104             m_Pane->addItemGrowing();
01105          #else
01106             XmiPaneAddSpaceExpanding(m_PaneWidget);
01107          #endif
01108          }
01109 
01110       //! Add whitespace item of fixed size.
01111       void AddSpaceFixed (
01112          int size
01113          ) {
01114          #ifdef WIN32_MFC
01115             m_Pane->addItemFixed(size);
01116          #else
01117             XmiPaneAddSpaceFixed(m_PaneWidget,size);
01118          #endif
01119          }
01120 
01121    #ifdef WIN32_MFC
01122       //! Compute size rectangle for given label text as CString (MFC only).
01123       CRect ComputeRect (
01124          const CString& str,
01125          int xadd = 0,
01126          int yadd = 0
01127          ) const;
01128    #endif
01129 
01130    #ifdef WIN32_MFC
01131       //! Compute size rectangle for given text "width" (MFC only).
01132       CRect ComputeRect (
01133          int width,
01134          int xadd = 0,
01135          int yadd = 0
01136          ) const { return (ComputeRect(CString('M',width),xadd,yadd)); }
01137    #endif
01138 
01139       //! Compute typical size for given text width in characters.
01140       MGUI::POINT ComputeTextSize (
01141          int width                        //!< Width in characters
01142          ) const;
01143 
01144       //! Compute size of given label text from MISTRING.
01145       MGUI::POINT ComputeTextSize (
01146          const MISTRING& str              //!< String (or TEXTID)
01147          ) const;
01148 
01149       //! Compute size of given label text as UNICODE string.
01150       MGUI::POINT ComputeTextSize (
01151          const UNICODE *str               //!< String
01152          ) const;
01153 
01154    #ifdef WIN32_MFC
01155       //! Compute size of given label text as CString (MFC only).
01156       CSize ComputeTextSize (
01157          const CString& str
01158          ) const;
01159    #endif
01160 
01161       //! Get suitable parent for dialog launched from pane.
01162       MDLGPARENT GetDlgParent (
01163          ) const {
01164          #ifdef WIN32_MFC
01165             return (GetMainWnd());
01166          #else
01167             return (MxGetShell(m_PaneWidget));
01168          #endif
01169          }
01170 
01171    #ifdef WIN32_MFC
01172       //! Get pointer to layout manager (MFC only).
01173       inline ETSLayoutMgr* GetLayoutMgr (
01174          ) const;
01175    #endif
01176 
01177    #ifdef WIN32_MFC
01178       //! Get next available dynamically assigned control ID.
01179       UINT GetNextControlID (
01180          );
01181    #endif
01182 
01183 //!      // Get pane orientation.
01184 //!      MGUI::LAYOUT_ORIENTATION GetOrientation (
01185 //!         ) const;
01186 
01187    #ifdef WIN32_MFC
01188       //! Get "main" window, typically for use as parent for other dialogs.
01189       inline CWnd* GetMainWnd (
01190          ) const;
01191    #endif
01192 
01193    #ifdef WIN32_MFC
01194       //! Get reference to layout manager pane.
01195       ETSLayoutMgr::CPane& GetPane (
01196          ) { return (m_Pane); }
01197    #endif
01198 
01199    #ifdef X_NATIVE
01200       //! Get pane widget (X only).
01201       Widget GetWidget (
01202          ) const { return (m_PaneWidget); }
01203    #endif
01204 
01205    #ifdef WIN32_MFC
01206       //! Get "root pane".
01207       MGUI::LAYOUT_PANE_ROOT* GetRootPane (
01208          ) const { return (m_RootPane); }
01209    #endif
01210 
01211    #ifdef WIN32_MFC
01212       //! Get root CWnd* for control creation.
01213       inline CWnd* GetRootWnd (
01214          ) const;
01215    #endif
01216 
01217       //! Determine if pane has been created.
01218       bool IsCreated (
01219          ) const {
01220          #ifdef WIN32_MFC
01221             return (m_Pane.IsValid());
01222          #else
01223             return (m_PaneWidget != 0);
01224          #endif
01225          }
01226 
01227    #ifdef WIN32_MFC
01228       //! Add CTRL to message pre-translation list.
01229       inline void PreTransListAddCtrl (
01230          CTRL* ctrl
01231          );
01232    #endif
01233 
01234       //! Set 'enabled' status for all controls in pane or children therof.
01235       void SetEnabled (
01236          bool enabled
01237          ) {
01238          #ifdef WIN32_MFC
01239             m_Pane->setEnabled(enabled);
01240          #else
01241             MxSetSensitive(m_PaneWidget,enabled);
01242          #endif
01243          }
01244 
01245       //! Set visibility for all controls in pane or children thereof.
01246       void SetVisible (
01247          bool visible
01248          ) {
01249       #ifdef WIN32_MFC
01250          m_Pane->setVisible(visible);
01251       #else
01252          MxShowWidget(m_PaneWidget,visible);
01253       #endif
01254          }
01255 
01256       //! Force update of layout.
01257       //! This may be necessary if the layout is changed after the dialog/window is initially created.
01258       void UpdateLayout (
01259          ) {
01260       #ifdef WIN32_MFC
01261          GetLayoutMgr()->UpdateLayout();
01262       #endif
01263          }
01264 
01265       #ifndef GENERATING_DOXYGEN_OUTPUT
01266       //! Function private to SML implemention of MGUI classes
01267       //! Used to prevent the need for ugly multiple inheritance.
01268       virtual SML_GUI_INTERFACE_BASE* GetSMLInterface (
01269          );
01270       #endif
01271 
01272    protected:
01273 
01274    #ifdef WIN32_MFC
01275       MGUI::LAYOUT_PANE_ROOT *m_RootPane;    //!< Pointer to root pane
01276       ETSLayoutMgr::CPane m_Pane;            //!< Actual layout manager pane
01277    #endif
01278 
01279    #ifdef X_NATIVE
01280       void SetPaneWidget (Widget PaneWidget);
01281    #endif
01282 
01283    private:
01284       #ifndef GENERATING_DOXYGEN_OUTPUT
01285 
01286    #ifdef X_NATIVE
01287       Widget m_PaneWidget;
01288    #endif
01289 
01290    #ifdef X_NATIVE
01291       static void CB_Destroy (Widget, LAYOUT_PANE_BASE*, void*);
01292    #endif
01293 
01294       LAYOUT_PANE_BASE (const LAYOUT_PANE_BASE&);
01295       LAYOUT_PANE_BASE& operator= (const LAYOUT_PANE_BASE&);
01296 
01297       #endif // GENERATING_DOXYGEN_OUTPUT
01298    };
01299 
01300 
01301 //---------------------------------------------------------------------------------------------------------
01302 
01303 //! Layout pane for use as root of dialog, window or page.
01304 class LAYOUT_PANE_ROOT : public MGUI::LAYOUT_PANE_BASE {
01305    public:
01306 
01307    #ifdef WIN32_MFC
01308       //! Constructor (MFC version).
01309       LAYOUT_PANE_ROOT (
01310          CWnd& RootWnd
01311          );
01312    #endif
01313 
01314    #ifdef X_NATIVE
01315       //! Constructor (X version).
01316       LAYOUT_PANE_ROOT (
01317          ) { }
01318    #endif
01319 
01320       //! Destructor.
01321       virtual ~LAYOUT_PANE_ROOT (
01322          );
01323 
01324    #ifdef WIN32_MFC
01325       //! Add ToolTip item.
01326       void AddToolTipItem (
01327          CWnd& item,
01328          LPCTSTR string
01329          );
01330    #endif
01331 
01332    #ifdef WIN32_MFC
01333       //! Get "layout manager".
01334       ETSLayoutMgr* GetLayoutMgr (
01335          ) const { return (m_LayoutMgr); }
01336    #endif
01337 
01338    #ifdef WIN32_MFC
01339       //! Get "main" pane.
01340       MGUI::LAYOUT_PANE_MAIN* GetMainPane (
01341          ) const { return (m_MainPane); }
01342    #endif
01343 
01344    #ifdef WIN32_MFC
01345       CWnd& GetWnd (
01346          ) const { return (m_RootWnd); }
01347    #endif
01348 
01349    #ifdef WIN32_MFC
01350       //! Initialize called internally by OnInitDialog() or similar (MFC version).
01351       void Init (
01352          ETSLayoutMgr *LayoutMgr,
01353          ETSLayoutMgr::CPane RootPane,
01354          TOOLTIPCTRL *ToolTipCtrl
01355          );
01356    #endif
01357 
01358    #ifdef X_NATIVE
01359       //! Initialize called internally by OnInitDialog() or similar (X version).
01360       void Init (
01361          Widget TopPaneWidget                   //!< Topmost "Pane" widget
01362          ) { SetPaneWidget(TopPaneWidget); }
01363    #endif
01364 
01365    #ifdef WIN32_MFC
01366       //! Add CTRL to message pre-translation list.
01367       void PreTransListAdd (
01368          CTRL* ctrl
01369          );
01370    #endif
01371 
01372    #ifdef WIN32_MFC
01373       //! Process message through pretranslation list if control has focus.
01374       //! @return 'true' if processed, false if not.
01375       bool PreTransListProcess (
01376          const CWnd* pFocusWnd,              //!< Window which currently has focus
01377          MSG *pMsg                           //!< Message to process
01378          );
01379    #endif
01380 
01381    protected:
01382 
01383    #ifdef WIN32_MFC
01384       MGUI::LAYOUT_PANE_MAIN *m_MainPane;    //!< Pointer to "main" pane, may be 'this' pane.
01385    #endif
01386 
01387    private:
01388       #ifndef GENERATING_DOXYGEN_OUTPUT
01389 
01390    #ifdef WIN32_MFC
01391       CWnd& m_RootWnd;
01392       ETSLayoutMgr *m_LayoutMgr;
01393       TOOLTIPCTRL *m_ToolTipCtrl;
01394       SIMPLE_ARRAY<CTRL*> m_PreTransCtrls;      //!< Controls that want PreTranlateMessage
01395    #endif
01396 
01397       LAYOUT_PANE_ROOT (const LAYOUT_PANE_ROOT&);
01398       LAYOUT_PANE_ROOT& operator= (const LAYOUT_PANE_ROOT&);
01399       #endif // GENERATING_DOXYGEN_OUTPUT
01400    };
01401 
01402 
01403 //---------------------------------------------------------------------------------------------------------
01404 
01405 //! Main layout pane for a dialog or window.
01406 class LAYOUT_PANE_MAIN : public MGUI::LAYOUT_PANE_ROOT {
01407    public:
01408 
01409    #ifdef WIN32_MFC
01410       //! Constructor (MFC version).
01411       LAYOUT_PANE_MAIN (
01412          CWnd& RootWnd
01413          ):
01414          LAYOUT_PANE_ROOT(RootWnd),
01415          m_NextControlID(ID_CONTROL_FIRST)
01416          { m_MainPane = this; }
01417    #endif
01418 
01419    #ifdef X_NATIVE
01420       //! Constructor (X version).
01421       LAYOUT_PANE_MAIN (
01422          ) { }
01423    #endif
01424 
01425    #ifdef WIN32_MFC
01426       //! Allocate next control ID.
01427       UINT AllocNextControlID (
01428          ) { return (++m_NextControlID); }
01429    #endif
01430 
01431    private:
01432       #ifndef GENERATING_DOXYGEN_OUTPUT
01433 
01434    #ifdef WIN32_MFC
01435       UINT m_NextControlID;
01436    #endif
01437 
01438       LAYOUT_PANE_MAIN (const LAYOUT_PANE_MAIN&);
01439       LAYOUT_PANE_MAIN& operator= (const LAYOUT_PANE_MAIN&);
01440       #endif // GENERATING_DOXYGEN_OUTPUT
01441    };
01442 
01443 
01444 //---------------------------------------------------------------------------------------------------------
01445 
01446 //! Layout pane intended for general use.
01447 class LAYOUT_PANE : public MGUI::LAYOUT_PANE_BASE {
01448    public:
01449 
01450       //! Constructor, initializes only, does not create actual pane.
01451       LAYOUT_PANE (
01452          ) { }
01453 
01454       //! Destructor.
01455       virtual ~LAYOUT_PANE (
01456          ) { }
01457 
01458       //! Create the actual pane.
01459       void Create (
01460          MGUI::LAYOUT_PANE_BASE& pane,          //!< 'Parent' pane
01461          MGUI::LAYOUT_ORIENTATION orientation,  //!< Pane orientation
01462          MGUI::LAYOUT_SIZEALIGN sizealign,      //!< Sizing/alignment
01463          int ChildSpacing = 4,                  //!< Spacing between 'children' of pane
01464          int ExtraBorder = 0                    //!< Extra border around pane, in addition to ChildSpacing
01465          );
01466 
01467    private:
01468       #ifndef GENERATING_DOXYGEN_OUTPUT
01469       LAYOUT_PANE (const LAYOUT_PANE&);
01470       LAYOUT_PANE& operator= (const LAYOUT_PANE&);
01471       #endif // GENERATING_DOXYGEN_OUTPUT
01472    };
01473 
01474 
01475 //---------------------------------------------------------------------------------------------------------
01476 
01477 //! Layout pane for "book" of tabbed pages.
01478 //! First Initialize the book, then create the pages and finally create the book itself.
01479 class LAYOUT_BOOK : public MGUI::LAYOUT_PANE_BASE {
01480    public:
01481 
01482       //! Constructor.
01483       LAYOUT_BOOK (
01484          );
01485 
01486       //! Create the book after page creation.
01487       void Create (
01488          );
01489 
01490       //! Get index to 'active' page.
01491       //! @return Zero-based index to active page, -1 if none created.
01492       int GetActiveIndex (
01493          ) const;
01494 
01495       //! Initialize prior to page creation.
01496       void Initialize (
01497          MGUI::LAYOUT_PANE_BASE& ParentPane,    //!< 'Parent' pane
01498          MGUI::LAYOUT_SIZEALIGN sizealign = MGUI::LAYOUT_SIZEALIGN_FixedSize
01499          );
01500 
01501       //! Set active page by index.
01502       void SetActiveIndex (
01503          int index                              //!< Zero-based page index
01504          );
01505 
01506    private:
01507       #ifndef GENERATING_DOXYGEN_OUTPUT
01508 
01509    #ifdef WIN32_MFC
01510       ETSLayoutPropertySheet m_PropSheet;
01511    #endif
01512 
01513    #ifdef X_NATIVE
01514       SIMPLE_ARRAY<MxTABPAGEITEM> m_TabPageItems;
01515       Widget m_TabPage;
01516    #endif
01517 
01518       MGUI::LAYOUT_PANE_BASE *m_pParentPane;
01519       LAYOUT_SIZEALIGN m_sizealign;
01520 
01521    #ifdef X_NATIVE
01522       static void TABCB_Create (Widget, int, void*);
01523       static void TABCB_Activate (Widget, int, void*);
01524    #endif
01525       
01526       LAYOUT_BOOK (const LAYOUT_BOOK&);
01527       LAYOUT_BOOK& operator= (const LAYOUT_BOOK&);
01528 
01529       friend class LAYOUT_PAGE;
01530       #endif // GENERATING_DOXYGEN_OUTPUT
01531    };
01532 
01533 
01534 //---------------------------------------------------------------------------------------------------------
01535 
01536 //! Layout pane for use as tab page.
01537 class LAYOUT_PAGE : public MGUI::LAYOUT_PANE_ROOT {
01538    public:
01539 
01540       //! Constructor.
01541       LAYOUT_PAGE (
01542          );
01543 
01544       //! Destructor.
01545       virtual ~LAYOUT_PAGE (
01546          );
01547 
01548       //! Create page with tab label from resource lookup.
01549       //! @return Page index.
01550       int Create (
01551          MGUI::LAYOUT_BOOK& book,               //!< Book to add page to
01552          const char *label,                     //!< Label string for resource lookup
01553          MGUI::LAYOUT_ORIENTATION orientation = MGUI::LAYOUT_ORIENTATION_Vertical
01554          );
01555 
01556       //! Create page with tab label from MISTRING.
01557       //! @return Page index.
01558       int Create (
01559          MGUI::LAYOUT_BOOK& book,               //!< Book to add page to
01560          const MISTRING& label,                 //!< Label string
01561          MGUI::LAYOUT_ORIENTATION orientation = MGUI::LAYOUT_ORIENTATION_Vertical
01562          );
01563 
01564       //! Determine if this is the 'active' page.
01565       bool IsActive (
01566          ) const;
01567 
01568       //! Set whether page is 'enabled' or not.
01569       void SetEnabled (
01570          bool enabled = true
01571          );
01572 
01573    protected:
01574 
01575       //! Create page contents.
01576       //! Derived class MUST implement this.
01577       //! This will be called by the page creation code and thus should not be called
01578       //! directly.
01579       virtual void OnInitPage (
01580          ) = 0;
01581 
01582       //! Called when page is made active.
01583       //! Derived class must call base class BEFORE performing own processing.
01584       virtual void OnSetActive (
01585          );
01586 
01587       //! Set to ignore nonvisible items when doing layout.
01588       //! This must be called before Create() and is usually done in the subclass constructor.
01589       void SetIgnoreNonVisible (
01590          bool IgnoreNonVisible = true
01591          ) { m_IgnoreNonVisible = IgnoreNonVisible; }
01592 
01593       //! Set whether to not automatically add "expanding space" at end (bottom usually) of page.
01594       //! This must be called before Create() and is usually done in the subclass constructor.
01595       //! Default behavior is to add expanding space.
01596       void SetNoSpaceExpanding (
01597          bool NoSpaceExpanding = true
01598          ) { m_NoSpaceExpanding = NoSpaceExpanding; }
01599 
01600    private:
01601       #ifndef GENERATING_DOXYGEN_OUTPUT
01602 
01603    #ifdef WIN32_MFC
01604       class MYPAGE : public ETSLayoutPropertyPage {
01605          public:
01606             MYPAGE (
01607                LAYOUT_PAGE& page
01608                ): m_page(page) { }
01609             virtual ~MYPAGE (
01610                ) { }
01611          protected:
01612             virtual BOOL OnInitDialog ();
01613             virtual BOOL PreTranslateMessage (MSG *pMsg);
01614             virtual BOOL OnSetActive ();
01615          private:
01616             LAYOUT_PAGE& m_page;
01617             MYPAGE (const MYPAGE&);
01618             MYPAGE& operator= (const MYPAGE&);
01619          };
01620       friend class MYPAGE;
01621 
01622       MYPAGE m_Page;
01623       TOOLTIPCTRL *m_ToolTipCtrl;
01624    #else
01625       int m_index;
01626    #endif
01627 
01628       LAYOUT_BOOK *m_pBook;
01629       MGUI::LAYOUT_ORIENTATION m_Orientation;
01630       bool m_IgnoreNonVisible;
01631       bool m_NoSpaceExpanding;
01632 
01633       LAYOUT_PAGE (const LAYOUT_PAGE&);
01634       LAYOUT_PAGE& operator= (const LAYOUT_PAGE&);
01635 
01636       friend class LAYOUT_BOOK;
01637       #endif // GENERATING_DOXYGEN_OUTPUT
01638    };
01639 
01640 
01641 //---------------------------------------------------------------------------------------------------------
01642 
01643 class LAYOUT_EQUALIZER {
01644    public:
01645 
01646       //! Dimension to equalize.
01647       enum EQUALIZE {
01648          EQUALIZE_Width =     1,
01649          EQUALIZE_Height =    2,
01650          EQUALIZE_Both =      3
01651          };
01652 
01653       //! Constructor.
01654       LAYOUT_EQUALIZER (
01655          EQUALIZE equalize = EQUALIZE_Width  //!< What dimension(s) to equalize
01656          );
01657 
01658       //! Destructor.
01659       ~LAYOUT_EQUALIZER (
01660          );
01661 
01662       //! Add MGUI::CTRL to be equalized.
01663       void Add (
01664          MGUI::CTRL& control
01665          );
01666 
01667    #ifdef WIN32_MFC
01668       //! Add CWnd* control to be equalized.
01669       void Add (
01670          CWnd& wnd
01671          );
01672    #endif
01673 
01674       //! Perform equalization.
01675       //! This is automatically done by destructor if not done previously.
01676       void Equalize (
01677          );
01678 
01679       //! Set dimensions to equali