Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/old.bezierTrack/gui/orxonox_gui_flags.cc @ 3762

Last change on this file since 3762 was 2605, checked in by bensch, 20 years ago

orxonox/trunk/gui: generalized: destructor, added label to class Widget, down is now a method of Packer, isOpen added for Windows

File size: 3.0 KB
Line 
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#include "orxonox_gui_flags.h"
27#include <iostream.h>
28
29/**
30   \brief Creates the Flags-Frame
31   \param widget The Widget from which the data will be parsed
32*/
33OrxonoxGuiFlags::OrxonoxGuiFlags (Widget* widget)
34{
35  flagText = (char*) malloc (1024);
36
37  flagsFrame = new Frame ("Orxonox-Startup-Flags:");
38  flagsBox = new Box ('v');
39
40  flagsLabel = new Label ();
41  flagsLabel->setSize (260,60);
42  flagsBox->fill (flagsLabel);
43  shortFlags = new CheckButton ("shortFlags");
44  flagsBox->fill (shortFlags);
45
46  flagsFrame->fill (flagsBox);
47}
48
49/**
50   \brief Function to return the Frame that holds the Flagtext.
51   \returns Frame that holds the Flagtext.
52*/
53Widget* OrxonoxGuiFlags::getWidget ()
54{
55  return flagsFrame;
56}
57
58/**
59   \brief Sets the Flags from widget downwards.
60   \param widget the Widget from which on to scan for deeper Options and their settings.
61*/
62void OrxonoxGuiFlags::setTextFromFlags (Widget* widget)
63{
64  sprintf (flagText, "");
65  strcat (flagText, "orxonox");
66  FlagsText (widget);
67  flagsLabel->setText (flagText);
68}
69
70/**
71    \brief this actually sets the flagtext, and appends it to flagText
72    \param widget like OrxonoxGuiFlags::setTextFromFlags(widget)
73*/
74void OrxonoxGuiFlags::FlagsText(Widget* widget)
75{
76  if (widget->is_option >= 1)
77    if  (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->default_value && (strcmp (static_cast<Option*>(widget)->flag_name, "") || strcmp (static_cast<Option*>(widget)->flag_name_short, "")))
78      {
79        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shortFlags->widget)))
80          {
81            strcat (flagText, " -");
82            strcat (flagText, static_cast<Option*>(widget)->flag_name_short);
83          }
84        else
85          {
86            strcat (flagText, " --");
87            strcat (flagText, static_cast<Option*>(widget)->flag_name);
88          }
89        if (static_cast<Option*>(widget)->is_option == 2)
90          {
91            sprintf (flagText, "%s=%i", flagText, static_cast<Option*>(widget)->value);
92          }
93      }
94  switch (widget->is_option)
95    {
96    case -1:
97      FlagsText (static_cast<Container*>(widget)->down);
98      break;
99    case -2:
100      FlagsText (static_cast<Box*>(widget)->down);
101      break;
102    } 
103 
104  if (widget->next != NULL)
105    FlagsText (widget->next);
106}
Note: See TracBrowser for help on using the repository browser.