root/branches/3.00/src/ControlAdjuster.h

Revision 644, 2.2 kB (checked in by fujii, 3 years ago)

Add new netinstall source.

Line 
1 /*
2  * Copyright (c) 2003, Frank Richter <frichter@gmx.li>
3  * Copyrught (c) 2003, Robert Collins <rbtcollins@hotmail.com>
4  *
5  *     This program is free software; you can redistribute it and/or modify
6  *     it under the terms of the GNU General Public License as published by
7  *     the Free Software Foundation; either version 2 of the License, or
8  *     (at your option) any later version.
9  *
10  *     A copy of the GNU General Public License can be found at
11  *     http://www.gnu.org/
12  *
13  * Written by Frank Richter.
14  *
15  */
16
17 #ifndef SETUP_CONTROLADJUSTER_H
18 #define SETUP_CONTROLADJUSTER_H
19
20 #include <vector>
21
22 #include "win32.h"
23 #include "RECTWrapper.h"
24
25 /*
26   This is a helper class to move/resize controls of a dialog when it's size
27   is changed. It's no fancy layouting stuff, but rather just moving them
28   around - to, for example, keep controls at the bottom really at the bottom
29   when the size changes.
30  */
31
32 enum ControlPosition {
33   CP_LEFT = 0,
34   CP_TOP = CP_LEFT,
35   CP_CENTERED,
36   CP_RIGHT,
37   CP_BOTTOM = CP_RIGHT,
38   CP_STRETCH,
39 };
40
41 /* left and right double as top and bottom. better labels sought. */
42 class ControlDimension
43 {
44   public:
45     ControlDimension(long &anInt1, long &anInt2) :
46       left(anInt1), right (anInt2){}
47     long &left;
48     long &right;
49 };
50
51 class ControlAdjuster
52 {
53 public:
54   struct ControlInfo
55   {
56     void adjust(HWND dlg, int widthChange, int heightChange) const;
57     // Control ID
58     int control;
59     /*
60      * Position specifiers.
61      */
62     ControlPosition horizontalPos;
63     ControlPosition verticalPos;
64     private:
65       void adjust (ControlPosition const &how, ControlDimension &where, int by) const;
66   };
67  
68   /*
69     Adjust all the controls.
70     'controlInfo' an array with the moving information.
71     The terminating item of the array should have an ID <= 0.
72    */
73   static void AdjustControls (HWND dlg, const ControlInfo controlInfo[],
74     int widthChange, int heightChange);
75 };
76
77 class SizeProcessor
78 {
79   typedef std::vector<const ControlAdjuster::ControlInfo*> ControlInfos;
80   ControlInfos controlInfos;
81   bool rectValid;
82   RECTWrapper lastRect;
83 public:
84   SizeProcessor ();
85  
86   void AddControlInfo (const ControlAdjuster::ControlInfo* controlInfo);
87   void UpdateSize (HWND dlg);
88 };
89
90 #endif // SETUP_CONTROLADJUSTER_H
Note: See TracBrowser for help on using the browser.