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

OptionsDialog.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 "Globals.h" 00027 #include "OptionsDialog.h" 00028 00029 00030 OptionsDialog::OptionsDialog(Surface *s) 00031 :Dialog(s, 200, 200, 200, 200) 00032 ,m_st1 (this, 5, 5, 150, 25) 00033 ,m_host(this, 5, 35, 150, 25) 00034 ,m_st2 (this, 5, 65, 150, 25) 00035 ,m_port(this, 5, 95, 150, 25) 00036 ,m_ok (this, 5, 125, 90, 25) 00037 ,m_cancel(this,105,125, 90, 25) 00038 { 00039 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format, 192, 192, 192, 255); 00040 Uint32 bgcolor2 = SDL_MapRGBA(GetScreen() -> format, 192, 192, 255, 255); 00041 Uint32 txtcolor = SDL_MapRGBA(GetScreen() -> format, 255, 192, 64, 255); 00042 00043 SetText("OptionsDialog"); 00044 CreateTemporaryScreen(); 00045 00046 // SetBgColor(bgcolor); 00047 // SetFgColor(txtcolor); 00048 SetMoveable(true); 00049 00050 m_st1.SetText("Host"); 00051 // m_host.SetBgColor(bgcolor2); 00052 m_st2.SetText("Port"); 00053 // m_port.SetBgColor(bgcolor2); 00054 m_ok.SetText("OK"); 00055 m_ok.SetAnchorDown(true); 00056 // m_ok.SetBgColor(bgcolor2); 00057 m_cancel.SetText("Cancel"); 00058 m_cancel.SetAnchorDown(true); 00059 m_cancel.SetAnchorRight(true); 00060 // m_cancel.SetBgColor(bgcolor2); 00061 00062 UpdateData(false); 00063 00064 AddChild(&m_st1); 00065 AddChild(&m_host); 00066 AddChild(&m_st2); 00067 AddChild(&m_port); 00068 AddChild(&m_ok); 00069 AddChild(&m_cancel); 00070 } 00071 00072 00073 OptionsDialog::~OptionsDialog() 00074 { 00075 } 00076 00077 00078 void OptionsDialog::OnEvent(surface_event_t *pstEvent) 00079 { 00080 if (pstEvent -> type == GUI_EVENT_BUTTON) 00081 { 00082 if (pstEvent -> local_id == m_ok.GetLocalID()) 00083 { 00084 UpdateData(); 00085 OnClose(); 00086 } 00087 else 00088 if (pstEvent -> local_id == m_cancel.GetLocalID()) 00089 { 00090 OnClose(); 00091 } 00092 } 00093 } 00094 00095 00096 void OptionsDialog::Draw() 00097 { 00098 SDL_Rect *area = GetClientRectPtr(); 00099 Uint32 color = GetBgColor(); 00100 00101 SDL_FillRect(m_screen, area, color); 00102 } 00103 00104 00105 void OptionsDialog::UpdateData(bool dlg2vars) 00106 { 00107 if (dlg2vars) 00108 { 00109 Globals::m_host = m_host.GetLine(); 00110 Globals::m_port = atoi(m_port.GetLine()); 00111 } 00112 else 00113 { 00114 char slask[200]; 00115 m_host.SetLine(Globals::m_host.c_str()); 00116 sprintf(slask,"%d",Globals::m_port); 00117 m_port.SetLine(slask); 00118 } 00119 } 00120

Generated for SDL C++ GUI by doxygen 1.3.6