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

MenuDialog.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 "OptionsDialog.h" 00027 #include "MainWindow.h" 00028 #include "MenuDialog.h" 00029 00030 00031 MenuDialog::MenuDialog(Surface *s) 00032 :Dialog(s, 160, 140, 320, 200) 00033 ,m_b1(this, 5, 5, 300, 25) 00034 ,m_b2(this, 5, 35, 300, 25) 00035 ,m_b3(this, 5, 65, 300, 25) 00036 ,m_b4(this, 5, 95, 300, 25) 00037 { 00038 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format, 192, 192, 192, 128); 00039 Uint32 txtcolor = SDL_MapRGBA(GetScreen() -> format, 255, 192, 64, 255); 00040 00041 SetText("MenuDialog"); 00042 // CreateTemporaryScreen(); 00043 00044 SetTransparent(true); 00045 // SetBgColor(bgcolor); 00046 // SetFgColor(txtcolor); 00047 00048 m_b1.SetText("Connect"); 00049 m_b2.SetText("Options"); 00050 m_b3.SetText("Exit"); 00051 m_b3.SetUICommand(UICOMMAND_QUIT); 00052 m_b4.SetText("Test"); 00053 AddChild(&m_b1); 00054 AddChild(&m_b2); 00055 AddChild(&m_b3); 00056 AddChild(&m_b4); 00057 } 00058 00059 00060 MenuDialog::~MenuDialog() 00061 { 00062 } 00063 00064 00065 void MenuDialog::OnEvent(surface_event_t *pstEvent) 00066 { 00067 if (pstEvent -> type == GUI_EVENT_BUTTON) 00068 { 00069 if (pstEvent -> local_id == m_b1.GetLocalID()) 00070 { 00071 // connect 00072 MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent()); 00073 if (pcl) 00074 { 00075 SetVisible(false); 00076 InvalidateEv(); 00077 pcl -> Connect(); 00078 } 00079 } 00080 else 00081 if (pstEvent -> local_id == m_b2.GetLocalID()) 00082 { 00083 // options 00084 MainWindow *pcl = dynamic_cast<MainWindow *>(GetParent()); 00085 if (pcl) 00086 { 00087 pcl -> ShowOptions(); 00088 } 00089 } 00090 else 00091 /* 00092 if (pstEvent -> local_id == m_b3.GetLocalID()) 00093 { 00094 // exit 00095 appl -> SetQuit( true ); 00096 } 00097 else 00098 */ 00099 if (pstEvent -> local_id == m_b4.GetLocalID()) 00100 { 00101 pprintf("Test button pressed\n"); 00102 } 00103 } 00104 } 00105 00106 00107 void MenuDialog::Connected(const string &str) 00108 { 00109 m_b1.SetText(str); 00110 }

Generated for SDL C++ GUI by doxygen 1.3.6