Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3623 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Mar 21, 2005, 8:15:38 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: gui now deletes as it should

Location:
orxonox/trunk/src/lib/gui/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc

    r3423 r3623  
    133133
    134134/* WIDGET */
    135 
    136 /**
    137    \brief deletes any given Widget
    138    This is still pretty crappy.
    139 */
    140 Widget::~Widget(void)
    141 {
    142   this->destroy();
    143 }
    144 
    145 /**
    146    \brief Initializes a widget.
    147    Initializes the next Pointer and the other Widget-specific Defaults.
    148 */
    149 void Widget::init(void)
     135/**
     136   \brief constructs a Widget
     137*/
     138Widget::Widget(void)
    150139{
    151140  next = NULL;
     
    155144
    156145/**
    157    \brief Destroys a Widget
    158 */
    159 void Widget::destroy(void)
    160 {
    161   if (this->title)
     146   \brief deletes any given Widget
     147   This is still pretty crappy.
     148*/
     149Widget::~Widget(void)
     150{
     151    if (this->title)
    162152    {
    163153      delete []this->title;
     
    172162    delete this->next;
    173163  this->next = NULL;
    174 
    175164  //!  \todo not hiding widget, deleting.
    176165  //  this->hide();
     
    513502
    514503/* PACKERS */
    515 
    516 /**
    517    \brief Initializes a Packer.
    518 
    519    Sets the down-pinter to NULL and other PackerSpecific-values to their defaults.
    520 */
    521 void Packer::init(void)
     504/**
     505   \brief Constructs a Packer
     506*/
     507Packer::Packer(void)
    522508{
    523509  this->down = NULL;
    524510  this->groupName = NULL;
    525 
    526 
    527   static_cast<Widget*>(this)->init();
    528   return;
    529511}
    530512
     
    532514   \brief Destroys a Packer.
    533515*/
    534 void Packer::destroy(void)
     516Packer::~Packer(void)
    535517{
    536518  PRINTF(4)("deleting the Packer part.\n");
     
    543525    delete this->down;
    544526  this->down = NULL;
    545 
    546   static_cast<Widget*>(this)->destroy();
    547527}
    548528
     
    575555   sets the Container-Specific defaults.
    576556*/
    577 void Container::init(void)
     557Container::Container(void)
    578558{
    579559  this->isOption = -1;
    580 
    581   static_cast<Packer*>(this)->init();
    582 
    583   return;
    584560}
    585561
     
    587563   \brief Destroys a Container.
    588564*/
    589 void Container::destroy(void)
     565Container::~Container(void)
    590566{
    591567  PRINTF(4)("deleting the Container part.\n");
    592 
    593   static_cast<Packer*>(this)->destroy();
    594568}
    595569
     
    665639Window::~Window(void)
    666640{
    667   this->destroy();
     641  if (this->title)
     642    PRINTF(3)("deleting the Window: %s\n", this->title);
     643  else
     644    PRINTF(3)("deleting the Window.\n");
     645  //  this->hide();
    668646}
    669647
     
    677655 
    678656  isOpen = false;
    679 
    680   static_cast<Container*>(this)->init();
    681657
    682658#ifdef HAVE_GTK2
     
    691667
    692668/**
    693    \brief Destroys a Window.
    694 */
    695 void Window::destroy(void)
    696 {
    697   if (this->title)
    698     PRINTF(3)("deleting the Window: %s\n", this->title);
    699   else
    700     PRINTF(3)("deleting the Window.\n");
    701   //  this->hide();
    702   static_cast<Container*>(this)->destroy();
    703  
    704 }
    705 
    706 /**
    707669   \brief Shows all Widgets that are included within this->widget.
    708670*/
     
    823785Frame::~Frame(void)
    824786{
    825   this->destroy();
    826 }
    827 
    828 /**
    829     \brief Initializes a new Frame with default settings
    830 */
    831 void Frame::init(void)
    832 {
    833   static_cast<Container*>(this)->init();
    834 
    835 #ifdef HAVE_GTK2
    836   this->widget = gtk_frame_new("");
    837   gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
    838 #endif /* HAVE_GTK2 */
    839 }
    840 
    841 /**
    842    \brief Destroys a Frame.
    843 */
    844 void Frame::destroy(void)
    845 {
    846787  if (this->title)
    847788    PRINTF(3)("deleting the Frame: %s\n", this->title);
    848789  else
    849790    PRINTF(3)("deleting the Frame.\n");
    850 
    851    static_cast<Container*>(this)->destroy();
     791}
     792
     793/**
     794    \brief Initializes a new Frame with default settings
     795*/
     796void Frame::init(void)
     797{
     798#ifdef HAVE_GTK2
     799  this->widget = gtk_frame_new("");
     800  gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
     801#endif /* HAVE_GTK2 */
    852802}
    853803
     
    892842EventBox::~EventBox(void)
    893843{
    894   this->destroy();
    895 
    896 }
    897 
    898 /**
    899    \brief Initializes a new EventBox
    900 */
    901 void EventBox::init(void)
    902 {
    903   this->isOption = -1;
    904 
    905   static_cast<Container*>(this)->init();
    906 
    907 #ifdef HAVE_GTK2
    908   this->widget = gtk_event_box_new();
    909   gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
    910 #endif /* HAVE_GTK2 */
    911 }
    912 
    913 /**
    914    \brief Destroys an EventBox.
    915 */
    916 void EventBox::destroy(void)
    917 {
    918844  if (this->title)
    919845    PRINTF(3)("deleting the EventBox: %s\n", this->title);
    920846  else
    921847    PRINTF(3)("deleting the EventBox.\n");
    922 
    923   static_cast<Container*>(this)->destroy();
     848}
     849
     850/**
     851   \brief Initializes a new EventBox
     852*/
     853void EventBox::init(void)
     854{
     855  this->isOption = -1;
     856
     857#ifdef HAVE_GTK2
     858  this->widget = gtk_event_box_new();
     859  gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
     860#endif /* HAVE_GTK2 */
    924861}
    925862
     
    960897Box::~Box(void)
    961898{
    962   this->destroy();
    963 }
    964 
    965 /**
    966    \brief Initializes a new Box with type boxtype
    967    \param boxtype see Box(char boxtype)
    968 */
    969 void Box::init(char boxtype)
    970 {
    971   this->isOption = -2;
    972 
    973   static_cast<Packer*>(this)->init();
    974 #ifdef HAVE_GTK2
    975   if (boxtype == 'v')
    976     {
    977       this->widget = gtk_vbox_new(FALSE, 0);
    978     }
    979   else
    980     {
    981       this->widget = gtk_hbox_new(FALSE, 0);
    982     }
    983 #endif /* HAVE_GTK2 */
    984 }
    985 
    986 /**
    987    \brief Destroys a Box.
    988 */
    989 void Box::destroy(void)
    990 {
    991899  if (this->title)
    992900    PRINTF(3)("deleting the Box: %s\n", this->title);
     
    994902    PRINTF(3)("deleting the Box.\n");
    995903
    996   static_cast<Packer*>(this)->destroy();
     904}
     905
     906/**
     907   \brief Initializes a new Box with type boxtype
     908   \param boxtype see Box(char boxtype)
     909*/
     910void Box::init(char boxtype)
     911{
     912  this->isOption = -2;
     913
     914#ifdef HAVE_GTK2
     915  if (boxtype == 'v')
     916    {
     917      this->widget = gtk_vbox_new(FALSE, 0);
     918    }
     919  else
     920    {
     921      this->widget = gtk_hbox_new(FALSE, 0);
     922    }
     923#endif /* HAVE_GTK2 */
    997924}
    998925
     
    1040967   sets all Option-Specific-Values to their defaults.
    1041968*/
    1042 void Option::init(void)
     969Option::Option(void)
    1043970{
    1044971  this->value = 0;
     
    1047974  this->saveable = false;
    1048975  this->defaultValue = 0;
    1049 
    1050   static_cast<Widget*>(this)->init();
    1051 
    1052   return;
    1053976}
    1054977
     
    1056979   \brief Destroys an Option.
    1057980*/
    1058 void Option::destroy(void)
     981Option::~Option(void)
    1059982{
    1060983  PRINTF(4)("deleting the Option Part.\n");
     
    1063986  if (this->flagNameShort)
    1064987    delete []this->flagNameShort;
    1065 
    1066   static_cast<Widget*>(this)->destroy();
    1067988}
    1068989
     
    11611082Button::~Button(void)
    11621083{
    1163   this->destroy();
    1164 }
    1165 
    1166 /**
    1167    \brief Initializes a new Button
    1168 */
    1169 void Button::init(void)
    1170 {
    1171   isOption = 0;
    1172 
    1173   static_cast<Option*>(this)->init();
    1174 
    1175 #ifdef HAVE_GTK2
    1176   widget = gtk_button_new_with_label("");
    1177 #endif /* HAVE_GTK2 */
    1178 }
    1179 
    1180 /**
    1181    \brief Destroys a Button.
    1182 */
    1183 void Button::destroy(void)
    1184 {
    11851084  if (this->title)
    11861085    PRINTF(3)("deleting the Label: %s\n", this->title);
     
    11881087    PRINTF(3)("deleting the Label.\n");
    11891088
    1190   static_cast<Option*>(this)->destroy();
     1089}
     1090
     1091/**
     1092   \brief Initializes a new Button
     1093*/
     1094void Button::init(void)
     1095{
     1096  isOption = 0;
     1097
     1098#ifdef HAVE_GTK2
     1099  widget = gtk_button_new_with_label("");
     1100#endif /* HAVE_GTK2 */
    11911101}
    11921102
     
    12451155CheckButton::~CheckButton(void)
    12461156{
    1247   this->destroy();
    1248 }
    1249 
    1250 /**
    1251    \brief Initialize a new CheckButton with default settings
    1252 */
    1253 void CheckButton::init(void)
    1254 {
    1255   this->isOption = 1;
    1256 
    1257   static_cast<Option*>(this)->init();
    1258 
    1259 #ifdef HAVE_GTK2
    1260   this->widget = gtk_check_button_new_with_label("");
    1261 #endif /* HAVE_GTK2 */
    1262 }
    1263 
    1264 /**
    1265    \brief Destroys a CheckButton.
    1266 */
    1267 void CheckButton::destroy(void)
    1268 {
    12691157  if (this->title)
    12701158    PRINTF(3)("deleting the CheckButton: %s\n", this->title);
    12711159  else
    12721160    PRINTF(3)("deleting the CheckButton.\n");
    1273 
    1274   static_cast<Option*>(this)->destroy();
     1161}
     1162
     1163/**
     1164   \brief Initialize a new CheckButton with default settings
     1165*/
     1166void CheckButton::init(void)
     1167{
     1168  this->isOption = 1;
     1169
     1170#ifdef HAVE_GTK2
     1171  this->widget = gtk_check_button_new_with_label("");
     1172#endif /* HAVE_GTK2 */
    12751173}
    12761174
     
    13501248Slider::~Slider(void)
    13511249{
    1352   this->destroy();
    1353 }
    1354 
    1355 /**
    1356    \brief Initializes a Slider with start and end Values
    1357    params: see Slider::Slider(char* slidername, int start, int end)
    1358 */
    1359 void Slider::init(int start, int end)
    1360 {
    1361   this->isOption = 2;
    1362 
    1363   static_cast<Option*>(this)->init();
    1364 
    1365   this->start = start;
    1366   this->end = end;
    1367 #ifdef HAVE_GTK2
    1368  widget = gtk_hscale_new_with_range(this->start, this->end, 5);
    1369 #endif /* HAVE_GTK2 */
    1370 }
    1371 
    1372 /**
    1373    \brief Destroys a Slider.
    1374 */
    1375 void Slider::destroy(void)
    1376 {
    13771250  if (this->title)
    13781251    PRINTF(3)("deleting the Slider: %s\n", this->title);
    13791252  else
    13801253    PRINTF(3)("deleting the Slider.\n");
    1381 
    1382   static_cast<Option*>(this)->destroy();
    1383 
     1254}
     1255
     1256/**
     1257   \brief Initializes a Slider with start and end Values
     1258   params: see Slider::Slider(char* slidername, int start, int end)
     1259*/
     1260void Slider::init(int start, int end)
     1261{
     1262  this->isOption = 2;
     1263
     1264  this->start = start;
     1265  this->end = end;
     1266#ifdef HAVE_GTK2
     1267 widget = gtk_hscale_new_with_range(this->start, this->end, 5);
     1268#endif /* HAVE_GTK2 */
    13841269}
    13851270
     
    14711356Menu::~Menu(void)
    14721357{
    1473   this->destroy();
    1474 }
    1475 
    1476 /**
    1477    \brief Initializes a new Menu with no items
    1478 */
    1479 void Menu::init(void)
    1480 {
    1481   this->isOption = 2;
    1482 
    1483   static_cast<Option*>(this)->init();
    1484 
    1485 #ifdef HAVE_GTK2
    1486   this->widget = gtk_option_menu_new();
    1487   this->menu = gtk_menu_new();
    1488 #endif /* HAVE_GTK2 */
    1489 
    1490 }
    1491 
    1492 /**
    1493    \brief Destroys a Menu.
    1494 */
    1495 void Menu::destroy(void)
    1496 {
    14971358  if (this->title)
    14981359    PRINTF(3)("deleting the Menu: %s\n", this->title);
     
    15001361    PRINTF(3)("deleting the Menu.\n");
    15011362  //! \todo destroy menu
    1502  
    1503   static_cast<Option*>(this)->destroy();
    1504 }
    1505 
     1363
     1364}
     1365
     1366/**
     1367   \brief Initializes a new Menu with no items
     1368*/
     1369void Menu::init(void)
     1370{
     1371  this->isOption = 2;
     1372
     1373#ifdef HAVE_GTK2
     1374  this->widget = gtk_option_menu_new();
     1375  this->menu = gtk_menu_new();
     1376#endif /* HAVE_GTK2 */
     1377
     1378}
    15061379
    15071380/**
     
    15781451OptionLabel::~OptionLabel(void)
    15791452{
    1580   this->destroy();
    1581 }
    1582 
    1583 /**
    1584    \brief Initializes an OptionLabel
    1585 */
    1586 void OptionLabel::init(void)
    1587 {
    1588   this->isOption = 5;
    1589   static_cast<Option*>(this)->init();
    1590 
    1591   cValue = NULL;
    1592 
    1593 #ifdef HAVE_GTK2
    1594   this->widget = gtk_label_new("");
    1595 #endif /* HAVE_GTK2 */
    1596 }
    1597 
    1598 /**
    1599    \brief Destroys a OptionLabel.
    1600 */
    1601 void OptionLabel::destroy(void)
    1602 {
    16031453  if (this->title)
    16041454    PRINTF(3)("deleting the OptionLabel: %s\n", this->title);
     
    16071457  if (this->cValue)
    16081458    delete []this->cValue;
    1609 
    1610   static_cast<Option*>(this)->destroy();
    1611 }
    1612 
     1459}
     1460
     1461/**
     1462   \brief Initializes an OptionLabel
     1463*/
     1464void OptionLabel::init(void)
     1465{
     1466  this->isOption = 5;
     1467  cValue = NULL;
     1468
     1469#ifdef HAVE_GTK2
     1470  this->widget = gtk_label_new("");
     1471#endif /* HAVE_GTK2 */
     1472}
    16131473
    16141474/**
     
    16891549Label::~Label(void)
    16901550{
    1691   this->destroy();
    1692 }
    1693 
    1694 /**
    1695    \brief initializes a new Label
    1696 */
    1697 void Label::init(void)
    1698 {
    1699   this->isOption = 0;
    1700 
    1701   static_cast<Widget*>(this)->init();
    1702 
    1703 #ifdef HAVE_GTK2
    1704   this->widget = gtk_label_new("");
    1705   gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE);
    1706 #endif /* HAVE_GTK2 */
    1707 }
    1708 
    1709 /**
    1710    \brief Destroys a Label.
    1711 */
    1712 void Label::destroy(void)
    1713 {
    17141551  if (this->title)
    17151552    PRINTF(3)("deleting the Label: %s\n", this->title);
    17161553  else
    17171554    PRINTF(3)("deleting the Label.\n");
    1718 
    1719   static_cast<Widget*>(this)->destroy();
     1555}
     1556
     1557/**
     1558   \brief initializes a new Label
     1559*/
     1560void Label::init(void)
     1561{
     1562  this->isOption = 0;
     1563
     1564#ifdef HAVE_GTK2
     1565  this->widget = gtk_label_new("");
     1566  gtk_label_set_line_wrap(GTK_LABEL(this->widget), TRUE);
     1567#endif /* HAVE_GTK2 */
    17201568}
    17211569
     
    18131661ProgressBar::~ProgressBar(void)
    18141662{
    1815   this->destroy();
     1663  if (this->title)
     1664    PRINTF(3)("deleting the ProgressBar: %s\n", this->title);
     1665  else
     1666    PRINTF(3)("deleting the ProgressBar.\n");
    18161667}
    18171668
     
    18251676  this->totalSize = 0.0;
    18261677
    1827   static_cast<Widget*>(this)->init();
    18281678#ifdef HAVE_GTK2
    18291679  this->adjustment =(GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
    18301680  this->widget = gtk_progress_bar_new_with_adjustment(this->adjustment);
    18311681#endif /* HAVE_GTK2 */
    1832 }
    1833 
    1834 /**
    1835    \brief Destroys a ProgressBar.
    1836 */
    1837 void ProgressBar::destroy(void)
    1838 {
    1839   if (this->title)
    1840     PRINTF(3)("deleting the ProgressBar: %s\n", this->title);
    1841   else
    1842     PRINTF(3)("deleting the ProgressBar.\n");
    1843 
    1844   static_cast<Widget*>(this)->destroy();
    18451682}
    18461683
     
    19131750Image::~Image(void)
    19141751{
    1915   this->destroy();
    1916 }
    1917 
    1918 /**
    1919     \brief Initializes a new Image
    1920 */
    1921 void Image::init(void)
    1922 {
    1923   isOption = 0;
    1924 
    1925   static_cast<Widget*>(this)->init();
    1926 }
    1927 
    1928 /**
    1929    \brief Destroys a Image.
    1930 */
    1931 void Image::destroy(void)
    1932 {
    19331752  if (this->title)
    19341753    PRINTF(3)("deleting the Image: %s\n", this->title);
    19351754  else
    19361755    PRINTF(3)("deleting the Image.\n");
    1937 
    1938   static_cast<Widget*>(this)->destroy();
     1756}
     1757
     1758/**
     1759    \brief Initializes a new Image
     1760*/
     1761void Image::init(void)
     1762{
     1763  isOption = 0;
    19391764}
    19401765
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.h

    r3590 r3623  
    3939
    4040 public:
     41  Widget(void);
    4142  virtual ~Widget(void);
    42   void init(void);
    43   void destroy(void);
    4443
    4544  void show(void);
     
    9089{
    9190 public:
     91  Packer(void);
     92  virtual ~Packer(void);
     93
    9294  Widget* down; //!< this points to the Widget below this.
    9395  char* groupName; //!< For each Packer you can specify a Groupname under which the lowerWidgets will be saved.
    94 
    95   void init(void);
    96   void destroy(void);
    9796
    9897  void setGroupName(char* name);
     
    115114 
    116115 public:
    117   void init(void);
    118   void destroy(void);
    119 
     116  Container(void);
     117  virtual ~Container(void);
    120118  //  void setBorderWidth(int borderwidth);
    121119  //  virtual void setTitle(char* title) = 0;
     
    138136  Window(void);
    139137  Window(char* windowName);
    140   ~Window(void);
    141   void init(void);
    142   void destroy(void);
     138  virtual ~Window(void);
     139  void init(void);
    143140 
    144141  void setTitle(char* title);
     
    164161  Frame(void);
    165162  Frame(char* frameName);
    166   ~Frame(void);
    167   void init(void);
    168   void destroy(void);
     163  virtual ~Frame(void);
     164  void init(void);
    169165 
    170166  void setTitle(char* title);
     
    180176  EventBox(void);
    181177  EventBox(char* eventBoxName);
    182   ~EventBox(void);
    183   void init(void);
    184   void destroy(void);
     178  virtual ~EventBox(void);
     179  void init(void);
    185180 
    186181  void setTitle(char* title);
     
    198193  Box(void);
    199194  Box(char boxtype);
    200   ~Box(void);
     195  virtual ~Box(void);
    201196  void init(char boxtype);
    202   void destroy(void);
    203197 
    204198  void fill(Widget* lowerWidget);
     
    217211 
    218212 public:
    219   void init(void);
    220   void destroy(void);
     213  Option(void);
     214  virtual ~Option(void);
     215  void init(void);
    221216
    222217  int value; //!< every option has a value either true or false(0,1) or something else like 25 for 25% of the volume
     
    246241 public:
    247242  Button(char* buttonname);
    248   ~Button(void);
    249   void init(void);
    250   void destroy(void);
     243  virtual ~Button(void);
     244  void init(void);
    251245
    252246  void setTitle(char* title);
     
    262256 public:
    263257  CheckButton(char* buttonname);
    264   ~CheckButton(void);
    265   void init(void);
    266   void destroy(void);
     258  virtual ~CheckButton(void);
     259  void init(void);
    267260
    268261  void setTitle(char* title);
     
    283276 public:
    284277  Slider(char* slidername, int start, int end);
    285   ~Slider(void);
     278  virtual ~Slider(void);
    286279  void init(int start, int end);
    287   void destroy(void);
    288280
    289281  void setTitle(char* title);
     
    305297 public:
    306298  Menu(char* menuname, ...);
    307   ~Menu(void);
    308   void init(void);
    309   void destroy(void);
     299  virtual ~Menu(void);
     300  void init(void);
    310301 
    311302  void setTitle(char* title);
     
    322313 public:
    323314  OptionLabel(char* label, char* value);
    324   ~OptionLabel(void);
    325   void init(void);
    326   void destroy(void);
    327  
     315  virtual ~OptionLabel(void);
     316  void init(void);
    328317 
    329318  void setValue(char* newValue);
     
    342331  Label(void);
    343332  Label(char* text);
    344   ~Label(void);
    345   void init(void);
    346   void destroy(void);
     333  virtual ~Label(void);
     334  void init(void);
    347335 
    348336  void setTitle(char* text);
     
    359347  ProgressBar(void);
    360348  ProgressBar(char* label);
    361   ~ProgressBar(void);
    362   void init(void);
    363   void destroy(void);
     349  virtual ~ProgressBar(void);
     350  void init(void);
    364351
    365352  void setTitle(char* title);
     
    385372 public:
    386373  Image(char* imgaename);
    387   ~Image(void);
    388   void init(void);
    389   void destroy(void);
     374  virtual ~Image(void);
     375  void init(void);
    390376
    391377  void setTitle(char* title);
Note: See TracChangeset for help on using the changeset viewer.