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