]> cygwin.com Git - cygwin-apps/setup.git/blob - PickCategoryLine.cc
Suggest URLs for updated setup based on build architecture
[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 "package_db.h"
18 #include "PickView.h"
19 #include "window.h"
20 #include "package_meta.h"
21 #include "resource.h"
22 #include <sstream>
23
24 const std::wstring
25 PickCategoryLine::get_text (int col_num) const
26 {
27 if (col_num == pkgname_col)
28 {
29 std::ostringstream s;
30 s << cat_tree->category().first;
31 if (pkgcount)
32 s << " (" << pkgcount << ")";
33 return string_to_wstring(s.str());
34 }
35 else if (col_num == new_col)
36 {
37 return LoadStringW(packagemeta::action_caption (cat_tree->action()));
38 }
39 return L"";
40 }
41
42 int
43 PickCategoryLine::do_action(int col_num, int action_id)
44 {
45 if (col_num == pkgname_col)
46 {
47 cat_tree->collapsed() = ! cat_tree->collapsed();
48 theView.refresh();
49 }
50 else if (col_num == new_col)
51 {
52 theView.GetParent ()->SetBusy ();
53 int u = cat_tree->do_action((packagemeta::_actions)(action_id), theView.deftrust);
54 theView.GetParent ()->ClearBusy ();
55 return u;
56 }
57 return 1;
58 }
59
60 int
61 PickCategoryLine::do_default_action(int col_num)
62 {
63 return 0;
64 }
65
66 ActionList *
67 PickCategoryLine::get_actions(int col) const
68 {
69 ActionList *al = new ActionList();
70 packagemeta::_actions current_default = cat_tree->action();
71
72 al->add(IDS_ACTION_DEFAULT, (int)packagemeta::NoChange_action, (current_default == packagemeta::NoChange_action), TRUE);
73 al->add(IDS_ACTION_INSTALL, (int)packagemeta::Install_action, (current_default == packagemeta::Install_action), TRUE);
74 al->add(packagedb::task == PackageDB_Install ? IDS_ACTION_REINSTALL : IDS_ACTION_RETRIEVE,
75 (int)packagemeta::Reinstall_action, (current_default == packagemeta::Reinstall_action), TRUE);
76 al->add(IDS_ACTION_UNINSTALL, (int)packagemeta::Uninstall_action, (current_default == packagemeta::Uninstall_action), TRUE);
77
78 return al;
79 }
80
81 ListViewLine::State
82 PickCategoryLine::get_state() const
83 {
84 return cat_tree->collapsed() ? State::collapsed : State::expanded;
85 }
86
87 int
88 PickCategoryLine::get_indent() const
89 {
90 return indent;
91 }
92
93 const std::string
94 PickCategoryLine::get_tooltip(int col_num) const
95 {
96 return "";
97 }
98
99 int
100 PickCategoryLine::map_key_to_action(WORD vkey, int modkeys, int & col_num,
101 int & action_id) const
102 {
103 switch (vkey)
104 {
105 case VK_SPACE: // expand <> collapse category
106 col_num = pkgname_col;
107 return Action::Direct;
108 case VK_APPS: // install/reinstall/uninstall context menu for category
109 col_num = new_col;
110 return Action::PopUp;
111 }
112
113 return Action::None;
114 }
This page took 0.045891 seconds and 6 git commands to generate.