]> cygwin.com Git - cygwin-apps/setup.git/blob - ControlAdjuster.h
Suppress bogus free-nonheap-object warning in iniparse.cc
[cygwin-apps/setup.git] / ControlAdjuster.h
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 CP_STRETCH_LEFTHALF,
40 CP_STRETCH_TOPHALF = CP_STRETCH_LEFTHALF,
41 CP_STRETCH_RIGHTHALF,
42 CP_STRETCH_BOTTOMHALF = CP_STRETCH_RIGHTHALF
43 };
44
45 /* left and right double as top and bottom. better labels sought. */
46 class ControlDimension
47 {
48 public:
49 ControlDimension(long &anInt1, long &anInt2) :
50 left(anInt1), right (anInt2){}
51 long &left;
52 long &right;
53 };
54
55 class ControlAdjuster
56 {
57 public:
58 struct ControlInfo
59 {
60 void adjust(HWND dlg, int widthChange, int heightChange) const;
61 // Control ID
62 int control;
63 /*
64 * Position specifiers.
65 */
66 ControlPosition horizontalPos;
67 ControlPosition verticalPos;
68 private:
69 void adjust (ControlPosition const &how, ControlDimension &where, int by) const;
70 };
71
72 /*
73 Adjust all the controls.
74 'controlInfo' an array with the moving information.
75 The terminating item of the array should have an ID <= 0.
76 */
77 static void AdjustControls (HWND dlg, const ControlInfo controlInfo[],
78 int widthChange, int heightChange);
79 };
80
81 class SizeProcessor
82 {
83 typedef std::vector<const ControlAdjuster::ControlInfo*> ControlInfos;
84 ControlInfos controlInfos;
85 bool rectValid;
86 RECTWrapper lastRect;
87 public:
88 SizeProcessor ();
89
90 void AddControlInfo (const ControlAdjuster::ControlInfo* controlInfo);
91 void UpdateSize (HWND dlg);
92 };
93
94 #endif // SETUP_CONTROLADJUSTER_H
This page took 0.037105 seconds and 5 git commands to generate.