~ubuntu-branches/ubuntu/oneiric/blobandconquer/oneiric

« back to all changes in this revision

Viewing changes to src/cplusplus/CBaseWidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Guus Sliepen
  • Date: 2008-06-15 12:04:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080615120429-5ss7cbb4z9mpywj5
Tags: 0.95-1
New upstream release. Closes: #486310

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2006 Parallel Realities
 
3
 
 
4
This program is free software; you can redistribute it and/or
 
5
modify it under the terms of the GNU General Public License
 
6
as published by the Free Software Foundation; either version 2
 
7
of the License, or (at your option) any later version.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
12
 
 
13
See the GNU General Public License for more details.
 
14
 
 
15
You should have received a copy of the GNU General Public License
 
16
along with this program; if not, write to the Free Software
 
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
18
 
 
19
*/
 
20
 
 
21
#include "../headers.h"
 
22
 
 
23
BaseWidget::BaseWidget()
 
24
{
 
25
        x = y = width = height = 0;
 
26
        
 
27
        widgetType = -1;
 
28
 
 
29
        visible = false;
 
30
        enabled = true;
 
31
 
 
32
        clicked = false;
 
33
 
 
34
        normalImage = NULL;
 
35
        clickedImage = NULL;
 
36
        disabledImage = NULL;
 
37
}
 
38
 
 
39
BaseWidget::~BaseWidget()
 
40
{
 
41
}
 
42
 
 
43
int BaseWidget::getWidgetType()
 
44
{
 
45
        return widgetType;
 
46
}
 
47
 
 
48
char *BaseWidget::getName()
 
49
{
 
50
        return name.getText();
 
51
}
 
52
 
 
53
char *BaseWidget::getGroupName()
 
54
{
 
55
        return groupName.getText();
 
56
}
 
57
 
 
58
bool BaseWidget::isEnabled()
 
59
{
 
60
        return enabled;
 
61
}
 
62
 
 
63
bool BaseWidget::isVisible()
 
64
{
 
65
        return visible;
 
66
}
 
67
 
 
68
void BaseWidget::setVisible(bool visible)
 
69
{
 
70
        this->visible = visible;
 
71
}
 
72
 
 
73
void BaseWidget::setBaseValues(Properties *properties)
 
74
{
 
75
        name = properties->getString("name", "NULL");
 
76
        groupName = properties->getString("groupName", "NULL");
 
77
 
 
78
        enabled = properties->getInt("enabled", 0);
 
79
        visible = properties->getInt("visible", 0);
 
80
        gridX = properties->getInt("x", 0);
 
81
        gridY = properties->getInt("y", 0);
 
82
 
 
83
        horizontalAlignment = properties->getInt("horizontalAlignment", 0);
 
84
        verticleAlignment = properties->getInt("verticleAlignment", 0);
 
85
 
 
86
        fontSize = properties->getInt("fontSize", 0);
 
87
        
 
88
        grid = UIManager::getInstance()->getGrid(properties->getString("grid", "unknown"));
 
89
        
 
90
        updatePosition();
 
91
}
 
92
 
 
93
void BaseWidget::updatePosition()
 
94
{
 
95
        x = grid->getCellX(gridX);
 
96
        y = grid->getCellY(gridY);
 
97
        
 
98
        if (widgetType != LISTVIEW)
 
99
        {
 
100
                y += (grid->getCellHeight() - height) / 2;
 
101
        }
 
102
}
 
103
 
 
104
// All abstract methods follow
 
105
 
 
106
void BaseWidget::use(int x, int y){}
 
107
void BaseWidget::setEnabled(bool enabled){}
 
108
void BaseWidget::mousePressed(SDL_MouseButtonEvent mouse){}
 
109
void BaseWidget::mouseReleased(SDL_MouseButtonEvent mouse){}
 
110
void BaseWidget::mouseMoved(int x, int y){}
 
111
void BaseWidget::keyPressed(int key, bool shiftHeld){}
 
112
void BaseWidget::joystickButtonPressed(int key){}