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

PlayerDialog.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 "forms/PlayerSelect.h" 00026 #include "MainWindow.h" 00027 #include "PlayerDialog.h" 00028 00029 using Form::PlayerSelect; 00030 00031 00032 PlayerDialog::PlayerDialog(Surface *s) 00033 :FormSurface(s,220,100,200,200) 00034 ,y(5) 00035 { 00036 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format,192,192,192,SDL_ALPHA_OPAQUE); 00037 Uint32 fgcolor = SDL_MapRGBA(GetScreen() -> format,255,192,64,SDL_ALPHA_OPAQUE); 00038 00039 SetText("PlayerDialog"); 00040 CreateTemporaryScreen(); 00041 SetMoveable(true); 00042 00043 // SetBgColor(bgcolor); 00044 // SetFgColor(fgcolor); 00045 } 00046 00047 00048 PlayerDialog::~PlayerDialog() 00049 { 00050 surfacevector_t::iterator it; 00051 for (it = m_ChildList.begin(); it != m_ChildList.end(); it++) 00052 { 00053 delete *it; 00054 } 00055 } 00056 00057 00058 void PlayerDialog::OnEvent(surface_event_t *pstEvent) 00059 { 00060 PlayerSelect *pcf = dynamic_cast<PlayerSelect *>(GetForm()); 00061 Button *pcb = dynamic_cast<Button *>(pstEvent -> ptr); 00062 00063 if (pcf && pcb) 00064 { 00065 pcf -> SelectPlayer(pcb -> GetText()); 00066 } 00067 OnClose(); 00068 } 00069 00070 00071 void PlayerDialog::Draw() 00072 { 00073 SDL_Rect *area = GetClientRectPtr(); 00074 Uint32 color = GetBgColor(); 00075 00076 SDL_FillRect(m_screen, area, color); 00077 } 00078 00079 00080 void PlayerDialog::AddButton(const string &str) 00081 { 00082 Button *pclButton; 00083 00084 pclButton = new Button(this, 5, y, 190, 25); 00085 pclButton -> SetText(str); 00086 pclButton -> SetBgColor( 160, 160, 160 ); 00087 pclButton -> SetMustBeDeleted(true); 00088 AddChild(pclButton); 00089 y += 30; 00090 } 00091 00092 00093 void PlayerDialog::Clear() 00094 { 00095 surfacevector_t::iterator it; 00096 Surface *s; 00097 bool repeat = true; 00098 00099 while (repeat) 00100 { 00101 repeat = false; 00102 for (it = m_ChildList.begin(); it != m_ChildList.end(); it++) 00103 { 00104 s = *it; 00105 if (dynamic_cast<Button *>(s)) 00106 { 00107 Remove(s); 00108 repeat = true; 00109 break; 00110 } 00111 } 00112 } 00113 y = 5; 00114 }

Generated for SDL C++ GUI by doxygen 1.3.6