annotate src/menu.cc @ 80:2f1ecc1c5f72

Huge cleanup -- move some global variables into a struct.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Sep 2011 17:39:49 +0300
parents a68786b9c74b
children 4580d53cefff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
2 * menu.cc
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
3 * AYM 1998-12-01
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 This file is part of Yadex.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 Yadex incorporates code from DEU 5.21 that was put in the public domain in
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 1994 by Raphaël Quinet and Brendon Wyber.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 The rest of Yadex is Copyright © 1997-2003 André Majorel and others.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 This program is free software; you can redistribute it and/or modify it under
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 the terms of the GNU General Public License as published by the Free Software
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 Foundation; either version 2 of the License, or (at your option) any later
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 version.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 This program is distributed in the hope that it will be useful, but WITHOUT
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 You should have received a copy of the GNU General Public License along with
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 Place, Suite 330, Boston, MA 02111-1307, USA.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 /*
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 These are the pop-up and pull-down menus.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 Events that are not understood (E.G. [Left] and [Right])
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 are put back in the input buffer before the
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 function returns.
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 #include "yadex.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 #include "events.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 #include "gfx.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 #include "menu.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 #include "menudata.h"
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
6
8ae95c3addd0 Remove useless extern declaration that causes a warning.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46 const char *MI_SEPARATION = "";
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 const unsigned char MIF_MACTIVE = 0x03;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 const unsigned char MIF_MTICK = 0x0c;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 const unsigned char MIF_SEPAR = 0x10;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
52 const short VSPACE = 2; // Pixels between items
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
56 * Menu_item - a menu item class
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 class Menu_item
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
60 public: Menu_item()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
62 flags = MIF_NTICK | MIF_NACTIVE;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
63 tilde_key = YK_;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
64 shortcut_key = YK_;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
65 str = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
68 unsigned char flags; // Logical-or of MIF_?ACTIVE MIF_?TICK MIF_SEPAR
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
69 inpev_t tilde_key;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
70 inpev_t shortcut_key;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
71 short y; // Top of item, relative to ly0. If there is a
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
72 // separation, it is above y.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
73 const char *str;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 union
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
76 bool s; // Static
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
77 bool *v; // Pointer to variable
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
78 struct
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
79 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
80 micb_t f; // Pointer to callback function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
81 micbarg_t a; // Argument
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
82 } f;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 tick;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 union
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
87 bool s; // Static
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
88 bool *v; // Pointer to variable
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
89 struct
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
90 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
91 micb_t f; // Pointer to callback function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
92 micbarg_t a; // Argument
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
93 } f;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 active;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 };
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
100 * Menu_priv - Menu's private data
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 class Menu_priv
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
104 public:Menu_priv()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
106 flags = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
107 title = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
108 title_len = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
109 items_ks_len = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
110 items_len = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
111 items.clear();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
112 user_ox0 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
113 user_oy0 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
114 ox0 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
115 oy0 = -1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
116 need_geom = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
117 visible = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
118 visible_disp = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
119 line = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
120 line_disp = UINT_MAX;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
121 item_height = FONTH + VSPACE;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
124 void vinit(Menu & m, const char *title, va_list argp);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
125 void cook();
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
126 void draw();
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
127 void draw_one_line(size_t line, bool highlighted);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
128 void geom();
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
129 int process_event(const input_status_t * is);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 // Menu data
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
132 unsigned char flags; // MF_MENUDATA
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
133 // The strings come from a Menu_data.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
134 // MF_POPUP Used as popup (not pull-down) menu
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
135 // If set, the title is shown and
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
136 // button releases are treated
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
137 // differently.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
138 // MF_TICK At least one item can be ticked
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
139 // (has the MIF_[SVF]TICK flag).
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
140 // MF_SHORTCUT At least one item has a key
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
141 // shortcut key.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
142 // MF_NUMS Force the use of standard
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
143 // shortcuts [0-9a-zA-Z] even if
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
144 // index/key shortcuts exist.
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
145 const char *title; // NULL if no title
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
146 size_t title_len; // Length of <title> (or 0 if none)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
147 size_t items_ks_len; // Length of the longest item counting key sc.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
148 size_t items_len; // Length of the longest item not counting k.s.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 const Menu_data *menudata;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
150 std::vector < Menu_item > items;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 // Geometry as the user would like it to be
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
153 int user_ox0; // Top left corner. < 0 means centered.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
154 int user_oy0; // Top left corner. < 0 means centered.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 // Geometry as it should be
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
157 int ix0, iy0, ix1, iy1; // Corners of inner edge of window
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
158 int ox0, oy0, ox1, oy1; // Corners of outer edge of window
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
159 int width; // Overall width of window
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
160 int height; // Overall height of window
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
161 int ty0; // Y-pos of title
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
162 int ly0; // Y-pos of first item
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 // Geometry as it is displayed
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
165 int ox0_disp;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
166 int oy0_disp;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
167 int width_disp;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
168 int height_disp;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 // Status
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
171 bool need_geom; // Need to call geom() again
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
172 bool visible; // Should the menu be visible ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
173 bool visible_disp; // Is it really visible ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
174 size_t line; // Which line should be highlighted ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
175 size_t line_disp; // Which line is actually highlighted ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
176 inpev_t _last_shortcut_key; // Shortcut key for last selected item.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 // Misc
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 unsigned short item_height;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 };
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 /* First subscript : 0 = normal, 1 = greyed out
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 Second subscript : 0 = normal, 1 = highlighted */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
185 const colour_pair_t menu_colour[2][2] = {
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
186 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
187 {WINBG, WINFG}, // Normal entry
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
188 {WINBG_HL, WINFG_HL} // Normal entry, highlighted
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
189 },
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
190 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
191 {WINBG, WINFG_DIM}, // Greyed out entry
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
192 {WINBG_HL, WINFG_DIM_HL} // Greyed out entry, highlighted
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
193 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 };
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
196 const unsigned char MF_POPUP = 0x01;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
197 const unsigned char MF_TICK = 0x02;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
198 const unsigned char MF_TILDE = 0x04;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 const unsigned char MF_SHORTCUT = 0x08;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
200 const unsigned char MF_NUMS = 0x10;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 const unsigned char MF_MENUDATA = 0x20;
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
205 * Menu::Menu - ctor from arguments in variable number
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
207 * Another ctor for Menu, suited to the creation of pull
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
208 * down menus.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
210 * Expects the title of the menu followed by repeats of
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
211 * either of the following sets of arguments, in any order :
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
213 * 1) Menu item
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
215 * A menu item is made of 3 or more arguments :
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
217 * const char *
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
218 * A NUL-terminated string that will be
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
219 * used to display the item. The first
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
220 * occurrence of a tilde ("~") in the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
221 * string indicates that the following
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
222 * character will be used as a local
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
223 * shortcut for this item.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
225 * That string must remain valid and should
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
226 * not change during the lifetime of the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
227 * Menu object.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
229 * inpev_t The global shortcut key associated to
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
230 * this item. That key will be displayed on
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
231 * the right of the menu.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
233 * <option> ...
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
234 * Zero or more options.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
236 * (unsigned char) 0
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
237 * The end of the item.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
239 * Where <option> is any of the following pairs of
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
240 * arguments :
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
242 * (unsigned char) MIF_STICK
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
243 * bool ticked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
244 * Indicates that this item can be ticked.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
245 * If <ticked> is true, the item will be
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
246 * initially ticked. To change the state of
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
247 * the item, call set_ticked().
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
249 * (unsigned char) MIF_VTICK
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
250 * bool *ticked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
251 * Indicates that this item can be ticked.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
252 * The argument is a pointer to a boolean
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
253 * variable. Whenever this item is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
254 * displayed, the variable is read and the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
255 * item is shown as ticked or unticked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
256 * depending on whether the function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
257 * returned true or false.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
259 * (unsigned char) MIF_FTICK
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
260 * boolcb_t ticked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
261 * void *arg
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
262 * Indicates that this item can be ticked.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
263 * The argument is a pointer to a function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
264 * taking only one argument (<arg>) and
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
265 * returning bool. Whenever this item is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
266 * displayed, the function is called and
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
267 * the item is shown as ticked or unticked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
268 * depending on whether the function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
269 * returned true or false.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
271 * (unsigned char) MIF_SACTIVE
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
272 * bool active
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
273 * Indicates that this item can be greyed
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
274 * out. If <active> is false the item
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
275 * will be initially greyed out. To change
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
276 * the state of the item, call
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
277 * set_active().
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
279 * (unsigned char) MIF_VACTIVE
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
280 * bool *active
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
281 * Indicates that this item can be greyed
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
282 * out. The argument is a pointer to a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
283 * boolean variable. Whenever this item is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
284 * displayed, the variable is read and the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
285 * item is shown as greyed out or not
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
286 * depending on whether the function
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
287 * returned false or true.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
289 * (unsigned char) MIF_FACTIVE
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
290 * boolcb_t active
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
291 * Indicates that this item can be greyed
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
292 * out. The argument is a pointer to a
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
293 * function taking only one argument
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
294 * (<arg>) and returning bool. Whenever
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
295 * this item is displayed, the function is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
296 * called and the item is shown as greyed
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
297 * out or not depending on whether the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
298 * function returned false or true.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
300 * 2) Separation
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
302 * A separation is made of exactly 1 argument :
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
304 * (const char *) MI_SEPARATION
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
306 * Pass a NULL pointer after the last group of arguments.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
308 * For a given item, the options MIF_STICK, MIF_VTICK and
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
309 * MIF_FTICK are mutually exclusive. For a given item, the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
310 * options MIF_SACTIVE, MIF_VACTIVE and MIF_FACTIVE are
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
311 * mutually exclusive.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
313 * A MI_SEPARATION argument at the end of the list (i.e.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
314 * not followed by an item) is ignored.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
316 * The ticked and greyed out states can change at any time
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
317 * but will not be reflected until the menu is redrawn from
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
318 * scratch.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
320 Menu::Menu(const char *title, ...)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
322 priv = new Menu_priv;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
323 va_list argp;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
324 va_start(argp, title);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
325 priv->vinit(*this, title, argp);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
326 va_end(argp);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
327 priv->cook();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
332 * Menu::Menu - ctor from an argument list
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
334 * This is the same thing as Menu::Menu (const char
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
335 * *title, ...) except that it expects a pointer on the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
336 * list of arguments.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
338 Menu::Menu(const char *title, va_list argp)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
340 priv = new Menu_priv;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
341 priv->vinit(*this, title, argp);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
342 priv->cook();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
347 * Menu::Menu - ctor from a list
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
349 * Another ctor for Menu, suited to the creation of the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
350 * menu from a list.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
352 Menu::Menu(const char *title,
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
353 al_llist_t * list, const char *(*getstr) (void *))
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
355 priv = new Menu_priv;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
356 set_title(title);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
357 size_t nitems = y_min(al_lcount(list), 100);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
358 priv->items.resize(nitems);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
359 size_t line;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
360 for (al_lrewind(list), line = 0;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
361 !al_leol(list) && line < nitems; al_lstep(list), line++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
362 priv->items[line].str = getstr(al_lptr(list));
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
363 priv->cook();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
368 * Menu::Menu - ctor from a Menu_data
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
370 Menu::Menu(const char *title, const Menu_data & menudata)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
372 priv = new Menu_priv;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
373 priv->menudata = &menudata;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
374 priv->flags |= MF_MENUDATA;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
375 set_title(title);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
376 size_t nitems = menudata.nitems();
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
377 priv->items.resize(nitems);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
378 priv->cook();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
383 * Menu::~Menu - dtor
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
385 Menu::~Menu()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
387 delete priv;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
392 * Menu_priv::vinit - initialize the menu from an argument list
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
394 void Menu_priv::vinit(Menu & m, const char *title, va_list argp)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
396 bool tick = false;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
398 m.set_title(title);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
400 while (items.size() < 100)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
402 Menu_item i;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
403
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
404 const char *str = va_arg(argp, const char *);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
405 while (str == MI_SEPARATION)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
406 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
407 i.flags |= MIF_SEPAR;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
408 str = va_arg(argp, const char *);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
409 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
410 if (str == 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
411 break;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
412
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
413 i.str = str;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
414 i.shortcut_key = (inpev_t) va_arg(argp, int);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
415 unsigned char flag;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
416 while ((flag = (unsigned char) va_arg(argp, int)) != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
417 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
418 if (flag == MIF_SACTIVE)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
419 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
420 i.flags = (i.flags & ~MIF_MACTIVE) | MIF_SACTIVE;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
421 i.active.s = (bool) va_arg(argp, int);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
422 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
423 else if (flag == MIF_VACTIVE)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
424 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
425 i.flags = (i.flags & ~MIF_MACTIVE) | MIF_VACTIVE;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
426 i.active.v = va_arg(argp, bool *);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
427 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
428 else if (flag == MIF_FACTIVE)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
429 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
430 i.flags = (i.flags & ~MIF_MACTIVE) | MIF_FACTIVE;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
431 i.active.f.f = va_arg(argp, micb_t);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
432 i.active.f.a = va_arg(argp, micbarg_t);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
433 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
434 else if (flag == MIF_STICK)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
435 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
436 tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
437 i.flags = (i.flags & ~MIF_MTICK) | MIF_STICK;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
438 i.tick.s = (bool) va_arg(argp, int);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
439 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
440 else if (flag == MIF_VTICK)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
441 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
442 tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
443 i.flags = (i.flags & ~MIF_MTICK) | MIF_VTICK;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
444 i.tick.v = va_arg(argp, bool *);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
445 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
446 else if (flag == MIF_FTICK)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
447 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
448 tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
449 i.flags = (i.flags & ~MIF_MTICK) | MIF_FTICK;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
450 i.tick.f.f = va_arg(argp, micb_t);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
451 i.tick.f.a = va_arg(argp, micbarg_t);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
452 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
453 else if (flag != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
454 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
455 nf_bug("Menu::ctor: flag %d", (int) flag);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
456 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
457 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
458 items.push_back(i);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
461 if (tick)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
462 flags |= MF_TICK;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
467 * Menu_priv::cook - parse the menu item strings
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
469 * Compute items_len, items_ks_len and prepare the cooked
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
470 * tilde shortcuts.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
472 void Menu_priv::cook()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
474 items_len = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
475 items_ks_len = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
476 short y = 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
478 for (size_t line = 0; line < items.size(); line++)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
479 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
480 Menu_item & i = items[line];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
481 if (i.shortcut_key != YK_)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
482 flags |= MF_SHORTCUT;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
483 if ((i.flags & MIF_MTICK) != MIF_NTICK)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
484 flags |= MF_TICK;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
485 if (i.flags & MIF_SEPAR)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
486 y += 2 * (NARROW_VSPACING + NARROW_BORDER);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
487 i.y = y;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
488 y += item_height;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
489 size_t len = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
490 i.tilde_key = YK_;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
491 const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
492 for (const char *p = str; *p != '\0'; p++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
493 if (p[0] == '~' && p[1] != '\0' && i.tilde_key == YK_)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
494 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
495 i.tilde_key = tolower(p[1]);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
496 flags |= MF_TILDE;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
497 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
498 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
499 len++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
500 size_t len_ks = len;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
501 if (i.shortcut_key != YK_)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
502 len_ks += strlen(key_to_string(i.shortcut_key)) + 2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
503 if (len > items_len)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
504 items_len = len;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
505 if (len_ks > items_ks_len)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
506 items_ks_len = len_ks;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
507 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
509 if (flags & MF_TICK)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
510 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
511 items_len += 2; // Tick mark
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
512 items_ks_len += 2;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
513 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
514 if (flags & MF_SHORTCUT)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
515 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
516 items_len += 4; // Space between strings and shortcut
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
517 items_ks_len += 4;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
518 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
519 if (!(flags & MF_TILDE) && !(flags & MF_SHORTCUT))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
520 flags |= MF_NUMS;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
521 if (flags & MF_NUMS)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
522 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
523 items_len += 4; // [1-9a-zA-Z] prefix
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
524 items_ks_len += 4;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
525 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
530 * Menu::set_title - set the title
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
532 * Set the title of the menu (it's ignored unless the menu
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
533 * is set in popup mode).
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
535 * Bug: changing the title does not take effect until the
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
536 * next display from scratch.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
538 void Menu::set_title(const char *title)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
540 priv->title = title;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
541 size_t title_len = title ? strlen(title) : 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
543 /* If the length of the title has changed,
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
544 force geom() to be called again. */
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
545 if (title_len != priv->title_len)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
546 priv->need_geom = true;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
548 priv->title_len = title_len;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
553 * Menu::set_coords - position or reposition the menu window.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
555 * (<x0>,<y0>) is the top left corner.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
556 * If <x0> is < 0, the window is horizontally centred.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
557 * If <y0> is < 0, the window is vertically centred.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
559 void Menu::set_coords(int x0, int y0)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
561 if (x0 != priv->ox0 || y0 != priv->oy0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
562 priv->need_geom = true; // Force geom() to be called
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
564 priv->user_ox0 = x0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
565 priv->user_oy0 = y0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
570 * Menu::set_item_no - set the current line
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
572 * The current line number is set to <item_no>. The first
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
573 * line bears number 0.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
575 void Menu::set_item_no(int item_no)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
577 priv->line = item_no;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
582 * Menu::set_popup - set the popup flag
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
584 * If <popup> is true, the popup flag is set. If <popup> is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
585 * false, the popup flag is cleared.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
587 void Menu::set_popup(bool popup)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
589 if (popup != ! !(priv->flags & MF_POPUP))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
590 priv->need_geom = true; // Force geom() to be called
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
591 if (popup)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
592 priv->flags |= MF_POPUP;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
593 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
594 priv->flags &= ~MF_POPUP;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
596
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
597
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
598 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
599 * Menu::set_force_numbers - set the force_numbers flags
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
601 * If <force_numbers> is true, the force_numbers flag is
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
602 * set. If <force_numbers> is false, the force_numbers flag
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
603 * is cleared.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
605 * The effect of the <force_numbers> flag is to disable key
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
606 * shortcuts and tilde shortcuts and to add automatic
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
607 * numbering of items ([1-9a-zA-Z]).
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
609 * If none of the items has a tilde or key shortcut,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
610 * <force_numbers> is automatically set. Otherwise, is it
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
611 * off by default.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
613 void Menu::set_force_numbers(bool force_numbers)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
615 if (force_numbers != ! !(priv->flags & MF_NUMS))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
616 priv->need_geom = true; // Force geom() to be called.
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
617 if (force_numbers)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
618 priv->flags |= MF_NUMS;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
619 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
620 priv->flags &= ~MF_NUMS;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
625 * Menu::set_visible - set the visible flag
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
627 * If <visible> is true, the visible flag is set. If
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
628 * <visible> is false, the visible flag is cleared.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
629 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
630 void Menu::set_visible(bool visible)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
632 priv->visible = visible;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
636 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
637 * Menu::set_ticked - tick or untick a menu item
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
638 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
639 * If <ticked> is true, item number <item_no> is ticked. If
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
640 * <ticked> is false, item number <item_no> is unticked.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
641 * If the menu item was not created with the MIF_STICK
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
642 * option, emit a warning and return without doing
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
643 * anything.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
645 void Menu::set_ticked(size_t item_no, bool ticked)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
646 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
647 if (item_no >= priv->items.size())
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
648 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
649 nf_bug("Menu::set_ticked: item_no %lu", (unsigned long) item_no);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
650 return;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
651 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
652 Menu_item & i = priv->items[item_no];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
653 if ((i.flags & MIF_MTICK) != MIF_STICK)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
654 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
655 nf_bug("Menu::set_ticked: flags %02X", i.flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
656 return;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
657 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
658 i.tick.s = ticked;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
659 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
660
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
663 * Menu::set_active - grey-out or ungrey-out a menu
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
665 * If <active> is false, item number <item_no> becomes
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
666 * greyed out. If <active> is true, item number <item_no>
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
667 * ceases to be greyed out. If the item was not created
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
668 * with with the MIF_SACTIVE option, emit a warning and
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
669 * return without doing anything.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
671 void Menu::set_active(size_t item_no, bool active)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
672 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
673 if (item_no >= priv->items.size())
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
674 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
675 nf_bug("Menu::set_active: item_no %lu", (unsigned long) item_no);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
676 return;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
677 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
678 Menu_item & i = priv->items[item_no];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
679 if ((i.flags & MIF_MACTIVE) != MIF_SACTIVE)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
680 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
681 nf_bug("Menu::set_active: flags %02Xh", i.flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
682 return;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
683 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
684 i.active.s = active;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
687
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
689 * Menu_priv::geom - recalculate the screen coordinates etc.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
691 void Menu_priv::geom()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
692 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
693 size_t width_chars = 0;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
694 if (title && (flags & MF_POPUP))
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
695 width_chars = y_max(width_chars, title_len);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
696 if (flags & MF_NUMS)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
697 width_chars = y_max(width_chars, items_len + 4);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
698 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
699 width_chars = y_max(width_chars, items_ks_len);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
700 int title_height = title && (flags & MF_POPUP) ? (int) (1.5 * FONTH) : 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
702 width = 2 * BOX_BORDER + 2 * WIDE_HSPACING + width_chars * FONTW;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
703 height = 2 * BOX_BORDER + 2 * WIDE_VSPACING + title_height
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
704 + items.back().y + item_height;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
705
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
706 if (user_ox0 < 0)
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
707 ox0 = (cfg.ScrMaxX - width) / 2;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
708 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
709 ox0 = user_ox0;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
710 ix0 = ox0 + BOX_BORDER;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
711 ix1 = ix0 + 2 * WIDE_HSPACING + width_chars * FONTW - 1;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
712 ox1 = ix1 + BOX_BORDER;
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
713 if (ox1 > cfg.ScrMaxX)
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
714 {
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
715 int overlap = ox1 - cfg.ScrMaxX;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
716 ox0 -= overlap;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
717 ix0 -= overlap;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
718 ix1 -= overlap;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
719 ox1 -= overlap;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
720 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
722 if (user_oy0 < 0)
80
2f1ecc1c5f72 Huge cleanup -- move some global variables into a struct.
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
723 oy0 = (cfg.ScrMaxY - height) / 2;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
724 else
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
725 oy0 = user_oy0;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
726 iy0 = oy0 + BOX_BORDER;
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
727 ty0 = iy0 + FONTH / 2; // Title of menu
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
728 ly0 = ty0 + title_height; // First item of menu
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
730 oy1 = oy0 + height - 1;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
731 iy1 = oy1 - BOX_BORDER;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
732
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
733 need_geom = false;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
734 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
735
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
736
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
737 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
738 * Menu::process_event - process an input event
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
739 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
740 * Process event in *<is>.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
741 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
742 * Return one of the following :
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
743 * - MEN_CANCEL: user pressed [Esc] or clicked outside
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
744 * the menu. The caller should delete the menu.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
745 * - MEN_INVALID: we didn't understand the event so we put it
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
746 * back in the input buffer.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
747 * - MEN_OTHER: we understood the event and processed it.
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
748 * - the number of the item that was validated.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
749 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
750 int Menu::process_event(const input_status_t * is)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
751 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
752 return priv->process_event(is);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
753 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
754
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
755
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
756 int Menu_priv::process_event(const input_status_t * is)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
757 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
758 size_t mouse_line;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
759 char status;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
760
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
761 if ((int) is->x < ix0 || (int) is->x > ix1 || (int) is->y < ly0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
762 mouse_line = items.size();
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
763 else
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
764 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
765 for (mouse_line = 0; mouse_line < items.size(); mouse_line++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
766 if ((int) is->y >= ly0 + items[mouse_line].y
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
767 && (int) is->y < ly0 + items[mouse_line].y + item_height)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
768 break;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
769 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
770
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
771 status = 'i';
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
772
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
773 // Clicking left button on an item: validate it.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
774 if (is->key == YE_BUTL_PRESS && mouse_line < items.size())
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
775 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
776 line = mouse_line; // Useless ?
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
777 status = 'v';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
778 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
779
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
780 // Moving over the box sets current line.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
781 else if (is->key == YE_MOTION && mouse_line < items.size())
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
782 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
783 line = mouse_line;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
784 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
785 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
786
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
787 /* Releasing the button while standing on an item: has a
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
788 different effect depending on whether we're in pull-down or
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
789 pop-up mode.
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
790
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
791 In pull-down mode, the button was normally last pressed on
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
792 the menu bar or on an item of this menu. So the current
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
793 item is selected upon button release.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
794
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
795 In pop-up mode, if the button was pressed, it was most
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
796 likely to exit a submenu (cf. the "thing type" menu) so we
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
797 ignore the event. */
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
798 else if (is->key == YE_BUTL_RELEASE
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
799 && mouse_line < items.size() && !(flags & MF_POPUP))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
800 status = 'v';
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
801
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
802 // [Enter], [Return]: accept selection
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
803 else if (is->key == YK_RETURN)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
804 status = 'v';
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
805
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
806 // [Esc]: cancel
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
807 else if (is->key == YK_ESC)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
808 status = 'c';
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
809
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
810 // [Up]: select previous line
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
811 else if (is->key == YK_UP)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
812 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
813 if (line > 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
814 line--;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
815 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
816 line = items.size() - 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
817 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
818 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
819
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
820 // [Down]: select next line
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
821 else if (is->key == YK_DOWN)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
822 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
823 if (line < items.size() - 1)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
824 line++;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
825 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
826 line = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
827 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
828 }
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
829
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
830 // [Home]: select first line
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
831 else if (is->key == YK_HOME)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
832 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
833 line = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
834 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
835 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
836
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
837 // [End]: select last line
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
838 else if (is->key == YK_END)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
839 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
840 line = items.size() - 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
841 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
842 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
843
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
844 // [Pgup]: select line - 5
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
845 else if (is->key == YK_PU)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
846 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
847 if (line >= 5)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
848 line -= 5;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
849 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
850 line = 0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
851 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
852 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
853
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
854 // [Pgdn]: select line + 5
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
855 else if (is->key == YK_PD)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
856 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
857 if (line + 5 < items.size())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
858 line += 5;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
859 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
860 line = items.size() - 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
861 status = 'o';
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
862 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
863
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
864 // [1]-[9]: select items 0 through 8
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
865 else if ((flags & MF_NUMS)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
866 && is->key < YK_ && within(dectoi(is->key), 1, items.size()))
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
867 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
868 line = dectoi(is->key) - 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
869 status = 'o';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
870 send_event(YK_RETURN);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
871 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
872
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
873 // [a]-[z]: select items 9 through 34
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
874 else if ((flags & MF_NUMS)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
875 && is->key < YK_
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
876 && islower(is->key) && within(b36toi(is->key), 10, items.size()))
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
877 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
878 line = b36toi(is->key) - 1;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
879 status = 'o';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
880 send_event(YK_RETURN);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
881 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
882
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
883 // [A]-[Z]: select items 35 through 60
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
884 else if ((flags & MF_NUMS)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
885 && is->key < YK_
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
886 && isupper(is->key)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
887 && within(b36toi(is->key) + 26, 36, items.size()))
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
888 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
889 line = b36toi(is->key) + 25;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
890 status = 'o';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
891 send_event(YK_RETURN);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
892 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
893
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
894 // A shortcut ?
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
895 else
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
896 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
897 /* First, check the list of tilde shortcuts
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
898 (only if is->key is a regular key) */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
899 if ((flags & MF_TILDE)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
900 && !(flags & MF_NUMS) && is->key == (unsigned char) is->key)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
901 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
902 for (size_t n = 0; n < items.size(); n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
903 if (items[n].tilde_key != YK_
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
904 && items[n].tilde_key == tolower(is->key))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
905 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
906 line = n;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
907 status = 'o';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
908 send_event(YK_RETURN);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
909 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
910 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
911 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
912 /* If no tilde shortcut matched, check the list of shortcut
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
913 keys. It's important to do the tilde shortcuts first so
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
914 that you can override a shortcut key (normally global)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
915 with a tilde shortcut (normally local). */
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
916 if (status == 'i' && (flags & MF_SHORTCUT) && !(flags & MF_NUMS))
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
917 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
918 for (size_t n = 0; n < items.size(); n++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
919 if (items[n].shortcut_key != YK_
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
920 && items[n].shortcut_key == is->key)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
921 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
922 line = n;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
923 status = 'o';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
924 send_event(YK_RETURN);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
925 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
926 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
927 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
928 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
929
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
930 // See last_shortcut_key()
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
931 if (status == 'v')
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
932 _last_shortcut_key =
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
933 (flags & MF_SHORTCUT) ? items[line].shortcut_key : 0;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
934
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
935 /* Return
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
936 - the item# if validated,
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
937 - MEN_CANCEL if cancelled,
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
938 - MEN_OTHER or MEN_INVALID if neither. */
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
939 if (status == 'v')
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
940 return (int) line;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
941 else if (status == 'c')
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
942 return MEN_CANCEL;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
943 else if (status == 'o')
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
944 return MEN_OTHER;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
945 else if (status == 'i')
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
946 return MEN_INVALID;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
947 else
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
948 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
949 // Can't happen
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
950 fatal_error("Menu::process_event: bad status %02Xh", status);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
951 return 0; // To please the compiler
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
952 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
953 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
954
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
955
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
956 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
957 * Menu::last_shortcut_key - shortcut key for last selected item
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
958 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
959 * Return the code of the shortcut key for the last
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
960 * selected item. This function shouldn't exist : it's just
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
961 * there because it helps editloop.cc. When real key
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
962 * bindings are implemented in editloop.cc,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
963 * get_shortcut_key() should disappear.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
964 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
965 inpev_t Menu::last_shortcut_key()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
966 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
967 return priv->_last_shortcut_key;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
968 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
969
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
970
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
971 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
972 * Menu::draw - display the menu
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
973 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
974 * If necessary, redraw everything from scratch. Else, if
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
975 * <line> has changed, refresh the highlighted line.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
976 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
977 void Menu::draw()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
978 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
979 priv->draw();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
980 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
981
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
982
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
983 void Menu_priv::draw()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
984 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
985 bool from_scratch = false;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
986
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
987 if (need_geom)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
988 geom();
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
989
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
990 // Do we need to redraw everything from scratch ?
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
991 if (visible && !visible_disp
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
992 || ox0 != ox0_disp
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
993 || oy0 != oy0_disp || width != width_disp || height != height_disp)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
994 from_scratch = true;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
995
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
996 // Display the static part of the menu
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
997 if (from_scratch)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
998 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
999 DrawScreenBox3D(ox0, oy0, ox1, oy1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1000 set_colour(WINTITLE);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1001 if ((flags & MF_POPUP) && title != 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1002 DrawScreenString(ix0 + WIDE_HSPACING, ty0, title);
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1003
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1004 for (size_t l = 0; l < items.size(); l++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1005 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1006 set_colour(WINFG);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1007 draw_one_line(l, false);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1008 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1009 visible_disp = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1010 ox0_disp = ox0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1011 oy0_disp = oy0;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1012 width_disp = width;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1013 height_disp = height;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1014 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1015
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1016 // Display the "highlight" bar
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1017 if (from_scratch || line != line_disp)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1018 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1019 if (line_disp < items.size())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1020 draw_one_line(line_disp, false);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1021 if (line < items.size())
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1022 draw_one_line(line, true);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1023 line_disp = line;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1024 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1025 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1026
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1027
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1028 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1029 * Menu::draw_one_line - display just one line of a menu
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1030 *
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1031 * <line> is the number of the option to draw (0 = first
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1032 * option). <highlighted> tells whether the option should
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1033 * be drawn highlighted.
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1034 */
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1035 void Menu_priv::draw_one_line(size_t line, bool highlighted)
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1036 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1037 const Menu_item & i = items[line];
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1038 int x = ix0 + FONTW;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1039 int y = ly0 + i.y;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1040 int text_y = y + VSPACE / 2;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1041
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1042 // Separation ?
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1043 if (i.flags & MIF_SEPAR)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1044 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1045 push_colour(WINBG_DARK);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1046 short groove_y = y - NARROW_VSPACING - 2 * NARROW_BORDER;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1047 DrawScreenLine(ix0, groove_y, ix1, groove_y);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1048 set_colour(WINBG_LIGHT);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1049 DrawScreenLine(ix0, groove_y + 1, ix1, groove_y + 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1050 pop_colour();
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1051 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1052
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1053 // Greyed out ?
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1054 bool active = true;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1055 switch (i.flags & MIF_MACTIVE)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1056 {
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1057 case MIF_NACTIVE:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1058 active = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1059 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1060
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1061 case MIF_SACTIVE:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1062 active = i.active.s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1063 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1064
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1065 case MIF_VACTIVE:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1066 active = *i.active.v;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1067 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1068
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1069 case MIF_FACTIVE:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1070 active = i.active.f.f(i.active.f.a);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1071 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1072
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1073 default:
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1074 nf_bug("Menu::draw_one_line: active %02Xh", i.flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1075 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1076 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1077 set_colour(menu_colour[!active][highlighted].bg);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1078 DrawScreenBox(ix0, y, ix1, y + item_height - 1);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1079 set_colour(menu_colour[!active][highlighted].fg);
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1080
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1081 // Tick mark if any
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1082 if (flags & MF_TICK)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1083 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1084 bool have_tick = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1085 bool ticked = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1086 switch (i.flags & MIF_MTICK)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1087 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1088 case MIF_NTICK:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1089 have_tick = false;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1090 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1091
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1092 case MIF_STICK:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1093 have_tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1094 ticked = i.tick.s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1095 break;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1096
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1097 case MIF_VTICK:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1098 have_tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1099 ticked = *i.tick.v;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1100 break;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1101
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1102 case MIF_FTICK:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1103 have_tick = true;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1104 ticked = i.tick.f.f(i.tick.f.a);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1105 break;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1106
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1107 default:
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1108 nf_bug("Menu::draw_one_line: tick %02Xh", i.flags);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1109 break;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1110 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1111 if (have_tick)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1112 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1113 if (ticked)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1114 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1115 unsigned hside = FONTW * 4 / 5;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1116 unsigned vside = FONTH * 4 / 5;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1117 int x0 = x + (FONTW - hside) / 2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1118 int y0 = y + (FONTH - vside) / 2;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1119 DrawScreenLine(x0, y0 + vside / 2, x0 + hside / 2,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1120 y0 + vside - 1);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1121 DrawScreenLine(x0 + hside / 2, y0 + vside - 1, x0 + hside - 1,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1122 y0);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1123 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1124 else
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1125 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1126 unsigned margin = FONTW / 5;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1127 DrawScreenLine(x + margin, y + FONTH / 2,
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1128 x + FONTW - 1 - margin, y + FONTH / 2);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1129 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1130 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1131 x += 2 * FONTW;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1132 }
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1133
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1134 // Automatic keys if any
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1135 if (flags & MF_NUMS)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1136 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1137 char c = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1138 if (line <= 8)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1139 c = '1' + line;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1140 else if (line >= 9 && line < 9 + 26)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1141 c = 'a' + line - 9;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1142 else if (line >= 9 + 26 && line < 9 + 26 + 26)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1143 c = 'A' + line - (9 + 26);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1144 if (c != '\0')
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1145 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1146 push_colour(highlighted ? WINLABEL_HL : WINLABEL);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1147 DrawScreenString(x, text_y, "[ ]");
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1148 pop_colour();
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1149 DrawScreenChar(x + FONTW, text_y, c);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1150 DrawScreenChar(x + FONTW, text_y + FONTU, '_');
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1151 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1152 x += 4 * FONTW;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1153 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1154
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1155 // Text
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1156 int tilde_index = -1;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1157 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1158 const char *str = (flags & MF_MENUDATA) ? (*menudata)[line] : i.str;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1159 char *buf = new char[strlen(str) + 1];
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1160 char *d = buf;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1161 for (const char *s = str; *s != '\0'; s++)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1162 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1163 if (*s == '~' && tilde_index < 0)
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1164 {
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1165 tilde_index = s - str;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1166 continue;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1167 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1168 *d++ = *s;
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1169 }
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1170 *d = '\0';
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1171 DrawScreenString(x, text_y, buf);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1172 delete[]buf;
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1173 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1174
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1175 // Underscore the tilde shortcut if any
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1176 if (!(flags & MF_NUMS) && tilde_index >= 0)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1177 DrawScreenString(x + tilde_index * FONTW, text_y + FONTU, "_");
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1178
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1179 // Shortcut key if any
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1180 if (!(flags & MF_NUMS) && i.shortcut_key != YK_)
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1181 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1182 const char *s = key_to_string(i.shortcut_key);
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1183 DrawScreenString(ix1 + 1 - FONTW - strlen(s) * FONTW, text_y, s);
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1184 }
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1185 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1186
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1187
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1188 /*
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1189 * WIDGET METHODS
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1190 */
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1191
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1192
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1193 void Menu::undraw()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1194 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1195 ; // I can't undraw myself
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1196 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1197
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1198
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1199 int Menu::can_undraw()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1200 {
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1201 return 0; // I can't undraw myself
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1202 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1203
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1204
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1205 int Menu::need_to_clear()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1206 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1207 return !priv->visible && priv->visible_disp || priv->need_geom;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1208 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1209
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1210
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1211 void Menu::clear()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1212 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1213 priv->visible_disp = false;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1214 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1215
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1216
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1217 int Menu::req_width()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1218 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1219 if (priv->need_geom)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1220 priv->geom();
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1221 return priv->width;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1222 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1223
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1224
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1225 int Menu::req_height()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1226 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1227 if (priv->need_geom)
33
a68786b9c74b Oops, used indent with tabs enabled. Remove tabs.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
1228 priv->geom();
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1229 return priv->height;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1230 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1231
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1232
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1233 int Menu::get_x0()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1234 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1235 return priv->ox0_disp;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1236 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1237
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1238
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1239 int Menu::get_y0()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1240 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1241 return priv->oy0_disp;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1242 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1243
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1244
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1245 int Menu::get_x1()
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1246 {
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1247 return priv->ox0_disp + priv->width_disp - 1;
0
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1248 }
241c93442be0 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1249
25
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1250
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1251 int Menu::get_y1()
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1252 {
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1253 return priv->oy0_disp + priv->height_disp - 1;
8eaf72e2041b Reindent the source using GNU indent and "indent -i4 -bli0 -npcs -nprs -npsl".
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
1254 }