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

LoginDialog.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 "FormSurface.h" 00028 #include "forms/Login.h" 00029 #include "MainWindow.h" 00030 #include "LoginDialog.h" 00031 00032 using Form::Login; 00033 00034 00035 LoginDialog::LoginDialog(Surface *s) 00036 :FormSurface(s, 220, 140, 200, 200) 00037 ,m_st1 (this, 5, 5, 150, 25) 00038 ,m_login(this, 5, 35, 150, 25) 00039 ,m_st2 (this, 5, 65, 150, 25) 00040 ,m_passwd(this, 5, 95, 150, 25) 00041 ,m_ok (this, 5, 125, 90, 25) 00042 ,m_cancel(this,105,125, 90, 25) 00043 { 00044 Uint32 bgcolor = SDL_MapRGBA(GetScreen() -> format, 192, 192, 192, 128); 00045 Uint32 txtcolor = SDL_MapRGBA(GetScreen() -> format, 255, 192, 64, 255); 00046 00047 SetText("LoginDialog"); 00048 CreateTemporaryScreen(); 00049 00050 // SetBgColor(bgcolor); 00051 // SetFgColor(txtcolor); 00052 SetMoveable(true); 00053 00054 m_st1.SetText("Login"); 00055 m_st2.SetText("Password"); 00056 m_passwd.SetEcho('*'); 00057 m_ok.SetText("OK"); 00058 m_cancel.SetText("Cancel"); 00059 00060 UpdateData(false); 00061 00062 AddChild(&m_st1); 00063 AddChild(&m_login); 00064 AddChild(&m_st2); 00065 AddChild(&m_passwd); 00066 AddChild(&m_ok); 00067 AddChild(&m_cancel); 00068 } 00069 00070 00071 LoginDialog::~LoginDialog() 00072 { 00073 } 00074 00075 00076 void LoginDialog::OnEvent(surface_event_t *pstEvent) 00077 { 00078 if (pstEvent -> type == GUI_EVENT_BUTTON) 00079 { 00080 Login *pclForm = dynamic_cast<Login *>(GetForm()); 00081 if (pstEvent -> local_id == m_ok.GetLocalID()) 00082 { 00083 UpdateData(); 00084 if (pclForm) 00085 { 00086 pclForm -> SetFormDoneOK(); 00087 } 00088 OnClose(); 00089 } 00090 else 00091 if (pstEvent -> local_id == m_cancel.GetLocalID()) 00092 { 00093 if (pclForm) 00094 { 00095 pclForm -> SetFormDoneCancel(); 00096 } 00097 OnClose(); 00098 } 00099 } 00100 } 00101 00102 00103 void LoginDialog::Draw() 00104 { 00105 SDL_Rect *area = GetClientRectPtr(); 00106 Uint32 color = GetBgColor(); 00107 00108 SDL_FillRect(m_screen, area, color); 00109 } 00110 00111 00112 void LoginDialog::UpdateData(bool dlg2vars) 00113 { 00114 if (dlg2vars) 00115 { 00116 Login *pclForm = dynamic_cast<Login *>(GetForm()); 00117 00118 if (pclForm) 00119 { 00120 pclForm -> SetLogin(m_login.GetLine()); 00121 DEB( printf("Login '%s'\n",m_login.GetLine());) 00122 pclForm -> SetPassword(m_passwd.GetLine()); 00123 DEB( printf("Password '%s'\n",m_passwd.GetLine());) 00124 } 00125 else 00126 { 00127 DEB( printf("Not a Login Form???\n");) 00128 } 00129 // Globals::m_login = m_login.GetLine(); 00130 // Globals::m_passwd = atoi(m_passwd.GetLine()); 00131 } 00132 else 00133 { 00134 m_login.SetLine(""); 00135 m_passwd.SetLine(""); 00136 } 00137 } 00138

Generated for SDL C++ GUI by doxygen 1.3.6