Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3624 in orxonox.OLD


Ignore:
Timestamp:
Mar 22, 2005, 1:19:28 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: gui: now the resolution is integrated from SDL. I hope this works on Windows too.
also fixed some virtual-function-stuff
also added better ability for menu→addItem, so now it should also work in non-GTK mode (after addaption).

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

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/gui/gui/Makefile.am

    r3493 r3624  
    2121
    2222#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
    23 LIBS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
     23AM_LDFLAGS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    2424
    2525bin_PROGRAMS=gui
  • orxonox/trunk/src/lib/gui/gui/Makefile.in

    r3579 r3624  
    131131LDFLAGS = @LDFLAGS@
    132132LIBOBJS = @LIBOBJS@
    133 
    134 #AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
    135 LIBS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
     133LIBS = @LIBS@
    136134LTLIBOBJS = @LTLIBOBJS@
    137135MAKEINFO = @MAKEINFO@
     
    195193MAINSRCDIR = ../../..
    196194AM_CXXFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) -I$(MAINSRCDIR) -I$(MAINSRCDIR)/world_entities -I$(MAINSRCDIR)/story_entities -I$(MAINSRCDIR)/lib -I$(MAINSRCDIR)/lib/coord -I$(MAINSRCDIR)/lib/data -I$(MAINSRCDIR)/lib/gaphics -I$(MAINSRCDIR)/lib/graphics/font -I$(MAINSRCDIR)/lib/graphics/importer -I$(MAINSRCDIR)/lib/gui -I$(MAINSRCDIR)/lib/lang -I$(MAINSRCDIR)/lib/util -I$(MAINSRCDIR)/lib/math -I$(MAINSRCDIR)/defs -I$(MAINSRCDIR)/font -I$(MAINSRCDIR)/network -I$(MAINSRCDIR)/glmenu -I$(MAINSRCDIR)/ai
     195
     196#AM_LDFLAGS=$(GTK2_LIBS)   $(GTHREAD_LIBS)
     197AM_LDFLAGS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    197198gui_SOURCES = orxonox_gui.cc \
    198199            orxonox_gui_gtk.cc \
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc

    r3623 r3624  
    168168
    169169/**
     170   \brief sets a new Title to a Widget
     171   \param title The new Title to set to the Widget
     172*/
     173void Widget::setTitle(const char* title)
     174{
     175  if (this->title)
     176    delete []this->title;
     177  this->title = new char[strlen(title)+1];
     178  strcpy(this->title, title);
     179}
     180
     181/**
    170182   \brief makes the widget visible.
    171183*/
     
    692704   \param title title the Window should get.
    693705*/
    694 void Window::setTitle(char* title)
     706void Window::setTitle(const char* title)
    695707{
    696708  if (this->title)
     
    806818   \param title The title the Frame should get.
    807819*/
    808 void Frame::setTitle(char* title)
     820void Frame::setTitle(const char* title)
    809821{
    810822  if (this->title)
     
    859871  gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3);
    860872#endif /* HAVE_GTK2 */
    861 }
    862 
    863 /**
    864    \brief Sets the Title of the EventBox(not implemented)
    865    \param title Name the EventBox should get(only datastructure-internal).
    866 */
    867 void EventBox::setTitle(char* title)
    868 {
    869   if (this->title)
    870     delete []this->title;
    871   this->title = new char[strlen(title)+1];
    872   strcpy(this->title, title);
    873873}
    874874
     
    949949}
    950950
    951 /**
    952    \brief Sets the Title of a Box.
    953    \param title the new Title to set.
    954 */
    955 void Box::setTitle(char* title)
    956 {
    957   if (this->title)
    958     delete []this->title;
    959   this->title = new char[strlen(title)+1];
    960   strcpy(this->title, title);
    961 }
    962 
    963951/* OPTION */
    964952
     
    11051093   \param title The name the Button should get
    11061094*/
    1107 void Button::setTitle(char *title)
     1095void Button::setTitle(const char *title)
    11081096{
    11091097  if (this->title)
     
    11771165   \param title The new Name the CheckButton should display.
    11781166*/
    1179 void CheckButton::setTitle(char* title)
     1167void CheckButton::setTitle(const char* title)
    11801168{
    11811169  if (this->title)
     
    12701258
    12711259/**
    1272    \brief Sets a new Title to the Slider
    1273    \param title The new Name of the slider
    1274 */
    1275 void Slider::setTitle(char* title)
    1276 {
    1277   if (this->title)
    1278     delete []this->title;
    1279   this->title = new char[strlen(title)+1];
    1280   strcpy(this->title, title);
    1281 }
    1282 
    1283 /**
    12841260   \brief Setting a new value to the Slider.
    12851261   Maybe you also require a Slider::redraw() for this to display
     
    13231299/* MENU */
    13241300
     1301/**
     1302   \brief constructs a new Menu, without adding any items to it.
     1303   \param menuName the Name the Menu gets.
     1304*/
     1305Menu::Menu(const char* menuName)
     1306{
     1307  this->init();
     1308  this->setTitle(menuName);
     1309}
     1310
    13251311/**
    13261312    \brief Creates a Menu-Item-list out of multiple input.
     
    13361322  char *itemName;
    13371323
    1338 #ifdef HAVE_GTK2             /////////////////////// REINPLEMENT
    13391324  va_start(itemlist, menuname);
    13401325  while(strcmp(itemName = va_arg(itemlist, char*), "lastItem"))
     
    13431328    }
    13441329  va_end(itemlist);
    1345 #endif /* HAVE_GTK2 */
    1346 
    1347 #ifdef HAVE_GTK2
    1348   gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu);
    1349   this->connectSignal("changed", this->OptionChange);
    1350 #endif /* HAVE_GTK2 */
    13511330}
    13521331
     
    13611340    PRINTF(3)("deleting the Menu.\n");
    13621341  //! \todo destroy menu
    1363 
     1342  this->currItem = this->firstItem;
     1343  while(this->currItem)
     1344    {
     1345      delete []this->currItem->name;
     1346      /*
     1347        #ifdef HAVE_GTK2
     1348        free(this->currItem->item);
     1349        #endif /* HAVE_GTK2 */
     1350      MenuItem* tmpItem = this->currItem;
     1351      this->currItem = this->currItem->next;
     1352      delete tmpItem;
     1353    }
    13641354}
    13651355
     
    13701360{
    13711361  this->isOption = 2;
     1362  this->firstItem = NULL;
    13721363
    13731364#ifdef HAVE_GTK2
    13741365  this->widget = gtk_option_menu_new();
    13751366  this->menu = gtk_menu_new();
    1376 #endif /* HAVE_GTK2 */
    1377 
    1378 }
    1379 
    1380 /**
    1381  * Sets the Database-Name of this Menu
    1382  \param title Database-Name to be set.
    1383 */
    1384 void Menu::setTitle(char* title)
    1385 {
    1386   if (this->title)
    1387     delete []this->title;
    1388   this->title = new char[strlen(title)+1];
    1389   strcpy(this->title, title);
     1367  gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu);
     1368  this->connectSignal("changed", this->OptionChange);
     1369#endif /* HAVE_GTK2 */
    13901370}
    13911371
     
    13931373   \brief appends a new Item to the Menu-List.
    13941374   \param itemName the itemName to be appendet.
    1395 
    1396    \todo make the item-list readable without GTK
    13971375*/
    13981376void Menu::addItem(char* itemName)
    13991377{
    1400 #ifdef HAVE_GTK2
    1401   this->item = gtk_menu_item_new_with_label(itemName);
    1402   gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->item);
    1403 #endif /* HAVE_GTK2 */
     1378  if (!this->firstItem)
     1379    this->firstItem = this->currItem = new MenuItem;
     1380  else
     1381    this->currItem = this->currItem->next = new MenuItem;
     1382
     1383  this->currItem->name = new char[strlen(itemName)+1];
     1384  strcpy(this->currItem->name, itemName);
     1385#ifdef HAVE_GTK2
     1386  this->currItem->item = gtk_menu_item_new_with_label(itemName);
     1387  gtk_menu_shell_append(GTK_MENU_SHELL(this->menu), this->currItem->item);
     1388#endif /* HAVE_GTK2 */
     1389  this->currItem->next = NULL;
    14041390}
    14051391
     
    14881474
    14891475/**
    1490    \brief Sets a ned Title to the OptionLabel.
    1491    \param title The now title of the OptionLabel.
    1492 */
    1493 void OptionLabel::setTitle(char* title)
    1494 {
    1495   if (this->title)
    1496     delete []this->title;
    1497   this->title = new char [strlen(title)+1];
    1498   strcpy(this->title, title);
    1499   this->redraw();
    1500 }
    1501 
    1502 /**
    15031476   \brief Redraws an OptionLabel(not implemented yet, but it works).
    15041477*/
     
    16831656
    16841657/**
    1685    \brief Sets a ned Title to the ProgressBar.
    1686    \param title The now title of the ProgressBar.
    1687 */
    1688 void ProgressBar::setTitle(char* title)
    1689 {
    1690   if (this->title)
    1691     delete []this->title;
    1692   this->title = new char [strlen(title)+1];
    1693   strcpy(this->title, title);
    1694 }
    1695 
    1696 /**
    16971658   \brief Sets the Total size of the Bar.(ex. The maximum one can download)
    16981659*/
     
    17631724  isOption = 0;
    17641725}
    1765 
    1766 /**
    1767    \brief Sets a ned Title to the Image.
    1768    \param title The now title of the OptionLabel.
    1769 */
    1770 void Image::setTitle(char* title)
    1771 {
    1772   if (this->title)
    1773     delete []this->title;
    1774   this->title = new char [strlen(title)+1];
    1775   strcpy(this->title, title);
    1776 }
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.h

    r3623 r3624  
    4545  void hide(void);
    4646  void setSize(int width, int height);
    47   virtual void setTitle(char* title) = 0;  //!< An abstract Function, that sets the title of Widgets.
     47  virtual void setTitle(const char* title);  //!< An abstract Function, that sets the title of Widgets.
    4848
    4949  Widget* findWidgetByName(char* name, unsigned int depth);
     
    117117  virtual ~Container(void);
    118118  //  void setBorderWidth(int borderwidth);
    119   //  virtual void setTitle(char* title) = 0;
    120119  void fill(Widget* lowerWidget);
    121120};
     
    139138  void init(void);
    140139 
    141   void setTitle(char* title);
     140  void setTitle(const char* title);
    142141  void showall(void);
    143142  void open(void);
     
    163162  virtual ~Frame(void);
    164163  void init(void);
    165  
    166   void setTitle(char* title);
     164
     165  void setTitle(const char* title);
    167166};
    168167
     
    178177  virtual ~EventBox(void);
    179178  void init(void);
    180  
    181   void setTitle(char* title);
    182179};
    183180
     
    197194 
    198195  void fill(Widget* lowerWidget);
    199 
    200   void setTitle(char* title);
    201196};
    202197
     
    244239  void init(void);
    245240
    246   void setTitle(char* title);
     241  void setTitle(const char* title);
    247242  void redraw(void);
    248243  void changeOption(void);
     
    259254  void init(void);
    260255
    261   void setTitle(char* title);
     256  void setTitle(const char* title);
    262257  bool isActive(void);           //!< a Bool value to see, if this CheckButton is active.
    263258  void redraw(void);
     
    279274  void init(int start, int end);
    280275
    281   void setTitle(char* title);
    282276  void setValue(int value);
    283277  void redraw(void);
     
    291285#ifdef HAVE_GTK2
    292286  GtkWidget* menu;                      //!< The menu That will hold the Options.
    293   GtkWidget* item;                      //!< One Item From a Menu.
    294287#endif /* HAVE_GTK2 */
    295288  va_list itemlist;                     //!< The list to readin multiple Options.
    296289 
    297  public:
     290  //! A struct to handle the MenuItems
     291  struct MenuItem
     292  {
     293    char* name;                         //!< The name of this entry.
     294#ifdef HAVE_GTK2
     295    GtkWidget* item;                    //!< One Item From a Menu.
     296#endif /* HAVE_GTK2 */
     297    MenuItem* next;                     //!< Pointer to the next MenuItem.
     298  };
     299  MenuItem* firstItem;                  //!< Pointer to the first Item.
     300  MenuItem* currItem;                   //!< Pointer to the current Item.
     301 
     302 public:
     303  Menu(const char* menuName);
    298304  Menu(char* menuname, ...);
    299305  virtual ~Menu(void);
    300306  void init(void);
    301307 
    302   void setTitle(char* title);
    303308  void addItem(char* itemName);
    304309  void redraw(void);
     
    317322 
    318323  void setValue(char* newValue);
    319   void setTitle(char* title);
    320324  void redraw(void);
    321325  void changeOption(void);
     
    350354  void init(void);
    351355
    352   void setTitle(char* title);
    353356  void setProgress(double progress);
    354357  void setTotalSize(double totalSize);
     
    374377  virtual ~Image(void);
    375378  void init(void);
    376 
    377   void setTitle(char* title);
    378379};
    379380
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_video.cc

    r3452 r3624  
    2727#include "orxonox_gui_video.h"
    2828
     29#include "glincl.h"
     30
    2931/**
    3032   \brief Creates the Video-Option-Frame
     
    4042  this->fullscreen->saveability();
    4143  this->videoBox->fill(this->fullscreen);
    42   this->resolution = new Menu("Resolution", "640x480", "800x600", "1024x768", "1280x1024", "1400x1050", "1600x1200", "1920x1200", "lastItem");
     44  this->resolution = new Menu("Resolution");
     45  this->getResolutions(this->resolution);
    4346  this->resolution->saveability();
    4447  this->videoBox->fill(this->resolution);
     
    146149}
    147150
     151void OrxonoxGuiVideo::getResolutions(Menu* menu)
     152{
     153  SDL_Init(SDL_INIT_VIDEO);
     154  SDL_Rect **modes;
     155  int i;
     156  char tmpChar[100];
     157 
     158  /* Get available fullscreen/hardware modes */
     159  modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
     160 
     161  /* Check is there are any modes available */
     162  if(modes == (SDL_Rect **)0){
     163    PRINTF(2)("No video-modes available!\n");
     164    exit(-1);
     165  }
     166 
     167  /* Check if our resolution is restricted */
     168  if(modes == (SDL_Rect **)-1){
     169    PRINTF(2)("All resolutions available.\n");
     170  }
     171  else{
     172    /* Print valid modes */
     173    PRINT(4)("Available Modes\n");
     174    for(i = 0; modes[i] ;++i)
     175      {
     176        PRINT(4)("  %d x %d\n", modes[i]->w, modes[i]->h);
     177        sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
     178        menu->addItem(tmpChar);
     179      }
     180  }
     181  SDL_Quit();
     182}
  • orxonox/trunk/src/lib/gui/gui/orxonox_gui_video.h

    r3452 r3624  
    4545  OrxonoxGuiVideo(void);
    4646  ~OrxonoxGuiVideo(void);
     47
     48  Widget* getWidget(void);
     49
     50  void getResolutions(Menu* menu);
    4751 
    48   Widget* getWidget(void);
     52
    4953};
    5054#endif /* _ORXONOX_GUI_VIDEO_H */
Note: See TracChangeset for help on using the changeset viewer.