MsgBoxDialog.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #include <dialogs/MsgBoxDialog.h>
00022 #include <graph/TextureStore.h>
00023 #include <GLW/GLWWindowManager.h>
00024 
00025 MsgBoxDialog *MsgBoxDialog::instance_ = 0;
00026 
00027 MsgBoxDialog *MsgBoxDialog::instance()
00028 {
00029         if (!instance_)
00030         {
00031                 instance_ = new MsgBoxDialog;
00032         }
00033         return instance_;
00034 }
00035 
00036 MsgBoxDialog::MsgBoxDialog() : 
00037         GLWWindow("", 210.0f, 150.0f, 0, "")
00038 {
00039         GLWPanel *topPanel = new GLWPanel(0.0f, 0.0f, 0.0f, 0.0f, false, false);
00040 
00041         GLTexture *texture = TextureStore::instance()->loadTexture(
00042                 S3D::getDataFile("data/windows/exclaim.bmp"),
00043                 S3D::getDataFile("data/windows/mask.bmp"));
00044         icon_ = new GLWIcon(0.0f, 0.0f, 32.0f, 32.0f, texture);
00045         topPanel->addWidget(icon_, 0, SpaceLeft | SpaceTop | AlignTop, 10.0f);
00046 
00047         message_ = new GLWLabel(0.0f, 0.0f, LANG_STRING(""), 8.0f, GLWLabel::eMultiLine);
00048         topPanel->addWidget(message_, 0, SpaceTop | SpaceLeft | SpaceRight | AlignCenterLeftRight, 10.0f);
00049 
00050         topPanel->setLayout(GLWPanel::LayoutHorizontal);
00051         addWidget(topPanel);
00052 
00053         okButton_ = (GLWTextButton *) 
00054                 addWidget(new GLWTextButton(LANG_RESOURCE("CANCEL", "Cancel"), 95, 10, 105, this, 
00055                 GLWButton::ButtonFlagCancel | GLWButton::ButtonFlagOk | 
00056                 GLWButton::ButtonFlagCenterX), 0, SpaceAll | AlignRight, 10.0f);
00057         okButton_->setToolTip(new ToolTip(ToolTip::ToolTipHelp, 
00058                 LANG_RESOURCE("CANCEL", "Cancel"),
00059                 LANG_RESOURCE("CANCEL_TOOLTIP", "Return to the game.")));
00060 
00061         windowLevel_ = 1000;
00062 
00063         setLayout(GLWPanel::LayoutVerticle);
00064         layout();
00065 }
00066 
00067 MsgBoxDialog::~MsgBoxDialog()
00068 {
00069 
00070 }
00071 
00072 void MsgBoxDialog::show(const LangString &message)
00073 {
00074         message_->setText(message);
00075         message_->calcWidth();
00076         layout();
00077 
00078         GLWWindowManager::instance()->showWindow(id_);
00079 }
00080 
00081 void MsgBoxDialog::buttonDown(unsigned int id)
00082 {
00083         if (id == okButton_->getId())
00084         {
00085                 GLWWindowManager::instance()->hideWindow(id_);
00086         }
00087 }
00088 
00089 void MsgBoxDialog::mouseDown(int button, float x, float y, bool &skipRest)
00090 {
00091         GLWWindow::mouseDown(button, x, y, skipRest);
00092         skipRest = true;
00093 }
00094 
00095 void MsgBoxDialog::mouseUp(int button, float x, float y, bool &skipRest)
00096 {
00097         GLWWindow::mouseUp(button, x,y, skipRest);
00098         skipRest = true;
00099 }
00100 
00101 void MsgBoxDialog::keyDown(char *buffer, unsigned int keyState, 
00102                 KeyboardHistory::HistoryElement *history, int hisCount, 
00103                 bool &skipRest)
00104 {
00105         GLWWindow::keyDown(buffer, keyState, history, hisCount, skipRest);
00106         skipRest = true;
00107 }
00108 
00109 void MsgBoxDialog::mouseWheel(float x, float y, float z, bool &skipRest)
00110 {
00111         GLWWindow::mouseWheel(x, y, z, skipRest);
00112         skipRest = true;
00113 }
00114 

Generated on Mon Feb 16 15:14:37 2009 for Scorched3D by  doxygen 1.5.3