Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 26, 2004, 3:44:44 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/updater: updated gui, so now it deletes itself when closing the app.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3288 r3289  
    6464  gtk_main();
    6565  gdk_threads_leave();
    66 }
    67 #endif /* HAVE_GTK2 */
     66  delete Window::mainWindow;
     67}
     68#endif /* HAVE_GTK2 */
     69
     70
     71//////////////////////////////
     72/// DEFINING WIDGET-CLASES ///
     73//////////////////////////////
    6874
    6975/* WIDGET */
     
    7581Widget::~Widget()
    7682{
    77   //  cout << "hiding: " <<this->label <<"\n";
    78   this->hide();
    79   //  cout << "check if Packer: "<<this->label <<"\n";
    80   if (this->isOption < 0)
    81     {
    82       //  cout << "get Down "<<this->label <<"\n";
    83       static_cast<Packer*>(this)->down->~Widget();
    84     }
    85   //  cout << "next != NULL?: " <<this->label <<"\n";
    86   if (this->next != NULL)
    87     this->next->~Widget();
    88   cout << "delete Widget: " <<this->label <<"\n";
    89   //  delete widget;
     83  this->destroy();
    9084}
    9185
     
    10296
    10397/**
     98   \brief Destroys a Widget
     99*/
     100void Widget::destroy(void)
     101{
     102  if (label)
     103    {
     104      delete []label;
     105    }
     106 
     107  PRINTF(4)("deleting the Widget part.\n");
     108
     109  PRINTF(4)("deleting recursively\n");
     110
     111  // deleting next item if existent
     112  if (this->next)
     113    delete this->next;
     114  this->next = NULL;
     115
     116  //!  \todo not hiding widget, deleting.
     117  //  this->hide();
     118}
     119
     120/**
    104121   \brief makes the widget visible.
    105122*/
     
    132149#endif /* HAVE_GTK2 */
    133150}
    134 
    135 #ifdef HAVE_GTK2
    136 /**
    137     \brief Connect any signal to any given Sub-widget
    138 */
    139 gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))
    140 {
    141   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);
    142 }
    143 
    144 /**
    145    \brief Connect a signal with additionally passing the whole Object
    146 */
    147 gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))
    148 {
    149   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);
    150 }
    151 
    152 /**
    153    \brief Connect a signal with additionally passing a whole external Object
    154 */
    155 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))
    156 {
    157   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
    158 }
    159 
    160 /**
    161    \brief Connect a signal with additionally passing a whole external Object
    162 */
    163 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *))
    164 {
    165   return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
    166 }
    167 
    168 void Widget::disconnectSignal (gulong signalID)
    169 {
    170   g_signal_handler_disconnect (G_OBJECT (this->widget), signalID);
    171 }
    172 #endif /* HAVE_GTK2 */
    173151
    174152/**
     
    213191
    214192#ifdef HAVE_GTK2
     193/**
     194    \brief Connect any signal to any given Sub-widget
     195*/
     196gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))
     197{
     198  return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);
     199}
     200
     201/**
     202   \brief Connect a signal with additionally passing the whole Object
     203*/
     204gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))
     205{
     206  return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);
     207}
     208
     209/**
     210   \brief Connect a signal with additionally passing a whole external Object
     211*/
     212gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))
     213{
     214  return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
     215}
     216
     217/**
     218   \brief Connect a signal with additionally passing a whole external Object
     219*/
     220gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *))
     221{
     222  return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);
     223}
     224
     225void Widget::disconnectSignal (gulong signalID)
     226{
     227  g_signal_handler_disconnect (G_OBJECT (this->widget), signalID);
     228}
    215229
    216230/**
     
    246260
    247261/**
     262   \brief Destroys a Packer.
     263*/
     264void Packer::destroy(void)
     265{
     266  PRINTF(4)("deleting the Packer part.\n");
     267 
     268  if (groupName)
     269    delete []groupName;
     270
     271  //deleting recursively.
     272  if (this->down)
     273    delete this->down;
     274  this->down = NULL;
     275
     276  static_cast<Widget*>(this)->destroy();
     277}
     278
     279/**
    248280   \brief Sets the group name under which all the lower widgets of this will be saved.
    249281   \param name The name of the group.
     
    283315
    284316/**
     317   \brief Destroys a Container.
     318*/
     319void Container::destroy(void)
     320{
     321  PRINTF(4)("deleting the Container part.\n");
     322
     323  static_cast<Packer*>(this)->destroy();
     324}
     325
     326/**
    285327   \briefFills a Container with lowerWidget.
    286328   \param lowerWidget the Widget that should be filled into the Container.
     
    298340    }
    299341  else
    300     cout << "!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"<<endl;
     342    PRINTF(1)("!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n");
    301343}
    302344
     
    329371     
    330372
    331 
    332373/**
    333374   \brief Creating a new Window without a Name
     
    342383   \param windowName the name the window should get.
    343384*/
     385
    344386Window::Window (char* windowName)
    345387{
    346388  this->init();
    347389  this->setTitle (windowName);
     390}
     391
     392/**
     393   \brief Destructs a Window.
     394*/
     395Window::~Window(void)
     396{
     397  this->destroy();
    348398}
    349399
     
    368418  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    369419#endif /* HAVE_GTK2 */
     420}
     421
     422/**
     423   \brief Destroys a Window.
     424*/
     425void Window::destroy(void)
     426{
     427  if (label)
     428    PRINTF(3)("deleting the Window: %s\n", label);
     429  else
     430    PRINTF(3)("deleting the Window.\n");
     431
     432  static_cast<Container*>(this)->destroy();
     433 
    370434}
    371435
     
    499563}
    500564
     565/**
     566   \brief destrcucts a Frame
     567*/
     568Frame::~Frame()
     569{
     570  this->destroy();
     571}
     572
    501573/**
    502574    \brief Initializes a new Frame with default settings
     
    510582  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    511583#endif /* HAVE_GTK2 */
     584}
     585
     586/**
     587   \brief Destroys a Frame.
     588*/
     589void Frame::destroy(void)
     590{
     591  if (label)
     592    PRINTF(3)("deleting the Frame: %s\n", label);
     593  else
     594    PRINTF(3)("deleting the Frame.\n");
     595
     596   static_cast<Container*>(this)->destroy();
    512597}
    513598
     
    532617   \brief Creates a new EventBox with default settings.
    533618*/
    534 EventBox::EventBox ()
     619EventBox::EventBox (void)
    535620{
    536621  this->init();
     
    548633
    549634/**
     635   \destructs an EventBox.
     636*/
     637EventBox::~EventBox(void)
     638{
     639  this->destroy();
     640
     641}
     642
     643/**
    550644   \brief Initializes a new EventBox
    551645*/
     
    560654  gtk_container_set_border_width (GTK_CONTAINER (widget), 3);
    561655#endif /* HAVE_GTK2 */
     656}
     657
     658/**
     659   \brief Destroys an EventBox.
     660*/
     661void EventBox::destroy(void)
     662{
     663  if (label)
     664    PRINTF(3)("deleting the EventBox: %s\n", label);
     665  else
     666    PRINTF(3)("deleting the EventBox.\n");
     667
     668  static_cast<Container*>(this)->destroy();
    562669}
    563670
     
    591698{
    592699  this->init(boxtype);
     700}
     701
     702/**
     703   \destructs a Box.
     704*/
     705Box::~Box(void)
     706{
     707  this->destroy();
    593708}
    594709
     
    612727    }
    613728#endif /* HAVE_GTK2 */
     729}
     730
     731/**
     732   \brief Destroys a Box.
     733*/
     734void Box::destroy(void)
     735{
     736  if (label)
     737    PRINTF(3)("deleting the Box: %s\n", label);
     738  else
     739    PRINTF(3)("deleting the Box.\n");
     740
     741  static_cast<Packer*>(this)->destroy();
    614742}
    615743
     
    641769/**
    642770   \brief Sets the Title of a Box.
    643    \title the new Title to set.
     771   \param title the new Title to set.
    644772*/
    645773void Box::setTitle(char* title)
     
    668796
    669797  return;
     798}
     799
     800/**
     801   \brief Destroys an Option.
     802*/
     803void Option::destroy(void)
     804{
     805  PRINTF(4)("deleting the Option Part.\n");
     806  if (flagName)
     807    delete []flagName;
     808  if (flagNameShort)
     809    delete []flagNameShort;
     810
     811  static_cast<Widget*>(this)->destroy();
    670812}
    671813
     
    746888
    747889/**
     890   \destructs a Button.
     891*/
     892Button::~Button(void)
     893{
     894  this->destroy();
     895}
     896
     897/**
    748898   \brief Initializes a new Button
    749899*/
     
    757907  widget = gtk_button_new_with_label ("");
    758908#endif /* HAVE_GTK2 */
     909}
     910
     911/**
     912   \brief Destroys a Button.
     913*/
     914void Button::destroy(void)
     915{
     916  if (label)
     917    PRINTF(3)("deleting the Label: %s\n", label);
     918  else
     919    PRINTF(3)("deleting the Label.\n");
     920
     921  static_cast<Option*>(this)->destroy();
    759922}
    760923
     
    799962
    800963/**
     964   \destructs a CheckButton.
     965*/
     966CheckButton::~CheckButton(void)
     967{
     968  this->destroy();
     969}
     970
     971/**
    801972   \brief Initialize a new CheckButton with default settings
    802973*/
     
    810981  widget = gtk_check_button_new_with_label ("");
    811982#endif /* HAVE_GTK2 */
     983}
     984
     985/**
     986   \brief Destroys a CheckButton.
     987*/
     988void CheckButton::destroy(void)
     989{
     990  if (label)
     991    PRINTF(3)("deleting the CheckButton: %s\n", label);
     992  else
     993    PRINTF(3)("deleting the CheckButton.\n");
     994
     995  static_cast<Option*>(this)->destroy();
    812996}
    813997
     
    8781062
    8791063/**
     1064   \destructs a Slider.
     1065*/
     1066Slider::~Slider(void)
     1067{
     1068  this->destroy();
     1069}
     1070
     1071/**
    8801072   \brief Initializes a Slider with start and end Values
    8811073   params: see Slider::Slider (char* slidername, int start, int end)
     
    8901082 widget = gtk_hscale_new_with_range (start, end, 5);
    8911083#endif /* HAVE_GTK2 */
     1084}
     1085
     1086/**
     1087   \brief Destroys a Slider.
     1088*/
     1089void Slider::destroy(void)
     1090{
     1091  if (label)
     1092    PRINTF(3)("deleting the Slider: %s\n", label);
     1093  else
     1094    PRINTF(3)("deleting the Slider.\n");
     1095
     1096  static_cast<Option*>(this)->destroy();
     1097
    8921098}
    8931099
     
    9111117{
    9121118  this->value = value;
     1119}
     1120
     1121/**
     1122   \brief Redraws the widget
     1123   Example: see void CheckButton::redraw ()
     1124*/
     1125void Slider::redraw ()
     1126{
     1127#ifdef HAVE_GTK2
     1128  gtk_range_set_value (GTK_RANGE (widget), value);
     1129#endif /* HAVE_GTK2 */
    9131130}
    9141131
     
    9271144#endif /* HAVE_GTK2 */
    9281145
    929 /**
    930    \brief Redraws the widget
    931    Example: see void CheckButton::redraw ()
    932 */
    933 void Slider::redraw ()
    934 {
    935 #ifdef HAVE_GTK2
    936   gtk_range_set_value (GTK_RANGE (widget), value);
    937 #endif /* HAVE_GTK2 */
    938 }
    9391146
    9401147/* MENU */
     
    9691176
    9701177/**
     1178   \destructs a Menu.
     1179*/
     1180Menu::~Menu(void)
     1181{
     1182  this->destroy();
     1183}
     1184
     1185/**
    9711186   \brief Initializes a new Menu with no items
    9721187*/
     
    9831198
    9841199}
     1200
     1201/**
     1202   \brief Destroys a Menu.
     1203*/
     1204void Menu::destroy(void)
     1205{
     1206  if (label)
     1207    PRINTF(3)("deleting the Menu: %s\n", label);
     1208  else
     1209    PRINTF(3)("deleting the Menu.\n");
     1210  //! \todo destroy menu
     1211 
     1212  static_cast<Option*>(this)->destroy();
     1213}
     1214
    9851215
    9861216/**
     
    10051235  item = gtk_menu_item_new_with_label (itemName);
    10061236  gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
     1237#endif /* HAVE_GTK2 */
     1238}
     1239
     1240/**
     1241   \brief Redraws the widget
     1242   Example: see void CheckButton::redraw ()
     1243*/
     1244void Menu::redraw ()
     1245{
     1246#ifdef HAVE_GTK2
     1247 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);
    10071248#endif /* HAVE_GTK2 */
    10081249}
     
    10221263#endif /* HAVE_GTK2 */
    10231264
    1024 /**
    1025    \brief Redraws the widget
    1026    Example: see void CheckButton::redraw ()
    1027 */
    1028 void Menu::redraw ()
    1029 {
    1030 #ifdef HAVE_GTK2
    1031  gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value);
    1032 #endif /* HAVE_GTK2 */
    1033 }
     1265/* OPTION LABEL */
    10341266
    10351267/**
     
    10461278
    10471279/**
     1280   \destructs an OptionLabel.
     1281*/
     1282OptionLabel::~OptionLabel(void)
     1283{
     1284  this->destroy();
     1285}
     1286
     1287/**
    10481288   \brief Initializes an OptionLabel
    10491289*/
     
    10581298#endif /* HAVE_GTK2 */
    10591299}
     1300
     1301/**
     1302   \brief Destroys a OptionLabel.
     1303*/
     1304void OptionLabel::destroy(void)
     1305{
     1306  if (label)
     1307    PRINTF(3)("deleting the OptionLabel: %s\n", label);
     1308  else
     1309    PRINTF(3)("deleting the OptionLabel.\n");
     1310  if (cValue)
     1311    delete []cValue;
     1312
     1313  static_cast<Option*>(this)->destroy();
     1314}
     1315
    10601316
    10611317/**
     
    11171373
    11181374/**
     1375   \destructs a Label.
     1376*/
     1377Label::~Label(void)
     1378{
     1379  this->destroy();
     1380}
     1381
     1382/**
    11191383   \brief initializes a new Label
    11201384*/
     
    11291393  gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE);
    11301394#endif /* HAVE_GTK2 */
     1395}
     1396
     1397/**
     1398   \brief Destroys a Label.
     1399*/
     1400void Label::destroy(void)
     1401{
     1402  if (label)
     1403    PRINTF(3)("deleting the Label: %s\n", label);
     1404  else
     1405    PRINTF(3)("deleting the Label.\n");
     1406
     1407  static_cast<Widget*>(this)->destroy();
    11311408}
    11321409
     
    11781455ProgressBar::~ProgressBar ()
    11791456{
     1457  this->destroy();
    11801458}
    11811459
     
    11971475
    11981476/**
     1477   \brief Destroys a ProgressBar.
     1478*/
     1479void ProgressBar::destroy(void)
     1480{
     1481  if (label)
     1482    PRINTF(3)("deleting the ProgressBar: %s\n", label);
     1483  else
     1484    PRINTF(3)("deleting the ProgressBar.\n");
     1485
     1486  static_cast<Widget*>(this)->destroy();
     1487}
     1488
     1489/**
    11991490   \brief Sets a ned Title to the ProgressBar.
    12001491   \param title The now title of the ProgressBar.
     
    12591550}
    12601551
     1552/**
     1553   \destructs an Image.
     1554*/
     1555Image::~Image(void)
     1556{
     1557  this->destroy();
     1558}
     1559
    12611560/**
    12621561    \brief Initializes a new Image
     
    12671566
    12681567  static_cast<Widget*>(this)->init();
     1568}
     1569
     1570/**
     1571   \brief Destroys a Image.
     1572*/
     1573void Image::destroy(void)
     1574{
     1575  if (label)
     1576    PRINTF(3)("deleting the Image: %s\n", label);
     1577  else
     1578    PRINTF(3)("deleting the Image.\n");
     1579
     1580  static_cast<Widget*>(this)->destroy();
    12691581}
    12701582
Note: See TracChangeset for help on using the changeset viewer.