00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#include <stdincl.h>
00024
00025
#include "client.h"
00026
#include "MainWindow.h"
00027
#include "TestMenu.h"
00028
00029
00030
using gui::Surface;
00031
using gui::SurfaceHelper;
00032
using gui::Menu;
00033
using gui::surface_event_t;
00034
00035
00036
TestMenu::TestMenu(Surface *s,SurfaceHelper *pclHelper)
00037 :Menu(s,pclHelper)
00038 #ifdef WIN32
00039 ,m_font("font.ttf", 10)
00040 #else
00041 ,m_font("../gui/fonts/font.ttf", 10)
00042 #endif
00043 ,m_item1(this,"Connect",&m_font )
00044 ,m_item2(this,"Options",&m_font)
00045 ,m_item3(this,"Test",&m_font)
00046 ,m_item4(this,"Exit",&m_font)
00047 ,m_title(this,"Test Menu",&m_font)
00048 ,m_item6(this,"YAM",&m_font,1)
00049 ,m_sep2(this)
00050 ,m_save(this,"Save (XML)",&m_font)
00051 ,m_sep(this)
00052 {
00053 SetTTFont(&m_font);
00054
00055 m_title.SetClickable(
false);
00056 m_item4.SetUICommand(UICOMMAND_QUIT);
00057 m_save.SetUICommand(UICOMMAND_XMLSAVE);
00058 AddMenuItem(&m_title);
00059 AddMenuItem(&m_save);
00060 AddMenuItem(&m_sep);
00061 AddMenuItem(&m_item1);
00062 AddMenuItem(&m_item2);
00063 AddMenuItem(&m_item3);
00064 AddMenuItem(&m_item6);
00065 AddMenuItem(&m_sep2);
00066 AddMenuItem(&m_item4);
00067 CreateMenu();
00068 CreateTemporaryScreen();
00069
00070 m_title.SetBgColor(0,0,0);
00071 m_title.SetFgColor(255,255,255);
00072 m_sep.SetFgColor(128,128,128);
00073 m_sep2.SetFgColor(128,128,128);
00074
00075 SetMoveable(
true);
00076 }
00077
00078
00079 TestMenu::~TestMenu()
00080 {
00081 }
00082
00083
00084
void TestMenu::OnEvent(surface_event_t *pstEvent)
00085 {
00086
if (pstEvent -> type == GUI_EVENT_BUTTON)
00087 {
00088
if (pstEvent -> local_id == m_item1.GetLocalID())
00089 {
00090
00091
MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent());
00092
if (pcl)
00093 {
00094 SetVisible(
false);
00095 InvalidateEv();
00096 pcl -> Connect();
00097 }
00098 }
00099
else
00100
if (pstEvent -> local_id ==
m_item2.GetLocalID())
00101 {
00102
00103
MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent());
00104
if (pcl)
00105 {
00106 pcl -> ShowOptions();
00107 }
00108 }
00109
else
00110
if (pstEvent -> local_id ==
m_item3.GetLocalID())
00111 {
00112
pprintf(
"Test button pressed\n");
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122 }
00123 }
00124
00125
00126 gui::Menu *
TestMenu::GetSubMenu(
int id)
00127 {
00128
if (
id == 1)
00129 {
00130
return new TestMenu(GetParent());
00131 }
00132
return NULL;
00133 }
00134
00135