diff options
author | José Ávila <linux@javila.net> | 2005-06-03 06:18:17 +0000 |
---|---|---|
committer | José Ávila <linux@javila.net> | 2005-06-03 06:18:17 +0000 |
commit | f73656a5f854bbde8aaf727c09d31a9215b1e041 (patch) | |
tree | b83c18c82c62873ab34d854a4b3ab8ff10ba0c38 /src/gui | |
parent | f4bab20b13d4b11522171b21b35d26ee43727206 (diff) | |
download | mana-f73656a5f854bbde8aaf727c09d31a9215b1e041.tar.gz mana-f73656a5f854bbde8aaf727c09d31a9215b1e041.tar.bz2 mana-f73656a5f854bbde8aaf727c09d31a9215b1e041.tar.xz mana-f73656a5f854bbde8aaf727c09d31a9215b1e041.zip |
Modification in help system
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/help.cpp | 33 | ||||
-rw-r--r-- | src/gui/help.h | 5 |
2 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 5b652f99..d1e13174 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -29,7 +29,6 @@ HelpWindow::HelpWindow(): Window("Help") { setContentSize(455, 350); - setResizeable(true); textBox = new TextBox(); textBox->setEditable(false); @@ -48,11 +47,8 @@ HelpWindow::HelpWindow(): add(scrollArea); add(okButton); - //setLocationRelativeTo(getParent()); + setLocationRelativeTo(getParent()); textBox->requestFocus(); - - std::string defHelp = "index"; - loadHelp(defHelp); } HelpWindow::~HelpWindow() @@ -66,16 +62,20 @@ HelpWindow::~HelpWindow() void HelpWindow::action(const std::string& eventId) { - scheduleDelete(); + setVisible(false); } void HelpWindow::mousePress(int mx, int my, int button) { - int x1 = scrollArea->getX() + 10; - int y1 = scrollArea->getY() + 15; - int x2 = x1 + scrollArea->getWidth() - 25; - int y2 = y1 + scrollArea->getHeight(); + getParent()->moveToTop(this); + if (button == gcn::MouseInput::LEFT) { + + int x1 = scrollArea->getX() + 10; + int y1 = scrollArea->getY() + 15; + int x2 = x1 + scrollArea->getWidth() - 25; + int y2 = y1 + scrollArea->getHeight(); + if ((mx >= x1) && (my >= y1) && (mx <= x2) && (my <= y2)) { for (unsigned int i = 0; i < links.size(); i++) @@ -85,14 +85,20 @@ void HelpWindow::mousePress(int mx, int my, int button) int y2 = y1 + textBox->getFont()->getHeight(); if ((my > y1) && (my < y2)) { std::string tmp = links[i].file; - loadHelp(tmp); + loadHelp(links[i].file); } } } - } + else if (hasMouse() && my < (int)(getTitleBarHeight() + getPadding())) + { + mMouseDrag = true; + mMouseXOffset = mx; + mMouseYOffset = my; + } + } } -void HelpWindow::loadHelp(std::string& helpFile) { +void HelpWindow::loadHelp(std::string helpFile) { helpFile = TMW_DATADIR "data/help/" + helpFile + ".txt"; std::ifstream fin; @@ -126,6 +132,7 @@ void HelpWindow::loadHelp(std::string& helpFile) { textBox->addRow(line); } scrollArea->setVerticalScrollAmount(0); + setVisible(true); fin.close(); } diff --git a/src/gui/help.h b/src/gui/help.h index 17821765..6c6bec13 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -24,7 +24,6 @@ #ifndef _TMW_HELP_H #define _TMW_HELP_H -#include <guichan.hpp> #include "window.h" #include "scrollarea.h" #include "button.h" @@ -64,13 +63,13 @@ class HelpWindow : public Window, public gcn::ActionListener /** * Load help in the dialog. */ - void loadHelp(std::string& helpFile); + void loadHelp(std::string helpFile); private: std::vector<HELP_LINK> links; gcn::Button *okButton; gcn::TextBox *textBox; - gcn::ScrollArea *scrollArea; + ScrollArea *scrollArea; }; #endif |