Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/gui/orxonox_gui_flags.cc @ 3162

Last change on this file since 3162 was 3158, checked in by bensch, 20 years ago

orxonox/trunk/gui: safer (char* initialization), nicer _n →N

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