diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-30 13:11:32 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-30 13:11:32 +0000 |
commit | bbd44ef322cb26ed326250300e240df6fc19b545 (patch) | |
tree | 8b61902cd739c77b872a0d0e081711223bb917e8 /src | |
parent | a6938f026fd8656cb559f2645110880f4e79c4f5 (diff) | |
download | mana-bbd44ef322cb26ed326250300e240df6fc19b545.tar.gz mana-bbd44ef322cb26ed326250300e240df6fc19b545.tar.bz2 mana-bbd44ef322cb26ed326250300e240df6fc19b545.tar.xz mana-bbd44ef322cb26ed326250300e240df6fc19b545.zip |
Subclassed ListBox and TextBox for a little better visual appearance.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/gui/buy.cpp | 3 | ||||
-rw-r--r-- | src/gui/listbox.cpp | 60 | ||||
-rw-r--r-- | src/gui/listbox.h | 54 | ||||
-rw-r--r-- | src/gui/npc.cpp | 3 | ||||
-rw-r--r-- | src/gui/npc_text.cpp | 3 | ||||
-rw-r--r-- | src/gui/sell.cpp | 3 | ||||
-rw-r--r-- | src/gui/textbox.cpp | 38 | ||||
-rw-r--r-- | src/gui/textbox.h | 49 | ||||
-rw-r--r-- | src/sound/sound.cpp | 2 | ||||
-rw-r--r-- | src/sound/sound.h | 6 |
11 files changed, 217 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 51d8b71b..7c8923b7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,7 @@ tmw_SOURCES = sound/sound.cpp \ gui/checkbox.cpp \ gui/gui.cpp \ gui/inventory.cpp \ + gui/listbox.cpp \ gui/login.cpp \ gui/npc.cpp \ gui/npc_text.cpp \ @@ -27,6 +28,7 @@ tmw_SOURCES = sound/sound.cpp \ gui/slider.cpp \ gui/status.cpp \ gui/stats.cpp \ + gui/textbox.cpp \ gui/textfield.cpp \ gui/window.cpp \ net/network.cpp \ diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 2f2e01ef..8eefa503 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -25,6 +25,7 @@ #include "button.h" #include "slider.h" #include "scrollarea.h" +#include "listbox.h" #include <sstream> @@ -32,7 +33,7 @@ BuyDialog::BuyDialog(gcn::Container *parent): Window(parent, "Buy"), money(0) { - itemList = new gcn::ListBox(this); + itemList = new ListBox(this); scrollArea = new ScrollArea(itemList); slider = new Slider(1.0); quantityLabel = new gcn::Label("0"); diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp new file mode 100644 index 00000000..b45823a6 --- /dev/null +++ b/src/gui/listbox.cpp @@ -0,0 +1,60 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "listbox.h" + +ListBox::ListBox(): + gcn::ListBox() +{ +} + +ListBox::ListBox(gcn::ListModel *listModel): + gcn::ListBox(listModel) +{ +} + +void ListBox::draw(gcn::Graphics *graphics) +{ + if (mListModel == NULL) { + return; + } + + graphics->setColor(gcn::Color(110, 160, 255)); + graphics->setFont(getFont()); + + int i; + int fontHeight = getFont()->getHeight(); + int y = 0; + + for (i = 0; i < mListModel->getNumberOfElements(); ++i) + { + if (i == mSelected) { + graphics->fillRectangle( + gcn::Rectangle(0, y, getWidth(), fontHeight)); + } + + graphics->drawText(mListModel->getElementAt(i), 1, y); + + y += fontHeight; + } +} diff --git a/src/gui/listbox.h b/src/gui/listbox.h new file mode 100644 index 00000000..2238bffb --- /dev/null +++ b/src/gui/listbox.h @@ -0,0 +1,54 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef __TMW_LISTBOX_H__ +#define __TMW_LISTBOX_H__ + +#include <guichan.hpp> + +/** + * A list box, meant to be used inside a scroll area. Same as the Guichan list + * box except this one doesn't have a background, instead completely relying + * on the scroll area. + * + * \ingroup GUI + */ +class ListBox : public gcn::ListBox { + public: + /** + * Constructor. + */ + ListBox(); + + /** + * Constructor. + */ + ListBox(gcn::ListModel *listModel); + + /** + * Draws the list box. + */ + void draw(gcn::Graphics *graphics); +}; + +#endif diff --git a/src/gui/npc.cpp b/src/gui/npc.cpp index 80d55c73..95180356 100644 --- a/src/gui/npc.cpp +++ b/src/gui/npc.cpp @@ -24,12 +24,13 @@ #include "npc.h" #include "button.h" #include "scrollarea.h" +#include "listbox.h" #include "../game.h" NpcListDialog::NpcListDialog(gcn::Container *parent): Window(parent, "NPC") { - itemList = new gcn::ListBox(this); + itemList = new ListBox(this); scrollArea = new ScrollArea(itemList); okButton = new Button("OK"); cancelButton = new Button("Cancel"); diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index 38c29688..dc70927c 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -24,12 +24,13 @@ #include "npc_text.h" #include "scrollarea.h" #include "button.h" +#include "textbox.h" #include "../game.h" NpcTextDialog::NpcTextDialog(gcn::Container *parent): Window(parent, "NPC") { - textBox = new gcn::TextBox(); + textBox = new TextBox(); textBox->setEditable(false); scrollArea = new ScrollArea(textBox); okButton = new Button("OK"); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 4dc210a4..bdf6ec6d 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -25,6 +25,7 @@ #include "button.h" #include "slider.h" #include "scrollarea.h" +#include "listbox.h" #include "../graphic/graphic.h" #include <sstream> @@ -32,7 +33,7 @@ SellDialog::SellDialog(gcn::Container *parent): Window(parent, "Sell") { - itemList = new gcn::ListBox(this); + itemList = new ListBox(this); scrollArea = new ScrollArea(itemList); slider = new Slider(1.0); quantityLabel = new gcn::Label("0"); diff --git a/src/gui/textbox.cpp b/src/gui/textbox.cpp new file mode 100644 index 00000000..a620f29f --- /dev/null +++ b/src/gui/textbox.cpp @@ -0,0 +1,38 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#include "textbox.h" + +TextBox::TextBox(): + gcn::TextBox() +{ + setOpaque(false); + setBorderSize(0); +} + +TextBox::TextBox(const std::string& text): + gcn::TextBox(text) +{ + setOpaque(false); + setBorderSize(0); +} diff --git a/src/gui/textbox.h b/src/gui/textbox.h new file mode 100644 index 00000000..8f5d910f --- /dev/null +++ b/src/gui/textbox.h @@ -0,0 +1,49 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ + */ + +#ifndef __TMW_TEXTBOX_H__ +#define __TMW_TEXTBOX_H__ + +#include <guichan.hpp> + +/** + * A text box, meant to be used inside a scroll area. Same as the Guichan text + * box except this one doesn't have a background or border, instead completely + * relying on the scroll area. + * + * \ingroup GUI + */ +class TextBox : public gcn::TextBox { + public: + /** + * Constructor. + */ + TextBox(); + + /** + * Constructor. + */ + TextBox(const std::string& text); +}; + +#endif diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp index 8ec29d7b..7d2ba834 100644 --- a/src/sound/sound.cpp +++ b/src/sound/sound.cpp @@ -17,6 +17,8 @@ * You should have received a copy of the GNU General Public License * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ */ #ifndef WIN32 diff --git a/src/sound/sound.h b/src/sound/sound.h index 95e8b7b8..1404ba48 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -17,10 +17,12 @@ * You should have received a copy of the GNU General Public License * along with The Mana World; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id$ */ -#ifndef __SOUND_H -#define __SOUND_H +#ifndef _TMW_SOUND_H +#define _TMW_SOUND_H #ifndef WIN32 |