Changeset 4338 in orxonox.OLD for orxonox/trunk/src/lib/gui
- Timestamp:
- May 27, 2005, 9:16:53 PM (20 years ago)
- Location:
- orxonox/trunk/src/lib/gui/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui/Makefile.am
r4266 r4338 25 25 noinst_LIBRARIES = libORXgui.a 26 26 27 libORXgui_a_CPPFLAGS=$(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 27 libORXgui_a_CPPFLAGS = -DBUILD_ORXONOX \ 28 $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 28 29 29 30 libORXgui_a_SOURCES = gui.cc \ -
orxonox/trunk/src/lib/gui/gui/Makefile.in
r4276 r4338 200 200 AM_LDFLAGS = $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS) 201 201 noinst_LIBRARIES = libORXgui.a 202 libORXgui_a_CPPFLAGS = $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 202 libORXgui_a_CPPFLAGS = -DBUILD_ORXONOX \ 203 $(GTK2_CFLAGS) $(GTHREAD_CFLAGS) $(CURL_CFLAGS) $(MSBITFIELDS) 204 203 205 libORXgui_a_SOURCES = gui.cc \ 204 206 gui_gtk.cc \ -
orxonox/trunk/src/lib/gui/gui/gui_gtk.cc
r4134 r4338 47 47 bool initGUI(int argc, char *argv[]) 48 48 { 49 executable = new char[strlen(argv[0])+1]; 50 strcpy(executable, argv[0]); 49 if (argv) 50 { 51 executable = new char[strlen(argv[0])+1]; 52 strcpy(executable, argv[0]); 53 } 54 else 55 executable = NULL; 51 56 52 57 #ifdef HAVE_GTK2 … … 1073 1078 #ifdef HAVE_GTK2 1074 1079 /** 1075 \brief Signal OptionChange writes the Value from the Sliderto its Object-Database.1076 \param widget The widget( Slider) that has a changed Value1077 \param slider the Slider-Object that should receive the change.1080 \brief Signal OptionChange writes the Value from the Option to its Object-Database. 1081 \param widget The widget(Option) that has a changed Value 1082 \param option the Option-Object that should receive the change. 1078 1083 */ 1079 1084 gint Option::OptionChange(GtkWidget *widget, Widget* option) 1080 1085 { 1081 1086 static_cast<Option*>(option)->changeOption(); 1082 flags->setTextFromFlags(Window::mainWindow); //// must be different !!! 1087 #ifdef BUILD_ORXONOX 1088 flags->setTextFromFlags(Window::mainWindow); 1089 #endif 1083 1090 } 1084 1091 #endif /* HAVE_GTK2 */ … … 1242 1249 \param end The maximal Value of the slider. 1243 1250 */ 1244 Slider::Slider(const char* slidername, int start, int end)1245 { 1246 this->optionType = GUI_ INT;1251 Slider::Slider(const char* slidername, float start, float end) 1252 { 1253 this->optionType = GUI_FLOAT; 1247 1254 1248 1255 this->start = start; … … 1268 1275 1269 1276 /** 1277 \brief sets the exactness of the widget 1278 \param exactness count of digits after the dot 1279 */ 1280 void Slider::setExactness(int exactness) 1281 { 1282 #ifdef HAVE_GTK2 1283 gtk_scale_set_digits(GTK_SCALE(this->widget), exactness); 1284 #endif /* HAVE_GTK2 */ 1285 } 1286 1287 /** 1270 1288 \brief Setting a new value to the Slider. 1271 1289 Maybe you also require a Slider::redraw() for this to display 1272 1290 */ 1273 void Slider::setValue( int value)1274 { 1275 this-> value = value;1291 void Slider::setValue(float value) 1292 { 1293 this->fValue = value; 1276 1294 } 1277 1295 … … 1283 1301 { 1284 1302 #ifdef HAVE_GTK2 1285 gtk_range_set_value(GTK_RANGE(this->widget), this-> value);1303 gtk_range_set_value(GTK_RANGE(this->widget), this->fValue); 1286 1304 #endif /* HAVE_GTK2 */ 1287 1305 } … … 1293 1311 { 1294 1312 #ifdef HAVE_GTK2 1295 this-> value =(int)gtk_range_get_value(GTK_RANGE(this->widget));1313 this->fValue = gtk_range_get_value(GTK_RANGE(this->widget)); 1296 1314 #else /* HAVE_GTK2 */ 1297 1315 char tmpChar[20]; … … 1299 1317 scanf("%s", tmpChar); 1300 1318 1301 if ((this->value = atoi(tmpChar))> this->end) 1302 this->value = this->end; 1303 if (this->value <= this->start) 1304 this->value = this->start; 1305 1306 PRINT(0)("%s set to: %d\n",this->title, this->value); 1307 #endif /* HAVE_GTK2 */ 1308 } 1319 if ((this->fValue = atof(tmpChar))> this->end) 1320 this->fValue = this->end; 1321 if (this->fValue <= this->start) 1322 this->fValue = this->start; 1323 1324 PRINT(0)("%s set to: %d\n",this->title, this->fValue); 1325 #endif /* HAVE_GTK2 */ 1326 } 1327 1328 char* Slider::save(void) 1329 { 1330 char* value = new char [30]; 1331 sprintf (value, "%f", this->fValue); 1332 return value; 1333 } 1334 void Slider::load(char* loadString) 1335 { 1336 this->fValue = atof(loadString); 1337 PRINT(5)("Loading %s: %s %f\n", this->title, loadString, fValue); 1338 this->redraw(); 1339 } 1340 1309 1341 1310 1342 ////////// … … 1387 1419 { 1388 1420 MenuItem* tmpItem = this->firstItem; 1389 for (int i = 0; i<this->value; i++) 1390 tmpItem = tmpItem->next; 1391 1392 return tmpItem->name; 1421 for (int i = 0; i < this->value; i++) 1422 if (tmpItem) 1423 tmpItem = tmpItem->next; 1424 else 1425 break; 1426 if (tmpItem) 1427 { 1428 char* tmpName = new char[strlen(tmpItem->name)+1]; 1429 strcpy(tmpName, tmpItem->name); 1430 return tmpName; 1431 } 1432 else 1433 return NULL; 1393 1434 } 1394 1435 … … 1471 1512 1472 1513 #endif /* HAVE_GTK2 */ 1473 PRINT( 5)("%s set to: %d\n", this->title, this->value);1514 PRINT(1)("%s set to: %d\n", this->title, this->value); 1474 1515 } 1475 1516 -
orxonox/trunk/src/lib/gui/gui/gui_gtk.h
r4132 r4338 61 61 62 62 virtual void setTitle(const char* title); //!< An abstract Function, that sets the title of Widgets. 63 virtual const char* getTitle(void) const { return this->title; }; 63 64 64 65 Widget* findWidgetByName(char* name, unsigned int depth); … … 296 297 { 297 298 private: 298 int start; //!< The beginning of the Slider-range. 299 int end; //!< The end of the Slider-range. 300 public: 301 Slider(const char* slidername, int start, int end); 299 float start; //!< The beginning of the Slider-range. 300 float end; //!< The end of the Slider-range. 301 float fValue; //!< a value for the slider 302 public: 303 Slider(const char* slidername, float start, float end); 302 304 virtual ~Slider(void); 303 305 304 void setValue(int value); 305 virtual void redraw(void); 306 virtual void changeOption(void); 306 void setExactness(int exactness); 307 void setValue(float value); 308 virtual void redraw(void); 309 virtual void changeOption(void); 310 311 virtual char* save(void); 312 virtual void load(char* loadString); 307 313 }; 308 314
Note: See TracChangeset
for help on using the changeset viewer.