]>
Commit | Line | Data |
---|---|---|
97647369 RC |
1 | /* |
2 | * Copyright (c) 2002 Robert Collins. | |
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 <robertc@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
c93bc6d0 MB |
16 | #ifndef SETUP_PICKVIEW_H |
17 | #define SETUP_PICKVIEW_H | |
97647369 RC |
18 | |
19 | #include "win32.h" | |
3c054baf | 20 | #include "String++.h" |
693916f8 | 21 | #include "window.h" |
ee91d9be | 22 | #include "RECTWrapper.h" |
97647369 RC |
23 | |
24 | #define HMARGIN 10 | |
25 | #define ROW_MARGIN 5 | |
26 | #define ICON_MARGIN 4 | |
27 | #define RTARROW_WIDTH 11 | |
28 | #define SPIN_WIDTH 11 | |
29 | #define NEW_COL_SIZE_SLOP (ICON_MARGIN + SPIN_WIDTH + RTARROW_WIDTH) | |
97647369 RC |
30 | #define CHECK_SIZE 11 |
31 | ||
525531ca RC |
32 | #define CATEGORY_EXPANDED 0 |
33 | #define CATEGORY_COLLAPSED 1 | |
34 | ||
97647369 RC |
35 | class PickView; |
36 | #include "PickCategoryLine.h" | |
37 | #include "package_meta.h" | |
38 | ||
693916f8 | 39 | class PickView : public Window |
97647369 RC |
40 | { |
41 | public: | |
693916f8 RC |
42 | virtual bool Create (Window * Parent = NULL, DWORD Style = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, RECT * r = NULL); |
43 | virtual bool registerWindowClass (); | |
97647369 RC |
44 | class views; |
45 | class Header; | |
46 | int num_columns; | |
47 | views get_view_mode () | |
48 | { | |
49 | return view_mode; | |
50 | }; | |
22120c90 | 51 | void defaultTrust (trusts trust); |
97647369 | 52 | void set_view_mode (views _mode); |
525531ca | 53 | void setViewMode (PickView::views mode); |
d2be933d RC |
54 | void paint (HWND hwnd); |
55 | LRESULT CALLBACK list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode); | |
56 | LRESULT CALLBACK list_hscroll (HWND hwnd, HWND hctl, UINT code, int pos); | |
57 | LRESULT CALLBACK list_vscroll (HWND hwnd, HWND hctl, UINT code, int pos); | |
693916f8 | 58 | virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); |
97647369 | 59 | Header *headers; |
693916f8 RC |
60 | PickView (Category & cat); |
61 | void init(views _mode); | |
49cf3899 | 62 | ~PickView(); |
97647369 RC |
63 | const char *mode_caption (); |
64 | void insert_pkg (packagemeta &); | |
65 | void insert_category (Category *, bool); | |
66 | void clear_view (void); | |
67 | int click (int row, int x); | |
ec2dbbf0 | 68 | void refresh(); |
97647369 RC |
69 | int current_col; |
70 | int new_col; | |
2fa7c5a4 RC |
71 | int bintick_col; |
72 | int srctick_col; | |
97647369 RC |
73 | int cat_col; |
74 | int pkg_col; | |
75 | int last_col; | |
76 | int row_height; | |
77 | TEXTMETRIC tm; | |
78 | HDC bitmap_dc; | |
79 | HANDLE bm_spin,bm_rtarrow, bm_checkyes, bm_checkno, bm_checkna; | |
80 | trusts deftrust; | |
81 | HANDLE sysfont; | |
82 | int scroll_ulc_x, scroll_ulc_y; | |
83 | int header_height; | |
84 | PickCategoryLine contents; | |
85 | void scroll (HWND hwnd, int which, int *var, int code); | |
86 | HWND ListHeader (void) const | |
87 | { | |
88 | return listheader; | |
89 | } | |
90 | ||
97647369 RC |
91 | class views |
92 | { | |
93 | public: | |
94 | static const views Unknown; | |
95 | static const views PackageFull; | |
96 | static const views Package; | |
e0aec95e MB |
97 | static const views PackageKeeps; |
98 | static const views PackageSkips; | |
97647369 RC |
99 | static const views Category; |
100 | static const views NView; | |
101 | views ():_value (0) | |
102 | { | |
103 | }; | |
104 | views (int aInt) | |
105 | { | |
106 | _value = aInt; | |
e0aec95e | 107 | if (_value < 0 || _value > 5) |
97647369 RC |
108 | _value = 0; |
109 | } | |
110 | views & operator++ (); | |
111 | bool operator == (views const &rhs) | |
112 | { | |
113 | return _value == rhs._value; | |
114 | } | |
115 | bool operator != (views const &rhs) | |
116 | { | |
117 | return _value != rhs._value; | |
118 | } | |
119 | const char *caption (); | |
120 | ||
121 | private: | |
122 | int _value; | |
123 | }; | |
124 | ||
125 | class Header | |
126 | { | |
127 | public: | |
128 | const char *text; | |
129 | int slen; | |
130 | int width; | |
131 | int x; | |
132 | }; | |
133 | ||
134 | private: | |
693916f8 | 135 | static ATOM WindowClassAtom; |
97647369 RC |
136 | HWND listheader; |
137 | views view_mode; | |
ee91d9be RC |
138 | |
139 | // Stuff needed to handle resizing | |
140 | bool hasClientRect; | |
141 | RECTWrapper lastClientRect; | |
142 | ||
97647369 RC |
143 | void set_headers (); |
144 | void init_headers (HDC dc); | |
3c054baf | 145 | void note_width (Header *hdrs, HDC dc, String const &string, int addend, |
97647369 | 146 | int column); |
97647369 RC |
147 | }; |
148 | ||
c93bc6d0 | 149 | #endif /* SETUP_PICKVIEW_H */ |