Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3165 in orxonox.OLD for orxonox/trunk/gui


Ignore:
Timestamp:
Dec 13, 2004, 2:17:30 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: compiling as not-GTK possibe, but it is not usable yet

Location:
orxonox/trunk/gui
Files:
8 edited

Legend:

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

    r3164 r3165  
    3434
    3535*/
    36 
    37 #include <gtk/gtkmain.h>
    38 
    3936#include "orxonox_gui.h"
    4037#include "orxonox_gui_video.h"
     
    6663OrxonoxGui::OrxonoxGui (int argc, char *argv[])
    6764{
    68  
     65#ifdef HAVE_GTK2
    6966  initGTK(argc, argv);
    70 
     67#endif
    7168  orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION);
     69#ifdef HAVE_GTK2
    7270  orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit);
    7371  orxonoxGUI->connectSignal ("delete_event", orxonoxGUI->orxonox_gui_quit);
     72#endif /* HAVE_GTK2 */
    7473 
    7574  Box* windowBox = new Box ('h');
     
    111110
    112111 
     112#ifdef HAVE_GTK2
    113113  mainloopGTK();
     114#endif
    114115}
    115116
  • orxonox/trunk/gui/orxonox_gui_banner.cc

    r3164 r3165  
    3838  // Banner Window //
    3939  logoWindow = new Window("Logo");
    40     bannerEventBox->connectSignal ("button_press_event", logoWindow, Window::windowOpen);
     40
     41#ifdef HAVE_GTK2
     42  bannerEventBox->connectSignal ("button_press_event", logoWindow, Window::windowOpen);
    4143
    4244  logoWindow->connectSignal("destroy", logoWindow, Window::windowClose);
    4345  logoWindow->connectSignal("delete_event", logoWindow, Window::windowClose);
     46#endif /* HAVE_GTK2 */
    4447  logoEventBox = new EventBox();
    4548  logoBox = new Box('v');
     
    5053  logoBox->fill(logoLabel);
    5154  logoBox->fill(logoEventBox);
     55#ifdef HAVE_GTK2
    5256  logoEventBox->connectSignal("button_press_event",logoWindow, Window::windowClose);
    53  
     57#endif /* HAVE_GTK2 */
     58
    5459  logoWindow->fill (logoBox);
    5560 
  • orxonox/trunk/gui/orxonox_gui_exec.cc

    r3162 r3165  
    4141 
    4242  start = new Button ("Start");
     43#ifdef HAVE_GTK2
    4344  start->connectSignal ("clicked", startOrxonox);
     45#endif /* HAVE_GTK2 */
    4446  execBox->fill (start);
    4547  saveSettings = new CheckButton ("Save Settings");
     
    5658  execBox->fill (alwaysShow);
    5759  quit = new Button ("Quit");
     60#ifdef HAVE_GTK2
    5861  quit->connectSignal ("clicked", orxonoxGUI->orxonox_gui_quit);
     62#endif /* HAVE_GTK2 */
    5963  execBox->fill (quit);
    6064
     
    278282}
    279283
     284#ifdef HAVE_GTK2
    280285/**
    281286   \brief Starts ORXONOX. (not really implemented yet, but the function is there.\n
     
    288293  cout << "Starting Orxonox" <<endl;
    289294}
     295#endif /* HAVE_GTK2 */
  • orxonox/trunk/gui/orxonox_gui_exec.h

    r3162 r3165  
    3939
    4040};
     41#ifdef HAVE_GTK2
    4142  gint startOrxonox (GtkWidget *widget, Widget* data);
    42 
     43#endif /* HAVE_GTK2 */
    4344#endif /* _ORXONOX_GUI_EXEC_H */
  • orxonox/trunk/gui/orxonox_gui_gtk.cc

    r3164 r3165  
    3939extern OrxonoxGuiExec* exec;
    4040
     41#ifdef HAVE_GTK2
    4142bool initGTK(int argc, char *argv[])
    4243{
     
    4849  gtk_main();
    4950}
     51#endif /* HAVE_GTK2 */
     52
    5053/* WIDGET */
    5154
     
    8790void Widget::show()
    8891{
     92#ifdef HAVE_GTK2
    8993  gtk_widget_show (this->widget);
     94#endif /* HAVE_GTK2 */
    9095}
    9196
     
    95100void Widget::hide()
    96101{
     102#ifdef HAVE_GTK2
    97103  gtk_widget_hide (this->widget);
     104#endif /* HAVE_GTK2 */
    98105}
    99106
     
    105112void Widget::setSize(int width, int height)
    106113{
     114#ifdef HAVE_GTK2
    107115  gtk_widget_set_usize (this->widget, width, height);
    108 }
    109 
     116#endif /* HAVE_GTK2 */
     117}
     118
     119#ifdef HAVE_GTK2
    110120/**
    111121    \brief Connect any signal to any given Sub-widget
     
    144154  g_signal_handler_disconnect (G_OBJECT (this->widget), signalID);
    145155}
     156#endif /* HAVE_GTK2 */
    146157
    147158/**
     
    181192}
    182193
     194#ifdef HAVE_GTK2
    183195gint Widget::doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing)
    184196{
    185197}
     198#endif /* HAVE_GTK2 */
    186199
    187200//void deleteWidget(Widget* lastWidget)
     
    249262  if (this->down == NULL)
    250263    {
     264#ifdef HAVE_GTK2
    251265      gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget);
     266#endif /* HAVE_GTK2 */
    252267      this->down = lowerWidget;
    253268    }
     
    310325  static_cast<Container*>(this)->init();
    311326
     327#ifdef HAVE_GTK2
    312328  widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    313329  gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE);
     
    316332#endif
    317333  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    318 
     334#endif /* HAVE_GTK2 */
    319335}
    320336
     
    327343    {
    328344      printf ("showall\n");
     345#ifdef HAVE_GTK2
    329346      gtk_widget_show_all  (widget);
    330       isOpen = true;
     347#endif /* HAVE_GTK2 */
     348     isOpen = true;
    331349    }
    332350  else
    333351    {
    334352      printf ("showone\n");
     353#ifdef HAVE_GTK2
    335354      gtk_widget_show (widget);
     355#endif /* HAVE_GTK2 */
    336356    }
    337357}
     
    347367  label = new char[strlen(title)+1];
    348368  strcpy(label, title);
     369#ifdef HAVE_GTK2
    349370  gtk_window_set_title (GTK_WINDOW (widget), title);
     371#endif /* HAVE_GTK2 */
    350372}
    351373
     
    358380    {
    359381      isOpen = true;
     382#ifdef HAVE_GTK2
    360383      gtk_widget_show_all(widget);
    361384      gtk_grab_add(widget);
     385#endif /* HAVE_GTK2 */
    362386    }
    363387}
     
    371395    {
    372396      isOpen = false;
     397#ifdef HAVE_GTK2
    373398      gtk_grab_remove(widget);
    374399      gtk_widget_hide (widget);
     400#endif /* HAVE_GTK2 */
    375401    }
    376402}
    377403
     404#ifdef HAVE_GTK2
    378405/**
    379406   \brief opens up a window (not topmost Window).
     
    415442  return FALSE;
    416443}
     444#endif /* HAVE_GTK2 */
    417445
    418446
     
    442470{
    443471  static_cast<Container*>(this)->init();
    444  
     472
     473#ifdef HAVE_GTK2
    445474  widget = gtk_frame_new ("");
    446475  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
     476#endif /* HAVE_GTK2 */
    447477}
    448478
     
    457487  label = new char[strlen(title)+1];
    458488  strcpy(label, title);
     489#ifdef HAVE_GTK2
    459490  gtk_frame_set_label (GTK_FRAME (widget), title);
     491#endif /* HAVE_GTK2 */
    460492}
    461493
     
    488520  static_cast<Container*>(this)->init();
    489521
     522#ifdef HAVE_GTK2
    490523  widget = gtk_event_box_new ();
    491524  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    492  
     525#endif /* HAVE_GTK2 */
    493526}
    494527
     
    533566
    534567  static_cast<Packer*>(this)->init();
     568#ifdef HAVE_GTK2
    535569  if (boxtype == 'v')
    536570    {
     
    541575      widget = gtk_hbox_new (FALSE, 0);
    542576    }
     577#endif /* HAVE_GTK2 */
     578
    543579}
    544580
     
    550586void Box::fill (Widget *lowerWidget)
    551587{
     588#ifdef HAVE_GTK2
    552589  gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0);
     590#endif /* HAVE_GTK2 */
    553591  if (this->down == NULL)
    554592    this->down = lowerWidget;
     
    579617
    580618  this->init();
     619#ifdef HAVE_GTK2
    581620  widget = gtk_image_new_from_file (imagename);
     621#endif /* HAVE_GTK2 */
    582622}
    583623
     
    671711  static_cast<Option*>(this)->init();
    672712
     713#ifdef HAVE_GTK2
    673714  widget = gtk_button_new_with_label ("");
     715#endif /* HAVE_GTK2 */
    674716}
    675717
     
    684726  label = new char[strlen(title)+1];
    685727  strcpy(label, title);
     728#ifdef HAVE_GTK2
    686729  gtk_button_set_label (GTK_BUTTON(widget), title);
     730#endif /* HAVE_GTK2 */
    687731}
    688732
     
    706750  this->setTitle(buttonname);
    707751
     752#ifdef HAVE_GTK2
    708753  this->connectSignal ("clicked", this->OptionChange);
     754#endif /* HAVE_GTK2 */
    709755}
    710756
     
    718764  static_cast<Option*>(this)->init();
    719765
     766#ifdef HAVE_GTK2
    720767  widget = gtk_check_button_new_with_label ("");
     768#endif /* HAVE_GTK2 */
    721769}
    722770
     
    731779  label = new char[strlen(title)+1];
    732780  strcpy(label, title);
     781#ifdef HAVE_GTK2
    733782  gtk_button_set_label(GTK_BUTTON(widget), title);
     783#endif /* HAVE_GTK2 */
    734784}
    735785
    736786bool CheckButton::isActive()
    737787{
     788#ifdef HAVE_GTK2
    738789  return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
    739 }
    740 
     790#endif /* HAVE_GTK2 */
     791}
     792
     793#ifdef HAVE_GTK2
    741794/**
    742795    \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database.
     
    750803  cout << static_cast<CheckButton*>(checkbutton)->label << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl;
    751804}
     805#endif /* HAVE_GTK2 */
    752806
    753807/**
     
    757811void CheckButton::redraw ()
    758812{
     813#ifdef HAVE_GTK2
    759814  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
     815#endif /* HAVE_GTK2 */
    760816}
    761817
     
    773829  this->setValue(start);
    774830  this->setTitle(slidername);
     831#ifdef HAVE_GTK2
    775832  this->connectSignal ("value_changed", this->OptionChange);
     833#endif /* HAVE_GTK2 */
    776834}
    777835
     
    786844  static_cast<Option*>(this)->init();
    787845
    788   widget = gtk_hscale_new_with_range (start, end, 5);
     846#ifdef HAVE_GTK2
     847 widget = gtk_hscale_new_with_range (start, end, 5);
     848#endif /* HAVE_GTK2 */
    789849}
    790850
     
    810870}
    811871
     872#ifdef HAVE_GTK2
    812873/**
    813874    \brief Signal OptionChange writes the Value from the Slider to its Object-Database.
     
    821882  cout << static_cast<Slider*>(slider)->label << " set to: "<< static_cast<Slider*>(slider)->value << endl;
    822883}
     884#endif /* HAVE_GTK2 */
    823885
    824886/**
     
    828890void Slider::redraw ()
    829891{
     892#ifdef HAVE_GTK2
    830893  gtk_range_set_value (GTK_RANGE (widget), value);
     894#endif /* HAVE_GTK2 */
    831895}
    832896
     
    845909   
    846910  char *itemName;
    847  
     911
     912#ifdef HAVE_GTK2             /////////////////////// REINPLEMENT
    848913  va_start (itemlist, menuname);
    849914  while (strcmp (itemName = va_arg (itemlist, char*), "lastItem"))
     
    852917    }
    853918  va_end(itemlist);
    854 
     919#endif /* HAVE_GTK2 */
     920
     921#ifdef HAVE_GTK2
    855922  gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu);
    856923  this->connectSignal ("changed", this->OptionChange);
     924#endif /* HAVE_GTK2 */
    857925}
    858926
     
    866934  static_cast<Option*>(this)->init();
    867935
     936#ifdef HAVE_GTK2
    868937  widget = gtk_option_menu_new ();
    869938  menu = gtk_menu_new ();
     939#endif /* HAVE_GTK2 */
    870940
    871941}
     
    889959void Menu::addItem (char* itemName)
    890960{
     961#ifdef HAVE_GTK2
    891962  item = gtk_menu_item_new_with_label (itemName);
    892963  gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
    893 }
    894 
     964#endif /* HAVE_GTK2 */
     965}
     966
     967#ifdef HAVE_GTK2
    895968/**
    896969    \brief Signal OptionChange writes the Value from the Menu to its Object-Database.
     
    904977  cout << static_cast<Menu*>(menu)->label << " changed to : " << static_cast<Menu*>(menu)->value << endl;
    905978}
     979#endif /* HAVE_GTK2 */
    906980
    907981/**
     
    911985void Menu::redraw ()
    912986{
    913   gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);
     987#ifdef HAVE_GTK2
     988 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);
     989#endif /* HAVE_GTK2 */
    914990}
    915991
     
    9271003  cValue = NULL;
    9281004
     1005#ifdef HAVE_GTK2
    9291006  widget = gtk_label_new ("");
    930 }
     1007#endif /* HAVE_GTK2 */
     1008}
     1009
    9311010void OptionLabel::setValue(char* newValue)
    9321011{
     
    9351014  cValue = new char [strlen(newValue)+1];
    9361015  strcpy(cValue, newValue);
     1016#ifdef HAVE_GTK2
    9371017  gtk_label_set_text (GTK_LABEL (widget), cValue);
     1018#endif /* HAVE_GTK2 */
    9381019}
    9391020
     
    9441025  label = new char [strlen(title)+1];
    9451026  strcpy(label, title);
     1027#ifdef HAVE_GTK2
    9461028  gtk_label_set_text (GTK_LABEL (widget), title);
     1029#endif /* HAVE_GTK2 */
    9471030}
    9481031
     
    9801063  static_cast<Widget*>(this)->init();
    9811064
     1065#ifdef HAVE_GTK2
    9821066  widget = gtk_label_new ("");
    9831067  gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
     1068#endif /* HAVE_GTK2 */
    9841069}
    9851070
     
    9941079  label = new char[strlen(text)+1];
    9951080  strcpy(label, text);
     1081#ifdef HAVE_GTK2
    9961082  gtk_label_set_text (GTK_LABEL (this->widget), text);
     1083#endif /* HAVE_GTK2 */
    9971084}
    9981085
     
    10031090char* Label::getText ()
    10041091{
    1005   return ((char*)gtk_label_get_text (GTK_LABEL (this->widget)));
    1006 }
     1092  return label;
     1093}
  • orxonox/trunk/gui/orxonox_gui_gtk.h

    r3164 r3165  
    1111#endif
    1212
     13#ifdef HAVE_GTK2
    1314#include <gtk/gtkmain.h>
    1415#include <gtk/gtkwindow.h>
     
    2526#include <gtk/gtkimage.h>
    2627#include <gtk/gtkeventbox.h>
    27 
     28#endif /* HAVE_GTK2 */
     29
     30#ifdef HAVE_GTK2
    2831bool initGTK(int argc, char *argv[]);
    2932bool mainloopGTK(void);
     33#endif /* HAVE_GTK2 */
     34
    3035
    3136//! This is the topmost object that can be displayed all others are derived from it.
     
    3742
    3843  Widget* next; //!< next always points to the next Widget in the list. Every Widget has a next one, or has NULL as next
     44#ifdef HAVE_GTK2
    3945  GtkWidget* widget; //!< widget is the gtk_widget that the specific Object Contains.
     46#endif /* HAVE_GTK2 */
    4047  void init(void);
    4148  int isOption; //!< with this Paramenter one can set the option-type: -2:Container, -1: Box, 0: not an Option, 1: Bool-option, 2: int-option, 3: float option, 4:char option, 5: char* option
     
    4552  enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2};
    4653  char* label; //!< The name of the Widget. Some do display it, Options need it to save;
     54#ifdef HAVE_GTK2
    4755  gulong connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *));
    4856  gulong connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *));
     
    5058  gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *));
    5159  void disconnectSignal (gulong signalID);
     60#endif /* HAVE_GTK2 */
    5261  void show ();
    5362  void hide ();
     
    5867  static void setOptions (Widget* widget);
    5968 
     69#ifdef HAVE_GTK2
    6070  static gint doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing);
     71#endif /* HAVE_GTK2 */
    6172};
    6273
     
    114125  void close();
    115126
     127#ifdef HAVE_GTK2
    116128  static gint windowOpen (GtkWidget *widget, GdkEvent* event, void* window);
    117129  static gint windowClose (GtkWidget *widget, GdkEvent* event, void* window);
    118130  static gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
     131#endif /* HAVE_GTK2 */
    119132};
    120133
     
    220233 public:
    221234  CheckButton (char* buttonname);
     235#ifdef HAVE_GTK2
    222236  static gint OptionChange (GtkWidget* widget, Widget* checkbutton);
     237#endif /* HAVE_GTK2 */
    223238 
    224239  void init(void);
     
    242257  void setValue(int value);
    243258
     259#ifdef HAVE_GTK2
    244260  static gint OptionChange (GtkWidget* widget, Widget* slider);
     261#endif /* HAVE_GTK2 */
    245262  void redraw();
    246263};
     
    250267{
    251268 private:
     269#ifdef HAVE_GTK2
    252270  GtkWidget* menu;
    253271  GtkWidget* item;
     272#endif /* HAVE_GTK2 */
    254273  va_list itemlist;
    255274 
     
    261280
    262281  void addItem(char* itemName);
     282#ifdef HAVE_GTK2
    263283  static gint OptionChange (GtkWidget* widget, Widget* menu);
     284#endif /* HAVE_GTK2 */
    264285  void redraw();
    265286};
  • orxonox/trunk/gui/orxonox_gui_keys.cc

    r3164 r3165  
    6868   
    6969    closeButton = new Button("close");
     70#ifdef HAVE_GTK2
    7071    closeButton->connectSignal("button_press_event", pKeyWindow, Window::windowClose);
     72#endif /* HAVE_GTK2 */
    7173
    7274    pKeysBox->fill(closeButton);
     
    7476   pKeyWindow->fill(pKeyFrame);
    7577   Window::addWindow(pKeyWindow);
     78#ifdef HAVE_GTK2
    7679   pKeyWindow->connectSignal("destroy", pKeyWindow, Window::windowClose);
    7780   pKeyWindow->connectSignal("delete_event", pKeyWindow, Window::windowClose);
     81#endif /* HAVE_GTK2 */
    7882
    7983  openButton = new Button (player);
     84#ifdef HAVE_GTK2
    8085  openButton->connectSignal("button_press_event", pKeyWindow, Window::windowOpen);
     86#endif /* HAVE_GTK2 */
    8187
    8288  inputWindow = new Window("inputWindow");
     
    8490  inputButton = new Button ("test");
    8591  inputWindow->fill (inputButton);
     92#ifdef HAVE_GTK2
    8693  inputWindow->connectSignal("destroy",  Widget::doNothingSignal);
    8794  inputWindow->connectSignal("delete_event", Widget::doNothingSignal);
     95#endif /* HAVE_GTK2 */
    8896
    8997}
     
    96104  inputKey[key]->pKeyOLabel = new OptionLabel (name, name);
    97105  inputKey[key]->pKeyOLabel->saveable = true;
    98  
     106
     107#ifdef HAVE_GTK2
    99108  //inputKey[key]->pKeyButton->connectSignal("key_press_event", inputKey[key]->pKeyButton, key_cb);
    100109  inputKey[key]->pKeyButton->connectSignal("button_press_event", inputKey[key], inputWindowEvent);
     110#endif /* HAVE_GTK2 */
    101111
    102112  inputKey[key]->pKeyBox->fill(inputKey[key]->pKeyButton);
     
    120130long Player::keySignal = 0;
    121131
     132#ifdef HAVE_GTK2
    122133gint Player::inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* inputKey)
    123134{
     
    264275  inputWindow->close();
    265276}
     277#endif /* HAVE_GTK2 */
  • orxonox/trunk/gui/orxonox_gui_keys.h

    r3163 r3165  
    88
    99#include "orxonox_gui.h"
     10#ifdef HAVE_GTK2
    1011#include <gdk/gdkkeysyms.h>
    11 
     12#endif /* HAVE_GTK2 */
    1213/**
    1314 * defines the Possible Player Keys
     
    6263  Button* getOpenButton();
    6364
     65#ifdef HAVE_GTK2
    6466  static gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget);
    6567  static gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey);
     68#endif /* HAVE_GTK2 */
    6669  void setkey(KEYS key);
    6770 
Note: See TracChangeset for help on using the changeset viewer.