- Timestamp:
- Mar 22, 2005, 1:19:28 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/gui/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui/Makefile.am
r3493 r3624 21 21 22 22 #AM_LDFLAGS=$(GTK2_LIBS) $(GTHREAD_LIBS) 23 LIBS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)23 AM_LDFLAGS=$(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 24 24 25 25 bin_PROGRAMS=gui -
orxonox/trunk/src/lib/gui/gui/Makefile.in
r3579 r3624 131 131 LDFLAGS = @LDFLAGS@ 132 132 LIBOBJS = @LIBOBJS@ 133 134 #AM_LDFLAGS=$(GTK2_LIBS) $(GTHREAD_LIBS) 135 LIBS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 133 LIBS = @LIBS@ 136 134 LTLIBOBJS = @LTLIBOBJS@ 137 135 MAKEINFO = @MAKEINFO@ … … 195 193 MAINSRCDIR = ../../.. 196 194 AM_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) 197 AM_LDFLAGS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 197 198 gui_SOURCES = orxonox_gui.cc \ 198 199 orxonox_gui_gtk.cc \ -
orxonox/trunk/src/lib/gui/gui/orxonox_gui_gtk.cc
r3623 r3624 168 168 169 169 /** 170 \brief sets a new Title to a Widget 171 \param title The new Title to set to the Widget 172 */ 173 void 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 /** 170 182 \brief makes the widget visible. 171 183 */ … … 692 704 \param title title the Window should get. 693 705 */ 694 void Window::setTitle(c har* title)706 void Window::setTitle(const char* title) 695 707 { 696 708 if (this->title) … … 806 818 \param title The title the Frame should get. 807 819 */ 808 void Frame::setTitle(c har* title)820 void Frame::setTitle(const char* title) 809 821 { 810 822 if (this->title) … … 859 871 gtk_container_set_border_width(GTK_CONTAINER(this->widget), 3); 860 872 #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);873 873 } 874 874 … … 949 949 } 950 950 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 963 951 /* OPTION */ 964 952 … … 1105 1093 \param title The name the Button should get 1106 1094 */ 1107 void Button::setTitle(c har *title)1095 void Button::setTitle(const char *title) 1108 1096 { 1109 1097 if (this->title) … … 1177 1165 \param title The new Name the CheckButton should display. 1178 1166 */ 1179 void CheckButton::setTitle(c har* title)1167 void CheckButton::setTitle(const char* title) 1180 1168 { 1181 1169 if (this->title) … … 1270 1258 1271 1259 /** 1272 \brief Sets a new Title to the Slider1273 \param title The new Name of the slider1274 */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 /**1284 1260 \brief Setting a new value to the Slider. 1285 1261 Maybe you also require a Slider::redraw() for this to display … … 1323 1299 /* MENU */ 1324 1300 1301 /** 1302 \brief constructs a new Menu, without adding any items to it. 1303 \param menuName the Name the Menu gets. 1304 */ 1305 Menu::Menu(const char* menuName) 1306 { 1307 this->init(); 1308 this->setTitle(menuName); 1309 } 1310 1325 1311 /** 1326 1312 \brief Creates a Menu-Item-list out of multiple input. … … 1336 1322 char *itemName; 1337 1323 1338 #ifdef HAVE_GTK2 /////////////////////// REINPLEMENT1339 1324 va_start(itemlist, menuname); 1340 1325 while(strcmp(itemName = va_arg(itemlist, char*), "lastItem")) … … 1343 1328 } 1344 1329 va_end(itemlist); 1345 #endif /* HAVE_GTK2 */1346 1347 #ifdef HAVE_GTK21348 gtk_option_menu_set_menu(GTK_OPTION_MENU(this->widget), menu);1349 this->connectSignal("changed", this->OptionChange);1350 #endif /* HAVE_GTK2 */1351 1330 } 1352 1331 … … 1361 1340 PRINTF(3)("deleting the Menu.\n"); 1362 1341 //! \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 } 1364 1354 } 1365 1355 … … 1370 1360 { 1371 1361 this->isOption = 2; 1362 this->firstItem = NULL; 1372 1363 1373 1364 #ifdef HAVE_GTK2 1374 1365 this->widget = gtk_option_menu_new(); 1375 1366 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 */ 1390 1370 } 1391 1371 … … 1393 1373 \brief appends a new Item to the Menu-List. 1394 1374 \param itemName the itemName to be appendet. 1395 1396 \todo make the item-list readable without GTK1397 1375 */ 1398 1376 void Menu::addItem(char* itemName) 1399 1377 { 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; 1404 1390 } 1405 1391 … … 1488 1474 1489 1475 /** 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 /**1503 1476 \brief Redraws an OptionLabel(not implemented yet, but it works). 1504 1477 */ … … 1683 1656 1684 1657 /** 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 /**1697 1658 \brief Sets the Total size of the Bar.(ex. The maximum one can download) 1698 1659 */ … … 1763 1724 isOption = 0; 1764 1725 } 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 45 45 void hide(void); 46 46 void setSize(int width, int height); 47 virtual void setTitle(c har* 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. 48 48 49 49 Widget* findWidgetByName(char* name, unsigned int depth); … … 117 117 virtual ~Container(void); 118 118 // void setBorderWidth(int borderwidth); 119 // virtual void setTitle(char* title) = 0;120 119 void fill(Widget* lowerWidget); 121 120 }; … … 139 138 void init(void); 140 139 141 void setTitle(c har* title);140 void setTitle(const char* title); 142 141 void showall(void); 143 142 void open(void); … … 163 162 virtual ~Frame(void); 164 163 void init(void); 165 166 void setTitle(c har* title);164 165 void setTitle(const char* title); 167 166 }; 168 167 … … 178 177 virtual ~EventBox(void); 179 178 void init(void); 180 181 void setTitle(char* title);182 179 }; 183 180 … … 197 194 198 195 void fill(Widget* lowerWidget); 199 200 void setTitle(char* title);201 196 }; 202 197 … … 244 239 void init(void); 245 240 246 void setTitle(c har* title);241 void setTitle(const char* title); 247 242 void redraw(void); 248 243 void changeOption(void); … … 259 254 void init(void); 260 255 261 void setTitle(c har* title);256 void setTitle(const char* title); 262 257 bool isActive(void); //!< a Bool value to see, if this CheckButton is active. 263 258 void redraw(void); … … 279 274 void init(int start, int end); 280 275 281 void setTitle(char* title);282 276 void setValue(int value); 283 277 void redraw(void); … … 291 285 #ifdef HAVE_GTK2 292 286 GtkWidget* menu; //!< The menu That will hold the Options. 293 GtkWidget* item; //!< One Item From a Menu.294 287 #endif /* HAVE_GTK2 */ 295 288 va_list itemlist; //!< The list to readin multiple Options. 296 289 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); 298 304 Menu(char* menuname, ...); 299 305 virtual ~Menu(void); 300 306 void init(void); 301 307 302 void setTitle(char* title);303 308 void addItem(char* itemName); 304 309 void redraw(void); … … 317 322 318 323 void setValue(char* newValue); 319 void setTitle(char* title);320 324 void redraw(void); 321 325 void changeOption(void); … … 350 354 void init(void); 351 355 352 void setTitle(char* title);353 356 void setProgress(double progress); 354 357 void setTotalSize(double totalSize); … … 374 377 virtual ~Image(void); 375 378 void init(void); 376 377 void setTitle(char* title);378 379 }; 379 380 -
orxonox/trunk/src/lib/gui/gui/orxonox_gui_video.cc
r3452 r3624 27 27 #include "orxonox_gui_video.h" 28 28 29 #include "glincl.h" 30 29 31 /** 30 32 \brief Creates the Video-Option-Frame … … 40 42 this->fullscreen->saveability(); 41 43 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); 43 46 this->resolution->saveability(); 44 47 this->videoBox->fill(this->resolution); … … 146 149 } 147 150 151 void 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 45 45 OrxonoxGuiVideo(void); 46 46 ~OrxonoxGuiVideo(void); 47 48 Widget* getWidget(void); 49 50 void getResolutions(Menu* menu); 47 51 48 Widget* getWidget(void); 52 49 53 }; 50 54 #endif /* _ORXONOX_GUI_VIDEO_H */
Note: See TracChangeset
for help on using the changeset viewer.