Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1974 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Jun 17, 2004, 9:35:55 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/gui/guicc: added OptionMenu

Location:
orxonox/branches/gui/guicc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/gui/guicc/orxonox_gui.cc

    r1973 r1974  
    2121  slider->connectSignal ("value_changed", slider->OptionChange);
    2222  box->fill(slider);
    23  
     23  Menu* menu = new Menu("test1", "no output", "verbose", "debug", "lastItem");
     24  menu->connectSignal ("changed", menu->OptionChange);
     25  box->fill(menu);
    2426  orxonoxGUI->showall ();
    2527 
     
    236238  cout << static_cast<Slider*>(slider)->value << endl;
    237239}
     240
     241
     242Menu::Menu(char* menuname, ...)
     243{
     244  /**
     245   * Creates an Menu-Item-list out of multiple input. Consider, that the last input argument has to be "lastItem" for this to work.
     246   */
     247  char *tmp;
     248  va_list itemlist;
     249  widget = gtk_option_menu_new();
     250  GtkWidget* menu = gtk_menu_new ();
     251  GtkWidget* item;
     252
     253  va_start(itemlist, menuname);
     254  while (strcmp(tmp = va_arg(itemlist, char*), "lastItem"))
     255    {
     256      item = gtk_menu_item_new_with_label (tmp);
     257      gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
     258    }
     259  va_end(itemlist);
     260
     261  gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
     262}
     263
     264gint Menu::OptionChange (GtkWidget *widget, Widget* menu)
     265{
     266  /**
     267   * Writes value, if changed on the Menu, to the object.
     268   */
     269  static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU(menu->widget));
     270  cout << static_cast<Menu*>(menu)->value << endl;
     271}
  • orxonox/branches/gui/guicc/orxonox_gui.h

    r1965 r1974  
    1212#include <gtk/gtkcheckbutton.h>
    1313#include <gtk/gtkhscale.h>
     14#include <gtk/gtkoptionmenu.h>
     15#include <gtk/gtkmenu.h>
     16#include <gtk/gtkmenuitem.h>
    1417
    1518
     
    103106{
    104107 public:
    105   Slider (char * slidername,int start, int end);
     108  Slider (char* slidername,int start, int end);
    106109  ~Slider();
    107110  int i;
    108111  static gint OptionChange (GtkWidget *widget, Widget* slider);
    109112};
     113
     114class Menu : public Option
     115{
     116 public:
     117  Menu(char* menuname, ...);
     118  ~Menu();
     119
     120  static gint OptionChange (GtkWidget *widget, Widget* menu);
     121};
     122   
    110123//gint orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data);
    111124
Note: See TracChangeset for help on using the changeset viewer.