+ bool NewLine;
+ bool IgnoreMaxWidth;
+ bool IgnoreMinWidth;
+ bool AddChildW;
+
+ // The table width cell ratio. This is the parameter
+ float TableRatio;
+
+ // The Width you want in pixel. This is the | parameter
+ sint32 WidthWanted;
+
+
+ // The min height of the cell
+ sint32 Height;
+
+ // Memorize max width
+ sint32 WidthMax;
+
+ // The cell color
+ NLMISC::CRGBA BgColor;
+
+ // Texture
+ CViewRenderer::CTextureId _TextureId; /// Accelerator
+ bool _UserTexture;
+ bool _TextureTiled;
+ bool _TextureScaled;
+
+ // Alignment
+ TAlign Align;
+ TVAlign VAlign;
+ sint32 LeftMargin;
+
+ // The cell group
+ CInterfaceGroup *Group;
+
+ // The cell is nowrap
+ bool NoWrap;
+
+ void setTexture(const std::string & TxName);
+ void setTextureTile(bool tiled);
+ void setTextureScale(bool scaled);
+
+ static void setDebugUICell( bool d ){ DebugUICell = d; }
+ static bool getDebugUICell(){ return DebugUICell; }
+
+ private:
+ void setEnclosedGroupDefaultParams();
+ static bool DebugUICell;
+ };
+
+ /**
+ * This group is used to simulate HTML table. Support "percent of the parent width" sizeRef mode.
+ */
+ class CGroupTable : public CInterfaceGroup
+ {
+ public:
+
+ ///constructor
+ CGroupTable(const TCtorParam ¶m);
+
+ // dtor
+ ~CGroupTable();
+
+ // Add a cell in the table
+ void addChild (CGroupCell* child);
+
+ // The ratio you want [0 ~1]. This is the parameter
+ float TableRatio;
+
+ // The Width you want in pixel. This is the parameter
+ sint32 ForceWidthMin;
+
+ // Table borders
+ sint32 Border;
+ sint32 CellPadding;
+ sint32 CellSpacing;
+
+ // The table color
+ NLMISC::CRGBA BgColor;
+ uint8 CurrentAlpha;
+
+ bool ContinuousUpdate;
+
+ std::string getProperties( const std::string &name ) const;
+ void setProperty( const std::string &name, const std::string &value );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
+
+ protected:
+
+ /// \from CInterfaceElement
+ void onInvalidateContent();
+ sint32 getMaxUsedW() const;
+ sint32 getMinUsedW() const;
+ void draw ();
+
+ /**
+ * init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
+ */
+ virtual void updateCoords();
+
+ virtual void checkCoords();
+
+ virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
+
+ // Content validated
+ bool _ContentValidated;
+
+ // Last parent width
+ sint32 _LastParentW;
+
+ // Children
+ std::vector _Cells;
+
+ // Table column
+ class CColumn
+ {
+ public:
+ CColumn()
+ {
+ Width = 0;
+ WidthMax = 0;
+ WidthWanted = 0;
+ TableRatio = 0;
+ Height = 0;
+ }
+ sint32 Width;
+ sint32 Height;
+ sint32 WidthWanted;
+ sint32 WidthMax;
+ float TableRatio;
+ };
+
+ // Table row
+ class CRow
+ {
+ public:
+ CRow()
+ {
+ Height = 0;
+ }
+ sint32 Height;
+ };
+
+ // Column table
+ std::vector _Columns;
+
+ // Column table
+ std::vector _Rows;
+ };
+
+}
+
+#endif // NL_GROUP_TABLE_H
+
+/* End of group_table.h */
+
+
diff --git a/code/nel/include/nel/gui/group_tree.h b/code/nel/include/nel/gui/group_tree.h
new file mode 100644
index 000000000..d5f2f1a43
--- /dev/null
+++ b/code/nel/include/nel/gui/group_tree.h
@@ -0,0 +1,381 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef NL_GROUP_TREE_H
+#define NL_GROUP_TREE_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/gui/group_frame.h"
+#include "nel/misc/smart_ptr.h"
+
+namespace NLGUI
+{
+ class CViewText;
+ class CViewBitmap;
+
+ // ----------------------------------------------------------------------------
+ class CGroupTree : public CInterfaceGroup
+ {
+
+ public:
+
+ struct SNode;
+ // optional callback that is called when a node has been added
+ struct INodeAddedCallback
+ {
+ /** A node has just been added in the CGroupTree object
+ * \param node The logic node from which the ui node was built
+ * \param interfaceElement The ui node that was built
+ */
+ virtual void nodeAdded(SNode *node, CInterfaceElement *interfaceElement) = 0;
+ };
+
+ // Logic structure to initialize the group tree (root node is not displayed and is always opened)
+ struct SNode : public CReflectableRefPtrTarget
+ {
+ typedef NLMISC::CRefPtr TRefPtr;
+ // Common
+ std::string Id; // If not present auto-generated
+ bool Opened;
+ bool DisplayText; // If false instanciate a template
+ bool Show; // If false, the node is not displayed (true default, Root ignored)
+ sint32 YDecal;
+ // Text
+ ucstring Text; // Internationalized displayed text
+ sint32 FontSize; // If -1 (default), then take the groupTree one
+ NLMISC::CRGBA Color;
+ // Template
+ NLMISC::CSmartPtr Template;
+ // Actions Handlers (for left button)
+ std::string AHName;
+ std::string AHCond;
+ std::string AHParams;
+ // Actions Handlers (for right button)
+ std::string AHNameRight;
+ std::string AHParamsRight;
+ // Actions Handlers (close/open node)
+ std::string AHNameClose;
+ std::string AHParamsClose;
+ // bitmap at this level of hierarchy
+ std::string Bitmap; // additionnal bitmap
+ // Hierarchy
+ std::vector Children;
+ SNode *Father;
+ // updated at display
+ SNode *LastVisibleSon; // filled at build time, meaningfull only if son is shown and opened, undefined otherwise
+ // Node added callback
+ INodeAddedCallback *NodeAddedCallback;
+ //
+ CGroupTree *ParentTree;
+ // ----------------------------
+ SNode();
+ ~SNode();
+ void updateLastVisibleSon();
+ void detachChild(SNode *pNode);
+ void deleteChild(SNode *pNode);
+ void addChild (SNode *pNode);
+ bool isChild(SNode *pNode) const;
+ void addChildFront (SNode *pNode);
+ void addChildAtIndex (SNode *pNode, sint index);
+ void addChildSorted(SNode *pNode);
+ void addChildSortedByBitmap(SNode *pNode);
+ void setParentTree(CGroupTree *parent);
+ void setFather(SNode *father);
+ void closeAll();
+ void makeOrphan();
+ bool parse (xmlNodePtr cur, CGroupTree *parentGroup);
+ uint getNumBitmap() const { return Bitmap.empty() ? 0 : 1; }
+ SNode *getNodeFromId(const std::string &id);
+
+ // accessors
+ void setBitmap(const std::string &bitmap) { Bitmap = bitmap; }
+ std::string getBitmap() const { return Bitmap; }
+ void setOpened(bool opened) { Opened = opened; }
+ bool getOpened() const { return Opened; }
+ void setText(const ucstring &text) { Text = text; }
+ const ucstring& getText() const { return Text; }
+ sint32 getFontSize() const { return FontSize; }
+ void setFontSize(sint32 value) { FontSize = value; }
+ sint32 getYDecal() const { return YDecal; }
+ void setYDecal(sint32 value) { YDecal = value; }
+
+
+ std::string getId() const { return Id; }
+ void setId(const std::string &value) { Id = value; }
+ bool getShow() const { return Show; }
+ void setShow(bool value) { Show = value; }
+ std::string getAHName() const { return AHName; }
+ void setAHName(const std::string &value) { AHName = value; }
+ std::string getAHCond() const { return AHCond; }
+ void setAHCond(const std::string &value) { AHCond = value; }
+ std::string getAHParams() const { return AHParams; }
+ void setAHParams(const std::string &value) { AHParams = value; }
+ std::string getAHNameRight() const { return AHNameRight; }
+ void setAHNameRight(const std::string &value) { AHNameRight = value; }
+ std::string getAHParamsRight() const { return AHParamsRight; }
+ void setAHParamsRight(const std::string &value) { AHParamsRight = value; }
+ std::string getAHNameClose() const { return AHNameClose; }
+ void setAHNameClose(const std::string &value) { AHNameClose = value; }
+ std::string getAHParamsClose() const { return AHParamsClose; }
+ void setAHParamsClose(const std::string &value) { AHParamsClose = value; }
+ NLMISC::CRGBA getColor() const { return Color; }
+ void setColor(NLMISC::CRGBA color) { Color = color; }
+ // sort branch & sons alphabetically
+ void sort();
+ // sort branch & sons alphabetically & by bitmap name (blank bitmap being the first)
+ void sortByBitmap();
+
+ // lua bindings
+ int luaGetNumChildren(CLuaState &ls);
+ int luaGetChild(CLuaState &ls);
+ int luaDetachChild(CLuaState &ls);
+ int luaDeleteChild(CLuaState &ls);
+ int luaAddChild(CLuaState &ls);
+ int luaAddChildSorted(CLuaState &ls);
+ int luaAddChildSortedByBitmap(CLuaState &ls);
+ int luaIsChild(CLuaState &ls);
+ int luaAddChildFront (CLuaState &ls);
+ int luaAddChildAtIndex (CLuaState &ls);
+ int luaCloseAll(CLuaState &ls);
+ int luaGetFather(CLuaState &ls);
+ int luaSort(CLuaState &ls);
+ int luaSortByBitmap(CLuaState &ls);
+ int luaGetNodeFromId(CLuaState &ls);
+ int luaGetParentTree(CLuaState &ls);
+
+ // get node from first parameter on lua stack and throw necessary exception if not present
+ static SNode *luaGetNodeOnStack(CLuaState &ls, const char *funcName);
+
+ REFLECT_EXPORT_START(CGroupTree::SNode, CReflectable)
+ REFLECT_STRING("Id", getId, setId);
+ REFLECT_STRING("Bitmap", getBitmap, setBitmap);
+ REFLECT_SINT32("FontSize", getFontSize, setFontSize);
+ REFLECT_SINT32("YDecal", getYDecal, setYDecal);
+ REFLECT_STRING("AHName", getAHName, setAHName);
+ REFLECT_STRING("AHCond", getAHCond, setAHCond);
+ REFLECT_RGBA("Color", getColor, setColor);
+ REFLECT_STRING("AHParams", getAHParams, setAHParams);
+ REFLECT_STRING("AHNameRight", getAHNameRight, setAHNameRight);
+ REFLECT_STRING("AHParamsRight", getAHParamsRight, setAHParamsRight);
+ REFLECT_STRING("AHNameClose", getAHNameClose, setAHNameClose);
+ REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose);
+ REFLECT_BOOL("Opened", getOpened, setOpened);
+ REFLECT_BOOL("Show", getShow, setShow);
+ REFLECT_UCSTRING("Text", getText, setText);
+ // lua
+ REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren);
+ REFLECT_LUA_METHOD("getChild", luaGetChild);
+ REFLECT_LUA_METHOD("detachChild", luaDetachChild);
+ REFLECT_LUA_METHOD("deleteChild", luaDeleteChild);
+ REFLECT_LUA_METHOD("addChild", luaAddChild);
+ REFLECT_LUA_METHOD("addChildSorted", luaAddChildSorted);
+ REFLECT_LUA_METHOD("addChildSortedByBitmap", luaAddChildSortedByBitmap);
+ REFLECT_LUA_METHOD("addChildFront", luaAddChildFront);
+ REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
+ REFLECT_LUA_METHOD("isChild", luaIsChild);
+ REFLECT_LUA_METHOD("closeAll", luaCloseAll);
+ REFLECT_LUA_METHOD("getFather", luaGetFather);
+ REFLECT_LUA_METHOD("sort", luaSort);
+ REFLECT_LUA_METHOD("sortByBitmap", luaSortByBitmap);
+ REFLECT_LUA_METHOD("getNodeFromId", luaGetNodeFromId);
+ REFLECT_LUA_METHOD("getParentTree", luaGetParentTree);
+ REFLECT_EXPORT_END
+
+
+ };
+
+ public:
+
+ ///constructor
+ CGroupTree(const TCtorParam ¶m);
+
+ // dtor
+ virtual ~CGroupTree();
+
+ std::string getProperty( const std::string &name ) const;
+ void setProperty( const std::string &name, const std::string &value );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
+
+ virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
+
+ virtual void checkCoords();
+
+ virtual void updateCoords();
+
+ virtual void draw();
+
+ virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
+
+ void reset();
+
+ // force rebuild the tree at next updateCoords()
+ void forceRebuild();
+
+ // For SNode
+ sint32 getIdNumber() { _IdGenerator++; return _IdGenerator; }
+ sint32 getFontSize() { return _FontSize; }
+ sint32 getYDecal() { return _YDecal; }
+
+ // Set root node and delete the last one the user must not delete all allocated sub node. Nb: selection is reseted
+ void setRootNode (SNode *);
+ // Remove all lines bitmaps and templates or texts
+ void removeAll();
+
+ // unselect current node in tree
+ void unselect();
+
+ // Select a node by its line index (depends on opened nodes). no-op if not possible (AH not here, line>size)
+ void selectLine(uint line, bool runAH = true);
+ // simulate right button click on the given line (this also select the line)
+ bool rightButton(uint line);
+
+ // Get the Selected Node Id. empty if none selected
+ const std::string &getSelectedNodeId() const;
+
+ // Select by the node Id. return false if not found (selection is not reseted)
+ // NB: if the node was already selected, no-op (no action handler launched)
+ bool selectNodeById(const std::string &nodeId, bool triggerAH = true);
+
+ // Get the root node (Opened State represent the current state)
+ SNode *getRootNode () const {return _RootNode;}
+
+ // get current SNode under the mouse (possibly NULL)
+ SNode *getNodeUnderMouse() const;
+
+ // Get/Change the NavigateOneBrnahc option. if false, then perform a reset before
+ bool getNavigateOneBranch() const {return _NavigateOneBranch;}
+ void changeNavigateOneBranch(bool newState);
+
+ // should be called by action handler when thy want to cancel the selection of the line that triggered them
+ void cancelNextSelectLine();
+
+ // Get selected node
+ SNode * getSelectedNode() { return _SelectedNode;}
+
+ // lua bindings
+ int luaGetRootNode(CLuaState &ls);
+ int luaSetRootNode(CLuaState &ls);
+ int luaForceRebuild(CLuaState &ls);
+ int luaSelectNodeById(CLuaState &ls);
+ int luaGetSelectedNodeId(CLuaState &ls);
+ int luaSelectLine(CLuaState &ls);
+ int luaUnselect(CLuaState &ls);
+ int luaGetNodeUnderMouse(CLuaState &ls);
+ int luaCancelNextSelectLine(CLuaState &ls);
+
+ // Reflection
+ REFLECT_EXPORT_START(CGroupTree, CInterfaceGroup)
+ REFLECT_BOOL ("navigate_one_branch", getNavigateOneBranch, changeNavigateOneBranch);
+ REFLECT_LUA_METHOD("getRootNode", luaGetRootNode);
+ REFLECT_LUA_METHOD("setRootNode", luaSetRootNode);
+ REFLECT_LUA_METHOD("forceRebuild", luaForceRebuild);
+ REFLECT_LUA_METHOD("getSelectedNodeId", luaGetSelectedNodeId);
+ REFLECT_LUA_METHOD("selectNodeById", luaSelectNodeById);
+ REFLECT_LUA_METHOD("selectLine", luaSelectLine);
+ REFLECT_LUA_METHOD("unselect", luaUnselect);
+ REFLECT_LUA_METHOD("getNodeUnderMouse", luaGetNodeUnderMouse);
+ REFLECT_LUA_METHOD("cancelNextSelectLine", luaCancelNextSelectLine);
+ REFLECT_EXPORT_END
+
+ private:
+
+ void setupArbo();
+ sint32 _BmpW, _BmpH, _FontSize, _YDecal;
+ sint32 _XExtend;
+
+ private:
+
+ // Display structure
+ struct SLine
+ {
+ CViewBase *TextOrTemplate;
+ std::vector Bmps;
+ SNode::TRefPtr Node;
+ uint8 Depth;
+
+ SLine()
+ {
+ TextOrTemplate = NULL;
+ }
+
+ ~SLine()
+ {
+ Bmps.clear();
+ }
+ uint getNumAdditionnalBitmap() const;
+ };
+
+ protected:
+
+ void rebuild();
+ void addTextLine (uint8 nDepth, SNode *pNode);
+ void addHierarchyBitmaps();
+
+ SNode *selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId);
+
+ SNode *_RootNode;
+ sint32 _IdGenerator;
+ bool _MustRebuild;
+ std::vector _Lines;
+ sint32 _OverLine;
+ NLMISC::CRGBA _OverColor;
+ NLMISC::CRGBA _OverColorBack;
+ SNode *_SelectedNode;
+ sint32 _SelectedLine;
+ NLMISC::CRGBA _SelectedColor;
+
+ // If a node is closed and a son of this node was selected, then this option force the ancestor being the new selection
+ bool _SelectAncestorOnClose;
+ bool _NavigateOneBranch;
+ bool _AvoidSelectNodeByIdIR;
+
+ // when an action handler is run, it can call 'cancelSelectLine' if no selection should be done for real
+ bool _CancelNextSelectLine;
+
+
+ // Bitmap For arbo
+ std::string _ArboOpenFirst;
+ std::string _ArboCloseJustOne;
+ std::string _ArboSonWithoutSon;
+ std::string _ArboSonLast;
+ std::string _ArboSon;
+ std::string _ArboLevel;
+ std::string _ArboXExtend;
+
+ // Special rectangle
+ bool _RectangleOutlineMode;
+ sint32 _RectangleX, _RectangleY;
+ sint32 _RectangleW, _RectangleH;
+ sint32 _RectangleDeltaRL;
+
+ sint32 getHrcIconXStart(sint32 depth);
+ sint32 getHrcIconXEnd(sint32 depth);
+
+ void drawSelection(sint x, sint y, sint w, NLMISC::CRGBA col);
+
+ CViewBitmap *createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture);
+ };
+
+}
+
+
+#endif // NL_GROUP_TREE_H
+
+/* End of group_tree.h */
+
+
diff --git a/code/nel/include/nel/gui/group_wheel.h b/code/nel/include/nel/gui/group_wheel.h
new file mode 100644
index 000000000..7778a2753
--- /dev/null
+++ b/code/nel/include/nel/gui/group_wheel.h
@@ -0,0 +1,50 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef RZ_GROUP_CONTAINER_H
+#define RZ_GROUP_CONTAINER_H
+
+#include "nel/gui/interface_group.h"
+
+namespace NLGUI
+{
+
+ // Special group to handle the mouse wheel message
+ class CInterfaceGroupWheel : public CInterfaceGroup
+ {
+ public:
+ /// Constructor
+ CInterfaceGroupWheel(const TCtorParam ¶m);
+
+ std::string getProperty( const std::string &name ) const;
+ void setProperty( const std::string &name, const std::string &value );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
+
+ /// Coming from CInterfaceElement
+ virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
+ virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
+ private:
+ IActionHandler *_AHWheelUp;
+ CStringShared _AHWheelUpParams;
+ IActionHandler *_AHWheelDown;
+ CStringShared _AHWheelDownParams;
+ };
+
+}
+
+#endif
diff --git a/code/nel/include/nel/gui/input_event_listener.h b/code/nel/include/nel/gui/input_event_listener.h
new file mode 100644
index 000000000..75ec9e20a
--- /dev/null
+++ b/code/nel/include/nel/gui/input_event_listener.h
@@ -0,0 +1,36 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef INPUTEVENTLISTENER_H
+#define INPUTEVENTLISTENER_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/gui/event_descriptor.h"
+
+namespace NLGUI
+{
+ /**
+ @brief Interface for accepting GUI input events.
+ */
+ class IInputEventListener
+ {
+ public:
+ virtual ~IInputEventListener(){}
+ virtual bool handleEvent( const CEventDescriptor &eventDesc ) = 0;
+ };
+}
+
+#endif
diff --git a/code/nel/include/nel/gui/input_handler.h b/code/nel/include/nel/gui/input_handler.h
new file mode 100644
index 000000000..5c87c6d1c
--- /dev/null
+++ b/code/nel/include/nel/gui/input_handler.h
@@ -0,0 +1,57 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#ifndef INPUT_HANDLER_H
+#define INPUT_HANDLER_H
+
+#include "nel/misc/events.h"
+#include "nel/gui/event_descriptor.h"
+#include "nel/gui/input_event_listener.h"
+
+namespace NLGUI{
+
+ /**
+ @brief The input event entry point of the GUI library.
+
+ Translates the NEL input events and forwards them.
+ */
+ class CInputHandler
+ {
+ public:
+ CInputHandler();
+ ~CInputHandler();
+
+ bool handleEvent( const NLMISC::CEvent &evnt );
+ bool handleSetFocusEvent( const NLMISC::CEvent &evnt );
+ bool handleKeyboardEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseMoveEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseButtonDownEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseButtonUpEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseDblClickEvent( const NLMISC::CEvent &evnt );
+ bool handleMouseWheelEvent( const NLMISC::CEvent &evnt );
+
+ void setListener( IInputEventListener* listener );
+
+ private:
+ IInputEventListener *listener;
+ };
+
+}
+
+#endif
+
diff --git a/code/nel/include/nel/gui/interface_anim.h b/code/nel/include/nel/gui/interface_anim.h
new file mode 100644
index 000000000..09f9cd9ea
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_anim.h
@@ -0,0 +1,135 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef RZ_INTERFACE_ANIM_H
+#define RZ_INTERFACE_ANIM_H
+
+#include "nel/gui/interface_property.h"
+#include "nel/gui/interface_group.h"
+#include "nel/gui/interface_link.h"
+#include "nel/3d/animation_time.h"
+#include "nel/3d/u_track.h"
+
+namespace NLGUI
+{
+
+ /**
+ * class managing an animation track
+ * \author Matthieu 'TrapII' Besson
+ * \author Nevrax France
+ * \date 2003
+ */
+ class CInterfaceTrack
+ {
+
+ public:
+
+ CInterfaceTrack();
+ virtual ~CInterfaceTrack();
+
+ virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
+
+ void update (double currentTime);
+
+ bool isDynamic () { return _Dynamic; }
+
+ void eval(); // Evaluate dynamic keys
+
+ private:
+
+ enum ETrackType
+ {
+ Track_Linear,
+ Track_TCB,
+ Track_Bezier
+ };
+
+ struct SDynKey
+ {
+ std::string Time;
+ std::string Value;
+ std::string InTan;
+ std::string OutTan;
+ std::string Step;
+ std::string Tension;
+ std::string Continuity;
+ std::string Bias;
+ std::string EaseTo;
+ std::string EaseFrom;
+ };
+
+ bool _Dynamic;
+ std::vector _DynKeys;
+
+ ETrackType _Type;
+ NL3D::UTrackKeyframer *_TrackKeyFramer;
+ std::vector _Targets;
+ };
+
+ /**
+ * class managing an animation of the interface
+ * \author Matthieu 'TrapII' Besson
+ * \author Nevrax France
+ * \date 2003
+ */
+ class CInterfaceAnim
+ {
+
+ public:
+
+ CInterfaceAnim();
+ virtual ~CInterfaceAnim();
+
+ virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
+
+ void update();
+ void start();
+ void stop();
+
+ bool isFinished() { return _Finished; }
+ bool isDisableButtons() { return _DisableButtons; }
+
+ protected:
+
+ CInterfaceGroup *_Parent;
+
+ // Parsed properties
+ double _Duration;
+ bool _DisableButtons;
+
+ std::string _AHOnFinish;
+ std::string _AHOnFinishParams;
+
+ std::string _Id;
+
+ std::vector _Tracks;
+
+ // Current anim
+ double _CurrentTime;
+ bool _Finished;
+ bool _AnimHasToBeStopped;
+
+ };
+
+}
+
+#endif // NL_INTERFACE_ANIM_H
+
+/* End of interface_anim.h */
+
+
diff --git a/code/nel/include/nel/gui/interface_common.h b/code/nel/include/nel/gui/interface_common.h
new file mode 100644
index 000000000..251b28b2d
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_common.h
@@ -0,0 +1,68 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef INTERFACE_COMMON_H
+#define INTERFACE_COMMON_H
+
+enum WindowsPriority
+{
+ WIN_PRIORITY_WORLD_SPACE = 0,
+ WIN_PRIORITY_LOWEST = 1,
+ WIN_PRIORITY_LOW = 2,
+ WIN_PRIORITY_NORMAL = 3,
+ WIN_PRIORITY_HIGH = 4,
+ WIN_PRIORITY_HIGHEST = 5,
+ WIN_PRIORITY_MAX = 8
+};
+
+enum THotSpot
+{
+ Hotspot_BL = 36, // 100100,
+ Hotspot_BM = 34, // 100010,
+ Hotspot_BR = 33, // 100001,
+ Hotspot_ML = 20, // 010100,
+ Hotspot_MM = 18, // 010010
+ Hotspot_MR = 17, // 010001
+ Hotspot_TL = 12, // 001100
+ Hotspot_TM = 10, // 001010
+ Hotspot_TR = 9, // 001001
+ Hotspot_xR = 1, // 000001
+ Hotspot_xM = 2, // 000010
+ Hotspot_xL = 4, // 000100
+ Hotspot_Bx = 32, // 100000
+ Hotspot_Mx = 16, // 010000
+ Hotspot_Tx = 8, // 001000
+ Hotspot_TTAuto = 0, // Special For Tooltip PosRef. Auto mode. see CCtrlBase and tooltip info
+};
+
+#define DECLARE_UI_CLASS(_class_) \
+ virtual std::string getClassName() {return #_class_;} \
+ static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());}
+#define REGISTER_UI_CLASS(_class_) \
+ class CRegisterUIClassHelper_##_class_ \
+ { \
+ public: \
+ CRegisterUIClassHelper_##_class_() \
+ { \
+ NLMISC::CClassRegistry::init(); \
+ NLMISC::CClassRegistry::registerClass(#_class_, _class_::creator, typeid(_class_).name()); \
+ } \
+ } RegisterUIClassHelper_##_class_;
+
+
+
+#endif
+
diff --git a/code/nel/include/nel/gui/interface_element.h b/code/nel/include/nel/gui/interface_element.h
new file mode 100644
index 000000000..210c24b2e
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_element.h
@@ -0,0 +1,637 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef NL_INTERFACE_ELEMENT_H
+#define NL_INTERFACE_ELEMENT_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/string_mapper.h"
+#include "nel/misc/smart_ptr.h"
+#include "nel/misc/vector.h"
+#include "nel/gui/interface_property.h"
+#include "nel/gui/reflect.h"
+#include "nel/gui/interface_common.h"
+
+namespace NLGUI
+{
+ class CGroupList;
+ class CInterfaceLink;
+ class CInterfaceElement;
+ class CInterfaceGroup;
+ class CViewBase;
+ class CCtrlBase;
+ class IActionHandler;
+ class CGroupParagraph;
+
+ /**
+ * A visitor to walk a tree of interface elements and apply a teartment on them.
+ *
+ * For each vsited element, visitElement() is called
+ * If the element is a control, then visitCtrl() is called, and then visitElement()
+ * If the element is a view, then visitView() is called, and then visitElement()
+ * If the element is a group, then visitGoup() is called, and then visitElement()
+ *
+ * \author Nicolas Vizerie
+ * \author Nevrax France
+ * \date 2003
+ */
+ class CInterfaceElementVisitor
+ {
+ public:
+ virtual void visit(CInterfaceElement * /* elem */) {}
+ virtual void visitGroup(CInterfaceGroup * /* group */) {}
+ virtual void visitView(CViewBase * /* view */) {}
+ virtual void visitCtrl(CCtrlBase * /* ctrl */) {}
+ };
+
+
+ /**
+ * class describing a localisable interface element, i.e. : an element with coordinates
+ * \author Nicolas Brigand
+ * \author Nevrax France
+ * \date 2002
+ */
+ class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
+ {
+ public:
+
+
+ enum EStrech
+ {
+ none=0,
+ width=1,
+ height=2
+ };
+
+ /// Constructor
+ CInterfaceElement()
+ {
+ _Parent = NULL;
+
+ _XReal = _YReal = _WReal = _HReal = 0;
+ _X = _Y = _W = _H = 0;
+ //_Snap = 1;
+
+ _PosRef = Hotspot_BL;
+ _ParentPosRef = Hotspot_BL;
+ _ParentPos = NULL;
+
+ _SizeRef = 0;
+ _SizeDivW = 10;
+ _SizeDivH = 10;
+ _ParentSize = NULL;
+
+ _Links = NULL;
+ _Active= true;
+ // default to 3 pass
+ _InvalidCoords= 3;
+
+ _ModulateGlobalColor= true;
+ _RenderLayer= 0;
+
+ _AvoidResizeParent= false;
+
+ editorSelected = false;
+
+ serializable = true;
+ }
+
+ // dtor
+ virtual ~CInterfaceElement();
+
+ /** Cloning
+ * Cloning is actually performed using a serial / unserial in a memory stream
+ * NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only
+ */
+ virtual CInterfaceElement *clone();
+
+ // help to serialize an action handler
+ static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
+
+ static std::string stripId( const std::string &fullId );
+
+ virtual std::string getProperty( const std::string &name ) const;
+
+ virtual void setProperty( const std::string &name, const std::string &value );
+
+ virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
+
+ /// Parse the element and initalize it
+ virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
+
+ /// Debug info on memory
+ virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); }
+
+ /// helper: display a parse error with the id of the lement
+ void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL);
+
+ /// Accessors : GET
+ const std::string& getId() const { return _Id; }
+ std::string getShortId() const;
+ std::string getIdByValue() const { return _Id; }
+
+ CInterfaceGroup* getParent() const { return _Parent; }
+
+ CInterfaceElement* getParentPos() const { return _ParentPos; }
+
+ CInterfaceElement* getParentSize() const { return _ParentSize; }
+
+ /// Get the master group of this element (recurs call.
+ CInterfaceElement* getMasterGroup() const;
+
+ // get a possible group container
+ CInterfaceGroup* getParentContainer();
+
+ bool getActive() const { return _Active; }
+
+ sint32 getX() const { return _X; }
+
+ sint32 getY() const { return _Y; }
+
+ sint32 getW() const { return (_Active?_W:0); }
+ sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); }
+
+ sint32 getH() const { return (_Active?_H:0); }
+ sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); }
+
+ /**
+ * Get the max width used by the window.
+ *
+ * The view must return the largest width its content can take if it will be resized at maximum.
+ * Typical use : for a CTextView multiline, it returns the size of the whole string.
+ *
+ * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
+ */
+ virtual sint32 getMaxUsedW() const { return INT_MAX; };
+
+ /**
+ * Get the min width used by the window.
+ *
+ * The view must return the smallest width its content can take if it will be resized at minimum.
+ * Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word.
+ *
+ * This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
+ */
+ virtual sint32 getMinUsedW() const { return 0; };
+
+ //bool isSnapped() const { return (_Snap>1); }
+
+ //sint32 getSnapping() const { return _Snap; }
+
+ sint32 getXReal() const { return _XReal; }
+
+ sint32 getYReal() const { return _YReal; }
+
+ sint32 getWReal() const { return (_Active?_WReal:0); }
+
+ sint32 getHReal() const { return (_Active?_HReal:0); }
+
+ THotSpot getPosRef () const { return _PosRef; }
+
+ THotSpot getParentPosRef () const { return _ParentPosRef; }
+
+ sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3
+
+ void setSizeRef(sint32 value) { _SizeRef = value; }
+
+ /// Accessors : SET
+ void setId (const std::string &newID) { _Id = newID; }
+
+ inline void setName(const std::string &name) { _Name = name; }
+ inline const std::string& getName() { return _Name; }
+
+ virtual void setIdRecurse(const std::string &newID);
+
+ void setParent (CInterfaceGroup *pIG) { _Parent = pIG; }
+
+ void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; }
+
+ void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; }
+
+ virtual void setActive (bool state);
+
+ void setX (sint32 x) { _X = x; }
+ void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); }
+
+ void setY (sint32 y) { _Y = y; }
+ void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); }
+
+ void setW (sint32 w);
+ void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); }
+
+ void setH (sint32 h);
+ void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); }
+
+ void setPosRef (THotSpot hs) { _PosRef = hs; }
+
+ void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; }
+
+ // Get the coordinate of a corner on screen
+ void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot);
+
+ /** Test if the given coordinates are inside this element
+ */
+ bool isIn(sint x, sint y) const;
+
+ /** Test if the given box intersect the element
+ */
+ bool isIn(sint x, sint y, uint width, uint height) const;
+
+ /** Test if another interface element intersect this one
+ */
+ bool isIn(const CInterfaceElement &other) const;
+
+ /**
+ * get the window containing the element
+ * \return NULL if the element is not on the window, otherwise returns a pointer to the window
+ */
+ CInterfaceGroup* getRootWindow();
+
+ /** get the element Depth, ie the number of parent he has (0 if _Parent==NULL)
+ * \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual)
+ */
+ uint getParentDepth() const;
+
+ /**
+ * true if the element and all its parents are active (recurs up to the root window)
+ */
+ bool isActiveThroughParents() const;
+
+ /**
+ * move the element (add dx and dy to its coords)
+ * \param dx : value added to _X
+ * \param dy : value added to _Y
+ */
+ virtual void move (sint32 dx, sint32 dy);
+
+ //void resizeBR (sint32 sizex, sint32 sizey);
+ //void stopResizeBR();
+ //void startResizeBR();
+
+ // Some tools
+
+ void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
+ const std::string &defVal);
+ void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
+ const std::string &defVal);
+ void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
+ const std::string &defVal);
+ void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
+ const std::string &defVal);
+
+ // Parse tools
+ static std::string HotSpotToString( THotSpot spot );
+ static std::string HotSpotCoupleToString( THotSpot parentPosRef, THotSpot posRef );
+ static THotSpot convertHotSpot (const char *ptr); //
+ static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
+ static NLMISC::CRGBA convertColor (const char *ptr);
+ static bool convertBool (const char *ptr);
+ static NLMISC::CVector convertVector (const char *ptr);
+ /** Convert a value that is in the form like width="50" or width="10%"
+ * if the value is absolute like '50' then 'pixels' is filled, else
+ * the ratio is remapped to the [0, 1] range and is copied in 'ratio'
+ */
+ static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio);
+
+ // add an interface link to that element (kept in a smart ptr)
+ void addLink(CInterfaceLink *link);
+
+ // remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr)
+ void removeLink(CInterfaceLink *link);
+
+ /** Update all links for this instance and its sons.
+ * Derivers should override this to update their sons.
+ */
+ virtual void updateAllLinks();
+
+
+ /** This allow to force opening an element. By default it just activate the element.
+ * It allow to have different behaviour on more complex containers
+ */
+ virtual void forceOpen() { setActive(true); }
+
+ virtual void enableBlink(uint /* numBlinks */ = 0) {}
+ virtual void disableBlink() {}
+ virtual bool getBlink() const { return false; }
+
+ // Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true
+ void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;}
+ bool getModulateGlobalColor() const {return _ModulateGlobalColor;}
+
+
+ void dummySet(sint32 value);
+ void dummySet(const std::string &value);
+
+ // lua methods
+ int luaUpdateCoords(CLuaState &ls);
+ int luaInvalidateCoords(CLuaState &ls);
+ int luaInvalidateContent(CLuaState &ls);
+ int luaCenter(CLuaState &ls);
+ int luaSetPosRef(CLuaState &ls);
+ int luaSetParentPos(CLuaState &ls);
+
+ // set sizeref as a string, like "wh", "wh5" ....
+ void setSizeRef(const std::string &sizeref);
+ std::string getSizeRefAsString() const;
+ std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const;
+
+ // export some properties
+ REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
+ REFLECT_BOOL ("active", getActive, setActive);
+ REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor);
+ REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords);
+ REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords);
+ REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords);
+ REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords);
+ REFLECT_SINT32 ("x_real", getXReal, dummySet);
+ REFLECT_SINT32 ("y_real", getYReal, dummySet);
+ REFLECT_SINT32 ("w_real", getWReal, dummySet);
+ REFLECT_SINT32 ("h_real", getHReal, dummySet);
+ REFLECT_STRING ("id", getIdByValue, dummySet);
+ REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef);
+ REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords);
+ REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords);
+ REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent);
+ REFLECT_LUA_METHOD("center", luaCenter);
+ REFLECT_LUA_METHOD("setPosRef", luaSetPosRef);
+ REFLECT_LUA_METHOD("setParentPos", luaSetParentPos);
+ REFLECT_EXPORT_END
+
+
+ /* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated
+ * Default 3 is needed for:
+ * 1: update _W/_H and _WReal/_HReal according to Sons
+ * 2: update XReal/YReal (eg: according to Scroll offset)
+ */
+ void invalidateCoords(uint8 numPass= 2);
+ uint8 getInvalidCoords() const {return _InvalidCoords;}
+
+ /* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable).
+ * It invalidates the content of the parent too.
+ */
+ void invalidateContent();
+
+ /* This call back is called when the content or the content of a child is been invalidated.
+ */
+ virtual void onInvalidateContent() {}
+
+ // called by interfaceManager for master window only
+ void resetInvalidCoords();
+
+ /// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord)
+ virtual void updateCoords();
+ /// Called each frame before draw to possibly invalidateCoords().
+ virtual void checkCoords();
+
+ /// Test if this element is son of the given element
+ bool isSonOf(const CInterfaceElement *other) const;
+
+ /// Called after first frame initialised
+ virtual void launch () {}
+
+ void setRenderLayer(sint8 rl) {_RenderLayer= rl;}
+ sint8 getRenderLayer() const { return _RenderLayer; }
+
+ void copyOptionFrom(const CInterfaceElement &other);
+
+ // center the element in middle of screen
+ void center();
+
+ // for debug only: draw wired quad to see where groups and hotspots are
+ enum TRenderWired
+ {
+ RenderView,
+ RenderCtrl,
+ RenderGroup
+ };
+ // if uiFilter is not empty, draw a quad only if the element id match
+ virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter);
+
+ void drawHotSpot(THotSpot hs, NLMISC::CRGBA col);
+
+ // Returns 'true' if that element can be downcasted to a view
+ virtual bool isView() const { return false; }
+
+ // Returns 'true' if that element can be downcasted to a ctrl
+ virtual bool isCtrl() const { return false; }
+
+ // Returns 'true' if that element can be downcasted to an interface group
+ virtual bool isGroup() const { return false; }
+
+
+ /** This is called before the config loading begins. This is the place to restore default state for config info.
+ */
+ virtual void onLoadConfig() {}
+ /** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig
+ * is called.
+ */
+ virtual bool wantSerialConfig() const { return false; }
+ // Serial config info about that element. This is called only if wantSerialConfig() returns true
+ virtual void serialConfig(NLMISC::IStream &f);
+
+ // visit the node of the ui tree
+ virtual void visit(CInterfaceElementVisitor *visitor);
+
+ /** When user is quitting the interface, this is called. Then the interface config is saved
+ * This is where the element get the opportunity to do some cleanup.
+ */
+ virtual void onQuit() {}
+
+ /// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add.
+ virtual void onAddToGroup() {}
+
+ /** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so
+ * this function is called on each children elements to move the XReal/Yreal only (with a delta)
+ */
+ virtual void onFrameUpdateWindowPos(sint dx, sint dy);
+
+ /// if true, InterfaceGroup child resize won't take this element into account
+ bool avoidResizeParent() const {return _AvoidResizeParent;}
+ void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;}
+
+ virtual std::string getClassName()
+ {
+ nlassert(0); // forgot to implement serial & to register the class ?
+ return "";
+ }
+
+ bool isInGroup( CInterfaceGroup *group );
+
+ static void setEditorMode( bool b ){ editorMode = b; }
+
+ void setEditorSelected( bool b ){ editorSelected = b; }
+ bool isEditorSelected() const{ return editorSelected; }
+
+ void setPosParent( const std::string &id );
+ void setSizeParent( const std::string &id );
+
+ void setSerializable( bool b ){ serializable = b; }
+ bool IsSerializable() const{ return serializable; }
+
+ protected:
+
+ bool editorSelected;
+
+ static bool editorMode;
+
+ ///the parent
+ CInterfaceGroup* _Parent;
+
+ ///the id of the element
+ std::string _Id;
+
+ std::string _Name;
+
+ ///is the element active?
+ bool _Active;
+
+ // if 0, don't need updateCoords(), else tell the number of pass needed
+ uint8 _InvalidCoords;
+
+ // Real display coords
+ sint32 _XReal, _YReal, _WReal, _HReal;
+
+ // Relative coords
+ sint32 _X;
+ sint32 _Y;
+ sint32 _W;
+ sint32 _H;
+
+ //sint32 _Snap;
+
+ // position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element
+ // will be placed on the center (middle middle) of the parent window
+ THotSpot _PosRef;
+ THotSpot _ParentPosRef;
+ NLMISC::CRefPtr _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it
+
+ sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3
+ sint32 _SizeDivW, _SizeDivH;
+ NLMISC::CRefPtr _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it
+
+ // Friend Class
+ friend class CGroupList;
+ friend class CGroupParagraph;
+
+ // True if must modulate the global color with the view
+ bool _ModulateGlobalColor;
+ // Index of layer to render it.
+ sint8 _RenderLayer;
+
+ // Used for CInterfaceGroup ChildResize feature
+ bool _AvoidResizeParent;
+
+
+ virtual void serial(NLMISC::IStream &f);
+
+ void parseSizeRef(const char *sizeRef);
+ void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH);
+
+ private:
+ //void snapSize();
+ bool serializable;
+
+ typedef NLMISC::CSmartPtr TLinkSmartPtr;
+ typedef std::vector TLinkVect;
+ TLinkVect *_Links; // links, or NULL if no link
+ };
+
+ /**
+ * class to compress string usage in the interface
+ * \author Matthieu 'Trap' Besson
+ * \author Nevrax France
+ * \date October 2003
+ */
+ class CStringShared
+ {
+
+ public:
+ CStringShared()
+ {
+ _Id = NLMISC::CStringMapper::emptyId();
+ }
+
+ const CStringShared& operator=(const std::string &str)
+ {
+ _Id = _UIStringMapper->localMap(str);
+ return *this;
+ }
+
+ const CStringShared& operator=(const CStringShared &str)
+ {
+ _Id = str._Id;
+ return *this;
+ }
+
+ const std::string &toString() const
+ {
+ return _UIStringMapper->localUnmap(_Id);
+ }
+
+ operator const std::string &() const
+ {
+ return _UIStringMapper->localUnmap(_Id);
+ }
+
+ bool empty() const
+ {
+ return _Id == NLMISC::CStringMapper::emptyId();
+ }
+
+ static CStringShared emptyString()
+ {
+ return CStringShared();
+ }
+
+ NLMISC::TStringId getStringId() const { return _Id; }
+
+ void serial(NLMISC::IStream &f)
+ {
+ std::string str;
+ if (f.isReading())
+ {
+ f.serial(str);
+ *this = str;
+ }
+ else
+ {
+ str = this->toString();
+ f.serial(str);
+ }
+ }
+
+ static void createStringMapper();
+ static void deleteStringMapper();
+
+ private:
+
+ NLMISC::TStringId _Id;
+ static NLMISC::CStringMapper *_UIStringMapper;
+ };
+
+ inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
+ inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
+
+
+}
+
+using namespace NLGUI;
+
+#endif // NL_INTERFACE_ELEMENT_H
+
+/* End of interface_element.h */
diff --git a/code/nel/include/nel/gui/interface_expr.h b/code/nel/include/nel/gui/interface_expr.h
new file mode 100644
index 000000000..e99e9668e
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_expr.h
@@ -0,0 +1,239 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef CL_INTERFACE_EXPR_H
+#define CL_INTERFACE_EXPR_H
+
+
+#include "nel/misc/ucstring.h"
+#include "nel/misc/rgba.h"
+
+namespace NLMISC{
+ class ICDBNode;
+ class CCDBNodeLeaf;
+ class CCDBNodeBranch;
+}
+
+namespace NLGUI
+{
+
+ struct CInterfaceExprUserType;
+ class CInterfaceExprNode;
+
+ /** a value that can be returned by a CInterfaceExpr instance
+ * It supports basic type;
+ * It can be extended by user defined types
+ */
+ class CInterfaceExprValue
+ {
+ public:
+ enum TType { Boolean = 0, Integer, Double, String, RGBA, UserType, NoType };
+ public:
+ // default ctor
+ CInterfaceExprValue() : _Type(NoType) {}
+ // copy ctor
+ CInterfaceExprValue(const CInterfaceExprValue &other);
+ // assignment operator
+ CInterfaceExprValue &operator = (const CInterfaceExprValue &other);
+ // dtor
+ ~CInterfaceExprValue() { clean(); }
+
+ TType getType() const { return _Type; }
+ // get. Should be used only if the type is valid
+ bool getBool() const;
+ sint64 getInteger() const;
+ double getDouble() const;
+ std::string getString() const;
+ NLMISC::CRGBA getRGBA() const;
+ const ucstring &getUCString() const;
+ CInterfaceExprUserType *getUserType() const;
+ // set
+ void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; }
+ void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
+ void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
+ void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; }
+ void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; }
+ void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
+ void setUserType(CInterfaceExprUserType *value);
+ // reset this object to initial state (no type)
+ void clean();
+ // conversions. They return true if success
+ bool toBool();
+ bool toInteger();
+ bool toDouble();
+ bool toString();
+ bool toType(TType type);
+ bool toRGBA();
+ // test if the value if a bool, double, or integer
+ bool isNumerical() const;
+ /** evaluate a from a string
+ * \param expr : where to start the evaluation
+ * \return the position following the token, or NULL if the parsing failed
+ */
+ const char *initFromString(const char *expr);
+
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ private:
+ TType _Type;
+ union
+ {
+ bool _BoolValue;
+ sint64 _IntegerValue;
+ double _DoubleValue;
+ CInterfaceExprUserType *_UserTypeValue;
+ uint32 _RGBAValue;
+ };
+ ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack..
+ private:
+ const char *evalBoolean(const char *expr);
+ const char *evalNumber(const char *expr);
+ const char *evalString(const char *expr);
+ };
+
+ /**
+ * Base class for user defined types that are use by the 'CInterfaceExprValue' class
+ * Derivers should include the 'clone' method
+ *
+ * CInterfaceExprValue instances have ownership of this object.
+ *
+ * \author Nicolas Vizerie
+ * \author Nevrax France
+ * \date 2003
+ */
+ struct CInterfaceExprUserType
+ {
+ // cloning method
+ virtual CInterfaceExprUserType *clone() const = 0;
+ // dtor
+ virtual ~CInterfaceExprUserType() {}
+ };
+
+
+ /** Evaluate expressions used in interface.
+ * It can retrieve values from the database.
+ * It can also build a list of database values it depends of.
+ *
+ * An expression can be :
+ *
+ * - a string : 'toto', 'abcd', 'a\nbcd', 'a\\t', the escape sequences are the one of C
+ * - a integer 1, 2, 3
+ * - a double 1.1, 2.2
+ * - a database entry : @ui:interface:toto:truc. If the address is a leaf, it returns the leaf value and put an observer on it. If not a leaf, it returns 0, but put an observer on it.
+ * - a database indirection @db:value[db:index] is replaced by @db:value0 if db:index == 0 for example
+ * - a user function call : fct(expr0, epxr1, ...).
+ *
+ * NB : The lua language has been integrated since then (2005), and should be more suited
+ * for most of the tasks.
+ *
+ *
+ * \author Nicolas Vizerie
+ * \author Nevrax France
+ * \date 2002
+ */
+ class CInterfaceExpr
+ {
+ public:
+ // list of argument for a function
+ typedef std::vector TArgList;
+ /** prototype of a user callable function
+ * It should return true if the result is meaningful. If not, the rest of the evaluation is stopped
+ */
+ typedef bool (* TUserFct) (TArgList &args, CInterfaceExprValue &result);
+ public:
+
+ // release memory
+ static void release();
+
+ /** This try to eval the provided expression.
+ * - This returns a result
+ * - This eventually fill a vector with a set of database entries it has dependencies on
+ * \param expr The expression to evaluate
+ * \param result The result value
+ * \param nodes If not NULL, will be filled with the database nodes this expression depends on
+ * Node will only be inserted once, so we end up with a set of node (not ordered)
+ * \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on.
+ */
+ static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector *nodes = NULL, bool noFctCalls = false);
+
+ /** Build a tree from the given expression so that it can be evaluated quickly.
+ * This is useful for a fixed expression that must be evaluated often
+ */
+ static CInterfaceExprNode *buildExprTree(const std::string &expr);
+
+
+ /** Register a function that can have several arguments
+ * // NB : this is case sensitive
+ */
+ static void registerUserFct(const char *name, TUserFct fct);
+ // Simple evaluations
+ static bool evalAsInt(const std::string &expr, sint64 &dest);
+ static bool evalAsDouble(const std::string &expr, double &dest);
+ static bool evalAsBool(const std::string &expr, bool &dest);
+ static bool evalAsString(const std::string &expr, std::string &dest);
+ /////////////////////////////////////////////////////////////////////////////////////////////
+ private:
+ // map of user functions
+ typedef std::map TUserFctMap;
+ private:
+ static TUserFctMap *_UserFct;
+ private:
+ /** eval the value of a single expression
+ * \return position to the next valid character
+ */
+ static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector *nodes, bool noFctCalls);
+ static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector *nodes, bool noFctCalls);
+ static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector *nodes);
+ public:
+ static const char *unpackDBentry(const char *expr, std::vector *nodes, std::string &dest, bool *hasIndirections = NULL);
+
+ /** Build tree of a single expression
+ * \return position to the next valid character
+ */
+ private:
+ static const char *buildExprTree(const char *expr, CInterfaceExprNode *&result);
+ static const char *buildFctNode(const char *expr, CInterfaceExprNode *&result);
+ static const char *buildDBEntryNode(const char *expr,CInterfaceExprNode *&result);
+ };
+
+
+ // helper macro to register user functions at startup
+ #define REGISTER_INTERFACE_USER_FCT(name, fct) \
+ const struct __InterUserFctRegister__##fct\
+ {\
+ __InterUserFctRegister__##fct() { CInterfaceExpr::registerUserFct(name, fct); }\
+ } __InterUserFctRegisterInstance__##fct;
+
+
+ // helper macro to declare a user function
+ // the code must follow
+ // arguments are available in 'args', result should be put in 'result'
+ #define DECLARE_INTERFACE_USER_FCT(name) \
+ bool name(CInterfaceExpr::TArgList &args, CInterfaceExprValue &result)
+
+
+ // helper macro to declare a C constant mirroring
+ #define DECLARE_INTERFACE_CONSTANT(_name, _cconst) \
+ static DECLARE_INTERFACE_USER_FCT(_name) \
+ { \
+ result.setInteger(_cconst); \
+ return true; \
+ } \
+ REGISTER_INTERFACE_USER_FCT(#_name, _name)
+
+}
+
+#endif
+
diff --git a/code/nel/include/nel/gui/interface_expr_node.h b/code/nel/include/nel/gui/interface_expr_node.h
new file mode 100644
index 000000000..47cb5a664
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_expr_node.h
@@ -0,0 +1,118 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef CL_INTERFACE_EXPR_NODE_H
+#define CL_INTERFACE_EXPR_NODE_H
+
+#include "interface_expr.h"
+
+namespace NLGUI
+{
+
+ /** Base node of an interface expression parse tree
+ * \author Nicolas Vizerie
+ * \author Nevrax France
+ * \date 2003
+ */
+ class CInterfaceExprNode
+ {
+ public:
+ virtual ~CInterfaceExprNode() {}
+ // eval result of expression, and eventually get the nodes the epression depends on
+ virtual void eval(CInterfaceExprValue &result) = 0;
+ // The same, but get db nodes the expression depends on (appended to vector)
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes) = 0;
+ // Get dependencies of the node (appended to vector)
+ virtual void getDepends(std::vector &nodes) = 0;
+ };
+
+
+ // *******************************************************************************************************
+ /** A constant value already parsed by interface (in a interface expr parse tree)
+ */
+ class CInterfaceExprNodeValue : public CInterfaceExprNode
+ {
+ public:
+ CInterfaceExprValue Value;
+ public:
+ virtual void eval(CInterfaceExprValue &result);
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes);
+ virtual void getDepends(std::vector &nodes);
+ };
+
+ // *******************************************************************************************************
+ /** A fct call (in a interface expr parse tree)
+ */
+ class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode
+ {
+ public:
+ CInterfaceExpr::TUserFct Func;
+ // list of parameters
+ std::vector Params;
+ public:
+ virtual void eval(CInterfaceExprValue &result);
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes);
+ virtual void getDepends(std::vector &nodes);
+ virtual ~CInterfaceExprNodeValueFnCall();
+ };
+
+ // *******************************************************************************************************
+ /** A db leaf read (in a interface expr parse tree)
+ */
+ class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode
+ {
+ public:
+ class NLMISC::CCDBNodeLeaf *Leaf;
+ public:
+ virtual void eval(CInterfaceExprValue &result);
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes);
+ virtual void getDepends(std::vector &nodes);
+ };
+
+ // *******************************************************************************************************
+ /** A db branch read (in a interface expr parse tree)
+ */
+ class CInterfaceExprNodeDBBranch : public CInterfaceExprNode
+ {
+ public:
+ class NLMISC::CCDBNodeBranch *Branch;
+ public:
+ virtual void eval(CInterfaceExprValue &result);
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes);
+ virtual void getDepends(std::vector &nodes);
+ };
+
+ // *******************************************************************************************************
+ /** A dependant db read (in a interface expr parse tree)
+ * This is rarely used so no real optim there..
+ */
+ class CInterfaceExprNodeDependantDBRead : public CInterfaceExprNode
+ {
+ public:
+ std::string Expr;
+ public:
+ virtual void eval(CInterfaceExprValue &result);
+ virtual void evalWithDepends(CInterfaceExprValue &result, std::vector &nodes);
+ virtual void getDepends(std::vector &nodes);
+ };
+
+
+}
+
+
+#endif
diff --git a/code/nel/include/nel/gui/interface_group.h b/code/nel/include/nel/gui/interface_group.h
new file mode 100644
index 000000000..61cdc2c9b
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_group.h
@@ -0,0 +1,422 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef NL_INTERFACE_GROUP_H
+#define NL_INTERFACE_GROUP_H
+
+#include "nel/gui/ctrl_base.h"
+#include "nel/gui/action_handler.h"
+
+namespace NLGUI
+{
+
+ class CInterfaceGroup : public CCtrlBase
+ {
+ public:
+ DECLARE_UI_CLASS(CInterfaceGroup)
+
+ /// Constructor
+ CInterfaceGroup(const TCtorParam ¶m);
+
+ /// Destructor
+ virtual ~CInterfaceGroup();
+
+ virtual void setIdRecurse(const std::string &id);
+
+ /// Coming from CInterfaceElement
+ virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
+
+ std::string getProperty( const std::string &name ) const;
+ void setProperty( const std::string &name, const std::string &value );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
+ xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const;
+ xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
+ xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
+ xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
+ virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
+ bool serializeLinks( xmlNodePtr parentNode ) const;
+
+ virtual uint32 getMemory ();
+
+ virtual CInterfaceElement* getElement (const std::string &id);
+ CInterfaceElement* findFromShortId(const std::string &id);
+
+ /// Dynamic creation
+ virtual void addView (CViewBase *child , sint eltOrder = -1);
+ virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
+ virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);
+
+ CViewBase* getView (const std::string &id);
+ CCtrlBase* getCtrl (const std::string &id);
+ CInterfaceGroup* getGroup(const std::string &id) const;
+
+ // Delete know type by ptr (return true if found and removed)
+ virtual bool delView (CViewBase *child, bool dontDelete = false);
+ virtual bool delCtrl (CCtrlBase *child, bool dontDelete = false);
+ virtual bool delGroup (CInterfaceGroup * child, bool dontDelete = false);
+
+ // Delete know type by name (return true if found and removed)
+ virtual bool delView (const std::string &id, bool dontDelete = false);
+ virtual bool delCtrl (const std::string &id, bool dontDelete = false);
+ virtual bool delGroup (const std::string &id, bool dontDelete = false);
+
+ // Delete unknow type by name or ptr. NB: additionaly, if it's a group, unmakeWindow() is called as necessary
+ bool delElement (const std::string &id, bool noWarning=false);
+ bool delElement (CInterfaceElement *pIE, bool noWarning=false);
+
+ uint getNumGroup() const { return (uint)_ChildrenGroups.size(); }
+ CInterfaceGroup *getGroup(uint index) const;
+
+ sint32 getMaxUsedW() const;
+ sint32 getMinUsedW() const;
+
+ /// Coming from CCtrlBase
+ virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
+
+ void executeControl (const std::string &sControlName);
+
+ const std::vector & getGroups () { return _ChildrenGroups; }
+ const std::vector & getControls() { return _Controls; }
+ const std::vector & getViews() { return _Views; }
+
+ // test is a group is a direct child of this interface group
+ bool isChildGroup(const CInterfaceGroup *group) const;
+
+ virtual bool isWindowUnder (sint32 x, sint32 y); // Virtual for menu that is not square
+ CInterfaceGroup *getGroupUnder (sint32 x, sint32 y);
+ virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group
+ virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL);
+ virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vIGL);
+
+ void absoluteToRelative (sint32 &x, sint32 &y);
+
+ /// Coming from CViewBase
+ virtual void draw ();
+ // Draw with no clip (if clip is done by parent)
+ virtual void drawNoClip();
+
+ /// Tool function to draw a single Element that should exist in the group (clipped by the group)
+ void drawElement (CViewBase *el);
+
+
+ /**
+ * update the elements coords
+ */
+ virtual void checkCoords();
+ virtual void updateCoords();
+
+ /// remove all views
+ virtual void clearViews();
+
+ /// remove all controls
+ virtual void clearControls();
+
+ /// remove all groups
+ virtual void clearGroups();
+
+ void setParentSizeMax(CInterfaceElement *pIE) { _ParentSizeMax = pIE; }
+ void setMaxW (sint32 maxw) { _MaxW = maxw; }
+ void setMaxH (sint32 maxh) { _MaxH = maxh; }
+ void setOfsX (sint32 x) { _OffsetX = x; }
+ void setOfsY (sint32 y) { _OffsetY = y; }
+ bool moveSBTrackY (CInterfaceGroup *target, sint32 dy);
+ bool moveSBTargetY (CInterfaceGroup *target, sint32 dy);
+ void setResizeFromChildW(bool resize) { _ResizeFromChildW = resize; }
+ void setResizeFromChildH(bool resize) { _ResizeFromChildH = resize; }
+
+ // Valid only for windows InterfaceGroup.
+ // escapable
+ void setEscapable(bool b) { _Escapable= b; }
+ bool getEscapable() const { return _Escapable; }
+ void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); }
+ const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); }
+ void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; }
+ const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; }
+ // enterable
+ void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); }
+ const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); }
+ void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; }
+ const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; }
+ uint8 getPriority() const { return _Priority; }
+ void setPriority(uint8 nprio);
+
+
+ sint32 getMaxW () const { return _MaxW; }
+ sint32 getMaxH () const { return _MaxH; }
+ sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; }
+ sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; }
+ sint32 getOfsX () const { return _OffsetX; }
+ sint32 getOfsY () const { return _OffsetY; }
+ bool getResizeFromChildW() const { return _ResizeFromChildW; }
+ bool getResizeFromChildH() const { return _ResizeFromChildH; }
+ sint32 getResizeFromChildWMargin() const { return _ResizeFromChildWMargin; }
+ sint32 getResizeFromChildHMargin() const { return _ResizeFromChildHMargin; }
+ void setResizeFromChildWMargin(sint32 margin) { _ResizeFromChildWMargin = margin; }
+ void setResizeFromChildHMargin(sint32 margin) { _ResizeFromChildHMargin = margin; }
+ bool getOverlappable() const { return _Overlappable; }
+
+ virtual void setActive (bool state);
+
+ // eval dimension of children bbox
+ void evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const;
+
+ virtual void launch ();
+
+
+ // right & left clicks handler
+ void setLeftClickHandler(const std::string &handler);
+ void setRightClickHandler(const std::string &handler);
+ void setLeftClickHandlerParams(const std::string ¶ms) { _AHOnLeftClickParams = params; }
+ void setRightClickHandlerParams(const std::string ¶ms) { _AHOnRightClickParams = params; }
+ void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); }
+ void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; }
+ void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); }
+ void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; }
+
+ const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); }
+ const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; }
+ const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); }
+ const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; }
+ const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); }
+ const std::string &getOnActiveParams() const { return _AHOnActiveParams; }
+ const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); }
+ const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; }
+
+ // find a sub view/ctrl/group in this group from its id
+ int luaFind(CLuaState &ls);
+ int luaGetEnclosingContainer(CLuaState &ls);
+ int luaDeleteLUAEnvTable(CLuaState &ls);
+ int luaAddGroup(CLuaState &ls);
+ int luaDelGroup(CLuaState &ls);
+ int luaGetNumGroups(CLuaState &ls);
+ int luaGetGroup(CLuaState &ls);
+
+ void setMaxSizeRef(const std::string &maxSizeRef);
+ std::string getMaxSizeRefAsString() const;
+
+
+ REFLECT_EXPORT_START(CInterfaceGroup, CCtrlBase)
+ REFLECT_LUA_METHOD("find", luaFind);
+ REFLECT_LUA_METHOD("deleteLUAEnvTable", luaDeleteLUAEnvTable);
+ REFLECT_LUA_METHOD("getEnclosingContainer", luaGetEnclosingContainer);
+ REFLECT_LUA_METHOD("addGroup", luaAddGroup);
+ REFLECT_LUA_METHOD("delGroup", luaDelGroup);
+ REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups);
+ REFLECT_LUA_METHOD("getGroup", luaGetGroup);
+ REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler);
+ REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler);
+ REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams);
+ REFLECT_STRING ("right_click_params", getRightClickHandlerParams, setRightClickHandlerParams);
+ REFLECT_STRING ("on_active", getOnActiveHandler, setOnActiveHandler);
+ REFLECT_STRING ("on_active_params", getOnActiveParams, setOnActiveParams);
+ REFLECT_STRING ("on_deactive", getOnDeactiveHandler, setOnDeactiveHandler);
+ REFLECT_STRING ("on_deactive_params", getOnDeactiveParams, setOnDeactiveParams);
+ REFLECT_STRING ("on_enter", getAHOnEnter, setAHOnEnter);
+ REFLECT_STRING ("on_enter_params", getAHOnEnterParams, setAHOnEnterParams);
+ REFLECT_STRING ("on_escape", getAHOnEscape, setAHOnEscape);
+ REFLECT_STRING ("on_escape_params", getAHOnEscapeParams, setAHOnEscapeParams);
+ REFLECT_SINT32 ("ofsx", getOfsX, setOfsX);
+ REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
+ REFLECT_BOOL("child_resize_w", getResizeFromChildW, setResizeFromChildW);
+ REFLECT_SINT32("child_resize_wmargin", getResizeFromChildWMargin, setResizeFromChildWMargin);
+ REFLECT_BOOL("child_resize_h", getResizeFromChildH, setResizeFromChildH);
+ REFLECT_SINT32("child_resize_hmargin", getResizeFromChildHMargin, setResizeFromChildHMargin);
+ REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
+ REFLECT_STRING("max_sizeref", getMaxSizeRefAsString, setMaxSizeRef);
+ REFLECT_SINT32 ("max_w", getMaxW, setMaxW);
+ REFLECT_SINT32 ("max_h", getMaxH, setMaxH);
+ REFLECT_SINT32 ("max_w_real", getMaxWReal, dummySet);
+ REFLECT_SINT32 ("max_h_real", getMaxHReal, dummySet);
+ REFLECT_EXPORT_END
+
+
+
+ // From CCtrlBase
+ virtual void updateAllLinks();
+
+ /// return true for some containers. false by default
+ virtual bool isMovable() const {return false;}
+
+ virtual sint32 getAlpha() const;
+ virtual void setAlpha (sint32 a);
+
+ /// Eval current clip coords. This is not incremental as with makeNewClip, and thus more slow. This also doesn't change the current clip window.
+ void getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const;
+
+ // quick way to know if the group is a CGroupContainer
+ bool isGroupContainer() const { return _IsGroupContainer; }
+ bool isGroupScrollText() const{ return _IsGroupScrollText; }
+ bool isGroupInScene() const{ return _IsGroupInScene; }
+ bool isGroupList() const{ return _IsGroupList; }
+
+ CInterfaceGroup* getEnclosingContainer();
+
+ sint getInsertionOrder(CViewBase *vb) const;
+
+ // for debug only
+ void dumpGroups();
+ void dumpEltsOrder();
+
+ virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter);
+
+ virtual bool isGroup() const { return true; }
+
+ // clear all edit box in the ui
+ virtual void clearAllEditBox();
+ // restore all backuped positions for containers
+ virtual void restoreAllContainersBackupPosition();
+
+ virtual void dumpSize(uint depth = 0) const;
+
+ // From CInterfaceElement
+ virtual void visit(CInterfaceElementVisitor *visitor);
+
+ /// Visits only this group's sub-groups and then the group itself
+ virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor );
+
+ // Check cursor
+ void setUseCursor(bool use);
+ bool getUseCursor() const { return _UseCursor; }
+
+
+ // From CInterfaceElement
+ virtual void onFrameUpdateWindowPos(sint dx, sint dy);
+ // true for CGroupInScene for instance
+ bool isNeedFrameUpdatePos() const {return _NeedFrameUpdatePos;}
+
+
+ /// \name LUA specific
+ // @{
+ // Create a LUA Environement if don't exist, then push it on the LUA stack
+ void pushLUAEnvTable();
+ // Free the LUA Env Table
+ void deleteLUAEnvTable(bool recurse = false);
+ // Set the LUA script to execute at checkCoords time (empty to reset)
+ void setLuaScriptOnDraw(const std::string &script);
+ //
+ void executeLuaScriptOnDraw();
+ // Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key
+ void addLuaScriptOnDBChange(const std::string &dbList, const std::string &script);
+ // Remove the LUA script to execute when a list of DB change
+ void removeLuaScriptOnDBChange(const std::string &dbList);
+ // @}
+
+ virtual CInterfaceElement *clone();
+ virtual void serial(NLMISC::IStream &f);
+
+ // Return the current Depth, with no ZBias applied.
+ float getDepthForZSort() const { return _DepthForZSort; }
+
+ protected:
+
+ void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH);
+ void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH);
+
+ // Compute clip contribution for current window, and a previous clipping rectangle. This doesn't change the clip window in the driver.
+ void computeCurrentClipContribution(sint32 prevX, sint32 prevY, sint32 prevW, sint32 prevH,
+ sint32 &newX, sint32 &newY, sint32 &newW, sint32 &newH) const;
+
+ void delEltOrder (CViewBase *pElt);
+
+ // update coords one time
+ void doUpdateCoords();
+
+ // notify children controls & groups that 'active' has been called on one of their parent
+ void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc);
+
+ protected:
+
+ /// children interface elements
+ std::vector _ChildrenGroups;
+ std::vector _Controls;
+ std::vector _Views;
+
+ std::vector _EltOrder;
+
+ /// Scroll properties
+ NLMISC::CRefPtr _ParentSizeMax; // RefPtr in case of group destroyed in a parent group with posref on it
+ sint32 _MaxW, _MaxH;
+ sint32 _MaxWReal, _MaxHReal;
+ sint32 _OffsetX, _OffsetY;
+
+ uint8 _Priority;
+
+ // Misc prop
+ bool _Overlappable : 1;
+ bool _ResizeFromChildW : 1;
+ bool _ResizeFromChildH : 1;
+ bool _Escapable : 1;
+ bool _UseCursor : 1;
+ bool _IsGroupContainer : 1; // faster than a virual call
+ bool _IsGroupScrollText : 1;
+ bool _IsGroupInScene : 1;
+ bool _IsGroupList : 1;
+ bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene
+ sint32 _ResizeFromChildWMargin;
+ sint32 _ResizeFromChildHMargin;
+ sint32 _GroupSizeRef;
+
+ // Projected Depth with no ZBias applied
+ float _DepthForZSort;
+
+ // handler for activation
+ IActionHandler *_AHOnActive;
+ CStringShared _AHOnActiveParams;
+ IActionHandler *_AHOnDeactive;
+ CStringShared _AHOnDeactiveParams;
+
+ // right & left clicks
+ IActionHandler *_AHOnLeftClick;
+ CStringShared _AHOnLeftClickParams;
+ IActionHandler *_AHOnRightClick;
+ CStringShared _AHOnRightClickParams;
+
+ // enter params.
+ IActionHandler *_AHOnEnter;
+ CStringShared _AHOnEnterParams;
+
+ // escape AH
+ IActionHandler *_AHOnEscape;
+ CStringShared _AHOnEscapeParams;
+
+ private:
+
+ void addToEltOrder(CViewBase *view, sint order);
+
+ /// \name LUA specific
+ // @{
+ // Lua Env Table created. Table is in the LUA_REGISTRYINDEX, with key as this CInterfaceGroup* userdata
+ bool _LUAEnvTableCreated;
+ // The LUA script to be executed on Draw (checkCoords)
+ CStringShared _LUAOnDraw;
+ // The InterfaceLink created specialy for Lua Script to be executed at some DB change
+ typedef std::map > TLUAOnDbChange;
+ TLUAOnDbChange _LUAOnDbChange;
+ void removeAllLUAOnDbChange();
+ protected:
+ void parseMaxSizeRef(const char *ptr);
+ // @}
+ };
+
+}
+
+#endif // NL_INTERFACE_GROUP_H
+
+/* End of interface_group.h */
+
+
diff --git a/code/nel/include/nel/gui/interface_link.h b/code/nel/include/nel/gui/interface_link.h
new file mode 100644
index 000000000..ffa6ac0c7
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_link.h
@@ -0,0 +1,186 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef CL_INTERFACE_LINK_H
+#define CL_INTERFACE_LINK_H
+
+#include "nel/misc/cdb_branch.h"
+#include "nel/misc/cdb_branch_observing_handler.h"
+
+namespace NLGUI
+{
+ class CReflectedProperty;
+ class CInterfaceExprValue;
+ class CInterfaceExprNode;
+ class CInterfaceElement;
+ class CInterfaceGroup;
+
+ /** A link in an interface.
+ * A link is an object that can read one or several values from the database, that can evaluate an expression
+ * on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to
+ * an interface property that has been exported by an interface element (the export system uses reflect.h).
+ * The first time it is created, it places observers on the database entries that are needed by the expression, so each
+ * time a database value changes, the link is marked as 'triggered'
+ * When updateTrigeredLinks() is called, all links are effectively updated.
+ *
+ * Example of use : connecting a change in the db tree to the 'active' state of a window
+ *
+ * NB : an additionnal action handler can be provided
+ * NB : The links are owned by the interface element (using a smart pointer)
+ * NB : Several targets may be used.
+ *
+ * \author Nicolas Vizerie
+ * \author Nevrax France
+ * \date 2002
+ */
+ class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
+ {
+ public:
+ #ifdef NL_DEBUG
+ // for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager
+ // and was created by calling CInterfaceManager::addLink, contains the name of this link
+ std::string LinkName;
+ #endif
+ public:
+ struct CTargetInfo
+ {
+ CInterfaceElement *Elem;
+ std::string PropertyName;
+ /** Affect a value to this target.
+ * \return true if the affectation could be made
+ */
+ bool affect(const CInterfaceExprValue &value);
+ };
+
+
+ /// Updates triggered interface links when triggered by the observed branch
+ class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver
+ {
+ public:
+ CInterfaceLinkUpdater();
+ ~CInterfaceLinkUpdater();
+ void onObserverCallFlush();
+ };
+
+ public:
+ CInterfaceLink();
+ ~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement
+ /** Make a link between the given interface element properties and a value that depends on database entries.
+ * The link is automatically added in the link list of the targets element (it calls CInterfaceElement::addLink), so when all target elements are removed, the link is.
+ * If there are no target element, the link is permanent (removed at exit)
+ * NB : The target is not updated during this call.
+ */
+ bool init(const std::vector &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent);
+ // force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved.
+ static void updateAllLinks();
+ // force all trigered links to be updated
+ static void updateTrigeredLinks();
+ // remove from the _LinksWithNoTarget list if the link has no target
+ void uninit();
+
+ // Force an update of the target of this link
+ void update();
+ /** Remove a target element. It won't be updated anymore by that link
+ * NB : this don't call removeLink() on the target
+ */
+ void removeTarget(CInterfaceElement *elem);
+ // Get the number of targets of this link
+ uint getNumTargets() const { return (uint)_Targets.size(); }
+ // Get the i-th target
+ CInterfaceElement *getTarget(uint index) const { return _Targets[index]._InterfaceElement; }
+
+ static void removeAllLinks();
+
+ static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val);
+
+ static bool isUpdatingAllLinks() { return _UpdateAllLinks; }
+
+ /** From a target name of a link, retrieve the target element and its target target property
+ * \return true if the target is valid
+ */
+ static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm);
+
+ /** From several target names of a link (seprated by ','), retrieve the target elements and their target properties
+ * \return true if all targets are valid
+ */
+ static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector &targetsVect);
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////
+ private:
+ friend struct CRemoveTargetPred;
+ // a target property
+ struct CTarget
+ {
+ CInterfaceElement *_InterfaceElement;
+ const CReflectedProperty *_Property;
+ };
+ private:
+ typedef std::list TLinkList;
+ typedef NLMISC::CSmartPtr TLinkSmartPtr;
+ typedef std::vector TLinkVect;
+ typedef std::vector TNodeVect;
+ private:
+ std::vector _Targets;
+ TNodeVect _ObservedNodes;
+ std::string _Expr;
+ CInterfaceExprNode *_ParseTree;
+ std::string _ActionHandler;
+ std::string _AHParams;
+ std::string _AHCond;
+ CInterfaceGroup *_AHParent;
+ static TLinkList _LinkList;
+ TLinkList::iterator _ListEntry;
+ bool _On;
+ static TLinkVect _LinksWithNoTarget; // there should be an owner for links with no targets
+ static bool _UpdateAllLinks;
+ ///\ name triggered link mgt
+ //@{
+ // next/previous link that was trigered. NULL means end or start of list
+ // each ptr is duplicated because with manage 2 lists : one list in which links are added, and one list in which we update links.
+ // This way one link can trigger another with no prb
+ CInterfaceLink *_PrevTriggeredLink[2];
+ CInterfaceLink *_NextTriggeredLink[2];
+ bool _Triggered[2];
+ // global lists
+ static CInterfaceLink *_FirstTriggeredLink[2];
+ static CInterfaceLink *_LastTriggeredLink[2];
+ // iterators in current list being updated : they're global so that deleting a CInterfaceLink instance prevent them from becoming dangling pointers
+ static CInterfaceLink *_CurrUpdatedLink;
+ static CInterfaceLink *_NextUpdatedLink;
+ // Index of the list in which triggered link must be inserted
+ static uint _CurrentTriggeredLinkList;
+
+ //
+ void linkInTriggerList(uint list);
+ void unlinkFromTriggerList(uint list);
+ //@}
+
+ private:
+ /** Inherited from ICDBNode::IPropertyObserver
+ * This doesn't update the node directly, but mark it as 'triggered'
+ * The node is really updated during the call to 'updateTrigeredLinks()'
+ */
+ virtual void update(NLMISC::ICDBNode *node);
+ void createObservers(const TNodeVect &nodes);
+ void removeObservers(const TNodeVect &nodes);
+ // debug : check that there are as many targets as reference to a link
+ void checkNbRefs();
+ };
+
+}
+
+#endif
diff --git a/code/nel/include/nel/gui/interface_options.h b/code/nel/include/nel/gui/interface_options.h
new file mode 100644
index 000000000..f52b9479a
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_options.h
@@ -0,0 +1,225 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef RZ_INTERFACE_LAYER_H
+#define RZ_INTERFACE_LAYER_H
+
+#include "nel/misc/debug.h"
+#include "nel/misc/smart_ptr.h"
+#include "nel/misc/rgba.h"
+#include "libxml/globals.h"
+#include "nel/misc/xml_auto_ptr.h"
+
+namespace NL3D
+{
+ class UAnimationSet;
+}
+
+namespace NLGUI
+{
+
+ // ***************************************************************************
+ class CInterfaceOptionValue
+ {
+ public:
+ CInterfaceOptionValue()
+ {
+ _Color= NLMISC::CRGBA::White;
+ _Int= 0;
+ _Float= 0;
+ _Boolean= false;
+ }
+
+ const std::string &getValStr () const {return _Str;}
+ sint32 getValSInt32() const {return _Int;}
+ float getValFloat () const {return _Float;}
+ NLMISC::CRGBA getValColor () const {return _Color;}
+ bool getValBool () const {return _Boolean;}
+
+ void init(const std::string &str);
+
+ // returned when InterfaceOptions param not found
+ static const CInterfaceOptionValue NullValue;
+
+ private:
+
+ std::string _Str;
+ NLMISC::CRGBA _Color;
+ sint32 _Int;
+ float _Float;
+ bool _Boolean;
+ };
+
+
+ // ***************************************************************************
+ class CInterfaceOptions : public NLMISC::CRefCount
+ {
+
+ public:
+
+ // for factory construction
+ struct TCtorParam
+ {
+ };
+
+ CInterfaceOptions( const TCtorParam &/* param */ );
+ virtual ~CInterfaceOptions();
+
+ virtual bool parse (xmlNodePtr cur);
+ virtual xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
+
+ // return NullValue if param not found
+ const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
+
+ // shortcuts to getValue(paramName).getValXXX()
+ const std::string &getValStr (const std::string &sParamName) const;
+ sint32 getValSInt32 (const std::string &sParamName) const;
+ float getValFloat (const std::string &sParamName) const;
+ NLMISC::CRGBA getValColor (const std::string &sParamName) const;
+ bool getValBool (const std::string &sParamName) const;
+
+ // copy basic map only from other CInterfaceOptions (non virtual method)
+ void copyBasicMap(const CInterfaceOptions &other);
+
+ protected:
+
+ std::map _ParamValue;
+
+ };
+
+
+
+ // ***************************************************************************
+ class COptionsLayer : public CInterfaceOptions
+ {
+
+ public:
+ COptionsLayer( const TCtorParam &/* param */ );
+ ~COptionsLayer();
+ xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
+ virtual bool parse (xmlNodePtr cur);
+
+ // Container optimizer
+
+ sint32 Tile_Blank;
+ sint32 Tile_M_Header, Tile_M_Scrollbar;
+ sint32 Tile_T, Tile_B, Tile_L, Tile_R;
+ sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open;
+
+ sint32 Scrollbar_Offset_X;
+ sint32 Scrollbar_W;
+ sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar;
+ sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar;
+ sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar;
+
+ sint32 TxId_L_Header, W_L_Header, H_L_Header;
+ sint32 TxId_M_Header, W_M_Header, H_M_Header;
+ sint32 TxId_R_Header, W_R_Header, H_R_Header;
+
+ sint32 TxId_TL, W_TL, H_TL;
+ sint32 TxId_T, W_T, H_T;
+ sint32 TxId_TR, W_TR, H_TR;
+ sint32 TxId_L, W_L, H_L;
+ sint32 TxId_R, W_R, H_R;
+ sint32 TxId_Blank, W_Blank, H_Blank;
+ sint32 TxId_BL, W_BL, H_BL;
+ sint32 TxId_B, W_B, H_B;
+ sint32 TxId_BR, W_BR, H_BR;
+
+ sint32 TxId_BL_Open, W_BL_Open, H_BL_Open;
+ sint32 TxId_B_Open, W_B_Open, H_B_Open;
+ sint32 TxId_BR_Open, W_BR_Open, H_BR_Open;
+ sint32 TxId_EL_Open, W_EL_Open, H_EL_Open;
+ sint32 TxId_EM_Open, W_EM_Open, H_EM_Open;
+ sint32 TxId_ER_Open, W_ER_Open, H_ER_Open;
+ sint32 TxId_E_Open, W_E_Open, H_E_Open;
+ sint32 TxId_M_Open, W_M_Open, H_M_Open;
+
+ sint32 TxId_TL_HighLight;
+ sint32 TxId_T_HighLight;
+ sint32 TxId_TR_HighLight;
+ sint32 TxId_L_HighLight;
+ sint32 TxId_R_HighLight;
+ sint32 TxId_BL_HighLight;
+ sint32 TxId_B_HighLight;
+ sint32 TxId_BR_HighLight;
+
+ sint32 HeaderH;
+ };
+
+ // ***************************************************************************
+ class COptionsContainerInsertion : public CInterfaceOptions
+ {
+ public:
+ COptionsContainerInsertion( const TCtorParam &/* param */ );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
+ virtual bool parse (xmlNodePtr cur);
+
+ sint32 TxId_R_Arrow;
+ sint32 TxId_L_Arrow;
+ sint32 TxId_T_Arrow;
+ sint32 TxId_B_Arrow;
+ sint32 TxId_InsertionBar;
+ };
+
+ // ***************************************************************************
+ class COptionsContainerMove : public CInterfaceOptions
+ {
+ public:
+ COptionsContainerMove( const TCtorParam &/* param */ );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
+ virtual bool parse (xmlNodePtr cur);
+
+ sint32 TrackW;
+ sint32 TrackH;
+ sint32 TrackY;
+ sint32 TrackYWithTopResizer;
+ sint32 TrackHWithTopResizer;
+ sint32 ResizerSize;
+ };
+
+
+
+ // ***************************************************************************
+ /**
+ * read a list of with no name. id auto incremented
+ */
+ class COptionsList : public CInterfaceOptions
+ {
+ public:
+ COptionsList( const TCtorParam &/* param */ );
+ xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
+ virtual bool parse (xmlNodePtr cur);
+
+ uint getNumParams() const {return _NumParams;}
+
+ // get a value by its index (from 0 to numParams)
+ const CInterfaceOptionValue &getValue(uint paramId) const;
+
+ private:
+ uint _NumParams;
+ };
+
+
+}
+
+#endif // NL_INTERFACE_LAYER_H
+
+/* End of interface_layer.h */
+
+
diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h
new file mode 100644
index 000000000..eb602b8ca
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_parser.h
@@ -0,0 +1,389 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef RZ_INTERFACE_PARSER_H
+#define RZ_INTERFACE_PARSER_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/3d/u_texture.h"
+#include "nel/gui/ctrl_sheet_selection.h"
+#include "nel/gui/interface_link.h"
+#include "nel/misc/smart_ptr.h"
+#include "nel/gui/lua_helper.h"
+#include "nel/gui/proc.h"
+#include "nel/gui/widget_manager.h"
+#include "nel/gui/link_data.h"
+
+namespace NLGUI
+{
+ class CInterfaceElement;
+ class CInterfaceGroup;
+ class CInterfaceOptions;
+ class CInterfaceLink;
+ class CCtrlBase;
+ class CGroupList;
+ class CGroupContainer;
+ class CInterfaceAnim;
+ class CViewPointer;
+
+ // ***************************************************************************
+ /**
+ * class managing the interface parsing
+ * \author Matthieu 'TrapII' Besson
+ * \author Nevrax France
+ * \date 2002
+ */
+
+ class CInterfaceParser : public IParser
+ {
+
+ public:
+
+ /// Interface for parser modules
+ /// Such modules can be plugged into CInterfaceParser, and
+ /// the modules then can parse GUI XMLs for widget classes that are not
+ /// generic enough to be in the GUI library.
+ class IParserModule
+ {
+ public:
+
+ /// Various parsing stages
+ enum ParsingStage
+ {
+ None = 0, /// module cannot parse in any stage.
+ Unresolved = 1, /// module can parse in the first stage when styles, templates, etc have not been resolved yet
+ Resolved = 2, /// module can parse after resolving styles and templates
+ GroupChildren = 4 /// module can parse when parsing the group children
+ };
+
+ IParserModule(){
+ parser = NULL;
+ parsingStage = None;
+ }
+ virtual ~IParserModule(){}
+
+ bool canParseInStage( ParsingStage stage )
+ {
+ if( ( parsingStage & static_cast< uint >( stage ) ) != 0 )
+ return true;
+ else
+ return false;
+ }
+
+ virtual bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ) = 0;
+ void setParser( CInterfaceParser *p ){ parser = p; }
+
+ protected:
+ CInterfaceParser *parser;
+ uint parsingStage;
+ };
+
+ /// Interface for event handlers which can be called when setting up the options.
+ class ISetupOptionCallbackClass
+ {
+ public:
+ virtual void setupOptions() = 0;
+ };
+
+
+ struct VariableData
+ {
+ std::string entry;
+ std::string type;
+ std::string value;
+ uint32 size;
+
+ VariableData()
+ {
+ size = 0;
+ }
+ };
+
+ CInterfaceParser();
+ virtual ~CInterfaceParser();
+
+ public:
+
+ /**
+ * Parsing methods
+ */
+
+ /** Load a set of xml files
+ * \param isFilename true if xmlFileNames array contains the names of the xml file, false, if each
+ * array is a script itself
+ */
+ bool parseInterface (const std::vector &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false);
+
+ bool parseXMLDocument (xmlNodePtr root, bool reload);
+ bool parseTemplateNode (xmlNodePtr node,xmlNodePtr instance,xmlNodePtr templ);
+ bool parseInstance(xmlNodePtr cur);
+ bool parseVector (xmlNodePtr cur);
+ bool parseVariable (xmlNodePtr cur, CInterfaceGroup * parentGroup);
+ bool parseOptions (xmlNodePtr cur, CInterfaceGroup * parentGroup);
+ bool parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
+ bool parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
+ bool parseControl (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
+ bool parseLink (xmlNodePtr cur, CInterfaceGroup * parentGroup);
+ bool parseView (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
+ bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
+ bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
+ bool parseDefine(xmlNodePtr cur);
+ bool parseProcedure(xmlNodePtr cur, bool reload);
+ bool parseSheetSelection(xmlNodePtr cur);
+ bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup);
+ bool parseStyle(xmlNodePtr cur);
+ bool parseLUAScript (xmlNodePtr cur);
+ bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
+ bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
+ void savePointerSettings( xmlNodePtr node );
+ void saveKeySettings( xmlNodePtr node );
+
+ void addModule( std::string name, IParserModule *module );
+ IParserModule* getModuleFor( std::string name ) const;
+ void removeAllModules();
+
+ // Called by each parse in parseXMLDocument
+ bool solveDefine(xmlNodePtr cur);
+ bool solveStyle(xmlNodePtr cur);
+
+ // Solve All define in a string. return false if some define not founs (defError contains this define)
+ bool solveDefine(const std::string &propVal, std::string &newPropVal, std::string &defError);
+
+ // Called after template & options parsing
+ void setupOptions();
+
+ /**
+ * Initializer
+ */
+
+ bool initCoordsAndLuaScript ();
+
+ /// Association builders : associate an element of the interface with the string ID of
+ /// another element used as reference for position values
+ void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID);
+ std::string getParentPosAssociation( CInterfaceElement *element ) const;
+ void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID);
+ std::string getParentSizeAssociation( CInterfaceElement *element ) const;
+ void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID);
+ std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const;
+
+ /// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed)
+ void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript);
+ std::string getLuaClassAssociation( CInterfaceGroup *group ) const;
+
+ /**
+ * Accessors
+ */
+ // access to control sheet selection
+ CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; }
+
+ /// \name Parameter variable
+ // @{
+ const std::string& getDefine(const std::string &id) const;
+ bool isDefineExist(const std::string &id) const;
+ void setDefine(const std::string &id, const std::string &value);
+ // @}
+
+ /// \name Dynamic links mgt
+ // @{
+ /** Associate the given dynamic link with an ID
+ * \return true if succesful
+ */
+ bool addLink(CInterfaceLink *link, const std::string &id);
+ /** remove the given link from its ID
+ * \return true if succesful
+ */
+ bool removeLink(const std::string &id);
+ // @}
+
+ /** create a template from an instance consisting of a single group
+ * \param templateName name of the template in the xml
+ * \param templateParams array containing each template parameter and its name
+ * \param number of template parameters in the array
+ */
+ CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks = true);
+ CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true)
+ {
+ if (templateParams.size() > 0)
+ return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
+ else
+ return createGroupInstance(templateName, parentID, NULL, 0, updateLinks);
+ }
+
+ /** create a template from an instance consisting of a single control or group
+ * \param templateName name of the template in the xml
+ * \param templateParams array containing each template parameter and its name
+ * \param number of template parameters in the array
+ */
+ CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair *templateParams, uint numParams, bool updateLinks /* = true */);
+ CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector > &templateParams, bool updateLinks = true)
+ {
+ if (templateParams.size() > 0)
+ return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
+ else
+ return createUIElement(templateName, parentID, NULL, 0, updateLinks);
+ }
+
+ static void freeXMLNodeAndSibblings(xmlNodePtr node);
+
+ // search a "tree" node in the hierarchy that match node. may return root! NULL if not found
+ static xmlNodePtr searchTreeNodeInHierarchy(xmlNodePtr root, const char *node);
+
+ /// \name Clearing mgt
+ // @{
+ void removeAllLinks();
+ void removeAllProcedures();
+ void removeAllDefines();
+ void removeAllTemplates();
+ void removeAllAnims();
+ void removeAll();
+ // @}
+
+ protected:
+ /// Procedure list
+ typedef TProcedureMap::iterator ItProcedureMap;
+ typedef TProcedureMap::const_iterator CstItProcedureMap;
+ TProcedureMap _ProcedureMap;
+
+ public:
+
+
+ // get info on procedure. return 0 if procedure not found
+ uint getProcedureNumActions( const std::string &procName ) const;
+
+ // return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
+ bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const;
+
+ void setCacheUIParsing( bool b ){ cacheUIParsing = b; }
+
+ CInterfaceAnim* getAnim( const std::string &name ) const;
+
+ CProcedure* getProc( const std::string &name );
+
+ const TProcedureMap& getProcMap() const{ return _ProcedureMap; }
+
+ protected:
+
+ /**
+ * Temporary data for init
+ */
+
+ /// vector storing parsed templates during init. At the end of init, only used template are kept
+ std::vector _Templates;
+
+
+ // map linking an element to its parent position used during init only
+ std::map _ParentPositionsMap;
+ std::map _ParentSizesMap;
+ std::map _ParentSizesMaxMap;
+
+ // map linking a group to its lua script. used during init only
+ std::map _LuaClassAssociation;
+
+ /**
+ * Data of initialized interface
+ */
+
+ /// Define Variable list
+ typedef std::map TVarMap;
+ typedef TVarMap::iterator ItVarMap;
+ typedef TVarMap::const_iterator CstItVarMap;
+ TVarMap _DefineMap;
+
+ bool validDefineChar(char c) const;
+
+ class CStyleProperty
+ {
+ public:
+ std::string Name;
+ std::string Value;
+ };
+ class CStyle
+ {
+ public:
+ std::vector Properties;
+ };
+
+
+ // mgt of sheet selections (inventory, buy, sell..)
+ CCtrlSheetSelection _CtrlSheetSelection;
+
+ // Map of dynamic links
+ typedef std::map > TLinkMap;
+ TLinkMap _LinkMap;
+
+ // Map of anims
+ typedef std::map TAnimMap;
+ TAnimMap _AnimMap;
+
+ // Map of styles.
+ typedef std::map TStyleMap;
+ TStyleMap _StyleMap;
+
+ protected:
+ std::map< std::string, IParserModule* > moduleMap;
+
+ // List of script loaded (for reloadLua command)
+ std::set _LuaFileScripts;
+
+ bool cacheUIParsing;
+ bool luaInitialized;
+ ISetupOptionCallbackClass *setupCallback;
+
+ uint32 linkId;
+ std::map< uint32, SLinkData > links;
+
+ bool editorMode;
+ std::map< std::string, VariableData > variableCache;
+ std::map< std::string, std::string > pointerSettings;
+ std::map< std::string, std::map< std::string, std::string > > keySettings;
+
+ public:
+ void initLUA();
+ void uninitLUA();
+ bool isLuaInitialized() const{ return luaInitialized; }
+
+ /// Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed)
+ bool loadLUA( const std::string &luaFile, std::string &error );
+
+ /// Reload all LUA scripts inserted through
+ void reloadAllLuaFileScripts();
+
+ void setSetupOptionsCallback( ISetupOptionCallbackClass *cb ){ setupCallback = cb; }
+
+ bool hasProc( const std::string &name ) const;
+ bool addProc( const std::string &name );
+ bool removeProc( const std::string &name );
+
+ const std::map< uint32, SLinkData >& getLinkMap() const{ return links; }
+ uint32 addLinkData( SLinkData &linkData );
+ void removeLinkData( uint32 id );
+ bool getLinkData( uint32 id, SLinkData &linkData );
+ void updateLinkData( uint32 id, const SLinkData &linkData );
+
+ void setEditorMode( bool b ){ editorMode = b; }
+
+ bool serializeVariables( xmlNodePtr parentNode ) const;
+ bool serializeProcs( xmlNodePtr parentNode ) const;
+ bool serializePointerSettings( xmlNodePtr parentNode ) const;
+ bool serializeKeySettings( xmlNodePtr parentNode ) const;
+ };
+
+}
+
+#endif // RZ_INTERFACE_PARSER_H
diff --git a/code/nel/include/nel/gui/interface_property.h b/code/nel/include/nel/gui/interface_property.h
new file mode 100644
index 000000000..63a62ef0e
--- /dev/null
+++ b/code/nel/include/nel/gui/interface_property.h
@@ -0,0 +1,106 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+#ifndef NL_INTERFACE_PROPERTY_H
+#define NL_INTERFACE_PROPERTY_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/rgba.h"
+#include "nel/misc/cdb.h"
+#include "nel/misc/cdb_leaf.h"
+#include "nel/misc/cdb_branch.h"
+
+namespace NLGUI
+{
+
+ /**
+ * interface property
+ * class used to managed all the interface member values
+ * As the database contains only sint64, several methods are needed to do the conversion
+ * \author Nicolas Brigand
+ * \author Nevrax France
+ * \date 2002
+ */
+ class CInterfaceProperty
+ {
+ public:
+ //enum defining a hot spot
+
+ /// Constructor
+ CInterfaceProperty()
+ {
+ _VolatileValue = NULL;
+ }
+
+ NLMISC::CCDBNodeLeaf* getNodePtr() const
+ {
+ return _VolatileValue;
+ }
+
+ void setNodePtr(NLMISC::CCDBNodeLeaf *ptr)
+ {
+ _VolatileValue = ptr;
+ }
+
+
+ bool link (const char *DBProp);
+ bool link( NLMISC::CCDBNodeLeaf *dbNode );
+ bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
+
+ /// float operations
+ void setDouble (double value) {setSInt64((sint64&) value);}
+ double getDouble () const {sint64 i = getSInt64(); return (double &) i; }
+ void readDouble (const char* value, const std::string& id);
+
+ /// sint32 operations
+ void setSInt32 (sint32 value) {_VolatileValue->setValue32 (value);}
+ sint32 getSInt32 () const {return _VolatileValue->getValue32();}
+ void readSInt32(const char* value, const std::string& id);
+
+ /// sint64 operations
+ void setSInt64 (sint64 value) {_VolatileValue->setValue64(value);}
+ sint64 getSInt64 () const {return _VolatileValue->getValue64();}
+ void readSInt64(const char* value, const std::string& id);
+
+ /// CRGBA operations
+ void setRGBA (const NLMISC::CRGBA & value);
+ NLMISC::CRGBA getRGBA () const;
+ void readRGBA (const char* value, const std::string& id);
+
+ /// HotSpot operations
+
+ void readHotSpot (const char* value, const std::string& id);
+
+ /// bool operations
+ void setBool (bool value);
+ bool getBool () const;
+ void readBool (const char* value, const std::string& id);
+
+ // Swap the content of this 2 property (no-op if one is NULL)
+ void swap32(CInterfaceProperty &o);
+
+ private:
+ /// volatile value of the property (pointer to a leaf of the database)
+ NLMISC::CCDBNodeLeaf* _VolatileValue;
+ };
+
+}
+
+#endif // NL_INTERFACE_PROPERTY_H
+
+/* End of interface_property.h */
diff --git a/code/nel/include/nel/gui/libwww.h b/code/nel/include/nel/gui/libwww.h
new file mode 100644
index 000000000..3983e5777
--- /dev/null
+++ b/code/nel/include/nel/gui/libwww.h
@@ -0,0 +1,283 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+
+
+#ifndef CL_LIB_WWW_H
+#define CL_LIB_WWW_H
+
+extern "C"
+{
+#include "libwww/WWWInit.h"
+}
+
+namespace NLGUI
+{
+ class CCtrlBaseButton;
+ class CCtrlScroll;
+ class CGroupList;
+
+ // ***************************************************************************
+
+ // Init the libwww
+ void initLibWWW();
+
+ // Get an url and setup a local domain
+ const std::string &setCurrentDomain(const std::string &url);
+
+ extern std::string CurrentCookie;
+
+ // ***************************************************************************
+
+ // Some DTD table
+
+ // Here, modify the DTD table to change the HTML parser (add new tags for exemples)
+
+ #undef HTML_ATTR
+ #define HTML_ATTR(t,a) MY_HTML_##t##_##a
+
+ enum
+ {
+ HTML_ATTR(A,ACCESSKEY) = 0,
+ HTML_ATTR(A,CHARSET),
+ HTML_ATTR(A,CLASS),
+ HTML_ATTR(A,COORDS),
+ HTML_ATTR(A,DIR),
+ HTML_ATTR(A,HREF),
+ HTML_ATTR(A,HREFLANG),
+ HTML_ATTR(A,ID),
+ HTML_ATTR(A,NAME),
+ HTML_ATTR(A,REL),
+ HTML_ATTR(A,REV),
+ HTML_ATTR(A,SHAPE),
+ HTML_ATTR(A,STYLE),
+ HTML_ATTR(A,TABINDEX),
+ HTML_ATTR(A,TARGET),
+ HTML_ATTR(A,TYPE),
+ HTML_ATTR(A,TITLE),
+ HTML_ATTR(A,Z_ACTION_CATEGORY),
+ HTML_ATTR(A,Z_ACTION_PARAMS),
+ HTML_ATTR(A,Z_ACTION_SHORTCUT),
+ };
+
+ enum
+ {
+ HTML_ATTR(TABLE,ALIGN) = 0,
+ HTML_ATTR(TABLE,BGCOLOR),
+ HTML_ATTR(TABLE,BORDER),
+ HTML_ATTR(TABLE,CELLPADDING),
+ HTML_ATTR(TABLE,CELLSPACING),
+ HTML_ATTR(TABLE,CLASS),
+ HTML_ATTR(TABLE,DIR),
+ HTML_ATTR(TABLE,FRAME),
+ HTML_ATTR(TABLE,ID),
+ HTML_ATTR(TABLE,L_MARGIN),
+ HTML_ATTR(TABLE,LANG),
+ HTML_ATTR(TABLE,NOWRAP),
+ HTML_ATTR(TABLE,RULES),
+ HTML_ATTR(TABLE,SUMMARY),
+ HTML_ATTR(TABLE,STYLE),
+ HTML_ATTR(TABLE,TITLE),
+ HTML_ATTR(TABLE,VALIGN),
+ HTML_ATTR(TABLE,WIDTH)
+ };
+
+ enum
+ {
+ HTML_ATTR(TR,ALIGN) = 0,
+ HTML_ATTR(TR,BGCOLOR),
+ HTML_ATTR(TR,L_MARGIN),
+ HTML_ATTR(TR,NOWRAP),
+ HTML_ATTR(TR,VALIGN),
+ };
+
+ enum
+ {
+ HTML_ATTR(TD,ABBR) = 0,
+ HTML_ATTR(TD,ALIGN),
+ HTML_ATTR(TD,AXIS),
+ HTML_ATTR(TD,BGCOLOR),
+ HTML_ATTR(TD,CHAR),
+ HTML_ATTR(TD,CHAROFF),
+ HTML_ATTR(TD,CLASS),
+ HTML_ATTR(TD,COLSPAN),
+ HTML_ATTR(TD,DIR),
+ HTML_ATTR(TD,ID),
+ HTML_ATTR(TD,HEADERS),
+ HTML_ATTR(TD,HEIGHT),
+ HTML_ATTR(TD,L_MARGIN),
+ HTML_ATTR(TD,LANG),
+ HTML_ATTR(TD,NOWRAP),
+ HTML_ATTR(TD,ROWSPAN),
+ HTML_ATTR(TD,SCOPE),
+ HTML_ATTR(TD,STYLE),
+ HTML_ATTR(TD,TITLE),
+ HTML_ATTR(TD,VALIGN),
+ HTML_ATTR(TD,WIDTH),
+ };
+
+ enum
+ {
+ HTML_ATTR(IMG,ALIGN) = 0,
+ HTML_ATTR(IMG,ALT),
+ HTML_ATTR(IMG,BORDER),
+ HTML_ATTR(IMG,CLASS),
+ HTML_ATTR(IMG,DIR),
+ HTML_ATTR(IMG,GLOBAL_COLOR),
+ HTML_ATTR(IMG,HEIGHT),
+ HTML_ATTR(IMG,HSPACE),
+ HTML_ATTR(IMG,ID),
+ HTML_ATTR(IMG,ISMAP),
+ HTML_ATTR(IMG,LANG),
+ HTML_ATTR(IMG,LONGDESC),
+ HTML_ATTR(IMG,SRC),
+ HTML_ATTR(IMG,STYLE),
+ HTML_ATTR(IMG,TITLE),
+ HTML_ATTR(IMG,USEMAP),
+ HTML_ATTR(IMG,VSPACE),
+ HTML_ATTR(IMG,WIDTH),
+ };
+
+ enum
+ {
+ HTML_ATTR(INPUT,ACCEPT) = 0,
+ HTML_ATTR(INPUT,ACCESSKEY),
+ HTML_ATTR(INPUT,ALIGN),
+ HTML_ATTR(INPUT,ALT),
+ HTML_ATTR(INPUT,CHECKED),
+ HTML_ATTR(INPUT,CLASS),
+ HTML_ATTR(INPUT,DIR),
+ HTML_ATTR(INPUT,DISABLED),
+ HTML_ATTR(INPUT,GLOBAL_COLOR),
+ HTML_ATTR(INPUT,ID),
+ HTML_ATTR(INPUT,LANG),
+ HTML_ATTR(INPUT,MAXLENGTH),
+ HTML_ATTR(INPUT,NAME),
+ HTML_ATTR(INPUT,READONLY),
+ HTML_ATTR(INPUT,SIZE),
+ HTML_ATTR(INPUT,SRC),
+ HTML_ATTR(INPUT,STYLE),
+ HTML_ATTR(INPUT,TABINDEX),
+ HTML_ATTR(INPUT,TITLE),
+ HTML_ATTR(INPUT,TYPE),
+ HTML_ATTR(INPUT,USEMAP),
+ HTML_ATTR(INPUT,VALUE),
+ HTML_ATTR(INPUT,Z_BTN_TMPL),
+ HTML_ATTR(INPUT,Z_INPUT_TMPL),
+ HTML_ATTR(INPUT,Z_INPUT_WIDTH),
+ };
+
+ enum
+ {
+ HTML_ATTR(TEXTAREA,CLASS) = 0,
+ HTML_ATTR(TEXTAREA,COLS),
+ HTML_ATTR(TEXTAREA,DIR),
+ HTML_ATTR(TEXTAREA,DISABLED),
+ HTML_ATTR(TEXTAREA,ID),
+ HTML_ATTR(TEXTAREA,LANG),
+ HTML_ATTR(TEXTAREA,NAME),
+ HTML_ATTR(TEXTAREA,READONLY),
+ HTML_ATTR(TEXTAREA,ROWS),
+ HTML_ATTR(TEXTAREA,STYLE),
+ HTML_ATTR(TEXTAREA,TABINDEX),
+ HTML_ATTR(TEXTAREA,TITLE),
+ HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
+ };
+
+ enum
+ {
+ HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
+ HTML_ATTR(P,QUICK_HELP_EVENTS),
+ HTML_ATTR(P,QUICK_HELP_LINK),
+ HTML_ATTR(P,NAME),
+ };
+
+ enum
+ {
+ HTML_ATTR(DIV,CLASS) = 0,
+ HTML_ATTR(DIV,ID),
+ HTML_ATTR(DIV,NAME),
+ HTML_ATTR(DIV,STYLE),
+ };
+
+
+ #undef HTML_ATTR
+
+ // ***************************************************************************
+
+ // A smart ptr for LibWWW strings
+ class C3WSmartPtr
+ {
+ public:
+ C3WSmartPtr ()
+ {
+ _Ptr = NULL;
+ }
+ C3WSmartPtr (const char *ptr)
+ {
+ _Ptr = ptr;
+ }
+ ~C3WSmartPtr ()
+ {
+ clear();
+ }
+ void operator=(const char *str)
+ {
+ clear ();
+ _Ptr = str;
+ }
+ operator const char *() const
+ {
+ return _Ptr;
+ }
+ void clear()
+ {
+ if (_Ptr)
+ {
+ void *ptr = (void*)_Ptr;
+ HT_FREE(ptr);
+ }
+ _Ptr = NULL;
+ }
+ private:
+ const char *_Ptr;
+ };
+
+ // ***************************************************************************
+
+ // Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
+ bool getPercentage (sint32 &width, float &percent, const char *str);
+
+ // ***************************************************************************
+
+ // Parse a HTML color
+ NLMISC::CRGBA getColor (const char *color);
+
+ // ***************************************************************************
+
+ void _VerifyLibWWW(const char *function, bool ok, const char *file, int line);
+ #define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
+
+ // ***************************************************************************
+
+ // Standard request terminator
+ int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
+
+ // ***************************************************************************
+}
+
+#endif
diff --git a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h b/code/nel/include/nel/gui/libwww_nel_stream.h
similarity index 93%
rename from code/ryzom/client/src/interface_v3/libwww_nel_stream.h
rename to code/nel/include/nel/gui/libwww_nel_stream.h
index 9f801e36c..4e1bd4e01 100644
--- a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h
+++ b/code/nel/include/nel/gui/libwww_nel_stream.h
@@ -20,11 +20,9 @@
#define LIBWWW_NEL_STREAM_H
-#include "HTProt.h"
+#include "libwww/HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile;
-
-extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
- void * param, int mode);
+extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H
diff --git a/code/ryzom/client/src/interface_v3/dbview_quantity.h b/code/nel/include/nel/gui/link_data.h
similarity index 53%
rename from code/ryzom/client/src/interface_v3/dbview_quantity.h
rename to code/nel/include/nel/gui/link_data.h
index b76296c61..3e7a5ae00 100644
--- a/code/ryzom/client/src/interface_v3/dbview_quantity.h
+++ b/code/nel/include/nel/gui/link_data.h
@@ -14,45 +14,29 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-
-
-#ifndef NL_DBVIEW_QUANTITY_H
-#define NL_DBVIEW_QUANTITY_H
+#ifndef LINKDATA_H
+#define LINKDATA_H
#include "nel/misc/types_nl.h"
+#include
-#include "view_text.h"
-
-
-// ***************************************************************************
-/**
- * Display a text in the form of val / max or "empty"
- * \author Lionel Berenguier
- * \author Nevrax France
- * \date 2002
- */
-class CDBViewQuantity : public CViewText
+namespace NLGUI
{
-public:
- /// Constructor
- CDBViewQuantity(const TCtorParam ¶m);
-
- virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
- virtual void draw ();
+ struct SLinkData
+ {
+ public:
+ uint32 id;
+ std::string parent;
+ std::string expr;
+ std::string target;
+ std::string action;
+ std::string params;
+ std::string cond;
+ };
-protected:
- CInterfaceProperty _Number;
- CInterfaceProperty _NumberMax;
- sint32 _Cache;
- sint32 _CacheMax;
- ucstring _EmptyText;
-
- void buildTextFromCache();
-};
+}
-#endif // NL_DBVIEW_QUANTITY_H
-
-/* End of dbview_quantity.h */
+#endif
diff --git a/code/nel/include/nel/gui/lua_helper.h b/code/nel/include/nel/gui/lua_helper.h
new file mode 100644
index 000000000..10b78daa8
--- /dev/null
+++ b/code/nel/include/nel/gui/lua_helper.h
@@ -0,0 +1,388 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef RZ_LUA_HELPER_H
+#define RZ_LUA_HELPER_H
+
+
+#include "nel/misc/types_nl.h"
+#include "nel/misc/smart_ptr.h"
+
+extern "C"
+{
+ #include "lua_loadlib.h"
+}
+
+namespace NLGUI
+{
+
+ class CLuaState;
+
+ namespace LuaHelperStuff
+ {
+ void formatLuaStackContext( std::string &stackContext );
+ std::string formatLuaErrorSysInfo( const std::string &error );
+ std::string formatLuaErrorNlWarn( const std::string &error );
+ }
+
+
+ // ***************************************************************************
+ /** Helper class to see if a stack is restored at its initial size (or with n return results).
+ * Check that the stack size remains unchanged when the object goes out of scope
+ */
+ class CLuaStackChecker
+ {
+ public:
+ CLuaStackChecker(CLuaState *state, int numWantedResults = 0);
+ ~CLuaStackChecker();
+ /** Increment exception context counter
+ * When an exception is thrown, lua stack checker do any assert bu will
+ * rather restore the lua stack at its original size, and will
+ * let the exception a chance to propagate
+ */
+ static void incrementExceptionContextCounter();
+ static void decrementExceptionContextCounter();
+
+ private:
+ CLuaState *_State;
+ int _FinalWantedSize;
+ static uint _ExceptionContextCounter;
+
+ };
+
+ // **************************************************************************
+ /** Helper class to restore the lua stack to the desired size when this object goes out of scope
+ */
+ class CLuaStackRestorer
+ {
+ public:
+ CLuaStackRestorer(CLuaState *state, int finalSize);
+ ~CLuaStackRestorer();
+ private:
+ int _FinalSize;
+ CLuaState *_State;
+ };
+
+ ////////////////
+ // EXCEPTIONS //
+ ////////////////
+
+ class ELuaError : public NLMISC::Exception
+ {
+ public:
+ ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); }
+ virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); }
+ ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); }
+ // what(), plus append the Reason
+ virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());}
+ };
+
+ // A parse error occured
+ class ELuaParseError : public ELuaError
+ {
+ public:
+ ELuaParseError() {}
+ ELuaParseError(const std::string &reason) : ELuaError(reason) {}
+ virtual ~ELuaParseError() throw() { }
+ // what(), plus append the Reason
+ virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());}
+ };
+
+ /** Exception thrown when something went wrong inside a wrapped function called by lua
+ */
+ class ELuaWrappedFunctionException : public ELuaError
+ {
+ public:
+ ELuaWrappedFunctionException(CLuaState *luaState);
+ ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason);
+ ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...);
+ virtual ~ELuaWrappedFunctionException() throw() { }
+ virtual const char *what() const throw() {return _Reason.c_str();}
+ protected:
+ void init(CLuaState *ls, const std::string &reason);
+ protected:
+ std::string _Reason;
+ };
+
+ // A execution error occured
+ class ELuaExecuteError : public ELuaError
+ {
+ public:
+ ELuaExecuteError() {}
+ ELuaExecuteError(const std::string &reason) : ELuaError(reason) {}
+ virtual ~ELuaExecuteError() throw() { }
+ // what(), plus append the Reason
+ virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());}
+ };
+
+ // A bad cast occured when using lua_checkcast
+ class ELuaBadCast : public ELuaError
+ {
+ public:
+ ELuaBadCast() {}
+ ELuaBadCast(const std::string &reason) : ELuaError(reason) {}
+ // what(), plus append the Reason
+ virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaBadCast: %s", what());}
+ };
+
+ // Error when trying to indexate an object that is not a table
+ class ELuaNotATable : public ELuaError
+ {
+ public:
+ ELuaNotATable() {}
+ ELuaNotATable(const std::string &reason) : ELuaError(reason) {}
+ // what(), plus append the Reason
+ virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaNotATable: %s", what());}
+ };
+
+
+ // ***************************************************************************
+ // a function to be used with a CLuaState instance
+ typedef int (* TLuaWrappedFunction) (CLuaState &ls);
+
+
+ // ***************************************************************************
+ /** C++ version of a lua state
+ */
+ class CLuaState : public NLMISC::CRefCount
+ {
+ public:
+ typedef NLMISC::CRefPtr TRefPtr;
+
+ // Create a new environement
+ CLuaState( bool debugger = false );
+ ~CLuaState();
+
+
+ /// \name Registering
+ // @{
+ // register a wrapped function
+ void registerFunc(const char *name, TLuaWrappedFunction function);
+ // @}
+
+
+ /// \name Script execution
+ // @{
+
+ /** Parse a script and push as a function in top of the LUA stack
+ * \throw ELuaParseError
+ * \param dbgSrc is a string for debug. Should be a filename (preceded with '@'), or a short script.
+ */
+ void loadScript(const std::string &code, const std::string &dbgSrc);
+
+ /** Execute a script from a string, possibly throwing an exception if there's a parse error
+ * \throw ELuaParseError, ELuaExecuteError
+ */
+ void executeScript(const std::string &code, int numRet = 0);
+
+ /** Execute a script from a string. If an errors occurs it is printed in the log
+ * \return true if script execution was successful
+ */
+ bool executeScriptNoThrow(const std::string &code, int numRet = 0);
+
+ /** Load a Script from a File (maybe in a BNP), and execute it
+ * \return false if file not found
+ * \throw ELuaParseError, ELuaExecuteError
+ */
+ bool executeFile(const std::string &pathName);
+
+ /** execute a very Small Script (a function call for instance)
+ * It is different from doString() in such there is a cache (where the key is the script itself)
+ * so that the second time this script is executed, there is no parsing
+ * Note: I experienced optim with about 10 times faster than a executeScript() on a simple "a= a+1;" script
+ * \throw ELuaParseError, ELuaExecuteError
+ */
+ void executeSmallScript(const std::string &script);
+
+ // @}
+
+
+ /// \name Stack Manipulation
+ // @{
+ // stack manipulation (indices start at 1)
+ void setTop(int index); // set new size of stack
+ void clear() { setTop(0); }
+ int getTop();
+ bool empty() { return getTop() == 0; }
+ void pushValue(int index); // copie nth element of stack to the top of the stack
+ void remove(int index); // remove nth element of stack
+ void insert(int index); // insert last element of the stack before the given position
+ void replace(int index); // replace nth element of the stack with the top of the stack
+ void pop(int numElem = 1); // remove n elements from the top of the stack
+ // test the type of an element in the stack
+ // return one of the following values :
+ // LUA_TNIL
+ // LUA_TNUMBER
+ // LUA_TBOOLEAN
+ // LUA_TSTRING
+ // LUA_TTABLE
+ // LUA_TFUNCTION
+ // LUA_TUSERDATA
+ // LUA_TTHREAD
+ // LUA_TLIGHTUSERDATA
+ int type(int index = -1);
+ const char *getTypename(int type);
+ bool isNil(int index = -1);
+ bool isBoolean(int index = -1);
+ bool isNumber(int index = -1);
+ bool isString(int index = -1);
+ bool isTable(int index = -1);
+ bool isFunction(int index = -1);
+ bool isCFunction(int index = -1);
+ bool isUserData(int index = -1);
+ bool isLightUserData(int index = -1);
+ // converting then getting a value from the stack
+ bool toBoolean(int index = -1);
+ lua_Number toNumber(int index = -1);
+ const char *toString(int index = -1);
+ void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
+ size_t strlen(int index = -1);
+ lua_CFunction toCFunction(int index = -1);
+ void *toUserData(int index = -1);
+ const void *toPointer(int index = -1);
+ /** Helper functions : get value of the wanted type in the top table after conversion
+ * A default value is used if the stack entry is NULL.
+ * If conversion fails then an exception is thrown (with optional msg)
+ */
+ bool getTableBooleanValue(const char *name, bool defaultValue= false);
+ double getTableNumberValue(const char *name, double defaultValue= 0);
+ const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
+ // pushing value onto the stack
+ void push(bool value);
+ void push(lua_Number value);
+ void push(const char *str);
+ void push(const char *str, int length);
+ void push(const std::string &str);
+ void pushNil();
+ void push(lua_CFunction f);
+ void push(TLuaWrappedFunction function);
+ void pushLightUserData(void *); // push a light user data (use newUserData to push a full userdata)
+ // metatables
+ bool getMetaTable(int index = -1);
+ bool setMetaTable(int index = -1); // set the metatable at top of stack to the object at 'index' (usually -2), then pop the metatable
+ // even if asignment failed
+ // comparison
+ bool equal(int index1, int index2);
+ bool rawEqual(int index1, int index2);
+ bool lessThan(int index1, int index2);
+ // concatenation of the n element at the top of the stack (using lua semantic)
+ void concat(int numElem);
+ // tables
+ void newTable(); // create a new table at top of the stack
+ void getTable(int index); // get value from a table at index 'index' (key is at top)
+ void rawGet(int index);
+ void setTable(int index); // set (key, value) from top of the stack into the given table
+ // both key and value are poped
+ void rawSet(int index);
+ bool next(int index); // table traversal
+ // UserData
+ void *newUserData(uint size);
+ // seting value by int index in a table
+ void rawSetI(int index, int n);
+ void rawGetI(int index, int n);
+ /** Calling functions (it's up to the caller to clear the results)
+ * The function should have been pushed on the stack
+ */
+ void call(int nargs, int nresults);
+ int pcall(int nargs, int nresults, int errfunc = 0);
+ /** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex'
+ * the behaviour is the same than with call of pcall.
+ */
+ int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex = LUA_GLOBALSINDEX, int errfunc = 0);
+
+ // push a C closure (pop n element from the stack and associate with the function)
+ void pushCClosure(lua_CFunction function, int n);
+ // @}
+
+
+ /// \name Misc
+ // @{
+ /** Retrieve pointer to a CLuaState environment from its lua_State pointer, or NULL
+ * if there no such environment
+ */
+ static CLuaState *fromStatePointer(lua_State *state);
+ // Get state pointer. The state should not be closed (this object has ownership)
+ lua_State *getStatePointer() const {return _State;}
+ // check that an index is valid when accessing the stack
+ // an assertion is raised if the index is not valid
+ void checkIndex(int index);
+
+ // registering C function to use with a lua state pointer
+ void registerFunc(const char *name, lua_CFunction function);
+
+ // Garbage collector
+ int getGCCount(); // get memory in use in KB
+ int getGCThreshold(); // get max memory in KB
+ void setGCThreshold(int kb); // set max memory in KB (no-op with ref-counted version)
+
+ // handle garbage collector for ref-counted version of lua (no-op with standard version, in which case gc handling is automatic)
+ void handleGC();
+
+ /** For Debug: get the Stack context of execution (filename / line)
+ * \param stackLevel: get the context of execution of the given stackLevel.
+ * 0 for the current function
+ * 1 for the function that called 0
+ * 2 ....
+ * NB: if called from a C function called from LUA, remember that stackLevel 0 is the current function.
+ * Hence if you want to know what LUA context called you, pass stackLevel=1!
+ * \param ret string cleared if any error, else filled with formated FileName / LineNumber
+ */
+ void getStackContext(std::string &ret, uint stackLevel);
+ // @}
+
+ // for debug : dump the current content of the stack (no recursion)
+ void dumpStack();
+ static void dumpStack(lua_State *ls);
+ void getStackAsString(std::string &dest);
+
+
+ private:
+ lua_State *_State;
+
+ #ifdef LUA_NEVRAX_VERSION
+ int _GCThreshold; // if refcounted gc is used, then garbage collector is handled manually
+ #endif
+ // Small Script Cache
+ uint _SmallScriptPool;
+ typedef std::map TSmallScriptCache;
+ TSmallScriptCache _SmallScriptCache;
+ static const char * _NELSmallScriptTableName;
+
+ private:
+ // this object isn't intended to be copied
+ CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); }
+ CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; }
+
+ void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0);
+
+ };
+
+
+ // Access to lua function
+ // one should not include lua.h directly because if a debugger is present, lua
+ // function pointer will be taken from a dynamic library.
+
+
+
+ //=============================================================================================
+ // include implementation
+ #define RZ_INCLUDE_LUA_HELPER_INLINE
+ #include "lua_helper_inline.h"
+ #undef RZ_INCLUDE_LUA_HELPER_INLINE
+
+}
+
+#endif
diff --git a/code/ryzom/client/src/interface_v3/lua_helper_inline.h b/code/nel/include/nel/gui/lua_helper_inline.h
similarity index 100%
rename from code/ryzom/client/src/interface_v3/lua_helper_inline.h
rename to code/nel/include/nel/gui/lua_helper_inline.h
diff --git a/code/nel/include/nel/gui/lua_ihm.h b/code/nel/include/nel/gui/lua_ihm.h
new file mode 100644
index 000000000..974ece6f7
--- /dev/null
+++ b/code/nel/include/nel/gui/lua_ihm.h
@@ -0,0 +1,193 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef NL_LUA_IHM_H
+#define NL_LUA_IHM_H
+
+#include "nel/misc/types_nl.h"
+#include "nel/gui/lua_helper.h"
+#include "nel/gui/interface_element.h"
+
+#define IHM_LUA_METATABLE "__ui_metatable"
+#define IHM_LUA_ENVTABLE "__ui_envtable"
+
+namespace NLMISC
+{
+ class CPolygon2D;
+ class CVector2f;
+ class CRGBA;
+}
+
+namespace NLGUI
+{
+
+ class CReflectable;
+ class CReflectedProperty;
+
+ // ***************************************************************************
+ /* Use this Exception for all LUA Error (eg: scripted passes bad number of paramters).
+ * Does not herit from Exception because avoid nlinfo, because sent twice (catch then resent)
+ * This is special to lua and IHM since it works with CLuaStackChecker, and also append to the error msg
+ * the FileName/LineNumber
+ */
+ class ELuaIHMException : public ELuaWrappedFunctionException
+ {
+ private:
+ static CLuaState *getLuaState();
+ public:
+ ELuaIHMException() : ELuaWrappedFunctionException(getLuaState())
+ {
+ }
+ ELuaIHMException(const std::string &reason) : ELuaWrappedFunctionException(getLuaState(), reason)
+ {
+ }
+ ELuaIHMException(const char *format, ...) : ELuaWrappedFunctionException(getLuaState())
+ {
+ std::string reason;
+ NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize);
+ init(getLuaState(), reason);
+ }
+ };
+
+ // ***************************************************************************
+ /**
+ * Define Functions to export from C to LUA
+ * \author Lionel Berenguier
+ * \author Nevrax France
+ * \date 2004
+ */
+ class CLuaIHM
+ {
+ public:
+ static void registerAll(CLuaState &ls);
+
+ /** CReflectableInterfaceElement management on stack, stored by a CRefPtr.
+ * May be called as well for ui element, because they derive from CReflectableRefPtrTarget
+ */
+ static void pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT);
+ static bool isReflectableOnStack(CLuaState &ls, sint index);
+ static CReflectableRefPtrTarget *getReflectableOnStack(CLuaState &ls, sint index);
+
+
+ // ucstring
+ static bool pop(CLuaState &ls, ucstring &dest);
+ static void push(CLuaState &ls, const ucstring &value);
+ static bool isUCStringOnStack(CLuaState &ls, sint index);
+ static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest);
+
+
+ // RGBA
+ static bool pop(CLuaState &ls, NLMISC::CRGBA &dest);
+
+ // CVector2f
+ static bool pop(CLuaState &ls, NLMISC::CVector2f &dest);
+
+ // helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail)
+ static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest);
+
+ // argument checkin helpers
+ static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required
+ static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required
+ static void checkArgMax(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at most the one required
+ static void check(CLuaState &ls, bool ok, const std::string &failReason);
+ static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType);
+ static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index);
+ static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index);
+ /** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack
+ * The various check... function call this function when their test fails
+ */
+ static void fails(CLuaState &ls, const char *format, ...);
+
+ // pop a sint32 from a lua stack, throw an exception on fail
+ static bool popSINT32(CLuaState &ls, sint32 & dest);
+ bool popString(CLuaState &ls, std::string & dest);
+
+ /** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object
+ * (throws on error)
+ */
+ static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException);
+
+ // push a reflected property on the stack
+ // NB : no check is done that 'property' is part of the class info of 'reflectedObject'
+ static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property);
+
+ private:
+ // Functions for the ui metatable
+ static class CInterfaceElement* getUIRelative( CInterfaceElement *pIE, const std::string &propName );
+ static int luaUIIndex( CLuaState &ls );
+ static int luaUINewIndex( CLuaState &ls );
+ static int luaUIEq( CLuaState &ls );
+ static int luaUINext( CLuaState &ls );
+ static int luaUIDtor( CLuaState &ls );
+
+
+ static void registerBasics(CLuaState &ls);
+ static void registerIHM(CLuaState &ls);
+ static void createLuaEnumTable(CLuaState &ls, const std::string &str);
+
+ public:
+ static void pushUIOnStack(CLuaState &ls, CInterfaceElement *pIE);
+ static bool isUIOnStack(CLuaState &ls, sint index);
+ static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index);
+ static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index);
+
+ private:
+
+ //////////////////////////////////////////// Exported functions //////////////////////////////////////////////////////
+
+ static uint32 getLocalTime();
+ static double getPreciseLocalTime();
+ static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace);
+ static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace);
+ static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace);
+ static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace);
+ static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace);
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ static int luaMethodCall(lua_State *ls);
+
+ static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none
+ static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none
+ static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none
+ static int setCaptureKeyboard(CLuaState &ls);
+ static int resetCaptureKeyboard(CLuaState &ls);
+ static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error)
+ static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none
+ static int getWindowSize(CLuaState &ls);
+ static int setTopWindow(CLuaState &ls); // set the top window
+ static int getTextureSize(CLuaState &ls);
+ static int disableModalWindow(CLuaState &ls);
+ static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none
+ static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none
+ static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none)
+ static bool fileExists(const std::string &fileName);
+ static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct
+ static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString
+ static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString
+ static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false
+ static int isUCString(CLuaState &ls);
+ static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ...
+ static int concatString(CLuaState &ls); // speedup concatenation of several strings
+ static int tableToString(CLuaState &ls); // concat element of a table to build a string
+ static int getPathContent(CLuaState &ls);
+ };
+
+}
+
+#endif // NL_LUA_IHM_H
+
+/* End of lua_ihm.h */
diff --git a/code/ryzom/client/src/interface_v3/lua_loadlib.h b/code/nel/include/nel/gui/lua_loadlib.h
similarity index 92%
rename from code/ryzom/client/src/interface_v3/lua_loadlib.h
rename to code/nel/include/nel/gui/lua_loadlib.h
index adab3ec0b..1fe0abcd3 100644
--- a/code/ryzom/client/src/interface_v3/lua_loadlib.h
+++ b/code/nel/include/nel/gui/lua_loadlib.h
@@ -19,9 +19,9 @@
extern "C"
{
-#include
-#include
-#include
+#include
+#include
+#include
}
// load the lua dll, return 1 on success
diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h
new file mode 100644
index 000000000..00aecbe84
--- /dev/null
+++ b/code/nel/include/nel/gui/lua_manager.h
@@ -0,0 +1,78 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef LUA_MANAGER_H
+#define LUA_MANAGER_H
+
+#include "nel/misc/smart_ptr.h"
+
+namespace NLGUI
+{
+ class CLuaState;
+
+ /**
+ Lua Manager
+
+ Provides a single global access point to the Lua state, and related stuff. :(
+ */
+ class CLuaManager
+ {
+ public:
+ ~CLuaManager();
+
+ static CLuaManager& getInstance()
+ {
+ if( instance == NULL )
+ {
+ instance = new CLuaManager();
+ }
+ return *instance;
+ }
+
+ /// Enables attaching the Lua debugger in the CLuaState instance, only matters on startup.
+ static void enableLuaDebugging(){ debugLua = true; }
+
+ /// Returns the Lua state.
+ NLGUI::CLuaState* getLuaState() const{ return luaState; }
+
+ /**
+ Executes a Lua script
+ @param luaScript - the script we want to execute ( the actual script, not the filename! )
+ @param smallScript - true if the script is very small, so it can be cached for the possible next execution.
+ */
+ bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
+
+ /// Resets the Lua state, that is deallocates it and allocates a new one.
+ void ResetLuaState();
+
+ /// Forces the Garbage Collector to run.
+ void forceGarbageCollect();
+
+ static void setEditorMode( bool b ){ editorMode = b; }
+
+ private:
+ CLuaManager();
+
+ static CLuaManager *instance;
+ static bool debugLua;
+ static bool editorMode;
+
+ NLGUI::CLuaState *luaState;
+ };
+
+}
+
+#endif
diff --git a/code/nel/include/nel/gui/lua_object.h b/code/nel/include/nel/gui/lua_object.h
new file mode 100644
index 000000000..1564df080
--- /dev/null
+++ b/code/nel/include/nel/gui/lua_object.h
@@ -0,0 +1,303 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef RZ_LUA_OBJECT
+#define RZ_LUA_OBJECT
+
+
+#include "nel/misc/smart_ptr.h"
+#include "nel/misc/rgba.h"
+#include "nel/gui/lua_helper.h"
+
+namespace NLGUI
+{
+
+ class CLuaEnumeration;
+
+ /**
+ * Wrapper to a lua value
+ *
+ * Useful to navigate through lua tables without having to deal with the stack.
+ *
+ * The following types are tracked by reference :
+ * - lua table
+ * - lua user data
+ * - lua functions
+ *
+ * The following types are kept by value :
+ *
+ * - lua numbers
+ * - lua strings ?
+ * - lua boolean
+ * - lua light user datas
+ * - lua 'pointers'
+ *
+ * Each reference object has an id giving its path in order to track bugs more easily
+ */
+ class CLuaObject
+ {
+ public:
+ CLuaObject() {}
+ ~CLuaObject();
+ // Build this object by popping it from the given lua state
+ CLuaObject(CLuaState &state, const char *id ="");
+ CLuaObject(CLuaState &state, const std::string &id);
+ // Build this object from another object
+ CLuaObject(const CLuaObject &other);
+ // Copy refrence to another lua object
+ CLuaObject &operator=(const CLuaObject &other);
+ // Get id for that object
+ const std::string &getId() const { return _Id; }
+ // Set id for that object
+ void setId(const std::string &id) { _Id = id; }
+ // See if the obj
+ bool isValid() const;
+ // Pop a new value for this lua object from the top of the stack. The stack must not be empty
+ void pop(CLuaState &luaState, const char *id ="");
+ // Push the object that is being referenced on the stack
+ // An assertion is raised if 'pop' hasn't been called or
+ // if the lua state has been destroyed
+ void push() const;
+ // Get the lua state in which the object resides.
+ CLuaState *getLuaState() const;
+ // Release the object. 'pop' must be called to make the object valid again
+ void release();
+ // type queries
+ int type() const;
+ const char *getTypename() const;
+ bool isNil() const;
+ bool isNumber() const;
+ bool isBoolean() const;
+ bool isString() const;
+ bool isFunction() const;
+ bool isCFunction() const;
+ bool isTable() const;
+ bool isUserData() const;
+ bool isLightUserData() const;
+ bool isRGBA() const;
+ // equality
+ bool rawEqual(const CLuaObject &other) const;
+ // conversions (no throw) : the actual value of object is not modified!!
+ NLMISC::CRGBA toRGBA() const; // default to black if not a crgba
+ bool toBoolean() const;
+ lua_Number toNumber() const;
+ std::string toString() const;
+ lua_CFunction toCFunction() const;
+ void *toUserData() const;
+ const void *toPointer() const;
+ // implicit conversions (no throw)
+ operator bool() const;
+ operator float() const;
+ operator double() const;
+ operator std::string() const;
+ /** create a sub table for this object, with a string as a key
+ * This object must be a table or an exception if thrown
+ */
+ CLuaObject newTable(const char *tableName) throw(ELuaNotATable);
+
+
+ /** Set a value in a table.
+ * If this object is not a table then an exception is thrown
+ * NB : value should came from the same lua environment
+ * \TODO other type of keys
+ */
+ void setValue(const char *key, const CLuaObject &value) throw(ELuaNotATable);
+ void setValue(const std::string &key, const CLuaObject &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
+ void setValue(const char *key, const std::string &value) throw(ELuaNotATable);
+ void setValue(const char *key, const char *value) throw(ELuaNotATable);
+ void setValue(const char *key, bool value) throw(ELuaNotATable);
+ void setValue(const char *key, TLuaWrappedFunction value) throw(ELuaNotATable);
+ void setValue(const char *key, double value) throw(ELuaNotATable);
+ void setValue(const std::string &key, const std::string &value) throw(ELuaNotATable) { setValue(key.c_str(), value); }
+ void setNil(const char *key) throw(ELuaNotATable);
+ void setNil(const std::string &key) throw(ELuaNotATable) { setNil(key.c_str()); }
+ /** Erase a value in a table by its key.
+ * If this object is not a table then an exception is thrown.
+ * \TODO other type of keys
+ */
+ void eraseValue(const char *key) throw(ELuaNotATable);
+ void eraseValue(const std::string &key) throw(ELuaNotATable) { eraseValue(key.c_str()); }
+ // test is this object is enumerable
+ bool isEnumerable() const;
+ // Enumeration of a table. If the object is not a table, an exception is thrown.
+ CLuaEnumeration enumerate() throw(ELuaNotATable);
+ // retrieve metatable of an object (or nil if object has no metatable)
+ CLuaObject getMetaTable() const;
+ // set metatable for this object
+ bool setMetaTable(CLuaObject &metatable);
+ /** Access to a sub element of a table (no throw).
+ * if the element is not a table, then 'nil' is returned
+ * TODO nico : add other key types if needed
+ * TODO nico : version that takes destination object as a reference in its parameter to avoid an object copy
+ */
+ CLuaObject operator[](double key) const;
+ CLuaObject operator[](const char *key) const;
+ CLuaObject operator[](const std::string &key) const { return operator[](key.c_str()); }
+ /** Checked access to a sub element of a table. An exception is thrown is the element is not a table.
+ */
+ CLuaObject at(const char *key) const throw (ELuaNotATable);
+ CLuaObject at(const std::string &key) const { return at(key.c_str()); }
+
+ // Test is that table has the given key. The object must be a table or an exception is thrown
+ bool hasKey(const char *key) const;
+
+ /** debug : recursively get value (useful for table)
+ * \param maxDepth (0 for no limit)
+ * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered)
+ */
+ std::string toStringRecurse(uint depth = 0, uint maxDepth = 20, std::set *alreadySeen = NULL) const;
+
+ /** dump the value in the log (includes tables)
+ * \param alreadySeen pointer to lua tables that have already been displayed by the command (to avoid infinite recursion when a cycluic graph is encountered)
+ */
+ void dump(uint maxDepth = 20, std::set *alreadySeen = NULL) const;
+ // concatenate identifiers, adding a dot between them if necessary. If right is a number then brackets are added
+ static std::string concatId(const std::string &left, const std::string &right);
+ // If this object is a function, then call it and return true on success
+ bool callNoThrow(int numArgs, int numRet);
+ // Call a method of this table by name (no throw version)
+ bool callMethodByNameNoThrow(const char *name, int numArgs, int numRet);
+ private:
+ NLMISC::CRefPtr _LuaState;
+ std::string _Id;
+ };
+
+
+ /** enumeration of the content of a lua table
+ *
+ * Example of use :
+ *
+ *\code
+ CLuaObject table;
+ table.pop(luaState); // retrieve table from the top of a lua stack
+ CLuaEnumeration enueration = table.enumerate();
+ while (enumeration.hasNext())
+ {
+ nlinfo('key = %s", enumeration.nextKey().toString().c_str());
+ nlinfo('value = %s", enumeration.nextValue().toString().c_str());
+ enumeration.next();
+ };
+ \endcode
+ *
+ * There is a macro called 'ENUM_LUA_TABLE' to automate that process.
+ * Previous code would then be written as follow :
+ *
+ *
+ *\code
+ CLuaObject table;
+ table.pop(luaState); // retrieve table from the top of a lua stack
+ ENUM_LUA_TABLE(table, enumeration);
+ {
+ nlinfo('key = %s", enumeration.nextKey().toString().c_str());
+ nlinfo('value = %s", enumeration.nextValue().toString().c_str());
+ };
+ \endcode
+ *
+ */
+ class CLuaEnumeration
+ {
+ public:
+ // is there a next key,value pair in the table
+ bool hasNext() { return _HasNext; }
+ // Return next key. Assertion if 'hasNext' is false
+ const CLuaObject &nextKey() const;
+ // Return next value. Assertion if 'hasNext' is false
+ CLuaObject &nextValue();
+ // Go to the next value. Assertion if there's no such value
+ void next();
+ private:
+ friend class CLuaObject;
+ // current value & key
+ CLuaObject _Table;
+ CLuaObject _Key;
+ CLuaObject _Value;
+ CLuaObject _NextFunction; // pointer to the global 'next' function
+ bool _HasNext;
+ // construction from a table on the stack
+ CLuaEnumeration(CLuaObject &table);
+ };
+
+
+
+
+ /** macro to ease lua table enumeration
+ * \param object A CLuaObject which must be a table, and on which enumeration is done. An exception will be thrown as 'CLuaObject::enumerate' is
+ * called if this is not the case
+ * \param enumerator The enumerator object
+ */
+ #define ENUM_LUA_TABLE(object, enumerator) for(CLuaEnumeration enumerator = (object).enumerate(); enumerator.hasNext(); enumerator.next())
+
+
+ //opitmized lua string for fast comparison
+ class CLuaString
+ {
+ public:
+ explicit CLuaString(const char *value = "")
+ {
+ nlassert( value != NULL );
+ _Str = value;
+ }
+ const std::string& getStr() const{ return _Str; }
+ private:
+ std::string _Str;
+ mutable CLuaState::TRefPtr _LuaState; // ref ptr so that statics get rebuilt on lua restart
+ mutable CLuaObject _InLua;
+ };
+
+ inline bool operator==(const char* lh, const CLuaString& rh)
+ {
+ return std::string(lh) == rh.getStr();
+ }
+
+ inline bool operator==( const CLuaString& lh, const CLuaString& rh)
+ {
+ return lh.getStr() == rh.getStr();
+ }
+
+ inline bool operator==(const CLuaString& lh, const char* rh)
+ {
+ return std::string(rh) == lh.getStr();
+ }
+
+ inline bool operator==( const CLuaString& lh, const std::string& rh)
+ {
+ return lh.getStr() == rh;
+ }
+
+ inline bool operator==(const std::string& lh, const CLuaString& rh)
+ {
+ return lh == rh.getStr();
+ }
+
+ class CLuaHashMapTraits
+ {
+ public:
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+ CLuaHashMapTraits()
+ {}
+
+ // hasher for lua string -> they are unique pointers for each string, so just hash a pointer instead of a string...
+ size_t operator()(const char *value) const { return ((size_t) value) >> 3; }
+
+ // equality for lua string for hash_map -> they are unique pointer -> compare pointers instead of string content
+ bool operator()(const char *lhs, const char *rhs) const { return lhs < rhs; }
+ };
+
+
+}
+
+#endif
diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h
new file mode 100644
index 000000000..dc6d00767
--- /dev/null
+++ b/code/nel/include/nel/gui/parser.h
@@ -0,0 +1,93 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#ifndef PARSER_H
+#define PARSER_H
+
+#include
+#include
+#include "nel/misc/types_nl.h"
+#include "nel/gui/proc.h"
+#include "nel/gui/link_data.h"
+
+namespace NLGUI
+{
+ class CInterfaceElement;
+ class CInterfaceGroup;
+ class CInterfaceAnim;
+ class CCtrlSheetSelection;
+ class CInterfaceLink;
+
+ /// Interface for the GUI XML parser class.
+ class IParser
+ {
+ public:
+ IParser();
+ virtual ~IParser();
+
+ static IParser* createParser();
+
+ virtual void addParentPositionAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
+ virtual void addParentSizeAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
+ virtual void addParentSizeMaxAssociation( CInterfaceElement *element, const std::string &parentID ) = 0;
+ virtual void addLuaClassAssociation( CInterfaceGroup *group, const std::string &luaScript ) = 0;
+ virtual std::string getParentPosAssociation( CInterfaceElement *element ) const = 0;
+ virtual std::string getParentSizeAssociation( CInterfaceElement *element ) const = 0;
+ virtual std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const = 0;
+ virtual std::string getLuaClassAssociation( CInterfaceGroup *group ) const = 0;
+ virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0;
+ virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
+ virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
+ virtual uint getProcedureNumActions( const std::string &procName ) const = 0;
+ virtual bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string ¶ms ) const = 0;
+ virtual const std::string& getDefine(const std::string &id) const = 0;
+ virtual CInterfaceAnim* getAnim( const std::string &name ) const = 0;
+ virtual CProcedure* getProc( const std::string &name ) = 0;
+ virtual const TProcedureMap& getProcMap() const = 0;
+ virtual bool parseInterface( const std::vector< std::string > &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false ) = 0;
+ virtual void initLUA() = 0;
+ virtual void uninitLUA() = 0;
+ virtual bool isLuaInitialized() const = 0;
+ virtual bool loadLUA( const std::string &luaFile, std::string &error ) = 0;
+ virtual void reloadAllLuaFileScripts() = 0;
+ virtual void removeAllTemplates() = 0;
+ virtual bool solveDefine( const std::string &propVal, std::string &newPropVal, std::string &defError ) = 0;
+ virtual CInterfaceElement* createUIElement( const std::string &templateName, const std::string &parentID, const std::pair< std::string,std::string> *templateParams, uint numParams, bool updateLinks ) = 0;
+ virtual CInterfaceElement* createUIElement( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
+ virtual bool isDefineExist( const std::string &id ) const = 0;
+ virtual CCtrlSheetSelection &getCtrlSheetSelection() = 0;
+ virtual bool addLink( CInterfaceLink *link, const std::string &id ) = 0;
+ virtual bool removeLink( const std::string &id ) = 0;
+ virtual void removeAll() = 0;
+ virtual bool hasProc( const std::string &name ) const = 0;
+ virtual bool addProc( const std::string &name ) = 0;
+ virtual bool removeProc( const std::string &name ) = 0;
+ virtual void setEditorMode( bool b ) = 0;
+ virtual const std::map< uint32, SLinkData >& getLinkMap() const = 0;
+ virtual uint32 addLinkData( SLinkData &linkData ) = 0;
+ virtual void removeLinkData( uint32 id ) = 0;
+ virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0;
+ virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0;
+ virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0;
+ virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0;
+ virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0;
+ virtual bool serializeKeySettings( xmlNodePtr parentNode ) const = 0;
+ };
+}
+
+#endif
+
diff --git a/code/nel/include/nel/gui/proc.h b/code/nel/include/nel/gui/proc.h
new file mode 100644
index 000000000..9e98008e4
--- /dev/null
+++ b/code/nel/include/nel/gui/proc.h
@@ -0,0 +1,150 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#ifndef PROC_H
+#define PROC_H
+
+#include "nel/misc/types_nl.h"
+#include
+#include
+#include |