LogDialog.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/LogDialog.h>
00022 #include <dialogs/QuitDialog.h>
00023 #include <GLW/GLWTextButton.h>
00024 #include <GLW/GLWWindowManager.h>
00025 #include <GLEXT/GLViewPort.h>
00026 #include <graph/OptionsDisplay.h>
00027 #include <common/Logger.h>
00028 
00029 LogDialog *LogDialog::instance_ = 0;
00030 
00031 LogDialog *LogDialog::instance()
00032 {
00033         if (!instance_)
00034         {
00035                 instance_ = new LogDialog;
00036         }
00037         return instance_;
00038 }
00039 
00040 LogDialog::LogDialog() : 
00041         GLWWindow("Log", 10.0f, 10.0f, 300.0f, 240.0f, 0,
00042                 "Log Window")
00043 {
00044         needCentered_ = true;
00045         quit_ = (GLWTextButton *) 
00046                 addWidget(new GLWTextButton(LANG_RESOURCE("QUIT", "Quit"), 205, 10, 85, this, 
00047                 GLWButton::ButtonFlagCenterX));
00048         listView_ = (GLWListView *) addWidget(new GLWListView(10, 40, 280, 140, 100));
00049         serverName_ = (GLWLabel *) addWidget(new GLWLabel(5, 195, LANG_RESOURCE("LOCAL", "Local")));
00050 
00051         // Add this class as a log handler
00052         Logger::addLogger(this);
00053 }
00054 
00055 LogDialog::~LogDialog()
00056 {
00057 }
00058 
00059 void LogDialog::logMessage(LoggerInfo &info)
00060 {
00061         listView_->addLine(info.getMessage());
00062         listView_->endPosition();
00063 }
00064 
00065 void LogDialog::draw()
00066 {
00067         float wWidth = (float) GLViewPort::getWidth();
00068         float width = wWidth - 40.0f;
00069         if (width < 320) width = 320;
00070         if (width > 640) width = 640;
00071         setW(width - 20);
00072         listView_->setW(width - 40);
00073         quit_->setX(width - 115);
00074 
00075         float wHeight = (float) GLViewPort::getHeight();
00076         float height = wHeight - 40.0f;
00077         if (height < 200) height = 200;
00078         if (height > 300) height = 300;
00079         serverName_->setY(height - 50);
00080         listView_->setH(height - 90);
00081         setH(height - 20);
00082 
00083         GLWWindow::draw();
00084 }
00085 
00086 void LogDialog::buttonDown(unsigned int id)
00087 {
00088         if (id == quit_->getId())
00089         {
00090                 GLWWindowManager::instance()->
00091                         showWindow(QuitDialog::instance()->getId());
00092         }
00093 }

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