Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2586 in orxonox.OLD for orxonox/trunk/gui/orxonox_gui.cc


Ignore:
Timestamp:
Oct 16, 2004, 6:47:41 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: added init-routine to all the Widget-type objects. (Menu is to come)

File:
1 edited

Legend:

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

    r2584 r2586  
    100100/* WIDGET */
    101101
     102void Widget::init()
     103{
     104  return;
     105}
     106
    102107void Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))
    103108{
     
    133138void Widget::walkThrough (void (*function)(Widget*))
    134139{
     140  /**
     141   * Moves Through all the Widgets downwards from this and executes the function on them.
     142   * function must be of type void and takes a Widget* as an Input.
     143   */
    135144  function(this);
    136145  switch (this->is_option)
     
    152161{
    153162  /**
    154    * This is For listing all the Options witch are located beneath this Widget.
     163   * This is for listing the option of "widget"
    155164   */
    156165  if (widget->is_option >= 1)
     
    161170{
    162171  /**
    163    * This is For listing all the Options witch are located beneath this Widget.
     172   * This is for setting the option of "widget"
    164173   */
    165174  if (widget->is_option >= 1)
     
    168177
    169178/* CONTAINERS*/
    170 
     179void Container::init (void)
     180{
     181  return;
     182}
    171183void Container::fill (Widget *lowerWidget)
    172184{
    173185  /**
    174    * fill any given Container with a lowerwidet
     186   * fills any given Container with a lowerwidet
    175187   */
    176188  if (this->down == NULL)
     
    192204   * Creating a Window
    193205   */
     206  this->init();
     207}
     208
     209Window::Window (char* windowName)
     210{
     211  /**
     212   * Creating a Window with passing a name
     213   */
     214  this->init();
     215  this->setTitle (windowName);
     216}
     217
     218Window::~Window ()
     219{
     220  /**
     221   * Destoying a Window (very BAD implemented)
     222   */
     223  gtk_widget_hide (widget);
     224 
     225}
     226
     227void Window::init()
     228{
     229  /**
     230  *initializes a new Window
     231  */
    194232  is_option = -1;
    195233  next = NULL;
     
    197235  widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    198236  gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE);
    199   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    200 }
    201 
    202 Window::Window (char* windowName)
    203 {
    204   /**
    205    * Creating a Window with passing a name
    206    */
    207   is_option = -1;
    208   next = NULL;
    209   down = NULL;
    210   widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    211   gtk_window_set_policy (GTK_WINDOW (widget), TRUE, TRUE, TRUE);
    212   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    213237#if !defined(__WIN32__)
    214238  gtk_window_set_decorated (GTK_WINDOW (widget), FALSE);
    215239#endif
    216   this->setTitle (windowName);
    217 }
    218 
    219 Window::~Window ()
    220 {
    221   /**
    222    * Destoying a Window (very BAD implemented)
    223    */
    224   gtk_widget_hide (widget);
    225  
     240  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    226241}
    227242
     
    263278   * Creates a new Frame without a name
    264279   */
     280  this->init();
     281}
     282Frame::Frame (char* title)
     283{
     284  /**
     285   * Creates a new Frame with name title
     286   */
     287  this->init();
     288  this->setTitle(title);
     289}
     290Frame::~Frame ()
     291{
     292  /**
     293   * Destroys given Frame (not implemented yet)
     294   */
     295}
     296
     297void Frame::init()
     298{
    265299  is_option = -1;
    266300  next = NULL;
     
    269303  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    270304}
    271 Frame::Frame (char* title)
    272 {
    273   /**
    274    * Creates a new Frame with name title
    275    */
    276   is_option = -1;
    277   next = NULL;
    278   down = NULL;
    279   widget = gtk_frame_new (title);
    280   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    281 }
    282 Frame::~Frame ()
    283 {
    284   /**
    285    * Destroys given Frame (not implemented yet)
    286    */
    287 }
    288305
    289306void Frame::setTitle (char* title)
     
    297314// EVENTBOX //
    298315EventBox::EventBox ()
     316{
     317  this->init();
     318}
     319
     320EventBox::EventBox (char* title)
     321{
     322  /**
     323   * Creates a new EventBox with name title
     324   */
     325  this->init();
     326  this->setTitle(title);
     327
     328}
     329void EventBox::init(void)
    299330{
    300331  is_option = -1;
     
    303334  widget = gtk_event_box_new ();
    304335  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    305 }
    306 
    307 EventBox::EventBox (char* title)
    308 {
    309   /**
    310    * Creates a new EventBox with name title
    311    */
    312   is_option = -1;
    313   next = NULL;
    314   down = NULL;
    315   widget = gtk_event_box_new ();
    316   gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    317 
    318 }
     336 
     337}
     338
     339
    319340void EventBox::setTitle (char* title)
    320341{
     
    336357   * Creates a new horizontal Box
    337358   */
    338   is_option = -2;
    339   next = NULL;
    340   down = NULL;
    341   widget = gtk_hbox_new(FALSE, 0);
     359  this->init('h');
    342360}
    343361Box::Box (char boxtype)
     
    346364   * Creates a new Box if boxtype is 'v' it will be vertically, if 'h' it will be horizontally
    347365   */
     366  this->init(boxtype);
     367}
     368Box::~Box ()
     369{
     370  /**
     371   * Destroys given Frame (not implemented yet)
     372   */
     373}
     374
     375void Box::init(char boxtype)
     376{
    348377  is_option = -2;
    349378  next = NULL;
     
    359388}
    360389
    361 Box::~Box ()
    362 {
    363   /**
    364    * Destroys given Frame (not implemented yet)
    365    */
    366 }
    367390
    368391void Box::fill (Widget *lowerWidget)
     
    394417  widget = gtk_image_new_from_file (imagename);
    395418}
     419void Image::init()
     420{
     421 
     422}
    396423
    397424
    398425/* OPTION */
    399 
     426void Option::init()
     427{
     428  return;
     429}
    400430void Option::setFlagName (char* flagname, int defaultvalue)
    401431{
     
    423453   * Creates a new Button with name buttonname
    424454   */
     455  this->init();
     456  this->setTitle(buttonname);
     457}
     458
     459void Button::init(void)
     460{
    425461  is_option = 0;
    426462  value = 0;
    427463  next = NULL;
    428   option_name = buttonname;
     464  option_name ="";
    429465  flag_name = "";
    430466  flag_name_short = "";
    431467  default_value = 0;
    432   widget = gtk_button_new_with_label (buttonname);
     468  widget = gtk_button_new_with_label ("");
     469}
     470
     471void Button::setTitle (char *title)
     472{
     473  option_name = title;
     474  gtk_button_set_label (GTK_BUTTON(widget), title);
    433475}
    434476
     
    443485   * Creates a new CheckButton with name buttonname
    444486   */
     487  this->init();
     488  this->setTitle(buttonname);
     489
     490  this->connectSignal ("clicked", this->OptionChange);
     491}
     492CheckButton::~CheckButton()
     493{
     494}
     495
     496void CheckButton::init(void)
     497{
    445498  is_option = 1;
    446499  value = 0;
    447500  next = NULL;
    448   option_name = buttonname;
     501  option_name = "";
    449502  flag_name = "";
    450503  flag_name_short = "";
    451504  default_value = 0;
    452   widget = gtk_check_button_new_with_label (buttonname);
    453 
    454   this->connectSignal ("clicked", this->OptionChange);
     505  widget = gtk_check_button_new_with_label ("");
     506}
     507void CheckButton::setTitle(char* title)
     508{
     509  option_name = title;
     510  gtk_button_set_label(GTK_BUTTON(widget), title);
    455511}
    456512
     
    476532   * Creates a new Slider with name slidername a beginning value of start and an end value of end.
    477533   */
     534  this->init(start, end);
     535  this->setValue(start);
     536  this->setTitle(slidername);
     537  this->connectSignal ("value_changed", this->OptionChange);
     538}
     539
     540Slider::~Slider()
     541{
     542}
     543
     544void Slider::init(int start, int end)
     545{
    478546  is_option = 2;
    479547  value = 0;
    480548  next = NULL;
    481   option_name = slidername;
     549  option_name = "";
    482550  flag_name = "";
    483551  flag_name_short = "";
    484552  default_value = 0;
    485553  widget = gtk_hscale_new_with_range (start, end, 5);
    486   value = start;
    487 
    488   this->connectSignal ("value_changed", this->OptionChange);
     554}
     555void Slider::setTitle(char* title)
     556{
     557  option_name = title;
     558}
     559void Slider::setValue(int value)
     560{
     561  this->value = value;
    489562}
    490563
     
    534607}
    535608
     609void Menu::init(void)
     610{
     611}
     612
    536613gint Menu::OptionChange (GtkWidget *widget, Widget* menu)
    537614{
     
    551628Label:: Label ()
    552629{
     630  this->init();
     631}
     632
     633Label:: Label (char* text)
     634{
     635  is_option = 0;
     636  next = NULL;
     637  widget = gtk_label_new (text);
     638  gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
     639}
     640
     641Label::~Label ()
     642{}
     643
     644void Label::init(void)
     645{
    553646  is_option = 0;
    554647  next = NULL;
     
    557650  gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    558651}
    559 
    560 Label:: Label (char* text)
    561 {
    562   is_option = 0;
    563   next = NULL;
    564   widget = gtk_label_new (text);
    565   gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    566 }
    567 
    568 Label::~Label ()
    569 {}
    570652 
    571653void Label::setText (char * text)
Note: See TracChangeset for help on using the changeset viewer.