]> cygwin.com Git - cygwin-apps/setup.git/blob - PickCategoryLine.cc
2002-01-22 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / PickCategoryLine.cc
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
16 #include "PickCategoryLine.h"
17 #include "PickView.h"
18
19 void
20 PickCategoryLine::empty (void)
21 {
22 while (bucket.number ())
23 {
24 PickLine *line = bucket.removebyindex (1);
25 delete line;
26 }
27 }
28
29 void
30 PickCategoryLine::paint (HDC hdc, int x, int y, int row, int show_cat)
31 {
32 int r = y + row * theView.row_height;
33 if (show_label)
34 {
35 int by = r + theView.tm.tmHeight - 11;
36 TextOut (hdc,
37 x + theView.headers[theView.cat_col].x + HMARGIN / 2 +
38 depth * 8, r, cat.name, strlen (cat.name));
39 if (!labellength)
40 {
41 SIZE s;
42 GetTextExtentPoint32 (hdc, cat.name, strlen (cat.name), &s);
43 labellength = s.cx;
44 }
45 SelectObject (theView.bitmap_dc, theView.bm_spin);
46 BitBlt (hdc,
47 x + theView.headers[theView.cat_col].x +
48 labellength + depth * 8 +
49 ICON_MARGIN +
50 HMARGIN / 2, by, 11, 11, theView.bitmap_dc, 0, 0, SRCCOPY);
51 TextOut (hdc,
52 x + theView.headers[theView.cat_col].x +
53 labellength + depth * 8 +
54 ICON_MARGIN + SPIN_WIDTH +
55 HMARGIN, r, current_default.caption (), strlen (current_default.caption ()));
56 }
57 if (collapsed)
58 return;
59 int accum_row = row + (show_label ? 1 : 0);
60 for (size_t n = 1; n <= bucket.number (); n++)
61 {
62 bucket[n]->paint (hdc, x, y, accum_row, show_cat);
63 accum_row += bucket[n]->itemcount ();
64 }
65 }
66
67 int
68 PickCategoryLine::click (int const myrow, int const ClickedRow, int const x)
69 {
70 if (myrow == ClickedRow && show_label)
71 {
72 if ((size_t) x >= theView.headers[theView.cat_col].x +
73 labellength + depth * 8 + ICON_MARGIN + HMARGIN / 2)
74 {
75 ++current_default;
76
77 return set_action (current_default);
78 }
79 else
80 {
81 collapsed = !collapsed;
82 int accum_row = 0;
83 for (size_t n = 1; n <= bucket.number (); n++)
84 accum_row += bucket[n]->itemcount ();
85 return collapsed ? accum_row : -accum_row;
86 }
87 }
88 else
89 {
90 int accum_row = myrow + (show_label ? 1 : 0);
91 for (size_t n = 1; n <= bucket.number (); n++)
92 {
93 if (accum_row + bucket[n]->itemcount () > ClickedRow)
94 return bucket[n]->click (accum_row, ClickedRow, x);
95 accum_row += bucket[n]->itemcount ();
96 }
97 return 0;
98 }
99 }
100
101 int
102 PickCategoryLine::set_action (packagemeta::_actions action)
103 {
104 current_default = action;
105 int accum_diff = 0;
106 for (size_t n = 1; n <= bucket.number (); n++)
107 accum_diff += bucket[n]->set_action (current_default);
108 return accum_diff;
109 }
This page took 0.040723 seconds and 6 git commands to generate.