]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/CWidget.cpp
Cleanup .desktop file
[quix0rs-blobwars.git] / src / CWidget.cpp
1 /*
2 Copyright (C) 2004-2010 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 Widget::Widget()
24 {
25         name[0] = 0;
26         groupName[0] = 0;
27         label[0] = 0;
28         options[0] = 0;
29         x = y = type = min = max = 0;
30         enabled = visible = true;
31         changed = false;
32
33         value = NULL;
34         next = previous = NULL;
35         image = NULL;
36 }
37
38 void Widget::setProperties(const char *name, const char *groupName, const char *label, const char *options, int x, int y, int min, int max)
39 {
40         if ((strlen(name) > 50) || (strlen(groupName) > 50) || (strlen(label) > 80) || (strlen(options) > 100))
41         {
42                 debug(("WIDGET NAME OVERFLOW!\n"));
43                 exit(1);
44         }
45
46         strlcpy(this->name, name, sizeof this->name);
47         strlcpy(this->groupName, groupName, sizeof this->groupName);
48         strlcpy(this->label, label, sizeof this->label);
49         strlcpy(this->options, options, sizeof this->options);
50         this->x = x;
51         this->y = y;
52         this->min = min;
53         this->max = max;
54 }
55
56 void Widget::setValue(int *value)
57 {
58         this->value = value;
59 }
60
61 void Widget::redraw()
62 {
63         if (image != NULL)
64                 SDL_FreeSurface(image);
65
66         image = NULL;
67 }