Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / interface_v3 / interface_ddx.h
blob2be1c84b4b9160dc3b89a30d37cfc251ad1082ea
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef NL_INTERFACE_DDX_H
23 #define NL_INTERFACE_DDX_H
25 #include "nel/misc/types_nl.h"
26 #include "nel/gui/interface_element.h"
27 #include "interface_pointer.h"
29 // Values for float (scrollbar float) must not exceed 200,00 this is due to storing on
30 // an integer value with a precision of 10,000
31 // For the moment realtime parameters are only valid on scrollbar
32 // ***************************************************************************
33 class CInterfaceDDX : public CInterfaceElement
35 public:
36 // The number of preset in cfg.
37 enum {NumPreset= 4, CustomPreset=NumPreset};
39 public:
40 virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
42 CInterfaceDDX();
43 virtual ~CInterfaceDDX();
45 // DB -> Parameters
46 void init();
48 // Parameters -> DB
49 void update();
51 // Restore realtime values
52 void cancel();
54 // Update parameters that are realtime
55 void updateRealtime(CCtrlBase *pSB, bool updateOnScrollEnd);
57 // Update all parameters to obey their preset (no op if no preset or if preset is Custom)
58 void updateParamPreset(NLMISC::CCDBNodeLeaf *presetChanged);
60 // set apply button can be pushed
61 void validateApplyButton();
63 private:
65 class CParam
67 public:
68 // -----------------------
69 enum SParamType { DataBase, ConfigFile };
70 enum SParamWidget { ColorButton, BoolButton, ScrollBarInt, ScrollBarFloat };
71 enum TRealTimeMode { RTModeFalse=0, RTModeTrue, RTModeEndScroll};
73 // -----------------------
74 // The control
75 CInterfaceElementPtr Elt;
76 SParamType Type;
77 SParamWidget Widget;
78 std::string Link;
79 // The tex view, result of the scroll
80 CViewTextPtr ResultView;
81 // The unit to append to the result string
82 std::string ResultUnit;
83 // For ScrollBarFloat widget only
84 uint8 ResultDecimal;
85 // For ScrollBarFloat widget only
86 bool RoundMode;
88 // If Widget is scrollbar int or float
89 sint32 Min, Max;
91 // When the effect of the param is applied
92 TRealTimeMode RealTimeMode;
93 sint32 RTBackupValue; // When canceling
95 // For ConfigFile widget only
96 NLMISC::CCDBNodeLeaf *PresetDB;
98 // -----------------------
99 CParam()
101 ResultDecimal= 0;
102 RoundMode= false;
103 PresetDB= NULL;
104 RealTimeMode= RTModeFalse;
106 void DBToWidget();
107 void CFGToWidget();
108 void WidgetToDB();
109 void WidgetToCFG();
110 void backupDB();
111 void backupCFG();
112 void restoreDB();
113 void restoreCFG();
115 // update ResultView according to widget. Don't modify DB or CFG
116 void WidgetToResultView();
118 // restore the preset value
119 void restoreCFGPreset(uint presetVal);
121 // From the current CFG value, compare to each preset value, and init the bitfield
122 uint32 getPresetPossibleBF();
124 private:
125 void updateScrollView(sint32 nVal);
126 void updateScrollView(double nVal);
127 void tryRound(double nVal);
130 // Array of parameters
131 std::vector<CParam> _Parameters;
133 // For preset change
134 class CPresetObs : public NLMISC::ICDBNode::IPropertyObserver
136 public:
137 virtual void update(NLMISC::ICDBNode* node);
138 CInterfaceDDX *Owner;
140 CPresetObs() : Owner(NULL) {}
142 CPresetObs _PresetObs;
143 std::set<NLMISC::CCDBNodeLeaf*> _PresetNodes;
145 // reset the preset values according to parameters values
146 void resetPreSet();
148 // For apply button ungraying
149 class CCtrlBaseButton *_ApplyButton;
152 // ***************************************************************************
153 class CDDXManager
155 public:
157 static CDDXManager *getInstance()
159 if (_Instance == NULL)
160 _Instance = new CDDXManager;
161 return _Instance;
164 // release memory
165 static void releaseInstance();
167 void add(CInterfaceDDX *pDDX);
168 CInterfaceDDX *get(const std::string &ddxName);
169 // Get the ddx from its parent name
170 CInterfaceDDX *getFromParent(const std::string &ddxParentName);
172 // Release the manager
173 void release();
175 private:
176 CDDXManager();
178 private:
179 static CDDXManager *_Instance;
180 std::map<std::string, CInterfaceDDX*> _DDXes;
183 #endif // NL_INTERFACE_ELEMENT_H
185 /* End of interface_element.h */