1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | 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 Foundation, |
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | |
---|
21 | ### File Specific: |
---|
22 | main-programmer: Benjamin Grauer |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | |
---|
27 | #include "gui_gtk.h" |
---|
28 | |
---|
29 | #include <stdarg.h> |
---|
30 | #include <string.h> |
---|
31 | #include <stdlib.h> |
---|
32 | |
---|
33 | using namespace std; |
---|
34 | |
---|
35 | #include "gui_flags.h" |
---|
36 | extern OrxonoxGuiFlags* flags; |
---|
37 | |
---|
38 | char* executable; |
---|
39 | |
---|
40 | /** |
---|
41 | \brief Initializes the Guis GTK-stuff. |
---|
42 | \param argc the argument count. |
---|
43 | \param argv The Argument strings. |
---|
44 | */ |
---|
45 | bool initGUI(int argc, char *argv[]) |
---|
46 | { |
---|
47 | executable = new char[strlen(argv[0])+1]; |
---|
48 | strcpy(executable, argv[0]); |
---|
49 | |
---|
50 | #ifdef HAVE_GTK2 |
---|
51 | #ifdef HAVE_GTHREAD |
---|
52 | PRINTF(4)("Initializing the ThreadSystem of the GUI\n"); |
---|
53 | g_thread_init(NULL); |
---|
54 | gdk_threads_init(); |
---|
55 | #endif /* HAVE_GTHREAD */ |
---|
56 | gtk_init(&argc, &argv); |
---|
57 | #include "rc" |
---|
58 | gtk_rc_parse_string( rc_string ); |
---|
59 | #endif /* HAVE_GTK2 */ |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | \brief enters the GUI's main-loop |
---|
64 | */ |
---|
65 | bool mainloopGUI(void) |
---|
66 | { |
---|
67 | #ifdef HAVE_GTK2 |
---|
68 | gdk_threads_enter(); |
---|
69 | gtk_main(); |
---|
70 | gdk_threads_leave(); |
---|
71 | delete Window::mainWindow; |
---|
72 | #else /* HAVE_GTK2 */ |
---|
73 | char boolAns = 'y'; |
---|
74 | char ans[1000]; |
---|
75 | PRINT(0)("================================\n"); |
---|
76 | PRINT(0)("= ORXONOX CONFIGURATION WIZARD =\n"); |
---|
77 | PRINT(0)("================================ - v." PACKAGE_VERSION "\n"); |
---|
78 | |
---|
79 | while(true) |
---|
80 | { |
---|
81 | PRINT(0)("\n Listing all the Orxonox Options: \n"); |
---|
82 | PRINT(0)(" #############################\n"); |
---|
83 | Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1); |
---|
84 | |
---|
85 | PRINT(0)("\nDo you want change any of the above values now? [Yn] "); |
---|
86 | scanf("%s", ans); |
---|
87 | if (ans[0] =='n' || ans[0]=='N') |
---|
88 | break; |
---|
89 | |
---|
90 | PRINT(0)("\n Listing all groups\n"); |
---|
91 | PRINT(0)(" #################\n"); |
---|
92 | int groupCount = 0; |
---|
93 | Window::mainWindow->walkThrough(Widget::listGroups, &groupCount, 1); |
---|
94 | |
---|
95 | PRINT(0)("\nIn which Group? [1-%d] ", groupCount); |
---|
96 | Packer* group; |
---|
97 | while(true) |
---|
98 | { |
---|
99 | scanf("%s", ans); |
---|
100 | int ansIp = atoi(ans); |
---|
101 | if (ansIp <= groupCount) |
---|
102 | { |
---|
103 | group = static_cast<Packer*>(Window::mainWindow->findGroupByNumber(&ansIp, 1)); |
---|
104 | break; |
---|
105 | } |
---|
106 | else |
---|
107 | PRINT(0)("\nChoose a smaller Number please: [1-%d] ", groupCount); |
---|
108 | } |
---|
109 | PRINT(0)("\n\nGroup: [%s]\n\n", group->groupName); |
---|
110 | int optionCount = 0; |
---|
111 | group->walkThrough(Widget::listOptions, &optionCount, 0); |
---|
112 | PRINT(0)("\nWhich Option? [1-%d] ", optionCount); |
---|
113 | Option* option; |
---|
114 | while(true) |
---|
115 | { |
---|
116 | scanf("%s", ans); |
---|
117 | int ansIp = atoi(ans); |
---|
118 | if (ansIp <= groupCount) |
---|
119 | { |
---|
120 | option = static_cast<Option*>(group->findOptionByNumber(&ansIp, 0)); |
---|
121 | break; |
---|
122 | } |
---|
123 | else |
---|
124 | PRINT(0)("\nChoose a smaler Number please: [1-%d] ", optionCount); |
---|
125 | } |
---|
126 | PRINT(0)("\n\n:: %s ::\n", option->title); |
---|
127 | option->changeOption(); |
---|
128 | |
---|
129 | // here follows the rest.... this will be nasty. |
---|
130 | //! \todo move this into the gui-gtk-file |
---|
131 | //! \todo finish it. |
---|
132 | //! \todo memory leek at save(); and save is a BAD word, use saveString instead, or something like it. |
---|
133 | } |
---|
134 | #endif /* HAVE_GTK2 */ |
---|
135 | |
---|
136 | } |
---|
137 | |
---|
138 | |
---|
139 | ////////////////////////////// |
---|
140 | /// DEFINING WIDGET-CLASES /// |
---|
141 | ////////////////////////////// |
---|
142 | |
---|
143 | //////////// |
---|
144 | /* WIDGET */ |
---|
145 | //////////// |
---|
146 | /** |
---|
147 | \brief constructs a Widget |
---|
148 | */ |
---|
149 | Widget::Widget(void) |
---|
150 | { |
---|
151 | next = NULL; |
---|
152 | this->title = NULL; |
---|
153 | } |
---|
154 | |
---|
155 | /** |
---|
156 | \brief deletes any given Widget |
---|
157 | This is still pretty crappy. |
---|
158 | */ |
---|
159 | Widget::~Widget(void) |
---|
160 | { |
---|
161 | if (this->title) |
---|
162 | { |
---|
163 | delete []this->title; |
---|
164 | } |
---|
165 | |
---|
166 | PRINTF(5)("deleting the Widget part.\n"); |
---|
167 | |
---|
168 | // deleting next item if existent |
---|
169 | if (this->next) |
---|
170 | delete this->next; |
---|
171 | this->next = NULL; |
---|
172 | |
---|
173 | //! \todo not hiding widget, deleting. |
---|
174 | // this->hide(); |
---|
175 | // gtk_destroy_widget(this->widget); |
---|
176 | } |
---|
177 | |
---|
178 | /** |
---|
179 | \brief sets a new Title to a Widget |
---|
180 | \param title The new Title to set to the Widget |
---|
181 | */ |
---|
182 | void Widget::setTitle(const char* title) |
---|
183 | { |
---|
184 | if (this->title) |
---|
185 | delete []this->title; |
---|
186 | this->title = new char[strlen(title)+1]; |
---|
187 | strcpy(this->title, title); |
---|
188 | } |
---|
189 | |
---|
190 | /** |
---|
191 | \brief makes the widget visible. |
---|
192 | */ |
---|
193 | void Widget::show(void) |
---|
194 | { |
---|
195 | #ifdef HAVE_GTK2 |
---|
196 | gtk_widget_show(this->widget); |
---|
197 | #endif /* HAVE_GTK2 */ |
---|
198 | } |
---|
199 | |
---|
200 | /** |
---|
201 | \brief hides the widget. |
---|
202 | */ |
---|
203 | void Widget::hide(void) |
---|
204 | { |
---|
205 | #ifdef HAVE_GTK2 |
---|
206 | gtk_widget_hide(this->widget); |
---|
207 | #endif /* HAVE_GTK2 */ |
---|
208 | } |
---|
209 | |
---|
210 | /** |
---|
211 | \brief Sets the resolution of a specific widget to the given size. |
---|
212 | \param width the width of the widget to set. |
---|
213 | \param height the height of the widget to set. |
---|
214 | */ |
---|
215 | void Widget::setSize(int width, int height) |
---|
216 | { |
---|
217 | #ifdef HAVE_GTK2 |
---|
218 | gtk_widget_set_usize(this->widget, width, height); |
---|
219 | #endif /* HAVE_GTK2 */ |
---|
220 | } |
---|
221 | |
---|
222 | /** |
---|
223 | \brief searches through widgets for a Name. |
---|
224 | */ |
---|
225 | Widget* Widget::findWidgetByName(char* name, unsigned int depth) |
---|
226 | { |
---|
227 | |
---|
228 | if (this->title && !strcmp(this->title, name)) |
---|
229 | return this; |
---|
230 | |
---|
231 | if (this->isOption < 0 && static_cast<Packer*>(this)->down) |
---|
232 | { |
---|
233 | Widget* tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1); |
---|
234 | if (tmp) |
---|
235 | return tmp; |
---|
236 | } |
---|
237 | |
---|
238 | if (depth>0 && this->next) |
---|
239 | return this->next->findWidgetByName(name, depth); |
---|
240 | |
---|
241 | return NULL; |
---|
242 | } |
---|
243 | |
---|
244 | /** |
---|
245 | \brief Moves through all the Widgets downwards from this and executes the function on them. |
---|
246 | \param function must be of type void and takes a Widget* as an Input. |
---|
247 | \param depth the current depth. if > 0 then the next Widget will also be walked through. |
---|
248 | */ |
---|
249 | void Widget::walkThrough(void(*function)(Widget*), unsigned int depth) |
---|
250 | { |
---|
251 | function(this); |
---|
252 | if (this->isOption < 0) |
---|
253 | { |
---|
254 | static_cast<Packer*>(this)->down->walkThrough(function, depth+1); |
---|
255 | } |
---|
256 | |
---|
257 | if (this->next && depth != 0) |
---|
258 | this->next->walkThrough(function, depth); |
---|
259 | } |
---|
260 | |
---|
261 | /** |
---|
262 | \brief Moves through all the Widgets downwards from this and executes the function on them. |
---|
263 | \param function must be of type void and takes a Widget* as an Input. |
---|
264 | \param data Additional Data you want to pass to the function. |
---|
265 | \param depth the current depth. if > 0 then the next Widget will also be walked through. |
---|
266 | */ |
---|
267 | void Widget::walkThrough(void(*function)(Widget*, void*), void* data, unsigned int depth) |
---|
268 | { |
---|
269 | function(this, data); |
---|
270 | if (this->isOption < 0) |
---|
271 | { |
---|
272 | static_cast<Packer*>(this)->down->walkThrough(function, data, depth+1); |
---|
273 | } |
---|
274 | if (this->next && depth != 0) |
---|
275 | this->next->walkThrough(function, data, depth); |
---|
276 | } |
---|
277 | |
---|
278 | /** |
---|
279 | \brief This is for listing the options of "widget" |
---|
280 | \param widget specifies the widget that should be listed |
---|
281 | */ |
---|
282 | void Widget::listOptionsAndGroups(Widget* widget) |
---|
283 | { |
---|
284 | if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) |
---|
285 | PRINT(0)("[%s]\n", static_cast<Packer*>(widget)->groupName); |
---|
286 | if (widget->isOption >= 1) |
---|
287 | { |
---|
288 | Widget::listOptions(widget); |
---|
289 | } |
---|
290 | } |
---|
291 | |
---|
292 | /** |
---|
293 | \brief This is for listing the options of "widget" |
---|
294 | \param widget specifies the widget that should be listed |
---|
295 | */ |
---|
296 | void Widget::listOptions(Widget* widget) |
---|
297 | { |
---|
298 | if(widget->isOption >= 1) |
---|
299 | PRINT(0)(" %s is %s\n", static_cast<Option*>(widget)->title, static_cast<Option*>(widget)->save()); |
---|
300 | } |
---|
301 | |
---|
302 | /** |
---|
303 | \brief This is for listing the options of "widget" |
---|
304 | \param widget specifies the widget that should be listed |
---|
305 | \param data A Counter, that always knows how many Options have been found yet. |
---|
306 | */ |
---|
307 | void Widget::listOptions(Widget* widget, void* data) |
---|
308 | { |
---|
309 | |
---|
310 | if (widget->isOption >= 1) |
---|
311 | { |
---|
312 | int* count =(int*)data; |
---|
313 | *count = *count +1; |
---|
314 | PRINT(0)(" %d:%s is %s\n", *count, |
---|
315 | static_cast<Option*>(widget)->title, |
---|
316 | static_cast<Option*>(widget)->save()); |
---|
317 | } |
---|
318 | } |
---|
319 | |
---|
320 | /** |
---|
321 | \brief Finds an Option by a given number(the n'th option found away from this Widget) |
---|
322 | \param number The Count of options to wait(by reference) |
---|
323 | \param depth The depth of the sarch. if 0 it will not search next pointer |
---|
324 | |
---|
325 | \todo should return Option* would be much sexier. |
---|
326 | */ |
---|
327 | Widget* Widget::findOptionByNumber(int* number, unsigned int depth) |
---|
328 | { |
---|
329 | if (isOption > 0) |
---|
330 | { |
---|
331 | --*number; |
---|
332 | if (*number <= 0) |
---|
333 | { |
---|
334 | return this; |
---|
335 | } |
---|
336 | } |
---|
337 | if (this->isOption < 0 && static_cast<Packer*>(this)->down) |
---|
338 | { |
---|
339 | Widget* tmp = static_cast<Packer*>(this)->down->findOptionByNumber(number, depth+1); |
---|
340 | if (tmp) |
---|
341 | return tmp; |
---|
342 | } |
---|
343 | if (depth>0 && this->next) |
---|
344 | return this->next->findOptionByNumber(number, depth); |
---|
345 | |
---|
346 | return NULL; |
---|
347 | } |
---|
348 | |
---|
349 | /** |
---|
350 | \brief This is for listing the groups of "widget" |
---|
351 | \param widget specifies the widget that should be listed |
---|
352 | */ |
---|
353 | void Widget::listGroups(Widget* widget) |
---|
354 | { |
---|
355 | if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) |
---|
356 | PRINT(0)("[%s]\n", static_cast<Packer*>(widget)->groupName); |
---|
357 | } |
---|
358 | |
---|
359 | /** |
---|
360 | \brief This is for listing the Groups of "widget". It also displays the n'th number found. |
---|
361 | \param widget specifies the widget that should be listed |
---|
362 | \param data the Counter, that will show the number(this function will raise it by one if a Group is fount. |
---|
363 | */ |
---|
364 | void Widget::listGroups(Widget* widget, void* data) |
---|
365 | { |
---|
366 | int* count = (int*)data; |
---|
367 | if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) |
---|
368 | PRINT(0)("%d: [%s]\n", ++*count, static_cast<Packer*>(widget)->groupName); |
---|
369 | } |
---|
370 | |
---|
371 | /** |
---|
372 | \brief Finds a Group by a given number(the n'th Group found away from this Widget) |
---|
373 | \param number The Count of options to wait(by reference) |
---|
374 | \param depth The depth of the sarch. if 0 it will not search next pointer |
---|
375 | */ |
---|
376 | Widget* Widget::findGroupByNumber(int* number, unsigned int depth) |
---|
377 | { |
---|
378 | if (isOption < 0 && static_cast<Packer*>(this)->groupName) |
---|
379 | { |
---|
380 | --*number; |
---|
381 | if (*number <= 0) |
---|
382 | { |
---|
383 | return this; |
---|
384 | } |
---|
385 | } |
---|
386 | if (this->isOption < 0 && static_cast<Packer*>(this)->down) |
---|
387 | { |
---|
388 | Widget* tmp = static_cast<Packer*>(this)->down->findGroupByNumber(number, depth+1); |
---|
389 | if (tmp) |
---|
390 | return tmp; |
---|
391 | } |
---|
392 | if (depth>0 && this->next) |
---|
393 | return this->next->findGroupByNumber(number, depth); |
---|
394 | |
---|
395 | return NULL; |
---|
396 | } |
---|
397 | |
---|
398 | /** |
---|
399 | \brief This is for setting the option of "widget" |
---|
400 | \param widget specifies the widget that should be set. |
---|
401 | */ |
---|
402 | void Widget::setOptions(Widget* widget) |
---|
403 | { |
---|
404 | if (widget->isOption >= 1) |
---|
405 | static_cast<Option*>(widget)->redraw(); |
---|
406 | } |
---|
407 | |
---|
408 | /** |
---|
409 | \brief Walks through all the Flags given at startuptime. |
---|
410 | */ |
---|
411 | void Widget::flagCheck(Widget* widget, void* flagName) |
---|
412 | { |
---|
413 | if (widget->isOption>=1) |
---|
414 | { |
---|
415 | Option* option =(Option*)widget; |
---|
416 | char* name =(char*)flagName; |
---|
417 | char* value = NULL; |
---|
418 | bool found = false; |
---|
419 | // check if long flag matches |
---|
420 | if ((option->flagName && strlen(name) > 2 && |
---|
421 | !strncmp(name+2, option->flagName, strlen(option->flagName)) && |
---|
422 | (name[strlen(option->flagName)+2] == '\0' || name[strlen(option->flagName)+2] == '=') )) |
---|
423 | { |
---|
424 | found = true; |
---|
425 | if (name[strlen(option->flagName)+2] == '=') |
---|
426 | { |
---|
427 | value = name+strlen(option->flagName)+3; |
---|
428 | } |
---|
429 | } |
---|
430 | // check if short flag matches |
---|
431 | else if (option->flagNameShort && strlen(name)>1 && |
---|
432 | !strncmp(name+1, option->flagNameShort, strlen(option->flagNameShort)) && |
---|
433 | (name[strlen(option->flagNameShort)+1] == '\0' || name[strlen(option->flagNameShort)+1] == '=')) |
---|
434 | { |
---|
435 | found = true; |
---|
436 | if (name[strlen(option->flagNameShort)+1] == '=') |
---|
437 | { |
---|
438 | value = name+strlen(option->flagNameShort)+2; |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | if (found) |
---|
443 | { |
---|
444 | PRINT(4)("found matching Flag %s\n", name); |
---|
445 | if (value) |
---|
446 | { |
---|
447 | PRINT(4)("with Value %s\n", value); |
---|
448 | option->value = atoi(value); |
---|
449 | } |
---|
450 | else |
---|
451 | { |
---|
452 | option->value = !option->defaultValue; |
---|
453 | } |
---|
454 | option->redraw(); |
---|
455 | } |
---|
456 | |
---|
457 | } |
---|
458 | } |
---|
459 | |
---|
460 | #ifdef HAVE_GTK2 |
---|
461 | /** |
---|
462 | \brief Connect any signal to any given Sub-widget |
---|
463 | */ |
---|
464 | gulong Widget::connectSignal(char* event, gint(*signal)(GtkWidget*, GdkEvent*, void *)) |
---|
465 | { |
---|
466 | return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), NULL); |
---|
467 | } |
---|
468 | |
---|
469 | /** |
---|
470 | \brief Connect a signal with additionally passing the whole Object |
---|
471 | */ |
---|
472 | gulong Widget::connectSignal(char* event, gint(*signal)( GtkWidget*, Widget *)) |
---|
473 | { |
---|
474 | return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), this); |
---|
475 | } |
---|
476 | |
---|
477 | /** |
---|
478 | \brief Connect a signal with additionally passing a whole external Object |
---|
479 | */ |
---|
480 | gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEvent*, void *)) |
---|
481 | { |
---|
482 | return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); |
---|
483 | } |
---|
484 | |
---|
485 | /** |
---|
486 | \brief Connect a signal with additionally passing a whole external Object |
---|
487 | */ |
---|
488 | gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, void *)) |
---|
489 | { |
---|
490 | return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); |
---|
491 | } |
---|
492 | |
---|
493 | /** |
---|
494 | \brief Connect a signal with additionally passing a whole external Object |
---|
495 | */ |
---|
496 | gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEventKey*, void *)) |
---|
497 | { |
---|
498 | return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj); |
---|
499 | } |
---|
500 | |
---|
501 | void Widget::disconnectSignal(gulong signalID) |
---|
502 | { |
---|
503 | g_signal_handler_disconnect(G_OBJECT(this->widget), signalID); |
---|
504 | } |
---|
505 | |
---|
506 | /** |
---|
507 | \brief Signal that does absolutely nothing |
---|
508 | \param widget The widget that initiated the Signal |
---|
509 | \param event The event-type. |
---|
510 | \param nothing nothin. |
---|
511 | */ |
---|
512 | gint Widget::doNothingSignal(GtkWidget *widget, GdkEvent* event, void* nothing) |
---|
513 | { |
---|
514 | } |
---|
515 | #endif /* HAVE_GTK2 */ |
---|
516 | |
---|
517 | ///////////// |
---|
518 | /* PACKERS */ |
---|
519 | ///////////// |
---|
520 | /** |
---|
521 | \brief Constructs a Packer |
---|
522 | */ |
---|
523 | Packer::Packer(void) |
---|
524 | { |
---|
525 | this->down = NULL; |
---|
526 | this->groupName = NULL; |
---|
527 | } |
---|
528 | |
---|
529 | /** |
---|
530 | \brief Destroys a Packer. |
---|
531 | */ |
---|
532 | Packer::~Packer(void) |
---|
533 | { |
---|
534 | PRINTF(5)("deleting the Packer part.\n"); |
---|
535 | if (this->groupName) |
---|
536 | delete []this->groupName; |
---|
537 | |
---|
538 | //deleting recursively. |
---|
539 | if (this->down) |
---|
540 | delete this->down; |
---|
541 | } |
---|
542 | |
---|
543 | /** |
---|
544 | \brief Sets the group name under which all the lower widgets of this will be saved. |
---|
545 | \param name The name of the group. |
---|
546 | */ |
---|
547 | void Packer::setGroupName(const char* name) |
---|
548 | { |
---|
549 | if (this->groupName) |
---|
550 | delete []this->groupName; |
---|
551 | this->groupName = new char[strlen(name)+1]; |
---|
552 | strcpy(this->groupName, name); |
---|
553 | } |
---|
554 | |
---|
555 | //////////////// |
---|
556 | /* CONTAINERS */ |
---|
557 | //////////////// |
---|
558 | /** |
---|
559 | \brief Initializes a Container. |
---|
560 | |
---|
561 | sets the Container-Specific defaults. |
---|
562 | */ |
---|
563 | Container::Container(void) |
---|
564 | { |
---|
565 | this->isOption = -1; |
---|
566 | } |
---|
567 | |
---|
568 | /** |
---|
569 | \brief Destroys a Container. |
---|
570 | */ |
---|
571 | Container::~Container(void) |
---|
572 | { |
---|
573 | PRINTF(5)("deleting the Container part.\n"); |
---|
574 | } |
---|
575 | |
---|
576 | /** |
---|
577 | \briefFills a Container with lowerWidget. |
---|
578 | \param lowerWidget the Widget that should be filled into the Container. |
---|
579 | |
---|
580 | It does this by filling up the down pointer only if down points to NULL. |
---|
581 | */ |
---|
582 | void Container::fill(Widget* lowerWidget) |
---|
583 | { |
---|
584 | if (this->down == NULL) |
---|
585 | { |
---|
586 | #ifdef HAVE_GTK2 |
---|
587 | gtk_container_add(GTK_CONTAINER(this->widget), lowerWidget->widget); |
---|
588 | #endif /* HAVE_GTK2 */ |
---|
589 | |
---|
590 | this->down = lowerWidget; |
---|
591 | } |
---|
592 | else |
---|
593 | PRINTF(1)("You tried to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"); |
---|
594 | } |
---|
595 | |
---|
596 | /** |
---|
597 | \param borderwidth sets the Width of the border |
---|
598 | */ |
---|
599 | void Container::setBorderWidth(int borderwidth) |
---|
600 | { |
---|
601 | this->borderwidth = borderwidth; |
---|
602 | |
---|
603 | #ifdef HAVE_GTK2 |
---|
604 | gtk_container_set_border_width(GTK_CONTAINER(widget), borderwidth); |
---|
605 | #endif /* HAVE_GTK2 */ |
---|
606 | } |
---|
607 | |
---|
608 | //////////// |
---|
609 | /* WINDOW */ |
---|
610 | //////////// |
---|
611 | |
---|
612 | /** |
---|
613 | \brief The main Window of Th Gui |
---|
614 | */ |
---|
615 | Window* Window::mainWindow = NULL; |
---|
616 | |
---|
617 | /** |
---|
618 | \brief Creating a Window with a name |
---|
619 | \param windowName the name the window should get. |
---|
620 | */ |
---|
621 | Window::Window(const char* windowName) |
---|
622 | { |
---|
623 | if (!mainWindow) |
---|
624 | { |
---|
625 | mainWindow = this; |
---|
626 | this->isOpen = true; |
---|
627 | } |
---|
628 | isOpen = false; |
---|
629 | |
---|
630 | #ifdef HAVE_GTK2 |
---|
631 | widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
---|
632 | gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE); |
---|
633 | #if !defined(__WIN32__) |
---|
634 | // gtk_window_set_decorated(GTK_WINDOW(widget), FALSE); |
---|
635 | #endif |
---|
636 | gtk_container_set_border_width(GTK_CONTAINER(widget), 3); |
---|
637 | #endif /* HAVE_GTK2 */ |
---|
638 | |
---|
639 | if (windowName) |
---|
640 | this->setTitle(windowName); |
---|
641 | } |
---|
642 | |
---|
643 | /** |
---|
644 | \brief Destructs a Window. |
---|
645 | */ |
---|
646 | Window::~Window(void) |
---|
647 | { |
---|
648 | PRINTF(5)("deleting the Window: %s\n", this->title); |
---|
649 | } |
---|
650 | |
---|
651 | /** |
---|
652 | \brief Adds a new Window Windows to the List of Windows. |
---|
653 | \param windowToAdd The Windows that should be added to the List |
---|
654 | \todo this instead of windowToAdd(possibly) |
---|
655 | */ |
---|
656 | void Window::addWindow(Window* windowToAdd) |
---|
657 | { |
---|
658 | if (!mainWindow) |
---|
659 | { |
---|
660 | mainWindow = windowToAdd; |
---|
661 | windowToAdd->isOpen = true; |
---|
662 | } |
---|
663 | else |
---|
664 | { |
---|
665 | Widget* tmpWindow = mainWindow; |
---|
666 | while(tmpWindow->next) |
---|
667 | tmpWindow = tmpWindow->next; |
---|
668 | tmpWindow->next = windowToAdd; |
---|
669 | windowToAdd->isOpen = false; |
---|
670 | } |
---|
671 | return; |
---|
672 | } |
---|
673 | |
---|
674 | /** |
---|
675 | \brief Shows all Widgets that are included within this->widget. |
---|
676 | */ |
---|
677 | void Window::showall(void) |
---|
678 | { |
---|
679 | #ifdef HAVE_GTK2 |
---|
680 | if (!this->isOpen) |
---|
681 | gtk_widget_show_all(this->widget); |
---|
682 | else |
---|
683 | gtk_widget_show(this->widget); |
---|
684 | #endif /* HAVE_GTK2 */ |
---|
685 | } |
---|
686 | |
---|
687 | /** |
---|
688 | \brief Set The Window-title to title |
---|
689 | \param title title the Window should get. |
---|
690 | */ |
---|
691 | void Window::setTitle(const char* title) |
---|
692 | { |
---|
693 | if (this->title) |
---|
694 | delete []this->title; |
---|
695 | this->title = new char[strlen(title)+1]; |
---|
696 | strcpy(this->title, title); |
---|
697 | #ifdef HAVE_GTK2 |
---|
698 | gtk_window_set_title(GTK_WINDOW(widget), title); |
---|
699 | #endif /* HAVE_GTK2 */ |
---|
700 | } |
---|
701 | |
---|
702 | /** |
---|
703 | \brief opens up a Window and fixes the Focus to it |
---|
704 | */ |
---|
705 | void Window::open(void) |
---|
706 | { |
---|
707 | if (this != mainWindow) |
---|
708 | { |
---|
709 | isOpen = true; |
---|
710 | #ifdef HAVE_GTK2 |
---|
711 | gtk_widget_show_all(this->widget); |
---|
712 | gtk_grab_add(this->widget); |
---|
713 | #endif /* HAVE_GTK2 */ |
---|
714 | } |
---|
715 | } |
---|
716 | |
---|
717 | /** |
---|
718 | \brief closes up a Window and removes the Focus from it |
---|
719 | */ |
---|
720 | void Window::close(void) |
---|
721 | { |
---|
722 | if (this != mainWindow) |
---|
723 | { |
---|
724 | this->isOpen = false; |
---|
725 | #ifdef HAVE_GTK2 |
---|
726 | gtk_grab_remove(this->widget); |
---|
727 | gtk_widget_hide(this->widget); |
---|
728 | #endif /* HAVE_GTK2 */ |
---|
729 | } |
---|
730 | } |
---|
731 | |
---|
732 | /** |
---|
733 | \brief opens up a window(not topmost Window). |
---|
734 | this is the Signal that does it. !!SIGNALS ARE STATIC!! |
---|
735 | \param widget the widget that did it. |
---|
736 | \param event the event that did it. |
---|
737 | \param window the Window that should be opened |
---|
738 | */ |
---|
739 | #ifdef HAVE_GTK2 |
---|
740 | gint Window::windowOpen(GtkWidget* widget, GdkEvent* event, void* window) |
---|
741 | { |
---|
742 | static_cast<Window*>(window)->open(); |
---|
743 | } |
---|
744 | #else /* HAVE_GTK2 */ |
---|
745 | int Window::windowOpen(void* widget, void* event, void* window){} |
---|
746 | #endif /* HAVE_GTK2 */ |
---|
747 | |
---|
748 | /** |
---|
749 | \brief closes a window(not topmost Window). |
---|
750 | this is the Signal that does it. !!SIGNALS ARE STATIC!! |
---|
751 | \param widget the widget that did it! |
---|
752 | \param event the event that did it! |
---|
753 | \param window the Window that should be closed |
---|
754 | */ |
---|
755 | #ifdef HAVE_GTK2 |
---|
756 | gint Window::windowClose(GtkWidget* widget, GdkEvent* event, void* window) |
---|
757 | { |
---|
758 | static_cast<Window*>(window)->close(); |
---|
759 | } |
---|
760 | #else /* HAVE_GTK2 */ |
---|
761 | int Window::windowClose(void* widget, void* event, void* window){} |
---|
762 | #endif /* HAVE_GTK2 */ |
---|
763 | |
---|
764 | /////////// |
---|
765 | /* FRAME */ |
---|
766 | /////////// |
---|
767 | /** |
---|
768 | \brief Creates a new Frame with name title |
---|
769 | */ |
---|
770 | Frame::Frame(char* frameName) |
---|
771 | { |
---|
772 | #ifdef HAVE_GTK2 |
---|
773 | this->widget = gtk_frame_new(""); |
---|
774 | gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); |
---|
775 | #endif /* HAVE_GTK2 */ |
---|
776 | if (title) |
---|
777 | this->setTitle(frameName); |
---|
778 | } |
---|
779 | |
---|
780 | /** |
---|
781 | \brief destrcucts a Frame |
---|
782 | */ |
---|
783 | Frame::~Frame(void) |
---|
784 | { |
---|
785 | PRINTF(5)("deleting the Frame: %s\n", this->title); |
---|
786 | } |
---|
787 | |
---|
788 | /** |
---|
789 | \brief Sets the Frames name to title |
---|
790 | \param title The title the Frame should get. |
---|
791 | */ |
---|
792 | void Frame::setTitle(const char* title) |
---|
793 | { |
---|
794 | if (this->title) |
---|
795 | delete []this->title; |
---|
796 | this->title = new char[strlen(title)+1]; |
---|
797 | strcpy(this->title, title); |
---|
798 | #ifdef HAVE_GTK2 |
---|
799 | gtk_frame_set_label(GTK_FRAME(widget), title); |
---|
800 | #endif /* HAVE_GTK2 */ |
---|
801 | } |
---|
802 | |
---|
803 | ////////////// |
---|
804 | /* EVENTBOX */ |
---|
805 | ////////////// |
---|
806 | /** |
---|
807 | \brief Creates a new EventBox with name title |
---|
808 | \param eventBoxName title the Eventbox should get(only data-structure-internal) |
---|
809 | */ |
---|
810 | EventBox::EventBox(const char* eventBoxName) |
---|
811 | { |
---|
812 | this->isOption = -1; |
---|
813 | |
---|
814 | #ifdef HAVE_GTK2 |
---|
815 | this->widget = gtk_event_box_new(); |
---|
816 | gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); |
---|
817 | #endif /* HAVE_GTK2 */ |
---|
818 | |
---|
819 | if (eventBoxName) |
---|
820 | this->setTitle(eventBoxName); |
---|
821 | } |
---|
822 | |
---|
823 | /** |
---|
824 | \brief destructs an EventBox. |
---|
825 | */ |
---|
826 | EventBox::~EventBox(void) |
---|
827 | { |
---|
828 | PRINTF(5)("deleting the EventBox: %s\n", this->title); |
---|
829 | } |
---|
830 | |
---|
831 | ///////// |
---|
832 | /* BOX */ |
---|
833 | ///////// |
---|
834 | /** |
---|
835 | \brief Creates a new Box of type boxtype |
---|
836 | \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally |
---|
837 | */ |
---|
838 | Box::Box(char boxtype) |
---|
839 | { |
---|
840 | this->isOption = -2; |
---|
841 | |
---|
842 | #ifdef HAVE_GTK2 |
---|
843 | if (boxtype == 'v') |
---|
844 | this->widget = gtk_vbox_new(FALSE, 0); |
---|
845 | else |
---|
846 | this->widget = gtk_hbox_new(FALSE, 0); |
---|
847 | #endif /* HAVE_GTK2 */ |
---|
848 | } |
---|
849 | |
---|
850 | /** |
---|
851 | \brief destructs a Box. |
---|
852 | */ |
---|
853 | Box::~Box(void) |
---|
854 | { |
---|
855 | PRINTF(5)("deleting the Box: %s\n", this->title); |
---|
856 | } |
---|
857 | |
---|
858 | /** |
---|
859 | \brief Fills a box with a given Widget. |
---|
860 | \param lowerWidget the next Widget that should be appendet to this Box |
---|
861 | |
---|
862 | It does this by apending the first one to its down-pointer and all its following ones to the preceding next-pointer. The last one will receive a NULL pointer as Next |
---|
863 | */ |
---|
864 | void Box::fill(Widget* lowerWidget) |
---|
865 | { |
---|
866 | #ifdef HAVE_GTK2 |
---|
867 | gtk_box_pack_start(GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0); |
---|
868 | #endif /* HAVE_GTK2 */ |
---|
869 | if (this->down == NULL) |
---|
870 | this->down = lowerWidget; |
---|
871 | else |
---|
872 | { |
---|
873 | Widget* tmp; |
---|
874 | tmp = this->down; |
---|
875 | while(tmp->next != NULL) |
---|
876 | tmp = tmp->next; |
---|
877 | tmp->next = lowerWidget; |
---|
878 | } |
---|
879 | } |
---|
880 | |
---|
881 | //////////// |
---|
882 | /* OPTION */ |
---|
883 | //////////// |
---|
884 | /** |
---|
885 | \brief Initializes a new Option. |
---|
886 | sets all Option-Specific-Values to their defaults. |
---|
887 | */ |
---|
888 | Option::Option(void) |
---|
889 | { |
---|
890 | this->value = 0; |
---|
891 | this->flagName = NULL; |
---|
892 | this->flagNameShort = NULL; |
---|
893 | |
---|
894 | this->shortDescription = NULL; |
---|
895 | this->longDescription = NULL; |
---|
896 | |
---|
897 | this->saveable = false; |
---|
898 | this->defaultValue = 0; |
---|
899 | } |
---|
900 | |
---|
901 | /** |
---|
902 | \brief Destroys an Option. |
---|
903 | */ |
---|
904 | Option::~Option(void) |
---|
905 | { |
---|
906 | PRINTF(5)("deleting the Option Part.\n"); |
---|
907 | if (this->flagName) |
---|
908 | delete []this->flagName; |
---|
909 | if (this->flagNameShort) |
---|
910 | delete []this->flagNameShort; |
---|
911 | if (this->shortDescription) |
---|
912 | delete []this->shortDescription; |
---|
913 | if (this->longDescription) |
---|
914 | delete []this->longDescription; |
---|
915 | } |
---|
916 | |
---|
917 | /** |
---|
918 | \brief This sets The FlagName of an Option and defines its default Values |
---|
919 | !! Options will be saved if flagname is different from NULL !! |
---|
920 | \param flagname the Name that will be displayed in the output |
---|
921 | \param defaultvalue the default Value for this Option(see definition of defaultvalue |
---|
922 | */ |
---|
923 | void Option::setFlagName(const char* flagname, int defaultvalue) |
---|
924 | { |
---|
925 | if (this->flagName) |
---|
926 | delete this->flagName; |
---|
927 | this->flagName = new char [strlen(flagname)+1]; |
---|
928 | strcpy(this->flagName, flagname); |
---|
929 | |
---|
930 | this->defaultValue = defaultvalue; |
---|
931 | |
---|
932 | if (this->flagNameShort) |
---|
933 | { |
---|
934 | delete this->flagNameShort; |
---|
935 | this->flagNameShort = NULL; |
---|
936 | } |
---|
937 | |
---|
938 | // cout << "Set Flagname of " << this->title << " to " << flagname << endl; |
---|
939 | } |
---|
940 | |
---|
941 | /** |
---|
942 | \brief see Option::setFlagName(char* flagname, int defaultvalue) |
---|
943 | \param flagname the Name that will be displayed in the output |
---|
944 | \param defaultvalue the default Value for this Option(see definition of defaultvalue |
---|
945 | \param flagnameshort a short flagname to be displayed in the output |
---|
946 | */ |
---|
947 | void Option::setFlagName(const char* flagname, const char* flagnameshort, int defaultvalue) |
---|
948 | { |
---|
949 | if (this->flagName) |
---|
950 | delete []this->flagName; |
---|
951 | this->flagName = new char [strlen(flagname)+1]; |
---|
952 | strcpy(this->flagName, flagname); |
---|
953 | |
---|
954 | if (this->flagNameShort) |
---|
955 | delete []this->flagNameShort; |
---|
956 | this->flagNameShort = new char [strlen(flagnameshort)+1]; |
---|
957 | strcpy(this->flagNameShort, flagnameshort); |
---|
958 | this->defaultValue = defaultvalue; |
---|
959 | // cout << "Set Flagname of " << this->title << " to " << flagname << endl; |
---|
960 | } |
---|
961 | |
---|
962 | void Option::setDescription(const char* shortDescription, const char* longDescription) |
---|
963 | { |
---|
964 | // setting up the short description |
---|
965 | if (this->shortDescription) |
---|
966 | delete []this->shortDescription; |
---|
967 | this->shortDescription = new char [strlen(shortDescription)+1]; |
---|
968 | strcpy(this->shortDescription, shortDescription); |
---|
969 | |
---|
970 | //setting up the long description |
---|
971 | if (this->longDescription) |
---|
972 | delete []this->longDescription; |
---|
973 | if (longDescription) |
---|
974 | { |
---|
975 | this->longDescription = new char [strlen(longDescription)+1]; |
---|
976 | strcpy(this->longDescription, longDescription); |
---|
977 | } |
---|
978 | else |
---|
979 | this->longDescription = NULL; |
---|
980 | } |
---|
981 | |
---|
982 | /** |
---|
983 | \brief Sets the saveable-state of the option. |
---|
984 | \param isSaveable the saveable-state to set. |
---|
985 | */ |
---|
986 | void Option::saveability(bool isSaveable) |
---|
987 | { |
---|
988 | this->saveable = isSaveable; |
---|
989 | } |
---|
990 | |
---|
991 | /** |
---|
992 | \brief saves an Option |
---|
993 | \returns the String that should be saved. (this string __should__ be deleted) |
---|
994 | |
---|
995 | this is a default Option save |
---|
996 | */ |
---|
997 | char* Option::save(void) |
---|
998 | { |
---|
999 | char* value = new char [30]; |
---|
1000 | sprintf (value, "%d", this->value); |
---|
1001 | return value; |
---|
1002 | } |
---|
1003 | |
---|
1004 | /** |
---|
1005 | \brief loads an Option from of its loadString |
---|
1006 | \param loadString the string from which to load the data from |
---|
1007 | */ |
---|
1008 | void Option::load(char* loadString) |
---|
1009 | { |
---|
1010 | this->value = atoi(loadString); |
---|
1011 | PRINT(5)("Loading %s: %s %d\n", this->title, loadString, value); |
---|
1012 | this->redraw(); |
---|
1013 | } |
---|
1014 | |
---|
1015 | /** |
---|
1016 | \returns The saveable-state. |
---|
1017 | */ |
---|
1018 | bool Option::isSaveable(void) |
---|
1019 | { |
---|
1020 | return this->saveable; |
---|
1021 | } |
---|
1022 | |
---|
1023 | #ifdef HAVE_GTK2 |
---|
1024 | /** |
---|
1025 | \brief Signal OptionChange writes the Value from the Slider to its Object-Database. |
---|
1026 | \param widget The widget(Slider) that has a changed Value |
---|
1027 | \param slider the Slider-Object that should receive the change. |
---|
1028 | */ |
---|
1029 | gint Option::OptionChange(GtkWidget *widget, Widget* option) |
---|
1030 | { |
---|
1031 | static_cast<Option*>(option)->changeOption(); |
---|
1032 | flags->setTextFromFlags(Window::mainWindow); //// must be different !!! |
---|
1033 | } |
---|
1034 | #endif /* HAVE_GTK2 */ |
---|
1035 | |
---|
1036 | //////////// |
---|
1037 | /* BUTTON */ |
---|
1038 | //////////// |
---|
1039 | /** |
---|
1040 | \brief Creates a new Button with a buttonname |
---|
1041 | \param buttonName sets the Name of the Button |
---|
1042 | */ |
---|
1043 | Button::Button(char* buttonName) |
---|
1044 | { |
---|
1045 | isOption = 0; |
---|
1046 | |
---|
1047 | #ifdef HAVE_GTK2 |
---|
1048 | widget = gtk_button_new_with_label(""); |
---|
1049 | #endif /* HAVE_GTK2 */ |
---|
1050 | |
---|
1051 | if (buttonName) |
---|
1052 | this->setTitle(buttonName); |
---|
1053 | } |
---|
1054 | |
---|
1055 | /** |
---|
1056 | \brief destructs a Button. |
---|
1057 | */ |
---|
1058 | Button::~Button(void) |
---|
1059 | { |
---|
1060 | PRINTF(5)("deleting the Label: %s\n", this->title); |
---|
1061 | } |
---|
1062 | |
---|
1063 | /** |
---|
1064 | \brief Sets a new name to the Button |
---|
1065 | \param title The name the Button should get |
---|
1066 | */ |
---|
1067 | void Button::setTitle(const char *title) |
---|
1068 | { |
---|
1069 | if (this->title) |
---|
1070 | delete []this->title; |
---|
1071 | this->title = new char[strlen(title)+1]; |
---|
1072 | strcpy(this->title, title); |
---|
1073 | #ifdef HAVE_GTK2 |
---|
1074 | gtk_button_set_label(GTK_BUTTON(widget), title); |
---|
1075 | #endif /* HAVE_GTK2 */ |
---|
1076 | } |
---|
1077 | |
---|
1078 | /** |
---|
1079 | \brief redraws the Button |
---|
1080 | \todo not implemented yet |
---|
1081 | */ |
---|
1082 | void Button::redraw(void) |
---|
1083 | { |
---|
1084 | } |
---|
1085 | |
---|
1086 | /** |
---|
1087 | \brief Button can not be changed, optionChange is empty) |
---|
1088 | |
---|
1089 | \todo Actions for non-GTK-mode |
---|
1090 | */ |
---|
1091 | void Button::changeOption(void) |
---|
1092 | { |
---|
1093 | // This will possibly be used for ACTIONS ! |
---|
1094 | } |
---|
1095 | |
---|
1096 | ///////////////// |
---|
1097 | /* CHECKBUTTON */ |
---|
1098 | ///////////////// |
---|
1099 | /** |
---|
1100 | \brief Creates a new CheckButton with an ame |
---|
1101 | \param buttonName The name the CheckButton should display. |
---|
1102 | */ |
---|
1103 | CheckButton::CheckButton(const char* buttonName) |
---|
1104 | { |
---|
1105 | this->isOption = 1; |
---|
1106 | |
---|
1107 | #ifdef HAVE_GTK2 |
---|
1108 | this->widget = gtk_check_button_new_with_label(""); |
---|
1109 | #endif /* HAVE_GTK2 */ |
---|
1110 | |
---|
1111 | if (buttonName) |
---|
1112 | this->setTitle(buttonName); |
---|
1113 | |
---|
1114 | #ifdef HAVE_GTK2 |
---|
1115 | this->connectSignal("clicked", this->OptionChange); |
---|
1116 | #endif /* HAVE_GTK2 */ |
---|
1117 | } |
---|
1118 | |
---|
1119 | /** |
---|
1120 | \brief destructs a CheckButton. |
---|
1121 | */ |
---|
1122 | CheckButton::~CheckButton(void) |
---|
1123 | { |
---|
1124 | if (this->title) |
---|
1125 | PRINTF(5)("deleting the CheckButton: %s\n", this->title); |
---|
1126 | else |
---|
1127 | PRINTF(5)("deleting the CheckButton.\n"); |
---|
1128 | } |
---|
1129 | |
---|
1130 | /** |
---|
1131 | \brief Sets a new Title to a CheckButton |
---|
1132 | \param title The new Name the CheckButton should display. |
---|
1133 | */ |
---|
1134 | void CheckButton::setTitle(const char* title) |
---|
1135 | { |
---|
1136 | if (this->title) |
---|
1137 | delete []this->title; |
---|
1138 | this->title = new char[strlen(title)+1]; |
---|
1139 | strcpy(this->title, title); |
---|
1140 | #ifdef HAVE_GTK2 |
---|
1141 | gtk_button_set_label(GTK_BUTTON(widget), title); |
---|
1142 | #endif /* HAVE_GTK2 */ |
---|
1143 | } |
---|
1144 | |
---|
1145 | /** |
---|
1146 | \returns the Active state of the checkButton |
---|
1147 | */ |
---|
1148 | bool CheckButton::isActive(void) |
---|
1149 | { |
---|
1150 | #ifdef HAVE_GTK2 |
---|
1151 | return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); |
---|
1152 | #endif /* HAVE_GTK2 */ |
---|
1153 | } |
---|
1154 | |
---|
1155 | /** |
---|
1156 | \brief Changed the Option, call this Function |
---|
1157 | */ |
---|
1158 | void CheckButton::changeOption(void) |
---|
1159 | { |
---|
1160 | #ifdef HAVE_GTK2 |
---|
1161 | this->value =(int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this->widget)); |
---|
1162 | #else /* HAVE_GTK2 */ |
---|
1163 | char tmpChar[200]; |
---|
1164 | PRINT(0)("\nPlease give me a new value for %s [0,1](default:%d): ",this->title, this->defaultValue); |
---|
1165 | scanf("%s", tmpChar); |
---|
1166 | |
---|
1167 | if ((this->value = atoi(tmpChar))=!0) |
---|
1168 | this->value = 1; |
---|
1169 | #endif /* HAVE_GTK2 */ |
---|
1170 | PRINT(0)("%s set to: %d\n", this->title, this->value); |
---|
1171 | } |
---|
1172 | |
---|
1173 | /** |
---|
1174 | \brief Redraws the CheckButton(if option has changed). |
---|
1175 | Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change |
---|
1176 | */ |
---|
1177 | void CheckButton::redraw(void) |
---|
1178 | { |
---|
1179 | #ifdef HAVE_GTK2 |
---|
1180 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(this->widget), value); |
---|
1181 | #endif /* HAVE_GTK2 */ |
---|
1182 | } |
---|
1183 | |
---|
1184 | //////////// |
---|
1185 | /* SLIDER */ |
---|
1186 | //////////// |
---|
1187 | /** |
---|
1188 | \brief Creates a new Slider |
---|
1189 | \param slidername The data-structure-name of the slider. |
---|
1190 | \param start The minimal Value of the slider. |
---|
1191 | \param end The maximal Value of the slider. |
---|
1192 | */ |
---|
1193 | Slider::Slider(const char* slidername, int start, int end) |
---|
1194 | { |
---|
1195 | this->isOption = 2; |
---|
1196 | |
---|
1197 | this->start = start; |
---|
1198 | this->end = end; |
---|
1199 | #ifdef HAVE_GTK2 |
---|
1200 | widget = gtk_hscale_new_with_range(this->start, this->end, 5); |
---|
1201 | #endif /* HAVE_GTK2 */ |
---|
1202 | |
---|
1203 | this->setValue(start); |
---|
1204 | this->setTitle(slidername); |
---|
1205 | #ifdef HAVE_GTK2 |
---|
1206 | this->connectSignal("value_changed", this->OptionChange); |
---|
1207 | #endif /* HAVE_GTK2 */ |
---|
1208 | } |
---|
1209 | |
---|
1210 | /** |
---|
1211 | \brief destructs a Slider. |
---|
1212 | */ |
---|
1213 | Slider::~Slider(void) |
---|
1214 | { |
---|
1215 | PRINTF(5)("deleting the Slider: %s\n", this->title); |
---|
1216 | } |
---|
1217 | |
---|
1218 | /** |
---|
1219 | \brief Setting a new value to the Slider. |
---|
1220 | Maybe you also require a Slider::redraw() for this to display |
---|
1221 | */ |
---|
1222 | void Slider::setValue(int value) |
---|
1223 | { |
---|
1224 | this->value = value; |
---|
1225 | } |
---|
1226 | |
---|
1227 | /** |
---|
1228 | \brief Redraws the widget |
---|
1229 | Example: see void CheckButton::redraw(void) |
---|
1230 | */ |
---|
1231 | void Slider::redraw(void) |
---|
1232 | { |
---|
1233 | #ifdef HAVE_GTK2 |
---|
1234 | gtk_range_set_value(GTK_RANGE(this->widget), this->value); |
---|
1235 | #endif /* HAVE_GTK2 */ |
---|
1236 | } |
---|
1237 | |
---|
1238 | /** |
---|
1239 | \brief Changed the Option, call this Function |
---|
1240 | */ |
---|
1241 | void Slider::changeOption(void) |
---|
1242 | { |
---|
1243 | #ifdef HAVE_GTK2 |
---|
1244 | this->value =(int)gtk_range_get_value(GTK_RANGE(this->widget)); |
---|
1245 | #else /* HAVE_GTK2 */ |
---|
1246 | char tmpChar[20]; |
---|
1247 | PRINT(0)("\nPlease give me a new value for %s [%d-%d] (default:%d): ", this->title, this->start, this->end, this->defaultValue); |
---|
1248 | scanf("%s", tmpChar); |
---|
1249 | |
---|
1250 | if ((this->value = atoi(tmpChar))> this->end) |
---|
1251 | this->value = this->end; |
---|
1252 | if (this->value <= this->start) |
---|
1253 | this->value = this->start; |
---|
1254 | #endif /* HAVE_GTK2 */ |
---|
1255 | PRINT(0)("%s set to: %d\n",this->title, this->value); |
---|
1256 | } |
---|
1257 | |
---|
1258 | ////////// |
---|
1259 | /* MENU */ |
---|
1260 | ////////// |
---|
1261 | /** |
---|
1262 | \brief constructs a new Menu, without adding any items to it. |
---|
1263 | \param menuName the Name the Menu gets. |
---|
1264 | */ |
---|
1265 | Menu::Menu(const char* menuName) |
---|
1266 | { |
---|
1267 | this->init(); |
---|
1268 | this->setTitle(menuName); |
---|
1269 | } |
---|
1270 | |
---|
1271 | /** |
---|
1272 | \brief Creates a Menu-Item-list out of multiple input. |
---|
1273 | !! Consider, that the last input argument has to be "lastItem" for this to work!! |
---|
1274 | \param menuname The Database-Name of this Menu |
---|
1275 | \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!! |
---|
1276 | */ |
---|
1277 | Menu::Menu(char* menuname, ...) |
---|
1278 | { |
---|
1279 | this->init(); |
---|
1280 | this->setTitle(menuname); |
---|
1281 | va_list itemlist; //!< The list to readin multiple Options. |
---|
1282 | |
---|
1283 | char *itemName; |
---|
1284 | |
---|
1285 | va_start(itemlist, menuname); |
---|
1286 | while(strcmp(itemName = va_arg(itemlist, char*), "lastItem")) |
---|
1287 | { |
---|
1288 | this->addItem(itemName); |
---|
1289 | } |
---|
1290 | va_end(itemlist); |
---|
1291 | } |
---|
1292 | |
---|
1293 | /** |
---|
1294 | \brief destructs a Menu. |
---|
1295 | */ |
---|
1296 | Menu::~Menu(void) |
---|
1297 | { |
---|
1298 | PRINTF(5)("deleting the Menu: %s\n", this->title); |
---|
1299 | this->currItem = this->firstItem; |
---|
1300 | while(this->currItem) |
---|
1301 | { |
---|
1302 | delete []this->currItem->name; |
---|
1303 | //! \todo destroy menu |
---|
1304 | /* |
---|
1305 | #ifdef HAVE_GTK2 |
---|
1306 | gtk_widget_destroy(this->currItem->item); |
---|
1307 | #endif /* HAVE_GTK2 */ |
---|
1308 | MenuItem* tmpItem = this->currItem; |
---|
1309 | this->currItem = this->currItem->next; |
---|
1310 | delete tmpItem; |
---|
1311 | } |
---|
1312 | } |
---|
1313 | |
---|
1314 | /** |
---|
1315 | \brief Initializes a new Menu with no items |
---|
1316 | */ |
---|
1317 | void Menu::init(void) |
---|
1318 | { |
---|
1319 | this->isOption = 2; |
---|
1320 | this->firstItem = NULL; |
---|
1321 | |
---|
1322 | #ifdef HAVE_GTK2 |
---|
1323 | this->widget = gtk_option_menu_new(); |
---|
1324 | this->menu = gtk_menu_new(); |
---|
1325 | gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu); |
---|
1326 | this->connectSignal("changed", this->OptionChange); |
---|
1327 | #endif /* HAVE_GTK2 */ |
---|
1328 | } |
---|
1329 | |
---|
1330 | /** |
---|
1331 | \brief saves the Label of the Menu |
---|
1332 | \returns the name of the selected Menu-Item |
---|
1333 | */ |
---|
1334 | char* Menu::save(void) |
---|
1335 | { |
---|
1336 | MenuItem* tmpItem = this->firstItem; |
---|
1337 | for (int i = 0; i<this->value; i++) |
---|
1338 | tmpItem = tmpItem->next; |
---|
1339 | |
---|
1340 | return tmpItem->name; |
---|
1341 | } |
---|
1342 | |
---|
1343 | /** |
---|
1344 | \brief loads a Menu from of its loadString |
---|
1345 | \param loadString the string from which to load the data from |
---|
1346 | */ |
---|
1347 | void Menu::load(char* loadString) |
---|
1348 | { |
---|
1349 | MenuItem* tmpItem = firstItem; |
---|
1350 | bool foundItem = false; |
---|
1351 | while (tmpItem) |
---|
1352 | { |
---|
1353 | if (!strcmp(loadString, tmpItem->name)) |
---|
1354 | {foundItem = true; break;} |
---|
1355 | tmpItem = tmpItem->next; |
---|
1356 | } |
---|
1357 | if (foundItem) |
---|
1358 | this->value = tmpItem->itemNumber; |
---|
1359 | else |
---|
1360 | { |
---|
1361 | this->value = 0; |
---|
1362 | PRINTF(2)("Sorry, but %s has not been found in the Itemlist of %s\n", loadString, this->title); |
---|
1363 | } |
---|
1364 | PRINTF(4)( "Loading %s: setting to %d\n", this->title, this->value); |
---|
1365 | this->redraw(); |
---|
1366 | } |
---|
1367 | |
---|
1368 | /** |
---|
1369 | \brief appends a new Item to the Menu-List. |
---|
1370 | \param itemName the itemName to be appendet. |
---|
1371 | */ |
---|
1372 | void Menu::addItem(char* itemName) |
---|
1373 | { |
---|
1374 | if (!this->firstItem) |
---|
1375 | { |
---|
1376 | this->firstItem = this->currItem = new MenuItem; |
---|
1377 | this->currItem->itemNumber = 0; |
---|
1378 | } |
---|
1379 | else |
---|
1380 | { |
---|
1381 | int tmpI = this->currItem->itemNumber; |
---|
1382 | this->currItem = this->currItem->next = new MenuItem; |
---|
1383 | this->currItem->itemNumber = tmpI+1; |
---|
1384 | } |
---|
1385 | |
---|
1386 | this->currItem->name = new char[strlen(itemName)+1]; |
---|
1387 | strcpy(this->currItem->name, itemName); |
---|
1388 | |
---|
1389 | #ifdef HAVE_GTK2 |
---|
1390 | this->currItem->item = gtk_menu_item_new_with_label(itemName); |
---|
1391 | gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->currItem->item); |
---|
1392 | #endif /* HAVE_GTK2 */ |
---|
1393 | this->currItem->next = NULL; |
---|
1394 | } |
---|
1395 | |
---|
1396 | /** |
---|
1397 | \brief Redraws the widget |
---|
1398 | Example: see void CheckButton::redraw(void) |
---|
1399 | */ |
---|
1400 | void Menu::redraw(void) |
---|
1401 | { |
---|
1402 | #ifdef HAVE_GTK2 |
---|
1403 | gtk_option_menu_set_history(GTK_OPTION_MENU(this->widget), this->value); |
---|
1404 | #endif /* HAVE_GTK2 */ |
---|
1405 | } |
---|
1406 | |
---|
1407 | /** |
---|
1408 | \brief Changed the Option, call this Function |
---|
1409 | */ |
---|
1410 | void Menu::changeOption(void) |
---|
1411 | { |
---|
1412 | #ifdef HAVE_GTK2 |
---|
1413 | this->value =(int)gtk_option_menu_get_history(GTK_OPTION_MENU(this->widget)); |
---|
1414 | #else /* HAVE_GTK2 */ |
---|
1415 | char tmpChar[20]; |
---|
1416 | PRINT(0)("\nPlease give me a new value for %s (default: %d): ", this->title, this->defaultValue); |
---|
1417 | scanf("%s",tmpChar); |
---|
1418 | this->value = atoi(tmpChar); |
---|
1419 | |
---|
1420 | #endif /* HAVE_GTK2 */ |
---|
1421 | PRINT(4)("%s set to: %d\n", this->title, this->value); |
---|
1422 | } |
---|
1423 | |
---|
1424 | /* OPTION LABEL */ |
---|
1425 | |
---|
1426 | /** |
---|
1427 | \brief Creates a new OptionLabel with a LabelName and a Value. |
---|
1428 | \param label The name of the OptionLabel. |
---|
1429 | \param value The Value of the OptionLabel(what will be displayed). |
---|
1430 | */ |
---|
1431 | OptionLabel::OptionLabel(const char* label, const char* value) |
---|
1432 | { |
---|
1433 | this->isOption = 5; |
---|
1434 | cValue = NULL; |
---|
1435 | |
---|
1436 | #ifdef HAVE_GTK2 |
---|
1437 | this->widget = gtk_label_new(""); |
---|
1438 | #endif /* HAVE_GTK2 */ |
---|
1439 | |
---|
1440 | this->setTitle(label); |
---|
1441 | this->setValue(value); |
---|
1442 | } |
---|
1443 | |
---|
1444 | /** |
---|
1445 | \brief destructs an OptionLabel. |
---|
1446 | */ |
---|
1447 | OptionLabel::~OptionLabel(void) |
---|
1448 | { |
---|
1449 | PRINTF(5)("deleting the OptionLabel: %s\n", this->title); |
---|
1450 | if (this->cValue) |
---|
1451 | delete []this->cValue; |
---|
1452 | } |
---|
1453 | |
---|
1454 | /** |
---|
1455 | \brief Updates the value of an OptionLabel |
---|
1456 | \param newValue The new Name that should be displayed. |
---|
1457 | */ |
---|
1458 | void OptionLabel::setValue(const char* newValue) |
---|
1459 | { |
---|
1460 | if (this->cValue) |
---|
1461 | delete []this->cValue; |
---|
1462 | this->cValue = new char [strlen(newValue)+1]; |
---|
1463 | strcpy(this->cValue, newValue); |
---|
1464 | #ifdef HAVE_GTK2 |
---|
1465 | gtk_label_set_text(GTK_LABEL(this->widget), this->cValue); |
---|
1466 | #endif /* HAVE_GTK2 */ |
---|
1467 | } |
---|
1468 | |
---|
1469 | /** |
---|
1470 | \brief Redraws an OptionLabel(not implemented yet, but it works). |
---|
1471 | */ |
---|
1472 | void OptionLabel::redraw(void) |
---|
1473 | { |
---|
1474 | #ifdef HAVE_GTK2 |
---|
1475 | gtk_label_set_text(GTK_LABEL(widget), title); |
---|
1476 | #endif /* HAVE_GTK2 */ |
---|
1477 | } |
---|
1478 | |
---|
1479 | /** |
---|
1480 | \brief Changed the Option, call this Function |
---|
1481 | */ |
---|
1482 | void OptionLabel::changeOption(void) |
---|
1483 | { |
---|
1484 | #ifdef HAVE_GTK2 |
---|
1485 | this->cValue =(char*)gtk_label_get_text(GTK_LABEL(this->widget)); |
---|
1486 | #else /* HAVE_GTK2 */ |
---|
1487 | PRINT(0)("\nPlease give me a new input for %s: ", this->title); |
---|
1488 | char tmpChar[100]; |
---|
1489 | scanf("%s",tmpChar); |
---|
1490 | this->setValue(tmpChar); |
---|
1491 | #endif /* HAVE_GTK2 */ |
---|
1492 | PRINT(4)("%s set to: %s\n", this->title, this->cValue); |
---|
1493 | } |
---|
1494 | |
---|
1495 | |
---|
1496 | /** |
---|
1497 | \brief creates the Optionlabel save-string |
---|
1498 | \returns the String to save. |
---|
1499 | */ |
---|
1500 | char* OptionLabel::save(void) |
---|
1501 | { |
---|
1502 | return cValue; |
---|
1503 | } |
---|
1504 | |
---|
1505 | /** |
---|
1506 | \brief loads an Option from of its loadString |
---|
1507 | \param loadString the string from which to load the data from |
---|
1508 | */ |
---|
1509 | void OptionLabel::load(char* loadString) |
---|
1510 | { |
---|
1511 | PRINTF(4)("Loading %s: setting to %s\n", this->title, loadString); |
---|
1512 | this->setValue(loadString); |
---|
1513 | } |
---|
1514 | |
---|
1515 | /////////// |
---|
1516 | /* LABEL */ |
---|
1517 | /////////// |
---|
1518 | /** |
---|
1519 | \brief Creates a new Label with a Text. |
---|
1520 | \param text The text to be displayed. |
---|
1521 | */ |
---|
1522 | Label:: Label(const char* text) |
---|
1523 | { |
---|
1524 | this->isOption = 0; |
---|
1525 | |
---|
1526 | #ifdef HAVE_GTK2 |
---|
1527 | this->widget = gtk_label_new(""); |
---|
1528 | gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE); |
---|
1529 | #endif /* HAVE_GTK2 */ |
---|
1530 | |
---|
1531 | if (text) |
---|
1532 | this->setTitle(text); |
---|
1533 | } |
---|
1534 | |
---|
1535 | /** |
---|
1536 | \brief destructs a Label. |
---|
1537 | */ |
---|
1538 | Label::~Label(void) |
---|
1539 | { |
---|
1540 | PRINTF(5)("deleting the Label: %s\n", this->title); |
---|
1541 | } |
---|
1542 | |
---|
1543 | /** |
---|
1544 | \brief Sets a new Text to a Label. |
---|
1545 | \param text The text to be inserted into the Label. |
---|
1546 | */ |
---|
1547 | void Label::setTitle(const char* text) |
---|
1548 | { |
---|
1549 | if (this->title) |
---|
1550 | delete []this->title; |
---|
1551 | this->title = new char[strlen(text)+1]; |
---|
1552 | strcpy(this->title, text); |
---|
1553 | #ifdef HAVE_GTK2 |
---|
1554 | gtk_label_set_text(GTK_LABEL(this->widget), this->title); |
---|
1555 | #endif /* HAVE_GTK2 */ |
---|
1556 | } |
---|
1557 | |
---|
1558 | /** |
---|
1559 | \brief ereases the Text of a Label |
---|
1560 | */ |
---|
1561 | void Label::ereaseText(void) |
---|
1562 | { |
---|
1563 | this->setTitle(""); |
---|
1564 | } |
---|
1565 | |
---|
1566 | /** |
---|
1567 | \brief appends some Text to a Label |
---|
1568 | \param textToAppend The text that will be appended to this Label |
---|
1569 | */ |
---|
1570 | void Label::appendText(char* textToAppend) |
---|
1571 | { |
---|
1572 | if (this->title) |
---|
1573 | { |
---|
1574 | char* tmpTitle = new char[strlen(this->title)+strlen(textToAppend)+1]; |
---|
1575 | strcpy(tmpTitle, title); |
---|
1576 | strcat(tmpTitle, textToAppend); |
---|
1577 | delete []this->title; |
---|
1578 | this->title = tmpTitle; |
---|
1579 | } |
---|
1580 | else |
---|
1581 | this->title = new char[strlen(textToAppend)]; |
---|
1582 | |
---|
1583 | #ifdef HAVE_GTK2 |
---|
1584 | gtk_label_set_text(GTK_LABEL(this->widget), title); |
---|
1585 | #endif /* HAVE_GTK2 */ |
---|
1586 | } |
---|
1587 | |
---|
1588 | /** |
---|
1589 | \brief Appends some integer to the Label |
---|
1590 | \param intToAppend The Int that will be added. |
---|
1591 | |
---|
1592 | it does this by just converting the int into a char* and send it to appendText |
---|
1593 | */ |
---|
1594 | void Label::appendInt(int intToAppend) |
---|
1595 | { |
---|
1596 | char append [32]; |
---|
1597 | sprintf(append, "%d", intToAppend); |
---|
1598 | this->appendText(append); |
---|
1599 | } |
---|
1600 | |
---|
1601 | |
---|
1602 | /** |
---|
1603 | \brief get the Text of a Label |
---|
1604 | \return The Text the Label holds. |
---|
1605 | */ |
---|
1606 | const char* Label::getText(void) |
---|
1607 | { |
---|
1608 | return this->title; |
---|
1609 | } |
---|
1610 | |
---|
1611 | ////////////////// |
---|
1612 | /* PROGRESS-BAR */ |
---|
1613 | ////////////////// |
---|
1614 | /** |
---|
1615 | \brief Creates a new ProgressBar. |
---|
1616 | \param label The name you want to get the ProgressBar. |
---|
1617 | */ |
---|
1618 | ProgressBar::ProgressBar(const char* label) |
---|
1619 | { |
---|
1620 | this->isOption = 0; |
---|
1621 | this->progress = 0.0; |
---|
1622 | this->totalSize = 0.0; |
---|
1623 | |
---|
1624 | #ifdef HAVE_GTK2 |
---|
1625 | this->adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); |
---|
1626 | this->widget = gtk_progress_bar_new_with_adjustment(this->adjustment); |
---|
1627 | #endif /* HAVE_GTK2 */ |
---|
1628 | |
---|
1629 | if (label) |
---|
1630 | this->setTitle(label); |
---|
1631 | } |
---|
1632 | |
---|
1633 | /** |
---|
1634 | \brief destructs a ProgressBar |
---|
1635 | */ |
---|
1636 | ProgressBar::~ProgressBar(void) |
---|
1637 | { |
---|
1638 | PRINTF(5)("deleting the ProgressBar: %s\n", this->title); |
---|
1639 | } |
---|
1640 | |
---|
1641 | /** |
---|
1642 | \brief Sets the Total size of the Bar.(ex. The maximum one can download) |
---|
1643 | */ |
---|
1644 | void ProgressBar::setTotalSize(double totalSize) |
---|
1645 | { |
---|
1646 | this->totalSize = totalSize; |
---|
1647 | } |
---|
1648 | |
---|
1649 | /** |
---|
1650 | \brief Sets the progress maximum is this->totalSize |
---|
1651 | */ |
---|
1652 | void ProgressBar::setProgress(double progress) |
---|
1653 | { |
---|
1654 | this->progress = progress; |
---|
1655 | |
---|
1656 | if (this->progress > this->totalSize) |
---|
1657 | this->progress = this->totalSize; |
---|
1658 | |
---|
1659 | #ifdef HAVE_GTK2 |
---|
1660 | gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize); |
---|
1661 | PRINTF(4)("Progress: %f%%\n", this->progress*100.0/this->totalSize); |
---|
1662 | #else /* HVE_GTK2 */ |
---|
1663 | PRINT(0)("Progress: %f%%\n", this->progress*100.0/this->totalSize); |
---|
1664 | #endif /* HAVE_GTK2 */ |
---|
1665 | } |
---|
1666 | |
---|
1667 | /** |
---|
1668 | \brief returns the Progress Status |
---|
1669 | */ |
---|
1670 | double ProgressBar::getProgress(void) |
---|
1671 | { |
---|
1672 | return this->progress; |
---|
1673 | } |
---|
1674 | |
---|
1675 | /////////// |
---|
1676 | /* IMAGE */ |
---|
1677 | /////////// |
---|
1678 | /** |
---|
1679 | \brief Creates a new Image |
---|
1680 | \param imageName the location of the Image on the Hard Disc |
---|
1681 | */ |
---|
1682 | Image::Image(const char* imageName) |
---|
1683 | { |
---|
1684 | this->init(imageName); |
---|
1685 | |
---|
1686 | #ifdef HAVE_GTK2 |
---|
1687 | widget = gtk_image_new_from_file(imageName); |
---|
1688 | #endif /* HAVE_GTK2 */ |
---|
1689 | } |
---|
1690 | |
---|
1691 | /** |
---|
1692 | \brief Creates a new Image |
---|
1693 | \param imageData data to the PixBuff |
---|
1694 | */ |
---|
1695 | Image::Image(char** imageData) |
---|
1696 | { |
---|
1697 | this->init("pixBuffImage"); |
---|
1698 | |
---|
1699 | #ifdef HAVE_GTK2 |
---|
1700 | widget = gtk_image_new_from_pixbuf(gdk_pixbuf_new_from_xpm_data((const char**)imageData)); |
---|
1701 | #endif /* HAVE_GTK2 */ |
---|
1702 | } |
---|
1703 | |
---|
1704 | |
---|
1705 | /** |
---|
1706 | \brief destructs an Image. |
---|
1707 | */ |
---|
1708 | Image::~Image(void) |
---|
1709 | { |
---|
1710 | PRINTF(5)("deleting the Image: %s\n", this->title); |
---|
1711 | } |
---|
1712 | |
---|
1713 | /** |
---|
1714 | \brief Initializes a new Image |
---|
1715 | \param name the name to set to the Image |
---|
1716 | */ |
---|
1717 | void Image::init(const char* name) |
---|
1718 | { |
---|
1719 | isOption = 0; |
---|
1720 | |
---|
1721 | if (this->title) |
---|
1722 | delete []this->title; |
---|
1723 | this->title = new char[strlen(name)+1]; |
---|
1724 | strcpy(this->title, name); |
---|
1725 | } |
---|