]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/CWidget.cpp
Added .gitignore to ignore certain files + fixed access rights on Makefile* as
[quix0rs-blobwars.git] / src / CWidget.cpp
1 /*
2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 */
21
22 #include "headers.h"
23
24 Widget::Widget()
25 {
26         name[0] = 0;
27         groupName[0] = 0;
28         label[0] = 0;
29         options[0] = 0;
30         x = y = type = min = max = 0;
31         enabled = visible = true;
32         changed = false;
33
34         value = NULL;
35         next = previous = NULL;
36         image = NULL;
37 }
38
39 void Widget::setProperties(const char *name, const char *groupName, const char *label, const char *options, int x, int y, int min, int max)
40 {
41         if ((strlen(name) > 50) || (strlen(groupName) > 50) || (strlen(label) > 80) || (strlen(options) > 100))
42         {
43                 debug(("WIDGET NAME OVERFLOW!\n"));
44                 exit(1);
45         }
46
47         strlcpy(this->name, name, sizeof this->name);
48         strlcpy(this->groupName, groupName, sizeof this->groupName);
49         strlcpy(this->label, label, sizeof this->label);
50         strlcpy(this->options, options, sizeof this->options);
51         this->x = x;
52         this->y = y;
53         this->min = min;
54         this->max = max;
55 }
56
57 void Widget::setValue(int *value)
58 {
59         this->value = value;
60 }
61
62 void Widget::redraw()
63 {
64         if (image != NULL)
65                 SDL_FreeSurface(image);
66
67         image = NULL;
68 }