Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

TestMenu.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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 /*, font, pclHelper*/ ) 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 // connect 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 // options 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 else 00116 if (pstEvent -> local_id == m_item4.GetLocalID()) 00117 { 00118 // exit 00119 appl -> SetQuit( true ); 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

Generated for SDL C++ GUI by doxygen 1.3.6