summaryrefslogtreecommitdiff
path: root/Bus/IvyProbe/ETSLayout.h
blob: 3bdc0dae720b52d426db6005a73450974439b94f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
////////////////////////////////////////////
//         ___ ____ _________________     //
//        / _/_  _// _______________/     //
//       / _/ / / / /  ___ ___ ____       //
//      /__/ /_/ / / /   // _/_  _/       //
//     _________/ / / / // _/ / /         //
// (c) 1998-2000_/ /___//_/  /_/          //
//                                        //
////////////////////////////////////////////
//          all rights reserved           //
////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// ETSLayoutDialog
//
// A class for smart layouting of Dialogs and such
//
// USAGE: See LayoutMgr.html
//
// AUTHOR: Erwin Tratar <tr@et-soft.de>
//
// DISCLAIMER:
//
// This Sourcecode and all accompaning material is ©1998-1999 Erwin Tratar. 
// All rights reserved.
//
// The source code may be used in compiled form in any way you desire 
// (including usage in commercial applications), providing that your 
// application adds essential code (i.e. it is not only a wrapper) to the 
// functionality found here
//
// Redistribution of the sourcecode itself, publication in any media or 
// inclusion in a library requires the authors expressed written consent.
// You may not sale this code for profit.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. USE IT 
// AT YOUR OWN RISK! THE AUTHOR ACCEPTS NO LIABILITY FOR ANY DAMAGE/LOSS OF 
// BUSINESS THAT THIS PRODUCT MAY CAUSE.


#if !defined(ETS_LAYOUTMGR_INCLUDED_)
#define ETS_LAYOUTMGR_INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// DialogMgr.h : header file
//
namespace ETSLayout
{

#ifdef CS_HELP
	typedef ETSCSHelpDialog		CBaseDialog;
	typedef ETSCSHelpFormView	CBaseFormView;
	typedef ETSCSHelpDlgBar		CBaseDialogBar;
	typedef ETSCSHelpPropPage	CBasePropertyPage;
#else
	typedef CDialog				CBaseDialog;
	typedef CFormView			CBaseFormView;
	typedef CDialogBar			CBaseDialogBar;
	typedef CPropertyPage		CBasePropertyPage;
#endif
}

// Support for CBCGDialogBar instead of CDialogBar available:
// you just have to change the typedef to CBaseDialogBar

#ifndef ETSGUI_EXT_CLASS
#define ETSGUI_EXT_CLASS
#endif

#include <afxtempl.h>

// Support for CBCGDialogBar instead of CDialogBar

/**
 * Controls whether the Icon is automatically set to IDR_MAINFRAME
 */
#define _AUTO_SET_ICON

/**
 * Forward class declarations
 */
class ETSLayoutDialog;
class ETSLayoutDialogBar;
class ETSLayoutFormView;
class ETSLayoutMgr;
class ETSLayoutPropertyPage;
class ETSLayoutPropertySheet;


/**
 * These are NOOPs now
 */
#define DECLARE_LAYOUT()
#define IMPLEMENT_LAYOUT()

/**
 * This is the default border size between the panes. You
 * may override it in Pane constructor, but it is the
 * fixed border around the root pane
 */
const int nDefaultBorder	= 5;

/**
 * The minimum size for not ABSOLUTE_XXX items
 */
const int nMinConstrain = 5;

class ETSGUI_EXT_CLASS ETSLayoutMgr
{
public:
	
	enum layResizeMode {
		GREEDY				= 0,		// Will eat up as much as it can
		ABSOLUTE_HORZ		= 1 << 0,	// Horizontal size is absolute
		RELATIVE_HORZ		= 1 << 1,	// Horizontal size in percent
		ABSOLUTE_VERT		= 1 << 2,	// Vertical size is absolute
		RELATIVE_VERT		= 1 << 3,	// Vertical size in percent

		NORESIZE			= ABSOLUTE_HORZ | ABSOLUTE_VERT,

		SIZE_MASK			= NORESIZE,

		ALIGN_LEFT			= 1 << 4,   // following only for NORESIZE
		ALIGN_RIGHT			= 1 << 5,
		ALIGN_TOP			= 1 << 6,
		ALIGN_BOTTOM		= 1 << 7,

		ALIGN_HCENTER		= ALIGN_LEFT    | ALIGN_RIGHT,	
		ALIGN_VCENTER		= ALIGN_TOP     | ALIGN_BOTTOM,

		ALIGN_CENTER		= ALIGN_HCENTER | ALIGN_VCENTER,

		ALIGN_FILL_HORZ		= 1 << 8,
		ALIGN_FILL_VERT		= 1 << 9,
		ALIGN_FILL			= ALIGN_FILL_HORZ | ALIGN_FILL_VERT,
	
/*		TRACKER_LEFT		= 1 << 10,	// not yet. May allow tracking of borders
		TRACKER_RIGHT		= 1 << 11,  // between items in the future
		TRACKER_TOP			= 1 << 12,
		TRACKER_BOTTOM		= 1 << 13,
*/
	};

	enum layOrientation {
		HORIZONTAL,
		VERTICAL
	};

	/**
	 * This is the base class for all kind of panes. 
	 */
	class ETSGUI_EXT_CLASS PaneBase {
		friend class ETSLayoutMgr;
		friend class CPaneBase;
		friend class CPane;

	public:

		/**
		 * Informs the caller how much of the given space this pane would
		 * like to receive in horizontal direction
		 */
		virtual int		getConstrainHorz(int sizeParent) = 0;


		/**
		 * Informs the caller how much of the given space this pane would
		 * like to receive in vertical direction
		 */
		virtual int		getConstrainVert(int sizeParent) = 0;

		/**
		 * Informs the caller how much of the given space this pane
		 * minimally need. This would be an absolute Value if 
		 * the mode contains ABSOLUTE_HORZ or an explicit minimum
		 * value, else nMinConstrain
		 */
		virtual int		getMinConstrainHorz() = 0;
		/**
		 * Informs the caller if there is an restriction for maximum
		 * space this pane needs. Return -1 for unrestricted (GREEDY
		 * or RELATIVE)
		 */
		virtual int		getMaxConstrainHorz() = 0;

		/**
		 * Informs the caller how much of the given space this pane
		 * minimally need. This would be an absolute Value if 
		 * the mode contains ABSOLUTE_VERT or an explicit minimum
		 * value, else nMinConstrain
		 */
		virtual int		getMinConstrainVert() = 0;

		/**
		 * Informs the caller if there is an restriction for maximum
		 * space this pane needs. Return -1 for unrestricted (GREEDY
		 * or RELATIVE)
		 */
		virtual int		getMaxConstrainVert() = 0;

		/**
		 * This will do the actual resize operation after the
		 * caller computed a new area for this pane
		 */
		virtual bool	resizeTo(CRect& rcNewArea) = 0;

		/**
		 * Constructor needed pointer to LayoutManager
		 */
		PaneBase( ETSLayoutMgr* pMgr )		{ m_pMgr = pMgr; };

		/**
		 * Virtual destructor needed in Container operations
		 */
		virtual ~PaneBase() {};

		/**
		 * Returs the Resize Mode of this pane
		 */
		DWORD	modeResize() { return m_modeResize; };

	protected:
		/**
		 * How this Item will be resized, a combination of the flags above
		 */
		DWORD	m_modeResize;

		/**
		 * A pointer to the holding LayoutManager derivate
		 */
		ETSLayoutMgr*		m_pMgr;
	};

	/**
	 * CPaneBase represents an autopointer to a PaneBase. Use this and you won't have to worry
	 * about cleaning up any Panes. Also this autopointer lets you return Pane objects
	 * from function without using pointers (at least you won't see them :) )
	 */
	struct ETSGUI_EXT_CLASS PaneHolder
	{
		PaneHolder(PaneBase* pPane );
		~PaneHolder();

		void	AddRef();
		void	Release();

		PaneBase*	m_pPane;
		long		m_nRefCount;
	};

	class ETSGUI_EXT_CLASS CPaneBase
	{
	protected:
		PaneHolder*		m_pPaneHolder;

	public:
		// Standardconstructor
		CPaneBase( );
		CPaneBase( PaneBase* pPane );
		CPaneBase( const CPaneBase& other );

		~CPaneBase();

		void operator=( PaneBase* pPane );
		void operator=( const CPaneBase& other );
		PaneBase* operator->() const;
		PaneBase* GetPaneBase()	{ return operator->(); }

		bool IsValid()			{ return (m_pPaneHolder != 0); }
		bool operator !()			{ return (m_pPaneHolder == 0); }

	};

	class Pane;
	class ETSGUI_EXT_CLASS CPane : public CPaneBase
	{
	public:
		// Standardconstructor
		CPane( );
		CPane( Pane* pPane );
		CPane( const CPane& other );

		~CPane();

		void operator=( Pane* pPane );
		void operator=( const CPane& other );
		Pane* operator->() const;
		Pane* GetPane()			{ return operator->(); }

		CPaneBase ConvertBase() const;

		CPane& operator<< ( const CPane pPane );
		CPane& operator<< ( const CPaneBase pItem );
	};



	/**
	 * PaneItem represents a single control
	 */
	class ETSGUI_EXT_CLASS PaneItem : public PaneBase {
		friend class ETSLayoutMgr;
		friend class Pane;
	protected:
		/**
		 * Creates a new PaneItem from an Control. If sizeX or sizeY are 0
		 * and modeResize is ABSOLUTE will copy the current dimensions of
		 * the control to m_sizeX/Y. So the appearance does not change
		 * from the Dialog Editor
		 */
		PaneItem( CWnd* pWnd, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);

		/**
		 * If your control is not mapped you can name it by its ChildID. Pass
		 * the pMgr to receive the CWnd* of nID. 
		 * The rest as stated above
		 */
		PaneItem( UINT nID, ETSLayoutMgr* pMgr, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=0, int sizeYMin=0);


	public:
		/**
		 * see PaneBase
		 */
		virtual int getConstrainHorz(int sizeParent);
		virtual int getConstrainVert(int sizeParent);
		virtual int getMinConstrainHorz();
		virtual int getMinConstrainVert();
		virtual int	getMaxConstrainHorz();
		virtual int	getMaxConstrainVert();
		virtual bool resizeTo(CRect& rcNewArea);

		bool	isDummy()				{ return (m_hwndCtrl == 0);	}

	protected:
		friend class ETSLayoutPropertySheet;

		/**
		 * The horizontal size of the control (see m_modeResize)
		 */
		int				m_sizeX;
		int				m_sizeXMin;

		/**
		 * The vertical size of the control (see m_modeResize)
		 */
		int				m_sizeY;
		int				m_sizeYMin;

		/**
		 * Child Control pointer
		 */
		HWND			m_hwndCtrl;

		/**
		 * Combo box needs special treatment
		 */
		bool			m_bComboSpecial;
	};


	/**
	 * This class encapsulates a Subpane (and indeed the root Pane too)
	 * it is a container of PaneBase* which it will recursivly resize
	 */
	class ETSGUI_EXT_CLASS Pane : public PaneBase {
		friend class ETSLayoutMgr;
		friend class CPaneBase;
		friend class CPane;
        friend class ETSLayoutPropertySheet;
        
	protected:
		/**
		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
		 */
		Pane( ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 );

	public:
		/**
		 * If your control is not mapped you can name it by its ChildID. Pass
		 * the pMgr to receive the CWnd* of nID. 
		 * The rest as stated above
		 */
		bool addItem( UINT nID, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);

		/**
		 * Creates a new PaneItem from an Control. If sizeX or sizeY are 0
		 * and modeResize is ABSOLUTE will copy the current dimensions of
		 * the control to m_sizeX/Y. So the appearance does not change
		 * from the Dialog Editor
		 */
		bool addItem( CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX=0, int sizeY=0, int sizeXMin=-1, int sizeYMin=-1);


		/**
		 * Add a whitespace Item (paneNull) of variable size with
		 * a minimum size of 0
		 */
		bool addItemGrowing();

		/**
		 * Add a whitespace Item (paneNull) with fixed size
		 */
		bool addItemFixed(int size);

		/**
		 * Add a whitespace Item (paneNull) of fixed size based on the
		 * current layout (as in the dialog template). Based on the layout
		 * of the pane vertical or horizontal spacing is considered
		 *
		 * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
		 */
		bool addItemSpaceBetween( CWnd* pWndFirst, CWnd* pWndSecond );
		bool addItemSpaceBetween( UINT nIDFirst, UINT nIDSecond );


		/**
		 * Add a whitespace Item (paneNull) of fixed size based on the
		 * size of another item
		 */
		bool addItemSpaceLike( CWnd* pWnd );
		bool addItemSpaceLike( UINT nID );


		/**
		 * Add an item to the pane, appending at the end. This may be either obtained
		 * by a call to ETSLayoutMgr::item() or one of the ETSLayoutMgr::paneXXX() calls
		 */
		bool addPane( CPaneBase pItem );
		bool addPane( CPane pSubpane, layResizeMode modeResize, int sizeSecondary /* = 0 */);

		virtual int		getConstrainHorz(int sizeParent);
		virtual int		getConstrainVert(int sizeParent);
		virtual int		getMinConstrainHorz();
		virtual int		getMinConstrainVert();
		virtual int		getMaxConstrainHorz();
		virtual int		getMaxConstrainVert();
		virtual bool	resizeTo(CRect& rcNewArea);

		/**
		 * The destructor takes care of destroying all Subpanes and items
		 */
		virtual ~Pane();

		/**
		 * Access to the orientation of this pane
		 */
		layOrientation	getOrientation() { return m_Orientation; };


	protected:

		int		resizeToAbsolute(int& availSpace, CArray<int,int>& sizePrimary, 
									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);
		
		bool	resizeToRelative(int& availSpace, CArray<int,int>& sizePrimary, 
									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);

		bool	resizeToGreedy(  int& availSpace, int nGreedy, CArray<int,int>& sizePrimary, 
									CArray<int,int>& sizeMin, CArray<int,int>& sizeMax);

		/**
		 * The orientation of the pane. Keep in mind that all subpanes
		 * must have the complementary orientation, i.e. a VERTICAL
		 * pane must have all HORIZONTAL SubPanes (or normal Items
		 * of course)
		 */
		layOrientation					m_Orientation;

		/**
		 * This array holds the pointers to the Items/SubPanes
		 */
		CArray<CPaneBase, CPaneBase>	m_paneItems;

		/**
		 * The secondary constrain
		 */
		int				m_sizeSecondary;

		/** 
		 * Size of gap between childs
		 */
		int				m_sizeBorder;
		int				m_sizeExtraBorder;
	};


	/**
	 * This class encapsulates a Subpane which is a Tab
	 * it will use calls to AdjustRect to position it's
	 * childs
	 */
	class ETSGUI_EXT_CLASS PaneTab : public Pane
	{
		friend class ETSLayoutMgr;

	protected:
		/**
		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
		 */
		PaneTab( CTabCtrl* pTab, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 );

	public:
		virtual int		getConstrainHorz(int sizeParent);
		virtual int		getConstrainVert(int sizeParent);
		virtual int		getMinConstrainHorz();
		virtual int		getMinConstrainVert();
		virtual int		getMaxConstrainHorz();
		virtual int		getMaxConstrainVert();
		virtual bool	resizeTo(CRect& rcNewArea);

	private:
		CTabCtrl* m_pTab;
	};

	/**
	 * This class encapsulates a Subpane which is a Static
	 * it will use calls to AdjustRect to position it's
	 * childs
	 */
	class ETSGUI_EXT_CLASS PaneCtrl : public Pane
	{
		friend class ETSLayoutMgr;
	protected:
		/**
		 * Tell the pane in which direction it is positioned. A HORIZONTAL pane
		 * arranges it's subpanes from left to right, a VERTICAL from top to bottom
		 */
		PaneCtrl( CWnd* pCtrl, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0);
		PaneCtrl( UINT nID, ETSLayoutMgr* pMgr, layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0 );

	public:

		virtual int		getConstrainHorz(int sizeParent);
		virtual int		getConstrainVert(int sizeParent);
		virtual int		getMinConstrainHorz();
		virtual int		getMinConstrainVert();
		virtual int		getMaxConstrainHorz();
		virtual int		getMaxConstrainVert();
		virtual bool	resizeTo(CRect& rcNewArea);

	private:
		HWND			m_hwndCtrl;
		int				m_sizeTopExtra;
	};




	ETSLayoutMgr(CWnd* pWnd)	{ m_pWnd = pWnd; m_sizeRootBorders = CSize(5,5); };
	virtual ~ETSLayoutMgr();

	virtual CRect GetRect() { CRect r; m_pWnd->GetClientRect(r); return r; };
	CWnd*	m_pWnd;
	CWnd*	GetWnd()		{ return m_pWnd; };
	void	setRootBorders(int cx, int cy)	{ m_sizeRootBorders = CSize(cx,cy); };

	/**
	 * Pass this for a pseudo Pane with no content
	 */
	static CWnd*	paneNull;

	/**
	 * Loads the current position and size from the registry using a supplied
	 * key. Will be loaded with AfxGetApp()->WriteProfileXXX(). You may
	 * specify a subfolder (e.g. Load( _T("MyDialog\\Layout") ); ). Will
	 * load the following keys:
	 *
	 * - lpstrRegKey+"SizeX";
	 * - lpstrRegKey+"SizeY";
	 * - lpstrRegKey+"PosX";
	 * - lpstrRegKey+"PosY";
	 *
	 * Is automatically called during OnActivate() if key specified in
	 * constructor.
	 */
	bool Load(LPCTSTR lpstrRegKey);

	/**
	 * Store the current position and size to the registry using a supplied
	 * key. Will be stored with AfxGetApp()->WriteProfileXXX(). You may
	 * specify a subfolder (e.g. Save( _T("MyDialog\\Layout") ); ). Will
	 * create the following keys:
	 *
	 * - lpstrRegKey+"SizeX";
	 * - lpstrRegKey+"SizeY";
	 * - lpstrRegKey+"PosX";
	 * - lpstrRegKey+"PosY";
	 *
	 * Is automatically called during DestroyWindow() if key specified in
	 * constructor.
	 */
	bool Save(LPCTSTR lpstrRegKey);

	/**
	 * Updates the layout after you specify the new
	 * layout
	 */
	virtual void UpdateLayout();
	virtual void UpdateLayout(CPane p) {
		if(m_RootPane.IsValid())
		{
			// free old root
			m_RootPane = 0;
		}
		m_RootPane = p;
		UpdateLayout();
	}

	/**
	 * Does the actual Layout, called from OnSize()
	 * Default implementation does nothing, use
	 * IMPLEMENT_LAYOUT in your derived class (see above)
	 */
	virtual void Layout(CRect& rcClient);


	/**
	 * Erasing only the these parts of the client area where
	 * there is no child window. Extra-code for group-boxes 
	 * included!
	 */
	void EraseBkgnd(CDC* pDC);

	/**
	 * Helperfunctions for the stream-interface. For usage see sample Application
	 * and/or documentation.
 	 */

	/**
	 * Create a new Pane. You may specify the resize
	 * mode for both directions. If you add modes for the secondary direction
	 * (i.e. *_VERT for a HORIZONTAL pane) then sizeSecondary is used as it's
	 * size. If you do not specify sizeSecondary and the mode is ABSOLUTE_VERT
	 * it will be computed as the maximum Height of all SubPanes (the same is
	 * true for VERTICAL panes and subpanes with *_HORZ)
	 */
	CPane pane( layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);

	/**
	 * Create one of the special control panes. Parameter are like pane(). For
	 * additional information see documentation
	 */
	CPane paneTab( CTabCtrl* pTab, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeSecondary = 0);
	CPane paneCtrl( UINT nID, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);
	CPane paneCtrl( CWnd* pCtrl, layOrientation orientation, layResizeMode modeResize = GREEDY, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0, int sizeTopExtra = 0, int sizeSecondary = 0);

	/**
	 * Creates a new PaneItem for an Control. If sizeX or sizeY are 0
	 * and modeResize is ABSOLUTE will copy the current dimensions of
	 * the control to m_sizeX/Y. So the appearance does not change
	 * from the Dialog Editor. size*Min = -1 means: do not make smaller
	 * than in Dialog Template.
	 */
	CPaneBase item(UINT nID, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);
	CPaneBase item(CWnd* pWnd, layResizeMode modeResize = GREEDY, int sizeX =0, int sizeY =0, int sizeXMin =-1, int sizeYMin =-1);


	/**
	 * Add a whitespace Item (paneNull) of variable size with
	 * a minimum size of 0
	 */
	CPaneBase itemGrowing(layOrientation orientation);

	/**
	 * Add a whitespace Item (paneNull) with fixed size
	 */
	CPaneBase itemFixed(layOrientation orientation, int sizePrimary);

	/**
	 * Add a whitespace Item (paneNull) of fixed size based on the
	 * current layout (as in the dialog template). Based on the layout
	 * of the pane vertical or horizontal spacing is considered
	 *
	 * First argument is the left (top) item for a HORIZONTAL (VERTICAL) pane
	 */
	CPaneBase itemSpaceBetween( layOrientation orientation, CWnd* pWndFirst, CWnd* pWndSecond );
	CPaneBase itemSpaceBetween( layOrientation orientation, UINT nIDFirst, UINT nIDSecond );

	/**
	 * Add a whitespace Item (paneNull) of fixed size based on the
	 * size of another item
	 */
	CPaneBase itemSpaceLike( layOrientation orientation, CWnd* pWnd );
	CPaneBase itemSpaceLike( layOrientation orientation, UINT nID );

protected:
	/**
	 * This holds the root pane. Fill in InitDialog()
	 */
	CPane m_RootPane;

	/**
 	 * Create a root pane
	 */
	CPane CreateRoot(layOrientation orientation, int sizeBorder = nDefaultBorder, int sizeExtraBorder = 0 )
	{
		if(m_RootPane.IsValid())
		{
			// free old root
			m_RootPane = 0;
		}
		m_RootPane = new Pane( this, orientation, sizeBorder, sizeExtraBorder);
		return m_RootPane;
	}

	/**
	 * Key in Registry where to store Size
	 */
	CString m_strRegStore;

	/**
	 * Borders around root
	 */
	CSize	m_sizeRootBorders;
};

inline ETSLayoutMgr::layResizeMode operator|(const ETSLayoutMgr::layResizeMode m1, 
											 const ETSLayoutMgr::layResizeMode m2)
	{ return (ETSLayoutMgr::layResizeMode)( (DWORD)m1|(DWORD)m2); }


/**
 * Base class for the Layout function. Derive your own class
 * from this or derive it from CDialog and modify _all_
 * references to CDialog to ETSLayoutDialog
 */
class ETSGUI_EXT_CLASS ETSLayoutDialog : public ETSLayout::CBaseDialog, protected ETSLayoutMgr
{
// Construction
public:
	ETSLayoutDialog(UINT nID, CWnd* pParent = NULL, LPCTSTR strName = NULL, bool bGripper = true);   // standard constructor

// Dialog Data
	//{{AFX_DATA(ETSLayoutDialog)
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ETSLayoutDialog)
	//}}AFX_VIRTUAL

// Implementation
protected:
	// Generated message map functions
	//{{AFX_MSG(ETSLayoutDialog)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	virtual BOOL OnInitDialog();
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	virtual CRect GetRect();

	bool		m_bGripper;
	CStatusBar	m_StatusBar;
};


/**
 * Base class for the Layout function. Derive your own class
 * from this or derive it from CDialog and modify _all_
 * references to CFormView to ETSLayoutFormView
 */
class ETSGUI_EXT_CLASS ETSLayoutFormView : public ETSLayout::CBaseFormView, public ETSLayoutMgr
{
// Construction
	DECLARE_DYNAMIC(ETSLayoutFormView)
public:
	ETSLayoutFormView(UINT nID, LPCTSTR strName = NULL);   // standard constructor
	virtual ~ETSLayoutFormView();

//	virtual void UpdateLayout();


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ETSLayoutDialog)
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(ETSLayoutDialog)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/**
 * Base class for the Layout function. Derive your own class
 * from this or derive it from CBCGDialogBar/CDialogBar and 
 * modify _all_  references to CBCGDialogBar/CDialogBar to 
 * ETSLayoutDialogBar
 */
class ETSGUI_EXT_CLASS ETSLayoutDialogBar : public ETSLayout::CBaseDialogBar, protected ETSLayoutMgr
{
// Construction
public:
#ifdef CS_HELP
	ETSLayoutDialogBar(UINT nID);
#else
	ETSLayoutDialogBar();
#endif


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ETSLayoutDialogBar)
	virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
	//}}AFX_VIRTUAL

	/**
	 * Override this to define Layout
	 */
	virtual BOOL Initialize() { return false; };
	virtual void UpdateLayout();

// Implementation
protected:
	// Generated message map functions
	//{{AFX_MSG(ETSLayoutDialogBar)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnDestroy();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG
	LRESULT OnInitDialog(WPARAM, LPARAM);
	DECLARE_MESSAGE_MAP()

	virtual CRect GetRect();
	bool	m_bInitialized;
};



/**************************************************
 ** ! the code is only tested for modal sheets ! **
 **************************************************/


/**
 * Resizable PropertySheet. Use this class standalone
 * or as your base class (instead CProptertySheet)
 */
class ETSGUI_EXT_CLASS ETSLayoutPropertySheet : public CPropertySheet, protected ETSLayoutMgr
{
	DECLARE_DYNAMIC(ETSLayoutPropertySheet)

// Construction
public:
	ETSLayoutPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);
	ETSLayoutPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, UINT iSelectPage = 0, LPCTSTR strName=NULL, bool bGripper=true);

// Operationen
public:
	void	SetAutoDestroy()		{ m_bAutoDestroy = true; }
	void	SetAutoDestroyPages()	{ m_bAutoDestroyPages = true; }
	void	ModelessWithButtons()	{ m_bModelessButtons = true; }
// Overrides
    virtual void AddMainArea(CPane paneRoot, CPaneBase itemTab);
    virtual void AddButtons(CPane paneBottom);
    
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ETSLayoutPropertySheet)
	public:
	virtual BOOL OnInitDialog();
	virtual void PostNcDestroy();
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~ETSLayoutPropertySheet();

	// Generated message map functions
protected:
	//{{AFX_MSG(ETSLayoutPropertySheet)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	afx_msg void OnDestroy();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	void Resize(int cx, int cy);

friend class ETSLayoutPropertyPage;

	void		Init(LPCTSTR strName, bool bGripper);
	CRect		m_rcStart;
	CRect		m_rcPage;
	bool		m_bGripper;
	CStatusBar	m_StatusBar;
	CPaneBase	m_ItemTab;
	bool		m_bAutoDestroy;
	bool		m_bAutoDestroyPages;
	bool		m_bModelessButtons;
};

/**
 * Base class for the Layout function. Derive your own class
 * from this or derive it from CPropertyPage and 
 * modify _all_  references to CPropertyPage to 
 * ETSLayoutPropertyPage
 */
class ETSGUI_EXT_CLASS ETSLayoutPropertyPage : public ETSLayout::CBasePropertyPage, protected ETSLayoutMgr
{
friend class ETSLayoutPropertySheet;

	DECLARE_DYNCREATE(ETSLayoutPropertyPage)

// Konstruktion
public:
	ETSLayoutPropertyPage( );
	ETSLayoutPropertyPage( UINT nIDTemplate, UINT nIDCaption = 0 );
	ETSLayoutPropertyPage( LPCTSTR lpszTemplateName, UINT nIDCaption = 0 );

	~ETSLayoutPropertyPage();


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ETSLayoutPropertyPage)
	public:
	virtual BOOL OnSetActive();
	//}}AFX_VIRTUAL

// Implementation
protected:
	// Generated message map functions
	//{{AFX_MSG(ETSLayoutPropertyPage)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
	virtual BOOL OnInitDialog();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
	afx_msg void OnDestroy();
	afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	virtual CRect GetRect();
	bool m_bLockMove;
	bool m_bResetBuddyOnNextTimeVisible;
};



//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(ETS_LAYOUTMGR_INCLUDED_)