Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2605 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Oct 19, 2004, 10:39:44 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: generalized: destructor, added label to class Widget, down is now a method of Packer, isOpen added for Windows

Location:
orxonox/trunk/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/gui/orxonox_gui.cc

    r2595 r2605  
    9999
    100100/* WIDGET */
     101
     102/**
     103 \brief deletes any given Widget
     104 This is still pretty crappy.
     105*/
     106Widget::~Widget()
     107{
     108  //  cout << "hiding: " <<this->label <<"\n";
     109  this->hide();
     110  //  cout << "check if Packer: "<<this->label <<"\n";
     111  if (this->is_option < 0)
     112    {
     113      //  cout << "get Down "<<this->label <<"\n";
     114      static_cast<Packer*>(this)->down->~Widget();
     115    }
     116  //  cout << "next != NULL?: " <<this->label <<"\n";
     117  if (this->next != NULL)
     118    this->next->~Widget();
     119  cout << "delete Widget: " <<this->label <<"\n";
     120  //  delete widget;
     121}
     122
    101123/**
    102124 * Initializes a widget.
     
    108130}
    109131
     132/**
     133 * makes the widget visible.
     134 */
     135void Widget::show()
     136{
     137  gtk_widget_show (this->widget);
     138}
     139
     140/**
     141 * hides the widget.
     142 */
     143void Widget::hide()
     144{
     145  gtk_widget_hide (this->widget);
     146}
     147
     148/**
     149 \brief Sets the resolution of a specific widget to the given size.
     150 \param width the width of the widget to set.
     151 \param height the height of the widget to set.
     152*/
     153void Widget::setSize(int width, int height)
     154{
     155  gtk_widget_set_usize (this->widget, width, height);
     156}
     157
    110158/**
    111159 * Connect any signal to any given Sub-widget
     
    130178{
    131179  g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
    132 }
    133 
    134 
    135 /**
    136  * Function to Shows a specific widget.
    137  */
    138 void Widget::show()
    139 {
    140   gtk_widget_show (this->widget);
    141180}
    142181
     
    149188{
    150189  function(this);
    151   switch (this->is_option)
     190  if (this->is_option < 0)
    152191    {
    153     case -1:
    154       static_cast<Container*>(this)->down->walkThrough (function);
    155       break;
    156     case -2:
    157       static_cast<Box*>(this)->down->walkThrough (function);
    158       break;
     192      static_cast<Packer*>(this)->down->walkThrough (function);
    159193    }
    160194
     
    163197}
    164198
    165 
    166199/**
    167200 * This is for listing the option of "widget"
     
    171204{
    172205  if (widget->is_option >= 1)
    173     cout << static_cast<Option*>(widget)->option_name <<" is : " << static_cast<Option*>(widget)->value <<endl;
     206    cout << static_cast<Option*>(widget)->label <<" is : " << static_cast<Option*>(widget)->value <<endl;
    174207}
    175208
     
    184217}
    185218
    186 /* CONTAINERS*/
     219//void deleteWidget(Widget* lastWidget)
     220
     221
     222/* PACKERS */
     223
     224/**
     225 * Initializes a Packer.
     226 * nothing to do here
     227 */
     228void Packer::init (void)
     229{
     230  return;
     231}
     232
     233/* CONTAINERS */
    187234
    188235/**
     
    234281
    235282/**
    236  * Destoying a Window (very BAD implemented).
    237  * For now it just hides the window.
    238  */
    239 Window::~Window ()
    240 {
    241   gtk_widget_hide (widget);
    242 }
    243 
    244 /**
    245283 *initializes a new Window
    246284 */
    247285void Window::init()
    248286{
     287  isOpen = true;
    249288  is_option = -1;
     289  label = "";
    250290  next = NULL;
    251291  down = NULL;
     
    263303void Window::showall ()
    264304{
     305  isOpen = true;
    265306  gtk_widget_show_all  (widget);
    266307}
     
    272313void Window::setTitle (char* title)
    273314{
     315  label=title;
    274316  gtk_window_set_title (GTK_WINDOW (widget), title);
    275317}
     
    311353}
    312354
    313 /**
    314  * Destroys given Frame (not implemented yet)
    315  */
    316 Frame::~Frame ()
    317 {
    318 }
    319 
    320355/**
    321356 * Initializes a new Frame with default settings
     
    324359{
    325360  is_option = -1;
     361  label = "";
    326362  next = NULL;
    327363  down = NULL;
     
    336372void Frame::setTitle (char* title)
    337373{
     374  label = title;
    338375  gtk_frame_set_label (GTK_FRAME (widget), title);
    339376}
     
    365402{
    366403  is_option = -1;
     404  label = "eventBox";
    367405  next = NULL;
    368406  down = NULL;
     
    378416void EventBox::setTitle (char* title)
    379417{
    380 
    381 }
    382 
    383 /**
    384  * Destructs an EventBox (not Implemented)
    385  */
    386 EventBox::~EventBox ()
    387 {
    388 }
    389 
     418  label = title;
     419}
    390420
    391421/* BOX */
     
    409439
    410440/**
    411  * Destroys given Box (not implemented yet)
    412  */
    413 Box::~Box ()
    414 {
    415 }
    416 
    417 /**
    418441 * Initializes a new Box with type boxtype
    419442 \param boxtype see Box(char boxtype)
     
    422445{
    423446  is_option = -2;
     447  label = "box";
    424448  next = NULL;
    425449  down = NULL;
     
    469493  this->init();
    470494  widget = gtk_image_new_from_file (imagename);
     495  label = imagename;
    471496}
    472497
     
    477502{
    478503  is_option = 0;
     504  label = "";
    479505  next = NULL;
    480506}
     
    501527  flag_name = flagname;
    502528  default_value = defaultvalue;
    503   cout << "Set Flagname of " << option_name << " to " << flagname << endl;
     529  cout << "Set Flagname of " << label << " to " << flagname << endl;
    504530}
    505531
     
    515541  flag_name_short = flagnameshort;
    516542  default_value = defaultvalue;
    517   cout << "Set Flagname of " << option_name << " to " << flagname << endl;
     543  cout << "Set Flagname of " << label << " to " << flagname << endl;
    518544}
    519545
     
    539565  value = 0;
    540566  next = NULL;
    541   option_name ="";
     567  label ="";
    542568  flag_name = "";
    543569  flag_name_short = "";
     
    552578void Button::setTitle (char *title)
    553579{
    554   option_name = title;
     580  label = title;
    555581  gtk_button_set_label (GTK_BUTTON(widget), title);
    556582}
     
    578604}
    579605
    580 /**
    581  * Destructs a CheckButton (not Implemented yet).
    582  */
    583 CheckButton::~CheckButton()
    584 {
    585 }
    586 
    587606/**
    588607 * Initiali a new CheckButton with default settings
     
    593612  value = 0;
    594613  next = NULL;
    595   option_name = "";
     614  label = "";
    596615  flag_name = "";
    597616  flag_name_short = "";
     
    606625void CheckButton::setTitle(char* title)
    607626{
    608   option_name = title;
     627  label = title;
    609628  gtk_button_set_label(GTK_BUTTON(widget), title);
    610629}
     
    620639  static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget));
    621640  flags->setTextFromFlags(orxonoxGUI);
    622   cout << static_cast<CheckButton*>(checkbutton)->option_name << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;
     641  cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;
    623642}
    624643
     
    649668
    650669/**
    651  * Destructs a Slider (not implemented yet)
    652  */
    653 Slider::~Slider()
    654 {
    655 }
    656 
    657 /**
    658670 * Initializes a Slider with start and end Values
    659671 * params: see Slider::Slider (char* slidername, int start, int end)
     
    664676  value = 0;
    665677  next = NULL;
    666   option_name = "";
     678  label = "";
    667679  flag_name = "";
    668680  flag_name_short = "";
     
    677689void Slider::setTitle(char* title)
    678690{
    679   option_name = title;
     691  label = title;
    680692}
    681693
     
    698710  static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget));
    699711  flags->setTextFromFlags(orxonoxGUI);
    700   cout << static_cast<Slider*>(slider)->option_name << " set to: "<< static_cast<Slider*>(slider)->value << endl;
     712  cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl;
    701713}
    702714
     
    758770void Menu::setTitle(char* title)
    759771{
    760   option_name = title;
     772  label = title;
    761773}
    762774
     
    779791  static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget));
    780792  flags->setTextFromFlags(orxonoxGUI);
    781   cout << static_cast<Menu*>(menu)->option_name << " changed to : " << static_cast<Menu*>(menu)->value << endl;
     793  cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl;
    782794}
    783795
     
    806818Label:: Label (char* text)
    807819{
     820  this->init();
     821  this->setText(text);
     822}
     823
     824/**
     825 * initializes a new Label
     826 */
     827void Label::init(void)
     828{
    808829  is_option = 0;
    809   next = NULL;
    810   widget = gtk_label_new (text);
    811   gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    812 }
    813 
    814 /**
    815  * Destructs a Label
    816  */
    817 Label::~Label ()
    818 {}
    819 
    820 /**
    821  * initializes a new Label
    822  */
    823 void Label::init(void)
    824 {
    825   is_option = 0;
     830  label = "";
    826831  next = NULL;
    827832  widget = gtk_label_new ("");
    828   gtk_widget_set_usize (widget, 260, 60);
    829833  gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    830834}
     
    836840void Label::setText (char * text)
    837841{
     842  label = text;
    838843  gtk_label_set_text (GTK_LABEL (this->widget), text);
    839844}
  • orxonox/trunk/gui/orxonox_gui.h

    r2595 r2605  
    3939 private:
    4040 public:
     41  ~Widget ();
     42
    4143  Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next
    4244  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
    4345  virtual void init(void);
    4446  int is_option; //!< with this Paramenter one can set the IsOption type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option
    45   enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; //!< defines is_option states
     47  /**
     48     \briefdefines is_option states
     49  */
     50  enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2};
     51  char* label; //!< The name of the Widget. Some do display it, Options need it to save;
    4652  void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
    4753  void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
    4854  void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *));
    4955  void show ();
     56  void hide ();
     57  void setSize(int width, int height);
    5058
    5159  void walkThrough (void (*function)(Widget*));
     
    5563};
    5664
     65//! This is a Packer Object, which has the ability to Pack other Widgets into itself.
     66class Packer : public Widget
     67{
     68 public:
     69  Widget* down; //!< this points to the Widget below this.
     70
     71  void init(void);
     72};
    5773
    5874//! This is a Container Class, it can contain one sub-Widget: down.
     
    6278 * The derived classes of Container can be displayed
    6379*/
    64 class Container : public Widget
     80class Container : public Packer
    6581{
    6682 private:
    6783  int borderwidth;
    6884  int policy;
    69   char* label;
    70  
    71  public:
    72   void init(void);
    73   Widget* down; //!< this points to the Widget below this.
     85 
     86 public:
     87  void init(void);
    7488  //  void setBorderWidth (int borderwidth);
    7589  //  virtual void setTitle (char* title) = 0;
     
    8498class Window : public Container
    8599{
     100 private:
     101  bool isOpen;
    86102 public:
    87103  Window (char* windowName);
    88104  Window (void);
    89   ~Window ();
    90105  void init ();
    91106 
     
    105120  Frame (char* frameName);
    106121  Frame (void);
    107   ~Frame ();
    108122  void init(void);
    109123 
     
    120134  EventBox (char* eventBoxName);
    121135  EventBox (void);
    122   ~EventBox ();
    123136  void init(void);
    124137 
     
    132145 * A Box is always filled left->right (horizontally) or up->down (vertically)
    133146 */
    134 class Box : public Widget
     147class Box : public Packer
    135148{
    136149 public:
    137150  Box (void);
    138151  Box (char boxtype);
    139   ~Box (void);
    140152  void init(char boxtype);
    141153
    142   Widget* down; //!< the Lower Widget of a Box.
    143154  void fill (Widget* lowerWidget);
    144155
     
    154165 public:
    155166  Image (char* imgaename);
    156   ~Image ();
    157167  void init(void);
    158168};
     
    169179
    170180  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
    171   char* option_name; //!< options have a name, that can be displayed around them
    172181  char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
    173182  char* flag_name_short; //!< like flag_name but shorter
     
    187196 public:
    188197  Button (char* buttonname);
    189   ~Button (void);
    190198  void init(void);
    191199
     
    202210 public:
    203211  CheckButton (char* buttonname);
    204   ~CheckButton (void);
    205212  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
    206213 
     
    219226 public:
    220227  Slider (char* slidername,int start, int end);
    221   ~Slider ();
    222228  void init(int start, int end);
    223229
     
    239245 public:
    240246  Menu (char* menuname, ...);
    241   ~Menu ();
    242247  void init(void);
    243248
     
    255260  Label ();
    256261  Label (char* text);
    257   ~Label ();
    258262  void init(void);
    259263 
  • orxonox/trunk/gui/orxonox_gui_banner.cc

    r2595 r2605  
    8888{
    8989  logoWindowIsOpen = 0;
    90   logoWindow->~Window();
     90  logoWindow->hide();
    9191}
    9292
  • orxonox/trunk/gui/orxonox_gui_exec.cc

    r2595 r2605  
    124124        char Buffer[256];
    125125        char* space2under;
    126         sprintf (Buffer, "%s", static_cast<Option*>(widget)->option_name);
     126        sprintf (Buffer, "%s", static_cast<Option*>(widget)->label);
    127127        if (strchr (Buffer, '_'))
    128128          cout << "Warning Optionname" << Buffer << " is not Valid for Saving, because it includes an underscore" << endl;
     
    189189{
    190190  if (widget->is_option >= 1)
    191     if (!strcmp (static_cast<Option*>(widget)->option_name, variableName))
     191    if (!strcmp (static_cast<Option*>(widget)->label, variableName))
    192192        static_cast<Option*>(widget)->value = variableValue;
    193193
  • orxonox/trunk/gui/orxonox_gui_flags.cc

    r2595 r2605  
    3939
    4040  flagsLabel = new Label ();
     41  flagsLabel->setSize (260,60);
    4142  flagsBox->fill (flagsLabel);
    4243  shortFlags = new CheckButton ("shortFlags");
Note: See TracChangeset for help on using the changeset viewer.