]>
Commit | Line | Data |
---|---|---|
8f53e82a RC |
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 | ||
ab57ceaa RC |
19 | #include "proppage.h" |
20 | ||
d0fa1c4e | 21 | class Category; |
bb849dbd | 22 | class packagemeta; |
8f53e82a RC |
23 | |
24 | #define CATEGORY_EXPANDED 0 | |
25 | #define CATEGORY_COLLAPSED 1 | |
26 | ||
8f53e82a RC |
27 | struct _header |
28 | { | |
4bb38dfa | 29 | const char *text; |
8f53e82a RC |
30 | int slen; |
31 | int width; | |
32 | int x; | |
33 | }; | |
34 | ||
55e204f6 | 35 | #ifdef __cplusplus |
cbfc4215 RC |
36 | #include "list.h" |
37 | #include "package_meta.h" | |
55e204f6 | 38 | |
cbfc4215 | 39 | class view; |
8f53e82a RC |
40 | |
41 | class pick_line | |
42 | { | |
b24c88b3 | 43 | public: |
cbfc4215 RC |
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; | |
ab57ceaa RC |
52 | virtual ~ pick_line () |
53 | { | |
54 | }; | |
cbfc4215 | 55 | protected: |
ad3c7385 RC |
56 | pick_line () { }; |
57 | pick_line (char const *aKey):key(aKey) {}; | |
cbfc4215 | 58 | pick_line (pick_line const &); |
ab57ceaa | 59 | pick_line & operator= (pick_line const &); |
cbfc4215 RC |
60 | }; |
61 | ||
ab57ceaa | 62 | class pick_pkg_line:public pick_line |
cbfc4215 RC |
63 | { |
64 | public: | |
ab57ceaa RC |
65 | pick_pkg_line (packagemeta & apkg):pkg (apkg) |
66 | { | |
67 | key = apkg.key; | |
68 | }; | |
cbfc4215 RC |
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); | |
ab57ceaa RC |
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 | }; | |
cbfc4215 RC |
82 | private: |
83 | packagemeta & pkg; | |
84 | }; | |
85 | ||
ad3c7385 | 86 | class pick_category_line:public pick_line |
cbfc4215 RC |
87 | { |
88 | public: | |
d343da15 | 89 | pick_category_line (Category & _cat, size_t thedepth = 0, bool aBool = |
ad3c7385 RC |
90 | true, bool aBool2 = true):pick_line (_cat.key), current_default (Default_action), |
91 | cat (_cat), labellength (0), depth(thedepth) | |
d343da15 RC |
92 | { |
93 | if (aBool) | |
94 | { | |
95 | collapsed = true; | |
96 | show_label = true; | |
97 | } | |
98 | else | |
99 | { | |
100 | collapsed = false; | |
101 | show_label = aBool2; | |
102 | } | |
ab57ceaa | 103 | }; |
ad3c7385 | 104 | ~pick_category_line (){ empty (); } |
d343da15 | 105 | void ShowLabel(bool aBool = true) {show_label = aBool; if (!show_label) collapsed = false;} |
cbfc4215 RC |
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; | |
d343da15 | 112 | int t = show_label ? 1 : 0; |
cbfc4215 | 113 | for (size_t n = 1; n <= bucket.number (); n++) |
ab57ceaa RC |
114 | t += bucket[n]->itemcount (); |
115 | return t; | |
cbfc4215 | 116 | }; |
ad3c7385 RC |
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 (); | |
ab57ceaa | 126 | private: |
ad3c7385 RC |
127 | enum _actions { |
128 | Default_action, | |
129 | Install_action, | |
130 | Reinstall_action, | |
131 | Uninstall_action | |
132 | } current_default; | |
133 | char const * actiontext(); | |
ab57ceaa | 134 | Category & cat; |
cbfc4215 | 135 | bool collapsed; |
d343da15 | 136 | bool show_label; |
ad3c7385 | 137 | size_t labellength; |
d343da15 | 138 | size_t depth; |
ad3c7385 RC |
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; | |
cbfc4215 RC |
142 | }; |
143 | ||
144 | class view | |
8f53e82a | 145 | { |
b24c88b3 | 146 | public: |
b566778e | 147 | class views; |
b24c88b3 | 148 | int num_columns; |
d343da15 | 149 | views get_view_mode () |
b24c88b3 RC |
150 | { |
151 | return view_mode; | |
152 | }; | |
153 | void set_view_mode (views _mode); | |
154 | struct _header *headers; | |
d343da15 | 155 | view (views mode, HWND listview, Category &cat); |
b24c88b3 | 156 | const char *mode_caption (); |
bb849dbd | 157 | void insert_pkg (packagemeta &); |
cbfc4215 | 158 | void insert_category (Category *, bool); |
b24c88b3 RC |
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; | |
d343da15 | 167 | pick_category_line contents; |
cbfc4215 | 168 | void scroll (HWND hwnd, int which, int *var, int code); |
ab57ceaa RC |
169 | HWND ListHeader (void) const |
170 | { | |
171 | return listheader; | |
172 | } | |
8f53e82a | 173 | |
ad3c7385 RC |
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 | ||
b24c88b3 | 194 | private: |
ab57ceaa | 195 | HWND listview; |
cbfc4215 | 196 | HWND listheader; |
bb849dbd | 197 | views view_mode; |
cbfc4215 | 198 | void set_headers (); |
b24c88b3 | 199 | void init_headers (HDC dc); |
ab57ceaa | 200 | |
8f53e82a | 201 | }; |
ab57ceaa RC |
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 | ||
55e204f6 | 219 | #endif /* __cplusplus */ |
8f53e82a | 220 | #endif /* _CHOOSE_H_ */ |