00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
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 }