]> cygwin.com Git - cygwin-apps/setup.git/blob - choose.h
2001-12-22 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[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 typedef enum
28 {
29 /* Note that the next four items must be in the same order as the
30 TRUST items in ini.h. */
31 ACTION_UNKNOWN,
32 ACTION_PREV,
33 ACTION_CURR,
34 ACTION_TEST,
35 ACTION_SKIP,
36 ACTION_UNINSTALL,
37 ACTION_REDO,
38 ACTION_SRC_ONLY,
39 ACTION_LAST,
40 ACTION_ERROR,
41 /* Use ACTION_SAME when you want to leve the current version unaltered
42 * even if it that version is not in setup.ini
43 */
44 ACTION_SAME = 100,
45 /* Actions taken when installed version matches the selected version. */
46 ACTION_SAME_PREV = ACTION_PREV + ACTION_SAME,
47 ACTION_SAME_CURR = ACTION_CURR + ACTION_SAME,
48 ACTION_SAME_TEST = ACTION_TEST + ACTION_SAME,
49 /* Last action. */
50 ACTION_SAME_LAST
51 }
52 actions;
53
54 typedef enum
55 {
56 VIEW_UNKNOWN,
57 VIEW_PACKAGE_FULL,
58 VIEW_PACKAGE,
59 VIEW_CATEGORY,
60 NVIEW
61 }
62 views;
63
64 struct _header
65 {
66 const char *text;
67 int slen;
68 int width;
69 int x;
70 };
71
72 #ifdef __cplusplus
73 #include "list.h"
74 #include "package_meta.h"
75
76 class view;
77
78 class pick_line
79 {
80 public:
81 virtual void paint (HDC hdc, int x, int y, int row, int show_cat) = 0;
82 virtual int click (int const myrow, int const ClickedRow, int const x) = 0;
83 virtual int itemcount () const = 0;
84 // this may indicate bad inheritance model.
85 virtual bool IsContainer (void) const = 0;
86 virtual void insert (pick_line &) = 0;
87 // Never allocate to key, always allocated elsewhere
88 char const *key;
89 virtual ~ pick_line ()
90 {
91 };
92 protected:
93 pick_line ()
94 {
95 };
96 pick_line (pick_line const &);
97 pick_line & operator= (pick_line const &);
98 };
99
100 class pick_pkg_line:public pick_line
101 {
102 public:
103 pick_pkg_line (packagemeta & apkg):pkg (apkg)
104 {
105 key = apkg.key;
106 };
107 virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
108 virtual int click (int const myrow, int const ClickedRow, int const x);
109 virtual int itemcount () const
110 {
111 return 1;
112 }
113 virtual bool IsContainer (void) const
114 {
115 return false;
116 }
117 virtual void insert (pick_line &)
118 {
119 };
120 private:
121 packagemeta & pkg;
122 };
123
124 class topbucket:public pick_line
125 {
126 public:
127 topbucket ()
128 {
129 key = 0;
130 };
131 virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
132 virtual int click (int const myrow, int const ClickedRow, int const x);
133 virtual int itemcount () const
134 {
135 int t = 0;
136 for (size_t n = 1; n <= bucket.number (); n++)
137 t += bucket[n]->itemcount ();
138 return t;
139 };
140 virtual bool IsContainer (void) const
141 {
142 return true;
143 }
144 virtual void insert (pick_line & aLine)
145 {
146 bucket.registerbyobject (aLine);
147 }
148 virtual void empty (void);
149 virtual ~ topbucket ();
150 protected:
151 topbucket (topbucket const &);
152 topbucket & operator= (topbucket const &);
153 private:
154 list < pick_line, char const *, strcasecmp > bucket;
155 };
156
157
158 class pick_category_line:public topbucket
159 {
160 public:
161 pick_category_line (Category & _cat, bool aBool =
162 true):cat (_cat), collapsed (aBool)
163 {
164 key = _cat.key;
165 };
166 virtual void paint (HDC hdc, int x, int y, int row, int show_cat);
167 virtual int click (int const myrow, int const ClickedRow, int const x);
168 virtual int itemcount () const
169 {
170 if (collapsed)
171 return 1;
172 int t = 1;
173 for (size_t n = 1; n <= bucket.number (); n++)
174 t += bucket[n]->itemcount ();
175 return t;
176 };
177 virtual void insert (pick_line & aLine)
178 {
179 bucket.registerbyobject (aLine);
180 }
181 private:
182 Category & cat;
183 list < pick_line, char const *, strcasecmp > bucket;
184 bool collapsed;
185 };
186
187 class view
188 {
189 public:
190 int num_columns;
191 views get_view_mode ()
192 {
193 return view_mode;
194 };
195 void set_view_mode (views _mode);
196 struct _header *headers;
197 view (views mode, HWND listview);
198 const char *mode_caption ();
199 void insert_pkg (packagemeta &);
200 void insert_category (Category *, bool);
201 void clear_view (void);
202 int click (int row, int x);
203 int current_col;
204 int new_col;
205 int src_col;
206 int cat_col;
207 int pkg_col;
208 int last_col;
209 // pick_line *lines;
210 // int nlines;
211 topbucket contents;
212 void scroll (HWND hwnd, int which, int *var, int code);
213 HWND ListHeader (void) const
214 {
215 return listheader;
216 }
217
218 private:
219 HWND listview;
220 HWND listheader;
221 views view_mode;
222 void set_headers ();
223 void init_headers (HDC dc);
224
225 };
226
227 class ChooserPage:public PropertyPage
228 {
229 public:
230 ChooserPage ()
231 {
232 };
233 virtual ~ ChooserPage ()
234 {
235 };
236
237 virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam);
238
239 bool Create ();
240 virtual void OnActivate ();
241 };
242
243 #endif /* __cplusplus */
244 #endif /* _CHOOSE_H_ */
This page took 0.096328 seconds and 6 git commands to generate.