FDOSTUI
FreeDOS Text User Interface
menu.hpp
Go to the documentation of this file.
1 /*
2  MENU.HPP
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __menu_hpp__
11 
12 #include "window.hpp"
13 #include "menuitem.h"
14 
15 class menu : public window
16 {
17 
18 public:
19 
21  {
24  };
25 
26  menu(
27  int const i_pos_x,
28  int const i_pos_y,
29  unsigned int const i_len_x,
30  unsigned int const i_len_y);
31 
32  virtual
33  ~menu();
34 
35  virtual void
36  draw() const;
37 
38  virtual enum event_response
39  event_key(
40  struct event_key const& i_event);
41 
42  virtual enum event_response
44  struct event_mouse const& i_event);
45 
46  void
47  set_menu(
48  struct menuitem* i_menu);
49 
50  void
52  bool const i_turnon);
53 
54 #if defined(__CURSES__)
55  virtual void
56  focus_enter();
57 #endif
58 
59 protected:
60 
62  unsigned int m_selected;
63  unsigned int m_offset;
65  struct array m_array;
66  struct menuitem* m_menu;
67 
68 private:
69 
70  menu();
71 
72  menu(
73  const menu&);
74 
75  menu&
76  operator=(menu const&);
77 
78  virtual void
79  move(
80  int const i_pos_x,
81  int const i_pos_y);
82 
83  virtual void
84  resize(
85  unsigned int const i_len_x,
86  unsigned int const i_len_y);
87 
88  void
89  draw_line(
90  int const i_pos_y,
91  int const i_erase) const;
92 
93  void
94  draw_item(
95  int const i_pos_y,
96  int const i_selected,
97  struct menuitem const*const i_menu) const;
98 
99  void
100  draw_items() const;
101 
102  void
103  preflight();
104 
105  enum event_response
107  unsigned char const i_ascii);
108 
109  enum event_response
111  enum scancodes const i_scan);
112 
113  void
114  select(
115  unsigned int const i_slot);
116 
117  void
118  select_next();
119 
120  void
121  select_previous();
122 
123  enum event_response
124  submenu(
125  struct menuitem * io_menu,
126  unsigned int const i_pos_x,
127  unsigned int const i_pos_y);
128 
129  int
131  int const i_pos_x,
132  int const i_pos_y);
133 };
134 
135 inline void
137  int const i_pos_x,
138  int const i_pos_y)
139 {
140  return;
141 }
142 
143 inline void
145  unsigned int const i_len_x,
146  unsigned int const i_len_y)
147 {
148  return;
149 }
150 
151 inline void
153  struct menuitem* i_menu)
154 {
155 
156  m_menu= i_menu;
157  preflight();
158 
159  return;
160 }
161 
162 inline void
164  bool const i_turnon)
165 {
166 
167  m_response_extended= i_turnon;
168 
169  return;
170 }
171 
172 #if defined(__CURSES__)
173 inline void
175 {
177  if (0 == (CURSOR_CAN_HIDE & _cursor_features))
178  {
180  }
181 }
182 #endif
183 
184 #define __menu_hpp__
185 #endif
event_response_extended
extended response for keystrokes
Definition: menu.hpp:20
int event_in_parent(int const i_pos_x, int const i_pos_y)
test if event is inside parent
Definition: menu.cpp:385
contains window class
scancodes
ASCII Scan Codes.
Definition: keyboard.h:26
int m_pos_y
Definition: box.h:15
void draw_line(int const i_pos_y, int const i_erase) const
draw a separator line
Definition: menu.cpp:43
unsigned int m_selected
Definition: menu.hpp:62
void select_next()
selects the next item
Definition: menu.cpp:815
virtual enum event_response event_mouse(struct event_mouse const &i_event)
handle mouse event
Definition: menu.cpp:601
int m_orig_pos_y
Definition: menu.hpp:64
bool m_response_extended
Definition: menu.hpp:61
void set_menu(struct menuitem *i_menu)
sets the menu
Definition: menu.hpp:152
struct box m_box
Definition: widget.hpp:171
virtual ~menu()
destructor
Definition: menu.cpp:36
virtual void focus_enter()
handle entering focus
Definition: group.cpp:155
void select_previous()
selects the previous item
Definition: menu.cpp:846
virtual void move(int const i_pos_x, int const i_pos_y)
move the widget to a new position
Definition: menu.hpp:136
void select(unsigned int const i_slot)
selects a menu item
Definition: menu.cpp:737
int m_pos_x
Definition: box.h:14
void draw_item(int const i_pos_y, int const i_selected, struct menuitem const *const i_menu) const
draw a menu item
Definition: menu.cpp:107
Definition: menu.hpp:23
a menu item
Definition: menuitem.h:33
container to hold objects
Definition: array.h:14
event_response
response
Definition: event.h:14
enum event_response event_key_ascii(unsigned char const i_ascii)
handle ASCII key events
Definition: menu.cpp:419
void set_response_extended(bool const i_turnon)
sets the behavior of the response used when the user presses specific keystrokes. ...
Definition: menu.hpp:163
struct array m_array
Definition: menu.hpp:65
Definition: menu.hpp:22
struct menuitem * m_menu
Definition: menu.hpp:66
unsigned int _cursor_features
global to hold the cursor features
Definition: ncurses/cursor.c:17
top level container widget that can be moved and resized by the user
Definition: window.hpp:19
void preflight()
configure the menu object (flattens the menu)
Definition: menu.cpp:877
Definition: cursor.h:18
enum event_response event_key_scan(enum scancodes const i_scan)
handle scancode events
Definition: menu.cpp:505
virtual void draw() const
draws the widget
Definition: menu.cpp:355
Allows a user to choose a value from a list.
Definition: menu.hpp:15
unsigned int m_offset
Definition: menu.hpp:63
virtual void focus_enter()
handle entering focus
Definition: menu.hpp:174
virtual void resize(unsigned int const i_len_x, unsigned int const i_len_y)
resize the widget
Definition: menu.hpp:144
enum event_response submenu(struct menuitem *io_menu, unsigned int const i_pos_x, unsigned int const i_pos_y)
popups sub menu
Definition: menu.cpp:920
container for a mouse event
Definition: event.h:37
void draw_items() const
draw all of the menu items
Definition: menu.cpp:306
virtual enum event_response event_key(struct event_key const &i_event)
handle key event
Definition: menu.cpp:582
container for a keyboard event
Definition: event.h:23