PageRenderTime 61ms CodeModel.GetById 13ms app.highlight 41ms RepoModel.GetById 1ms app.codeStats 1ms

/install/xbt/linux/misc/windows/ETSLayout.h

http://torrentpier2.googlecode.com/
C++ Header | 964 lines | 375 code | 173 blank | 416 comment | 5 complexity | 42937379301bef51bf7bba66ec30b2fb MD5 | raw file
  1////////////////////////////////////////////
  2//         ___ ____ _________________     //
  3//        / _/_  _// _______________/     //
  4//       / _/ / / / /  ___ ___ ____       //
  5//      /__/ /_/ / / /   // _/_  _/       //
  6//     _________/ / / / // _/ / /         //
  7// (c) 1998-2000_/ /___//_/  /_/          //
  8//                                        //
  9////////////////////////////////////////////
 10//          all rights reserved           //
 11////////////////////////////////////////////
 12
 13/////////////////////////////////////////////////////////////////////////////
 14// ETSLayoutDialog
 15//
 16// A class for smart layouting of Dialogs and such
 17//
 18// USAGE: See LayoutMgr.html
 19//
 20// AUTHOR: Erwin Tratar <tr@et-soft.de>
 21//
 22// DISCLAIMER:
 23//
 24// This Sourcecode and all accompaning material is Š1998-1999 Erwin Tratar. 
 25// All rights reserved.
 26//
 27// The source code may be used in compiled form in any way you desire 
 28// (including usage in commercial applications), providing that your 
 29// application adds essential code (i.e. it is not only a wrapper) to the 
 30// functionality found here
 31//
 32// Redistribution of the sourcecode itself, publication in any media or 
 33// inclusion in a library requires the authors expressed written consent.
 34// You may not sale this code for profit.
 35//
 36// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. USE IT 
 37// AT YOUR OWN RISK! THE AUTHOR ACCEPTS NO LIABILITY FOR ANY DAMAGE/LOSS OF 
 38// BUSINESS THAT THIS PRODUCT MAY CAUSE.
 39
 40
 41#if !defined(ETS_LAYOUTMGR_INCLUDED_)
 42#define ETS_LAYOUTMGR_INCLUDED_
 43
 44#if _MSC_VER >= 1000
 45#pragma once
 46#endif // _MSC_VER >= 1000
 47// DialogMgr.h : header file
 48//
 49
 50namespace ETSLayout
 51{
 52
 53#ifdef CS_HELP
 54	typedef ETSCSHelpDialog		CBaseDialog;
 55	typedef ETSCSHelpFormView	CBaseFormView;
 56	typedef ETSCSHelpDlgBar		CBaseDialogBar;
 57	typedef ETSCSHelpPropPage	CBasePropertyPage;
 58#else
 59	typedef CDialog				CBaseDialog;
 60	typedef CFormView			CBaseFormView;
 61	typedef CDialogBar			CBaseDialogBar;
 62	typedef CPropertyPage		CBasePropertyPage;
 63#endif
 64}
 65
 66// Support for CBCGDialogBar instead of CDialogBar available:
 67// you just have to change the typedef to CBaseDialogBar
 68
 69#ifndef ETSGUI_EXT_CLASS
 70#define ETSGUI_EXT_CLASS
 71#endif
 72
 73#include <afxtempl.h>
 74
 75// Support for CBCGDialogBar instead of CDialogBar
 76
 77/**
 78 * Controls whether the Icon is automatically set to IDR_MAINFRAME
 79 */
 80#define _AUTO_SET_ICON
 81
 82/**
 83 * Forward class declarations
 84 */
 85class ETSLayoutDialog;
 86class ETSLayoutDialogBar;
 87class ETSLayoutFormView;
 88class ETSLayoutMgr;
 89class ETSLayoutPropertyPage;
 90class ETSLayoutPropertySheet;
 91
 92
 93/**
 94 * These are NOOPs now
 95 */
 96#define DECLARE_LAYOUT()
 97#define IMPLEMENT_LAYOUT()
 98
 99/**
100 * This is the default border size between the panes. You
101 * may override it in Pane constructor, but it is the
102 * fixed border around the root pane
103 */
104const int nDefaultBorder	= 5;
105
106/**
107 * The minimum size for not ABSOLUTE_XXX items
108 */
109const int nMinConstrain = 5;
110
111class ETSGUI_EXT_CLASS ETSLayoutMgr
112{
113public:
114	
115	enum layResizeMode {
116		GREEDY				= 0,		// Will eat up as much as it can
117		ABSOLUTE_HORZ		= 1 << 0,	// Horizontal size is absolute
118		RELATIVE_HORZ		= 1 << 1,	// Horizontal size in percent
119		ABSOLUTE_VERT		= 1 << 2,	// Vertical size is absolute
120		RELATIVE_VERT		= 1 << 3,	// Vertical size in percent
121
122		NORESIZE			= ABSOLUTE_HORZ | ABSOLUTE_VERT,
123
124		SIZE_MASK			= NORESIZE,
125
126		ALIGN_LEFT			= 1 << 4,   // following only for NORESIZE
127		ALIGN_RIGHT			= 1 << 5,
128		ALIGN_TOP			= 1 << 6,
129		ALIGN_BOTTOM		= 1 << 7,
130
131		ALIGN_HCENTER		= ALIGN_LEFT    | ALIGN_RIGHT,	
132		ALIGN_VCENTER		= ALIGN_TOP     | ALIGN_BOTTOM,
133
134		ALIGN_CENTER		= ALIGN_HCENTER | ALIGN_VCENTER,
135
136		ALIGN_FILL_HORZ		= 1 << 8,
137		ALIGN_FILL_VERT		= 1 << 9,
138		ALIGN_FILL			= ALIGN_FILL_HORZ | ALIGN_FILL_VERT,
139	
140/*		TRACKER_LEFT		= 1 << 10,	// not yet. May allow tracking of borders
141		TRACKER_RIGHT		= 1 << 11,  // between items in the future
142		TRACKER_TOP			= 1 << 12,
143		TRACKER_BOTTOM		= 1 << 13,
144*/
145	};
146
147	enum layOrientation {
148		HORIZONTAL,
149		VERTICAL
150	};
151
152	/**
153	 * This is the base class for all kind of panes. 
154	 */
155	class ETSGUI_EXT_CLASS PaneBase {
156		friend class ETSLayoutMgr;
157		friend class CPaneBase;
158		friend class CPane;
159
160	public:
161
162		/**
163		 * Informs the caller how much of the given space this pane would
164		 * like to receive in horizontal direction
165		 */
166		virtual int		getConstrainHorz(int sizeParent) = 0;
167
168
169		/**
170		 * Informs the caller how much of the given space this pane would
171		 * like to receive in vertical direction
172		 */
173		virtual int		getConstrainVert(int sizeParent) = 0;
174
175		/**
176		 * Informs the caller how much of the given space this pane
177		 * minimally need. This would be an absolute Value if 
178		 * the mode contains ABSOLUTE_HORZ or an explicit minimum
179		 * value, else nMinConstrain
180		 */
181		virtual int		getMinConstrainHorz() = 0;
182		/**
183		 * Informs the caller if there is an restriction for maximum
184		 * space this pane needs. Return -1 for unrestricted (GREEDY
185		 * or RELATIVE)
186		 */
187		virtual int		getMaxConstrainHorz() = 0;
188
189		/**
190		 * Informs the caller how much of the given space this pane
191		 * minimally need. This would be an absolute Value if 
192		 * the mode contains ABSOLUTE_VERT or an explicit minimum
193		 * value, else nMinConstrain
194		 */
195		virtual int		getMinConstrainVert() = 0;
196
197		/**
198		 * Informs the caller if there is an restriction for maximum
199		 * space this pane needs. Return -1 for unrestricted (GREEDY
200		 * or RELATIVE)
201		 */
202		virtual int		getMaxConstrainVert() = 0;
203
204		/**
205		 * This will do the actual resize operation after the
206		 * caller computed a new area for this pane
207		 */
208		virtual bool	resizeTo(CRect& rcNewArea) = 0;
209
210		/**
211		 * Constructor needed pointer to LayoutManager
212		 */
213		PaneBase( ETSLayoutMgr* pMgr )		{ m_pMgr = pMgr; };
214
215		/**
216		 * Virtual destructor needed in Container operations
217		 */
218		virtual ~PaneBase() {};
219
220		/**
221		 * Returs the Resize Mode of this pane
222		 */
223		DWORD	modeResize() { return m_modeResize; };
224
225	protected:
226		/**
227		 * How this Item will be resized, a combination of the flags above
228		 */
229		DWORD	m_modeResize;
230
231		/**
232		 * A pointer to the holding LayoutManager derivate
233		 */
234		ETSLayoutMgr*		m_pMgr;
235	};
236
237	/**
238	 * CPaneBase represents an autopointer to a PaneBase. Use this and you won't have to worry
239	 * about cleaning up any Panes. Also this autopointer lets you return Pane objects
240	 * from function without using pointers (at least you won't see them :) )
241	 */
242	struct ETSGUI_EXT_CLASS PaneHolder
243	{
244		PaneHolder(PaneBase* pPane );
245		~PaneHolder();
246
247		void	AddRef();
248		void	Release();
249
250		PaneBase*	m_pPane;
251		long		m_nRefCount;
252	};
253
254	class ETSGUI_EXT_CLASS CPaneBase
255	{
256	protected:
257		PaneHolder*		m_pPaneHolder;
258
259	public:
260		// Standardconstructor
261		CPaneBase( );
262		CPaneBase( PaneBase* pPane );
263		CPaneBase( const CPaneBase& other );
264
265		~CPaneBase();
266
267		void operator=( PaneBase* pPane );
268		void operator=( const CPaneBase& other );
269		PaneBase* operator->() const;
270		PaneBase* GetPaneBase()	{ return operator->(); }
271
272		bool IsValid()			{ return (m_pPaneHolder != 0); }
273		bool operator !()		{ return (m_pPaneHolder == 0); }
274
275	};
276
277	class Pane;
278	class ETSGUI_EXT_CLASS CPane : public CPaneBase
279	{
280	public:
281		// Standardconstructor
282		CPane( );
283		CPane( Pane* pPane );
284		CPane( const CPane& other );
285
286		~CPane();
287
288		void operator=( Pane* pPane );
289		void operator=( const CPane& other );
290		Pane* operator->() const;
291		Pane* GetPane()			{ return operator->(); }
292
293		CPaneBase ConvertBase() const;
294
295		CPane& operator<< ( const CPane pPane );
296		CPane& operator<< ( const CPaneBase pItem );
297	};
298
299
300
301	/**
302	 * PaneItem represents a single control
303	 */
304	class ETSGUI_EXT_CLASS PaneItem : public PaneBase {
305		friend class ETSLayoutMgr;
306		friend class Pane;
307	protected:
308		/**
309		 * Creates a new PaneItem from an Control. If sizeX or sizeY are 0
310		 * and modeResize is ABSOLUTE will copy the current dimensions of
311		 * the control to m_sizeX/Y. So the appearance does not change
312		 * from the Dialog Editor
313		 */
314		PaneItem( CWnd* pWnd, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);
315
316		/**
317		 * If your control is not mapped you can name it by its ChildID. Pass
318		 * the pMgr to receive the CWnd* of nID. 
319		 * The rest as stated above
320		 */
321		PaneItem( UINT nID, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);
322
323
324	public:
325		/**
326		 * see PaneBase
327		 */
328		virtual int getConstrainHorz(int sizeParent);
329		virtual int getConstrainVert(int sizeParent);
330		virtual int getMinConstrainHorz();
331		virtual int getMinConstrainVert();
332		virtual int	getMaxConstrainHorz();
333		virtual int	getMaxConstrainVert();
334		virtual bool resizeTo(CRect& rcNewArea);
335
336		bool	isDummy()				{ return (m_hwndCtrl == 0);	}
337
338	protected:
339		friend class ETSLayoutPropertySheet;
340
341		/**
342		 * The horizontal size of the control (see m_modeResize)
343		 */
344		int				m_sizeX;
345		int				m_sizeXMin;
346
347		/**
348		 * The vertical size of the control (see m_modeResize)
349		 */
350		int				m_sizeY;
351		int				m_sizeYMin;
352
353		/**
354		 * Child Control pointer
355		 */
356		HWND			m_hwndCtrl;
357
358		/**
359		 * Combo box needs special treatment
360		 */
361		bool			m_bComboSpecial;
362	};
363
364
365	/**
366	 * This class encapsulates a Subpane (and indeed the root Pane too)
367	 * it is a container of PaneBase* which it will recursivly resize
368	 */
369	class ETSGUI_EXT_CLASS Pane : public PaneBase {
370		friend class ETSLayoutMgr;
371		friend class CPaneBase;
372		friend class CPane;
373        friend class ETSLayoutPropertySheet;
374        
375	protected:
376		/**
377		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
378		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
379		 */
380		Pane( ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 );
381
382	public:
383		/**
384		 * If your control is not mapped you can name it by its ChildID. Pass
385		 * the pMgr to receive the CWnd* of nID. 
386		 * The rest as stated above
387		 */
388		bool addItem( UINT nID, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);
389
390		/**
391		 * Creates a new PaneItem from an Control. If sizeX or sizeY are 0
392		 * and modeResize is ABSOLUTE will copy the current dimensions of
393		 * the control to m_sizeX/Y. So the appearance does not change
394		 * from the Dialog Editor
395		 */
396		bool addItem( CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);
397
398
399		/**
400		 * Add a whitespace Item (paneNull) of variable size with
401		 * a minimum size of 0
402		 */
403		bool addItemGrowing();
404
405		/**
406		 * Add a whitespace Item (paneNull) with fixed size
407		 */
408		bool addItemFixed(int size);
409
410		/**
411		 * Add a whitespace Item (paneNull) of fixed size based on the
412		 * current layout (as in the dialog template). Based on the layout
413		 * of the pane vertical or horizontal spacing is considered
414		 *
415		 * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
416		 */
417		bool addItemSpaceBetween( CWnd* pWndFirst, CWnd* pWndSecond );
418		bool addItemSpaceBetween( UINT nIDFirst, UINT nIDSecond );
419
420
421		/**
422		 * Add a whitespace Item (paneNull) of fixed size based on the
423		 * size of another item
424		 */
425		bool addItemSpaceLike( CWnd* pWnd );
426		bool addItemSpaceLike( UINT nID );
427
428
429		/**
430		 * Add an item to the pane, appending at the end. This may be either obtained
431		 * by a call to ETSLayoutMgr::item() or one of the ETSLayoutMgr::paneXXX() calls
432		 */
433		bool addPane( CPaneBase pItem );
434		bool addPane( CPane pSubpane, layResizeMode modeResize, int sizeSecondary /* = 0 */);
435
436		virtual int		getConstrainHorz(int sizeParent);
437		virtual int		getConstrainVert(int sizeParent);
438		virtual int		getMinConstrainHorz();
439		virtual int		getMinConstrainVert();
440		virtual int		getMaxConstrainHorz();
441		virtual int		getMaxConstrainVert();
442		virtual bool	resizeTo(CRect& rcNewArea);
443
444		/**
445		 * The destructor takes care of destroying all Subpanes and items
446		 */
447		virtual ~Pane();
448
449		/**
450		 * Access to the orientation of this pane
451		 */
452		layOrientation	getOrientation() { return m_Orientation; };
453
454
455	protected:
456
457		int		resizeToAbsolute(int& availSpace, CArray<int,int>& sizePrimary, 
458									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
459		
460		bool	resizeToRelative(int& availSpace, CArray<int,int>& sizePrimary, 
461									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
462
463		bool	resizeToGreedy(  int& availSpace, int nGreedy, CArray<int,int>& sizePrimary, 
464									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
465
466		/**
467		 * The orientation of the pane. Keep in mind that all subpanes
468		 * must have the complementary orientation, i.e. a VERTICAL
469		 * pane must have all HORIZONTAL SubPanes (or normal Items
470		 * of course)
471		 */
472		layOrientation					m_Orientation;
473
474		/**
475		 * This array holds the pointers to the Items/SubPanes
476		 */
477		CArray<CPaneBase, CPaneBase>	m_paneItems;
478
479		/**
480		 * The secondary constrain
481		 */
482		int				m_sizeSecondary;
483
484		/** 
485		 * Size of gap between childs
486		 */
487		int				m_sizeBorder;
488		int				m_sizeExtraBorder;
489	};
490
491
492	/**
493	 * This class encapsulates a Subpane which is a Tab
494	 * it will use calls to AdjustRect to position it's
495	 * childs
496	 */
497	class ETSGUI_EXT_CLASS PaneTab : public Pane
498	{
499		friend class ETSLayoutMgr;
500
501	protected:
502		/**
503		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
504		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
505		 */
506		PaneTab( CTabCtrl* pTab, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 );
507
508	public:
509		virtual int		getConstrainHorz(int sizeParent);
510		virtual int		getConstrainVert(int sizeParent);
511		virtual int		getMinConstrainHorz();
512		virtual int		getMinConstrainVert();
513		virtual int		getMaxConstrainHorz();
514		virtual int		getMaxConstrainVert();
515		virtual bool	resizeTo(CRect& rcNewArea);
516
517	private:
518		CTabCtrl* m_pTab;
519	};
520
521	/**
522	 * This class encapsulates a Subpane which is a Static
523	 * it will use calls to AdjustRect to position it's
524	 * childs
525	 */
526	class ETSGUI_EXT_CLASS PaneCtrl : public Pane
527	{
528		friend class ETSLayoutMgr;
529	protected:
530		/**
531		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
532		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
533		 */
534		PaneCtrl( CWnd* pCtrl, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0);
535		PaneCtrl( UINT nID, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0 );
536
537	public:
538
539		virtual int		getConstrainHorz(int sizeParent);
540		virtual int		getConstrainVert(int sizeParent);
541		virtual int		getMinConstrainHorz();
542		virtual int		getMinConstrainVert();
543		virtual int		getMaxConstrainHorz();
544		virtual int		getMaxConstrainVert();
545		virtual bool	resizeTo(CRect& rcNewArea);
546
547	private:
548		HWND			m_hwndCtrl;
549		int				m_sizeTopExtra;
550	};
551
552
553
554
555	ETSLayoutMgr(CWnd* pWnd)	{ m_pWnd = pWnd; m_sizeRootBorders = CSize(5,5); };
556	virtual ~ETSLayoutMgr();
557
558	virtual CRect GetRect() { CRect r; m_pWnd->GetClientRect(r); return r; };
559	CWnd*	m_pWnd;
560	CWnd*	GetWnd()		{ return m_pWnd; };
561	void	setRootBorders(int cx, int cy)	{ m_sizeRootBorders = CSize(cx,cy); };
562
563	/**
564	 * Pass this for a pseudo Pane with no content
565	 */
566	static CWnd*	paneNull;
567
568	/**
569	 * Loads the current position and size from the registry using a supplied
570	 * key. Will be loaded with AfxGetApp()->WriteProfileXXX(). You may
571	 * specify a subfolder (e.g. Load( _T("MyDialog\\Layout") ); ). Will
572	 * load the following keys:
573	 *
574	 * - lpstrRegKey+"SizeX";
575	 * - lpstrRegKey+"SizeY";
576	 * - lpstrRegKey+"PosX";
577	 * - lpstrRegKey+"PosY";
578	 *
579	 * Is automatically called during OnActivate() if key specified in
580	 * constructor.
581	 */
582	bool Load(LPCTSTR lpstrRegKey);
583
584	/**
585	 * Store the current position and size to the registry using a supplied
586	 * key. Will be stored with AfxGetApp()->WriteProfileXXX(). You may
587	 * specify a subfolder (e.g. Save( _T("MyDialog\\Layout") ); ). Will
588	 * create the following keys:
589	 *
590	 * - lpstrRegKey+"SizeX";
591	 * - lpstrRegKey+"SizeY";
592	 * - lpstrRegKey+"PosX";
593	 * - lpstrRegKey+"PosY";
594	 *
595	 * Is automatically called during DestroyWindow() if key specified in
596	 * constructor.
597	 */
598	bool Save(LPCTSTR lpstrRegKey);
599
600	/**
601	 * Updates the layout after you specify the new
602	 * layout
603	 */
604	virtual void UpdateLayout();
605	virtual void UpdateLayout(CPane p) {
606		if(m_RootPane.IsValid())
607		{
608			// free old root
609			m_RootPane = 0;
610		}
611		m_RootPane = p;
612		UpdateLayout();
613	}
614
615	/**
616	 * Does the actual Layout, called from OnSize()
617	 * Default implementation does nothing, use
618	 * IMPLEMENT_LAYOUT in your derived class (see above)
619	 */
620	virtual void Layout(CRect& rcClient);
621
622
623	/**
624	 * Erasing only the these parts of the client area where
625	 * there is no child window. Extra-code for group-boxes 
626	 * included!
627	 */
628	void EraseBkgnd(CDC* pDC);
629
630	/**
631	 * Helperfunctions for the stream-interface. For usage see sample Application
632	 * and/or documentation.
633 	 */
634
635	/**
636	 * Create a new Pane. You may specify the resize
637	 * mode for both directions. If you add modes for the secondary direction
638	 * (i.e. *_VERT for a HORIZONTAL pane) then sizeSecondary is used as it's
639	 * size. If you do not specify sizeSecondary and the mode is ABSOLUTE_VERT
640	 * it will be computed as the maximum Height of all SubPanes (the same is
641	 * true for VERTICAL panes and subpanes with *_HORZ)
642	 */
643	CPane pane( layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);
644
645	/**
646	 * Create one of the special control panes. Parameter are like pane(). For
647	 * additional information see documentation
648	 */
649	CPane paneTab( CTabCtrl* pTab, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);
650	CPane paneCtrl( UINT nID, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);
651	CPane paneCtrl( CWnd* pCtrl, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);
652
653	/**
654	 * Creates a new PaneItem for an Control. If sizeX or sizeY are 0
655	 * and modeResize is ABSOLUTE will copy the current dimensions of
656	 * the control to m_sizeX/Y. So the appearance does not change
657	 * from the Dialog Editor. size*Min = -1 means: do not make smaller
658	 * than in Dialog Template.
659	 */
660	CPaneBase item(UINT nID, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);
661	CPaneBase item(CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);
662
663
664	/**
665	 * Add a whitespace Item (paneNull) of variable size with
666	 * a minimum size of 0
667	 */
668	CPaneBase itemGrowing(layOrientation orientation);
669
670	/**
671	 * Add a whitespace Item (paneNull) with fixed size
672	 */
673	CPaneBase itemFixed(layOrientation orientation, int sizePrimary);
674
675	/**
676	 * Add a whitespace Item (paneNull) of fixed size based on the
677	 * current layout (as in the dialog template). Based on the layout
678	 * of the pane vertical or horizontal spacing is considered
679	 *
680	 * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
681	 */
682	CPaneBase itemSpaceBetween( layOrientation orientation, CWnd* pWndFirst, CWnd* pWndSecond );
683	CPaneBase itemSpaceBetween( layOrientation orientation, UINT nIDFirst, UINT nIDSecond );
684
685	/**
686	 * Add a whitespace Item (paneNull) of fixed size based on the
687	 * size of another item
688	 */
689	CPaneBase itemSpaceLike( layOrientation orientation, CWnd* pWnd );
690	CPaneBase itemSpaceLike( layOrientation orientation, UINT nID );
691
692protected:
693	/**
694	 * This holds the root pane. Fill in InitDialog()
695	 */
696	CPane m_RootPane;
697
698	/**
699 	 * Create a root pane
700	 */
701	CPane CreateRoot(layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 )
702	{
703		if(m_RootPane.IsValid())
704		{
705			// free old root
706			m_RootPane = 0;
707		}
708		m_RootPane = new Pane( this, orientation, sizeBorder, sizeExtraBorder);
709		return m_RootPane;
710	}
711
712	/**
713	 * Key in Registry where to store Size
714	 */
715	CString m_strRegStore;
716
717	/**
718	 * Borders around root
719	 */
720	CSize	m_sizeRootBorders;
721};
722
723inline ETSLayoutMgr::layResizeMode operator|(const ETSLayoutMgr::layResizeMode m1, 
724											 const ETSLayoutMgr::layResizeMode m2)
725	{ return (ETSLayoutMgr::layResizeMode)( (DWORD)m1|(DWORD)m2); }
726
727
728/**
729 * Base class for the Layout function. Derive your own class
730 * from this or derive it from CDialog and modify _all_
731 * references to CDialog to ETSLayoutDialog
732 */
733class ETSGUI_EXT_CLASS ETSLayoutDialog : public ETSLayout::CBaseDialog, protected ETSLayoutMgr
734{
735// Construction
736public:
737	ETSLayoutDialog(UINT nID, CWnd* pParent = NULL, LPCTSTR strName = NULL, bool bGripper = true);   // standard constructor
738
739// Dialog Data
740	//{{AFX_DATA(ETSLayoutDialog)
741	//}}AFX_DATA
742
743
744// Overrides
745	// ClassWizard generated virtual function overrides
746	//{{AFX_VIRTUAL(ETSLayoutDialog)
747	//}}AFX_VIRTUAL
748
749// Implementation
750protected:
751	// Generated message map functions
752	//{{AFX_MSG(ETSLayoutDialog)
753	afx_msg void OnSize(UINT nType, int cx, int cy);
754	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
755	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
756	virtual BOOL OnInitDialog();
757	afx_msg void OnDestroy();
758	//}}AFX_MSG
759	DECLARE_MESSAGE_MAP()
760
761	virtual CRect GetRect();
762
763	bool		m_bGripper;
764	CStatusBar	m_StatusBar;
765};
766
767
768/**
769 * Base class for the Layout function. Derive your own class
770 * from this or derive it from CDialog and modify _all_
771 * references to CFormView to ETSLayoutFormView
772 */
773class ETSGUI_EXT_CLASS ETSLayoutFormView : public ETSLayout::CBaseFormView, public ETSLayoutMgr
774{
775// Construction
776	DECLARE_DYNAMIC(ETSLayoutFormView)
777public:
778	ETSLayoutFormView(UINT nID, LPCTSTR strName = NULL);   // standard constructor
779	virtual ~ETSLayoutFormView();
780
781//	virtual void UpdateLayout();
782
783
784// Overrides
785	// ClassWizard generated virtual function overrides
786	//{{AFX_VIRTUAL(ETSLayoutDialog)
787	//}}AFX_VIRTUAL
788
789// Implementation
790protected:
791
792	// Generated message map functions
793	//{{AFX_MSG(ETSLayoutDialog)
794	afx_msg void OnSize(UINT nType, int cx, int cy);
795	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
796	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
797	//}}AFX_MSG
798	DECLARE_MESSAGE_MAP()
799};
800
801
802/**
803 * Base class for the Layout function. Derive your own class
804 * from this or derive it from CBCGDialogBar/CDialogBar and 
805 * modify _all_  references to CBCGDialogBar/CDialogBar to 
806 * ETSLayoutDialogBar
807 */
808class ETSGUI_EXT_CLASS ETSLayoutDialogBar : public ETSLayout::CBaseDialogBar, protected ETSLayoutMgr
809{
810// Construction
811public:
812#ifdef CS_HELP
813	ETSLayoutDialogBar(UINT nID);
814#else
815	ETSLayoutDialogBar();
816#endif
817
818
819// Overrides
820	// ClassWizard generated virtual function overrides
821	//{{AFX_VIRTUAL(ETSLayoutDialogBar)
822	virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
823	//}}AFX_VIRTUAL
824
825	/**
826	 * Override this to define Layout
827	 */
828	virtual BOOL Initialize() { return false; };
829	virtual void UpdateLayout();
830
831// Implementation
832protected:
833	// Generated message map functions
834	//{{AFX_MSG(ETSLayoutDialogBar)
835	afx_msg void OnSize(UINT nType, int cx, int cy);
836	afx_msg void OnDestroy();
837	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
838	//}}AFX_MSG
839	LRESULT OnInitDialog(WPARAM, LPARAM);
840	DECLARE_MESSAGE_MAP()
841
842	virtual CRect GetRect();
843	bool	m_bInitialized;
844};
845
846
847
848/**************************************************
849 ** ! the code is only tested for modal sheets ! **
850 **************************************************/
851
852
853/**
854 * Resizable PropertySheet. Use this class standalone
855 * or as your base class (instead CProptertySheet)
856 */
857class ETSGUI_EXT_CLASS ETSLayoutPropertySheet : public CPropertySheet, protected ETSLayoutMgr
858{
859	DECLARE_DYNAMIC(ETSLayoutPropertySheet)
860
861// Construction
862public:
863	ETSLayoutPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);
864	ETSLayoutPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);
865
866// Operationen
867public:
868	void	SetAutoDestroy()		{ m_bAutoDestroy = true; }
869	void	SetAutoDestroyPages()	{ m_bAutoDestroyPages = true; }
870	void	ModelessWithButtons()	{ m_bModelessButtons = true; }
871// Overrides
872    virtual void AddMainArea(CPane paneRoot, CPaneBase itemTab);
873    virtual void AddButtons(CPane paneBottom);
874    
875	// ClassWizard generated virtual function overrides
876	//{{AFX_VIRTUAL(ETSLayoutPropertySheet)
877	public:
878	virtual BOOL OnInitDialog();
879	virtual void PostNcDestroy();
880	//}}AFX_VIRTUAL
881
882// Implementation
883public:
884	virtual ~ETSLayoutPropertySheet();
885
886	// Generated message map functions
887protected:
888	//{{AFX_MSG(ETSLayoutPropertySheet)
889	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
890	afx_msg void OnSize(UINT nType, int cx, int cy);
891	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
892	afx_msg void OnDestroy();
893	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
894	//}}AFX_MSG
895	DECLARE_MESSAGE_MAP()
896
897	void Resize(int cx, int cy);
898
899friend class ETSLayoutPropertyPage;
900
901	void		Init(LPCTSTR strName, bool bGripper);
902	CRect		m_rcStart;
903	CRect		m_rcPage;
904	bool		m_bGripper;
905	CStatusBar	m_StatusBar;
906	CPaneBase	m_ItemTab;
907	bool		m_bAutoDestroy;
908	bool		m_bAutoDestroyPages;
909	bool		m_bModelessButtons;
910};
911
912/**
913 * Base class for the Layout function. Derive your own class
914 * from this or derive it from CPropertyPage and 
915 * modify _all_  references to CPropertyPage to 
916 * ETSLayoutPropertyPage
917 */
918class ETSGUI_EXT_CLASS ETSLayoutPropertyPage : public ETSLayout::CBasePropertyPage, protected ETSLayoutMgr
919{
920friend class ETSLayoutPropertySheet;
921
922	DECLARE_DYNCREATE(ETSLayoutPropertyPage)
923
924// Konstruktion
925public:
926	ETSLayoutPropertyPage( );
927	ETSLayoutPropertyPage( UINT nIDTemplate, UINT nIDCaption = 0 );
928	ETSLayoutPropertyPage( LPCTSTR lpszTemplateName, UINT nIDCaption = 0 );
929
930	~ETSLayoutPropertyPage();
931
932
933// Overrides
934	// ClassWizard generated virtual function overrides
935	//{{AFX_VIRTUAL(ETSLayoutPropertyPage)
936	public:
937	virtual BOOL OnSetActive();
938	//}}AFX_VIRTUAL
939
940// Implementation
941protected:
942	// Generated message map functions
943	//{{AFX_MSG(ETSLayoutPropertyPage)
944	afx_msg void OnSize(UINT nType, int cx, int cy);
945	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
946	virtual BOOL OnInitDialog();
947	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
948	afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
949	afx_msg void OnDestroy();
950	afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
951	//}}AFX_MSG
952	DECLARE_MESSAGE_MAP()
953
954	virtual CRect GetRect();
955	bool m_bLockMove;
956	bool m_bResetBuddyOnNextTimeVisible;
957};
958
959
960
961//{{AFX_INSERT_LOCATION}}
962// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
963
964#endif // !defined(ETS_LAYOUTMGR_INCLUDED_)