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