Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3158 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Dec 11, 2004, 11:55:08 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk/gui: safer (char* initialization), nicer _n →N

Location:
orxonox/trunk/gui
Files:
4 edited

Legend:

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

    r3147 r3158  
    7474{
    7575  if (widget->isOption >= 1)
    76     if  (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->default_value && (strcmp (static_cast<Option*>(widget)->flag_name, "") || strcmp (static_cast<Option*>(widget)->flag_name_short, "")))
     76    if  (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue && (static_cast<Option*>(widget)->flagName || static_cast<Option*>(widget)->flagNameShort ))
    7777      {
    7878        if (shortFlags->isActive())
    7979          {
    8080            strcat (flagText, " -");
    81             strcat (flagText, static_cast<Option*>(widget)->flag_name_short);
     81            strcat (flagText, static_cast<Option*>(widget)->flagNameShort);
    8282          }
    8383        else
    8484          {
    8585            strcat (flagText, " --");
    86             strcat (flagText, static_cast<Option*>(widget)->flag_name);
     86            strcat (flagText, static_cast<Option*>(widget)->flagName);
    8787          }
    8888        if (static_cast<Option*>(widget)->isOption == 2)
  • orxonox/trunk/gui/orxonox_gui_gtk.cc

    r3157 r3158  
    6969{
    7070  next = NULL;
    71   label = "";
     71  label = NULL;
    7272  return;
    7373}
     
    331331void Window::setTitle (char* title)
    332332{
    333   label=title;
     333  if (label)
     334    delete label;
     335  label = new char[strlen(title)+1];
     336  strcpy(label, title);
    334337  gtk_window_set_title (GTK_WINDOW (widget), title);
    335338}
     
    438441void Frame::setTitle (char* title)
    439442{
    440   label = title;
     443  if (label)
     444    delete label;
     445  label = new char[strlen(title)+1];
     446  strcpy(label, title);
    441447  gtk_frame_set_label (GTK_FRAME (widget), title);
    442448}
     
    481487void EventBox::setTitle (char* title)
    482488{
    483   label = title;
     489  if (label)
     490    delete label;
     491  label = new char[strlen(title)+1];
     492  strcpy(label, title);
    484493}
    485494
     
    552561Image::Image (char* imagename)
    553562{
     563  if (label)
     564    delete label;
     565  label = new char[strlen(imagename)+1];
     566  strcpy(label, imagename);
     567
    554568  this->init();
    555569  widget = gtk_image_new_from_file (imagename);
    556   label = imagename;
    557570}
    558571
     
    577590{
    578591  value = 0;
    579   flag_name = "";
    580   flag_name_short = "";
     592  flagName = NULL;
     593  flagNameShort = NULL;
    581594  saveable = false;
    582   default_value = 0;
     595  defaultValue = 0;
    583596
    584597  static_cast<Widget*>(this)->init();
     
    595608void Option::setFlagName (char* flagname, int defaultvalue)
    596609{
    597   flag_name = flagname;
    598   default_value = defaultvalue;
     610  if (flagName)
     611    delete flagName;
     612  flagName = new char [strlen(flagname)+1];
     613  strcpy(flagName, flagname);
     614  defaultValue = defaultvalue;
    599615  cout << "Set Flagname of " << label << " to " << flagname << endl;
    600616}
     
    608624void Option::setFlagName (char* flagname, char* flagnameshort,  int defaultvalue)
    609625{
    610   flag_name = flagname;
    611   flag_name_short = flagnameshort;
    612   default_value = defaultvalue;
     626  if (flagName)
     627    delete flagName;
     628  flagName = new char [strlen(flagname)+1];
     629  strcpy(flagName, flagname);
     630
     631  if (flagNameShort)
     632    delete flagNameShort;
     633  flagNameShort = new char [strlen(flagnameshort)+1];
     634  strcpy(flagName, flagnameshort);
     635  defaultValue = defaultvalue;
    613636  cout << "Set Flagname of " << label << " to " << flagname << endl;
    614637}
     
    689712void CheckButton::setTitle(char* title)
    690713{
    691   label = title;
     714  if (label)
     715    delete label;
     716  label = new char[strlen(title)+1];
     717  strcpy(label, title);
    692718  gtk_button_set_label(GTK_BUTTON(widget), title);
    693719}
     
    754780void Slider::setTitle(char* title)
    755781{
    756   label = title;
     782  if (label)
     783    delete label;
     784  label = new char[strlen(title)+1];
     785  strcpy(label, title);
    757786}
    758787
     
    833862void Menu::setTitle(char* title)
    834863{
    835   label = title;
     864  if (label)
     865    delete label;
     866  label = new char[strlen(title)+1];
     867  strcpy(label, title);
    836868}
    837869
     
    930962void Label::setText (char* text)
    931963{
    932   label = text;
     964  if (label)
     965    delete label;
     966  label = new char[strlen(text)+1];
     967  strcpy(label, text);
    933968  gtk_label_set_text (GTK_LABEL (this->widget), text);
    934969}
  • orxonox/trunk/gui/orxonox_gui_gtk.h

    r3157 r3158  
    181181
    182182  int value; //!< every option has a value either true or false (0,1) or something else like 25 for 25% of the volume
    183   char* flag_name; //!< options have a flag name that will be appendet if you start the Program from the GUI.
    184   char* flag_name_short; //!< like flag_name but shorter
    185   int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
     183  char* flagName; //!< options have a flag name that will be appendet if you start the Program from the GUI.
     184  char* flagNameShort; //!< like flag_name but shorter
     185  int defaultValue; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value)
    186186  bool saveable;  //! Options can be Saved.
    187187
  • orxonox/trunk/gui/orxonox_gui_keys.cc

    r3157 r3158  
    8484  inputButton = new Button ("test");
    8585  inputWindow->fill (inputButton);
    86   inputWindow->connectSignal("destroy", inputWindow, Widget::doNothingSignal);
    87   inputWindow->connectSignal("delete_event", inputWindow, Widget::doNothingSignal);
     86  inputWindow->connectSignal("destroy", Widget::doNothingSignal);
     87  inputWindow->connectSignal("delete_event", Widget::doNothingSignal);
    8888
    8989}
     
    255255      break;
    256256    }
     257
    257258  inputkey->pKeyOLabel->setTitle (title);
    258259  inputButton->disconnectSignal(keySignal);
Note: See TracChangeset for help on using the changeset viewer.