summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 15:50:42 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-16 15:50:42 +0000
commit57b3e0e1f0b835ff2982e9f66c7af402caecd3c1 (patch)
treed47849491f941ae2074840d2f44fd8fc1148af5d /src
parent960257dd1744a7c735f9ece50eaef79c96c895a9 (diff)
downloadmana-57b3e0e1f0b835ff2982e9f66c7af402caecd3c1.tar.gz
mana-57b3e0e1f0b835ff2982e9f66c7af402caecd3c1.tar.bz2
mana-57b3e0e1f0b835ff2982e9f66c7af402caecd3c1.tar.xz
mana-57b3e0e1f0b835ff2982e9f66c7af402caecd3c1.zip
Formatting updates to buddy window and menu item and made testing menu item
visible.
Diffstat (limited to 'src')
-rw-r--r--src/gui/buddywindow.cpp13
-rw-r--r--src/gui/buddywindow.h8
-rw-r--r--src/gui/menuitem.cpp60
-rw-r--r--src/gui/menuitem.h51
-rw-r--r--src/resources/buddylist.cpp66
-rw-r--r--src/resources/buddylist.h64
6 files changed, 131 insertions, 131 deletions
diff --git a/src/gui/buddywindow.cpp b/src/gui/buddywindow.cpp
index f9c32be5..2e81c798 100644
--- a/src/gui/buddywindow.cpp
+++ b/src/gui/buddywindow.cpp
@@ -18,26 +18,28 @@
* 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 "buddywindow.h"
#include "menuitem.h"
BuddyWindow::BuddyWindow():
- Window("Buddys")
+ Window("Buddys")
{
- setContentSize(80,200);
-
+ setContentSize(80, 200);
+
listbox = new gcn::ListBox();
listbox->setListModel(dynamic_cast<ListModel*>(this));
-
+
scrollArea = new ScrollArea(listbox);
scrollArea->setDimension(gcn::Rectangle(
2, 0, 76, 180));
add(scrollArea);
-
+
addBuddy("Usiu"); // for testing
MenuItem *item = new MenuItem("Test");
+ item->setPosition(0, 200 - item->getHeight());
add(item);
}
@@ -55,6 +57,5 @@ void BuddyWindow::draw(gcn::Graphics *graphics)
void BuddyWindow::action(const std::string& eventId)
{
-
}
diff --git a/src/gui/buddywindow.h b/src/gui/buddywindow.h
index 00fb07fb..a884ba6f 100644
--- a/src/gui/buddywindow.h
+++ b/src/gui/buddywindow.h
@@ -18,6 +18,7 @@
* 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_BUDDYWINDOW_H
@@ -34,7 +35,7 @@
* \ingroup Interface
*/
class BuddyWindow : public Window, public BuddyList,
- public gcn::ActionListener
+ public gcn::ActionListener
{
public:
/**
@@ -56,11 +57,10 @@ class BuddyWindow : public Window, public BuddyList,
* Performs action.
*/
void action(const std::string &actionId);
-
+
private:
- gcn::ListBox *listbox;
+ gcn::ListBox *listbox;
ScrollArea *scrollArea;
};
#endif /* _TMW_BUDDYWINDOW_H */
-
diff --git a/src/gui/menuitem.cpp b/src/gui/menuitem.cpp
index 0f3aa2c1..256f5712 100644
--- a/src/gui/menuitem.cpp
+++ b/src/gui/menuitem.cpp
@@ -18,6 +18,7 @@
* 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 "menuitem.h"
@@ -25,46 +26,45 @@
MenuItem::MenuItem(const std::string& label)
{
- setBorderSize(0);
+ setBorderSize(0);
- // Load graphic
- Image *item[4];
-
- ResourceManager *resman = ResourceManager::getInstance();
+ // Load graphic
+ Image *item[4];
- item[0] = resman->getImage("graphics/gui/menuitemN.png");
- item[1] = resman->getImage("graphics/gui/menuitemF.png");
- item[2] = resman->getImage("graphics/gui/menuitemP.png");
- item[3] = resman->getImage("graphics/gui/menuitemP.png");
+ ResourceManager *resman = ResourceManager::getInstance();
- int bgridx[4] = {0, 9, 16, 25};
- int bgridy[4] = {0, 4, 19, 24};
- int a, x, y;
+ item[0] = resman->getImage("graphics/gui/menuitemN.png");
+ item[1] = resman->getImage("graphics/gui/menuitemF.png");
+ item[2] = resman->getImage("graphics/gui/menuitemP.png");
+ item[3] = resman->getImage("graphics/gui/menuitemP.png");
- for (int mode = 0; mode < 4; mode++) {
- a = 0;
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
- menuitem[mode].grid[a] = item[mode]->getSubImage(
- bgridx[x], bgridy[y],
- bgridx[x + 1] - bgridx[x] + 1,
- bgridy[y + 1] - bgridy[y] + 1);
- a++;
- }
- }
- }
- addMouseListener(this);
+ int bgridx[4] = {0, 9, 16, 25};
+ int bgridy[4] = {0, 4, 19, 24};
+ int a, x, y;
+
+ for (int mode = 0; mode < 4; mode++) {
+ a = 0;
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
+ menuitem[mode].grid[a] = item[mode]->getSubImage(
+ bgridx[x], bgridy[y],
+ bgridx[x + 1] - bgridx[x] + 1,
+ bgridy[y + 1] - bgridy[y] + 1);
+ a++;
+ }
+ }
+ }
+ addMouseListener(this);
+ setSize(50,10);
}
- MenuItem::~MenuItem()
+MenuItem::~MenuItem()
{
-
}
void MenuItem::draw(gcn::Graphics* graphics)
{
- int mode=0;
-
+ int mode = 0;
int x, y;
getAbsolutePosition(x, y);
@@ -74,6 +74,4 @@ void MenuItem::draw(gcn::Graphics* graphics)
void MenuItem::mousePress(int x, int y, int button)
{
-
}
-
diff --git a/src/gui/menuitem.h b/src/gui/menuitem.h
index 1dd5dad7..dcfdf11f 100644
--- a/src/gui/menuitem.h
+++ b/src/gui/menuitem.h
@@ -18,6 +18,7 @@
* 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_MENUITEM_H
@@ -29,29 +30,29 @@
class MenuItem : public gcn::Widget, public gcn::MouseListener
{
- public:
- /**
- * Constructor.
- */
- MenuItem(const std::string& label);
-
- /**
- * Destructor.
- */
- ~MenuItem();
-
- /**
- * Draws the MenuItem.
- */
- void draw(gcn::Graphics* graphics);
-
- /**
- * Handles mouse
- */
- void mousePress(int x, int y, int button);
-
- private:
- ImageRect menuitem[4];
-};
-#endif /* _TMW_MENUITEM_H */
+ public:
+ /**
+ * Constructor.
+ */
+ MenuItem(const std::string& label);
+
+ /**
+ * Destructor.
+ */
+ ~MenuItem();
+
+ /**
+ * Draws the MenuItem.
+ */
+ void draw(gcn::Graphics* graphics);
+ /**
+ * Handles mouse
+ */
+ void mousePress(int x, int y, int button);
+
+ private:
+ ImageRect menuitem[4];
+};
+
+#endif /* _TMW_MENUITEM_H */
diff --git a/src/resources/buddylist.cpp b/src/resources/buddylist.cpp
index 91bcf986..226551c7 100644
--- a/src/resources/buddylist.cpp
+++ b/src/resources/buddylist.cpp
@@ -18,6 +18,7 @@
* 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 "buddylist.h"
@@ -33,49 +34,48 @@ BuddyList::~BuddyList()
bool BuddyList::addBuddy(const std::string buddy)
{
- for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
- {
- // Buddy already exist
- if(*buddyit == buddy) return false;
- }
-
- // Buddy doesnt exist, add it
- buddylist.push_back(buddy);
-
- return true;
+ for (buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ {
+ // Buddy already exist
+ if (*buddyit == buddy) return false;
+ }
+
+ // Buddy doesnt exist, add it
+ buddylist.push_back(buddy);
+
+ return true;
}
bool BuddyList::removeBuddy(const std::string buddy)
{
- if(buddylist.size() > 0) {
- for(buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
- {
- // Buddy exist, remove it
- if(*buddyit == buddy) {
- buddylist.remove(buddy);
- return true;
- }
- }
- }
-
- // Buddy doesnt exist
- return false;
+ if (buddylist.size() > 0) {
+ for (buddyit = buddylist.begin(); buddyit != buddylist.end(); buddyit++)
+ {
+ // Buddy exist, remove it
+ if (*buddyit == buddy) {
+ buddylist.remove(buddy);
+ return true;
+ }
+ }
+ }
+
+ // Buddy doesnt exist
+ return false;
}
int BuddyList::getNumberOfElements(void)
{
- return buddylist.size();
+ return buddylist.size();
}
std::string BuddyList::getElementAt(int number)
{
- if(number <= buddylist.size() - 1)
- {
- buddyit = buddylist.begin();
- std::advance(buddyit, number);
- return *buddyit;
- }
-
- return "";
-}
+ if (number <= buddylist.size() - 1)
+ {
+ buddyit = buddylist.begin();
+ std::advance(buddyit, number);
+ return *buddyit;
+ }
+ return "";
+}
diff --git a/src/resources/buddylist.h b/src/resources/buddylist.h
index 704ce450..d0598747 100644
--- a/src/resources/buddylist.h
+++ b/src/resources/buddylist.h
@@ -18,6 +18,7 @@
* 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_BUDDYLIST_H
@@ -28,41 +29,40 @@
#include <string>
class BuddyList : public gcn::ListModel {
- public:
- /**
- * Constructor
- */
- BuddyList();
+ public:
+ /**
+ * Constructor
+ */
+ BuddyList();
- /**
- * Destructor
- */
- virtual ~BuddyList();
-
- /**
- * Adds buddy to the list
- */
- bool addBuddy(const std::string buddy);
+ /**
+ * Destructor
+ */
+ virtual ~BuddyList();
- /**
- * Removes buddy from the list
- */
- bool removeBuddy(const std::string buddy);
-
- /**
- * Returns the number of buddy on the list
- */
- int getNumberOfElements(void);
-
- /**
- * Returns the buddy of the number or null
- */
- std::string getElementAt(int number);
+ /**
+ * Adds buddy to the list
+ */
+ bool addBuddy(const std::string buddy);
- private:
- std::list<std::string> buddylist; /**< Buddy list */
- std::list<std::string>::iterator buddyit; /**< Iterator */
+ /**
+ * Removes buddy from the list
+ */
+ bool removeBuddy(const std::string buddy);
+
+ /**
+ * Returns the number of buddy on the list
+ */
+ int getNumberOfElements(void);
+
+ /**
+ * Returns the buddy of the number or null
+ */
+ std::string getElementAt(int number);
+
+ private:
+ std::list<std::string> buddylist; /**< Buddy list */
+ std::list<std::string>::iterator buddyit; /**< Iterator */
};
#endif /* _TMW_BUDDYLIST_H */
-