Use git-describe to determine release version
[cygwin-setup.git] / PickView.h
blob0ce7581d7be2713b63b98d4cf79ddef03d80d8f8
1 /*
2 * Copyright (c) 2002 Robert Collins.
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.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
12 * Written by Robert Collins <robertc@hotmail.com>
16 #ifndef SETUP_PICKVIEW_H
17 #define SETUP_PICKVIEW_H
19 #include <string>
20 #include "win32.h"
21 #include "window.h"
22 #include "RECTWrapper.h"
24 #define HMARGIN 10
25 #define ROW_MARGIN 5
26 #define ICON_MARGIN 4
27 #define SPIN_WIDTH 11
28 #define CHECK_SIZE 11
29 #define TREE_INDENT 12
31 #define CATEGORY_EXPANDED 0
32 #define CATEGORY_COLLAPSED 1
34 class PickView;
35 #include "PickCategoryLine.h"
36 #include "package_meta.h"
38 class PickView : public Window
40 public:
41 virtual bool Create (Window * Parent = NULL, DWORD Style = WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN, RECT * r = NULL);
42 virtual bool registerWindowClass ();
43 class views;
44 class Header;
45 int num_columns;
46 void defaultTrust (trusts trust);
47 void cycleViewMode ();
48 void setViewMode (views mode);
49 void DrawIcon (HDC hdc, int x, int y, HANDLE hIcon);
50 void paint (HWND hwnd);
51 LRESULT CALLBACK list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode);
52 LRESULT CALLBACK list_hscroll (HWND hwnd, HWND hctl, UINT code, int pos);
53 LRESULT CALLBACK list_vscroll (HWND hwnd, HWND hctl, UINT code, int pos);
54 void set_vscroll_info (const RECT &r);
55 virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam);
56 Header *headers;
57 PickView (Category & cat);
58 void init(views _mode);
59 ~PickView();
60 const char *mode_caption ();
61 void setObsolete (bool doit);
62 void insert_pkg (packagemeta &);
63 void insert_category (Category *, bool);
64 int click (int row, int x);
65 void refresh();
66 int current_col;
67 int new_col;
68 int bintick_col;
69 int srctick_col;
70 int cat_col;
71 int size_col;
72 int pkg_col;
73 int last_col;
74 int row_height;
75 TEXTMETRIC tm;
76 HDC bitmap_dc, icon_dc;
77 HBITMAP bm_icon;
78 HRGN rect_icon;
79 HBRUSH bg_fg_brush;
80 HANDLE bm_spin, bm_checkyes, bm_checkno, bm_checkna, bm_treeplus, bm_treeminus;
81 trusts deftrust;
82 HANDLE sysfont;
83 int scroll_ulc_x, scroll_ulc_y;
84 int header_height;
85 PickCategoryLine contents;
86 void scroll (HWND hwnd, int which, int *var, int code, int howmany);
88 void SetPackageFilter (const std::string &filterString)
90 packageFilterString = filterString;
94 HWND ListHeader (void) const
96 return listheader;
99 class views
101 public:
102 static const views Unknown;
103 static const views PackageFull;
104 static const views Package;
105 static const views PackageKeeps;
106 static const views PackageSkips;
107 static const views Category;
108 static const views NView;
109 views ():_value (0)
112 views (int aInt)
114 _value = aInt;
115 if (_value < 0 || _value > 5)
116 _value = 0;
118 views & operator++ ();
119 bool operator == (views const &rhs)
121 return _value == rhs._value;
123 bool operator != (views const &rhs)
125 return _value != rhs._value;
127 const char *caption ();
129 private:
130 int _value;
133 class Header
135 public:
136 const char *text;
137 int width;
138 int x;
139 bool needs_clip;
142 private:
143 static ATOM WindowClassAtom;
144 HWND listheader;
145 views view_mode;
146 bool showObsolete;
147 std::string packageFilterString;
149 // Stuff needed to handle resizing
150 bool hasWindowRect;
151 RECTWrapper lastWindowRect;
152 int total_delta_x;
154 int set_header_column_order (views vm);
155 void set_headers ();
156 void init_headers (HDC dc);
157 void note_width (Header *hdrs, HDC dc, const std::string& string,
158 int addend, int column);
161 bool isObsolete (std::set <std::string, casecompare_lt_op> &categories);
162 bool isObsolete (const std::string& catname);
164 #endif /* SETUP_PICKVIEW_H */