]> cygwin.com Git - cygwin-apps/setup.git/blame - choose.h
2001-12-21 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / choose.h
CommitLineData
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
d0fa1c4e 19class Category;
bb849dbd 20class packagemeta;
8f53e82a
RC
21
22#define CATEGORY_EXPANDED 0
23#define CATEGORY_COLLAPSED 1
24
55e204f6
RC
25typedef 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
b24c88b3
RC
49}
50actions;
55e204f6
RC
51
52typedef enum
53{
54 VIEW_UNKNOWN,
55 VIEW_PACKAGE_FULL,
56 VIEW_PACKAGE,
57 VIEW_CATEGORY,
58 NVIEW
b24c88b3
RC
59}
60views;
8f53e82a
RC
61
62struct _header
63{
4bb38dfa 64 const char *text;
8f53e82a
RC
65 int slen;
66 int width;
67 int x;
68};
69
55e204f6 70#ifdef __cplusplus
cbfc4215
RC
71#include "list.h"
72#include "package_meta.h"
55e204f6 73
cbfc4215 74class view;
8f53e82a
RC
75
76class pick_line
77{
b24c88b3 78public:
cbfc4215
RC
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 () {};
88protected:
89 pick_line () {};
90 pick_line (pick_line const &);
91 pick_line &operator= (pick_line const &);
92};
93
94class pick_pkg_line : public pick_line
95{
96public:
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 &) {};
104private:
105 packagemeta & pkg;
106};
107
108class topbucket : public pick_line
109{
110public:
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
b24c88b3 116 {
cbfc4215
RC
117 int t = 0;
118 for (size_t n = 1; n <= bucket.number (); n++)
119 t += bucket[n]->itemcount ();
120 return t;
b24c88b3 121 };
cbfc4215
RC
122 virtual bool IsContainer (void) const {return true;}
123 virtual void insert (pick_line &aLine)
b24c88b3 124 {
cbfc4215
RC
125 bucket.registerbyobject (aLine);
126 }
127 virtual void empty (void);
128 virtual ~topbucket ();
129protected:
130 topbucket (topbucket const &);
131 topbucket &operator= (topbucket const &);
b24c88b3 132private:
cbfc4215 133 list <pick_line, char const *, strcasecmp> bucket;
8f53e82a 134};
cbfc4215 135
8f53e82a 136
cbfc4215
RC
137class pick_category_line : public topbucket
138{
139public:
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
163class view
8f53e82a 164{
b24c88b3
RC
165public:
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;
cbfc4215 173 view (views mode, HWND listview);
b24c88b3 174 const char *mode_caption ();
bb849dbd 175 void insert_pkg (packagemeta &);
cbfc4215 176 void insert_category (Category *, bool);
b24c88b3
RC
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;
cbfc4215
RC
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;}
8f53e82a 190
b24c88b3 191private:
cbfc4215
RC
192 HWND listview;
193 HWND listheader;
bb849dbd 194 views view_mode;
cbfc4215 195 void set_headers ();
b24c88b3 196 void init_headers (HDC dc);
8f53e82a 197};
55e204f6 198#endif /* __cplusplus */
8f53e82a 199#endif /* _CHOOSE_H_ */
This page took 0.044869 seconds and 5 git commands to generate.