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