[3147] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | This program is distributed in the hope that it will be useful, |
---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | GNU General Public License for more details. |
---|
| 15 | |
---|
| 16 | You should have received a copy of the GNU General Public License |
---|
| 17 | along with this program; if not, write to the Free Software Foundation, |
---|
| 18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | ### File Specific: |
---|
| 22 | main-programmer: Benjamin Grauer |
---|
| 23 | |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | |
---|
[3144] | 27 | #include <iostream> |
---|
| 28 | |
---|
| 29 | #include "orxonox_gui_gtk.h" |
---|
[3147] | 30 | |
---|
| 31 | |
---|
[3144] | 32 | using namespace std; |
---|
[3147] | 33 | |
---|
[3144] | 34 | // temporarily. |
---|
| 35 | #include "orxonox_gui_flags.h" |
---|
| 36 | #include "orxonox_gui_exec.h" |
---|
| 37 | extern Window* orxonoxGUI; |
---|
| 38 | extern OrxonoxGuiFlags* flags; |
---|
| 39 | extern OrxonoxGuiExec* exec; |
---|
| 40 | |
---|
[3165] | 41 | #ifdef HAVE_GTK2 |
---|
[3187] | 42 | /** |
---|
| 43 | \brief Initializes the Guis GTK-stuff. |
---|
| 44 | \param argc the argument count. |
---|
| 45 | \param argv The Argument strings. |
---|
| 46 | */ |
---|
[3164] | 47 | bool initGTK(int argc, char *argv[]) |
---|
| 48 | { |
---|
[3271] | 49 | #ifdef HAVE_GTHREAD |
---|
| 50 | PRINTF(3)("Initializing the ThreadSystem of the GUI\n"); |
---|
| 51 | g_thread_init(NULL); |
---|
| 52 | gdk_threads_init(); |
---|
| 53 | #endif /* HAVE_GTHREAD */ |
---|
[3164] | 54 | gtk_init (&argc, &argv); |
---|
| 55 | gtk_rc_parse( "rc" ); |
---|
| 56 | } |
---|
[3187] | 57 | |
---|
| 58 | /** |
---|
| 59 | \brief enters the GTK-main-loop |
---|
| 60 | */ |
---|
[3164] | 61 | bool mainloopGTK(void) |
---|
| 62 | { |
---|
[3271] | 63 | gdk_threads_enter(); |
---|
[3164] | 64 | gtk_main(); |
---|
[3271] | 65 | gdk_threads_leave(); |
---|
[3289] | 66 | delete Window::mainWindow; |
---|
[3164] | 67 | } |
---|
[3165] | 68 | #endif /* HAVE_GTK2 */ |
---|
| 69 | |
---|
[3289] | 70 | |
---|
| 71 | ////////////////////////////// |
---|
| 72 | /// DEFINING WIDGET-CLASES /// |
---|
| 73 | ////////////////////////////// |
---|
| 74 | |
---|
[3144] | 75 | /* WIDGET */ |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | \brief deletes any given Widget |
---|
| 79 | This is still pretty crappy. |
---|
| 80 | */ |
---|
| 81 | Widget::~Widget() |
---|
| 82 | { |
---|
[3289] | 83 | this->destroy(); |
---|
[3144] | 84 | } |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | \brief Initializes a widget. |
---|
| 88 | Initializes the next Pointer and the other Widget-specific Defaults. |
---|
| 89 | */ |
---|
| 90 | void Widget::init() |
---|
| 91 | { |
---|
| 92 | next = NULL; |
---|
[3290] | 93 | this->title = NULL; |
---|
[3144] | 94 | return; |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /** |
---|
[3289] | 98 | \brief Destroys a Widget |
---|
| 99 | */ |
---|
| 100 | void Widget::destroy(void) |
---|
| 101 | { |
---|
[3290] | 102 | if (this->title) |
---|
[3289] | 103 | { |
---|
[3290] | 104 | delete []this->title; |
---|
[3289] | 105 | } |
---|
| 106 | |
---|
| 107 | PRINTF(4)("deleting the Widget part.\n"); |
---|
| 108 | |
---|
| 109 | PRINTF(4)("deleting recursively\n"); |
---|
| 110 | |
---|
| 111 | // deleting next item if existent |
---|
| 112 | if (this->next) |
---|
| 113 | delete this->next; |
---|
| 114 | this->next = NULL; |
---|
| 115 | |
---|
| 116 | //! \todo not hiding widget, deleting. |
---|
| 117 | // this->hide(); |
---|
[3291] | 118 | // delete this->widget; |
---|
[3289] | 119 | } |
---|
| 120 | |
---|
| 121 | /** |
---|
[3144] | 122 | \brief makes the widget visible. |
---|
| 123 | */ |
---|
| 124 | void Widget::show() |
---|
| 125 | { |
---|
[3165] | 126 | #ifdef HAVE_GTK2 |
---|
[3144] | 127 | gtk_widget_show (this->widget); |
---|
[3165] | 128 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 129 | } |
---|
| 130 | |
---|
| 131 | /** |
---|
| 132 | \brief hides the widget. |
---|
| 133 | */ |
---|
| 134 | void Widget::hide() |
---|
| 135 | { |
---|
[3165] | 136 | #ifdef HAVE_GTK2 |
---|
[3144] | 137 | gtk_widget_hide (this->widget); |
---|
[3165] | 138 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 139 | } |
---|
| 140 | |
---|
| 141 | /** |
---|
| 142 | \brief Sets the resolution of a specific widget to the given size. |
---|
| 143 | \param width the width of the widget to set. |
---|
| 144 | \param height the height of the widget to set. |
---|
| 145 | */ |
---|
| 146 | void Widget::setSize(int width, int height) |
---|
| 147 | { |
---|
[3165] | 148 | #ifdef HAVE_GTK2 |
---|
[3144] | 149 | gtk_widget_set_usize (this->widget, width, height); |
---|
[3165] | 150 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 151 | } |
---|
| 152 | |
---|
| 153 | /** |
---|
| 154 | \brief Moves through all the Widgets downwards from this and executes the function on them. |
---|
[3275] | 155 | \param function must be of type void and takes a Widget* as an Input. |
---|
[3144] | 156 | */ |
---|
| 157 | void Widget::walkThrough (void (*function)(Widget*)) |
---|
| 158 | { |
---|
| 159 | function(this); |
---|
[3147] | 160 | if (this->isOption < 0) |
---|
[3144] | 161 | { |
---|
| 162 | static_cast<Packer*>(this)->down->walkThrough (function); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | if (this->next != NULL) |
---|
| 166 | this->next->walkThrough(function); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | /** |
---|
| 170 | \brief This is for listing the option of "widget" |
---|
| 171 | \param widget specifies the widget that should be listed |
---|
| 172 | */ |
---|
| 173 | void Widget::listOptions (Widget* widget) |
---|
| 174 | { |
---|
[3166] | 175 | if (widget->isOption < 0 && static_cast<Packer*>(widget)->groupName) |
---|
| 176 | cout << "[" << static_cast<Packer*>(widget)->groupName << "]\n"; |
---|
| 177 | if (widget->isOption >= 1 && widget->isOption <= 3) |
---|
[3290] | 178 | cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<Option*>(widget)->value <<endl; |
---|
[3166] | 179 | else if (widget->isOption == 5) |
---|
[3290] | 180 | cout << " " << static_cast<Option*>(widget)->title <<" is : " << static_cast<OptionLabel*>(widget)->cValue <<endl; |
---|
[3144] | 181 | } |
---|
| 182 | |
---|
| 183 | /** |
---|
| 184 | \brief This is for setting the option of "widget" |
---|
| 185 | \param widget specifies the widget that should be set. |
---|
| 186 | */ |
---|
| 187 | void Widget::setOptions (Widget* widget) |
---|
| 188 | { |
---|
[3147] | 189 | if (widget->isOption >= 1) |
---|
[3144] | 190 | static_cast<Option*>(widget)->redraw();// <<" is : " << static_cast<Option*>(this)->value <<endl; |
---|
| 191 | } |
---|
| 192 | |
---|
[3165] | 193 | #ifdef HAVE_GTK2 |
---|
[3289] | 194 | /** |
---|
| 195 | \brief Connect any signal to any given Sub-widget |
---|
| 196 | */ |
---|
| 197 | gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)) |
---|
| 198 | { |
---|
| 199 | return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); |
---|
| 200 | } |
---|
[3187] | 201 | |
---|
| 202 | /** |
---|
[3289] | 203 | \brief Connect a signal with additionally passing the whole Object |
---|
| 204 | */ |
---|
| 205 | gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *)) |
---|
| 206 | { |
---|
| 207 | return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | /** |
---|
| 211 | \brief Connect a signal with additionally passing a whole external Object |
---|
| 212 | */ |
---|
| 213 | gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)) |
---|
| 214 | { |
---|
| 215 | return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | /** |
---|
| 219 | \brief Connect a signal with additionally passing a whole external Object |
---|
| 220 | */ |
---|
| 221 | gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)) |
---|
| 222 | { |
---|
| 223 | return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | void Widget::disconnectSignal (gulong signalID) |
---|
| 227 | { |
---|
| 228 | g_signal_handler_disconnect (G_OBJECT (this->widget), signalID); |
---|
| 229 | } |
---|
| 230 | |
---|
| 231 | /** |
---|
[3187] | 232 | \brief Signal that does absolutely nothing |
---|
| 233 | \param widget The widget that initiated the Signal |
---|
| 234 | \param event The event-type. |
---|
| 235 | \param nothing nothin. |
---|
| 236 | */ |
---|
[3157] | 237 | gint Widget::doNothingSignal (GtkWidget *widget, GdkEvent* event, void* nothing) |
---|
| 238 | { |
---|
| 239 | } |
---|
[3165] | 240 | #endif /* HAVE_GTK2 */ |
---|
[3157] | 241 | |
---|
[3144] | 242 | //void deleteWidget(Widget* lastWidget) |
---|
| 243 | |
---|
| 244 | |
---|
| 245 | /* PACKERS */ |
---|
| 246 | |
---|
| 247 | /** |
---|
| 248 | \brief Initializes a Packer. |
---|
[3187] | 249 | |
---|
[3144] | 250 | Sets the down-pinter to NULL and other PackerSpecific-values to their defaults. |
---|
| 251 | */ |
---|
| 252 | void Packer::init (void) |
---|
| 253 | { |
---|
| 254 | down = NULL; |
---|
[3161] | 255 | groupName = NULL; |
---|
[3144] | 256 | |
---|
| 257 | |
---|
| 258 | static_cast<Widget*>(this)->init(); |
---|
| 259 | return; |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | /** |
---|
[3289] | 263 | \brief Destroys a Packer. |
---|
| 264 | */ |
---|
| 265 | void Packer::destroy(void) |
---|
| 266 | { |
---|
| 267 | PRINTF(4)("deleting the Packer part.\n"); |
---|
| 268 | |
---|
| 269 | if (groupName) |
---|
| 270 | delete []groupName; |
---|
| 271 | |
---|
| 272 | //deleting recursively. |
---|
| 273 | if (this->down) |
---|
| 274 | delete this->down; |
---|
| 275 | this->down = NULL; |
---|
| 276 | |
---|
| 277 | static_cast<Widget*>(this)->destroy(); |
---|
| 278 | } |
---|
| 279 | |
---|
| 280 | /** |
---|
[3144] | 281 | \brief Sets the group name under which all the lower widgets of this will be saved. |
---|
| 282 | \param name The name of the group. |
---|
| 283 | */ |
---|
| 284 | void Packer::setGroupName (char* name) |
---|
| 285 | { |
---|
[3161] | 286 | if (groupName) |
---|
| 287 | delete groupName; |
---|
| 288 | groupName = new char [strlen(name)+1]; |
---|
| 289 | strcpy(groupName, name); |
---|
[3144] | 290 | } |
---|
| 291 | |
---|
| 292 | /** |
---|
| 293 | \brief Retrieves the group name under which all the lower widgets of this will be saved. |
---|
| 294 | \returns name The name of the group. |
---|
| 295 | */ |
---|
| 296 | char* Packer::getGroupName (void) |
---|
| 297 | { |
---|
| 298 | return groupName; |
---|
| 299 | } |
---|
| 300 | |
---|
| 301 | /* CONTAINERS */ |
---|
| 302 | |
---|
| 303 | /** |
---|
| 304 | \brief Initializes a Container. |
---|
[3187] | 305 | |
---|
[3144] | 306 | sets the Container-Specific defaults. |
---|
| 307 | */ |
---|
| 308 | void Container::init (void) |
---|
| 309 | { |
---|
[3147] | 310 | isOption = -1; |
---|
[3144] | 311 | |
---|
| 312 | static_cast<Packer*>(this)->init(); |
---|
| 313 | |
---|
| 314 | return; |
---|
| 315 | } |
---|
| 316 | |
---|
| 317 | /** |
---|
[3289] | 318 | \brief Destroys a Container. |
---|
| 319 | */ |
---|
| 320 | void Container::destroy(void) |
---|
| 321 | { |
---|
| 322 | PRINTF(4)("deleting the Container part.\n"); |
---|
| 323 | |
---|
| 324 | static_cast<Packer*>(this)->destroy(); |
---|
| 325 | } |
---|
| 326 | |
---|
| 327 | /** |
---|
[3144] | 328 | \briefFills a Container with lowerWidget. |
---|
[3187] | 329 | \param lowerWidget the Widget that should be filled into the Container. |
---|
| 330 | |
---|
[3144] | 331 | It does this by filling up the down pointer only if down points to NULL. |
---|
| 332 | */ |
---|
| 333 | void Container::fill (Widget *lowerWidget) |
---|
| 334 | { |
---|
| 335 | if (this->down == NULL) |
---|
| 336 | { |
---|
[3165] | 337 | #ifdef HAVE_GTK2 |
---|
[3144] | 338 | gtk_container_add (GTK_CONTAINER (this->widget), lowerWidget->widget); |
---|
[3165] | 339 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 340 | this->down = lowerWidget; |
---|
| 341 | } |
---|
| 342 | else |
---|
[3289] | 343 | PRINTF(1)("!!error!! You try to put more than one Widget into a Container. \nNot including this item.\nThis is only possible with Boxes.\n"); |
---|
[3144] | 344 | } |
---|
| 345 | |
---|
| 346 | // gtk_container_set_border_width (GTK_CONTAINER (widget), 5); |
---|
| 347 | |
---|
| 348 | /* WINDOW */ |
---|
| 349 | |
---|
[3148] | 350 | Window* Window::mainWindow = NULL; |
---|
| 351 | |
---|
[3187] | 352 | /** |
---|
| 353 | \brief Adds a new Window Windows to the List of Windows. |
---|
| 354 | \param windowToAdd The Windows that should be added to the List |
---|
| 355 | \todo this instead of windowToAdd (possibly) |
---|
| 356 | */ |
---|
[3148] | 357 | void Window::addWindow(Window* windowToAdd) |
---|
| 358 | { |
---|
| 359 | if (!mainWindow) |
---|
| 360 | { |
---|
| 361 | mainWindow = windowToAdd; |
---|
| 362 | return; |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | Widget* tmpWindow = mainWindow; |
---|
| 366 | while (tmpWindow->next) |
---|
| 367 | tmpWindow = tmpWindow->next; |
---|
| 368 | tmpWindow->next = windowToAdd; |
---|
| 369 | |
---|
| 370 | return; |
---|
| 371 | } |
---|
| 372 | |
---|
| 373 | |
---|
[3144] | 374 | /** |
---|
| 375 | \brief Creating a new Window without a Name |
---|
| 376 | */ |
---|
| 377 | Window::Window (void) |
---|
| 378 | { |
---|
| 379 | this->init(); |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | /** |
---|
| 383 | \brief Creating a Window with a name |
---|
| 384 | \param windowName the name the window should get. |
---|
| 385 | */ |
---|
[3289] | 386 | |
---|
[3144] | 387 | Window::Window (char* windowName) |
---|
| 388 | { |
---|
| 389 | this->init(); |
---|
| 390 | this->setTitle (windowName); |
---|
| 391 | } |
---|
| 392 | |
---|
| 393 | /** |
---|
[3289] | 394 | \brief Destructs a Window. |
---|
| 395 | */ |
---|
| 396 | Window::~Window(void) |
---|
| 397 | { |
---|
| 398 | this->destroy(); |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | /** |
---|
[3144] | 402 | \brief initializes a new Window |
---|
| 403 | */ |
---|
| 404 | void Window::init() |
---|
| 405 | { |
---|
[3148] | 406 | if (!mainWindow) |
---|
| 407 | mainWindow = this; |
---|
[3152] | 408 | |
---|
[3144] | 409 | isOpen = false; |
---|
| 410 | |
---|
| 411 | static_cast<Container*>(this)->init(); |
---|
| 412 | |
---|
[3165] | 413 | #ifdef HAVE_GTK2 |
---|
[3144] | 414 | widget = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
---|
| 415 | gtk_window_set_policy (GTK_WINDOW(widget), TRUE, TRUE, TRUE); |
---|
| 416 | #if !defined(__WIN32__) |
---|
[3154] | 417 | // gtk_window_set_decorated (GTK_WINDOW (widget), FALSE); |
---|
[3144] | 418 | #endif |
---|
| 419 | gtk_container_set_border_width (GTK_CONTAINER (widget), 3); |
---|
[3165] | 420 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 421 | } |
---|
| 422 | |
---|
| 423 | /** |
---|
[3289] | 424 | \brief Destroys a Window. |
---|
| 425 | */ |
---|
| 426 | void Window::destroy(void) |
---|
| 427 | { |
---|
[3290] | 428 | if (this->title) |
---|
| 429 | PRINTF(3)("deleting the Window: %s\n", this->title); |
---|
[3289] | 430 | else |
---|
| 431 | PRINTF(3)("deleting the Window.\n"); |
---|
| 432 | |
---|
[3291] | 433 | this->hide(); |
---|
[3289] | 434 | static_cast<Container*>(this)->destroy(); |
---|
| 435 | |
---|
| 436 | } |
---|
| 437 | |
---|
| 438 | /** |
---|
[3144] | 439 | \brief Shows all Widgets that are included within this->widget. |
---|
| 440 | */ |
---|
| 441 | void Window::showall () |
---|
| 442 | { |
---|
| 443 | if (!isOpen) |
---|
| 444 | { |
---|
[3166] | 445 | // printf ("showall\n"); |
---|
[3165] | 446 | #ifdef HAVE_GTK2 |
---|
[3144] | 447 | gtk_widget_show_all (widget); |
---|
[3165] | 448 | #endif /* HAVE_GTK2 */ |
---|
| 449 | isOpen = true; |
---|
[3144] | 450 | } |
---|
| 451 | else |
---|
| 452 | { |
---|
[3166] | 453 | // printf ("showone\n"); |
---|
[3165] | 454 | #ifdef HAVE_GTK2 |
---|
[3144] | 455 | gtk_widget_show (widget); |
---|
[3165] | 456 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 457 | } |
---|
| 458 | } |
---|
| 459 | |
---|
| 460 | /** |
---|
| 461 | \brief Set The Window-title to title |
---|
| 462 | \param title title the Window should get. |
---|
| 463 | */ |
---|
| 464 | void Window::setTitle (char* title) |
---|
| 465 | { |
---|
[3290] | 466 | if (this->title) |
---|
| 467 | delete []this->title; |
---|
| 468 | this->title = new char[strlen(title)+1]; |
---|
| 469 | strcpy(this->title, title); |
---|
[3165] | 470 | #ifdef HAVE_GTK2 |
---|
[3144] | 471 | gtk_window_set_title (GTK_WINDOW (widget), title); |
---|
[3165] | 472 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 473 | } |
---|
| 474 | |
---|
| 475 | /** |
---|
[3147] | 476 | \brief opens up a Window and fixes the Focus to it |
---|
| 477 | */ |
---|
| 478 | void Window::open() |
---|
| 479 | { |
---|
[3148] | 480 | if (this != mainWindow) |
---|
| 481 | { |
---|
| 482 | isOpen = true; |
---|
[3165] | 483 | #ifdef HAVE_GTK2 |
---|
[3148] | 484 | gtk_widget_show_all(widget); |
---|
| 485 | gtk_grab_add(widget); |
---|
[3165] | 486 | #endif /* HAVE_GTK2 */ |
---|
[3148] | 487 | } |
---|
[3147] | 488 | } |
---|
| 489 | |
---|
| 490 | /** |
---|
| 491 | \brief closes up a Window and removes the Focus from it |
---|
| 492 | */ |
---|
| 493 | void Window::close() |
---|
| 494 | { |
---|
[3148] | 495 | if (this != mainWindow) |
---|
| 496 | { |
---|
| 497 | isOpen = false; |
---|
[3165] | 498 | #ifdef HAVE_GTK2 |
---|
[3148] | 499 | gtk_grab_remove(widget); |
---|
| 500 | gtk_widget_hide (widget); |
---|
[3165] | 501 | #endif /* HAVE_GTK2 */ |
---|
[3148] | 502 | } |
---|
[3147] | 503 | } |
---|
| 504 | |
---|
[3165] | 505 | #ifdef HAVE_GTK2 |
---|
[3147] | 506 | /** |
---|
[3153] | 507 | \brief opens up a window (not topmost Window). |
---|
| 508 | this is the Signal that does it. !!SIGNALS ARE STATIC!! |
---|
[3187] | 509 | \param widget the widget that did it. |
---|
| 510 | \param event the event that did it. |
---|
[3153] | 511 | \param window the Window that should be opened |
---|
| 512 | */ |
---|
| 513 | gint Window::windowOpen (GtkWidget *widget, GdkEvent* event, void* window) |
---|
| 514 | { |
---|
| 515 | static_cast<Window*>(window)->open(); |
---|
| 516 | } |
---|
| 517 | |
---|
| 518 | /** |
---|
| 519 | \brief closes a window (not topmost Window). |
---|
| 520 | this is the Signal that does it. !!SIGNALS ARE STATIC!! |
---|
| 521 | \param widget the widget that did it! |
---|
| 522 | \param event the event that did it! |
---|
| 523 | \param window the Window that should be closed |
---|
| 524 | */ |
---|
| 525 | gint Window::windowClose (GtkWidget *widget, GdkEvent* event, void* window) |
---|
| 526 | { |
---|
| 527 | static_cast<Window*>(window)->close(); |
---|
| 528 | } |
---|
[3156] | 529 | |
---|
[3153] | 530 | /** |
---|
[3144] | 531 | * Quits the orxonox_GUI. |
---|
| 532 | * This can be called as a Signal and is therefor static |
---|
| 533 | \param widget The widget that called this function |
---|
| 534 | \param event the event that happened to execute this function |
---|
| 535 | \param data some data passed with the Signal |
---|
| 536 | */ |
---|
| 537 | gint Window::orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data) |
---|
| 538 | { |
---|
| 539 | if (exec->shouldsave()) |
---|
[3161] | 540 | exec->writeToFile (Window::mainWindow); |
---|
[3144] | 541 | |
---|
| 542 | gtk_main_quit(); |
---|
| 543 | return FALSE; |
---|
| 544 | } |
---|
[3165] | 545 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 546 | |
---|
| 547 | |
---|
| 548 | /* FRAME */ |
---|
| 549 | |
---|
| 550 | /** |
---|
| 551 | \brief Creates a new Frame without a name |
---|
| 552 | */ |
---|
| 553 | Frame::Frame (void) |
---|
| 554 | { |
---|
| 555 | this->init(); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | /** |
---|
| 559 | \brief Creates a new Frame with name title |
---|
| 560 | */ |
---|
| 561 | Frame::Frame (char* title) |
---|
| 562 | { |
---|
| 563 | this->init(); |
---|
| 564 | this->setTitle(title); |
---|
| 565 | } |
---|
| 566 | |
---|
[3289] | 567 | /** |
---|
| 568 | \brief destrcucts a Frame |
---|
| 569 | */ |
---|
| 570 | Frame::~Frame() |
---|
| 571 | { |
---|
| 572 | this->destroy(); |
---|
| 573 | } |
---|
| 574 | |
---|
[3144] | 575 | /** |
---|
| 576 | \brief Initializes a new Frame with default settings |
---|
| 577 | */ |
---|
| 578 | void Frame::init() |
---|
| 579 | { |
---|
| 580 | static_cast<Container*>(this)->init(); |
---|
[3165] | 581 | |
---|
| 582 | #ifdef HAVE_GTK2 |
---|
[3144] | 583 | widget = gtk_frame_new (""); |
---|
| 584 | gtk_container_set_border_width (GTK_CONTAINER (widget), 3); |
---|
[3165] | 585 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 586 | } |
---|
| 587 | |
---|
| 588 | /** |
---|
[3289] | 589 | \brief Destroys a Frame. |
---|
| 590 | */ |
---|
| 591 | void Frame::destroy(void) |
---|
| 592 | { |
---|
[3290] | 593 | if (this->title) |
---|
| 594 | PRINTF(3)("deleting the Frame: %s\n", this->title); |
---|
[3289] | 595 | else |
---|
| 596 | PRINTF(3)("deleting the Frame.\n"); |
---|
| 597 | |
---|
| 598 | static_cast<Container*>(this)->destroy(); |
---|
| 599 | } |
---|
| 600 | |
---|
| 601 | /** |
---|
[3144] | 602 | \brief Sets the Frames name to title |
---|
| 603 | \param title The title the Frame should get. |
---|
| 604 | */ |
---|
| 605 | void Frame::setTitle (char* title) |
---|
| 606 | { |
---|
[3290] | 607 | if (this->title) |
---|
| 608 | delete []this->title; |
---|
| 609 | this->title = new char[strlen(title)+1]; |
---|
| 610 | strcpy(this->title, title); |
---|
[3165] | 611 | #ifdef HAVE_GTK2 |
---|
[3144] | 612 | gtk_frame_set_label (GTK_FRAME (widget), title); |
---|
[3165] | 613 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 614 | } |
---|
| 615 | |
---|
| 616 | // EVENTBOX // |
---|
| 617 | |
---|
| 618 | /** |
---|
| 619 | \brief Creates a new EventBox with default settings. |
---|
| 620 | */ |
---|
[3289] | 621 | EventBox::EventBox (void) |
---|
[3144] | 622 | { |
---|
| 623 | this->init(); |
---|
| 624 | } |
---|
[3263] | 625 | |
---|
[3144] | 626 | /** |
---|
| 627 | \brief Creates a new EventBox with name title |
---|
| 628 | \param title title the Eventbox should get (only data-structure-internal) |
---|
| 629 | */ |
---|
| 630 | EventBox::EventBox (char* title) |
---|
| 631 | { |
---|
| 632 | this->init(); |
---|
| 633 | this->setTitle(title); |
---|
| 634 | } |
---|
| 635 | |
---|
| 636 | /** |
---|
[3289] | 637 | \destructs an EventBox. |
---|
| 638 | */ |
---|
| 639 | EventBox::~EventBox(void) |
---|
| 640 | { |
---|
| 641 | this->destroy(); |
---|
| 642 | |
---|
| 643 | } |
---|
| 644 | |
---|
| 645 | /** |
---|
[3144] | 646 | \brief Initializes a new EventBox |
---|
| 647 | */ |
---|
| 648 | void EventBox::init(void) |
---|
| 649 | { |
---|
[3147] | 650 | isOption = -1; |
---|
[3144] | 651 | |
---|
| 652 | static_cast<Container*>(this)->init(); |
---|
| 653 | |
---|
[3165] | 654 | #ifdef HAVE_GTK2 |
---|
[3144] | 655 | widget = gtk_event_box_new (); |
---|
| 656 | gtk_container_set_border_width (GTK_CONTAINER (widget), 3); |
---|
[3165] | 657 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 658 | } |
---|
| 659 | |
---|
| 660 | /** |
---|
[3289] | 661 | \brief Destroys an EventBox. |
---|
| 662 | */ |
---|
| 663 | void EventBox::destroy(void) |
---|
| 664 | { |
---|
[3290] | 665 | if (this->title) |
---|
| 666 | PRINTF(3)("deleting the EventBox: %s\n", this->title); |
---|
[3289] | 667 | else |
---|
| 668 | PRINTF(3)("deleting the EventBox.\n"); |
---|
| 669 | |
---|
| 670 | static_cast<Container*>(this)->destroy(); |
---|
| 671 | } |
---|
| 672 | |
---|
| 673 | /** |
---|
[3144] | 674 | \brief Sets the Title of the EventBox (not implemented) |
---|
| 675 | \param title Name the EventBox should get (only datastructure-internal). |
---|
| 676 | */ |
---|
| 677 | void EventBox::setTitle (char* title) |
---|
| 678 | { |
---|
[3290] | 679 | if (this->title) |
---|
| 680 | delete []this->title; |
---|
| 681 | this->title = new char[strlen(title)+1]; |
---|
| 682 | strcpy(this->title, title); |
---|
[3144] | 683 | } |
---|
| 684 | |
---|
| 685 | /* BOX */ |
---|
| 686 | |
---|
| 687 | /** |
---|
| 688 | \brief Creates a new horizontal Box |
---|
| 689 | */ |
---|
| 690 | Box::Box (void) |
---|
| 691 | { |
---|
| 692 | this->init('h'); |
---|
| 693 | } |
---|
| 694 | |
---|
| 695 | /** |
---|
| 696 | \brief Creates a new Box of type boxtype |
---|
| 697 | \param boxtype if 'v' the Box will be vertically, if 'h' the Box will be horizontally |
---|
| 698 | */ |
---|
| 699 | Box::Box (char boxtype) |
---|
| 700 | { |
---|
| 701 | this->init(boxtype); |
---|
| 702 | } |
---|
| 703 | |
---|
| 704 | /** |
---|
[3289] | 705 | \destructs a Box. |
---|
| 706 | */ |
---|
| 707 | Box::~Box(void) |
---|
| 708 | { |
---|
| 709 | this->destroy(); |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | /** |
---|
[3144] | 713 | \brief Initializes a new Box with type boxtype |
---|
| 714 | \param boxtype see Box(char boxtype) |
---|
| 715 | */ |
---|
| 716 | void Box::init(char boxtype) |
---|
| 717 | { |
---|
[3147] | 718 | isOption = -2; |
---|
[3144] | 719 | |
---|
| 720 | static_cast<Packer*>(this)->init(); |
---|
[3165] | 721 | #ifdef HAVE_GTK2 |
---|
[3144] | 722 | if (boxtype == 'v') |
---|
| 723 | { |
---|
| 724 | widget = gtk_vbox_new (FALSE, 0); |
---|
| 725 | } |
---|
| 726 | else |
---|
| 727 | { |
---|
| 728 | widget = gtk_hbox_new (FALSE, 0); |
---|
| 729 | } |
---|
[3165] | 730 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 731 | } |
---|
| 732 | |
---|
[3289] | 733 | /** |
---|
| 734 | \brief Destroys a Box. |
---|
| 735 | */ |
---|
| 736 | void Box::destroy(void) |
---|
| 737 | { |
---|
[3290] | 738 | if (this->title) |
---|
| 739 | PRINTF(3)("deleting the Box: %s\n", this->title); |
---|
[3289] | 740 | else |
---|
| 741 | PRINTF(3)("deleting the Box.\n"); |
---|
| 742 | |
---|
| 743 | static_cast<Packer*>(this)->destroy(); |
---|
| 744 | } |
---|
| 745 | |
---|
[3144] | 746 | /** |
---|
| 747 | \brief Fills a box with a given Widget. |
---|
[3187] | 748 | \param lowerWidget the next Widget that should be appendet to this Box |
---|
| 749 | |
---|
[3144] | 750 | It does this by apending the first one to its down-pointer and all its following ones to the preceding next-pointer. The last one will receive a NULL pointer as Next |
---|
| 751 | */ |
---|
| 752 | void Box::fill (Widget *lowerWidget) |
---|
| 753 | { |
---|
[3165] | 754 | #ifdef HAVE_GTK2 |
---|
[3144] | 755 | gtk_box_pack_start (GTK_BOX (this->widget), lowerWidget->widget, TRUE, TRUE, 0); |
---|
[3165] | 756 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 757 | if (this->down == NULL) |
---|
| 758 | this->down = lowerWidget; |
---|
| 759 | else |
---|
| 760 | { |
---|
| 761 | Widget* tmp; |
---|
| 762 | tmp = this->down; |
---|
| 763 | while (tmp->next != NULL) |
---|
| 764 | { |
---|
| 765 | tmp = tmp->next; |
---|
| 766 | } |
---|
| 767 | tmp->next = lowerWidget; |
---|
| 768 | } |
---|
| 769 | } |
---|
| 770 | |
---|
| 771 | /** |
---|
[3287] | 772 | \brief Sets the Title of a Box. |
---|
[3289] | 773 | \param title the new Title to set. |
---|
[3144] | 774 | */ |
---|
[3287] | 775 | void Box::setTitle(char* title) |
---|
[3144] | 776 | { |
---|
[3290] | 777 | if (this->title) |
---|
| 778 | delete []this->title; |
---|
| 779 | this->title = new char[strlen(title)+1]; |
---|
| 780 | strcpy(this->title, title); |
---|
[3144] | 781 | } |
---|
| 782 | |
---|
| 783 | /* OPTION */ |
---|
| 784 | |
---|
| 785 | /** |
---|
| 786 | \brief Initializes a new Option. |
---|
| 787 | sets all Option-Specific-Values to their defaults. |
---|
| 788 | */ |
---|
| 789 | void Option::init() |
---|
| 790 | { |
---|
| 791 | value = 0; |
---|
[3158] | 792 | flagName = NULL; |
---|
| 793 | flagNameShort = NULL; |
---|
[3144] | 794 | saveable = false; |
---|
[3158] | 795 | defaultValue = 0; |
---|
[3144] | 796 | |
---|
| 797 | static_cast<Widget*>(this)->init(); |
---|
| 798 | |
---|
| 799 | return; |
---|
| 800 | } |
---|
| 801 | |
---|
| 802 | /** |
---|
[3289] | 803 | \brief Destroys an Option. |
---|
| 804 | */ |
---|
| 805 | void Option::destroy(void) |
---|
| 806 | { |
---|
| 807 | PRINTF(4)("deleting the Option Part.\n"); |
---|
| 808 | if (flagName) |
---|
| 809 | delete []flagName; |
---|
| 810 | if (flagNameShort) |
---|
| 811 | delete []flagNameShort; |
---|
| 812 | |
---|
| 813 | static_cast<Widget*>(this)->destroy(); |
---|
| 814 | } |
---|
| 815 | |
---|
| 816 | /** |
---|
[3144] | 817 | \brief This sets The FlagName of an Option and defines its default Values |
---|
[3187] | 818 | !! Options will be saved if flagname is different from NULL !! |
---|
[3144] | 819 | \param flagname the Name that will be displayed in the output |
---|
| 820 | \param defaultvalue the default Value for this Option (see definition of defaultvalue |
---|
| 821 | */ |
---|
| 822 | void Option::setFlagName (char* flagname, int defaultvalue) |
---|
| 823 | { |
---|
[3158] | 824 | if (flagName) |
---|
| 825 | delete flagName; |
---|
| 826 | flagName = new char [strlen(flagname)+1]; |
---|
| 827 | strcpy(flagName, flagname); |
---|
| 828 | defaultValue = defaultvalue; |
---|
[3166] | 829 | |
---|
[3290] | 830 | // cout << "Set Flagname of " << this->title << " to " << flagname << endl; |
---|
[3144] | 831 | } |
---|
| 832 | |
---|
| 833 | /** |
---|
| 834 | \brief see Option::setFlagName (char* flagname, int defaultvalue) |
---|
| 835 | \param flagname the Name that will be displayed in the output |
---|
| 836 | \param defaultvalue the default Value for this Option (see definition of defaultvalue |
---|
| 837 | \param flagnameshort a short flagname to be displayed in the output |
---|
| 838 | */ |
---|
| 839 | void Option::setFlagName (char* flagname, char* flagnameshort, int defaultvalue) |
---|
| 840 | { |
---|
[3158] | 841 | if (flagName) |
---|
| 842 | delete flagName; |
---|
| 843 | flagName = new char [strlen(flagname)+1]; |
---|
| 844 | strcpy(flagName, flagname); |
---|
| 845 | |
---|
| 846 | if (flagNameShort) |
---|
| 847 | delete flagNameShort; |
---|
| 848 | flagNameShort = new char [strlen(flagnameshort)+1]; |
---|
[3159] | 849 | strcpy(flagNameShort, flagnameshort); |
---|
[3158] | 850 | defaultValue = defaultvalue; |
---|
[3290] | 851 | // cout << "Set Flagname of " << this->title << " to " << flagname << endl; |
---|
[3144] | 852 | } |
---|
| 853 | |
---|
[3288] | 854 | /** |
---|
| 855 | \brief Sets the saveable-state of the option to true. |
---|
| 856 | */ |
---|
| 857 | void Option::saveability(void) |
---|
| 858 | { |
---|
| 859 | this->saveable = true; |
---|
| 860 | } |
---|
[3144] | 861 | |
---|
[3288] | 862 | /** |
---|
| 863 | \brief Sets the saveable-state of the option. |
---|
| 864 | \param isSaveable the saveable-state to set. |
---|
| 865 | */ |
---|
| 866 | void Option::saveability(bool isSaveable) |
---|
| 867 | { |
---|
| 868 | this->saveable = isSaveable; |
---|
| 869 | } |
---|
| 870 | |
---|
| 871 | /** |
---|
| 872 | \returns The saveable-state. |
---|
| 873 | */ |
---|
| 874 | bool Option::isSaveable(void) |
---|
| 875 | { |
---|
| 876 | return this->saveable; |
---|
| 877 | } |
---|
| 878 | |
---|
[3144] | 879 | /* BUTTON */ |
---|
| 880 | |
---|
| 881 | /** |
---|
| 882 | \brief Creates a new Button with a buttonname |
---|
| 883 | \param buttonname sets the Name of the Button |
---|
| 884 | */ |
---|
| 885 | Button::Button(char* buttonname) |
---|
| 886 | { |
---|
| 887 | this->init(); |
---|
| 888 | this->setTitle(buttonname); |
---|
| 889 | } |
---|
| 890 | |
---|
| 891 | /** |
---|
[3289] | 892 | \destructs a Button. |
---|
| 893 | */ |
---|
| 894 | Button::~Button(void) |
---|
| 895 | { |
---|
| 896 | this->destroy(); |
---|
| 897 | } |
---|
| 898 | |
---|
| 899 | /** |
---|
[3144] | 900 | \brief Initializes a new Button |
---|
| 901 | */ |
---|
| 902 | void Button::init(void) |
---|
| 903 | { |
---|
[3147] | 904 | isOption = 0; |
---|
[3144] | 905 | |
---|
| 906 | static_cast<Option*>(this)->init(); |
---|
| 907 | |
---|
[3165] | 908 | #ifdef HAVE_GTK2 |
---|
[3144] | 909 | widget = gtk_button_new_with_label (""); |
---|
[3165] | 910 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 911 | } |
---|
| 912 | |
---|
| 913 | /** |
---|
[3289] | 914 | \brief Destroys a Button. |
---|
| 915 | */ |
---|
| 916 | void Button::destroy(void) |
---|
| 917 | { |
---|
[3290] | 918 | if (this->title) |
---|
| 919 | PRINTF(3)("deleting the Label: %s\n", this->title); |
---|
[3289] | 920 | else |
---|
| 921 | PRINTF(3)("deleting the Label.\n"); |
---|
| 922 | |
---|
| 923 | static_cast<Option*>(this)->destroy(); |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | /** |
---|
[3144] | 927 | \brief Sets a new name to the Button |
---|
| 928 | \param title The name the Button should get |
---|
| 929 | */ |
---|
| 930 | void Button::setTitle (char *title) |
---|
| 931 | { |
---|
[3290] | 932 | if (this->title) |
---|
| 933 | delete []this->title; |
---|
| 934 | this->title = new char[strlen(title)+1]; |
---|
| 935 | strcpy(this->title, title); |
---|
[3165] | 936 | #ifdef HAVE_GTK2 |
---|
[3144] | 937 | gtk_button_set_label (GTK_BUTTON(widget), title); |
---|
[3165] | 938 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 939 | } |
---|
| 940 | |
---|
| 941 | /** |
---|
| 942 | \brief redraws the Button |
---|
| 943 | not implemented yet |
---|
| 944 | */ |
---|
| 945 | void Button::redraw () |
---|
| 946 | { |
---|
| 947 | } |
---|
| 948 | |
---|
| 949 | /* CHECKBUTTON */ |
---|
| 950 | |
---|
| 951 | /** |
---|
| 952 | \brief Creates a new CheckButton with an ame |
---|
| 953 | \param buttonname The name the CheckButton should display. |
---|
| 954 | */ |
---|
| 955 | CheckButton::CheckButton (char* buttonname) |
---|
| 956 | { |
---|
| 957 | this->init(); |
---|
| 958 | this->setTitle(buttonname); |
---|
| 959 | |
---|
[3165] | 960 | #ifdef HAVE_GTK2 |
---|
[3144] | 961 | this->connectSignal ("clicked", this->OptionChange); |
---|
[3165] | 962 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 963 | } |
---|
| 964 | |
---|
| 965 | /** |
---|
[3289] | 966 | \destructs a CheckButton. |
---|
| 967 | */ |
---|
| 968 | CheckButton::~CheckButton(void) |
---|
| 969 | { |
---|
| 970 | this->destroy(); |
---|
| 971 | } |
---|
| 972 | |
---|
| 973 | /** |
---|
[3144] | 974 | \brief Initialize a new CheckButton with default settings |
---|
| 975 | */ |
---|
| 976 | void CheckButton::init(void) |
---|
| 977 | { |
---|
[3147] | 978 | isOption = 1; |
---|
[3144] | 979 | |
---|
| 980 | static_cast<Option*>(this)->init(); |
---|
| 981 | |
---|
[3165] | 982 | #ifdef HAVE_GTK2 |
---|
[3144] | 983 | widget = gtk_check_button_new_with_label (""); |
---|
[3165] | 984 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 985 | } |
---|
| 986 | |
---|
| 987 | /** |
---|
[3289] | 988 | \brief Destroys a CheckButton. |
---|
| 989 | */ |
---|
| 990 | void CheckButton::destroy(void) |
---|
| 991 | { |
---|
[3290] | 992 | if (this->title) |
---|
| 993 | PRINTF(3)("deleting the CheckButton: %s\n", this->title); |
---|
[3289] | 994 | else |
---|
| 995 | PRINTF(3)("deleting the CheckButton.\n"); |
---|
| 996 | |
---|
| 997 | static_cast<Option*>(this)->destroy(); |
---|
| 998 | } |
---|
| 999 | |
---|
| 1000 | /** |
---|
[3144] | 1001 | \brief Sets a new Title to a CheckButton |
---|
| 1002 | \param title The new Name the CheckButton should display. |
---|
| 1003 | */ |
---|
| 1004 | void CheckButton::setTitle(char* title) |
---|
| 1005 | { |
---|
[3290] | 1006 | if (this->title) |
---|
| 1007 | delete []this->title; |
---|
| 1008 | this->title = new char[strlen(title)+1]; |
---|
| 1009 | strcpy(this->title, title); |
---|
[3165] | 1010 | #ifdef HAVE_GTK2 |
---|
[3144] | 1011 | gtk_button_set_label(GTK_BUTTON(widget), title); |
---|
[3165] | 1012 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1013 | } |
---|
| 1014 | |
---|
[3146] | 1015 | bool CheckButton::isActive() |
---|
| 1016 | { |
---|
[3165] | 1017 | #ifdef HAVE_GTK2 |
---|
[3146] | 1018 | return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); |
---|
[3165] | 1019 | #endif /* HAVE_GTK2 */ |
---|
[3146] | 1020 | } |
---|
[3144] | 1021 | |
---|
[3165] | 1022 | #ifdef HAVE_GTK2 |
---|
[3144] | 1023 | /** |
---|
| 1024 | \brief Signal OptionChange writes the Value from the CheckButton to its Object-Database. |
---|
| 1025 | \param widget The widget(CheckButton) that has a changed Value |
---|
| 1026 | \param checkbutton the CheckButton-Object that should receive the change. |
---|
| 1027 | */ |
---|
| 1028 | gint CheckButton::OptionChange (GtkWidget *widget, Widget* checkbutton) |
---|
| 1029 | { |
---|
| 1030 | static_cast<CheckButton*>(checkbutton)->value = (int)gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ((CheckButton*)checkbutton->widget)); |
---|
| 1031 | flags->setTextFromFlags(orxonoxGUI); ////// must be different!!! |
---|
[3290] | 1032 | cout << static_cast<CheckButton*>(checkbutton)->title << " set to: " << static_cast<CheckButton*>(checkbutton)->value << endl; |
---|
[3144] | 1033 | } |
---|
[3165] | 1034 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1035 | |
---|
| 1036 | /** |
---|
| 1037 | \brief Redraws the CheckButton (if option has changed). |
---|
| 1038 | Example: if new settings are loaded the Button must be redrawn for the GUI to display that Change |
---|
| 1039 | */ |
---|
| 1040 | void CheckButton::redraw () |
---|
| 1041 | { |
---|
[3165] | 1042 | #ifdef HAVE_GTK2 |
---|
[3144] | 1043 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); |
---|
[3165] | 1044 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1045 | } |
---|
| 1046 | |
---|
| 1047 | /* SLIDER */ |
---|
| 1048 | |
---|
| 1049 | /** |
---|
| 1050 | \brief Creates a new Slider |
---|
| 1051 | \param slidername The data-structure-name of the slider. |
---|
| 1052 | \param start The minimal Value of the slider. |
---|
| 1053 | \param end The maximal Value of the slider. |
---|
| 1054 | */ |
---|
| 1055 | Slider::Slider (char* slidername, int start, int end) |
---|
| 1056 | { |
---|
| 1057 | this->init(start, end); |
---|
| 1058 | this->setValue(start); |
---|
| 1059 | this->setTitle(slidername); |
---|
[3165] | 1060 | #ifdef HAVE_GTK2 |
---|
[3144] | 1061 | this->connectSignal ("value_changed", this->OptionChange); |
---|
[3165] | 1062 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1063 | } |
---|
| 1064 | |
---|
| 1065 | /** |
---|
[3289] | 1066 | \destructs a Slider. |
---|
| 1067 | */ |
---|
| 1068 | Slider::~Slider(void) |
---|
| 1069 | { |
---|
| 1070 | this->destroy(); |
---|
| 1071 | } |
---|
| 1072 | |
---|
| 1073 | /** |
---|
[3144] | 1074 | \brief Initializes a Slider with start and end Values |
---|
| 1075 | params: see Slider::Slider (char* slidername, int start, int end) |
---|
| 1076 | */ |
---|
| 1077 | void Slider::init(int start, int end) |
---|
| 1078 | { |
---|
[3147] | 1079 | isOption = 2; |
---|
[3144] | 1080 | |
---|
| 1081 | static_cast<Option*>(this)->init(); |
---|
| 1082 | |
---|
[3165] | 1083 | #ifdef HAVE_GTK2 |
---|
| 1084 | widget = gtk_hscale_new_with_range (start, end, 5); |
---|
| 1085 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1086 | } |
---|
| 1087 | |
---|
| 1088 | /** |
---|
[3289] | 1089 | \brief Destroys a Slider. |
---|
| 1090 | */ |
---|
| 1091 | void Slider::destroy(void) |
---|
| 1092 | { |
---|
[3290] | 1093 | if (this->title) |
---|
| 1094 | PRINTF(3)("deleting the Slider: %s\n", this->title); |
---|
[3289] | 1095 | else |
---|
| 1096 | PRINTF(3)("deleting the Slider.\n"); |
---|
| 1097 | |
---|
| 1098 | static_cast<Option*>(this)->destroy(); |
---|
| 1099 | |
---|
| 1100 | } |
---|
| 1101 | |
---|
| 1102 | /** |
---|
[3144] | 1103 | \brief Sets a new Title to the Slider |
---|
| 1104 | \param title The new Name of the slider |
---|
| 1105 | */ |
---|
| 1106 | void Slider::setTitle(char* title) |
---|
| 1107 | { |
---|
[3290] | 1108 | if (this->title) |
---|
| 1109 | delete []this->title; |
---|
| 1110 | this->title = new char[strlen(title)+1]; |
---|
| 1111 | strcpy(this->title, title); |
---|
[3144] | 1112 | } |
---|
| 1113 | |
---|
| 1114 | /** |
---|
| 1115 | \brief Setting a new value to the Slider. |
---|
| 1116 | Maybe you also require a Slider::redraw() for this to display |
---|
| 1117 | */ |
---|
| 1118 | void Slider::setValue(int value) |
---|
| 1119 | { |
---|
| 1120 | this->value = value; |
---|
| 1121 | } |
---|
| 1122 | |
---|
[3289] | 1123 | /** |
---|
| 1124 | \brief Redraws the widget |
---|
| 1125 | Example: see void CheckButton::redraw () |
---|
| 1126 | */ |
---|
| 1127 | void Slider::redraw () |
---|
| 1128 | { |
---|
[3165] | 1129 | #ifdef HAVE_GTK2 |
---|
[3289] | 1130 | gtk_range_set_value (GTK_RANGE (widget), value); |
---|
| 1131 | #endif /* HAVE_GTK2 */ |
---|
| 1132 | } |
---|
| 1133 | |
---|
| 1134 | #ifdef HAVE_GTK2 |
---|
[3144] | 1135 | /** |
---|
| 1136 | \brief Signal OptionChange writes the Value from the Slider to its Object-Database. |
---|
| 1137 | \param widget The widget(Slider) that has a changed Value |
---|
| 1138 | \param slider the Slider-Object that should receive the change. |
---|
| 1139 | */ |
---|
| 1140 | gint Slider::OptionChange (GtkWidget *widget, Widget* slider) |
---|
| 1141 | { |
---|
| 1142 | static_cast<Slider*>(slider)->value = (int)gtk_range_get_value (GTK_RANGE ((Slider*)slider->widget)); |
---|
| 1143 | flags->setTextFromFlags(orxonoxGUI); //// must be different !!! |
---|
[3290] | 1144 | cout << static_cast<Slider*>(slider)->title << " set to: "<< static_cast<Slider*>(slider)->value << endl; |
---|
[3144] | 1145 | } |
---|
[3165] | 1146 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1147 | |
---|
| 1148 | |
---|
| 1149 | /* MENU */ |
---|
| 1150 | |
---|
| 1151 | /** |
---|
| 1152 | \brief Creates a Menu-Item-list out of multiple input. |
---|
| 1153 | !! Consider, that the last input argument has to be "lastItem" for this to work!! |
---|
| 1154 | \param menuname The Database-Name of this Menu |
---|
| 1155 | \param ... items to be added to this Menu. !! Consider, that the last input argument has to be "lastItem" for this to work!! |
---|
| 1156 | */ |
---|
| 1157 | Menu::Menu (char* menuname, ...) |
---|
| 1158 | { |
---|
| 1159 | this->init(); |
---|
| 1160 | this->setTitle(menuname); |
---|
| 1161 | |
---|
| 1162 | char *itemName; |
---|
[3165] | 1163 | |
---|
| 1164 | #ifdef HAVE_GTK2 /////////////////////// REINPLEMENT |
---|
[3144] | 1165 | va_start (itemlist, menuname); |
---|
| 1166 | while (strcmp (itemName = va_arg (itemlist, char*), "lastItem")) |
---|
| 1167 | { |
---|
| 1168 | this->addItem(itemName); |
---|
| 1169 | } |
---|
| 1170 | va_end(itemlist); |
---|
[3165] | 1171 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1172 | |
---|
[3165] | 1173 | #ifdef HAVE_GTK2 |
---|
[3144] | 1174 | gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu); |
---|
| 1175 | this->connectSignal ("changed", this->OptionChange); |
---|
[3165] | 1176 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1177 | } |
---|
| 1178 | |
---|
| 1179 | /** |
---|
[3289] | 1180 | \destructs a Menu. |
---|
| 1181 | */ |
---|
| 1182 | Menu::~Menu(void) |
---|
| 1183 | { |
---|
| 1184 | this->destroy(); |
---|
| 1185 | } |
---|
| 1186 | |
---|
| 1187 | /** |
---|
[3144] | 1188 | \brief Initializes a new Menu with no items |
---|
| 1189 | */ |
---|
| 1190 | void Menu::init(void) |
---|
| 1191 | { |
---|
[3147] | 1192 | isOption = 2; |
---|
[3144] | 1193 | |
---|
| 1194 | static_cast<Option*>(this)->init(); |
---|
| 1195 | |
---|
[3165] | 1196 | #ifdef HAVE_GTK2 |
---|
[3144] | 1197 | widget = gtk_option_menu_new (); |
---|
| 1198 | menu = gtk_menu_new (); |
---|
[3165] | 1199 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1200 | |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | /** |
---|
[3289] | 1204 | \brief Destroys a Menu. |
---|
| 1205 | */ |
---|
| 1206 | void Menu::destroy(void) |
---|
| 1207 | { |
---|
[3290] | 1208 | if (this->title) |
---|
| 1209 | PRINTF(3)("deleting the Menu: %s\n", this->title); |
---|
[3289] | 1210 | else |
---|
| 1211 | PRINTF(3)("deleting the Menu.\n"); |
---|
| 1212 | //! \todo destroy menu |
---|
| 1213 | |
---|
| 1214 | static_cast<Option*>(this)->destroy(); |
---|
| 1215 | } |
---|
| 1216 | |
---|
| 1217 | |
---|
| 1218 | /** |
---|
[3144] | 1219 | * Sets the Database-Name of this Menu |
---|
| 1220 | \param title Database-Name to be set. |
---|
| 1221 | */ |
---|
| 1222 | void Menu::setTitle(char* title) |
---|
| 1223 | { |
---|
[3290] | 1224 | if (this->title) |
---|
| 1225 | delete []this->title; |
---|
| 1226 | this->title = new char[strlen(title)+1]; |
---|
| 1227 | strcpy(this->title, title); |
---|
[3144] | 1228 | } |
---|
| 1229 | |
---|
| 1230 | /** |
---|
| 1231 | \brief appends a new Item to the Menu-List. |
---|
| 1232 | \param itemName the itemName to be appendet. |
---|
| 1233 | */ |
---|
| 1234 | void Menu::addItem (char* itemName) |
---|
| 1235 | { |
---|
[3165] | 1236 | #ifdef HAVE_GTK2 |
---|
[3144] | 1237 | item = gtk_menu_item_new_with_label (itemName); |
---|
| 1238 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); |
---|
[3165] | 1239 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1240 | } |
---|
| 1241 | |
---|
[3289] | 1242 | /** |
---|
| 1243 | \brief Redraws the widget |
---|
| 1244 | Example: see void CheckButton::redraw () |
---|
| 1245 | */ |
---|
| 1246 | void Menu::redraw () |
---|
| 1247 | { |
---|
[3165] | 1248 | #ifdef HAVE_GTK2 |
---|
[3289] | 1249 | gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); |
---|
| 1250 | #endif /* HAVE_GTK2 */ |
---|
| 1251 | } |
---|
| 1252 | |
---|
| 1253 | #ifdef HAVE_GTK2 |
---|
[3144] | 1254 | /** |
---|
| 1255 | \brief Signal OptionChange writes the Value from the Menu to its Object-Database. |
---|
| 1256 | \param widget The widget(Menu) that has a changed Value |
---|
| 1257 | \param menu the Menu-Object that should receive the change. |
---|
| 1258 | */ |
---|
| 1259 | gint Menu::OptionChange (GtkWidget *widget, Widget* menu) |
---|
| 1260 | { |
---|
| 1261 | static_cast<Menu*>(menu)->value = (int)gtk_option_menu_get_history (GTK_OPTION_MENU (menu->widget)); |
---|
| 1262 | flags->setTextFromFlags(orxonoxGUI); //// must be different !!! |
---|
[3290] | 1263 | cout << static_cast<Menu*>(menu)->title << " changed to : " << static_cast<Menu*>(menu)->value << endl; |
---|
[3144] | 1264 | } |
---|
[3165] | 1265 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1266 | |
---|
[3289] | 1267 | /* OPTION LABEL */ |
---|
[3144] | 1268 | |
---|
[3187] | 1269 | /** |
---|
| 1270 | \brief Creates a new OptionLabel with a LabelName and a Value. |
---|
| 1271 | \param label The name of the OptionLabel. |
---|
| 1272 | \param value The Value of the OptionLabel (what will be displayed). |
---|
| 1273 | */ |
---|
[3161] | 1274 | OptionLabel::OptionLabel(char* label, char* value) |
---|
[3156] | 1275 | { |
---|
| 1276 | init(); |
---|
[3161] | 1277 | setTitle(label); |
---|
| 1278 | setValue(value); |
---|
[3156] | 1279 | } |
---|
| 1280 | |
---|
[3187] | 1281 | /** |
---|
[3289] | 1282 | \destructs an OptionLabel. |
---|
| 1283 | */ |
---|
| 1284 | OptionLabel::~OptionLabel(void) |
---|
| 1285 | { |
---|
| 1286 | this->destroy(); |
---|
| 1287 | } |
---|
| 1288 | |
---|
| 1289 | /** |
---|
[3187] | 1290 | \brief Initializes an OptionLabel |
---|
| 1291 | */ |
---|
[3156] | 1292 | void OptionLabel::init(void) |
---|
| 1293 | { |
---|
| 1294 | static_cast<Option*>(this)->init(); |
---|
[3161] | 1295 | isOption = 5; |
---|
| 1296 | cValue = NULL; |
---|
[3156] | 1297 | |
---|
[3165] | 1298 | #ifdef HAVE_GTK2 |
---|
[3156] | 1299 | widget = gtk_label_new (""); |
---|
[3165] | 1300 | #endif /* HAVE_GTK2 */ |
---|
[3156] | 1301 | } |
---|
[3165] | 1302 | |
---|
[3187] | 1303 | /** |
---|
[3289] | 1304 | \brief Destroys a OptionLabel. |
---|
| 1305 | */ |
---|
| 1306 | void OptionLabel::destroy(void) |
---|
| 1307 | { |
---|
[3290] | 1308 | if (this->title) |
---|
| 1309 | PRINTF(3)("deleting the OptionLabel: %s\n", this->title); |
---|
[3289] | 1310 | else |
---|
| 1311 | PRINTF(3)("deleting the OptionLabel.\n"); |
---|
| 1312 | if (cValue) |
---|
| 1313 | delete []cValue; |
---|
| 1314 | |
---|
| 1315 | static_cast<Option*>(this)->destroy(); |
---|
| 1316 | } |
---|
| 1317 | |
---|
| 1318 | |
---|
| 1319 | /** |
---|
[3187] | 1320 | \brief Updates the value of an OptionLabel |
---|
| 1321 | \param newValue The new Name that should be displayed. |
---|
| 1322 | */ |
---|
[3161] | 1323 | void OptionLabel::setValue(char* newValue) |
---|
| 1324 | { |
---|
| 1325 | if (cValue) |
---|
| 1326 | delete cValue; |
---|
| 1327 | cValue = new char [strlen(newValue)+1]; |
---|
| 1328 | strcpy(cValue, newValue); |
---|
[3165] | 1329 | #ifdef HAVE_GTK2 |
---|
[3161] | 1330 | gtk_label_set_text (GTK_LABEL (widget), cValue); |
---|
[3165] | 1331 | #endif /* HAVE_GTK2 */ |
---|
[3161] | 1332 | } |
---|
[3156] | 1333 | |
---|
[3187] | 1334 | /** |
---|
| 1335 | \brief Sets a ned Title to the OptionLabel. |
---|
| 1336 | \param title The now title of the OptionLabel. |
---|
| 1337 | */ |
---|
[3156] | 1338 | void OptionLabel::setTitle(char* title) |
---|
| 1339 | { |
---|
[3290] | 1340 | if (this->title) |
---|
| 1341 | delete []this->title; |
---|
| 1342 | this->title = new char [strlen(title)+1]; |
---|
| 1343 | strcpy(this->title, title); |
---|
[3165] | 1344 | #ifdef HAVE_GTK2 |
---|
[3156] | 1345 | gtk_label_set_text (GTK_LABEL (widget), title); |
---|
[3165] | 1346 | #endif /* HAVE_GTK2 */ |
---|
[3156] | 1347 | } |
---|
| 1348 | |
---|
[3187] | 1349 | /** |
---|
| 1350 | \brief Redraws an OptionLabel (not implemented yet, but it works). |
---|
| 1351 | */ |
---|
[3156] | 1352 | void OptionLabel::redraw(void) |
---|
| 1353 | { |
---|
| 1354 | |
---|
| 1355 | } |
---|
| 1356 | |
---|
[3144] | 1357 | /** |
---|
| 1358 | \brief Creates a new default Label with no Text. |
---|
| 1359 | You migth consider adding Label::setTitle with this. |
---|
| 1360 | */ |
---|
[3156] | 1361 | Label::Label () |
---|
[3144] | 1362 | { |
---|
| 1363 | this->init(); |
---|
| 1364 | } |
---|
| 1365 | |
---|
| 1366 | /** |
---|
| 1367 | \brief Creates a new Label with a Text. |
---|
| 1368 | \param text The text to be displayed. |
---|
| 1369 | */ |
---|
| 1370 | Label:: Label (char* text) |
---|
| 1371 | { |
---|
| 1372 | this->init(); |
---|
[3287] | 1373 | this->setTitle(text); |
---|
[3144] | 1374 | } |
---|
| 1375 | |
---|
| 1376 | /** |
---|
[3289] | 1377 | \destructs a Label. |
---|
| 1378 | */ |
---|
| 1379 | Label::~Label(void) |
---|
| 1380 | { |
---|
| 1381 | this->destroy(); |
---|
| 1382 | } |
---|
| 1383 | |
---|
| 1384 | /** |
---|
[3144] | 1385 | \brief initializes a new Label |
---|
| 1386 | */ |
---|
| 1387 | void Label::init(void) |
---|
| 1388 | { |
---|
[3147] | 1389 | isOption = 0; |
---|
[3144] | 1390 | |
---|
| 1391 | static_cast<Widget*>(this)->init(); |
---|
| 1392 | |
---|
[3165] | 1393 | #ifdef HAVE_GTK2 |
---|
[3144] | 1394 | widget = gtk_label_new (""); |
---|
| 1395 | gtk_label_set_line_wrap (GTK_LABEL(widget), TRUE); |
---|
[3165] | 1396 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1397 | } |
---|
| 1398 | |
---|
| 1399 | /** |
---|
[3289] | 1400 | \brief Destroys a Label. |
---|
| 1401 | */ |
---|
| 1402 | void Label::destroy(void) |
---|
| 1403 | { |
---|
[3290] | 1404 | if (this->title) |
---|
| 1405 | PRINTF(3)("deleting the Label: %s\n", this->title); |
---|
[3289] | 1406 | else |
---|
| 1407 | PRINTF(3)("deleting the Label.\n"); |
---|
| 1408 | |
---|
| 1409 | static_cast<Widget*>(this)->destroy(); |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | /** |
---|
[3144] | 1413 | \brief Sets a new Text to a Label. |
---|
| 1414 | \param text The text to be inserted into the Label. |
---|
| 1415 | */ |
---|
[3287] | 1416 | void Label::setTitle(char* text) |
---|
[3144] | 1417 | { |
---|
[3290] | 1418 | if (this->title) |
---|
| 1419 | delete []this->title; |
---|
| 1420 | this->title = new char[strlen(text)+1]; |
---|
| 1421 | strcpy(this->title, text); |
---|
[3165] | 1422 | #ifdef HAVE_GTK2 |
---|
[3144] | 1423 | gtk_label_set_text (GTK_LABEL (this->widget), text); |
---|
[3165] | 1424 | #endif /* HAVE_GTK2 */ |
---|
[3144] | 1425 | } |
---|
| 1426 | |
---|
| 1427 | /** |
---|
| 1428 | \brief get the Text of a Label |
---|
| 1429 | \return The Text the Label holds. |
---|
| 1430 | */ |
---|
| 1431 | char* Label::getText () |
---|
| 1432 | { |
---|
[3290] | 1433 | return this->title; |
---|
[3144] | 1434 | } |
---|
[3244] | 1435 | |
---|
| 1436 | /** |
---|
[3275] | 1437 | \brief Creates a new ProgressBar. |
---|
[3244] | 1438 | */ |
---|
| 1439 | ProgressBar::ProgressBar (void) |
---|
| 1440 | { |
---|
| 1441 | this->init (); |
---|
| 1442 | } |
---|
| 1443 | |
---|
| 1444 | /** |
---|
[3275] | 1445 | \brief Creates a new ProgressBar. |
---|
[3244] | 1446 | \param label The name you want to get the ProgressBar. |
---|
| 1447 | */ |
---|
| 1448 | ProgressBar::ProgressBar (char* label) |
---|
| 1449 | { |
---|
| 1450 | this->init(); |
---|
[3287] | 1451 | this->setTitle (label); |
---|
[3244] | 1452 | } |
---|
| 1453 | |
---|
| 1454 | /** |
---|
[3275] | 1455 | \brief destructs a ProgressBar |
---|
[3244] | 1456 | */ |
---|
| 1457 | ProgressBar::~ProgressBar () |
---|
| 1458 | { |
---|
[3289] | 1459 | this->destroy(); |
---|
[3244] | 1460 | } |
---|
| 1461 | |
---|
| 1462 | /** |
---|
| 1463 | \brief Initializes a ProgressBar |
---|
| 1464 | */ |
---|
| 1465 | void ProgressBar::init (void) |
---|
| 1466 | { |
---|
| 1467 | isOption = 0; |
---|
| 1468 | progress = 0.0; |
---|
| 1469 | totalSize = 0.0; |
---|
| 1470 | |
---|
| 1471 | static_cast<Widget*>(this)->init(); |
---|
| 1472 | #ifdef HAVE_GTK2 |
---|
| 1473 | adjustment = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0); |
---|
| 1474 | widget = gtk_progress_bar_new_with_adjustment(adjustment); |
---|
| 1475 | #endif /* HAVE_GTK2 */ |
---|
| 1476 | } |
---|
| 1477 | |
---|
| 1478 | /** |
---|
[3289] | 1479 | \brief Destroys a ProgressBar. |
---|
| 1480 | */ |
---|
| 1481 | void ProgressBar::destroy(void) |
---|
| 1482 | { |
---|
[3290] | 1483 | if (this->title) |
---|
| 1484 | PRINTF(3)("deleting the ProgressBar: %s\n", this->title); |
---|
[3289] | 1485 | else |
---|
| 1486 | PRINTF(3)("deleting the ProgressBar.\n"); |
---|
| 1487 | |
---|
| 1488 | static_cast<Widget*>(this)->destroy(); |
---|
| 1489 | } |
---|
| 1490 | |
---|
| 1491 | /** |
---|
[3287] | 1492 | \brief Sets a ned Title to the ProgressBar. |
---|
| 1493 | \param title The now title of the ProgressBar. |
---|
| 1494 | */ |
---|
| 1495 | void ProgressBar::setTitle(char* title) |
---|
| 1496 | { |
---|
[3290] | 1497 | if (this->title) |
---|
| 1498 | delete []this->title; |
---|
| 1499 | this->title = new char [strlen(title)+1]; |
---|
| 1500 | strcpy(this->title, title); |
---|
[3287] | 1501 | } |
---|
| 1502 | |
---|
| 1503 | /** |
---|
[3244] | 1504 | \brief Sets the Total size of the Bar. (ex. The maximum one can download) |
---|
| 1505 | */ |
---|
[3259] | 1506 | void ProgressBar::setTotalSize (double totalSize) |
---|
[3244] | 1507 | { |
---|
[3259] | 1508 | this->totalSize = totalSize; |
---|
[3244] | 1509 | } |
---|
| 1510 | |
---|
| 1511 | /** |
---|
| 1512 | \brief Sets the progress maximum is this->totalSize |
---|
| 1513 | */ |
---|
| 1514 | void ProgressBar::setProgress (double progress) |
---|
| 1515 | { |
---|
| 1516 | this->progress = progress; |
---|
| 1517 | |
---|
| 1518 | if (this->progress > this->totalSize) |
---|
| 1519 | this->progress = this->totalSize; |
---|
| 1520 | |
---|
| 1521 | #ifdef HAVE_GTK2 |
---|
| 1522 | gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize); |
---|
| 1523 | #endif /* HAVE_GTK2 */ |
---|
[3263] | 1524 | PRINTF(3)("Progress: %f\n", progress*100.0/totalSize); |
---|
[3244] | 1525 | } |
---|
| 1526 | |
---|
| 1527 | /** |
---|
| 1528 | \brief returns the Progress Status |
---|
| 1529 | */ |
---|
| 1530 | double ProgressBar::getProgress (void) |
---|
| 1531 | { |
---|
| 1532 | return this->progress; |
---|
| 1533 | } |
---|
[3287] | 1534 | |
---|
| 1535 | /* IMAGE */ |
---|
| 1536 | |
---|
| 1537 | /** |
---|
| 1538 | \brief Creates a new Image |
---|
| 1539 | \param imagename the location of the Image on the Hard Disc |
---|
| 1540 | */ |
---|
| 1541 | Image::Image (char* imagename) |
---|
| 1542 | { |
---|
| 1543 | this->init(); |
---|
[3290] | 1544 | if (this->title) |
---|
| 1545 | delete []this->title; |
---|
| 1546 | this->title = new char[strlen(imagename)+1]; |
---|
| 1547 | strcpy(this->title, imagename); |
---|
[3287] | 1548 | |
---|
| 1549 | #ifdef HAVE_GTK2 |
---|
| 1550 | widget = gtk_image_new_from_file (imagename); |
---|
| 1551 | #endif /* HAVE_GTK2 */ |
---|
| 1552 | } |
---|
| 1553 | |
---|
[3289] | 1554 | /** |
---|
| 1555 | \destructs an Image. |
---|
| 1556 | */ |
---|
| 1557 | Image::~Image(void) |
---|
| 1558 | { |
---|
| 1559 | this->destroy(); |
---|
| 1560 | } |
---|
| 1561 | |
---|
[3287] | 1562 | /** |
---|
| 1563 | \brief Initializes a new Image |
---|
| 1564 | */ |
---|
| 1565 | void Image::init() |
---|
| 1566 | { |
---|
| 1567 | isOption = 0; |
---|
| 1568 | |
---|
| 1569 | static_cast<Widget*>(this)->init(); |
---|
| 1570 | } |
---|
| 1571 | |
---|
| 1572 | /** |
---|
[3289] | 1573 | \brief Destroys a Image. |
---|
| 1574 | */ |
---|
| 1575 | void Image::destroy(void) |
---|
| 1576 | { |
---|
[3290] | 1577 | if (this->title) |
---|
| 1578 | PRINTF(3)("deleting the Image: %s\n", this->title); |
---|
[3289] | 1579 | else |
---|
| 1580 | PRINTF(3)("deleting the Image.\n"); |
---|
| 1581 | |
---|
| 1582 | static_cast<Widget*>(this)->destroy(); |
---|
| 1583 | } |
---|
| 1584 | |
---|
| 1585 | /** |
---|
[3287] | 1586 | \brief Sets a ned Title to the Image. |
---|
| 1587 | \param title The now title of the OptionLabel. |
---|
| 1588 | */ |
---|
| 1589 | void Image::setTitle(char* title) |
---|
| 1590 | { |
---|
[3290] | 1591 | if (this->title) |
---|
| 1592 | delete []this->title; |
---|
| 1593 | this->title = new char [strlen(title)+1]; |
---|
| 1594 | strcpy(this->title, title); |
---|
[3287] | 1595 | } |
---|