summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp49
-rw-r--r--src/being.h4
-rw-r--r--src/configuration.cpp17
-rw-r--r--src/configuration.h9
-rw-r--r--src/gui/itemcontainer.h6
-rw-r--r--src/gui/setup_players.cpp48
-rw-r--r--src/gui/skill.cpp18
-rw-r--r--src/gui/skill.h2
-rw-r--r--src/gui/table.cpp102
-rw-r--r--src/gui/table.h62
-rw-r--r--src/gui/table_model.cpp44
-rw-r--r--src/gui/table_model.h38
12 files changed, 173 insertions, 226 deletions
diff --git a/src/being.cpp b/src/being.cpp
index a9f5c973..7641de35 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -21,8 +21,6 @@
#include "being.h"
-#include <cassert>
-
#include "animatedsprite.h"
#include "equipment.h"
#include "game.h"
@@ -47,6 +45,8 @@
#include "utils/xml.h"
+#include <cassert>
+
#define BEING_EFFECTS_FILE "effects.xml"
#define HAIR_FILE "hair.xml"
@@ -291,8 +291,7 @@ void Being::setDirection(Uint8 direction)
}
}
-SpriteDirection
-Being::getSpriteDirection() const
+SpriteDirection Being::getSpriteDirection() const
{
SpriteDirection dir;
@@ -441,8 +440,7 @@ Being::Type Being::getType() const
return UNKNOWN;
}
-void
-Being::setStatusEffectBlock(int offset, Uint16 newEffects)
+void Being::setStatusEffectBlock(int offset, Uint16 newEffects)
{
for (int i = 0; i < STATUS_EFFECTS; i++) {
int index = StatusEffect::blockEffectIndexToEffectIndex(offset + i);
@@ -452,8 +450,7 @@ Being::setStatusEffectBlock(int offset, Uint16 newEffects)
}
}
-void
-Being::handleStatusEffect(StatusEffect *effect, int effectId)
+void Being::handleStatusEffect(StatusEffect *effect, int effectId)
{
if (!effect)
return;
@@ -473,21 +470,18 @@ Being::handleStatusEffect(StatusEffect *effect, int effectId)
}
}
-void
-Being::updateStunMode(int oldMode, int newMode)
+void Being::updateStunMode(int oldMode, int newMode)
{
handleStatusEffect(StatusEffect::getStatusEffect(oldMode, false), -1);
handleStatusEffect(StatusEffect::getStatusEffect(newMode, true), -1);
}
-void
-Being::updateStatusEffect(int index, bool newStatus)
+void Being::updateStatusEffect(int index, bool newStatus)
{
handleStatusEffect(StatusEffect::getStatusEffect(index, newStatus), index);
}
-void
-Being::setStatusEffect(int index, bool active)
+void Being::setStatusEffect(int index, bool active)
{
const bool wasActive = mStatusEffects.find(index) != mStatusEffects.end();
@@ -500,8 +494,7 @@ Being::setStatusEffect(int index, bool active)
}
}
-int
-Being::getOffset(char pos, char neg) const
+int Being::getOffset(char pos, char neg) const
{
// Check whether we're walking in the requested direction
if (mAction != WALK || !(mDirection & (pos | neg))) {
@@ -558,8 +551,7 @@ static EffectDescription *default_effect = NULL;
static std::map<int, EffectDescription *> effects;
static bool effects_initialized = false;
-static EffectDescription *
-getEffectDescription(xmlNodePtr node, int *id)
+static EffectDescription *getEffectDescription(xmlNodePtr node, int *id)
{
EffectDescription *ed = new EffectDescription;
@@ -570,8 +562,7 @@ getEffectDescription(xmlNodePtr node, int *id)
return ed;
}
-static EffectDescription *
-getEffectDescription(int effectId)
+static EffectDescription *getEffectDescription(int effectId)
{
if (!effects_initialized)
{
@@ -617,8 +608,7 @@ getEffectDescription(int effectId)
return ed;
}
-void
-Being::internalTriggerEffect(int effectId, bool sfx, bool gfx)
+void Being::internalTriggerEffect(int effectId, bool sfx, bool gfx)
{
logger->log("Special effect #%d on %s", effectId,
getId() == player_node->getId() ? "self" : "other");
@@ -649,25 +639,21 @@ static int hairStylesNr;
static int hairColorsNr;
static std::vector<std::string> hairColors;
-static void
-initializeHair(void);
+static void initializeHair();
-int
-Being::getHairStylesNr(void)
+int Being::getHairStylesNr()
{
initializeHair();
return hairStylesNr;
}
-int
-Being::getHairColorsNr(void)
+int Being::getHairColorsNr()
{
initializeHair();
return hairColorsNr;
}
-std::string
-Being::getHairColor(int index)
+std::string Being::getHairColor(int index)
{
initializeHair();
if (index < 0 || index >= hairColorsNr)
@@ -678,8 +664,7 @@ Being::getHairColor(int index)
static bool hairInitialized = false;
-static void
-initializeHair(void)
+static void initializeHair()
{
if (hairInitialized)
return;
diff --git a/src/being.h b/src/being.h
index d7f78753..f48ebae2 100644
--- a/src/being.h
+++ b/src/being.h
@@ -374,9 +374,9 @@ class Being : public Sprite
const std::auto_ptr<Equipment> mEquipment;
- static int getHairColorsNr(void);
+ static int getHairColorsNr();
- static int getHairStylesNr(void);
+ static int getHairStylesNr();
static std::string getHairColor(int index);
diff --git a/src/configuration.cpp b/src/configuration.cpp
index e2deae31..49914467 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -60,7 +60,8 @@ void Configuration::setValue(const std::string &key, std::string value)
}
}
-std::string ConfigurationObject::getValue(const std::string &key, std::string deflt)
+std::string ConfigurationObject::getValue(const std::string &key,
+ std::string deflt)
{
OptionIterator iter = mOptions.find(key);
return ((iter != mOptions.end()) ? iter->second : deflt);
@@ -72,8 +73,7 @@ float ConfigurationObject::getValue(const std::string &key, float deflt)
return (iter != mOptions.end()) ? atof(iter->second.c_str()) : deflt;
}
-void
-ConfigurationObject::deleteList(const std::string &name)
+void ConfigurationObject::deleteList(const std::string &name)
{
for (ConfigurationList::const_iterator
it = mContainerOptions[name].begin(); it != mContainerOptions[name].end(); it++)
@@ -82,8 +82,7 @@ ConfigurationObject::deleteList(const std::string &name)
mContainerOptions[name].clear();
}
-void
-ConfigurationObject::clear(void)
+void ConfigurationObject::clear()
{
for (std::map<std::string, ConfigurationList>::const_iterator
it = mContainerOptions.begin(); it != mContainerOptions.end(); it++)
@@ -92,13 +91,12 @@ ConfigurationObject::clear(void)
}
-ConfigurationObject::~ConfigurationObject(void)
+ConfigurationObject::~ConfigurationObject()
{
clear();
}
-void
-ConfigurationObject::initFromXML(xmlNodePtr parent_node)
+void ConfigurationObject::initFromXML(xmlNodePtr parent_node)
{
clear();
@@ -163,8 +161,7 @@ void Configuration::init(const std::string &filename)
xmlFreeDoc(doc);
}
-void
-ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
+void ConfigurationObject::writeToXML(xmlTextWriterPtr writer)
{
for (OptionIterator i = mOptions.begin(); i != mOptions.end(); i++)
{
diff --git a/src/configuration.h b/src/configuration.h
index 3751d429..0c2363e5 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -71,7 +71,7 @@ class ConfigurationObject
friend class Configuration;
public:
- virtual ~ConfigurationObject(void);
+ virtual ~ConfigurationObject();
/**
* Sets an option using a string value.
@@ -108,7 +108,7 @@ class ConfigurationObject
/**
* Re-sets all data in the configuration
*/
- virtual void clear(void);
+ virtual void clear();
/**
* Serialises a container into a list of configuration options
@@ -158,7 +158,7 @@ class ConfigurationObject
{
ConfigurationList *list = &(mContainerOptions[name]);
CONT container = empty;
-
+
for (ConfigurationList::const_iterator it = list->begin(); it != list->end(); it++)
container = manager->readConfigItem(*it, container);
@@ -187,7 +187,7 @@ class ConfigurationObject
class Configuration : public ConfigurationObject
{
public:
- virtual ~Configuration(void) {}
+ virtual ~Configuration() {}
/**
* Reads config file and parse all options into memory.
@@ -214,6 +214,7 @@ class Configuration : public ConfigurationObject
virtual void setValue(const std::string &key, std::string value);
virtual void setValue(const std::string &key, float value);
+
private:
typedef std::list<ConfigListener*> Listeners;
typedef Listeners::iterator ListenerIterator;
diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h
index 34545df8..6ee76885 100644
--- a/src/gui/itemcontainer.h
+++ b/src/gui/itemcontainer.h
@@ -112,17 +112,17 @@ class ItemContainer : public gcn::Widget, public gcn::MouseListener,
/**
* Find the current item index by the most recently used item ID
*/
- void refindSelectedItem(void);
+ void refindSelectedItem();
/**
* Determine and set the height of the container.
*/
- void recalculateHeight(void);
+ void recalculateHeight();
/**
* Sends out selection events to the list of selection listeners.
*/
- void distributeValueChangedEvent(void);
+ void distributeValueChangedEvent();
Inventory *mInventory;
Image *mSelImg;
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 7dcbb5dc..c556a82d 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -21,10 +21,6 @@
#include "setup_players.h"
-#include <vector>
-#include <guichan/widgets/dropdown.hpp>
-#include <guichan/widgets/label.hpp>
-
#include "button.h"
#include "checkbox.h"
#include "ok_dialog.h"
@@ -34,6 +30,11 @@
#include "../log.h"
#include "../sound.h"
+#include <guichan/widgets/dropdown.hpp>
+#include <guichan/widgets/label.hpp>
+
+#include <vector>
+
#define COLUMNS_NR 2 // name plus listbox
#define NAME_COLUMN 0
#define RELATION_CHOICE_COLUMN 1
@@ -55,9 +56,9 @@ static const std::string RELATION_NAMES[PlayerRelation::RELATIONS_NR] = {
class PlayerRelationListModel : public gcn::ListModel
{
public:
- virtual ~PlayerRelationListModel(void) { }
+ virtual ~PlayerRelationListModel() { }
- virtual int getNumberOfElements(void)
+ virtual int getNumberOfElements()
{
return PlayerRelation::RELATIONS_NR;
}
@@ -73,30 +74,30 @@ public:
class PlayerTableModel : public TableModel
{
public:
- PlayerTableModel(void) :
+ PlayerTableModel() :
mPlayers(NULL)
{
playerRelationsUpdated();
}
- virtual ~PlayerTableModel(void)
+ virtual ~PlayerTableModel()
{
freeWidgets();
if (mPlayers)
delete mPlayers;
}
- virtual int getRows(void)
+ virtual int getRows()
{
return mPlayers->size();
}
- virtual int getColumns(void)
+ virtual int getColumns()
{
return COLUMNS_NR;
}
- virtual int getRowHeight(void)
+ virtual int getRowHeight()
{
return ROW_HEIGHT;
}
@@ -109,7 +110,7 @@ public:
return RELATION_CHOICE_COLUMN_WIDTH;
}
- virtual void playerRelationsUpdated(void)
+ virtual void playerRelationsUpdated()
{
signalBeforeUpdate();
@@ -146,7 +147,7 @@ public:
return mWidgets[WIDGET_AT(row, column)];
}
- virtual void freeWidgets(void)
+ virtual void freeWidgets()
{
if (mPlayers)
delete mPlayers;
@@ -175,9 +176,9 @@ protected:
class IgnoreChoicesListModel : public gcn::ListModel
{
public:
- virtual ~IgnoreChoicesListModel(void) { }
+ virtual ~IgnoreChoicesListModel() { }
- virtual int getNumberOfElements(void)
+ virtual int getNumberOfElements()
{
return player_relations.getPlayerIgnoreStrategies()->size();
}
@@ -260,14 +261,13 @@ Setup_Players::Setup_Players():
player_relations.addListener(this);
}
-Setup_Players::~Setup_Players(void)
+Setup_Players::~Setup_Players()
{
player_relations.removeListener(this);
}
-void
-Setup_Players::reset()
+void Setup_Players::reset()
{
// We now have to search through the list of ignore choices to find the current
// selection. We could use an index into the table of config options in
@@ -284,8 +284,7 @@ Setup_Players::reset()
mIgnoreActionChoicesBox->setSelected(selection);
}
-void
-Setup_Players::apply()
+void Setup_Players::apply()
{
player_relations.setPersistIgnores(mPersistIgnores->isSelected());
player_relations.store();
@@ -297,13 +296,11 @@ Setup_Players::apply()
| (mDefaultWhisper->isSelected()? PlayerRelation::WHISPER : 0));
}
-void
-Setup_Players::cancel()
+void Setup_Players::cancel()
{
}
-void
-Setup_Players::action(const gcn::ActionEvent &event)
+void Setup_Players::action(const gcn::ActionEvent &event)
{
if (event.getId() == ACTION_TABLE) {
// temporarily eliminate ourselves: we are fully aware of this change, so there is no
@@ -336,8 +333,7 @@ Setup_Players::action(const gcn::ActionEvent &event)
}
}
-void
-Setup_Players::updatedPlayer(const std::string &name)
+void Setup_Players::updatedPlayer(const std::string &name)
{
mPlayerTableModel->playerRelationsUpdated();
mDefaultTrading->setSelected(player_relations.getDefault() & PlayerRelation::TRADE);
diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp
index 1b7466ff..82108f84 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -43,7 +43,7 @@ struct SkillInfo {
std::vector<SkillInfo> skill_db;
-static void initSkillinfo(void);
+static void initSkillinfo();
class SkillGuiTableModel : public StaticTableModel
{
@@ -56,11 +56,9 @@ public:
update();
}
- virtual int
- getRows(void) { return mEntriesNr; }
+ virtual int getRows() { return mEntriesNr; }
- virtual int
- getColumnWidth(int index)
+ virtual int getColumnWidth(int index)
{
switch (index) {
case 0: return 160;
@@ -68,14 +66,12 @@ public:
}
}
- virtual int
- getRowHeight(void)
+ virtual int getRowHeight()
{
return 12;
}
- virtual void
- update(void)
+ virtual void update()
{
static const SkillInfo fakeSkillInfo = { "Mystery Skill", false };
@@ -108,7 +104,6 @@ public:
}
}
-
private:
SkillDialog *mDialog;
int mEntriesNr;
@@ -250,8 +245,7 @@ void SkillDialog::cleanList()
mSkillList.clear();
}
-static void
-initSkillinfo(void)
+static void initSkillinfo()
{
SkillInfo emptySkillInfo = { "", false };
diff --git a/src/gui/skill.h b/src/gui/skill.h
index bbd950cb..82ff12f2 100644
--- a/src/gui/skill.h
+++ b/src/gui/skill.h
@@ -68,7 +68,7 @@ class SkillDialog : public Window, public gcn::ActionListener
void setSkill(int id, int lv, int sp);
void cleanList();
- const std::vector<SKILL*>& getSkills(void) const { return mSkillList; }
+ const std::vector<SKILL*>& getSkills() const { return mSkillList; }
private:
GuiTable mTable;//gcn::ListBox *mSkillListBox;
diff --git a/src/gui/table.cpp b/src/gui/table.cpp
index bddfbfed..fa455062 100644
--- a/src/gui/table.cpp
+++ b/src/gui/table.cpp
@@ -19,11 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "table.h"
+
#include <guichan/graphics.hpp>
#include <guichan/actionlistener.hpp>
-#include "table.h"
-#include <cassert>
+#include <cassert>
class GuiTableActionListener : public gcn::ActionListener
@@ -31,7 +32,7 @@ class GuiTableActionListener : public gcn::ActionListener
public:
GuiTableActionListener(GuiTable *_table, gcn::Widget *_widget, int _row, int _column);
- virtual ~GuiTableActionListener(void);
+ virtual ~GuiTableActionListener();
virtual void action(const gcn::ActionEvent& actionEvent);
@@ -55,7 +56,7 @@ GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *wid
}
}
-GuiTableActionListener::~GuiTableActionListener(void)
+GuiTableActionListener::~GuiTableActionListener()
{
if (mWidget) {
mWidget->removeActionListener(this);
@@ -63,8 +64,7 @@ GuiTableActionListener::~GuiTableActionListener(void)
}
}
-void
-GuiTableActionListener::action(const gcn::ActionEvent& actionEvent)
+void GuiTableActionListener::action(const gcn::ActionEvent& actionEvent)
{
mTable->setSelected(mRow, mColumn);
mTable->distributeActionEvent();
@@ -83,19 +83,17 @@ GuiTable::GuiTable(TableModel *initial_model) :
addKeyListener(this);
}
-GuiTable::~GuiTable(void)
+GuiTable::~GuiTable()
{
delete mModel;
}
-TableModel *
-GuiTable::getModel(void) const
+TableModel *GuiTable::getModel() const
{
return mModel;
}
-void
-GuiTable::setModel(TableModel *new_model)
+void GuiTable::setModel(TableModel *new_model)
{
if (mModel) {
uninstallActionListeners();
@@ -112,8 +110,7 @@ GuiTable::setModel(TableModel *new_model)
}
-void
-GuiTable::recomputeDimensions(void)
+void GuiTable::recomputeDimensions()
{
int rows_nr = mModel->getRows();
int columns_nr = mModel->getColumns();
@@ -135,33 +132,28 @@ GuiTable::recomputeDimensions(void)
setHeight(height);
}
-void
-GuiTable::setSelected(int row, int column)
+void GuiTable::setSelected(int row, int column)
{
mSelectedColumn = column;
mSelectedRow = row;
}
-int
-GuiTable::getSelectedRow(void)
+int GuiTable::getSelectedRow()
{
return mSelectedRow;
}
-int
-GuiTable::getSelectedColumn(void)
+int GuiTable::getSelectedColumn()
{
return mSelectedColumn;
}
-void
-GuiTable::setLinewiseSelection(bool linewise)
+void GuiTable::setLinewiseSelection(bool linewise)
{
mLinewiseMode = linewise;
}
-int
-GuiTable::getRowHeight(void)
+int GuiTable::getRowHeight()
{
if (mModel)
return mModel->getRowHeight() + 1; // border
@@ -169,8 +161,7 @@ GuiTable::getRowHeight(void)
return 0;
}
-int
-GuiTable::getColumnWidth(int i)
+int GuiTable::getColumnWidth(int i)
{
if (mModel)
return mModel->getColumnWidth(i) + 1; // border
@@ -178,16 +169,14 @@ GuiTable::getColumnWidth(int i)
return 0;
}
-void
-GuiTable::uninstallActionListeners(void)
+void GuiTable::uninstallActionListeners()
{
for (std::vector<GuiTableActionListener *>::const_iterator it = action_listeners.begin(); it != action_listeners.end(); it++)
delete *it;
action_listeners.clear();
}
-void
-GuiTable::installActionListeners(void)
+void GuiTable::installActionListeners()
{
if (!mModel)
return;
@@ -206,8 +195,7 @@ GuiTable::installActionListeners(void)
}
// -- widget ops
-void
-GuiTable::draw(gcn::Graphics* graphics)
+void GuiTable::draw(gcn::Graphics* graphics)
{
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
@@ -226,7 +214,7 @@ GuiTable::draw(gcn::Graphics* graphics)
int max_rows_nr = mModel->getRows() - first_row; // clip if neccessary:
if (max_rows_nr < rows_nr)
rows_nr = max_rows_nr;
-
+
// Now determine the first and last column
// Take the easy way out; these are usually bounded and all visible.
int first_column = 0;
@@ -281,42 +269,36 @@ GuiTable::draw(gcn::Graphics* graphics)
}
}
-void
-GuiTable::logic(void)
+void GuiTable::logic()
{
}
-void
-GuiTable::moveToTop(gcn::Widget *widget)
+void GuiTable::moveToTop(gcn::Widget *widget)
{
gcn::Widget::moveToTop(widget);
this->mTopWidget = widget;
}
-void
-GuiTable::moveToBottom(gcn::Widget *widget)
+void GuiTable::moveToBottom(gcn::Widget *widget)
{
gcn::Widget::moveToBottom(widget);
if (widget == this->mTopWidget)
this->mTopWidget = NULL;
}
-gcn::Rectangle
-GuiTable::getChildrenArea(void)
+gcn::Rectangle GuiTable::getChildrenArea()
{
return gcn::Rectangle(0, 0, getWidth(), getHeight());
}
// -- KeyListener notifications
-void
-GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
+void GuiTable::keyPressed(gcn::KeyEvent& keyEvent)
{
}
// -- MouseListener notifications
-void
-GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
+void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
{
if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) {
int row = getRowForY(mouseEvent.getY());
@@ -331,24 +313,20 @@ GuiTable::mousePressed(gcn::MouseEvent& mouseEvent)
}
}
-void
-GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
+void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent)
{
}
-void
-GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
+void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent)
{
}
-
-void
-GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
+
+void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent)
{
}
// -- TableModelListener notifications
-void
-GuiTable::modelUpdated(bool completed)
+void GuiTable::modelUpdated(bool completed)
{
if (completed) {
recomputeDimensions();
@@ -359,8 +337,7 @@ GuiTable::modelUpdated(bool completed)
}
}
-gcn::Widget *
-GuiTable::getWidgetAt(int x, int y)
+gcn::Widget *GuiTable::getWidgetAt(int x, int y)
{
int row = getRowForY(y);
int column = getColumnForX(x);
@@ -380,8 +357,7 @@ GuiTable::getWidgetAt(int x, int y)
return NULL;
}
-int
-GuiTable::getRowForY(int y)
+int GuiTable::getRowForY(int y)
{
int row = y / getRowHeight();
@@ -392,8 +368,7 @@ GuiTable::getRowForY(int y)
return row;
}
-int
-GuiTable::getColumnForX(int x)
+int GuiTable::getColumnForX(int x)
{
int column;
int delta = 0;
@@ -412,16 +387,17 @@ GuiTable::getColumnForX(int x)
}
-void
-GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
+void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler)
{
gcn::Widget::_setFocusHandler(focusHandler);
- if (mModel)
- for (int r = 0; r < mModel->getRows(); ++r)
+ if (mModel) {
+ for (int r = 0; r < mModel->getRows(); ++r) {
for (int c = 0; c < mModel->getColumns(); ++c) {
gcn::Widget *w = mModel->getElementAt(r, c);
if (w)
w->_setFocusHandler(focusHandler);
}
+ }
+ }
}
diff --git a/src/gui/table.h b/src/gui/table.h
index cef82d5d..21ba050b 100644
--- a/src/gui/table.h
+++ b/src/gui/table.h
@@ -36,8 +36,9 @@
class GuiTableActionListener;
/**
- * A table, with rows and columns made out of sub-widgets. Largely inspired by (and can be thought of as a generalisation of)
- * the guichan listbox implementation.
+ * A table, with rows and columns made out of sub-widgets. Largely inspired by
+ * (and can be thought of as a generalisation of) the guichan listbox
+ * implementation.
*
* Normally you want this within a ScrollArea.
*
@@ -48,41 +49,43 @@ class GuiTable : public gcn::Widget,
public gcn::KeyListener,
public TableModelListener
{
- friend class GuiTableActionListener; // so that the action listener can call distributeActionEvent
+ // so that the action listener can call distributeActionEvent
+ friend class GuiTableActionListener;
+
public:
GuiTable(TableModel * initial_model = NULL);
- virtual ~GuiTable(void);
+ virtual ~GuiTable();
/**
* Retrieves the active table model
*/
- TableModel *getModel(void) const;
+ TableModel *getModel() const;
/**
* Sets the table model
*
- * Note that actions issued by widgets returned from the model will update the table
- * selection, but only AFTER any event handlers installed within the widget have been
- *triggered. To be notified after such an update, add an action listener to the table
- * instead.
+ * Note that actions issued by widgets returned from the model will update
+ * the table selection, but only AFTER any event handlers installed within
+ * the widget have been triggered. To be notified after such an update,
+ * add an action listener to the table instead.
*/
void setModel(TableModel *m);
void setSelected(int row, int column);
- int getSelectedRow(void);
+ int getSelectedRow();
- int getSelectedColumn(void);
+ int getSelectedColumn();
- gcn::Rectangle getChildrenArea(void);
+ gcn::Rectangle getChildrenArea();
/**
- * Toggle whether to use linewise selection mode, in which the table selects an entire
- * line at a time, rather than a single cell.
+ * Toggle whether to use linewise selection mode, in which the table
+ * selects an entire line at a time, rather than a single cell.
*
- * Note that column information is tracked even in linewise selection mode; this mode
- * therefore only affects visualisation.
+ * Note that column information is tracked even in linewise selection
+ * mode; this mode therefore only affects visualisation.
*
* Disabled by default.
*
@@ -93,7 +96,7 @@ public:
// Inherited from Widget
virtual void draw(gcn::Graphics* graphics);
- virtual void logic(void);
+ virtual void logic();
virtual gcn::Widget *getWidgetAt(int x, int y);
@@ -113,25 +116,25 @@ public:
virtual void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent);
virtual void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent);
-
+
virtual void mouseDragged(gcn::MouseEvent& mouseEvent);
// Constraints inherited from TableModelListener
virtual void modelUpdated(bool);
protected:
+ /** Frees all action listeners on inner widgets. */
+ virtual void uninstallActionListeners();
+ /** Installs all action listeners on inner widgets. */
+ virtual void installActionListeners();
- virtual void uninstallActionListeners(void); // frees all action listeners on inner widgets
- virtual void installActionListeners(void); // installs all action listeners on inner widgets
-
- virtual int getRowHeight(void);
+ virtual int getRowHeight();
virtual int getColumnWidth(int i);
-
-private:
+private:
int getRowForY(int y); // -1 on error
int getColumnForX(int x); // -1 on error
- void recomputeDimensions(void);
+ void recomputeDimensions();
bool mLinewiseMode;
TableModel *mModel;
@@ -139,11 +142,14 @@ private:
int mSelectedRow;
int mSelectedColumn;
- int mPopFramesNr; // Number of frames to skip upwards when drawing the selected widget
+ /** Number of frames to skip upwards when drawing the selected widget. */
+ int mPopFramesNr;
- gcn::Widget *mTopWidget; // If someone moves a fresh widget to the top, we must display it
+ /** If someone moves a fresh widget to the top, we must display it. */
+ gcn::Widget *mTopWidget;
- std::vector<GuiTableActionListener *> action_listeners; // Vector for compactness; used as a list in practice.
+ /** Vector for compactness; used as a list in practice. */
+ std::vector<GuiTableActionListener *> action_listeners;
};
diff --git a/src/gui/table_model.cpp b/src/gui/table_model.cpp
index 57da29d9..2146879a 100644
--- a/src/gui/table_model.cpp
+++ b/src/gui/table_model.cpp
@@ -19,31 +19,28 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "table_model.h"
+
#include <guichan/widget.hpp>
#include <cstdlib>
-#include "table_model.h"
-void
-TableModel::installListener(TableModelListener *listener)
+void TableModel::installListener(TableModelListener *listener)
{
listeners.insert(listener);
}
-void
-TableModel::removeListener(TableModelListener *listener)
+void TableModel::removeListener(TableModelListener *listener)
{
listeners.erase(listener);
}
-void
-TableModel::signalBeforeUpdate(void)
+void TableModel::signalBeforeUpdate()
{
for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++)
(*it)->modelUpdated(false);
}
-void
-TableModel::signalAfterUpdate(void)
+void TableModel::signalAfterUpdate()
{
for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++)
(*it)->modelUpdated(true);
@@ -63,23 +60,21 @@ StaticTableModel::StaticTableModel(int row, int column) :
mWidths.resize(column, 1);
}
-StaticTableModel::~StaticTableModel(void)
+StaticTableModel::~StaticTableModel()
{
for (std::vector<gcn::Widget *>::const_iterator it = mTableModel.begin(); it != mTableModel.end(); it++)
if (*it)
delete *it;
}
-void
-StaticTableModel::resize(void)
+void StaticTableModel::resize()
{
mRows = getRows();
mColumns = getColumns();
mTableModel.resize(mRows * mColumns, NULL);
}
-void
-StaticTableModel::set(int row, int column, gcn::Widget *widget)
+void StaticTableModel::set(int row, int column, gcn::Widget *widget)
{
if (row >= mRows || row < 0
|| column >= mColumns || column < 0)
@@ -104,14 +99,12 @@ StaticTableModel::set(int row, int column, gcn::Widget *widget)
signalAfterUpdate();
}
-gcn::Widget *
-StaticTableModel::getElementAt(int row, int column)
+gcn::Widget *StaticTableModel::getElementAt(int row, int column)
{
return mTableModel[WIDGET_AT(row, column)];
}
-void
-StaticTableModel::fixColumnWidth(int column, int width)
+void StaticTableModel::fixColumnWidth(int column, int width)
{
if (width < 0
|| column < 0 || column >= mColumns)
@@ -120,8 +113,7 @@ StaticTableModel::fixColumnWidth(int column, int width)
mWidths[column] = -width; // Negate to tag as fixed
}
-void
-StaticTableModel::fixRowHeight(int height)
+void StaticTableModel::fixRowHeight(int height)
{
if (height < 0)
return;
@@ -129,14 +121,12 @@ StaticTableModel::fixRowHeight(int height)
mHeight = -height;
}
-int
-StaticTableModel::getRowHeight(void)
+int StaticTableModel::getRowHeight()
{
return abs(mHeight);
}
-int
-StaticTableModel::getColumnWidth(int column)
+int StaticTableModel::getColumnWidth(int column)
{
if (column < 0 || column >= mColumns)
return 0;
@@ -144,14 +134,12 @@ StaticTableModel::getColumnWidth(int column)
return abs(mWidths[column]);
}
-int
-StaticTableModel::getRows(void)
+int StaticTableModel::getRows()
{
return mRows;
}
-int
-StaticTableModel::getColumns(void)
+int StaticTableModel::getColumns()
{
return mColumns;
}
diff --git a/src/gui/table_model.h b/src/gui/table_model.h
index 4be4e60e..67f30f2e 100644
--- a/src/gui/table_model.h
+++ b/src/gui/table_model.h
@@ -22,17 +22,20 @@
#ifndef TMW_TABLE_MODEL_H_
#define TMW_TABLE_MODEL_H_
+#include "../guichanfwd.h"
+
#include <guichan/gui.hpp>
+
#include <set>
#include <vector>
-#include "../guichanfwd.h"
class TableModelListener
{
public:
/**
- * Must be invoked by the TableModel whenever a global change is about to occur or
- * has occurred (e.g., when a row or column is being removed or added).
+ * Must be invoked by the TableModel whenever a global change is about to
+ * occur or has occurred (e.g., when a row or column is being removed or
+ * added).
*
* This method is triggered twice, once before and once after the update.
*
@@ -47,22 +50,22 @@ public:
class TableModel
{
public:
- virtual ~TableModel(void) { }
+ virtual ~TableModel() { }
/**
* Determines the number of rows (lines) in the table
*/
- virtual int getRows(void) = 0;
+ virtual int getRows() = 0;
/**
* Determines the number of columns in each row
*/
- virtual int getColumns(void) = 0;
+ virtual int getColumns() = 0;
/**
* Determines the height for each row
*/
- virtual int getRowHeight(void) = 0;
+ virtual int getRowHeight() = 0;
/**
* Determines the width of each individual column
@@ -82,12 +85,12 @@ protected:
/**
* Tells all listeners that the table is about to see an update
*/
- virtual void signalBeforeUpdate(void);
+ virtual void signalBeforeUpdate();
/**
* Tells all listeners that the table has seen an update
*/
- virtual void signalAfterUpdate(void);
+ virtual void signalAfterUpdate();
private:
std::set<TableModelListener *> listeners;
@@ -98,16 +101,18 @@ class StaticTableModel : public TableModel
{
public:
StaticTableModel(int width, int height);
- virtual ~StaticTableModel(void);
+ virtual ~StaticTableModel();
/**
* Inserts a widget into the table model.
- * The model is resized to accomodate the widget's width and height, unless column width / row height have been fixed.
+ * The model is resized to accomodate the widget's width and height,
+ * unless column width / row height have been fixed.
*/
virtual void set(int row, int column, gcn::Widget *widget);
/**
- * Fixes the column width for a given column; this overrides dynamic width inference.
+ * Fixes the column width for a given column; this overrides dynamic width
+ * inference.
*
* Semantics are undefined for width 0.
*/
@@ -123,15 +128,14 @@ public:
/**
* Resizes the table model
*/
- virtual void resize(void);
+ virtual void resize();
- virtual int getRows(void);
- virtual int getColumns(void);
- virtual int getRowHeight(void);
+ virtual int getRows();
+ virtual int getColumns();
+ virtual int getRowHeight();
virtual int getColumnWidth(int index);
virtual gcn::Widget *getElementAt(int row, int column);
-
protected:
int mRows, mColumns;
int mHeight;