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/gui | |
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/gui')
-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 |
8 files changed, 209 insertions, 4 deletions
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 |