summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-19 12:41:27 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-19 12:41:27 +0000
commit86e10f867bc0531cdc2007524aa7757d7d594e7d (patch)
tree0e37ad5c038ca930d6a8beba557427b9ad34de8b /src
parent129040251c8242bd4b56f4fc6b107017d62bca3c (diff)
downloadmana-client-86e10f867bc0531cdc2007524aa7757d7d594e7d.tar.gz
mana-client-86e10f867bc0531cdc2007524aa7757d7d594e7d.tar.bz2
mana-client-86e10f867bc0531cdc2007524aa7757d7d594e7d.tar.xz
mana-client-86e10f867bc0531cdc2007524aa7757d7d594e7d.zip
More refining of windows.
Diffstat (limited to 'src')
-rw-r--r--src/gui/char_server.cpp15
-rw-r--r--src/gui/char_server.h7
-rw-r--r--src/gui/login.cpp41
-rw-r--r--src/gui/login.h14
-rw-r--r--src/gui/window.cpp24
-rw-r--r--src/gui/window.h2
6 files changed, 46 insertions, 57 deletions
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 342836e4..6664be84 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -30,8 +30,8 @@ char server[30];
int showServerList = 1;
-ServerSelectDialog::ServerSelectDialog():
- Window("Select Server")
+ServerSelectDialog::ServerSelectDialog(gcn::Container *parent):
+ Window(parent, "Select Server")
{
serverListModel = new ServerListModel();
serverList = new gcn::ListBox(serverListModel);
@@ -63,6 +63,8 @@ ServerSelectDialog::ServerSelectDialog():
// Select first server
serverList->setSelected(1);
}
+
+ setLocationRelativeTo(getParent());
}
ServerSelectDialog::~ServerSelectDialog()
@@ -74,11 +76,6 @@ ServerSelectDialog::~ServerSelectDialog()
delete cancelButton;
}
-void ServerSelectDialog::init()
-{
- setLocationRelativeTo(getParent());
-}
-
void ServerSelectDialog::action(const std::string& eventId)
{
if (eventId == "ok") {
@@ -103,9 +100,7 @@ std::string ServerListModel::getElementAt(int i) {
void char_server() {
- ServerSelectDialog *dialog = new ServerSelectDialog();
- guiTop->add(dialog);
- dialog->init();
+ ServerSelectDialog *dialog = new ServerSelectDialog(guiTop);
state = LOGIN;
diff --git a/src/gui/char_server.h b/src/gui/char_server.h
index 6a11c589..66ea52bf 100644
--- a/src/gui/char_server.h
+++ b/src/gui/char_server.h
@@ -52,15 +52,10 @@ class ServerListModel : public gcn::ListModel {
*/
class ServerSelectDialog : public Window, public gcn::ActionListener {
public:
- ServerSelectDialog();
+ ServerSelectDialog(gcn::Container *parent);
~ServerSelectDialog();
/**
- * Initializes the dialog. Should be called after adding it to the GUI.
- */
- void init();
-
- /**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index cd74e850..3748106b 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -28,8 +28,8 @@
#include "../graphic/graphic.h"
-LoginDialog::LoginDialog():
- Window("Login")
+LoginDialog::LoginDialog(gcn::Container *parent):
+ Window(parent, "Login")
{
userLabel = new gcn::Label("Name:");
passLabel = new gcn::Label("Password:");
@@ -69,21 +69,7 @@ LoginDialog::LoginDialog():
add(keepCheck);
add(okButton);
add(cancelButton);
-}
-
-LoginDialog::~LoginDialog()
-{
- delete userLabel;
- delete passLabel;
- delete userField;
- delete passField;
- delete keepCheck;
- delete okButton;
- delete cancelButton;
-}
-void LoginDialog::init()
-{
setLocationRelativeTo(getParent());
userField->requestFocus();
userField->setCaretPosition(userField->getText().length());
@@ -96,6 +82,17 @@ void LoginDialog::init()
}
}
+LoginDialog::~LoginDialog()
+{
+ delete userLabel;
+ delete passLabel;
+ delete userField;
+ delete passField;
+ delete keepCheck;
+ delete okButton;
+ delete cancelButton;
+}
+
void LoginDialog::action(const std::string& eventId)
{
if (eventId == "ok") {
@@ -124,13 +121,9 @@ void LoginDialog::action(const std::string& eventId)
}
}
-/**
- * Display login dialog
- */
+
void login() {
- LoginDialog *dialog = new LoginDialog();
- guiTop->add(dialog);
- dialog->init();
+ LoginDialog *dialog = new LoginDialog(guiTop);
while (state == LOGIN) {
clear_bitmap(buffer);
@@ -145,9 +138,7 @@ void login() {
delete dialog;
}
-/**
- * Attempt to login to login server
- */
+
void server_login(const std::string& user, const std::string& pass) {
strncpy(username, user.c_str(), LEN_USERNAME);
strncpy(password, pass.c_str(), LEN_PASSWORD);
diff --git a/src/gui/login.h b/src/gui/login.h
index 725e578c..46c12d08 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -43,15 +43,10 @@
*/
class LoginDialog : public Window, public gcn::ActionListener {
public:
- LoginDialog();
+ LoginDialog(gcn::Container *parent);
~LoginDialog();
/**
- * Initializes the dialog. Should be called after adding it to the GUI.
- */
- void init();
-
- /**
* Called when receiving actions from the widgets.
*/
void action(const std::string& eventId);
@@ -66,7 +61,14 @@ class LoginDialog : public Window, public gcn::ActionListener {
gcn::Button *cancelButton;
};
+/**
+ * Display login dialog
+ */
void login();
+
+/**
+ * Attempt to login to login server
+ */
void server_login(const std::string& user, const std::string& pass);
#endif
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index a75dd242..eb886538 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -23,7 +23,7 @@
#include "gui.h"
#include <guichan/allegro.hpp>
-Window::Window(std::string text) :
+Window::Window(gcn::Container *parent, std::string text) :
caption(text),
mousePX(0),
mousePY(0),
@@ -31,9 +31,9 @@ Window::Window(std::string text) :
mouseDown(false),
titlebarHeight(20)
{
- titlebarColor.r = 32;
- titlebarColor.g = 32;
- titlebarColor.b = 128;
+ titlebarColor.r = 203;
+ titlebarColor.g = 203;
+ titlebarColor.b = 203;
setBaseColor(gcn::Color(255, 255, 255));
@@ -50,6 +50,9 @@ Window::Window(std::string text) :
chrome->setOpaque(false);
chrome->setY(titlebarHeight);
gcn::Container::add(chrome);
+
+ // Add this window to the parent container
+ parent->add(this);
}
Window::~Window()
@@ -72,6 +75,10 @@ void Window::draw(gcn::Graphics* graphics)
getDimension().height - titlebarHeight));
}
+ // Draw line around window
+ graphics->setColor(titlebarColor);
+ graphics->drawRectangle(gcn::Rectangle(0, titlebarHeight - 1,
+ getWidth(), getHeight() - titlebarHeight + 1));
// Skinned dialog render
if (typeid(*graphics) == typeid(gcn::AllegroGraphics))
@@ -95,7 +102,7 @@ void Window::draw(gcn::Graphics* graphics)
// Plain title bar
graphics->setColor(titlebarColor);
graphics->fillRectangle(gcn::Rectangle(0, 0,
- getDimension().width, titlebarHeight));
+ getWidth(), titlebarHeight));
}
// Draw title
@@ -173,7 +180,6 @@ void Window::mouseRelease(int mx, int my, int button)
mouseDown = false;
}
-//window move
void Window::mouseMotion(int mx, int my)
{
if (mouseDown)
@@ -186,17 +192,17 @@ void Window::mouseMotion(int mx, int my)
x = x - (mousePX - mx);
y = y - (mousePY - my);
- //keep guichan window inside window
+ // Keep guichan window inside window
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (x + winWidth > 799)
x = 799 - winWidth;
- if (y + winWidth > 599)
+ if (y + winHeight > 599)
y = 599 - winHeight;
- //snap window to edges
+ // Snap window to edges
if (x < snapSize)
x = 0;
if (y < snapSize)
diff --git a/src/gui/window.h b/src/gui/window.h
index a51a150c..3fa3f58f 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -49,7 +49,7 @@ class Window : public gcn::Container, public gcn::MouseListener
BITMAP *dRight; /**< Right side of title bar */
public:
- Window(std::string text = "Window");
+ Window(gcn::Container *parent, std::string text = "Window");
~Window();
/**