Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc @ 4026

Last change on this file since 4026 was 4026, checked in by bensch, 19 years ago

orxonox/trunk: gui: minor cleanup

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