00001 /* 00002 * Metroid Password Generator 00003 * Copyright (C) 2005 emuWorks 00004 * http://games.technoplaza.net/ 00005 * 00006 * This file is part of Metroid Password Generator. 00007 * 00008 * Metroid Password Generator is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * Metroid Password Generator is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Metroid Password Generator; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 // $Id: PasswordPanel.hh,v 1.4 2005/09/27 09:32:14 technoplaza Exp $ 00024 00025 namespace mpg { 00026 class Password; 00027 00028 /// class to display a password in Metroid font and style 00029 class PasswordPanel : public wxPanel { 00030 DECLARE_DYNAMIC_CLASS(PasswordPanel) 00031 DECLARE_EVENT_TABLE() 00032 00033 private: 00034 wxBitmap alphabet; 00035 const Password *password; 00036 00037 static const int START_X = 4; 00038 static const int START_Y = 4; 00039 static const int CHARS_PER_ROW = 13; 00040 static const int CHAR_WIDTH = 16; 00041 static const int CHAR_HEIGHT = 16; 00042 00043 /** 00044 * Gets the upper-left corner position of a letter in the alphabet 00045 * bitmap. 00046 * 00047 * @param letter The letter to find. 00048 * 00049 * @return The (x,y) position of the letter. 00050 */ 00051 wxPoint getLetterPos(wxChar letter) const; 00052 00053 /** 00054 * Called to erase the background on this PasswordPanel. 00055 * 00056 * @param event The triggering wxEraseEvent (unused). 00057 */ 00058 void onEraseBackground(wxEraseEvent &event); 00059 00060 /** 00061 * Called to paint this PasswordPanel. 00062 * 00063 * @param event The triggering wxPaintEvent (unused). 00064 */ 00065 void onPaint(wxPaintEvent &event); 00066 00067 public: 00068 /** 00069 * Creates a new PasswordPanel. 00070 */ 00071 PasswordPanel(); 00072 00073 /** 00074 * Sets the password string drawn by this PasswordPanel. 00075 * 00076 * @param password The password. 00077 */ 00078 void setPassword(const Password *password); 00079 }; 00080 00081 inline void PasswordPanel::setPassword(const Password *password) 00082 { this->password = password; } 00083 inline void PasswordPanel::onEraseBackground(wxEraseEvent &) {} 00084 } 00085