Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3423 in orxonox.OLD for orxonox/trunk/src/gui/orxonox_gui_gtk.cc


Ignore:
Timestamp:
Feb 27, 2005, 7:11:19 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged branches/updater back into the trunk
merged with command: svn merge branches/updater trunk -r 3241:HEAD
resolved conflicts in debug.h in favor of the trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/gui/orxonox_gui_gtk.cc

    r3192 r3423  
    3434// temporarily.
    3535#include "orxonox_gui_flags.h"
    36 #include "orxonox_gui_exec.h"
    3736extern Window* orxonoxGUI;
    3837extern OrxonoxGuiFlags* flags;
    39 extern OrxonoxGuiExec* exec;
    40 
    41 #ifdef HAVE_GTK2
     38
    4239/**
    4340   \brief Initializes the Guis GTK-stuff.
     
    4542   \param argv The Argument strings.
    4643*/
    47 bool initGTK(int argc, char *argv[])
    48 {
    49   gtk_init (&argc, &argv);
     44bool initGUI(int argc, char *argv[])
     45{
     46#ifdef HAVE_GTK2
     47#ifdef HAVE_GTHREAD
     48  PRINTF(3)("Initializing the ThreadSystem of the GUI\n");
     49  g_thread_init(NULL);
     50  gdk_threads_init();
     51#endif /* HAVE_GTHREAD */
     52  gtk_init(&argc, &argv);
    5053  gtk_rc_parse( "rc" );
    51 }
    52 
    53 /**
    54    \brief enters the GTK-main-loop
    55 */
    56 bool mainloopGTK(void)
    57 {
     54#endif /* HAVE_GTK2 */
     55}
     56
     57
     58/**
     59   \brief enters the GUI's main-loop
     60*/
     61bool mainloopGUI(void)
     62{
     63#ifdef HAVE_GTK2
     64  gdk_threads_enter();
    5865  gtk_main();
    59 }
    60 #endif /* HAVE_GTK2 */
     66  gdk_threads_leave();
     67  delete Window::mainWindow;
     68#else /* HAVE_GTK2 */
     69  char boolAns = 'y';
     70  char ans[10];
     71  while(true)
     72    {
     73      PRINT(0)(" Listing all the Orxonox Options: \n");
     74      PRINT(0)("  #############################\n");
     75      Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1);
     76     
     77      PRINT(0)("\nDo you want change any of the above values now? [Yn] ");
     78      cin >>boolAns ;
     79      if (boolAns =='n' || boolAns=='N')
     80        break;
     81     
     82      PRINT(0)("\n Listing all groups\n");
     83      PRINT(0)("  #################\n");
     84      int groupCount = 0;
     85      Window::mainWindow->walkThrough(Widget::listGroups, &groupCount, 1);
     86     
     87      PRINT(0)("\nIn which Group? [1-%d] ", groupCount);
     88      Packer* group;
     89      while(true)
     90        {
     91          cin >> ans;
     92          int ansIp = atoi(ans);
     93          if (ansIp <= groupCount)
     94            {
     95              group = static_cast<Packer*>(Window::mainWindow->findGroupByNumber(&ansIp, 1));
     96              break;
     97            }
     98          else
     99            PRINT(0)("\nChoose a smaler Number please: [1-%d] ", groupCount);
     100        }
     101      PRINT(0)("\n\nGroup: [%s]\n\n", group->groupName);
     102      int optionCount = 0;
     103      group->walkThrough(Widget::listOptions, &optionCount, 0);
     104      PRINT(0)("\nWhich Option? [1-%d] ", optionCount);
     105      Option* option;
     106      while(true)
     107        {
     108          cin >> ans;
     109          int ansIp = atoi(ans);
     110          if (ansIp <= groupCount)
     111            {
     112              option = static_cast<Option*>(group->findOptionByNumber(&ansIp, 0));
     113              break;
     114            }
     115          else
     116            PRINT(0)("\nChoose a smaler Number please: [1-%d] ", optionCount);
     117        }
     118      PRINT(0)("\n\n:: %s ::\n", option->title);
     119      option->changeOption();
     120     
     121      // here follows the rest.... this will be nasty.
     122      //! \todo move this into the gui-gtk-file
     123      //! \todo finish it.
     124    }
     125#endif /* HAVE_GTK2 */
     126 
     127}
     128
     129
     130//////////////////////////////
     131/// DEFINING WIDGET-CLASES ///
     132//////////////////////////////
    61133
    62134/* WIDGET */
     
    66138   This is still pretty crappy.
    67139*/
    68 Widget::~Widget()
    69 {
    70   //  cout << "hiding: " <<this->label <<"\n";
    71   this->hide();
    72   //  cout << "check if Packer: "<<this->label <<"\n";
    73   if (this->isOption < 0)
    74     {
    75       //  cout << "get Down "<<this->label <<"\n";
    76       static_cast<Packer*>(this)->down->~Widget();
    77     }
    78   //  cout << "next != NULL?: " <<this->label <<"\n";
    79   if (this->next != NULL)
    80     this->next->~Widget();
    81   cout << "delete Widget: " <<this->label <<"\n";
    82   //  delete widget;
     140Widget::~Widget(void)
     141{
     142  this->destroy();
    83143}
    84144
     
    87147   Initializes the next Pointer and the other Widget-specific Defaults.
    88148*/
    89 void Widget::init()
     149void Widget::init(void)
    90150{
    91151  next = NULL;
    92   label = NULL;
     152  this->title = NULL;
    93153  return;
    94154}
    95155
    96156/**
     157   \brief Destroys a Widget
     158*/
     159void Widget::destroy(void)
     160{
     161  if (this->title)
     162    {
     163      delete []this->title;
     164    }
     165 
     166  PRINTF(4)("deleting the Widget part.\n");
     167
     168  PRINTF(4)("deleting recursively\n");
     169
     170  // deleting next item if existent
     171  if (this->next)
     172    delete this->next;
     173  this->next = NULL;
     174
     175  //!  \todo not hiding widget, deleting.
     176  //  this->hide();
     177  //  delete this->widget;
     178}
     179
     180/**
    97181   \brief makes the widget visible.
    98182*/
    99 void Widget::show()
    100 {
    101 #ifdef HAVE_GTK2
    102   gtk_widget_show (this->widget);
     183void Widget::show(void)
     184{
     185#ifdef HAVE_GTK2
     186  gtk_widget_show(this->widget);
    103187#endif /* HAVE_GTK2 */
    104188}
     
    107191   \brief hides the widget.
    108192*/
    109 void Widget::hide()
    110 {
    111 #ifdef HAVE_GTK2
    112   gtk_widget_hide (this->widget);
     193void Widget::hide(void)
     194{
     195#ifdef HAVE_GTK2
     196  gtk_widget_hide(this->widget);
    113197#endif /* HAVE_GTK2 */
    114198}
     
    122206{
    123207#ifdef HAVE_GTK2
    124   gtk_widget_set_usize (this->widget, width, height);
    125 #endif /* HAVE_GTK2 */
    126 }
    127 
    128 #ifdef HAVE_GTK2
    129 /**
    130     \brief Connect any signal to any given Sub-widget
    131 */
    132 gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))
    133 {
    134   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);
    135 }
    136 
    137 /**
    138    \brief Connect a signal with additionally passing the whole Object
    139 */
    140 gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))
    141 {
    142   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);
    143 }
    144 
    145 /**
    146    \brief Connect a signal with additionally passing a whole external Object
    147 */
    148 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))
    149 {
    150   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
    151 }
    152 
    153 /**
    154    \brief Connect a signal with additionally passing a whole external Object
    155 */
    156 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *))
    157 {
    158   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
    159 }
    160 
    161 void Widget::disconnectSignal (gulong signalID)
    162 {
    163   g_signal_handler_disconnect (G_OBJECT (this->widget), signalID);
    164 }
    165 #endif /* HAVE_GTK2 */
     208  gtk_widget_set_usize(this->widget, width, height);
     209#endif /* HAVE_GTK2 */
     210}
     211
     212/**
     213   \brief searches through widgets for a Name.
     214*/
     215Widget* Widget::findWidgetByName(char* name, unsigned int depth)
     216{
     217
     218  if (this->title && !strcmp(this->title, name))
     219    return this;
     220
     221  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
     222    {
     223      Widget* tmp = static_cast<Packer*>(this)->down->findWidgetByName(name, depth+1);
     224      if (tmp)
     225        return tmp;
     226    }
     227 
     228  if (depth>0 && this->next)
     229    return this->next->findWidgetByName(name, depth);
     230
     231  return NULL;
     232}
    166233
    167234/**
    168235   \brief Moves through all the Widgets downwards from this and executes the function on them.
    169    \param Function must be of type void and takes a Widget* as an Input.
    170 */
    171 void Widget::walkThrough (void (*function)(Widget*))
     236   \param function must be of type void and takes a Widget* as an Input.
     237   \param depth the current depth. if > 0 then the next Widget will also be walked through.
     238*/
     239void Widget::walkThrough(void(*function)(Widget*), unsigned int depth)
    172240{
    173241  function(this);
    174242  if (this->isOption < 0)
    175243    {
    176       static_cast<Packer*>(this)->down->walkThrough (function);
     244      static_cast<Packer*>(this)->down->walkThrough(function, depth+1);
    177245    }
    178246
    179   if (this->next != NULL)
    180     this->next->walkThrough(function);
     247  if (this->next && depth != 0)
     248    this->next->walkThrough(function, depth);
     249}
     250
     251/**
     252   \brief Moves through all the Widgets downwards from this and executes the function on them.
     253   \param function must be of type void and takes a Widget* as an Input.
     254   \param data Additional Data you want to pass to the function.
     255   \param depth the current depth. if > 0 then the next Widget will also be walked through.
     256*/
     257void Widget::walkThrough(void(*function)(Widget*, void*), void* data, unsigned int depth)
     258{
     259  function(this, data);
     260  if (this->isOption < 0)
     261    {
     262      static_cast<Packer*>(this)->down->walkThrough(function, data, depth+1);
     263    }
     264  if (this->next && depth != 0)
     265    this->next->walkThrough(function, data, depth);
    181266}
    182267
    183268/**
    184     \brief This is for listing the option of "widget"
     269    \brief This is for listing the options of "widget"
    185270    \param widget specifies the widget that should be listed
    186271*/
    187 void Widget::listOptions (Widget* widget)
     272void Widget::listOptionsAndGroups(Widget* widget)
    188273{
    189274  if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
    190275    cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n";
    191276  if (widget->isOption >= 1 && widget->isOption <= 3)
    192     cout << "  " << static_cast<Option*>(widget)->label <<" is : " << static_cast<Option*>(widget)->value <<endl;
     277    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;
    193278  else if (widget->isOption == 5)
    194     cout << "  " << static_cast<Option*>(widget)->label <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
    195 }
    196 
     279    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
     280}
     281
     282/**
     283    \brief This is for listing the options of "widget"
     284    \param widget specifies the widget that should be listed
     285*/
     286void Widget::listOptions(Widget* widget)
     287{
     288  if (widget->isOption >= 1 && widget->isOption <= 3)
     289    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;
     290  else if (widget->isOption == 5)
     291    cout << "  " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
     292}
     293
     294/**
     295    \brief This is for listing the options of "widget"
     296    \param widget specifies the widget that should be listed
     297    \param data A Counter, that always knows how many Options have been found yet.
     298*/
     299void Widget::listOptions(Widget* widget, void* data)
     300{
     301 
     302  if (widget->isOption >= 1 && widget->isOption <= 3)
     303    {
     304      int* count =(int*)data;
     305      *count = *count +1;
     306      cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl;
     307    }
     308  else if (widget->isOption == 5)
     309    {
     310      int* count =(int*)data;
     311      *count = *count +1;
     312      cout << *count << ": " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl;
     313    }
     314}
     315
     316/**
     317    \brief Finds an Option by a given number(the n'th option found away from this Widget)
     318    \param number The Count of options to wait(by reference)
     319    \param depth The depth of the sarch. if 0 it will not search next pointer
     320   
     321    \todo should return Option* would be much sexier.
     322*/
     323Widget* Widget::findOptionByNumber(int* number, unsigned int depth)
     324{
     325  if (isOption > 0)
     326    {
     327      --*number;
     328      if (*number <= 0)
     329        {
     330          return this;
     331        }
     332    }
     333  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
     334    {
     335      Widget* tmp = static_cast<Packer*>(this)->down->findOptionByNumber(number, depth+1);
     336      if (tmp)
     337        return tmp;
     338    }
     339  if (depth>0 && this->next)
     340    return this->next->findOptionByNumber(number, depth);
     341
     342  return NULL;
     343}
     344
     345/**
     346    \brief This is for listing the groups of "widget"
     347    \param widget specifies the widget that should be listed
     348*/
     349void Widget::listGroups(Widget* widget)
     350{
     351  if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
     352    cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n";
     353}
     354
     355/**
     356    \brief This is for listing the Groups of "widget". It also displays the n'th number found.
     357    \param widget specifies the widget that should be listed
     358    \param data the Counter, that will show the number(this function will raise it by one if a Group is fount.
     359*/
     360void Widget::listGroups(Widget* widget, void* data)
     361{
     362  if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName)
     363    {
     364      int* count =(int*)data;
     365      *count = *count +1;
     366      cout << *count <<": [" << static_cast<Packer*>(widget)->groupName << "]\n";
     367    }
     368}
     369
     370/**
     371    \brief Finds a Group by a given number(the n'th Group found away from this Widget)
     372    \param number The Count of options to wait(by reference)
     373    \param depth The depth of the sarch. if 0 it will not search next pointer
     374*/
     375Widget* Widget::findGroupByNumber(int* number, unsigned int depth)
     376{
     377  if (isOption < 0 && static_cast<Packer*>(this)->groupName)
     378    {
     379      --*number;
     380      if (*number <= 0)
     381        {
     382          return this;
     383        }
     384    }
     385  if (this->isOption < 0 && static_cast<Packer*>(this)->down)
     386    {
     387      Widget* tmp = static_cast<Packer*>(this)->down->findGroupByNumber(number, depth+1);
     388      if (tmp)
     389        return tmp;
     390    }
     391  if (depth>0 && this->next)
     392    return this->next->findGroupByNumber(number, depth);
     393
     394  return NULL;
     395}
     396 
    197397/**
    198398    \brief This is for setting the option of "widget"
    199399    \param widget specifies the widget that should be set.
    200400*/
    201 void Widget::setOptions (Widget* widget)
     401void Widget::setOptions(Widget* widget)
    202402{
    203403  if (widget->isOption >= 1)
    204     static_cast<Option*>(widget)->redraw();// <<" is : " << static_cast<Option*>(this)->value <<endl;
    205 }
    206 
    207 #ifdef HAVE_GTK2
     404    static_cast<Option*>(widget)->redraw();
     405}
     406
     407/**
     408   \brief Walks through all the Flags given at startuptime.
     409*/
     410void Widget::flagCheck(Widget* widget, void* flagName)
     411{
     412  if (widget->isOption>=1)
     413    {     
     414      Option* option =(Option*)widget;
     415      char* name =(char*)flagName;
     416      char* value = NULL;
     417      bool found = false;
     418      // check if long flag matches
     419      if ((option->flagName && strlen(name)>2 && !strncmp(name+2, option->flagName, strlen(option->flagName)) &&(name[strlen(option->flagName)+2] == '\0' || name[strlen(option->flagName)+2] == '=') ))
     420        {
     421          found = true;
     422          if (name[strlen(option->flagName)+2] == '=')
     423            {
     424              value = name+strlen(option->flagName)+3;
     425            }
     426        }
     427      else if (option->flagNameShort && strlen(name)>1 && !strncmp(name+1, option->flagNameShort, strlen(option->flagNameShort))&&(name[strlen(option->flagNameShort)+1] == '\0' || name[strlen(option->flagNameShort)+1] == '=')) // check if short flag matches
     428        {
     429          found = true;
     430          if (name[strlen(option->flagNameShort)+1] == '=')
     431            {
     432              value = name+strlen(option->flagNameShort)+2;
     433            }     
     434        }
     435
     436      if (found)
     437        {
     438          PRINT(3)("found matching Flag %s\n", name);
     439          if (value)
     440            {
     441              PRINT(3)("with Value %s\n", value);
     442              option->value = atoi(value);
     443            }
     444          else
     445            {
     446              option->value = !option->defaultValue;
     447            }
     448          option->redraw();
     449        }
     450
     451    }
     452}
     453
     454#ifdef HAVE_GTK2
     455/**
     456    \brief Connect any signal to any given Sub-widget
     457*/
     458gulong Widget::connectSignal(char* event, gint(*signal)(GtkWidget*, GdkEvent*, void *))
     459{
     460  return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), NULL);
     461}
     462
     463/**
     464   \brief Connect a signal with additionally passing the whole Object
     465*/
     466gulong Widget::connectSignal(char* event, gint(*signal)( GtkWidget*, Widget *))
     467{
     468  return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), this);
     469}
     470
     471/**
     472   \brief Connect a signal with additionally passing a whole external Object
     473*/
     474gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEvent*, void *))
     475{
     476  return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj);
     477}
     478
     479/**
     480   \brief Connect a signal with additionally passing a whole external Object
     481*/
     482gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, void *))
     483{
     484  return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj);
     485}
     486
     487/**
     488   \brief Connect a signal with additionally passing a whole external Object
     489*/
     490gulong Widget::connectSignal(char* event, void* extObj, gint(*signal)(GtkWidget*, GdkEventKey*, void *))
     491{
     492  return g_signal_connect(G_OBJECT(this->widget), event, G_CALLBACK(signal), extObj);
     493}
     494
     495void Widget::disconnectSignal(gulong signalID)
     496{
     497  g_signal_handler_disconnect(G_OBJECT(this->widget), signalID);
     498}
    208499
    209500/**
     
    213504   \param nothing nothin.
    214505*/
    215 gint Widget::doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing)
     506gint Widget::doNothingSignal(GtkWidget *widget, GdkEvent* event, void* nothing)
    216507{
    217508}
     
    228519   Sets the down-pinter to NULL and other PackerSpecific-values to their defaults.
    229520*/
    230 void Packer::init (void)
    231 {
    232   down = NULL;
    233   groupName = NULL;
     521void Packer::init(void)
     522{
     523  this->down = NULL;
     524  this->groupName = NULL;
    234525
    235526
     
    239530
    240531/**
     532   \brief Destroys a Packer.
     533*/
     534void Packer::destroy(void)
     535{
     536  PRINTF(4)("deleting the Packer part.\n");
     537 
     538  if (this->groupName)
     539    delete []this->groupName;
     540
     541  //deleting recursively.
     542  if (this->down)
     543    delete this->down;
     544  this->down = NULL;
     545
     546  static_cast<Widget*>(this)->destroy();
     547}
     548
     549/**
    241550   \brief Sets the group name under which all the lower widgets of this will be saved.
    242551   \param name The name of the group.
    243552*/
    244 void Packer::setGroupName (char* name)
    245 {
    246   if (groupName)
    247     delete groupName;
    248   groupName = new char [strlen(name)+1];
    249   strcpy(groupName, name);
     553void Packer::setGroupName(char* name)
     554{
     555  if (this->groupName)
     556    delete []this->groupName;
     557  this->groupName = new char[strlen(name)+1];
     558  strcpy(this->groupName, name);
    250559}
    251560
     
    254563   \returns name The name of the group.
    255564*/
    256 char* Packer::getGroupName (void)
    257 {
    258   return groupName;
     565char* Packer::getGroupName(void)
     566{
     567  return this->groupName;
    259568}
    260569
     
    266575   sets the Container-Specific defaults.
    267576*/
    268 void Container::init (void)
    269 {
    270   isOption = -1;
     577void Container::init(void)
     578{
     579  this->isOption = -1;
    271580
    272581  static_cast<Packer*>(this)->init();
    273582
    274583  return;
     584}
     585
     586/**
     587   \brief Destroys a Container.
     588*/
     589void Container::destroy(void)
     590{
     591  PRINTF(4)("deleting the Container part.\n");
     592
     593  static_cast<Packer*>(this)->destroy();
    275594}
    276595
     
    281600   It does this by filling up the down pointer only if down points to NULL.
    282601*/
    283 void Container::fill (Widget *lowerWidget)
     602void Container::fill(Widget *lowerWidget)
    284603{
    285604  if (this->down == NULL)
    286605    {
    287606#ifdef HAVE_GTK2
    288       gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget);
     607      gtk_container_add(GTK_CONTAINER(this->widget), lowerWidget->widget);
    289608#endif /* HAVE_GTK2 */
    290609      this->down = lowerWidget;
    291610    }
    292611  else
    293     cout << "!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"<<endl;
    294 }
    295 
    296 // gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
     612    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");
     613}
     614
     615// gtk_container_set_border_width(GTK_CONTAINER(widget), 5);
    297616
    298617/* WINDOW */
     
    303622   \brief Adds a new Window Windows to the List of Windows.
    304623   \param windowToAdd The Windows that should be added to the List
    305    \todo this instead of windowToAdd (possibly)
     624   \todo this instead of windowToAdd(possibly)
    306625*/
    307626void Window::addWindow(Window* windowToAdd)
     
    314633
    315634  Widget* tmpWindow = mainWindow;
    316   while (tmpWindow->next)
     635  while(tmpWindow->next)
    317636    tmpWindow = tmpWindow->next;
    318637  tmpWindow->next = windowToAdd;
     
    322641     
    323642
    324 
    325643/**
    326644   \brief Creating a new Window without a Name
    327645*/
    328 Window::Window (void)
     646Window::Window(void)
    329647{
    330648  this->init();
     
    335653   \param windowName the name the window should get.
    336654*/
    337 Window::Window (char* windowName)
     655
     656Window::Window(char* windowName)
    338657{
    339658  this->init();
    340   this->setTitle (windowName);
     659  this->setTitle(windowName);
     660}
     661
     662/**
     663   \brief Destructs a Window.
     664*/
     665Window::~Window(void)
     666{
     667  this->destroy();
    341668}
    342669
     
    344671   \brief initializes a new Window
    345672*/
    346 void Window::init()
     673void Window::init(void)
    347674{
    348675  if (!mainWindow)
     
    354681
    355682#ifdef HAVE_GTK2
    356   widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    357   gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE);
     683  widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     684  gtk_window_set_policy(GTK_WINDOW(widget), TRUE, TRUE, TRUE);
    358685#if !defined(__WIN32__)
    359   //  gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);
     686  //  gtk_window_set_decorated(GTK_WINDOW(widget), FALSE);
    360687#endif
    361   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    362 #endif /* HAVE_GTK2 */
     688  gtk_container_set_border_width(GTK_CONTAINER(widget), 3);
     689#endif /* HAVE_GTK2 */
     690}
     691
     692/**
     693   \brief Destroys a Window.
     694*/
     695void Window::destroy(void)
     696{
     697  if (this->title)
     698    PRINTF(3)("deleting the Window: %s\n", this->title);
     699  else
     700    PRINTF(3)("deleting the Window.\n");
     701  //  this->hide();
     702  static_cast<Container*>(this)->destroy();
     703 
    363704}
    364705
     
    366707   \brief Shows all Widgets that are included within this->widget.
    367708*/
    368 void Window::showall ()
    369 {
    370   if (!isOpen)
    371     {
    372       //      printf ("showall\n");
    373 #ifdef HAVE_GTK2
    374       gtk_widget_show_all  (widget);
     709void Window::showall(void)
     710{
     711  if (!this->isOpen)
     712    {
     713      //      printf("showall\n");
     714#ifdef HAVE_GTK2
     715      gtk_widget_show_all(this->widget);
    375716#endif /* HAVE_GTK2 */
    376      isOpen = true;
     717     this->isOpen = true;
    377718    }
    378719  else
    379720    {
    380       //      printf ("showone\n");
    381 #ifdef HAVE_GTK2
    382       gtk_widget_show (widget);
     721      //      printf("showone\n");
     722#ifdef HAVE_GTK2
     723      gtk_widget_show(this->widget);
    383724#endif /* HAVE_GTK2 */
    384725    }
     
    389730   \param title title the Window should get.
    390731*/
    391 void Window::setTitle (char* title)
    392 {
    393   if (label)
    394     delete []label;
    395   label = new char[strlen(title)+1];
    396   strcpy(label, title);
    397 #ifdef HAVE_GTK2
    398   gtk_window_set_title (GTK_WINDOW (widget), title);
     732void Window::setTitle(char* title)
     733{
     734  if (this->title)
     735    delete []this->title;
     736  this->title = new char[strlen(title)+1];
     737  strcpy(this->title, title);
     738#ifdef HAVE_GTK2
     739  gtk_window_set_title(GTK_WINDOW(widget), title);
    399740#endif /* HAVE_GTK2 */
    400741}
     
    403744   \brief opens up a Window and fixes the Focus to it
    404745*/
    405 void Window::open()
     746void Window::open(void)
    406747{
    407748  if (this != mainWindow)
     
    409750      isOpen = true;
    410751#ifdef HAVE_GTK2
    411       gtk_widget_show_all(widget);
    412       gtk_grab_add(widget);
     752      gtk_widget_show_all(this->widget);
     753      gtk_grab_add(this->widget);
    413754#endif /* HAVE_GTK2 */
    414755    }
     
    418759   \brief closes up a Window and removes the Focus from it
    419760*/
    420 void Window::close()
     761void Window::close(void)
    421762{
    422763  if (this != mainWindow)
    423764    {
    424       isOpen = false;
    425 #ifdef HAVE_GTK2
    426       gtk_grab_remove(widget);
    427       gtk_widget_hide (widget);
    428 #endif /* HAVE_GTK2 */
    429     }
    430 }
    431 
    432 #ifdef HAVE_GTK2
    433 /**
    434    \brief opens up a window (not topmost Window).
     765      this->isOpen = false;
     766#ifdef HAVE_GTK2
     767      gtk_grab_remove(this->widget);
     768      gtk_widget_hide(this->widget);
     769#endif /* HAVE_GTK2 */
     770    }
     771}
     772
     773#ifdef HAVE_GTK2
     774/**
     775   \brief opens up a window(not topmost Window).
    435776   this is the Signal that does it. !!SIGNALS ARE STATIC!!
    436777   \param widget the widget that did it.
     
    438779   \param window the Window that should be opened
    439780*/
    440 gint Window::windowOpen (GtkWidget *widget, GdkEvent* event, void* window)
     781gint Window::windowOpen(GtkWidget *widget, GdkEvent* event, void* window)
    441782{
    442783  static_cast<Window*>(window)->open();
     
    444785
    445786/**
    446    \brief closes a window (not topmost Window).
     787   \brief closes a window(not topmost Window).
    447788   this is the Signal that does it. !!SIGNALS ARE STATIC!!
    448789   \param widget the widget that did it!
     
    450791   \param window the Window that should be closed
    451792*/
    452 gint Window::windowClose (GtkWidget *widget, GdkEvent* event, void* window)
     793gint Window::windowClose(GtkWidget *widget, GdkEvent* event, void* window)
    453794{
    454795  static_cast<Window*>(window)->close();
    455796}
    456797
    457 /**
    458  * Quits the orxonox_GUI.
    459  * This can be called as a Signal and is therefor static
    460  \param widget The widget that called this function
    461  \param event the event that happened to execute this function
    462  \param data some data passed with the Signal
    463  */
    464 gint Window::orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data)
    465 {
    466   if (exec->shouldsave())
    467     exec->writeToFile (Window::mainWindow);
    468 
    469   gtk_main_quit();
    470   return FALSE;
    471 }
    472798#endif /* HAVE_GTK2 */
    473799
     
    478804    \brief Creates a new Frame without a name
    479805*/
    480 Frame::Frame (void)
     806Frame::Frame(void)
    481807{
    482808  this->init();
     
    486812   \brief Creates a new Frame with name title
    487813*/
    488 Frame::Frame (char* title)
     814Frame::Frame(char* title)
    489815{
    490816  this->init();
     
    492818}
    493819
     820/**
     821   \brief destrcucts a Frame
     822*/
     823Frame::~Frame(void)
     824{
     825  this->destroy();
     826}
     827
    494828/**
    495829    \brief Initializes a new Frame with default settings
    496830*/
    497 void Frame::init()
     831void Frame::init(void)
    498832{
    499833  static_cast<Container*>(this)->init();
    500834
    501835#ifdef HAVE_GTK2
    502   widget = gtk_frame_new ("");
    503   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    504 #endif /* HAVE_GTK2 */
     836  this->widget = gtk_frame_new("");
     837  gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
     838#endif /* HAVE_GTK2 */
     839}
     840
     841/**
     842   \brief Destroys a Frame.
     843*/
     844void Frame::destroy(void)
     845{
     846  if (this->title)
     847    PRINTF(3)("deleting the Frame: %s\n", this->title);
     848  else
     849    PRINTF(3)("deleting the Frame.\n");
     850
     851   static_cast<Container*>(this)->destroy();
    505852}
    506853
     
    509856   \param title The title the Frame should get.
    510857*/
    511 void Frame::setTitle (char* title)
    512 {
    513   if (label)
    514     delete []label;
    515   label = new char[strlen(title)+1];
    516   strcpy(label, title);
    517 #ifdef HAVE_GTK2
    518   gtk_frame_set_label (GTK_FRAME (widget), title);
     858void Frame::setTitle(char* title)
     859{
     860  if (this->title)
     861    delete []this->title;
     862  this->title = new char[strlen(title)+1];
     863  strcpy(this->title, title);
     864#ifdef HAVE_GTK2
     865  gtk_frame_set_label(GTK_FRAME(widget), title);
    519866#endif /* HAVE_GTK2 */
    520867}
     
    525872   \brief Creates a new EventBox with default settings.
    526873*/
    527 EventBox::EventBox ()
     874EventBox::EventBox(void)
    528875{
    529876  this->init();
    530877}
     878
    531879/**
    532880   \brief Creates a new EventBox with name title
    533    \param title title the Eventbox should get (only data-structure-internal)
    534 */
    535 EventBox::EventBox (char* title)
     881   \param title title the Eventbox should get(only data-structure-internal)
     882*/
     883EventBox::EventBox(char* title)
    536884{
    537885  this->init();
     
    540888
    541889/**
     890   \brief destructs an EventBox.
     891*/
     892EventBox::~EventBox(void)
     893{
     894  this->destroy();
     895
     896}
     897
     898/**
    542899   \brief Initializes a new EventBox
    543900*/
    544901void EventBox::init(void)
    545902{
    546   isOption = -1;
     903  this->isOption = -1;
    547904
    548905  static_cast<Container*>(this)->init();
    549906
    550907#ifdef HAVE_GTK2
    551   widget = gtk_event_box_new ();
    552   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    553 #endif /* HAVE_GTK2 */
    554 }
    555 
    556 /**
    557    \brief Sets the Title of the EventBox (not implemented)
    558    \param title Name the EventBox should get (only datastructure-internal).
    559 */
    560 void EventBox::setTitle (char* title)
    561 {
    562   if (label)
    563     delete []label;
    564   label = new char[strlen(title)+1];
    565   strcpy(label, title);
     908  this->widget = gtk_event_box_new();
     909  gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
     910#endif /* HAVE_GTK2 */
     911}
     912
     913/**
     914   \brief Destroys an EventBox.
     915*/
     916void EventBox::destroy(void)
     917{
     918  if (this->title)
     919    PRINTF(3)("deleting the EventBox: %s\n", this->title);
     920  else
     921    PRINTF(3)("deleting the EventBox.\n");
     922
     923  static_cast<Container*>(this)->destroy();
     924}
     925
     926/**
     927   \brief Sets the Title of the EventBox(not implemented)
     928   \param title Name the EventBox should get(only datastructure-internal).
     929*/
     930void EventBox::setTitle(char* title)
     931{
     932  if (this->title)
     933    delete []this->title;
     934  this->title = new char[strlen(title)+1];
     935  strcpy(this->title, title);
    566936}
    567937
     
    571941   \brief Creates a new horizontal Box
    572942*/
    573 Box::Box (void)
     943Box::Box(void)
    574944{
    575945  this->init('h');
     
    580950   \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally
    581951*/
    582 Box::Box (char boxtype)
     952Box::Box(char boxtype)
    583953{
    584954  this->init(boxtype);
     955}
     956
     957/**
     958   \brief destructs a Box.
     959*/
     960Box::~Box(void)
     961{
     962  this->destroy();
    585963}
    586964
     
    591969void Box::init(char boxtype)
    592970{
    593   isOption = -2;
     971  this->isOption = -2;
    594972
    595973  static_cast<Packer*>(this)->init();
     
    597975  if (boxtype == 'v')
    598976    {
    599       widget = gtk_vbox_new (FALSE, 0);
     977      this->widget = gtk_vbox_new(FALSE, 0);
    600978    }
    601979  else
    602980    {
    603       widget = gtk_hbox_new (FALSE, 0);
    604     }
    605 #endif /* HAVE_GTK2 */
    606 
     981      this->widget = gtk_hbox_new(FALSE, 0);
     982    }
     983#endif /* HAVE_GTK2 */
     984}
     985
     986/**
     987   \brief Destroys a Box.
     988*/
     989void Box::destroy(void)
     990{
     991  if (this->title)
     992    PRINTF(3)("deleting the Box: %s\n", this->title);
     993  else
     994    PRINTF(3)("deleting the Box.\n");
     995
     996  static_cast<Packer*>(this)->destroy();
    607997}
    608998
     
    6131003    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
    6141004*/
    615 void Box::fill (Widget *lowerWidget)
    616 {
    617 #ifdef HAVE_GTK2
    618   gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0);
     1005void Box::fill(Widget* lowerWidget)
     1006{
     1007#ifdef HAVE_GTK2
     1008  gtk_box_pack_start(GTK_BOX(this->widget), lowerWidget->widget, TRUE, TRUE, 0);
    6191009#endif /* HAVE_GTK2 */
    6201010  if (this->down == NULL)
     
    6241014      Widget* tmp;
    6251015      tmp = this->down;
    626       while (tmp->next != NULL)
     1016      while(tmp->next != NULL)
    6271017        {
    6281018          tmp = tmp->next;
     
    6321022}
    6331023
    634 /* IMAGE */
    635 
    636 /**
    637    \brief Creates a new Image
    638    \param imagename the location of the Image on the Hard Disc
    639 */
    640 Image::Image (char* imagename)
    641 {
    642   this->init();
    643   if (label)
    644     delete []label;
    645   label = new char[strlen(imagename)+1];
    646   strcpy(label, imagename);
    647 
    648 #ifdef HAVE_GTK2
    649   widget = gtk_image_new_from_file (imagename);
    650 #endif /* HAVE_GTK2 */
    651 }
    652 
    653 /**
    654     \brief Initializes a new Image
    655 */
    656 void Image::init()
    657 {
    658   isOption = 0;
    659 
    660   static_cast<Widget*>(this)->init();
    661 }
    662 
     1024/**
     1025   \brief Sets the Title of a Box.
     1026   \param title the new Title to set.
     1027*/
     1028void Box::setTitle(char* title)
     1029{
     1030  if (this->title)
     1031    delete []this->title;
     1032  this->title = new char[strlen(title)+1];
     1033  strcpy(this->title, title);
     1034}
    6631035
    6641036/* OPTION */
     
    6681040   sets all Option-Specific-Values to their defaults.
    6691041*/
    670 void Option::init()
    671 {
    672   value = 0;
    673   flagName = NULL;
    674   flagNameShort = NULL;
    675   saveable = false;
    676   defaultValue = 0;
     1042void Option::init(void)
     1043{
     1044  this->value = 0;
     1045  this->flagName = NULL;
     1046  this->flagNameShort = NULL;
     1047  this->saveable = false;
     1048  this->defaultValue = 0;
    6771049
    6781050  static_cast<Widget*>(this)->init();
    6791051
    6801052  return;
     1053}
     1054
     1055/**
     1056   \brief Destroys an Option.
     1057*/
     1058void Option::destroy(void)
     1059{
     1060  PRINTF(4)("deleting the Option Part.\n");
     1061  if (this->flagName)
     1062    delete []this->flagName;
     1063  if (this->flagNameShort)
     1064    delete []this->flagNameShort;
     1065
     1066  static_cast<Widget*>(this)->destroy();
    6811067}
    6821068
     
    6851071   !! Options will be saved if flagname is different from NULL !!
    6861072   \param flagname the Name that will be displayed in the output
    687    \param defaultvalue the default Value for this Option (see definition of defaultvalue
    688 */
    689 void Option::setFlagName (char* flagname, int defaultvalue)
    690 {
    691   if (flagName)
    692     delete flagName;
    693   flagName = new char [strlen(flagname)+1];
    694   strcpy(flagName, flagname);
    695   defaultValue = defaultvalue;
    696 
    697   //  cout << "Set Flagname of " << label << " to " << flagname << endl;
     1073   \param defaultvalue the default Value for this Option(see definition of defaultvalue
     1074*/
     1075void Option::setFlagName(char* flagname, int defaultvalue)
     1076{
     1077  if (this->flagName)
     1078    delete this->flagName;
     1079  this->flagName = new char [strlen(flagname)+1];
     1080  strcpy(this->flagName, flagname);
     1081  this->defaultValue = defaultvalue;
     1082
     1083  //  cout << "Set Flagname of " << this->title << " to " << flagname << endl;
    6981084}
    6991085
    7001086/**
    701     \brief see Option::setFlagName (char* flagname, int defaultvalue)
     1087    \brief see Option::setFlagName(char* flagname, int defaultvalue)
    7021088    \param flagname the Name that will be displayed in the output
    703     \param defaultvalue the default Value for this Option (see definition of defaultvalue
     1089    \param defaultvalue the default Value for this Option(see definition of defaultvalue
    7041090    \param flagnameshort a short flagname to be displayed in the output
    7051091*/
    706 void Option::setFlagName (char* flagname, char* flagnameshort,  int defaultvalue)
    707 {
    708   if (flagName)
    709     delete flagName;
    710   flagName = new char [strlen(flagname)+1];
    711   strcpy(flagName, flagname);
    712 
    713   if (flagNameShort)
    714     delete flagNameShort;
    715   flagNameShort = new char [strlen(flagnameshort)+1];
    716   strcpy(flagNameShort, flagnameshort);
    717   defaultValue = defaultvalue;
    718   //  cout << "Set Flagname of " << label << " to " << flagname << endl;
    719 }
     1092void Option::setFlagName(char* flagname, char* flagnameshort,  int defaultvalue)
     1093{
     1094  if (this->flagName)
     1095    delete []this->flagName;
     1096  this->flagName = new char [strlen(flagname)+1];
     1097  strcpy(this->flagName, flagname);
     1098
     1099  if (this->flagNameShort)
     1100    delete []this->flagNameShort;
     1101  this->flagNameShort = new char [strlen(flagnameshort)+1];
     1102  strcpy(this->flagNameShort, flagnameshort);
     1103  this->defaultValue = defaultvalue;
     1104  //  cout << "Set Flagname of " << this->title << " to " << flagname << endl;
     1105}
     1106
     1107/**
     1108   \brief Sets the saveable-state of the option to true.
     1109*/
     1110void Option::saveability(void)
     1111{
     1112  this->saveable = true;
     1113}
     1114
     1115/**
     1116   \brief Sets the saveable-state of the option.
     1117   \param isSaveable the saveable-state to set.
     1118*/
     1119void Option::saveability(bool isSaveable)
     1120{
     1121  this->saveable = isSaveable;
     1122}
     1123
     1124/**
     1125   \returns The saveable-state.
     1126*/
     1127bool Option::isSaveable(void)
     1128{
     1129  return this->saveable;
     1130}
     1131
     1132#ifdef HAVE_GTK2
     1133/**
     1134    \brief Signal OptionChange writes the Value from the Slider to its Object-Database.
     1135    \param widget The widget(Slider) that has a changed Value
     1136    \param slider the Slider-Object that should receive the change.
     1137*/
     1138gint Option::OptionChange(GtkWidget *widget, Widget* option)
     1139{
     1140  static_cast<Option*>(option)->changeOption();
     1141  flags->setTextFromFlags(Window::mainWindow);  //// must be different !!!
     1142}
     1143#endif /* HAVE_GTK2 */
    7201144
    7211145
     
    7331157
    7341158/**
     1159   \brief destructs a Button.
     1160*/
     1161Button::~Button(void)
     1162{
     1163  this->destroy();
     1164}
     1165
     1166/**
    7351167   \brief Initializes a new Button
    7361168*/
     
    7421174
    7431175#ifdef HAVE_GTK2
    744   widget = gtk_button_new_with_label ("");
    745 #endif /* HAVE_GTK2 */
     1176  widget = gtk_button_new_with_label("");
     1177#endif /* HAVE_GTK2 */
     1178}
     1179
     1180/**
     1181   \brief Destroys a Button.
     1182*/
     1183void Button::destroy(void)
     1184{
     1185  if (this->title)
     1186    PRINTF(3)("deleting the Label: %s\n", this->title);
     1187  else
     1188    PRINTF(3)("deleting the Label.\n");
     1189
     1190  static_cast<Option*>(this)->destroy();
    7461191}
    7471192
     
    7501195   \param title The name the Button should get
    7511196*/
    752 void Button::setTitle (char *title)
    753 {
    754   if (label)
    755     delete []label;
    756   label = new char[strlen(title)+1];
    757   strcpy(label, title);
    758 #ifdef HAVE_GTK2
    759   gtk_button_set_label (GTK_BUTTON(widget), title);
     1197void Button::setTitle(char *title)
     1198{
     1199  if (this->title)
     1200    delete []this->title;
     1201  this->title = new char[strlen(title)+1];
     1202  strcpy(this->title, title);
     1203#ifdef HAVE_GTK2
     1204  gtk_button_set_label(GTK_BUTTON(widget), title);
    7601205#endif /* HAVE_GTK2 */
    7611206}
     
    7651210   not implemented yet
    7661211*/
    767 void Button::redraw ()
    768 {
     1212void Button::redraw(void)
     1213{
     1214}
     1215
     1216/**
     1217   \brief Button can not be changed, optionChange is empty)
     1218
     1219   \todo Actions for non-GTK-mode
     1220*/
     1221void Button::changeOption(void)
     1222{
     1223  // This will possibly be used for ACTIONS !
    7691224}
    7701225
     
    7751230   \param buttonname The name the CheckButton should display.
    7761231*/
    777 CheckButton::CheckButton (char* buttonname)
     1232CheckButton::CheckButton(char* buttonname)
    7781233{
    7791234  this->init();
     
    7811236
    7821237#ifdef HAVE_GTK2
    783   this->connectSignal ("clicked", this->OptionChange);
    784 #endif /* HAVE_GTK2 */
     1238  this->connectSignal("clicked", this->OptionChange);
     1239#endif /* HAVE_GTK2 */
     1240}
     1241
     1242/**
     1243   \brief destructs a CheckButton.
     1244*/
     1245CheckButton::~CheckButton(void)
     1246{
     1247  this->destroy();
    7851248}
    7861249
     
    7901253void CheckButton::init(void)
    7911254{
    792   isOption = 1;
     1255  this->isOption = 1;
    7931256
    7941257  static_cast<Option*>(this)->init();
    7951258
    7961259#ifdef HAVE_GTK2
    797   widget = gtk_check_button_new_with_label ("");
    798 #endif /* HAVE_GTK2 */
     1260  this->widget = gtk_check_button_new_with_label("");
     1261#endif /* HAVE_GTK2 */
     1262}
     1263
     1264/**
     1265   \brief Destroys a CheckButton.
     1266*/
     1267void CheckButton::destroy(void)
     1268{
     1269  if (this->title)
     1270    PRINTF(3)("deleting the CheckButton: %s\n", this->title);
     1271  else
     1272    PRINTF(3)("deleting the CheckButton.\n");
     1273
     1274  static_cast<Option*>(this)->destroy();
    7991275}
    8001276
     
    8051281void CheckButton::setTitle(char* title)
    8061282{
    807   if (label)
    808     delete []label;
    809   label = new char[strlen(title)+1];
    810   strcpy(label, title);
     1283  if (this->title)
     1284    delete []this->title;
     1285  this->title = new char[strlen(title)+1];
     1286  strcpy(this->title, title);
    8111287#ifdef HAVE_GTK2
    8121288  gtk_button_set_label(GTK_BUTTON(widget), title);
     
    8141290}
    8151291
    816 bool CheckButton::isActive()
     1292bool CheckButton::isActive(void)
    8171293{
    8181294#ifdef HAVE_GTK2
     
    8211297}
    8221298
    823 #ifdef HAVE_GTK2
    824 /**
    825     \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database.
    826     \param widget The widget(CheckButton) that has a changed Value
    827     \param checkbutton the CheckButton-Object that should receive the change.
    828 */
    829 gint CheckButton::OptionChange (GtkWidget *widget, Widget* checkbutton)
    830 {
    831   static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget));
    832   flags->setTextFromFlags(orxonoxGUI);   ////// must be different!!!
    833   cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;
    834 }
    835 #endif /* HAVE_GTK2 */
    836 
    837 /**
    838    \brief Redraws the CheckButton (if option has changed).
     1299/**
     1300   \brief Changed the Option, call this Function
     1301*/
     1302void CheckButton::changeOption(void)
     1303{
     1304#ifdef HAVE_GTK2
     1305  this->value =(int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(this->widget));
     1306#else /* HAVE_GTK2 */
     1307  char tmpChar[20];
     1308  cout << "\nPlease give me a new value for " << this->title << " [0,1](defualt:" << this->defaultValue << "): ";
     1309  cin >> tmpChar;
     1310
     1311  if ((this->value = atoi(tmpChar))=!0)
     1312    this->value = 1;
     1313#endif /* HAVE_GTK2 */
     1314  cout << this->title << " set to: " << this->value << endl;
     1315}
     1316
     1317
     1318/**
     1319   \brief Redraws the CheckButton(if option has changed).
    8391320   Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change
    8401321*/
    841 void CheckButton::redraw ()
    842 {
    843 #ifdef HAVE_GTK2
    844   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
     1322void CheckButton::redraw(void)
     1323{
     1324#ifdef HAVE_GTK2
     1325  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(this->widget), value);
    8451326#endif /* HAVE_GTK2 */
    8461327}
     
    8541335   \param end The maximal Value of the slider.
    8551336*/
    856 Slider::Slider (char* slidername, int start, int end)
     1337Slider::Slider(char* slidername, int start, int end)
    8571338{
    8581339  this->init(start, end);
     
    8601341  this->setTitle(slidername);
    8611342#ifdef HAVE_GTK2
    862   this->connectSignal ("value_changed", this->OptionChange);
    863 #endif /* HAVE_GTK2 */
     1343  this->connectSignal("value_changed", this->OptionChange);
     1344#endif /* HAVE_GTK2 */
     1345}
     1346
     1347/**
     1348   \brief destructs a Slider.
     1349*/
     1350Slider::~Slider(void)
     1351{
     1352  this->destroy();
    8641353}
    8651354
    8661355/**
    8671356   \brief Initializes a Slider with start and end Values
    868    params: see Slider::Slider (char* slidername, int start, int end)
     1357   params: see Slider::Slider(char* slidername, int start, int end)
    8691358*/
    8701359void Slider::init(int start, int end)
    8711360{
    872   isOption = 2;
     1361  this->isOption = 2;
    8731362
    8741363  static_cast<Option*>(this)->init();
    8751364
    876 #ifdef HAVE_GTK2
    877  widget = gtk_hscale_new_with_range (start, end, 5);
    878 #endif /* HAVE_GTK2 */
     1365  this->start = start;
     1366  this->end = end;
     1367#ifdef HAVE_GTK2
     1368 widget = gtk_hscale_new_with_range(this->start, this->end, 5);
     1369#endif /* HAVE_GTK2 */
     1370}
     1371
     1372/**
     1373   \brief Destroys a Slider.
     1374*/
     1375void Slider::destroy(void)
     1376{
     1377  if (this->title)
     1378    PRINTF(3)("deleting the Slider: %s\n", this->title);
     1379  else
     1380    PRINTF(3)("deleting the Slider.\n");
     1381
     1382  static_cast<Option*>(this)->destroy();
     1383
    8791384}
    8801385
     
    8851390void Slider::setTitle(char* title)
    8861391{
    887   if (label)
    888     delete []label;
    889   label = new char[strlen(title)+1];
    890   strcpy(label, title);
     1392  if (this->title)
     1393    delete []this->title;
     1394  this->title = new char[strlen(title)+1];
     1395  strcpy(this->title, title);
    8911396}
    8921397
     
    9001405}
    9011406
    902 #ifdef HAVE_GTK2
    903 /**
    904     \brief Signal OptionChange writes the Value from the Slider to its Object-Database.
    905     \param widget The widget(Slider) that has a changed Value
    906     \param slider the Slider-Object that should receive the change.
    907 */
    908 gint Slider::OptionChange (GtkWidget *widget, Widget* slider)
    909 {
    910   static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget));
    911   flags->setTextFromFlags(orxonoxGUI);  //// must be different !!!
    912   cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl;
    913 }
    914 #endif /* HAVE_GTK2 */
    915 
    9161407/**
    9171408   \brief Redraws the widget
    918    Example: see void CheckButton::redraw ()
    919 */
    920 void Slider::redraw ()
    921 {
    922 #ifdef HAVE_GTK2
    923   gtk_range_set_value (GTK_RANGE (widget), value);
    924 #endif /* HAVE_GTK2 */
     1409   Example: see void CheckButton::redraw(void)
     1410*/
     1411void Slider::redraw(void)
     1412{
     1413#ifdef HAVE_GTK2
     1414  gtk_range_set_value(GTK_RANGE(this->widget), value);
     1415#endif /* HAVE_GTK2 */
     1416}
     1417
     1418/**
     1419   \brief Changed the Option, call this Function
     1420*/
     1421void Slider::changeOption(void)
     1422{
     1423#ifdef HAVE_GTK2
     1424  this->value =(int)gtk_range_get_value(GTK_RANGE(this->widget));
     1425#else /* HAVE_GTK2 */
     1426  char tmpChar[20];
     1427  cout << "\nPlease give me a new value for " << this->title << " [" <<this->start << "-" << this->end << "](defualt:" << this->defaultValue << "): ";
     1428  cin >> tmpChar;
     1429
     1430  if ((this->value = atoi(tmpChar))> this->end)
     1431    this->value = this->end;
     1432  if (this->value <= this->start)
     1433    this->value = this->start;
     1434#endif /* HAVE_GTK2 */
     1435  cout << this->title << " set to: " << this->value << endl;
    9251436}
    9261437
     
    9331444    \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!!
    9341445*/
    935 Menu::Menu (char* menuname, ...)
     1446Menu::Menu(char* menuname, ...)
    9361447{
    9371448  this->init();
     
    9411452
    9421453#ifdef HAVE_GTK2             /////////////////////// REINPLEMENT
    943   va_start (itemlist, menuname);
    944   while (strcmp (itemName = va_arg (itemlist, char*), "lastItem"))
     1454  va_start(itemlist, menuname);
     1455  while(strcmp(itemName = va_arg(itemlist, char*), "lastItem"))
    9451456    {
    9461457      this->addItem(itemName);
     
    9501461
    9511462#ifdef HAVE_GTK2
    952   gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
    953   this->connectSignal ("changed", this->OptionChange);
    954 #endif /* HAVE_GTK2 */
     1463  gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu);
     1464  this->connectSignal("changed", this->OptionChange);
     1465#endif /* HAVE_GTK2 */
     1466}
     1467
     1468/**
     1469   \brief destructs a Menu.
     1470*/
     1471Menu::~Menu(void)
     1472{
     1473  this->destroy();
    9551474}
    9561475
     
    9601479void Menu::init(void)
    9611480{
    962   isOption = 2;
     1481  this->isOption = 2;
    9631482
    9641483  static_cast<Option*>(this)->init();
    9651484
    9661485#ifdef HAVE_GTK2
    967   widget = gtk_option_menu_new ();
    968   menu = gtk_menu_new ();
    969 #endif /* HAVE_GTK2 */
    970 
    971 }
     1486  this->widget = gtk_option_menu_new();
     1487  this->menu = gtk_menu_new();
     1488#endif /* HAVE_GTK2 */
     1489
     1490}
     1491
     1492/**
     1493   \brief Destroys a Menu.
     1494*/
     1495void Menu::destroy(void)
     1496{
     1497  if (this->title)
     1498    PRINTF(3)("deleting the Menu: %s\n", this->title);
     1499  else
     1500    PRINTF(3)("deleting the Menu.\n");
     1501  //! \todo destroy menu
     1502 
     1503  static_cast<Option*>(this)->destroy();
     1504}
     1505
    9721506
    9731507/**
     
    9771511void Menu::setTitle(char* title)
    9781512{
    979   if (label)
    980     delete []label;
    981   label = new char[strlen(title)+1];
    982   strcpy(label, title);
     1513  if (this->title)
     1514    delete []this->title;
     1515  this->title = new char[strlen(title)+1];
     1516  strcpy(this->title, title);
    9831517}
    9841518
     
    9861520   \brief appends a new Item to the Menu-List.
    9871521   \param itemName the itemName to be appendet.
    988 */
    989 void Menu::addItem (char* itemName)
    990 {
    991 #ifdef HAVE_GTK2
    992   item = gtk_menu_item_new_with_label (itemName);
    993   gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
    994 #endif /* HAVE_GTK2 */
    995 }
    996 
    997 #ifdef HAVE_GTK2
    998 /**
    999     \brief Signal OptionChange writes the Value from the Menu to its Object-Database.
    1000     \param widget The widget(Menu) that has a changed Value
    1001     \param menu the Menu-Object that should receive the change.
    1002 */
    1003 gint Menu::OptionChange (GtkWidget *widget, Widget* menu)
    1004 {
    1005   static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget));
    1006   flags->setTextFromFlags(orxonoxGUI); //// must be different !!!
    1007   cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl;
    1008 }
    1009 #endif /* HAVE_GTK2 */
     1522
     1523   \todo make the item-list readable without GTK
     1524*/
     1525void Menu::addItem(char* itemName)
     1526{
     1527#ifdef HAVE_GTK2
     1528  this->item = gtk_menu_item_new_with_label(itemName);
     1529  gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->item);
     1530#endif /* HAVE_GTK2 */
     1531}
    10101532
    10111533/**
    10121534   \brief Redraws the widget
    1013    Example: see void CheckButton::redraw ()
    1014 */
    1015 void Menu::redraw ()
    1016 {
    1017 #ifdef HAVE_GTK2
    1018  gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);
    1019 #endif /* HAVE_GTK2 */
    1020 }
     1535   Example: see void CheckButton::redraw(void)
     1536*/
     1537void Menu::redraw(void)
     1538{
     1539#ifdef HAVE_GTK2
     1540 gtk_option_menu_set_history(GTK_OPTION_MENU(this->widget), this->value);
     1541#endif /* HAVE_GTK2 */
     1542}
     1543
     1544/**
     1545   \brief Changed the Option, call this Function
     1546*/
     1547void Menu::changeOption(void)
     1548{
     1549#ifdef HAVE_GTK2
     1550  this->value =(int)gtk_option_menu_get_history(GTK_OPTION_MENU(this->widget));
     1551#else /* HAVE_GTK2 */
     1552  char tmpChar[20];
     1553  cout << "\nPlease give me a new value for " << this->title << "(defualt:" << this->defaultValue << "): ";
     1554  cin >> tmpChar;
     1555  this->value = atoi(tmpChar);
     1556
     1557#endif /* HAVE_GTK2 */
     1558  cout << this->title << " set to: " << this->value << endl;
     1559}
     1560
     1561/* OPTION LABEL */
    10211562
    10221563/**
    10231564   \brief Creates a new OptionLabel with a LabelName and a Value.
    10241565   \param label The name of the OptionLabel.
    1025    \param value The Value of the OptionLabel (what will be displayed).
     1566   \param value The Value of the OptionLabel(what will be displayed).
    10261567*/
    10271568OptionLabel::OptionLabel(char* label, char* value)
    10281569{
    1029   init();
    1030   setTitle(label);
    1031   setValue(value);
     1570  this->init();
     1571  this->setTitle(label);
     1572  this->setValue(value);
     1573}
     1574
     1575/**
     1576   \brief destructs an OptionLabel.
     1577*/
     1578OptionLabel::~OptionLabel(void)
     1579{
     1580  this->destroy();
    10321581}
    10331582
     
    10371586void OptionLabel::init(void)
    10381587{
     1588  this->isOption = 5;
    10391589  static_cast<Option*>(this)->init();
    1040   isOption = 5;
     1590
    10411591  cValue = NULL;
    10421592
    10431593#ifdef HAVE_GTK2
    1044   widget = gtk_label_new ("");
    1045 #endif /* HAVE_GTK2 */
    1046 }
     1594  this->widget = gtk_label_new("");
     1595#endif /* HAVE_GTK2 */
     1596}
     1597
     1598/**
     1599   \brief Destroys a OptionLabel.
     1600*/
     1601void OptionLabel::destroy(void)
     1602{
     1603  if (this->title)
     1604    PRINTF(3)("deleting the OptionLabel: %s\n", this->title);
     1605  else
     1606    PRINTF(3)("deleting the OptionLabel.\n");
     1607  if (this->cValue)
     1608    delete []this->cValue;
     1609
     1610  static_cast<Option*>(this)->destroy();
     1611}
     1612
    10471613
    10481614/**
     
    10521618void OptionLabel::setValue(char* newValue)
    10531619{
    1054   if (cValue)
    1055     delete cValue;
    1056   cValue = new char [strlen(newValue)+1];
    1057   strcpy(cValue, newValue);
    1058 #ifdef HAVE_GTK2
    1059   gtk_label_set_text (GTK_LABEL (widget), cValue);
     1620  if (this->cValue)
     1621    delete []this->cValue;
     1622  this->cValue = new char [strlen(newValue)+1];
     1623  strcpy(this->cValue, newValue);
     1624#ifdef HAVE_GTK2
     1625  gtk_label_set_text(GTK_LABEL(this->widget), this->cValue);
    10601626#endif /* HAVE_GTK2 */
    10611627}
     
    10671633void OptionLabel::setTitle(char* title)
    10681634{
    1069   if (label)
    1070     delete []label;
    1071   label = new char [strlen(title)+1];
    1072   strcpy(label, title);
    1073 #ifdef HAVE_GTK2
    1074   gtk_label_set_text (GTK_LABEL (widget), title);
    1075 #endif /* HAVE_GTK2 */
    1076 }
    1077 
    1078 /**
    1079    \brief Redraws an OptionLabel (not implemented yet, but it works).
     1635  if (this->title)
     1636    delete []this->title;
     1637  this->title = new char [strlen(title)+1];
     1638  strcpy(this->title, title);
     1639  this->redraw();
     1640}
     1641
     1642/**
     1643   \brief Redraws an OptionLabel(not implemented yet, but it works).
    10801644*/
    10811645void OptionLabel::redraw(void)
    10821646{
    1083  
    1084 }
     1647#ifdef HAVE_GTK2
     1648  gtk_label_set_text(GTK_LABEL(widget), title);
     1649#endif /* HAVE_GTK2 */
     1650}
     1651
     1652/**
     1653   \brief Changed the Option, call this Function
     1654*/
     1655void OptionLabel::changeOption(void)
     1656{
     1657#ifdef HAVE_GTK2
     1658  this->cValue =(char*)gtk_label_get_text(GTK_LABEL(this->widget));
     1659#else /* HAVE_GTK2 */
     1660  cout << "\nPlease give me a new input for " << this->title << ": ";
     1661  cin >> this->cValue;
     1662#endif /* HAVE_GTK2 */
     1663  cout << this->title << " set to: " << this->cValue << endl;
     1664}
     1665
    10851666
    10861667/**
     
    10881669   You migth consider adding Label::setTitle with this.
    10891670*/
    1090 Label::Label ()
     1671Label::Label(void)
    10911672{
    10921673  this->init();
     
    10971678   \param text The text to be displayed.
    10981679*/
    1099 Label:: Label (char* text)
     1680Label:: Label(char* text)
    11001681{
    11011682  this->init();
    1102   this->setText(text);
     1683  this->setTitle(text);
     1684}
     1685
     1686/**
     1687   \brief destructs a Label.
     1688*/
     1689Label::~Label(void)
     1690{
     1691  this->destroy();
    11031692}
    11041693
     
    11081697void Label::init(void)
    11091698{
    1110   isOption = 0;
     1699  this->isOption = 0;
    11111700
    11121701  static_cast<Widget*>(this)->init();
    11131702
    11141703#ifdef HAVE_GTK2
    1115   widget = gtk_label_new ("");
    1116   gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    1117 #endif /* HAVE_GTK2 */
     1704  this->widget = gtk_label_new("");
     1705  gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE);
     1706#endif /* HAVE_GTK2 */
     1707}
     1708
     1709/**
     1710   \brief Destroys a Label.
     1711*/
     1712void Label::destroy(void)
     1713{
     1714  if (this->title)
     1715    PRINTF(3)("deleting the Label: %s\n", this->title);
     1716  else
     1717    PRINTF(3)("deleting the Label.\n");
     1718
     1719  static_cast<Widget*>(this)->destroy();
    11181720}
    11191721
     
    11221724   \param text The text to be inserted into the Label.
    11231725*/
    1124 void Label::setText (char* text)
    1125 {
    1126   if (label)
    1127     delete []label;
    1128   label = new char[strlen(text)+1];
    1129   strcpy(label, text);
    1130 #ifdef HAVE_GTK2
    1131   gtk_label_set_text (GTK_LABEL (this->widget), text);
    1132 #endif /* HAVE_GTK2 */
    1133 }
     1726void Label::setTitle(char* text)
     1727{
     1728  if (this->title)
     1729    delete []this->title;
     1730  this->title = new char[strlen(text)+1];
     1731  strcpy(this->title, text);
     1732#ifdef HAVE_GTK2
     1733  gtk_label_set_text(GTK_LABEL(this->widget), this->title);
     1734#endif /* HAVE_GTK2 */
     1735}
     1736
     1737/**
     1738   \brief ereases the Text of a Label
     1739*/
     1740void Label::ereaseText(void)
     1741{
     1742  this->setTitle("");
     1743}
     1744
     1745/**
     1746    \brief appends some Text to a Label
     1747    \param textToAppend The text that will be appended to this Label
     1748*/
     1749void Label::appendText(char* textToAppend)
     1750{
     1751  if (this->title)
     1752    {
     1753      char* tmpTitle = new char[strlen(this->title)+strlen(textToAppend)+1];
     1754      strcpy(tmpTitle, title); 
     1755      strcat(tmpTitle, textToAppend);
     1756      delete []this->title;
     1757      this->title = tmpTitle;
     1758    }
     1759  else
     1760    {
     1761      this->title = new char[strlen(textToAppend)];
     1762    }
     1763 
     1764#ifdef HAVE_GTK2
     1765  gtk_label_set_text(GTK_LABEL(this->widget), title);
     1766#endif /* HAVE_GTK2 */
     1767}
     1768
     1769/**
     1770    \brief Appends some integer to the Label
     1771    \param intToAppend The Int that will be added.
     1772   
     1773    it does this by just converting the int into a char* and send it to appendText
     1774*/
     1775void Label::appendInt(int intToAppend)
     1776{
     1777  char append [32];
     1778  sprintf(append, "%d", intToAppend);
     1779  this->appendText(append);
     1780}
     1781
    11341782
    11351783/**
     
    11371785   \return The Text the Label holds.
    11381786*/
    1139 char* Label::getText ()
    1140 {
    1141   return label;
    1142 }
     1787char* Label::getText(void)
     1788{
     1789  return this->title;
     1790}
     1791
     1792/**
     1793   \brief Creates a new ProgressBar.
     1794*/
     1795ProgressBar::ProgressBar(void)
     1796{
     1797  this->init();
     1798}
     1799
     1800/**
     1801   \brief Creates a new ProgressBar.
     1802   \param label The name you want to get the ProgressBar.
     1803*/
     1804ProgressBar::ProgressBar(char* label)
     1805{
     1806  this->init();
     1807  this->setTitle(label);
     1808}
     1809
     1810/**
     1811   \brief destructs a ProgressBar
     1812*/
     1813ProgressBar::~ProgressBar(void)
     1814{
     1815  this->destroy();
     1816}
     1817
     1818/**
     1819   \brief Initializes a ProgressBar
     1820*/
     1821void ProgressBar::init(void)
     1822{
     1823  this->isOption = 0;
     1824  this->progress = 0.0;
     1825  this->totalSize = 0.0;
     1826
     1827  static_cast<Widget*>(this)->init();
     1828#ifdef HAVE_GTK2
     1829  this->adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
     1830  this->widget = gtk_progress_bar_new_with_adjustment(this->adjustment);
     1831#endif /* HAVE_GTK2 */
     1832}
     1833
     1834/**
     1835   \brief Destroys a ProgressBar.
     1836*/
     1837void ProgressBar::destroy(void)
     1838{
     1839  if (this->title)
     1840    PRINTF(3)("deleting the ProgressBar: %s\n", this->title);
     1841  else
     1842    PRINTF(3)("deleting the ProgressBar.\n");
     1843
     1844  static_cast<Widget*>(this)->destroy();
     1845}
     1846
     1847/**
     1848   \brief Sets a ned Title to the ProgressBar.
     1849   \param title The now title of the ProgressBar.
     1850*/
     1851void ProgressBar::setTitle(char* title)
     1852{
     1853  if (this->title)
     1854    delete []this->title;
     1855  this->title = new char [strlen(title)+1];
     1856  strcpy(this->title, title);
     1857}
     1858
     1859/**
     1860   \brief Sets the Total size of the Bar.(ex. The maximum one can download)
     1861*/
     1862void ProgressBar::setTotalSize(double totalSize)
     1863{
     1864  this->totalSize = totalSize;
     1865}
     1866
     1867/**
     1868   \brief Sets the progress maximum is this->totalSize
     1869*/
     1870void ProgressBar::setProgress(double progress)
     1871{
     1872  this->progress = progress;
     1873
     1874  if (this->progress > this->totalSize)
     1875    this->progress = this->totalSize;
     1876
     1877#ifdef HAVE_GTK2
     1878  gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize);
     1879#endif /* HAVE_GTK2 */
     1880  PRINTF(3)("Progress: %f\n", this->progress*100.0/this->totalSize);
     1881}
     1882
     1883/**
     1884    \brief returns the Progress Status
     1885*/
     1886double ProgressBar::getProgress(void)
     1887{
     1888  return this->progress;
     1889}
     1890
     1891/* IMAGE */
     1892
     1893/**
     1894   \brief Creates a new Image
     1895   \param imagename the location of the Image on the Hard Disc
     1896*/
     1897Image::Image(char* imagename)
     1898{
     1899  this->init();
     1900  if (this->title)
     1901    delete []this->title;
     1902  this->title = new char[strlen(imagename)+1];
     1903  strcpy(this->title, imagename);
     1904
     1905#ifdef HAVE_GTK2
     1906  widget = gtk_image_new_from_file(imagename);
     1907#endif /* HAVE_GTK2 */
     1908}
     1909
     1910/**
     1911   \brief destructs an Image.
     1912*/
     1913Image::~Image(void)
     1914{
     1915  this->destroy();
     1916}
     1917
     1918/**
     1919    \brief Initializes a new Image
     1920*/
     1921void Image::init(void)
     1922{
     1923  isOption = 0;
     1924
     1925  static_cast<Widget*>(this)->init();
     1926}
     1927
     1928/**
     1929   \brief Destroys a Image.
     1930*/
     1931void Image::destroy(void)
     1932{
     1933  if (this->title)
     1934    PRINTF(3)("deleting the Image: %s\n", this->title);
     1935  else
     1936    PRINTF(3)("deleting the Image.\n");
     1937
     1938  static_cast<Widget*>(this)->destroy();
     1939}
     1940
     1941/**
     1942   \brief Sets a ned Title to the Image.
     1943   \param title The now title of the OptionLabel.
     1944*/
     1945void Image::setTitle(char* title)
     1946{
     1947  if (this->title)
     1948    delete []this->title;
     1949  this->title = new char [strlen(title)+1];
     1950  strcpy(this->title, title);
     1951}
Note: See TracChangeset for help on using the changeset viewer.