summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/buy.cpp3
-rw-r--r--src/gui/char_server.cpp3
-rw-r--r--src/gui/scrollarea.cpp108
-rw-r--r--src/gui/scrollarea.h58
-rw-r--r--src/gui/textfield.h4
6 files changed, 173 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9a91e2f5..3a98f468 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,7 @@ tmw_SOURCES = sound/sound.cpp \
gui/ok_dialog.cpp \
gui/passwordfield.cpp \
gui/progressbar.cpp \
+ gui/scrollarea.cpp \
gui/setup.cpp \
gui/shop.cpp \
gui/skill.cpp \
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index c2648ef3..2f2e01ef 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -24,6 +24,7 @@
#include "buy.h"
#include "button.h"
#include "slider.h"
+#include "scrollarea.h"
#include <sstream>
@@ -32,7 +33,7 @@ BuyDialog::BuyDialog(gcn::Container *parent):
money(0)
{
itemList = new gcn::ListBox(this);
- scrollArea = new gcn::ScrollArea(itemList);
+ scrollArea = new ScrollArea(itemList);
slider = new Slider(1.0);
quantityLabel = new gcn::Label("0");
moneyLabel = new gcn::Label("350 G");
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index eee37277..ef45fbcc 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -25,6 +25,7 @@
#include "../graphic/graphic.h"
#include "button.h"
#include "window.h"
+#include "scrollarea.h"
char server[30];
int showServerList = 1;
@@ -35,7 +36,7 @@ ServerSelectDialog::ServerSelectDialog(gcn::Container *parent):
{
serverListModel = new ServerListModel();
serverList = new gcn::ListBox(serverListModel);
- scrollArea = new gcn::ScrollArea(serverList);
+ scrollArea = new ScrollArea(serverList);
okButton = new Button("OK");
cancelButton = new Button("Cancel");
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
new file mode 100644
index 00000000..30460efb
--- /dev/null
+++ b/src/gui/scrollarea.cpp
@@ -0,0 +1,108 @@
+/*
+ * 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 "scrollarea.h"
+#include "gui.h"
+
+
+ScrollArea::ScrollArea():
+ gcn::ScrollArea()
+{
+ setBorderSize(2);
+}
+
+ScrollArea::ScrollArea(gcn::Widget *widget):
+ gcn::ScrollArea(widget)
+{
+ setBorderSize(2);
+}
+
+void ScrollArea::draw(gcn::Graphics *graphics)
+{
+ int alpha = getBaseColor().a;
+ gcn::Color highlightColor = getBaseColor() + 0x303030;
+ highlightColor.a = alpha;
+ gcn::Color shadowColor = getBaseColor() - 0x303030;
+ shadowColor.a = alpha;
+
+ if (mVBarVisible)
+ {
+ drawUpButton(graphics);
+ drawDownButton(graphics);
+ drawVBar(graphics);
+ drawVMarker(graphics);
+ }
+
+ if (mHBarVisible)
+ {
+ drawLeftButton(graphics);
+ drawRightButton(graphics);
+ drawHBar(graphics);
+ drawHMarker(graphics);
+ }
+
+ if (mHBarVisible && mVBarVisible)
+ {
+ graphics->setColor(getBaseColor());
+ graphics->fillRectangle(gcn::Rectangle(getWidth() - mScrollbarWidth,
+ getHeight() - mScrollbarWidth,
+ mScrollbarWidth,
+ mScrollbarWidth));
+ }
+
+ if (mContent)
+ {
+ gcn::Rectangle contdim = mContent->getDimension();
+ graphics->pushClipArea(getContentDimension());
+
+ if (mContent->getBorderSize() > 0)
+ {
+ gcn::Rectangle rec = mContent->getDimension();
+ rec.x -= mContent->getBorderSize();
+ rec.y -= mContent->getBorderSize();
+ rec.width += 2 * mContent->getBorderSize();
+ rec.height += 2 * mContent->getBorderSize();
+ graphics->pushClipArea(rec);
+ mContent->drawBorder(graphics);
+ graphics->popClipArea();
+ }
+
+ graphics->pushClipArea(contdim);
+ mContent->draw(graphics);
+ graphics->popClipArea();
+ graphics->popClipArea();
+ }
+}
+
+void ScrollArea::drawBorder(gcn::Graphics *graphics)
+{
+ int x, y, w, h, bs;
+ getAbsolutePosition(x, y);
+ bs = getBorderSize();
+ w = getWidth() + bs * 2;
+ h = getHeight() + bs * 2;
+ x -= bs;
+ y -= bs;
+
+ draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, x, y, w, h);
+}
diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h
new file mode 100644
index 00000000..63c8a122
--- /dev/null
+++ b/src/gui/scrollarea.h
@@ -0,0 +1,58 @@
+/*
+ * 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_SCROLLAREA_H__
+#define __TMW_SCROLLAREA_H__
+
+#include <allegro.h>
+#include <guichan.hpp>
+
+/**
+ * A scroll area.
+ *
+ * \ingroup GUI
+ */
+class ScrollArea : public gcn::ScrollArea {
+ public:
+ /**
+ * Constructor.
+ */
+ ScrollArea();
+
+ /**
+ * Constructor.
+ */
+ ScrollArea(gcn::Widget *content);
+
+ /**
+ * Draws the scroll area.
+ */
+ void draw(gcn::Graphics *graphics);
+
+ /**
+ * Draws the background and border of the scroll area.
+ */
+ void drawBorder(gcn::Graphics *graphics);
+};
+
+#endif
diff --git a/src/gui/textfield.h b/src/gui/textfield.h
index a8aa9245..306a776c 100644
--- a/src/gui/textfield.h
+++ b/src/gui/textfield.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef __TEXTFIELD_H__
-#define __TEXTFIELD_H__
+#ifndef __TMW_TEXTFIELD_H__
+#define __TMW_TEXTFIELD_H__
#include <allegro.h>
#include <guichan.hpp>