Planeshift
pawsconfigwindow.h
Go to the documentation of this file.
1 /*
2  * pawsconfigwindow.h - Author: Ondrej Hurt
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PAWS_CONFIG_WINDOW_HEADER
21 #define PAWS_CONFIG_WINDOW_HEADER
22 
23 #include <csutil/parray.h>
24 
25 #include "paws/pawswidget.h"
26 #include "paws/pawstree.h"
27 #include "gui/pawscontrolwindow.h"
28 
29 
30 
31 /* Configuration is divided into sections. Sections are identified by names.
32  * The main configuration window consist of a tree of sections on the left and
33  * one section window on the right. Each node of the tree represents one section.
34  * When a node is selected, a section window is shown on the right. (e.g. keyboard configuration)
35  * All section windows are widgets derived from the pawsConfigSectionWindow class.
36  *
37  * The tree on the left is described in /data/configtree.xml file.
38  * Each tree node that is meant to invoke configuration section (pawsConfigSectionWindow subclass)
39  * must have two attributes defined:
40  * - SectionName: string that identifies section
41  * - factory: name of pawsConfigSectionWindow subclass that takes care of GUI of this section
42  *
43  * pawsConfigSectionWindow is the superclass of section windows.
44  */
46 {
47 public:
49  {
50  dirty = false;
51  }
52  void SetSectionName(const csString &_sectionName)
53  {
54  sectionName = _sectionName;
55  }
56  virtual bool Initialize() = 0;
58  virtual bool LoadConfig() = 0;
60  virtual bool IsDirty()
61  {
62  return dirty;
63  }
65  virtual bool SaveConfig() = 0;
66 
68  virtual void SetDefault() = 0;
69 
70 protected:
71  /* Says what section of configuration is being configured by this window.
72  * A pawsConfigSectionWindow could be used by more than one section
73  * and 'sectionName' tells which section it is.
74  */
75  csString sectionName;
76 
77  /* Is data in configuration window different from data in configuration file
78  * i.e. do we need to save it ?
79  * Should be set to true when user changes something, and to false when the data is loaded/saved.
80  */
81  bool dirty;
82 
83 };
84 
85 
86 
87 // The sectWnd_t structure holds a pair [ section name , section window ]
88 struct sectWnd_t
89 {
90  sectWnd_t(const csString &_sectName, pawsConfigSectionWindow* _sectWnd)
91  {
92  sectName = _sectName;
93  sectWnd = _sectWnd;
94  }
95  csString sectName;
97 };
98 
99 
100 
106 {
107 public:
108 
110 
111  // from pawsWidget:
112  virtual bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* widget);
113  virtual bool OnSelected(pawsWidget* widget);
114  virtual bool PostSetup();
115 
118  void SetNotify(pawsWidget* notify);
119 
120 
121 private:
123  pawsConfigSectionWindow* FindSectionWindow(const csString &sectName);
124 
125  iObjectRegistry* object_reg;
126  csArray<sectWnd_t> sectWnds;
127 
128  pawsSimpleTree* sectionTree;
129  pawsWidget* sectionParent;
130  pawsConfigSectionWindow* currSectWnd;
131  pawsWidget* okButton, * resetButton;
132  pawsWidget* notify;
133 };
134 
135 
137 
138 
139 #endif
140 
void SetSectionName(const csString &_sectionName)
This is a window that is controlled by a button on the control bar.
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget *widget)
Called whenever a button is released.
Definition: pawswidget.h:1205
virtual bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
Definition: pawswidget.h:709
virtual bool OnSelected(pawsWidget *widget)
Called whenever a widget is selected.
Class pawsConfigWindow implements the main configuration window that is invoked in-game by clicking o...
virtual bool LoadConfig()=0
sets content of dialog according to current configuration
sectWnd_t(const csString &_sectName, pawsConfigSectionWindow *_sectWnd)
pawsConfigSectionWindow * sectWnd
virtual void SetDefault()=0
sets content of dialog according to default configuration
virtual bool Initialize()=0
csString sectName
virtual bool IsDirty()
were settings modified ?
virtual bool SaveConfig()=0
remembers settings in-game and saves them permanently to a file also
CREATE_PAWS_FACTORY(pawsConfigWindow)