-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdlgMainMenu.cpp_old
83 lines (62 loc) · 2.05 KB
/
dlgMainMenu.cpp_old
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//--------------------------------------
// The Main Menu
//--------------------------------------
#include "dlgMainMenu.h"
#include "winMain.h"
#include "winFiles.h"
dlgMainMenu main_menu;
//----------------------------------------------------------------------
// WINDOW DEFINITION
//----------------------------------------------------------------------
#define NUM_APP_WINDOWS 2
#define ID_BUTTON1 (0x0001 | ID_TYPE_TEXT | ID_TYPE_BUTTON)
#define ID_BUTTON2 (0x0002 | ID_TYPE_TEXT | ID_TYPE_BUTTON)
// for now I am defining a bunch of full mutables
// probably want something different
static uiWindow *app_windows[NUM_APP_WINDOWS] = {
&main_win,
&files_win };
static char button_text[NUM_APP_WINDOWS][UI_MAX_BUTTON];
static const uiElement menu_elements[] =
{
{ ID_BUTTON1, 0, 35, 90, 35, V(button_text[0]), COLOR_BLUE, COLOR_WHITE, FONT_BIG, JUST_CENTER },
{ ID_BUTTON2, 0, 70, 90, 35, V(button_text[1]), COLOR_BLUE, COLOR_WHITE, FONT_BIG, JUST_CENTER },
};
//-----------------------
// implementation
//-----------------------
dlgMainMenu::dlgMainMenu() :
uiWindow(menu_elements,4)
{}
void dlgMainMenu::begin()
{
const char *app_text = the_app.getAppButtonText();
app_text = strstr(app_text,"%") ? "MAIN" : app_text;
// sublimate % button to "main"
m_num_elements = 0;
for (int i=0; i<NUM_APP_WINDOWS; i++)
{
const char *text = app_windows[i]->getMenuLabel();
if (strcmp(app_text,text))
{
strcpy(button_text[m_num_elements++],text);
}
}
drawTypedElements();
}
void dlgMainMenu::onButton(const uiElement *ele, bool pressed)
{
if (!pressed)
{
const char *text = (const char *) ele->param;
for (int i=0; i<NUM_APP_WINDOWS; i++)
{
uiWindow *win = app_windows[i];
if (!strcmp(text,win->getMenuLabel()))
{
the_app.setBaseWindow(win);
return;
}
}
}
}