1 /*
2 Copyright (C) 2004 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 
Widget()23 Widget::Widget()
24 {
25 	strcpy(name, "");
26 	strcpy(groupName, "");
27 	strcpy(label, "");
28 	strcpy(options, "");
29 	x = y = type = min = max = 0;
30 	enabled = visible = true;
31 	changed = false;
32 
33 	value = NULL;
34 	textValue = NULL;
35 	next = previous = NULL;
36 	image = NULL;
37 }
38 
~Widget()39 Widget::~Widget()
40 {
41 	redraw();
42 }
43 
setProperties(const char * name,const char * groupName,const char * label,const char * options,int x,int y,int min,int max)44 void Widget::setProperties(const char *name, const char *groupName, const char *label, const char *options, int x, int y, int min, int max)
45 {
46 	if ((strlen(name) > 50) || (strlen(groupName) > 50) || (strlen(label) > 50) || (strlen(options) > 100))
47 	{
48 		debug(("WIDGET NAME OVERFLOW!\n"));
49 		exit(1);
50 	}
51 
52 	strcpy(this->name, name);
53 	strcpy(this->groupName, groupName);
54 	strcpy(this->label, label);
55 	strcpy(this->options, options);
56 	this->x = x;
57 	this->y = y;
58 	this->min = min;
59 	this->max = max;
60 }
61 
setValue(int * value)62 void Widget::setValue(int *value)
63 {
64 	this->value = value;
65 }
66 
redraw()67 void Widget::redraw()
68 {
69 	if (image != NULL)
70 		SDL_FreeSurface(image);
71 
72 	image = NULL;
73 }
74 
destroy()75 void Widget::destroy()
76 {
77 	redraw();
78 }
79