]> cygwin.com Git - cygwin-apps/setup.git/blob - choose.h
2002-01-20 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / choose.h
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
16 #ifndef _CHOOSE_H_
17 #define _CHOOSE_H_
18
19 #include "proppage.h"
20
21 class Category;
22 class packagemeta;
23
24 #define CATEGORY_EXPANDED 0
25 #define CATEGORY_COLLAPSED 1
26
27 struct _header
28 {
29 const char *text;
30 int slen;
31 int width;
32 int x;
33 };
34
35 #ifdef __cplusplus
36 #include "list.h"
37 #include "package_meta.h"
38
39 class view;
40
41 class pick_line
42 {
43 public:
44 virtual void paint (HDC hdc, int x, int y, int row, int show_cat) = 0;
45 virtual int click (int const myrow, int const ClickedRow, int const x) = 0;
46 virtual int itemcount () const = 0;
47 // this may indicate bad inheritance model.
48 virtual bool IsContainer (void) const = 0;
49 virtual void insert (pick_line &) = 0;
50 // Never allocate to key, always allocated elsewhere
51 char const *key;
52 virtual ~ pick_line ()
53 {
54 };
55 protected:
56 pick_line () { };
57 pick_line (char const *aKey):key(aKey) {};
58 pick_line (pick_line const &);
59 pick_line & operator= (pick_line const &);
60 };
61
62 class pick_pkg_line:public pick_line
63 {
64 public:
65 pick_pkg_line (packagemeta & apkg):pkg (apkg)
66 {
67 key = apkg.key;
68 };
69 virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
70 virtual int click (int const myrow, int const ClickedRow, int const x);
71 virtual int itemcount () const
72 {
73 return 1;
74 }
75 virtual bool IsContainer (void) const
76 {
77 return false;
78 }
79 virtual void insert (pick_line &)
80 {
81 };
82 private:
83 packagemeta & pkg;
84 };
85
86 class pick_category_line:public pick_line
87 {
88 public:
89 pick_category_line (Category & _cat, size_t thedepth = 0, bool aBool =
90 true, bool aBool2 = true):pick_line (_cat.key), current_default (Default_action),
91 cat (_cat), labellength (0), depth(thedepth)
92 {
93 if (aBool)
94 {
95 collapsed = true;
96 show_label = true;
97 }
98 else
99 {
100 collapsed = false;
101 show_label = aBool2;
102 }
103 };
104 ~pick_category_line (){ empty (); }
105 void ShowLabel(bool aBool = true) {show_label = aBool; if (!show_label) collapsed = false;}
106 virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
107 virtual int click (int const myrow, int const ClickedRow, int const x);
108 virtual int itemcount () const
109 {
110 if (collapsed)
111 return 1;
112 int t = show_label ? 1 : 0;
113 for (size_t n = 1; n <= bucket.number (); n++)
114 t += bucket[n]->itemcount ();
115 return t;
116 };
117 virtual bool IsContainer (void) const
118 {
119 return true;
120 }
121 virtual void insert (pick_line & aLine)
122 {
123 bucket.registerbyobject (aLine);
124 }
125 void empty ();
126 private:
127 enum _actions {
128 Default_action,
129 Install_action,
130 Reinstall_action,
131 Uninstall_action
132 } current_default;
133 char const * actiontext();
134 Category & cat;
135 bool collapsed;
136 bool show_label;
137 size_t labellength;
138 size_t depth;
139 pick_category_line (pick_category_line const &);
140 pick_category_line & operator= (pick_category_line const &);
141 list < pick_line, char const *, strcasecmp > bucket;
142 };
143
144 class view
145 {
146 class views;
147 public:
148 int num_columns;
149 views get_view_mode ()
150 {
151 return view_mode;
152 };
153 void set_view_mode (views _mode);
154 struct _header *headers;
155 view (views mode, HWND listview, Category &cat);
156 const char *mode_caption ();
157 void insert_pkg (packagemeta &);
158 void insert_category (Category *, bool);
159 void clear_view (void);
160 int click (int row, int x);
161 int current_col;
162 int new_col;
163 int src_col;
164 int cat_col;
165 int pkg_col;
166 int last_col;
167 pick_category_line contents;
168 void scroll (HWND hwnd, int which, int *var, int code);
169 HWND ListHeader (void) const
170 {
171 return listheader;
172 }
173
174
175 class views {
176 public:
177 static const views Unknown;
178 static const views PackageFull;
179 static const views Package;
180 static const views Category;
181 static const views NView;
182 views () : _value (0) {};
183 views (int aInt) { _value = aInt; if (_value < 0 || _value > 3)
184 _value = 0;}
185 views& operator++ ();
186 bool operator == (views const &rhs) {return _value == rhs._value;}
187 bool operator != (views const &rhs) {return _value != rhs._value;}
188 const char * caption ();
189
190 private:
191 int _value;
192 };
193
194 private:
195 HWND listview;
196 HWND listheader;
197 views view_mode;
198 void set_headers ();
199 void init_headers (HDC dc);
200
201 };
202
203 class ChooserPage:public PropertyPage
204 {
205 public:
206 ChooserPage ()
207 {
208 };
209 virtual ~ ChooserPage ()
210 {
211 };
212
213 virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam);
214
215 bool Create ();
216 virtual void OnActivate ();
217 };
218
219 #endif /* __cplusplus */
220 #endif /* _CHOOSE_H_ */
This page took 0.046204 seconds and 6 git commands to generate.