-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIDropDownMenu.h
68 lines (50 loc) · 1.68 KB
/
GUIDropDownMenu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// GUIDropDown.h
// Deep
//
// Created by Nathan Daly on 8/22/13.
// Copyright (c) 2013 Lions Entertainment. All rights reserved.
//
#ifndef __Deep__GUIDropDown__
#define __Deep__GUIDropDown__
#include <iostream>
#include <string>
#include <list>
#include "GUIView.h"
namespace GUI {
class DropDownMenu : public View {
public:
DropDownMenu(int w, int text_size = 12);
// Init with entries (list of std::strings)
template <typename Iter_t>
DropDownMenu(int w, int text_size,
Iter_t entries_begin, Iter_t entries_end);
std::string get_selected_entry();
int get_selected_entry_position();
private:
void init_menu_view(int text_size_);
void update_menu_view();
int text_size;
int selected_entry_idx;
std::list<std::string> entries;
View *menu;
bool clicked;
DispPoint pre_click_pos;
// Mouse Events. Following three functions all work the same:
// Returns true if the mouse-event is finished being handled.
// If returns false, handling will continue up the chain.
// May optionally call capture_focus() to become the target for keypresses.
virtual bool handle_mouse_down(DispPoint coord);
virtual bool handle_mouse_up(DispPoint coord);
virtual bool handle_mouse_motion(DispPoint coord, DispPoint rel_motion);
friend class MenuEntry;
};
template <typename Iter_t>
DropDownMenu::DropDownMenu(int w, int text_size_,
Iter_t entries_begin, Iter_t entries_end)
:View(w, 1), entries(entries_begin, entries_end)
{
init_menu_view(text_size_);
}
} // namespace GUI
#endif /* defined(__Deep__GUIDropDown__) */