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