Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2587 in orxonox.OLD


Ignore:
Timestamp:
Oct 17, 2004, 12:48:07 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: added init-routine to Menu as promised in last comit-message

Location:
orxonox/trunk/gui
Files:
2 edited

Legend:

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

    r2586 r2587  
    582582   * Creates an Menu-Item-list out of multiple input. Consider, that the last input argument has to be "lastItem" for this to work.
    583583   */
     584  this->init();
     585  this->setTitle(menuname);
     586   
     587  char *itemName;
     588 
     589  va_start (itemlist, menuname);
     590  while (strcmp (itemName = va_arg (itemlist, char*), "lastItem"))
     591    {
     592      this->addItem(itemName);
     593    }
     594  va_end(itemlist);
     595
     596  gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
     597  this->connectSignal ("changed", this->OptionChange);
     598}
     599
     600void Menu::init(void)
     601{
    584602  is_option = 2;
    585603  value = 0;
    586604  next = NULL;
    587   option_name = menuname;
    588605  flag_name = "";
    589606  flag_name_short = "";
    590607  default_value = 0;
    591   char *tmp;
    592   va_list itemlist;
    593608  widget = gtk_option_menu_new ();
    594   GtkWidget* menu = gtk_menu_new ();
    595   GtkWidget* item;
    596 
    597   va_start (itemlist, menuname);
    598   while (strcmp (tmp = va_arg (itemlist, char*), "lastItem"))
    599     {
    600       item = gtk_menu_item_new_with_label (tmp);
    601       gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
    602     }
    603   va_end(itemlist);
    604 
    605   gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
    606   this->connectSignal ("changed", this->OptionChange);
    607 }
    608 
    609 void Menu::init(void)
    610 {
     609  menu = gtk_menu_new ();
     610
     611}
     612
     613void Menu::setTitle(char* title)
     614{
     615  option_name = title;
     616}
     617
     618void Menu::addItem (char* itemName)
     619{
     620  item = gtk_menu_item_new_with_label (itemName);
     621  gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
    611622}
    612623
  • orxonox/trunk/gui/orxonox_gui.h

    r2586 r2587  
    178178class Menu : public Option
    179179{
     180 private:
     181  GtkWidget* menu;
     182  GtkWidget* item;
     183  va_list itemlist;
     184 
    180185 public:
    181186  Menu (char* menuname, ...);
    182187  ~Menu ();
    183   void init(void);   /// HAS TO BE IMPLEMENTED!! most difficult :-)
    184 
     188  void init(void);
     189
     190  void setTitle(char* title);
     191
     192  void addItem(char* itemName);
    185193  static gint OptionChange (GtkWidget* widget, Widget* menu);
    186194  void redraw();
Note: See TracChangeset for help on using the changeset viewer.