Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/gui/gtk_gui/gui_flags.cc @ 5412

Last change on this file since 5412 was 5412, checked in by bensch, 19 years ago

orxonox/trunk: subprojects compile again (but with many segfaults)

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 "gui_flags.h"
27
28/**
29 *  Creates the Flags-Frame
30*/
31GuiFlags::GuiFlags()
32{
33  this->flagsFrame = new Frame("Orxonox-Startup-Flags:");
34  this->flagsBox = new Box('v');
35
36  this->flagsLabel = new Label();
37  this->flagsLabel->setSize(260,60);
38  this->flagsBox->fill(flagsLabel);
39  this->shortFlags = new CheckButton("shortFlags");
40  this->shortFlags->setDefaultValue(0);
41  this->flagsBox->fill(shortFlags);
42
43  this->flagsFrame->fill(flagsBox);
44  this->setMainWidget(flagsFrame);
45}
46
47/**
48 *  Destructs the Flags-stuff
49*/
50GuiFlags::~GuiFlags()
51{
52  // nothing to do here
53}
54
55/**
56 *  Sets the Flags from widget downwards.
57 * @param widget the Widget from which on to scan for deeper Options and their settings.
58*/
59void GuiFlags::setTextFromFlags(Widget* widget)
60{
61  if (widget == NULL)
62    return;
63  FlagInfo flagInfo;
64  flagInfo.shortFlags = this->shortFlags;
65  flagInfo.flagsLabel = this->flagsLabel;
66
67  this->flagsLabel->ereaseText();
68  this->flagsLabel->appendText(executable);
69  widget->walkThrough(GuiFlags::flagsText, &flagInfo, 0);
70  //  flagsLabel->setTitle(flagText);
71}
72
73/**
74  *  this actually sets the flagtext, and appends it to flagText
75  * @param widget like GuiFlags::setTextFromFlags(widget)
76  * @param flagInfo Information aboout the Flag that should be updated.
77*/
78void GuiFlags::flagsText(Widget* widget, void* flagInfo)
79{
80  FlagInfo* info =(FlagInfo*)flagInfo;
81  if(widget->optionType > GUI_NOTHING)
82    if (static_cast<Option*>(widget)->value != static_cast<Option*>(widget)->defaultValue )
83      {
84        if(info->shortFlags->isActive() && static_cast<Option*>(widget)->flagNameShort)
85          {
86            info->flagsLabel->appendText(" -");
87            info->flagsLabel->appendText(static_cast<Option*>(widget)->flagNameShort);
88          }
89        else if(!info->shortFlags->isActive() && static_cast<Option*>(widget)->flagName)
90          {
91            info->flagsLabel->appendText(" --");
92            info->flagsLabel->appendText(static_cast<Option*>(widget)->flagName);
93          }
94
95        if(static_cast<Option*>(widget)->optionType > GUI_BOOL)
96          {
97            info->flagsLabel->appendText("=");
98            info->flagsLabel->appendInt(static_cast<Option*>(widget)->value);
99          }
100      }
101}
Note: See TracBrowser for help on using the repository browser.