00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LOGIN_H
00023 #define LOGIN_H
00024
00025 #include "gui/widgets/window.h"
00026
00027 #include <guichan/actionlistener.hpp>
00028 #include <guichan/keylistener.hpp>
00029 #include <guichan/listmodel.hpp>
00030
00031 #include <string>
00032 #include <vector>
00033
00034 class LoginData;
00035
00041 class LoginDialog : public Window, public gcn::ActionListener,
00042 public gcn::KeyListener
00043 {
00044 public:
00050 LoginDialog(LoginData *loginData);
00051
00052 ~LoginDialog();
00053
00057 void action(const gcn::ActionEvent &event);
00058
00062 void keyPressed(gcn::KeyEvent &keyEvent);
00063
00064 private:
00069 bool canSubmit();
00070
00071 #ifdef EATHENA_SUPPORT
00072
00079 static bool isUShort(const std::string &str);
00080
00088 static unsigned short getUShort(const std::string &str);
00089
00090 #endif
00091 gcn::TextField *mUserField;
00092 gcn::TextField *mPassField;
00093 #ifdef EATHENA_SUPPORT
00094 gcn::TextField *mServerField;
00095 gcn::TextField *mPortField;
00096 gcn::DropDown *mServerDropDown;
00097 #endif
00098 gcn::CheckBox *mKeepCheck;
00099 gcn::Button *mOkButton;
00100 gcn::Button *mCancelButton;
00101 gcn::Button *mRegisterButton;
00102
00103 LoginData *mLoginData;
00104
00109 class DropDownList : public gcn::ListModel
00110 {
00111 private:
00112 std::vector<std::string> mServers;
00113 std::vector<std::string> mPorts;
00114 std::string mConfigPrefix;
00115 int mMaxEntries;
00116 void saveEntry(const std::string &server,
00117 const std::string &port, int &saved);
00118 public:
00119 DropDownList(std::string prefix,
00120 std::vector<std::string> dfltServer,
00121 std::vector<std::string> dfltPort,
00122 int maxEntries);
00123 void save(const std::string &server, const std::string &port);
00124 int getNumberOfElements();
00125 std::string getElementAt(int i);
00126 std::string getServerAt(int i);
00127 std::string getPortAt(int i);
00128 };
00129 DropDownList *mServerList;
00130 };
00131
00132 #endif