Merged default

--HG--
branch : gsoc2012-gui-editor
hg/feature/sse2
dfighter1985 12 years ago
commit 307b60f44b

@ -58,6 +58,7 @@ MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION)
PATHS
/usr/local/lib
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib

@ -1,37 +1,37 @@
SUBDIRS(misc)
IF(WITH_3D)
SUBDIRS(3d)
ENDIF(WITH_3D)
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF(WITH_GUI)
IF(WITH_GEORGES)
SUBDIRS(georges)
ENDIF(WITH_GEORGES)
IF(WITH_LIGO)
SUBDIRS(ligo)
ENDIF(WITH_LIGO)
IF(WITH_LOGIC)
SUBDIRS(logic)
ENDIF(WITH_LOGIC)
IF(WITH_NET)
SUBDIRS(net)
ENDIF(WITH_NET)
IF(WITH_SOUND)
SUBDIRS(sound)
ENDIF(WITH_SOUND)
IF(WITH_PACS)
SUBDIRS(pacs)
ENDIF(WITH_PACS)
IF(WITH_NEL_CEGUI)
SUBDIRS(cegui)
ENDIF(WITH_NEL_CEGUI)
SUBDIRS(misc)
IF(WITH_3D)
SUBDIRS(3d)
ENDIF(WITH_3D)
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF(WITH_GUI)
IF(WITH_GEORGES)
SUBDIRS(georges)
ENDIF(WITH_GEORGES)
IF(WITH_LIGO)
SUBDIRS(ligo)
ENDIF(WITH_LIGO)
IF(WITH_LOGIC)
SUBDIRS(logic)
ENDIF(WITH_LOGIC)
IF(WITH_NET)
SUBDIRS(net)
ENDIF(WITH_NET)
IF(WITH_SOUND)
SUBDIRS(sound)
ENDIF(WITH_SOUND)
IF(WITH_PACS)
SUBDIRS(pacs)
ENDIF(WITH_PACS)
IF(WITH_NEL_CEGUI)
SUBDIRS(cegui)
ENDIF(WITH_NEL_CEGUI)

@ -1,3 +1,3 @@
FILE(GLOB HEADERS *.h)
INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers)
FILE(GLOB HEADERS *.h)
INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers)

@ -1,153 +1,153 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_ACTION_HANDLER_H
#define NL_ACTION_HANDLER_H
#include "nel/misc/types_nl.h"
#include <libxml/parser.h>
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include <map>
namespace NLGUI
{
class CCtrlBase;
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class IActionHandler
{
public:
// Execute the answer to the action
// Params has the following form : paramName=theParam|paramName2=theParam2|...
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { }
virtual ~IActionHandler() {}
static std::string getParam (const std::string &Params, const std::string &ParamName);
static void getAllParams (const std::string &Params, std::vector< std::pair<std::string,std::string> > &AllParams);
};
/**
interface for action handlers factory
no release in this factory : a handler must be destroyed by the control that created it
*/
class CAHManager
{
public:
typedef std::map< std::string, IActionHandler* > TFactoryMap;
typedef std::map< IActionHandler*, std::string > TNameMap;
static CAHManager* getInstance()
{
if (_GlobalInstance == NULL)
_GlobalInstance = new CAHManager;
return _GlobalInstance;
}
/// return pointer to action handler or null if it doesn't exist
IActionHandler *getActionHandler(const std::string &name) const
{
TFactoryMap::const_iterator it = FactoryMap.find(name);
if( it == FactoryMap.end() )
{
nlwarning( "Couldn't find action handler %s", name.c_str() );
return NULL;
}
else
return it->second;
}
/// Return the name of the action handler given its pointer
const std::string &getActionHandlerName(IActionHandler *pAH) const
{
TNameMap::const_iterator it = NameMap.find(pAH);
return it != NameMap.end() ? it->second : EmptyName;
}
/// map of action handler factories
TFactoryMap FactoryMap;
TNameMap NameMap;
std::string EmptyName;
/// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed)
IActionHandler *getAH(const std::string &name, std::string &params);
IActionHandler *getAH(const std::string &name, class CStringShared &params);
/** common method to parse Action Handler from a xml node
* \param ahId eg: "onclick_l"
* \param paramId eg: "params_l".
* \param params returned parameters.
* NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book")
* is taken
* NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed
*/
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string &params);
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared &params);
/// Get the AH name from ptr
const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); }
void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") );
void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") );
// Submit a generic event
void submitEvent( const std::string &evt );
static void setEditorMode( bool b ){ editorMode = b; }
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
static bool editorMode;
};
/// Ah name must all be lower case
#define REGISTER_ACTION_HANDLER(handler ,name) \
class handler##Factory : public handler \
{ \
public: \
handler##Factory () \
{ \
nlassert(name!=NULL); \
const char *c= name; \
while(*c!='\0') \
{ \
nlassert(islower(*c) || !isalpha(*c)); \
c++; \
} \
CAHManager *pAHFM = CAHManager::getInstance(); \
pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \
pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \
}; \
}; \
handler##Factory handler##FactoryInstance ; \
\
}
#endif //NL_ACTION_HANDLER_H
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_ACTION_HANDLER_H
#define NL_ACTION_HANDLER_H
#include "nel/misc/types_nl.h"
#include <libxml/parser.h>
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include <map>
namespace NLGUI
{
class CCtrlBase;
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class IActionHandler
{
public:
// Execute the answer to the action
// Params has the following form : paramName=theParam|paramName2=theParam2|...
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { }
virtual ~IActionHandler() {}
static std::string getParam (const std::string &Params, const std::string &ParamName);
static void getAllParams (const std::string &Params, std::vector< std::pair<std::string,std::string> > &AllParams);
};
/**
interface for action handlers factory
no release in this factory : a handler must be destroyed by the control that created it
*/
class CAHManager
{
public:
typedef std::map< std::string, IActionHandler* > TFactoryMap;
typedef std::map< IActionHandler*, std::string > TNameMap;
static CAHManager* getInstance()
{
if (_GlobalInstance == NULL)
_GlobalInstance = new CAHManager;
return _GlobalInstance;
}
/// return pointer to action handler or null if it doesn't exist
IActionHandler *getActionHandler(const std::string &name) const
{
TFactoryMap::const_iterator it = FactoryMap.find(name);
if( it == FactoryMap.end() )
{
nlwarning( "Couldn't find action handler %s", name.c_str() );
return NULL;
}
else
return it->second;
}
/// Return the name of the action handler given its pointer
const std::string &getActionHandlerName(IActionHandler *pAH) const
{
TNameMap::const_iterator it = NameMap.find(pAH);
return it != NameMap.end() ? it->second : EmptyName;
}
/// map of action handler factories
TFactoryMap FactoryMap;
TNameMap NameMap;
std::string EmptyName;
/// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed)
IActionHandler *getAH(const std::string &name, std::string &params);
IActionHandler *getAH(const std::string &name, class CStringShared &params);
/** common method to parse Action Handler from a xml node
* \param ahId eg: "onclick_l"
* \param paramId eg: "params_l".
* \param params returned parameters.
* NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book")
* is taken
* NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed
*/
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string &params);
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared &params);
/// Get the AH name from ptr
const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); }
void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") );
void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") );
// Submit a generic event
void submitEvent( const std::string &evt );
static void setEditorMode( bool b ){ editorMode = b; }
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
static bool editorMode;
};
/// Ah name must all be lower case
#define REGISTER_ACTION_HANDLER(handler ,name) \
class handler##Factory : public handler \
{ \
public: \
handler##Factory () \
{ \
nlassert(name!=NULL); \
const char *c= name; \
while(*c!='\0') \
{ \
nlassert(islower(*c) || !isalpha(*c)); \
c++; \
} \
CAHManager *pAHFM = CAHManager::getInstance(); \
pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \
pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \
}; \
}; \
handler##Factory handler##FactoryInstance ; \
\
}
#endif //NL_ACTION_HANDLER_H

@ -1,190 +1,190 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BASE_H
#define RZ_CTRL_BASE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
#include "nel/gui/event_descriptor.h"
namespace NLGUI
{
class CCtrlBase : public CViewBase
{
public:
// Tooltip mode
enum TToolTipParentType
{
TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears
TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears
TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies.
TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window
NumToolTipParentRef
};
public:
/// Constructor
CCtrlBase(const TCtorParam &param) : CViewBase(param)
{
_ToolTipInstant= true;
_ToolTipParent= TTCtrl;
// see interface.txt for meaning of auto
_ToolTipParentPosRef= Hotspot_TTAuto;
_ToolTipPosRef= Hotspot_TTAuto;
resizer = false;
}
/// Destructor
virtual ~CCtrlBase();
static std::string tooltipParentToString( TToolTipParentType type );
static TToolTipParentType stringToToolTipParent( const std::string &str );
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;
// special parse
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
/// Handle all events (implemented by derived classes) (return true to signal event handled)
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Get the ContextHelp for this control. Default is to return _ContextHelp
virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;}
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); }
// Get the name of the context help window. Default to "context_help"
virtual std::string getContextHelpWindowName() const;
/// Get the ContextHelp ActionHandler. If "", noop
const std::string &getContextHelpActionHandler() const {return _OnContextHelp;}
/// Get the ContextHelp ActionHandler Params
const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;}
/// true if both are empty
bool emptyContextHelp() const;
// Should return true if the context help should be displayed instantly
bool wantInstantContextHelp() const { return _ToolTipInstant; }
/// Set true if ToolTip should be displayed instantly
void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;}
/** If ctrl has a non rectangle shape, perform further test to know
* if control should be taken in account for context help
*/
virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; }
/// return the type of anchor for the tooltip of this control
TToolTipParentType getToolTipParent() const { return _ToolTipParent;}
const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();}
/// Set the type of anchor for the tooltip of this control
void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; }
void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; }
/// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;}
THotSpot getToolTipPosRef() const { return _ToolTipPosRef;}
THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;}
THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;}
/// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;}
void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;}
/// replace the default contextHelp
ucstring getDefaultContextHelp() const {return _ContextHelp;}
void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;}
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
// called when this element or a son has been captured
virtual void elementCaptured(CCtrlBase * /* capturedElement */) {}
virtual bool isCtrl() const { return true; }
// Made for CtrlResizer to take the precedence over son controls.
virtual uint getDeltaDepth() const { return 0; }
// true if this ctrl is capturable (true by default, false for tooltip)
virtual bool isCapturable() const {return true;}
bool isResizer() const{ return resizer; }
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
/** test if virtual desktop change is possible while this element is captured by the mouse
* Useful for resizers
*/
virtual bool canChangeVirtualDesktop() const { return true; }
// called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {}
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
virtual void serial(NLMISC::IStream &f);
uint32 getDepth( CInterfaceGroup *group );
protected:
// This is the ContextHelp filled by default in parse()
ucstring _ContextHelp;
CStringShared _OnContextHelp;
CStringShared _OnContextHelpParams;
CStringShared _ToolTipSpecialParent;
TToolTipParentType _ToolTipParent;
bool _ToolTipInstant : 1;
THotSpot _ToolTipParentPosRef : 6;
THotSpot _ToolTipPosRef : 6;
THotSpot _ToolTipParentPosRefAlt : 6;
THotSpot _ToolTipPosRefAlt : 6;
protected:
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
void mapAHString( const std::string &key, const std::string &value );
std::string getAHString( const std::string &key ) const;
static std::map< std::string, std::map< std::string, std::string > > AHCache;
bool resizer;
};
}
#endif // RZ_VIEW_BASE_H
/* End of ctrl_base.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BASE_H
#define RZ_CTRL_BASE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
#include "nel/gui/event_descriptor.h"
namespace NLGUI
{
class CCtrlBase : public CViewBase
{
public:
// Tooltip mode
enum TToolTipParentType
{
TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears
TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears
TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies.
TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window
NumToolTipParentRef
};
public:
/// Constructor
CCtrlBase(const TCtorParam &param) : CViewBase(param)
{
_ToolTipInstant= true;
_ToolTipParent= TTCtrl;
// see interface.txt for meaning of auto
_ToolTipParentPosRef= Hotspot_TTAuto;
_ToolTipPosRef= Hotspot_TTAuto;
resizer = false;
}
/// Destructor
virtual ~CCtrlBase();
static std::string tooltipParentToString( TToolTipParentType type );
static TToolTipParentType stringToToolTipParent( const std::string &str );
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;
// special parse
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
/// Handle all events (implemented by derived classes) (return true to signal event handled)
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Get the ContextHelp for this control. Default is to return _ContextHelp
virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;}
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); }
// Get the name of the context help window. Default to "context_help"
virtual std::string getContextHelpWindowName() const;
/// Get the ContextHelp ActionHandler. If "", noop
const std::string &getContextHelpActionHandler() const {return _OnContextHelp;}
/// Get the ContextHelp ActionHandler Params
const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;}
/// true if both are empty
bool emptyContextHelp() const;
// Should return true if the context help should be displayed instantly
bool wantInstantContextHelp() const { return _ToolTipInstant; }
/// Set true if ToolTip should be displayed instantly
void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;}
/** If ctrl has a non rectangle shape, perform further test to know
* if control should be taken in account for context help
*/
virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; }
/// return the type of anchor for the tooltip of this control
TToolTipParentType getToolTipParent() const { return _ToolTipParent;}
const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();}
/// Set the type of anchor for the tooltip of this control
void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; }
void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; }
/// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;}
THotSpot getToolTipPosRef() const { return _ToolTipPosRef;}
THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;}
THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;}
/// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;}
void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;}
/// replace the default contextHelp
ucstring getDefaultContextHelp() const {return _ContextHelp;}
void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;}
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
// called when this element or a son has been captured
virtual void elementCaptured(CCtrlBase * /* capturedElement */) {}
virtual bool isCtrl() const { return true; }
// Made for CtrlResizer to take the precedence over son controls.
virtual uint getDeltaDepth() const { return 0; }
// true if this ctrl is capturable (true by default, false for tooltip)
virtual bool isCapturable() const {return true;}
bool isResizer() const{ return resizer; }
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
/** test if virtual desktop change is possible while this element is captured by the mouse
* Useful for resizers
*/
virtual bool canChangeVirtualDesktop() const { return true; }
// called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {}
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
virtual void serial(NLMISC::IStream &f);
uint32 getDepth( CInterfaceGroup *group );
protected:
// This is the ContextHelp filled by default in parse()
ucstring _ContextHelp;
CStringShared _OnContextHelp;
CStringShared _OnContextHelpParams;
CStringShared _ToolTipSpecialParent;
TToolTipParentType _ToolTipParent;
bool _ToolTipInstant : 1;
THotSpot _ToolTipParentPosRef : 6;
THotSpot _ToolTipPosRef : 6;
THotSpot _ToolTipParentPosRefAlt : 6;
THotSpot _ToolTipPosRefAlt : 6;
protected:
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
void mapAHString( const std::string &key, const std::string &value );
std::string getAHString( const std::string &key ) const;
static std::map< std::string, std::map< std::string, std::string > > AHCache;
bool resizer;
};
}
#endif // RZ_VIEW_BASE_H
/* End of ctrl_base.h */

@ -1,270 +1,270 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_BASE_BUTTON_H
#define NL_CTRL_BASE_BUTTON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Base Class For Buttons.
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CCtrlBaseButton : public CCtrlBase
{
public:
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
/// Constructor
CCtrlBaseButton(const TCtorParam &param);
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 bool handleEvent (const NLGUI::CEventDescriptor& event);
/// \name Misc
// @{
void setType (EType t) { _Type = t; }
EType getType() { return _Type; }
std::string getTypeString() const;
void setTypeFromString( const std::string &type );
void setClickWhenPushed(bool click) { _ClickWhenPushed = click; }
bool getClickWhenPushed() const { return _ClickWhenPushed; }
void setPushed (bool state);
bool getPushed () const { return _Pushed; }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
// Set half tone mode for the display of frozen buttons. Default is true.
void setFrozenHalfTone(bool enabled);
bool getFrozenHalfTone() const { return _FrozenHalfTone; }
// if the radio is a radio button, then all radio button are unselected
void unselect();
// @}
/// \name Colors
// @{
void setColor(NLMISC::CRGBA col) { _ColorNormal = col; }
void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; }
void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; }
NLMISC::CRGBA getColor() const { return _ColorNormal; }
NLMISC::CRGBA getColorPushed() const { return _ColorPushed; }
NLMISC::CRGBA getColorOver() const { return _ColorOver; }
// Override because mustupdate 3 states
void setModulateGlobalColorAll(bool state);
void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;}
void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;}
void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;}
virtual sint32 getAlpha() const { return _ColorNormal.A; }
virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; }
std::string getColorAsString() const
{ return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " +
NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); }
std::string getColorOverAsString() const
{ return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " +
NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); }
std::string getColorPushedAsString() const
{ return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " +
NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); }
void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); }
void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); }
void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); }
// @}
///\name radio button specific
//@{
/** Initialize radio button reference
* Advanced:
* NB: must call initRBRef() for radio button if button is created without parse().
* NB: setParent() must be called before (else assert)
*/
void initRBRef();
//@}
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
/// \name Handlers
// @{
// Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
// get Event part
std::string _getActionOnOver() const{ return CAHManager::getInstance()->getAHName( _AHOnOver ); }
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftClick ); }
std::string _getActionOnLeftLongClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftLongClick ); }
std::string _getActionOnDblLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftDblClick ); }
std::string _getActionOnRightClick() const { return CAHManager::getInstance()->getAHName( _AHOnRightClick ); }
std::string _getActionOnClockTick() const { return CAHManager::getInstance()->getAHName( _AHOnClockTick ); }
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnOver() const{ return _AHOverParams.toString(); }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click
void runLeftClickAction();
// Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
std::string getListMenuRight () { return _ListMenuRight.toString(); }
// @}
int luaRunLeftClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
REFLECT_BOOL("frozen", getFrozen, setFrozen);
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
EType _Type;
// State
bool _Pushed : 1;
bool _Over : 1;
bool _OverWhenPushed : 1;
bool _Frozen : 1;
bool _FrozenHalfTone : 1;
bool _ClickWhenPushed : 1;
bool _ModulateGlobalColorNormal : 1;
bool _ModulateGlobalColorPushed : 1;
bool _ModulateGlobalColorOver : 1;
bool _LeftLongClickHandled : 1; // Is it already handled ?
bool _LeftDblClickHandled : 1;
///\name radio button specific
//@{
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
// There is only one radio button per group that own the reference (the first one)
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
//@}
// Colors
NLMISC::CRGBA _ColorNormal;
NLMISC::CRGBA _ColorPushed;
NLMISC::CRGBA _ColorOver;
///\name Long click specific
//@{
sint64 _LeftLongClickDate; // Time we left click down
//@}
// for double click : last date at which last left click occurred
static sint64 _LastLeftClickDate;
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
///\name Action Handler
//@{
IActionHandler *_AHOnOver;
CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
std::string _AHOnLeftClickStringParams;
IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick;
CStringShared _AHLeftDblClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHRightClickParams;
IActionHandler *_AHOnClockTick;
CStringShared _AHClockTickParams;
IActionHandler *_AHOnLeftLongClick;
CStringShared _AHLeftLongClickParams;
//@}
CStringShared _ListMenuLeft;
CStringShared _ListMenuRight;
// get the colors modulated on request
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorNormal;
if(_ModulateGlobalColorNormal)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorPushed;
if(_ModulateGlobalColorPushed)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorOver;
if(_ModulateGlobalColorOver)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
// call it at draw
void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement);
};
}
#endif // NL_CTRL_BASE_BUTTON_H
/* End of ctrl_base_button.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_BASE_BUTTON_H
#define NL_CTRL_BASE_BUTTON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Base Class For Buttons.
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CCtrlBaseButton : public CCtrlBase
{
public:
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
/// Constructor
CCtrlBaseButton(const TCtorParam &param);
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 bool handleEvent (const NLGUI::CEventDescriptor& event);
/// \name Misc
// @{
void setType (EType t) { _Type = t; }
EType getType() { return _Type; }
std::string getTypeString() const;
void setTypeFromString( const std::string &type );
void setClickWhenPushed(bool click) { _ClickWhenPushed = click; }
bool getClickWhenPushed() const { return _ClickWhenPushed; }
void setPushed (bool state);
bool getPushed () const { return _Pushed; }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
// Set half tone mode for the display of frozen buttons. Default is true.
void setFrozenHalfTone(bool enabled);
bool getFrozenHalfTone() const { return _FrozenHalfTone; }
// if the radio is a radio button, then all radio button are unselected
void unselect();
// @}
/// \name Colors
// @{
void setColor(NLMISC::CRGBA col) { _ColorNormal = col; }
void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; }
void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; }
NLMISC::CRGBA getColor() const { return _ColorNormal; }
NLMISC::CRGBA getColorPushed() const { return _ColorPushed; }
NLMISC::CRGBA getColorOver() const { return _ColorOver; }
// Override because mustupdate 3 states
void setModulateGlobalColorAll(bool state);
void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;}
void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;}
void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;}
virtual sint32 getAlpha() const { return _ColorNormal.A; }
virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; }
std::string getColorAsString() const
{ return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " +
NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); }
std::string getColorOverAsString() const
{ return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " +
NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); }
std::string getColorPushedAsString() const
{ return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " +
NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); }
void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); }
void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); }
void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); }
// @}
///\name radio button specific
//@{
/** Initialize radio button reference
* Advanced:
* NB: must call initRBRef() for radio button if button is created without parse().
* NB: setParent() must be called before (else assert)
*/
void initRBRef();
//@}
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
/// \name Handlers
// @{
// Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
// get Event part
std::string _getActionOnOver() const{ return CAHManager::getInstance()->getAHName( _AHOnOver ); }
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftClick ); }
std::string _getActionOnLeftLongClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftLongClick ); }
std::string _getActionOnDblLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftDblClick ); }
std::string _getActionOnRightClick() const { return CAHManager::getInstance()->getAHName( _AHOnRightClick ); }
std::string _getActionOnClockTick() const { return CAHManager::getInstance()->getAHName( _AHOnClockTick ); }
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnOver() const{ return _AHOverParams.toString(); }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click
void runLeftClickAction();
// Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
std::string getListMenuRight () { return _ListMenuRight.toString(); }
// @}
int luaRunLeftClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
REFLECT_BOOL("frozen", getFrozen, setFrozen);
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
EType _Type;
// State
bool _Pushed : 1;
bool _Over : 1;
bool _OverWhenPushed : 1;
bool _Frozen : 1;
bool _FrozenHalfTone : 1;
bool _ClickWhenPushed : 1;
bool _ModulateGlobalColorNormal : 1;
bool _ModulateGlobalColorPushed : 1;
bool _ModulateGlobalColorOver : 1;
bool _LeftLongClickHandled : 1; // Is it already handled ?
bool _LeftDblClickHandled : 1;
///\name radio button specific
//@{
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
// There is only one radio button per group that own the reference (the first one)
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
//@}
// Colors
NLMISC::CRGBA _ColorNormal;
NLMISC::CRGBA _ColorPushed;
NLMISC::CRGBA _ColorOver;
///\name Long click specific
//@{
sint64 _LeftLongClickDate; // Time we left click down
//@}
// for double click : last date at which last left click occurred
static sint64 _LastLeftClickDate;
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
///\name Action Handler
//@{
IActionHandler *_AHOnOver;
CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
std::string _AHOnLeftClickStringParams;
IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick;
CStringShared _AHLeftDblClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHRightClickParams;
IActionHandler *_AHOnClockTick;
CStringShared _AHClockTickParams;
IActionHandler *_AHOnLeftLongClick;
CStringShared _AHLeftLongClickParams;
//@}
CStringShared _ListMenuLeft;
CStringShared _ListMenuRight;
// get the colors modulated on request
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorNormal;
if(_ModulateGlobalColorNormal)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorPushed;
if(_ModulateGlobalColorPushed)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorOver;
if(_ModulateGlobalColorOver)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
// call it at draw
void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement);
};
}
#endif // NL_CTRL_BASE_BUTTON_H
/* End of ctrl_base_button.h */

@ -1,108 +1,108 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BUTTON_H
#define RZ_CTRL_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
/**
* <Class description>
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCtrlButton : public CCtrlBaseButton
{
public:
/// Constructor
CCtrlButton(const TCtorParam &param) : CCtrlBaseButton(param)
{
_Scale = false;
_Align = 0;
}
void setAlignFromString( const std::string &s );
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;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */);
// Display part
virtual void draw();
void setTexture (const std::string&name);
void setTexturePushed (const std::string&name);
void setTextureOver (const std::string&name);
void fitTexture();
std::string getTexture () const;
std::string getTexturePushed () const;
std::string getTextureOver() const;
bool isTextureValid() const { return _TextureIdNormal != -1; }
// test if the texture must scale
bool getScale() const { return _Scale; }
void setScale(bool scale) { _Scale = scale; }
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton)
REFLECT_STRING("texture", getTexture, setTexture);
REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed);
REFLECT_STRING("texture_over", getTextureOver, setTextureOver);
REFLECT_BOOL("scale", getScale, setScale);
REFLECT_EXPORT_END
protected:
CViewRenderer::CTextureId _TextureIdNormal;
CViewRenderer::CTextureId _TextureIdPushed;
CViewRenderer::CTextureId _TextureIdOver;
private:
bool _Scale;
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
};
}
#endif // RZ_CTRL_BUTTON_H
/* End of ctrl_button.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BUTTON_H
#define RZ_CTRL_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
/**
* <Class description>
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCtrlButton : public CCtrlBaseButton
{
public:
/// Constructor
CCtrlButton(const TCtorParam &param) : CCtrlBaseButton(param)
{
_Scale = false;
_Align = 0;
}
void setAlignFromString( const std::string &s );
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;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */);
// Display part
virtual void draw();
void setTexture (const std::string&name);
void setTexturePushed (const std::string&name);
void setTextureOver (const std::string&name);
void fitTexture();
std::string getTexture () const;
std::string getTexturePushed () const;
std::string getTextureOver() const;
bool isTextureValid() const { return _TextureIdNormal != -1; }
// test if the texture must scale
bool getScale() const { return _Scale; }
void setScale(bool scale) { _Scale = scale; }
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton)
REFLECT_STRING("texture", getTexture, setTexture);
REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed);
REFLECT_STRING("texture_over", getTextureOver, setTextureOver);
REFLECT_BOOL("scale", getScale, setScale);
REFLECT_EXPORT_END
protected:
CViewRenderer::CTextureId _TextureIdNormal;
CViewRenderer::CTextureId _TextureIdPushed;
CViewRenderer::CTextureId _TextureIdOver;
private:
bool _Scale;
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
};
}
#endif // RZ_CTRL_BUTTON_H
/* End of ctrl_button.h */

@ -1,110 +1,110 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_COL_PICK_H
#define RZ_CTRL_COL_PICK_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
/**
* Class handling a Color Picker
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlColPick : public CCtrlBase
{
public:
CCtrlColPick(const TCtorParam &param);
~CCtrlColPick();
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 updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
sint32 getColorR () const { return _ColorSelect.R; }
sint32 getColorG () const { return _ColorSelect.G; }
sint32 getColorB () const { return _ColorSelect.B; }
sint32 getColorA () const { return _ColorSelect.A; }
void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; }
void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; }
void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; }
void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; }
std::string getColor () const; // Get Color Selected
void setColor (const std::string &col); // Set Color Selected
std::string getColorOver () const; // Get Color Over
void setColorOver (const std::string &col); // Set Color Over
REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase)
REFLECT_SINT32("r", getColorR, setColorR);
REFLECT_SINT32("g", getColorG, setColorG);
REFLECT_SINT32("b", getColorB, setColorB);
REFLECT_SINT32("a", getColorA, setColorA);
REFLECT_STRING("color", getColor, setColor);
REFLECT_STRING("color_over", getColorOver, setColorOver);
REFLECT_EXPORT_END
protected:
void selectColor (sint32 x, sint32 y);
NLMISC::CRGBA getColor (sint32 x, sint32 y);
protected:
bool _MouseDown;
sint32 _Texture;
NLMISC::CRGBA _ColorSelect; // Last Color selected
NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer
std::string _AHOnChange;
std::string _AHOnChangeParams;
CInterfaceProperty _ColSelR;
CInterfaceProperty _ColSelG;
CInterfaceProperty _ColSelB;
CInterfaceProperty _ColSelA;
};
}
#endif // RZ_CTRL_COL_PICK_H
/* End of ctrl_col_pick.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_COL_PICK_H
#define RZ_CTRL_COL_PICK_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
/**
* Class handling a Color Picker
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlColPick : public CCtrlBase
{
public:
CCtrlColPick(const TCtorParam &param);
~CCtrlColPick();
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 updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
sint32 getColorR () const { return _ColorSelect.R; }
sint32 getColorG () const { return _ColorSelect.G; }
sint32 getColorB () const { return _ColorSelect.B; }
sint32 getColorA () const { return _ColorSelect.A; }
void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; }
void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; }
void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; }
void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; }
std::string getColor () const; // Get Color Selected
void setColor (const std::string &col); // Set Color Selected
std::string getColorOver () const; // Get Color Over
void setColorOver (const std::string &col); // Set Color Over
REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase)
REFLECT_SINT32("r", getColorR, setColorR);
REFLECT_SINT32("g", getColorG, setColorG);
REFLECT_SINT32("b", getColorB, setColorB);
REFLECT_SINT32("a", getColorA, setColorA);
REFLECT_STRING("color", getColor, setColor);
REFLECT_STRING("color_over", getColorOver, setColorOver);
REFLECT_EXPORT_END
protected:
void selectColor (sint32 x, sint32 y);
NLMISC::CRGBA getColor (sint32 x, sint32 y);
protected:
bool _MouseDown;
sint32 _Texture;
NLMISC::CRGBA _ColorSelect; // Last Color selected
NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer
std::string _AHOnChange;
std::string _AHOnChangeParams;
CInterfaceProperty _ColSelR;
CInterfaceProperty _ColSelG;
CInterfaceProperty _ColSelB;
CInterfaceProperty _ColSelA;
};
}
#endif // RZ_CTRL_COL_PICK_H
/* End of ctrl_col_pick.h */

@ -1,64 +1,64 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CTRL_DRAGGABLE_H
#define CTRL_DRAGGABLE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CCtrlDraggable : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlDraggable )
CCtrlDraggable( const TCtorParam &param );
virtual ~CCtrlDraggable(){};
static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; }
bool isDragged() const{ return dragged; }
void setDragged( bool dragged ){ this->dragged = dragged; }
bool isDraggable() const{ return draggable; }
void setDraggable( bool draggable ){ this->draggable = draggable; }
void abortDragging()
{
dragged = false;
_LastDraggedSheet = NULL;
}
// Necessary because of reflection, no other purpose
void draw(){}
REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase)
REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END
protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
private:
static CCtrlDraggable *_LastDraggedSheet;
bool dragged;
bool draggable;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CTRL_DRAGGABLE_H
#define CTRL_DRAGGABLE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CCtrlDraggable : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlDraggable )
CCtrlDraggable( const TCtorParam &param );
virtual ~CCtrlDraggable(){};
static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; }
bool isDragged() const{ return dragged; }
void setDragged( bool dragged ){ this->dragged = dragged; }
bool isDraggable() const{ return draggable; }
void setDraggable( bool draggable ){ this->draggable = draggable; }
void abortDragging()
{
dragged = false;
_LastDraggedSheet = NULL;
}
// Necessary because of reflection, no other purpose
void draw(){}
REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase)
REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END
protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
private:
static CCtrlDraggable *_LastDraggedSheet;
bool dragged;
bool draggable;
};
}
#endif

@ -1,94 +1,94 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_POLYGON_H
#define RZ_CTRL_POLYGON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
#include "nel/misc/polygon.h"
namespace NLMISC
{
class CVector2f;
}
namespace NLGUI
{
/** Display of an arbitrary polygon in the ui.
* polygons are clipped & batched.
*
* Derives from CCtrlBase in order to provide button / tooltip capability
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 1/2006
*/
class CCtrlPolygon : public CCtrlBase
{
public:
CCtrlPolygon();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords();
virtual void draw();
/** Change the vertices. This is costly because concav / complex polys are split in a list of triangles
*/
void setVertices(const std::vector<NLMISC::CVector> &vertices);
const std::vector<NLMISC::CVector> &getVertices() const { return _Poly.Vertices; }
// test if current position in inside the current (transformed) poly (in window space)
bool contains(const NLMISC::CVector2f &pos) const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha(sint32 a);
/** Change the matrix for this poly. Changing the matrix is usually cheaper than changing
* The vertices because complex poly do not have to be split again
*/
//void setMatrix(const NLMISC::CMatrix &mat);
//const NLMISC::CMatrix &getMatrix() const { return _Matrix; }
// test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself)
bool isValid() const { return _Valid; }
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CPolygon _Poly;
NLMISC::CPolygon2D _XFormPoly;
//NLMISC::CMatrix _Matrix;
bool _Valid;
bool _Touched;
NLMISC::CRGBA _Color;
std::vector<NLMISC::CTriangle> _Tris;
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
private:
void updateBoudingRect();
protected:
// TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ...
virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src);
public:
void touch();
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_POLYGON_H
#define RZ_CTRL_POLYGON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
#include "nel/misc/polygon.h"
namespace NLMISC
{
class CVector2f;
}
namespace NLGUI
{
/** Display of an arbitrary polygon in the ui.
* polygons are clipped & batched.
*
* Derives from CCtrlBase in order to provide button / tooltip capability
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 1/2006
*/
class CCtrlPolygon : public CCtrlBase
{
public:
CCtrlPolygon();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords();
virtual void draw();
/** Change the vertices. This is costly because concav / complex polys are split in a list of triangles
*/
void setVertices(const std::vector<NLMISC::CVector> &vertices);
const std::vector<NLMISC::CVector> &getVertices() const { return _Poly.Vertices; }
// test if current position in inside the current (transformed) poly (in window space)
bool contains(const NLMISC::CVector2f &pos) const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha(sint32 a);
/** Change the matrix for this poly. Changing the matrix is usually cheaper than changing
* The vertices because complex poly do not have to be split again
*/
//void setMatrix(const NLMISC::CMatrix &mat);
//const NLMISC::CMatrix &getMatrix() const { return _Matrix; }
// test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself)
bool isValid() const { return _Valid; }
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CPolygon _Poly;
NLMISC::CPolygon2D _XFormPoly;
//NLMISC::CMatrix _Matrix;
bool _Valid;
bool _Touched;
NLMISC::CRGBA _Color;
std::vector<NLMISC::CTriangle> _Tris;
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
private:
void updateBoudingRect();
protected:
// TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ...
virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src);
public:
void touch();
};
}
#endif

@ -1,116 +1,116 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_QUAD_H
#define RZ_CTRL_QUAD_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
namespace NLGUI
{
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
* are driven by the quad vertices coordinates (see setQuad).
*
* Derives from CCtrlBase for tooltipping support
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 12/2005
*/
class CCtrlQuad : public CCtrlBase
{
public:
enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount };
CCtrlQuad();
// from CInterfaceElement
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
virtual void updateCoords();
virtual void draw();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
// texture
void setTexture(const std::string &texName);
std::string getTexture () const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
/** Set a new quad relative to parent pos
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
*/
void setQuad(const NLMISC::CQuad &quad);
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
/** Fit the given texture size (no hotspot for now, always centered)
* NB : current texture is not modified.
*/
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
const NLMISC::CQuad &getQuad() const { return _Quad; }
void setAdditif(bool additif);
bool getAdditif() const { return _Additif; }
void setFiltered(bool filtered);
bool getFiltered() const { return _Filtered; }
void setPattern(float umin, float umax, TWrapMode wrapMode);
/** Set uvs for each corners -> this will change the wrap mode to CustomUVs
* Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior
*/
void setCustomUVs(const NLMISC::CUV uvs[4]);
// from CCtrlBase, no op by default
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// see if this control contains the given point (in parent coords)
bool contains(const NLMISC::CVector2f &pos) const;
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CRGBA _Color;
NLMISC::CQuad _Quad;
NLMISC::CQuadUV _RealQuad; // absolute coords
float _ClampedUCorrection;
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _Additif;
bool _Filtered;
float _UMin;
float _UMax;
TWrapMode _WrapMode;
NLMISC::CUV _CustomUVs[4];
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_QUAD_H
#define RZ_CTRL_QUAD_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
namespace NLGUI
{
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
* are driven by the quad vertices coordinates (see setQuad).
*
* Derives from CCtrlBase for tooltipping support
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 12/2005
*/
class CCtrlQuad : public CCtrlBase
{
public:
enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount };
CCtrlQuad();
// from CInterfaceElement
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
virtual void updateCoords();
virtual void draw();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
// texture
void setTexture(const std::string &texName);
std::string getTexture () const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
/** Set a new quad relative to parent pos
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
*/
void setQuad(const NLMISC::CQuad &quad);
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
/** Fit the given texture size (no hotspot for now, always centered)
* NB : current texture is not modified.
*/
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
const NLMISC::CQuad &getQuad() const { return _Quad; }
void setAdditif(bool additif);
bool getAdditif() const { return _Additif; }
void setFiltered(bool filtered);
bool getFiltered() const { return _Filtered; }
void setPattern(float umin, float umax, TWrapMode wrapMode);
/** Set uvs for each corners -> this will change the wrap mode to CustomUVs
* Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior
*/
void setCustomUVs(const NLMISC::CUV uvs[4]);
// from CCtrlBase, no op by default
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// see if this control contains the given point (in parent coords)
bool contains(const NLMISC::CVector2f &pos) const;
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CRGBA _Color;
NLMISC::CQuad _Quad;
NLMISC::CQuadUV _RealQuad; // absolute coords
float _ClampedUCorrection;
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _Additif;
bool _Filtered;
float _UMin;
float _UMax;
TWrapMode _WrapMode;
NLMISC::CUV _CustomUVs[4];
};
}
#endif

@ -1,206 +1,206 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_SCROLL_H
#define RZ_CTRL_SCROLL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_scroll_base.h"
namespace NLGUI
{
/**
* Class handling scollbar function
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
DECLARE_UI_CLASS( CCtrlScroll )
CCtrlScroll(const TCtorParam &param);
~CCtrlScroll();
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 updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setTarget (CInterfaceGroup *pIG);
// Return the delta value the track has moved
sint32 moveTrackX (sint32 dx);
sint32 moveTrackY (sint32 dy);
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
void moveTargetX (sint32 dx);
void moveTargetY (sint32 dy);
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
// invert the factor for target
void setInverted(bool invert) { _Inverted = invert; }
void setTextureBottomOrLeft (const std::string &txName);
void setTextureMiddle (const std::string &txName);
void setTextureTopOrRight (const std::string &txName);
std::string getTextureBottomOrLeft() const;
std::string getTextureMiddle() const;
std::string getTextureTopOrRight() const;
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
// number scroller
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
void setValue(sint32 value);
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
void setStepValue(uint32 step) { _StepValue= step; }
void setTrackPos(sint32 pos);
sint32 getTrackPos() const { return _TrackPos; }
sint32 getTrackSize() const { return _TrackSize; }
// dummy set for track size (forlua export)
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
int luaSetTarget(CLuaState &ls);
int luaEnsureVisible(CLuaState &ls);
// name
void setName(const std::string & val) {_Name = val;}
std::string getName() const {return _Name;}
// max
void setMax(sint32 max) {_Max = max;}
sint32 getMax() const {return _Max;}
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
REFLECT_SINT32("value", getValue, setValue);
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
REFLECT_STRING("name", getName, setName);
REFLECT_SINT32("max", getMax, setMax);
REFLECT_EXPORT_END
/** Ensure that a child element be visible into the frame through which
* its parent group is displayed.
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
* matching the middle of the list, we would do :
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
*
* The scrollbar will be moved accordingly.
*/
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
protected:
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
sint32 _Value; // Or we can use a normal value
sint32 _InitialValue;
sint32 _Min, _Max;
std::string _AHOnScroll;
std::string _AHOnScrollParams;
//
std::string _AHOnScrollEnd;
std::string _AHOnScrollEndParams;
//
//
std::string _AHOnScrollCancel;
std::string _AHOnScrollCancelParams;
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos;
sint32 _TrackPos;
sint32 _TrackSize;
sint32 _TrackSizeMin;
sint32 _MouseDownOffsetX;
sint32 _MouseDownOffsetY;
sint32 _TxIdB; // Same as Left if Horizontal sb
sint32 _TxIdM;
sint32 _TxIdT; // Same as Right if Horizontal sb
uint8 _TileM;
sint32 _LastTargetHReal;
sint32 _LastTargetMaxHReal;
sint32 _LastTargetOfsY;
sint32 _LastTargetWReal;
sint32 _LastTargetMaxWReal;
sint32 _LastTargetOfsX;
bool _Vertical : 1; // true if vertical track bar
bool _IsDBLink : 1;
bool _ObserverOn : 1;
bool _Inverted : 1;
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;
sint32 _TargetStepY;
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
uint32 _StepValue;
// Slider's name
std::string _Name;
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);
void runAH(const std::string &name, const std::string &params);
};
}
#endif // RZ_CTRL_SCROLL_H
/* End of ctrl_scroll.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_SCROLL_H
#define RZ_CTRL_SCROLL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_scroll_base.h"
namespace NLGUI
{
/**
* Class handling scollbar function
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
DECLARE_UI_CLASS( CCtrlScroll )
CCtrlScroll(const TCtorParam &param);
~CCtrlScroll();
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 updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setTarget (CInterfaceGroup *pIG);
// Return the delta value the track has moved
sint32 moveTrackX (sint32 dx);
sint32 moveTrackY (sint32 dy);
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
void moveTargetX (sint32 dx);
void moveTargetY (sint32 dy);
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
// invert the factor for target
void setInverted(bool invert) { _Inverted = invert; }
void setTextureBottomOrLeft (const std::string &txName);
void setTextureMiddle (const std::string &txName);
void setTextureTopOrRight (const std::string &txName);
std::string getTextureBottomOrLeft() const;
std::string getTextureMiddle() const;
std::string getTextureTopOrRight() const;
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
// number scroller
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
void setValue(sint32 value);
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
void setStepValue(uint32 step) { _StepValue= step; }
void setTrackPos(sint32 pos);
sint32 getTrackPos() const { return _TrackPos; }
sint32 getTrackSize() const { return _TrackSize; }
// dummy set for track size (forlua export)
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
int luaSetTarget(CLuaState &ls);
int luaEnsureVisible(CLuaState &ls);
// name
void setName(const std::string & val) {_Name = val;}
std::string getName() const {return _Name;}
// max
void setMax(sint32 max) {_Max = max;}
sint32 getMax() const {return _Max;}
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
REFLECT_SINT32("value", getValue, setValue);
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
REFLECT_STRING("name", getName, setName);
REFLECT_SINT32("max", getMax, setMax);
REFLECT_EXPORT_END
/** Ensure that a child element be visible into the frame through which
* its parent group is displayed.
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
* matching the middle of the list, we would do :
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
*
* The scrollbar will be moved accordingly.
*/
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
protected:
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
sint32 _Value; // Or we can use a normal value
sint32 _InitialValue;
sint32 _Min, _Max;
std::string _AHOnScroll;
std::string _AHOnScrollParams;
//
std::string _AHOnScrollEnd;
std::string _AHOnScrollEndParams;
//
//
std::string _AHOnScrollCancel;
std::string _AHOnScrollCancelParams;
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos;
sint32 _TrackPos;
sint32 _TrackSize;
sint32 _TrackSizeMin;
sint32 _MouseDownOffsetX;
sint32 _MouseDownOffsetY;
sint32 _TxIdB; // Same as Left if Horizontal sb
sint32 _TxIdM;
sint32 _TxIdT; // Same as Right if Horizontal sb
uint8 _TileM;
sint32 _LastTargetHReal;
sint32 _LastTargetMaxHReal;
sint32 _LastTargetOfsY;
sint32 _LastTargetWReal;
sint32 _LastTargetMaxWReal;
sint32 _LastTargetOfsX;
bool _Vertical : 1; // true if vertical track bar
bool _IsDBLink : 1;
bool _ObserverOn : 1;
bool _Inverted : 1;
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;
sint32 _TargetStepY;
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
uint32 _StepValue;
// Slider's name
std::string _Name;
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);
void runAH(const std::string &name, const std::string &params);
};
}
#endif // RZ_CTRL_SCROLL_H
/* End of ctrl_scroll.h */

@ -1,60 +1,60 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CTRL_SCROLL_BASE_H
#define CTRL_SCROLL_BASE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlScrollBase )
CCtrlScrollBase( const TCtorParam &param );
virtual ~CCtrlScrollBase();
virtual void setTarget( CInterfaceGroup *pIG );
CInterfaceGroup* getTarget(){ return _Target; }
virtual sint32 moveTrackX( sint32 dx );
virtual sint32 moveTrackY( sint32 dy );
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
virtual void moveTargetX( sint32 dx );
virtual void moveTargetY( sint32 dy );
// Necessary because of reflection, no other purpose
void draw(){}
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
private:
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CTRL_SCROLL_BASE_H
#define CTRL_SCROLL_BASE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlScrollBase )
CCtrlScrollBase( const TCtorParam &param );
virtual ~CCtrlScrollBase();
virtual void setTarget( CInterfaceGroup *pIG );
CInterfaceGroup* getTarget(){ return _Target; }
virtual sint32 moveTrackX( sint32 dx );
virtual sint32 moveTrackY( sint32 dy );
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
virtual void moveTargetX( sint32 dx );
virtual void moveTargetY( sint32 dy );
// Necessary because of reflection, no other purpose
void draw(){}
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
private:
};
}
#endif

@ -1,83 +1,83 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_SHEET_CTRL_SELECTION_H
#define CL_SHEET_CTRL_SELECTION_H
namespace NLGUI
{
class IActionHandler;
/** Infos about a selection group
*/
class CSheetSelectionGroup
{
public:
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
void setTexture(const std::string &texName);
sint32 getTextureIndex() const { return _TextureIndex; }
sint32 getTextureWidth() const { return _TextureWidth; }
sint32 getTextureHeight() const { return _TextureHeight; }
void setColor(NLMISC::CRGBA color) { _Color = color; }
NLMISC::CRGBA getColor() const { return _Color; }
void setActive(bool active) { _Active = active; }
bool isActive() const { return _Active; }
const std::string &getName() const { return _Name; }
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
private:
std::string _Name;
bool _Active;
sint32 _TextureIndex; // index for the selection texture
sint32 _TextureWidth;
sint32 _TextureHeight;
NLMISC::CRGBA _Color; // color that modulate the texture of selection
bool _GlobalColorEnabled;
};
/** Class to manage selection of sheet.
* Sheet are managed by groups, identified by their ID.
*/
class CCtrlSheetSelection
{
public:
// Add a group, and returns its index, or -1 if already created.
sint addGroup(const std::string &name);
// Get a group by its name (must exist)
CSheetSelectionGroup *getGroup(const std::string &name);
const CSheetSelectionGroup *getGroup(const std::string &name) const;
// Get a group by its index
CSheetSelectionGroup *getGroup(uint index);
const CSheetSelectionGroup *getGroup(uint index) const;
// Get the index of a group from its name, return -1 if not a group
sint getGroupIndex(const std::string &name) const;
// Deactivate all groups
void deactivateAll();
// delete all groups
void deleteGroups();
private:
//
typedef std::vector<CSheetSelectionGroup> TGroupVect;
typedef std::map<std::string, uint> TGroupNameToIndex;
private:
TGroupVect _Groups;
TGroupNameToIndex _GroupNameToIndex;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_SHEET_CTRL_SELECTION_H
#define CL_SHEET_CTRL_SELECTION_H
namespace NLGUI
{
class IActionHandler;
/** Infos about a selection group
*/
class CSheetSelectionGroup
{
public:
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
void setTexture(const std::string &texName);
sint32 getTextureIndex() const { return _TextureIndex; }
sint32 getTextureWidth() const { return _TextureWidth; }
sint32 getTextureHeight() const { return _TextureHeight; }
void setColor(NLMISC::CRGBA color) { _Color = color; }
NLMISC::CRGBA getColor() const { return _Color; }
void setActive(bool active) { _Active = active; }
bool isActive() const { return _Active; }
const std::string &getName() const { return _Name; }
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
private:
std::string _Name;
bool _Active;
sint32 _TextureIndex; // index for the selection texture
sint32 _TextureWidth;
sint32 _TextureHeight;
NLMISC::CRGBA _Color; // color that modulate the texture of selection
bool _GlobalColorEnabled;
};
/** Class to manage selection of sheet.
* Sheet are managed by groups, identified by their ID.
*/
class CCtrlSheetSelection
{
public:
// Add a group, and returns its index, or -1 if already created.
sint addGroup(const std::string &name);
// Get a group by its name (must exist)
CSheetSelectionGroup *getGroup(const std::string &name);
const CSheetSelectionGroup *getGroup(const std::string &name) const;
// Get a group by its index
CSheetSelectionGroup *getGroup(uint index);
const CSheetSelectionGroup *getGroup(uint index) const;
// Get the index of a group from its name, return -1 if not a group
sint getGroupIndex(const std::string &name) const;
// Deactivate all groups
void deactivateAll();
// delete all groups
void deleteGroups();
private:
//
typedef std::vector<CSheetSelectionGroup> TGroupVect;
typedef std::map<std::string, uint> TGroupNameToIndex;
private:
TGroupVect _Groups;
TGroupNameToIndex _GroupNameToIndex;
};
}
#endif

@ -1,170 +1,170 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_TEXT_BUTTON_H
#define NL_CTRL_TEXT_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ***************************************************************************
/**
* Text Button that can be either Push or Toggle button. Localized, auto-resize
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CCtrlTextButton : public CCtrlBaseButton
{
public:
/// Constructor
CCtrlTextButton(const TCtorParam &param);
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;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// Display part
virtual void draw();
// Hide/Show the text also.
virtual void setActive(bool state);
// Add also our ViewText
virtual void onAddToGroup();
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Special Text Colors accessors
// Colors
NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;}
void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;}
NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;}
void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;}
NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;}
void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;}
// Shadow Colors
NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;}
void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;}
NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;}
void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;}
NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;}
void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;}
// Global Modulate Colors
bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;}
void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;}
bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;}
void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;}
bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;}
void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;}
// Set text (noop if text id)
void setText (const ucstring &text);
ucstring getText () const;
void setHardText (const std::string &text);
std::string getHardText () const;
CViewText* getViewText();
void setViewText(CViewText* text) {_ViewText=text;}
void setTextX(sint32 x);
sint32 getTextX() const { return _TextX; }
void setWMargin(sint32 w) { _WMargin = w; }
sint32 getWMargin() const { return _WMargin; }
sint32 getWMin() const { return _WMin; }
void setWMin( sint32 wmin ) { _WMin = wmin; }
// Compute Size according to bitmap and Text (Ensure as big as possible button)
sint32 getWMax() const;
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
REFLECT_UCSTRING("uc_hardtext", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
REFLECT_EXPORT_END
protected:
enum {NumTexture= 3};
CViewRenderer::CTextureId _TextureIdNormal[NumTexture];
CViewRenderer::CTextureId _TextureIdPushed[NumTexture];
CViewRenderer::CTextureId _TextureIdOver[NumTexture];
// setup
void setup();
private:
CViewText *_ViewText;
bool _Setuped;
bool _IsViewTextId;
bool _ForceTextOver; // text is displayed over the "over" texture
// Size of Bitmaps
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
// Value to add to TextW to get button W.
sint32 _WMargin;
// Min W Value
sint32 _WMin;
sint32 _TextY;
sint32 _TextX;
THotSpot _TextPosRef;
THotSpot _TextParentPosRef;
// Special Colors for text
NLMISC::CRGBA _TextColorNormal;
NLMISC::CRGBA _TextColorPushed;
NLMISC::CRGBA _TextColorOver;
NLMISC::CRGBA _TextShadowColorNormal;
NLMISC::CRGBA _TextShadowColorPushed;
NLMISC::CRGBA _TextShadowColorOver;
bool _TextModulateGlobalColorNormal;
bool _TextModulateGlobalColorPushed;
bool _TextModulateGlobalColorOver;
bool _TextHeaderColor;
};
}
#endif // NL_CTRL_TEXT_BUTTON_H
/* End of ctrl_text_button.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_TEXT_BUTTON_H
#define NL_CTRL_TEXT_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ***************************************************************************
/**
* Text Button that can be either Push or Toggle button. Localized, auto-resize
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CCtrlTextButton : public CCtrlBaseButton
{
public:
/// Constructor
CCtrlTextButton(const TCtorParam &param);
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;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// Display part
virtual void draw();
// Hide/Show the text also.
virtual void setActive(bool state);
// Add also our ViewText
virtual void onAddToGroup();
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Special Text Colors accessors
// Colors
NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;}
void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;}
NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;}
void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;}
NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;}
void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;}
// Shadow Colors
NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;}
void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;}
NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;}
void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;}
NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;}
void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;}
// Global Modulate Colors
bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;}
void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;}
bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;}
void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;}
bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;}
void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;}
// Set text (noop if text id)
void setText (const ucstring &text);
ucstring getText () const;
void setHardText (const std::string &text);
std::string getHardText () const;
CViewText* getViewText();
void setViewText(CViewText* text) {_ViewText=text;}
void setTextX(sint32 x);
sint32 getTextX() const { return _TextX; }
void setWMargin(sint32 w) { _WMargin = w; }
sint32 getWMargin() const { return _WMargin; }
sint32 getWMin() const { return _WMin; }
void setWMin( sint32 wmin ) { _WMin = wmin; }
// Compute Size according to bitmap and Text (Ensure as big as possible button)
sint32 getWMax() const;
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
REFLECT_UCSTRING("uc_hardtext", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
REFLECT_EXPORT_END
protected:
enum {NumTexture= 3};
CViewRenderer::CTextureId _TextureIdNormal[NumTexture];
CViewRenderer::CTextureId _TextureIdPushed[NumTexture];
CViewRenderer::CTextureId _TextureIdOver[NumTexture];
// setup
void setup();
private:
CViewText *_ViewText;
bool _Setuped;
bool _IsViewTextId;
bool _ForceTextOver; // text is displayed over the "over" texture
// Size of Bitmaps
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
// Value to add to TextW to get button W.
sint32 _WMargin;
// Min W Value
sint32 _WMin;
sint32 _TextY;
sint32 _TextX;
THotSpot _TextPosRef;
THotSpot _TextParentPosRef;
// Special Colors for text
NLMISC::CRGBA _TextColorNormal;
NLMISC::CRGBA _TextColorPushed;
NLMISC::CRGBA _TextColorOver;
NLMISC::CRGBA _TextShadowColorNormal;
NLMISC::CRGBA _TextShadowColorPushed;
NLMISC::CRGBA _TextShadowColorOver;
bool _TextModulateGlobalColorNormal;
bool _TextModulateGlobalColorPushed;
bool _TextModulateGlobalColorOver;
bool _TextHeaderColor;
};
}
#endif // NL_CTRL_TEXT_BUTTON_H
/* End of ctrl_text_button.h */

@ -1,59 +1,59 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_TOOLTIP_H
#define RZ_CTRL_TOOLTIP_H
#include "nel/gui/ctrl_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
/**
* \author Matthieu 'Mr TRAP' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlToolTip : public CCtrlBase
{
public:
DECLARE_UI_CLASS(CCtrlToolTip)
/// Constructor
CCtrlToolTip(const TCtorParam &param) : CCtrlBase(param) {}
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void draw();
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
// Can do nothing with tooltip (but display it :) )
virtual bool isCapturable() const {return false;}
virtual void serial(NLMISC::IStream &f);
public:
};
}
#endif // RZ_CTRL_TOOLTIP_H
/* End of ctrl_tooltip.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_TOOLTIP_H
#define RZ_CTRL_TOOLTIP_H
#include "nel/gui/ctrl_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
/**
* \author Matthieu 'Mr TRAP' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlToolTip : public CCtrlBase
{
public:
DECLARE_UI_CLASS(CCtrlToolTip)
/// Constructor
CCtrlToolTip(const TCtorParam &param) : CCtrlBase(param) {}
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void draw();
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
// Can do nothing with tooltip (but display it :) )
virtual bool isCapturable() const {return false;}
virtual void serial(NLMISC::IStream &f);
public:
};
}
#endif // RZ_CTRL_TOOLTIP_H
/* End of ctrl_tooltip.h */

@ -1,71 +1,71 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef DBMANAGER_H
#define DBMANAGER_H
#include "nel/misc/cdb_manager.h"
namespace NLGUI
{
/**
Database Manager
Provides access to a simple CDB based tree hierarchical data store
*/
class CDBManager : public NLMISC::CCDBManager
{
public:
static CDBManager* getInstance();
static void release();
/**
Retrieves a leaf node from the database.
@param name - name of the data leaf node we are querying.
@param create - when true if a node cannot be found it is created.
*/
NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true );
/**
Deletes a node from the database.
@param name - name of the node.
*/
void delDbProp( const std::string &name );
/**
Returns a leaf node's content as an sint32
@param name - name of the leaf node.
*/
sint32 getDbValue32( const std::string &name );
/**
Returns the root branch of the database.
*/
NLMISC::CCDBNodeBranch* getDB() const;
private:
CDBManager();
~CDBManager();
static CDBManager *instance;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef DBMANAGER_H
#define DBMANAGER_H
#include "nel/misc/cdb_manager.h"
namespace NLGUI
{
/**
Database Manager
Provides access to a simple CDB based tree hierarchical data store
*/
class CDBManager : public NLMISC::CCDBManager
{
public:
static CDBManager* getInstance();
static void release();
/**
Retrieves a leaf node from the database.
@param name - name of the data leaf node we are querying.
@param create - when true if a node cannot be found it is created.
*/
NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true );
/**
Deletes a node from the database.
@param name - name of the node.
*/
void delDbProp( const std::string &name );
/**
Returns a leaf node's content as an sint32
@param name - name of the leaf node.
*/
sint32 getDbValue32( const std::string &name );
/**
Returns the root branch of the database.
*/
NLMISC::CCDBNodeBranch* getDB() const;
private:
CDBManager();
~CDBManager();
static CDBManager *instance;
};
}
#endif

@ -1,169 +1,169 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_COMBO_BOX_H
#define NL_DBGROUP_COMBO_BOX_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CGroupMenu;
// ***************************************************************************
/**
* Widget: ComboBox of text
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupComboBox : public CInterfaceGroup
{
public:
/// Constructor
CDBGroupComboBox(const TCtorParam &param);
~CDBGroupComboBox();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
// Combo Texts
void resetTexts();
void addText(const ucstring &text);
void setText(uint i, const ucstring &text);
void insertText(uint i, const ucstring &text);
const ucstring &getText(uint i) const;
const uint &getTextId(uint i) const;
uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const;
void removeText(uint nPos);
uint getNumTexts() const {return (uint)_Texts.size();}
void sortText();
// selection
void setSelection(sint32 val);
void setSelectionNoTrigger(sint32 val);
sint32 getSelection() const;
// selection number
void setSelectionNb(sint32 /* val */){}
sint32 getSelectionNb() const {return (sint32)_Texts.size();}
// selection text
void setSelectionText(const std::string & val);
std::string getSelectionText() const;
// view text
void setViewText(const ucstring & text);
ucstring getViewText() const;
void setTexture(uint i, const ucstring &texture);
sint32 evalContentWidth() const;
int luaAddText(CLuaState &ls);
int luaRemoveSelection(CLuaState &ls);
int luaRemoveText(CLuaState &ls);
int luaRemoveTextByIndex(CLuaState &ls);
int luaResetTexts(CLuaState &ls);
int luaSetText(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaGetText(CLuaState &ls);
int luaGetNumTexts(CLuaState &ls);
int luaSetTexture(CLuaState &ls);
REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup)
REFLECT_SINT32("selection", getSelection, setSelection)
REFLECT_LUA_METHOD("addText", luaAddText)
REFLECT_LUA_METHOD("setText", luaSetText)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("setTexture", luaSetTexture)
REFLECT_LUA_METHOD("getText", luaGetText)
REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts)
REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection)
REFLECT_LUA_METHOD("removeText", luaRemoveText)
REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex)
REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText)
REFLECT_UCSTRING ("view_text", getViewText, setViewText)
REFLECT_EXPORT_END
protected:
friend class CHandlerComboBoxSelectStart;
bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead
bool _Setuped;
bool _DirtySelection;
sint32 _CacheSelection;
// sint32
CInterfaceProperty _Selection;
sint32 _NotLinkedToDBSelection;
std::vector<std::pair<uint, ucstring> > _Texts;
std::vector<ucstring> _Textures;
// Action Handler called on combo click
std::string _AHOnSelectStart;
// Action handler called when the content is changed
std::string _AHOnChange;
std::string _AHOnChangeParams;
bool _CallingOnChangeActionHandler; // avoid infinite loop here
// Children
CViewText *_ViewText;
CCtrlBaseButton *_SelectButton;
bool _IsExternViewText;
ucstring _ExternViewText;
private:
void setup();
void dirt();
public:
// private : fill a menu with current content
void fillMenu(CGroupMenu *groupMenu) const;
static std::string measureMenu;
static std::string selectMenu;
static std::string selectMenuOut;
};
}
#endif // NL_DBGROUP_COMBO_BOX_H
/* End of dbgroup_combo_box.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_COMBO_BOX_H
#define NL_DBGROUP_COMBO_BOX_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CGroupMenu;
// ***************************************************************************
/**
* Widget: ComboBox of text
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupComboBox : public CInterfaceGroup
{
public:
/// Constructor
CDBGroupComboBox(const TCtorParam &param);
~CDBGroupComboBox();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
// Combo Texts
void resetTexts();
void addText(const ucstring &text);
void setText(uint i, const ucstring &text);
void insertText(uint i, const ucstring &text);
const ucstring &getText(uint i) const;
const uint &getTextId(uint i) const;
uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const;
void removeText(uint nPos);
uint getNumTexts() const {return (uint)_Texts.size();}
void sortText();
// selection
void setSelection(sint32 val);
void setSelectionNoTrigger(sint32 val);
sint32 getSelection() const;
// selection number
void setSelectionNb(sint32 /* val */){}
sint32 getSelectionNb() const {return (sint32)_Texts.size();}
// selection text
void setSelectionText(const std::string & val);
std::string getSelectionText() const;
// view text
void setViewText(const ucstring & text);
ucstring getViewText() const;
void setTexture(uint i, const ucstring &texture);
sint32 evalContentWidth() const;
int luaAddText(CLuaState &ls);
int luaRemoveSelection(CLuaState &ls);
int luaRemoveText(CLuaState &ls);
int luaRemoveTextByIndex(CLuaState &ls);
int luaResetTexts(CLuaState &ls);
int luaSetText(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaGetText(CLuaState &ls);
int luaGetNumTexts(CLuaState &ls);
int luaSetTexture(CLuaState &ls);
REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup)
REFLECT_SINT32("selection", getSelection, setSelection)
REFLECT_LUA_METHOD("addText", luaAddText)
REFLECT_LUA_METHOD("setText", luaSetText)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("setTexture", luaSetTexture)
REFLECT_LUA_METHOD("getText", luaGetText)
REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts)
REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection)
REFLECT_LUA_METHOD("removeText", luaRemoveText)
REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex)
REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText)
REFLECT_UCSTRING ("view_text", getViewText, setViewText)
REFLECT_EXPORT_END
protected:
friend class CHandlerComboBoxSelectStart;
bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead
bool _Setuped;
bool _DirtySelection;
sint32 _CacheSelection;
// sint32
CInterfaceProperty _Selection;
sint32 _NotLinkedToDBSelection;
std::vector<std::pair<uint, ucstring> > _Texts;
std::vector<ucstring> _Textures;
// Action Handler called on combo click
std::string _AHOnSelectStart;
// Action handler called when the content is changed
std::string _AHOnChange;
std::string _AHOnChangeParams;
bool _CallingOnChangeActionHandler; // avoid infinite loop here
// Children
CViewText *_ViewText;
CCtrlBaseButton *_SelectButton;
bool _IsExternViewText;
ucstring _ExternViewText;
private:
void setup();
void dirt();
public:
// private : fill a menu with current content
void fillMenu(CGroupMenu *groupMenu) const;
static std::string measureMenu;
static std::string selectMenu;
static std::string selectMenuOut;
};
}
#endif // NL_DBGROUP_COMBO_BOX_H
/* End of dbgroup_combo_box.h */

@ -1,100 +1,100 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_SELECT_NUMBER_H
#define NL_DBGROUP_SELECT_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CViewBitmap;
// ***************************************************************************
/**
* Widget to select a number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupSelectNumber : public CInterfaceGroup
{
public:
/// Constructor
CDBGroupSelectNumber(const TCtorParam &param);
~CDBGroupSelectNumber();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// mod interface
void changeValue(sint delta);
sint32 getMinValue () const { return _MinValue; }
void setMinValue (sint32 m) { _MinValue = m; }
sint32 getMaxValue () const { return _MaxValue; }
void setMaxValue (sint32 m) { _MaxValue = m; }
sint32 getCurrentValue () const { return _Number.getSInt32(); }
void setCurrentValue (sint32 val) { _Number.setSInt32(val); }
REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup)
REFLECT_SINT32("min", getMinValue, setMinValue);
REFLECT_SINT32("max", getMaxValue, setMaxValue);
REFLECT_EXPORT_END
protected:
// sint32
CInterfaceProperty _Number;
bool _LoopMode;
sint _MinValue;
sint _MaxValue;
sint _DeltaMultiplier;
// Children
CViewBitmap *_SlotNumber;
CViewText *_TextNumber;
CCtrlBaseButton *_ButtonUp;
CCtrlBaseButton *_ButtonDown;
private:
void setup();
};
}
#endif // NL_DBGROUP_SELECT_NUMBER_H
/* End of dbgroup_select_number.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_SELECT_NUMBER_H
#define NL_DBGROUP_SELECT_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CViewBitmap;
// ***************************************************************************
/**
* Widget to select a number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupSelectNumber : public CInterfaceGroup
{
public:
/// Constructor
CDBGroupSelectNumber(const TCtorParam &param);
~CDBGroupSelectNumber();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// mod interface
void changeValue(sint delta);
sint32 getMinValue () const { return _MinValue; }
void setMinValue (sint32 m) { _MinValue = m; }
sint32 getMaxValue () const { return _MaxValue; }
void setMaxValue (sint32 m) { _MaxValue = m; }
sint32 getCurrentValue () const { return _Number.getSInt32(); }
void setCurrentValue (sint32 val) { _Number.setSInt32(val); }
REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup)
REFLECT_SINT32("min", getMinValue, setMinValue);
REFLECT_SINT32("max", getMaxValue, setMaxValue);
REFLECT_EXPORT_END
protected:
// sint32
CInterfaceProperty _Number;
bool _LoopMode;
sint _MinValue;
sint _MaxValue;
sint _DeltaMultiplier;
// Children
CViewBitmap *_SlotNumber;
CViewText *_TextNumber;
CCtrlBaseButton *_ButtonUp;
CCtrlBaseButton *_ButtonDown;
private:
void setup();
};
}
#endif // NL_DBGROUP_SELECT_NUMBER_H
/* End of dbgroup_select_number.h */

@ -1,115 +1,115 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR_H
#define RZ_DBVIEW_BAR_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a bitmap used as the front texture of a progress bar
* the bitmap is drawn from _X to _W * _Range/_RangeMax
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CDBViewBar : public CViewBitmap
{
public:
enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick };
public:
/// Constructor
CDBViewBar(const TCtorParam &param)
: CViewBitmap(param),
_Slot(TCtorParam())
{
_Color= NLMISC::CRGBA::White;
_ValueInt= 0;
_RangeInt = 255;
_ReferenceInt= 0;
_Type = ViewBar_Normal;
}
void setType (TViewBar vb);
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue (sint32 r) { _ValueInt = r; }
void setRange (sint32 r) { _RangeInt = r; }
void setReference (sint32 r) { _ReferenceInt = r; }
sint32 getValue () const { return _ValueInt; }
sint32 getRange () const { return _RangeInt; }
sint32 getReference () const { return _ReferenceInt; }
void setValueDbLink (const std::string &r);
void setRangeDbLink (const std::string &r);
void setReferenceDbLink (const std::string &r);
std::string getValueDbLink () const;
std::string getRangeDbLink () const;
std::string getReferenceDbLink () const;
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar, CViewBitmap)
REFLECT_SINT32 ("value", getValue, setValue);
REFLECT_SINT32 ("range", getRange, setRange);
REFLECT_SINT32 ("reference", getReference, setReference);
REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink);
REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink);
REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink);
REFLECT_EXPORT_END
protected:
CViewBitmap _Slot;
TViewBar _Type;
sint32 _HBar;
NLMISC::CRGBA _ColorNegative;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value;
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range;
// Reference of the progression (substracted from value and range).
CInterfaceProperty _Reference;
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt;
sint32 _RangeInt;
sint32 _ReferenceInt;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
};
}
#endif // RZ_DBVIEW_BAR_H
/* End of dbview_bar.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR_H
#define RZ_DBVIEW_BAR_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a bitmap used as the front texture of a progress bar
* the bitmap is drawn from _X to _W * _Range/_RangeMax
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CDBViewBar : public CViewBitmap
{
public:
enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick };
public:
/// Constructor
CDBViewBar(const TCtorParam &param)
: CViewBitmap(param),
_Slot(TCtorParam())
{
_Color= NLMISC::CRGBA::White;
_ValueInt= 0;
_RangeInt = 255;
_ReferenceInt= 0;
_Type = ViewBar_Normal;
}
void setType (TViewBar vb);
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue (sint32 r) { _ValueInt = r; }
void setRange (sint32 r) { _RangeInt = r; }
void setReference (sint32 r) { _ReferenceInt = r; }
sint32 getValue () const { return _ValueInt; }
sint32 getRange () const { return _RangeInt; }
sint32 getReference () const { return _ReferenceInt; }
void setValueDbLink (const std::string &r);
void setRangeDbLink (const std::string &r);
void setReferenceDbLink (const std::string &r);
std::string getValueDbLink () const;
std::string getRangeDbLink () const;
std::string getReferenceDbLink () const;
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar, CViewBitmap)
REFLECT_SINT32 ("value", getValue, setValue);
REFLECT_SINT32 ("range", getRange, setRange);
REFLECT_SINT32 ("reference", getReference, setReference);
REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink);
REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink);
REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink);
REFLECT_EXPORT_END
protected:
CViewBitmap _Slot;
TViewBar _Type;
sint32 _HBar;
NLMISC::CRGBA _ColorNegative;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value;
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range;
// Reference of the progression (substracted from value and range).
CInterfaceProperty _Reference;
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt;
sint32 _RangeInt;
sint32 _ReferenceInt;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
};
}
#endif // RZ_DBVIEW_BAR_H
/* End of dbview_bar.h */

@ -1,110 +1,110 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR3_H
#define RZ_DBVIEW_BAR3_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a 3 Bar widget
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CDBViewBar3 : public CViewBitmap
{
public:
/// Constructor
CDBViewBar3(const TCtorParam &param);
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
void setMini (bool mini);
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue0 (sint32 r) { _ValueInt[0] = r; }
void setValue1 (sint32 r) { _ValueInt[1] = r; }
void setValue2 (sint32 r) { _ValueInt[2] = r; }
void setRange0 (sint32 r) { _RangeInt[0] = r; }
void setRange1 (sint32 r) { _RangeInt[1] = r; }
void setRange2 (sint32 r) { _RangeInt[2] = r; }
sint32 getValue0 () const { return _ValueInt[0]; }
sint32 getValue1 () const { return _ValueInt[1]; }
sint32 getValue2 () const { return _ValueInt[2]; }
sint32 getRange0 () const { return _RangeInt[0]; }
sint32 getRange1 () const { return _RangeInt[1]; }
sint32 getRange2 () const { return _RangeInt[2]; }
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap)
REFLECT_SINT32 ("value1", getValue0, setValue0);
REFLECT_SINT32 ("value2", getValue1, setValue1);
REFLECT_SINT32 ("value3", getValue2, setValue2);
REFLECT_SINT32 ("range1", getRange0, setRange0);
REFLECT_SINT32 ("range2", getRange1, setRange1);
REFLECT_SINT32 ("range3", getRange2, setRange2);
REFLECT_EXPORT_END
static void forceLink();
protected:
CViewBitmap _Slot;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value[3];
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range[3];
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt[3];
sint32 _RangeInt[3];
NLMISC::CRGBA _Colors[3];
NLMISC::CRGBA _ColorsNegative[3];
bool _Mini;
// Height of the bitmap
sint32 _BarH;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
void setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp );
sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
std::string getValProp( const CInterfaceProperty &prop, sint32 intProp ) const;
};
}
#endif // RZ_DBVIEW_BAR3_H
/* End of dbview_bar3.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR3_H
#define RZ_DBVIEW_BAR3_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a 3 Bar widget
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CDBViewBar3 : public CViewBitmap
{
public:
/// Constructor
CDBViewBar3(const TCtorParam &param);
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
void setMini (bool mini);
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue0 (sint32 r) { _ValueInt[0] = r; }
void setValue1 (sint32 r) { _ValueInt[1] = r; }
void setValue2 (sint32 r) { _ValueInt[2] = r; }
void setRange0 (sint32 r) { _RangeInt[0] = r; }
void setRange1 (sint32 r) { _RangeInt[1] = r; }
void setRange2 (sint32 r) { _RangeInt[2] = r; }
sint32 getValue0 () const { return _ValueInt[0]; }
sint32 getValue1 () const { return _ValueInt[1]; }
sint32 getValue2 () const { return _ValueInt[2]; }
sint32 getRange0 () const { return _RangeInt[0]; }
sint32 getRange1 () const { return _RangeInt[1]; }
sint32 getRange2 () const { return _RangeInt[2]; }
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap)
REFLECT_SINT32 ("value1", getValue0, setValue0);
REFLECT_SINT32 ("value2", getValue1, setValue1);
REFLECT_SINT32 ("value3", getValue2, setValue2);
REFLECT_SINT32 ("range1", getRange0, setRange0);
REFLECT_SINT32 ("range2", getRange1, setRange1);
REFLECT_SINT32 ("range3", getRange2, setRange2);
REFLECT_EXPORT_END
static void forceLink();
protected:
CViewBitmap _Slot;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value[3];
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range[3];
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt[3];
sint32 _RangeInt[3];
NLMISC::CRGBA _Colors[3];
NLMISC::CRGBA _ColorsNegative[3];
bool _Mini;
// Height of the bitmap
sint32 _BarH;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
void setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp );
sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
std::string getValProp( const CInterfaceProperty &prop, sint32 intProp ) const;
};
}
#endif // RZ_DBVIEW_BAR3_H
/* End of dbview_bar3.h */

@ -1,67 +1,67 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_DIGIT_H
#define NL_DBVIEW_DIGIT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A number displayed with special bitmaps
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewDigit : public CViewBase
{
public:
/// Constructor
CDBViewDigit(const TCtorParam &param);
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 draw ();
virtual void updateCoords();
protected:
CInterfaceProperty _Number;
sint32 _Cache;
sint32 _NumDigit;
NLMISC::CRGBA _Color;
// space between each digit
sint32 _WSpace;
// The texture digit for the current number
sint32 _DigitId[10];
uint _DivBase;
};
}
#endif // NL_DBVIEW_DIGIT_H
/* End of dbview_digit.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_DIGIT_H
#define NL_DBVIEW_DIGIT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A number displayed with special bitmaps
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewDigit : public CViewBase
{
public:
/// Constructor
CDBViewDigit(const TCtorParam &param);
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 draw ();
virtual void updateCoords();
protected:
CInterfaceProperty _Number;
sint32 _Cache;
sint32 _NumDigit;
NLMISC::CRGBA _Color;
// space between each digit
sint32 _WSpace;
// The texture digit for the current number
sint32 _DigitId[10];
uint _DivBase;
};
}
#endif // NL_DBVIEW_DIGIT_H
/* End of dbview_digit.h */

@ -1,77 +1,77 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_NUMBER_H
#define NL_DBVIEW_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text from a database number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewNumber : public CViewText
{
public:
/// Constructor
CDBViewNumber(const TCtorParam &param);
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 draw ();
void link (const std::string &dbprop)
{
_Number.link (dbprop.c_str());
}
static void forceLink();
protected:
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
else return (_Number.getSInt64() / _Divisor)%_Modulo; }
protected:
CInterfaceProperty _Number;
sint64 _Cache;
bool _Positive; // only positive values are displayed
bool _Format; // the number will be formatted (like "1,000,000") if >= 10k
sint64 _Divisor, _Modulo;
// string to append to the value (eg: meters)
CStringShared _Suffix;
CStringShared _Prefix;
};
}
#endif // NL_DBVIEW_NUMBER_H
/* End of dbview_number.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_NUMBER_H
#define NL_DBVIEW_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text from a database number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewNumber : public CViewText
{
public:
/// Constructor
CDBViewNumber(const TCtorParam &param);
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 draw ();
void link (const std::string &dbprop)
{
_Number.link (dbprop.c_str());
}
static void forceLink();
protected:
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
else return (_Number.getSInt64() / _Divisor)%_Modulo; }
protected:
CInterfaceProperty _Number;
sint64 _Cache;
bool _Positive; // only positive values are displayed
bool _Format; // the number will be formatted (like "1,000,000") if >= 10k
sint64 _Divisor, _Modulo;
// string to append to the value (eg: meters)
CStringShared _Suffix;
CStringShared _Prefix;
};
}
#endif // NL_DBVIEW_NUMBER_H
/* End of dbview_number.h */

@ -1,65 +1,65 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_QUANTITY_H
#define NL_DBVIEW_QUANTITY_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text in the form of val / max or "empty"
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewQuantity : public CViewText
{
public:
/// Constructor
CDBViewQuantity(const TCtorParam &param);
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 draw ();
static void forceLink();
protected:
CInterfaceProperty _Number;
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
ucstring _EmptyText;
void buildTextFromCache();
};
}
#endif // NL_DBVIEW_QUANTITY_H
/* End of dbview_quantity.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_QUANTITY_H
#define NL_DBVIEW_QUANTITY_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text in the form of val / max or "empty"
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewQuantity : public CViewText
{
public:
/// Constructor
CDBViewQuantity(const TCtorParam &param);
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 draw ();
static void forceLink();
protected:
CInterfaceProperty _Number;
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
ucstring _EmptyText;
void buildTextFromCache();
};
}
#endif // NL_DBVIEW_QUANTITY_H
/* End of dbview_quantity.h */

@ -1,257 +1,257 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_EVENT_DESCRIPTOR_H
#define RZ_EVENT_DESCRIPTOR_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CEventDescriptor
{
public:
enum EEventType
{
key = 0,
mouse = 1,
system = 2
};
EEventType getType() const
{
return _EventType;
}
protected:
//type of the event
EEventType _EventType;
};
/** encode key events.
*/
class CEventDescriptorKey : public CEventDescriptor
{
public:
enum EKeyEventType
{
keydown = 0, // a key has been press down. The key value is stored as a TKey
keyup, // a key has been released. The key value is stored as a TKey
keychar, // a key has been stroke. The key is a ucchar
keystring, // a string has been sent. The string is a ucstring
unknown, // uninitialized event
};
CEventDescriptorKey() : _KeyEvent(unknown)
{
_EventType = key;
}
// ctrcuct from a CEventKey obj
CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown)
{
_EventType = key;
init(ev);
}
// get the type of the key event
EKeyEventType getKeyEventType() const { return _KeyEvent; }
// return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert
NLMISC::TKey getKey() const
{
nlassert(_KeyEvent == keydown || _KeyEvent == keyup);
return _Key;
}
// return the char that has been pressed. The key event type MUST be 'keychar', else => assert
ucchar getChar() const
{
nlassert(_KeyEvent == keychar);
return _Char;
}
// return the string that has been sent. The key event type MUST be 'keystring', else => assert
ucstring getString() const
{
nlassert(_KeyEvent == keystring);
return _String;
}
bool getKeyCtrl() const // is CTRL pressed ?
{
return _CtrlState;
}
bool getKeyShift() const // is SHIFT (right or left) pressed ?
{
return _ShiftState;
}
bool getKeyAlt() const // is ALT (right or left) pressed ?
{
return _AltState;
}
// init from a CEventKey obj
void init(const NLMISC::CEventKey &ev);
private:
EKeyEventType _KeyEvent;
bool _CtrlState;
bool _ShiftState;
bool _AltState;
union
{
NLMISC::TKey _Key;
ucchar _Char;
};
ucstring _String;
};
// ----------------------------------------------------------------------------
class CEventDescriptorMouse : public CEventDescriptor
{
public:
enum EEventTypeExtended
{
mouseleftdown=0,
mouseleftup=1,
mouserightdown=2,
mouserightup=3,
mousewheel=4, // Complementary info stored in wheel
mousemove=5, // Complementary info stored in x and y
mouseleftdblclk= 6,
mouserightdblclk= 7,
};
CEventDescriptorMouse()
{
_EventType = mouse;
_X = _Y = _Wheel = 0;
}
CEventDescriptorMouse (sint32 x, sint32 y)
{
_X = x;
_Y = y;
}
sint32 getX() const
{
return _X;
}
sint32 getY() const
{
return _Y;
}
sint32 getWheel() const
{
return _Wheel;
}
sint32 getEventTypeExtended() const
{
return _EventTypeExtended;
}
void setX (sint32 x)
{
_X = x;
}
void setY (sint32 y)
{
_Y = y;
}
void setWheel (sint32 w)
{
_Wheel = w;
}
void setEventTypeExtended (sint32 e)
{
_EventTypeExtended = e;
}
protected:
sint32 _X;
sint32 _Y;
sint32 _Wheel;
sint32 _EventTypeExtended;
};
// ----------------------------------------------------------------------------
class CEventDescriptorSystem : public CEventDescriptor
{
public:
enum EEventTypeExtended
{
activecalledonparent= 0,
clocktick,
setfocus,
unknown
};
sint32 getEventTypeExtended() const
{
return _EventTypeExtended;
}
void setEventTypeExtended (sint32 e)
{
_EventTypeExtended = e;
}
CEventDescriptorSystem() : _EventTypeExtended(unknown)
{
_EventType = system;
}
protected:
sint32 _EventTypeExtended;
};
// ----------------------------------------------------------------------------
class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem
{
public:
bool getActive() const { return _Active; }
void setActive(bool active) { _Active = active; }
CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active)
{
setEventTypeExtended(activecalledonparent);
}
protected:
bool _Active;
};
// ----------------------------------------------------------------------------
class CEventDescriptorSetFocus : public CEventDescriptorSystem
{
public:
bool hasFocus() const { return _HasFocus; }
CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus)
{
setEventTypeExtended(setfocus);
}
protected:
bool _HasFocus;
};
}
#endif // RZ_EVENT_DESCRIPTOR_H
/* End of event_descriptor.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_EVENT_DESCRIPTOR_H
#define RZ_EVENT_DESCRIPTOR_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CEventDescriptor
{
public:
enum EEventType
{
key = 0,
mouse = 1,
system = 2
};
EEventType getType() const
{
return _EventType;
}
protected:
//type of the event
EEventType _EventType;
};
/** encode key events.
*/
class CEventDescriptorKey : public CEventDescriptor
{
public:
enum EKeyEventType
{
keydown = 0, // a key has been press down. The key value is stored as a TKey
keyup, // a key has been released. The key value is stored as a TKey
keychar, // a key has been stroke. The key is a ucchar
keystring, // a string has been sent. The string is a ucstring
unknown, // uninitialized event
};
CEventDescriptorKey() : _KeyEvent(unknown)
{
_EventType = key;
}
// ctrcuct from a CEventKey obj
CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown)
{
_EventType = key;
init(ev);
}
// get the type of the key event
EKeyEventType getKeyEventType() const { return _KeyEvent; }
// return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert
NLMISC::TKey getKey() const
{
nlassert(_KeyEvent == keydown || _KeyEvent == keyup);
return _Key;
}
// return the char that has been pressed. The key event type MUST be 'keychar', else => assert
ucchar getChar() const
{
nlassert(_KeyEvent == keychar);
return _Char;
}
// return the string that has been sent. The key event type MUST be 'keystring', else => assert
ucstring getString() const
{
nlassert(_KeyEvent == keystring);
return _String;
}
bool getKeyCtrl() const // is CTRL pressed ?
{
return _CtrlState;
}
bool getKeyShift() const // is SHIFT (right or left) pressed ?
{
return _ShiftState;
}
bool getKeyAlt() const // is ALT (right or left) pressed ?
{
return _AltState;
}
// init from a CEventKey obj
void init(const NLMISC::CEventKey &ev);
private:
EKeyEventType _KeyEvent;
bool _CtrlState;
bool _ShiftState;
bool _AltState;
union
{
NLMISC::TKey _Key;
ucchar _Char;
};
ucstring _String;
};
// ----------------------------------------------------------------------------
class CEventDescriptorMouse : public CEventDescriptor
{
public:
enum EEventTypeExtended
{
mouseleftdown=0,
mouseleftup=1,
mouserightdown=2,
mouserightup=3,
mousewheel=4, // Complementary info stored in wheel
mousemove=5, // Complementary info stored in x and y
mouseleftdblclk= 6,
mouserightdblclk= 7,
};
CEventDescriptorMouse()
{
_EventType = mouse;
_X = _Y = _Wheel = 0;
}
CEventDescriptorMouse (sint32 x, sint32 y)
{
_X = x;
_Y = y;
}
sint32 getX() const
{
return _X;
}
sint32 getY() const
{
return _Y;
}
sint32 getWheel() const
{
return _Wheel;
}
sint32 getEventTypeExtended() const
{
return _EventTypeExtended;
}
void setX (sint32 x)
{
_X = x;
}
void setY (sint32 y)
{
_Y = y;
}
void setWheel (sint32 w)
{
_Wheel = w;
}
void setEventTypeExtended (sint32 e)
{
_EventTypeExtended = e;
}
protected:
sint32 _X;
sint32 _Y;
sint32 _Wheel;
sint32 _EventTypeExtended;
};
// ----------------------------------------------------------------------------
class CEventDescriptorSystem : public CEventDescriptor
{
public:
enum EEventTypeExtended
{
activecalledonparent= 0,
clocktick,
setfocus,
unknown
};
sint32 getEventTypeExtended() const
{
return _EventTypeExtended;
}
void setEventTypeExtended (sint32 e)
{
_EventTypeExtended = e;
}
CEventDescriptorSystem() : _EventTypeExtended(unknown)
{
_EventType = system;
}
protected:
sint32 _EventTypeExtended;
};
// ----------------------------------------------------------------------------
class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem
{
public:
bool getActive() const { return _Active; }
void setActive(bool active) { _Active = active; }
CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active)
{
setEventTypeExtended(activecalledonparent);
}
protected:
bool _Active;
};
// ----------------------------------------------------------------------------
class CEventDescriptorSetFocus : public CEventDescriptorSystem
{
public:
bool hasFocus() const { return _HasFocus; }
CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus)
{
setEventTypeExtended(setfocus);
}
protected:
bool _HasFocus;
};
}
#endif // RZ_EVENT_DESCRIPTOR_H
/* End of event_descriptor.h */

@ -1,44 +1,44 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef EVENT_LISTENER
#define EVENT_LISTENER
#include "nel/misc/event_listener.h"
#include "nel/gui/input_handler.h"
namespace NLGUI
{
class CEventListener : public NLMISC::IEventListener
{
public:
CEventListener();
~CEventListener();
void addToServer( NLMISC::CEventServer *server );
void removeFromServer();
void operator()( const NLMISC::CEvent &evnt );
private:
NLGUI::CInputHandler inputHandler;
NLMISC::CEventServer *eventServer;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef EVENT_LISTENER
#define EVENT_LISTENER
#include "nel/misc/event_listener.h"
#include "nel/gui/input_handler.h"
namespace NLGUI
{
class CEventListener : public NLMISC::IEventListener
{
public:
CEventListener();
~CEventListener();
void addToServer( NLMISC::CEventServer *server );
void removeFromServer();
void operator()( const NLMISC::CEvent &evnt );
private:
NLGUI::CInputHandler inputHandler;
NLMISC::CEventServer *eventServer;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,117 +1,117 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_CONTAINER_BASE_H
#define GROUP_CONTAINER_BASE_H
#include "nel/gui/interface_group.h"
#include "nel/misc/rgba.h"
namespace NLGUI
{
class CGroupContainerBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase();
virtual void removeAllContainers();
virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
// for export
sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; }
sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; }
sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; }
sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; }
// sin32 versions for export
void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); }
void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); }
void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); }
void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup )
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_EXPORT_END
virtual bool isMoving() const{ return false; }
// Get the header color draw. NB: depends if grayed, and if active.
virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); };
uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; }
uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; }
virtual bool isGrayed() const{ return false; }
virtual bool getTouchFlag(bool clearFlag) const{ return false; }
virtual void backupPosition(){}
virtual void restorePosition(){}
protected:
void triggerAlphaSettingsChangedAH();
uint8 _CurrentContainerAlpha;
uint8 _CurrentContentAlpha;
uint8 _ContainerAlpha;
uint8 _ContentAlpha;
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
bool _UseGlobalAlpha : 1;
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private:
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_CONTAINER_BASE_H
#define GROUP_CONTAINER_BASE_H
#include "nel/gui/interface_group.h"
#include "nel/misc/rgba.h"
namespace NLGUI
{
class CGroupContainerBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase();
virtual void removeAllContainers();
virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
// for export
sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; }
sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; }
sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; }
sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; }
// sin32 versions for export
void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); }
void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); }
void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); }
void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup )
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_EXPORT_END
virtual bool isMoving() const{ return false; }
// Get the header color draw. NB: depends if grayed, and if active.
virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); };
uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; }
uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; }
virtual bool isGrayed() const{ return false; }
virtual bool getTouchFlag(bool clearFlag) const{ return false; }
virtual void backupPosition(){}
virtual void restorePosition(){}
protected:
void triggerAlphaSettingsChangedAH();
uint8 _CurrentContainerAlpha;
uint8 _CurrentContentAlpha;
uint8 _ContainerAlpha;
uint8 _ContentAlpha;
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
bool _UseGlobalAlpha : 1;
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private:
};
}
#endif

@ -1,368 +1,368 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_EDITBOX_H
#define RZ_CTRL_EDITBOX_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_editbox_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ----------------------------------------------------------------------------
class CGroupEditBox : public CGroupEditBoxBase
{
public:
class IComboKeyHandler
{
public:
virtual ~IComboKeyHandler(){}
virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0;
};
enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with
DECLARE_UI_CLASS( CGroupEditBox )
/// Constructor
CGroupEditBox(const TCtorParam &param);
/// Dtor
~CGroupEditBox();
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors
ucstring getInputString() const { return _InputString; }
const ucstring &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; }
/** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n'
*/
void setPrompt(const ucstring &s) { _Prompt = s; }
void setInputString(const ucstring &str);
void setInputStringRef(const ucstring &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val);
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
void setInputStringAsStdString(const std::string &str);
std::string getInputStringAsStdString() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
void setColor(NLMISC::CRGBA col);
/// force the selection of all the text
void setSelectionAll();
virtual void checkCoords();
virtual void updateCoords();
virtual void clearViews ();
virtual void setActive (bool state);
static CGroupEditBox *getMenuFather() { return _MenuFather; }
void setCommand(const ucstring &command, bool execute);
// Stop parent from blinking
void stopParentBlink() { if (_Parent) _Parent->disableBlink(); }
// Get / set cursor position
sint32 getCursorPos () const {return _CursorPos;}
void setCursorPos (sint32 pos) {_CursorPos=pos;}
// Get / set cursor at previous line end
bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;}
void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;}
// Get / set current selection position
static sint32 getSelectCursorPos () {return _SelectCursorPos;}
static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;}
// Get the view text
const CViewText *getViewText () const {return _ViewText;}
// Get the historic information
sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
const ucstring &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler
const std::string &getAHOnChange() const {return _AHOnChange;}
const std::string &getParamsOnChange() const {return _ParamsOnChange;}
void cutSelection();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Copy the selection into buffer
void copy();
// Paste the selection into buffer
void paste();
// Write the string into buffer
void writeString(const ucstring &str, bool replace = true, bool atEnd = true);
// Expand the expression (true if there was a '/' at the start of the line)
bool expand();
// Back space
void back();
// ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant)
void bypassNextKey() { _BypassNextKey = true; }
// True if the editBox loose the focus on enter
bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;}
//
virtual void clearAllEditBox();
// From CInterfaceElement
virtual bool wantSerialConfig() const;
// From CInterfaceElement
virtual void serialConfig(NLMISC::IStream &f);
// From CInterfaceElement
virtual void onQuit();
// From CInterfaceElement
virtual void onLoadConfig();
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
// from CCtrlBase
virtual void onKeyboardCaptureLost();
// set the input string as "default". will be reseted at first click (used for user information)
void setDefaultInputString(const ucstring &str);
// For Interger and PositiveInteger, can specify min and max values
void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;}
void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;}
void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;}
void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;}
void setFocusOnText();
int luaSetSelectionAll(CLuaState &ls);
int luaSetupDisplayText(CLuaState &ls);
int luaSetFocusOnText(CLuaState &ls);
int luaCancelFocusOnText(CLuaState &ls);
REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase)
REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText);
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString);
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
REFLECT_EXPORT_END
/** Restore the original value of the edit box.
* This value is captured when the edit box get focus
* (return true if no undo was available)
* Will always fails ifthe edito box do not have the focus
*/
bool undo();
/** Cancel last undo operation
* Return true if redo operation is available
*/
bool redo();
/// freeze the control (loose focus, and cannot edit)
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
protected:
// Cursor infos
float _BlinkTime;
sint32 _CursorPos;
uint32 _MaxNumChar;
uint32 _MaxNumReturn;
uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only
sint32 _MaxCharsSize;
sint32 _FirstVisibleChar;
sint32 _LastVisibleChar;
// Text selection
static sint32 _SelectCursorPos;
bool _SelectingText;
NLMISC::CRGBA _TextSelectColor;
NLMISC::CRGBA _BackSelectColor;
// Text info
ucstring _Prompt;
ucstring _InputString;
CViewText *_ViewText;
// undo / redo
ucstring _StartInputString; // value of the input string when focus was acuired first
ucstring _ModifiedInputString;
// Historic info
typedef std::deque<ucstring> THistoric;
THistoric _Historic;
uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex;
sint32 _PrevNumLine;
// Action Handler
std::string _AHOnChange;
std::string _ParamsOnChange;
std::string _ListMenuRight;
std::string _AHOnFocusLost;
std::string _AHOnFocusLostParams;
// entry type
TEntryType _EntryType;
bool _Setupped : 1; // setup
bool _BypassNextKey : 1;
bool _BlinkState : 1;
bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines)
bool _LooseFocusOnEnter : 1;
bool _ResetFocusOnHide : 1;
bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed.
// If the edit box is at the bottom of the screen and if it expands on y
// because of multiline, thz parent container will be moved to top
// The good position can be restored by a press on enter then
bool _WantReturn : 1; // Want return char, don't call the enter action handler
bool _Savable : 1; // should content be saved ?
bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited)
bool _Frozen : 1; // is the control frozen? (cannot edit in it)
bool _CanRedo : 1;
bool _CanUndo : 1;
std::vector<char> _NegativeFilter;
sint _CursorTexID;
sint32 _CursorWidth;
sint32 _IntegerMinValue;
sint32 _IntegerMaxValue;
uint32 _PositiveIntegerMinValue;
uint32 _PositiveIntegerMaxValue;
sint32 _ViewTextDeltaX;
private:
void setupDisplayText();
void makeTopWindow();
void handleEventChar(const NLGUI::CEventDescriptorKey &event);
void handleEventString(const NLGUI::CEventDescriptorKey &event);
void setup();
void triggerOnChangeAH();
void appendStringFromClipboard(const ucstring &str);
ucstring getSelection();
static CGroupEditBox *_MenuFather;
static bool isValidAlphaNumSpace(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z') ||
ac==' ';
}
static bool isValidAlphaNum(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidAlpha(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidPlayerNameChar(ucchar c)
{
// valid player name (with possible shard prefix / suffix format
return isValidAlpha(c) || c=='.' || c=='(' || c==')';
}
static bool isValidFilenameChar(ucchar c)
{
if (c == '\\' ||
c == '/' ||
c == ':' ||
c == '*' ||
c == '?' ||
c == '\"' ||
c == '<' ||
c == '>' ||
c == '|') return false;
return true;
}
//
bool isFiltered(ucchar c)
{
uint length = (uint)_NegativeFilter.size();
for (uint k = 0; k < length; ++k)
{
if ((ucchar) _NegativeFilter[k] == c) return true;
}
return false;
}
static IComboKeyHandler *comboKeyHandler;
public:
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
};
}
#endif // RZ_CTRL_EDITBOX_H
/* End of ctrl_editbox.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_EDITBOX_H
#define RZ_CTRL_EDITBOX_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_editbox_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ----------------------------------------------------------------------------
class CGroupEditBox : public CGroupEditBoxBase
{
public:
class IComboKeyHandler
{
public:
virtual ~IComboKeyHandler(){}
virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0;
};
enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with
DECLARE_UI_CLASS( CGroupEditBox )
/// Constructor
CGroupEditBox(const TCtorParam &param);
/// Dtor
~CGroupEditBox();
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;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors
ucstring getInputString() const { return _InputString; }
const ucstring &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; }
/** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n'
*/
void setPrompt(const ucstring &s) { _Prompt = s; }
void setInputString(const ucstring &str);
void setInputStringRef(const ucstring &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val);
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
void setInputStringAsStdString(const std::string &str);
std::string getInputStringAsStdString() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
void setColor(NLMISC::CRGBA col);
/// force the selection of all the text
void setSelectionAll();
virtual void checkCoords();
virtual void updateCoords();
virtual void clearViews ();
virtual void setActive (bool state);
static CGroupEditBox *getMenuFather() { return _MenuFather; }
void setCommand(const ucstring &command, bool execute);
// Stop parent from blinking
void stopParentBlink() { if (_Parent) _Parent->disableBlink(); }
// Get / set cursor position
sint32 getCursorPos () const {return _CursorPos;}
void setCursorPos (sint32 pos) {_CursorPos=pos;}
// Get / set cursor at previous line end
bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;}
void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;}
// Get / set current selection position
static sint32 getSelectCursorPos () {return _SelectCursorPos;}
static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;}
// Get the view text
const CViewText *getViewText () const {return _ViewText;}
// Get the historic information
sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
const ucstring &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler
const std::string &getAHOnChange() const {return _AHOnChange;}
const std::string &getParamsOnChange() const {return _ParamsOnChange;}
void cutSelection();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Copy the selection into buffer
void copy();
// Paste the selection into buffer
void paste();
// Write the string into buffer
void writeString(const ucstring &str, bool replace = true, bool atEnd = true);
// Expand the expression (true if there was a '/' at the start of the line)
bool expand();
// Back space
void back();
// ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant)
void bypassNextKey() { _BypassNextKey = true; }
// True if the editBox loose the focus on enter
bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;}
//
virtual void clearAllEditBox();
// From CInterfaceElement
virtual bool wantSerialConfig() const;
// From CInterfaceElement
virtual void serialConfig(NLMISC::IStream &f);
// From CInterfaceElement
virtual void onQuit();
// From CInterfaceElement
virtual void onLoadConfig();
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
// from CCtrlBase
virtual void onKeyboardCaptureLost();
// set the input string as "default". will be reseted at first click (used for user information)
void setDefaultInputString(const ucstring &str);
// For Interger and PositiveInteger, can specify min and max values
void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;}
void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;}
void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;}
void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;}
void setFocusOnText();
int luaSetSelectionAll(CLuaState &ls);
int luaSetupDisplayText(CLuaState &ls);
int luaSetFocusOnText(CLuaState &ls);
int luaCancelFocusOnText(CLuaState &ls);
REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase)
REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText);
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString);
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
REFLECT_EXPORT_END
/** Restore the original value of the edit box.
* This value is captured when the edit box get focus
* (return true if no undo was available)
* Will always fails ifthe edito box do not have the focus
*/
bool undo();
/** Cancel last undo operation
* Return true if redo operation is available
*/
bool redo();
/// freeze the control (loose focus, and cannot edit)
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
protected:
// Cursor infos
float _BlinkTime;
sint32 _CursorPos;
uint32 _MaxNumChar;
uint32 _MaxNumReturn;
uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only
sint32 _MaxCharsSize;
sint32 _FirstVisibleChar;
sint32 _LastVisibleChar;
// Text selection
static sint32 _SelectCursorPos;
bool _SelectingText;
NLMISC::CRGBA _TextSelectColor;
NLMISC::CRGBA _BackSelectColor;
// Text info
ucstring _Prompt;
ucstring _InputString;
CViewText *_ViewText;
// undo / redo
ucstring _StartInputString; // value of the input string when focus was acuired first
ucstring _ModifiedInputString;
// Historic info
typedef std::deque<ucstring> THistoric;
THistoric _Historic;
uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex;
sint32 _PrevNumLine;
// Action Handler
std::string _AHOnChange;
std::string _ParamsOnChange;
std::string _ListMenuRight;
std::string _AHOnFocusLost;
std::string _AHOnFocusLostParams;
// entry type
TEntryType _EntryType;
bool _Setupped : 1; // setup
bool _BypassNextKey : 1;
bool _BlinkState : 1;
bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines)
bool _LooseFocusOnEnter : 1;
bool _ResetFocusOnHide : 1;
bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed.
// If the edit box is at the bottom of the screen and if it expands on y
// because of multiline, thz parent container will be moved to top
// The good position can be restored by a press on enter then
bool _WantReturn : 1; // Want return char, don't call the enter action handler
bool _Savable : 1; // should content be saved ?
bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited)
bool _Frozen : 1; // is the control frozen? (cannot edit in it)
bool _CanRedo : 1;
bool _CanUndo : 1;
std::vector<char> _NegativeFilter;
sint _CursorTexID;
sint32 _CursorWidth;
sint32 _IntegerMinValue;
sint32 _IntegerMaxValue;
uint32 _PositiveIntegerMinValue;
uint32 _PositiveIntegerMaxValue;
sint32 _ViewTextDeltaX;
private:
void setupDisplayText();
void makeTopWindow();
void handleEventChar(const NLGUI::CEventDescriptorKey &event);
void handleEventString(const NLGUI::CEventDescriptorKey &event);
void setup();
void triggerOnChangeAH();
void appendStringFromClipboard(const ucstring &str);
ucstring getSelection();
static CGroupEditBox *_MenuFather;
static bool isValidAlphaNumSpace(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z') ||
ac==' ';
}
static bool isValidAlphaNum(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidAlpha(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidPlayerNameChar(ucchar c)
{
// valid player name (with possible shard prefix / suffix format
return isValidAlpha(c) || c=='.' || c=='(' || c==')';
}
static bool isValidFilenameChar(ucchar c)
{
if (c == '\\' ||
c == '/' ||
c == ':' ||
c == '*' ||
c == '?' ||
c == '\"' ||
c == '<' ||
c == '>' ||
c == '|') return false;
return true;
}
//
bool isFiltered(ucchar c)
{
uint length = (uint)_NegativeFilter.size();
for (uint k = 0; k < length; ++k)
{
if ((ucchar) _NegativeFilter[k] == c) return true;
}
return false;
}
static IComboKeyHandler *comboKeyHandler;
public:
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
};
}
#endif // RZ_CTRL_EDITBOX_H
/* End of ctrl_editbox.h */

@ -1,67 +1,67 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_EDITBOX_BASE_H
#define GROUP_EDITBOX_BASE_H
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CGroupEditBoxBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupEditBoxBase )
CGroupEditBoxBase( const TCtorParam &param );
~CGroupEditBoxBase();
// True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus
bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; }
void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; }
std::string getAHOnFocus(){ return _AHOnFocus; }
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
// disable any current selection
static void disableSelection(){ _CurrSelection = NULL; }
// Get / set current selection
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
void draw(){}
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
protected:
bool _RecoverFocusOnEnter : 1;
std::string _AHOnFocus;
std::string _AHOnFocusParams;
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_EDITBOX_BASE_H
#define GROUP_EDITBOX_BASE_H
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CGroupEditBoxBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupEditBoxBase )
CGroupEditBoxBase( const TCtorParam &param );
~CGroupEditBoxBase();
// True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus
bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; }
void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; }
std::string getAHOnFocus(){ return _AHOnFocus; }
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
// disable any current selection
static void disableSelection(){ _CurrSelection = NULL; }
// Get / set current selection
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
void draw(){}
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
protected:
bool _RecoverFocusOnEnter : 1;
std::string _AHOnFocus;
std::string _AHOnFocusParams;
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
};
}
#endif

@ -1,118 +1,118 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_FRAME_H
#define NL_GROUP_FRAME_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
{
public:
/// Constructor
CGroupFrame(const TCtorParam &param);
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 draw ();
void copyOptionFrom(const CGroupFrame &other);
void setupOptions();
void setColorAsString(const std::string & col);
std::string getColorAsString() const;
REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup)
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_EXPORT_END
static void resetDisplayTypes() { _DispTypes.clear(); }
// ******************
protected:
bool _DisplayFrame;
NLMISC::CRGBA _Color;
uint8 _DispType;
std::string _Options;
// Fields Defined in the XML => must not herit them from extends=""
bool _DisplayFrameDefined : 1;
bool _ColorDefined : 1;
bool _DispTypeDefined : 1;
// Static stuff
enum
{
TextTL= 0,
TextTM,
TextTR,
TextML,
TextMM,
TextMR,
TextBL,
TextBM,
TextBR
};
struct SDisplayType
{
std::string Name;
sint32 BorderIds[9];
uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR
sint32 LeftBorder; // enum
sint32 RightBorder;
sint32 TopBorder;
sint32 BottomBorder;
// -----------------------
SDisplayType()
{
for (uint i = 0; i < 9; ++i)
TileBorder[i] = 0;
}
};
static std::vector<SDisplayType> _DispTypes;
};
}
#endif // NL_GROUP_FRAME_H
/* End of group_frame.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_FRAME_H
#define NL_GROUP_FRAME_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
{
public:
/// Constructor
CGroupFrame(const TCtorParam &param);
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 draw ();
void copyOptionFrom(const CGroupFrame &other);
void setupOptions();
void setColorAsString(const std::string & col);
std::string getColorAsString() const;
REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup)
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_EXPORT_END
static void resetDisplayTypes() { _DispTypes.clear(); }
// ******************
protected:
bool _DisplayFrame;
NLMISC::CRGBA _Color;
uint8 _DispType;
std::string _Options;
// Fields Defined in the XML => must not herit them from extends=""
bool _DisplayFrameDefined : 1;
bool _ColorDefined : 1;
bool _DispTypeDefined : 1;
// Static stuff
enum
{
TextTL= 0,
TextTM,
TextTR,
TextML,
TextMM,
TextMR,
TextBL,
TextBM,
TextBR
};
struct SDisplayType
{
std::string Name;
sint32 BorderIds[9];
uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR
sint32 LeftBorder; // enum
sint32 RightBorder;
sint32 TopBorder;
sint32 BottomBorder;
// -----------------------
SDisplayType()
{
for (uint i = 0; i < 9; ++i)
TileBorder[i] = 0;
}
};
static std::vector<SDisplayType> _DispTypes;
};
}
#endif // NL_GROUP_FRAME_H
/* End of group_frame.h */

@ -1,93 +1,93 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HEADER_H
#define CL_GROUP_HEADER_H
#include "nel/gui/group_list.h"
namespace NLGUI
{
class CGroupHeaderEntry;
// *****************************************************************************************************************
/** Display a header with movable entries.
* Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode)
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2006
*/
class CGroupHeader : public CGroupList
{
public:
REFLECT_EXPORT_START(CGroupHeader, CGroupList)
REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns);
REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer);
REFLECT_EXPORT_END
CGroupHeader(const TCtorParam &param);
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;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getHeaderMaxSize() const { return _HeaderMaxSize; }
// get the entries in this header
void getEntries(std::vector<CGroupHeaderEntry *> &dest);
// ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()'
void enlargeColumns(sint32 margin);
// ensure that content of each column is visible
void resizeColumnsAndContainer(sint32 margin);
private:
sint32 _HeaderMaxSize;
int luaEnlargeColumns(CLuaState &ls);
int luaResizeColumnsAndContainer(CLuaState &ls);
};
// *****************************************************************************************************************
// an entry in a header, includes a "mover control" to move it inside its parent header
// NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size'
class CGroupHeaderEntry : public CInterfaceGroup
{
public:
CGroupHeaderEntry(const TCtorParam &param);
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getMinSize() const { return _MinSize; }
virtual void updateCoords();
CInterfaceGroup *getTargetColumn() const;
const std::string &getAHOnResize() const { return _AHOnResize; }
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
private:
sint32 _MinSize;
sint32 _ResizerSize;
std::string _TargetColumnId;
std::string _AHOnResize;
std::string _AHOnResizeParams;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HEADER_H
#define CL_GROUP_HEADER_H
#include "nel/gui/group_list.h"
namespace NLGUI
{
class CGroupHeaderEntry;
// *****************************************************************************************************************
/** Display a header with movable entries.
* Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode)
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2006
*/
class CGroupHeader : public CGroupList
{
public:
REFLECT_EXPORT_START(CGroupHeader, CGroupList)
REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns);
REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer);
REFLECT_EXPORT_END
CGroupHeader(const TCtorParam &param);
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;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getHeaderMaxSize() const { return _HeaderMaxSize; }
// get the entries in this header
void getEntries(std::vector<CGroupHeaderEntry *> &dest);
// ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()'
void enlargeColumns(sint32 margin);
// ensure that content of each column is visible
void resizeColumnsAndContainer(sint32 margin);
private:
sint32 _HeaderMaxSize;
int luaEnlargeColumns(CLuaState &ls);
int luaResizeColumnsAndContainer(CLuaState &ls);
};
// *****************************************************************************************************************
// an entry in a header, includes a "mover control" to move it inside its parent header
// NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size'
class CGroupHeaderEntry : public CInterfaceGroup
{
public:
CGroupHeaderEntry(const TCtorParam &param);
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getMinSize() const { return _MinSize; }
virtual void updateCoords();
CInterfaceGroup *getTargetColumn() const;
const std::string &getAHOnResize() const { return _AHOnResize; }
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
private:
sint32 _MinSize;
sint32 _ResizerSize;
std::string _TargetColumnId;
std::string _AHOnResize;
std::string _AHOnResizeParams;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,270 +1,270 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_LIST_H
#define NL_GROUP_LIST_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CGroupList : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupList(const TCtorParam &param);
// dtor
~CGroupList();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false);
bool delChild(uint index, bool forceDontDelete = false);
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
int luaGetChild(CLuaState &ls);
void deleteAllChildren();
void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
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;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; }
bool getDynamicDisplaySize() { return _DynamicDisplaySize; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
int luaGetElementIndex(CLuaState &ls);
// swap 2 entries in the list (and also their orders)
void swapChildren(uint index1, uint index2);
int luaUpChild(CLuaState &ls);
int luaDownChild(CLuaState &ls);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
// children number
void setChildrenNb(sint32 /* val */){}
sint32 getChildrenNb() const {return (sint32)_Elements.size();}
int luaAddChild(CLuaState &ls);
int luaAddChildAtIndex(CLuaState &ls);
int luaDetachChild(CLuaState &ls);
int luaClear(CLuaState &ls); // synonimous for deleteAllChildren
int luaAddTextChild(CLuaState &ls);
int luaAddColoredTextChild(CLuaState &ls);
int luaDelChild(CLuaState &ls);
REFLECT_EXPORT_START(CGroupList, CInterfaceGroup)
REFLECT_LUA_METHOD("addTextChild", luaAddTextChild)
REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild)
REFLECT_LUA_METHOD("addChild", luaAddChild);
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
REFLECT_LUA_METHOD("clear", luaClear);
REFLECT_LUA_METHOD("delChild", luaDelChild);
REFLECT_LUA_METHOD("upChild", luaUpChild);
REFLECT_LUA_METHOD("downChild", luaDownChild);
REFLECT_LUA_METHOD("getChild", luaGetChild);
REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex);
REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb);
REFLECT_EXPORT_END
protected:
std::string _HardText;
uint32 _TextId;
//max number of elements
sint32 _MaxElements;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Used for context menu to display the same size as the whole content
bool _DynamicDisplaySize;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
private:
void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
void setupSizes();
void onTextChanged();
};
}
#endif // NL_GROUP_LIST_H
/* End of group_list.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_LIST_H
#define NL_GROUP_LIST_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CGroupList : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupList(const TCtorParam &param);
// dtor
~CGroupList();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false);
bool delChild(uint index, bool forceDontDelete = false);
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
int luaGetChild(CLuaState &ls);
void deleteAllChildren();
void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
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;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; }
bool getDynamicDisplaySize() { return _DynamicDisplaySize; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
int luaGetElementIndex(CLuaState &ls);
// swap 2 entries in the list (and also their orders)
void swapChildren(uint index1, uint index2);
int luaUpChild(CLuaState &ls);
int luaDownChild(CLuaState &ls);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
// children number
void setChildrenNb(sint32 /* val */){}
sint32 getChildrenNb() const {return (sint32)_Elements.size();}
int luaAddChild(CLuaState &ls);
int luaAddChildAtIndex(CLuaState &ls);
int luaDetachChild(CLuaState &ls);
int luaClear(CLuaState &ls); // synonimous for deleteAllChildren
int luaAddTextChild(CLuaState &ls);
int luaAddColoredTextChild(CLuaState &ls);
int luaDelChild(CLuaState &ls);
REFLECT_EXPORT_START(CGroupList, CInterfaceGroup)
REFLECT_LUA_METHOD("addTextChild", luaAddTextChild)
REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild)
REFLECT_LUA_METHOD("addChild", luaAddChild);
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
REFLECT_LUA_METHOD("clear", luaClear);
REFLECT_LUA_METHOD("delChild", luaDelChild);
REFLECT_LUA_METHOD("upChild", luaUpChild);
REFLECT_LUA_METHOD("downChild", luaDownChild);
REFLECT_LUA_METHOD("getChild", luaGetChild);
REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex);
REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb);
REFLECT_EXPORT_END
protected:
std::string _HardText;
uint32 _TextId;
//max number of elements
sint32 _MaxElements;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Used for context menu to display the same size as the whole content
bool _DynamicDisplaySize;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
private:
void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
void setupSizes();
void onTextChanged();
};
}
#endif // NL_GROUP_LIST_H
/* End of group_list.h */

@ -1,401 +1,401 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_GROUP_MENU_H
#define RZ_GROUP_MENU_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_modal.h"
#include "nel/gui/group_submenu_base.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlScroll;
class CViewBitmap;
class CGroupList;
class CGroupMenu;
/**
* CViewTextMenu is an element of a sub menu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewTextMenu : public CViewText
{
public:
CViewTextMenu(const TCtorParam &param) : CViewText(param)
{
_Grayed = false;
_Checked = false;
_Checkable = false;
_CheckBox = NULL;
Over = false;
}
bool getGrayed() const;
void setGrayed (bool g);
bool getChecked() const { return _Checked; }
void setChecked(bool c);
bool getCheckable() const { return _Checkable; }
void setCheckable(bool c);
void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; }
CViewBitmap * getCheckBox() const { return _CheckBox; }
bool getFormatted () const { return getMultiLine (); }
virtual sint32 getAlpha() const;
virtual void setAlpha (sint32 a);
REFLECT_EXPORT_START(CViewTextMenu, CViewText)
REFLECT_BOOL("grayed", getGrayed, setGrayed);
REFLECT_BOOL("checked", getChecked, setChecked);
REFLECT_EXPORT_END
public:
bool Over;
NLMISC::CRGBA OldColor;
NLMISC::CRGBA OldShadowColor;
NLMISC::CRGBA OldColorOver;
NLMISC::CRGBA OldShadowColorOver;
NLMISC::CRGBA OldColorGrayed;
NLMISC::CRGBA OldShadowColorGrayed;
private:
CViewBitmap *_CheckBox;
bool _Grayed;
bool _Checked;
bool _Checkable;
};
/**
* CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu)
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupSubMenu : public CGroupSubMenuBase
{
public:
CGroupSubMenu(const TCtorParam &param);
virtual ~CGroupSubMenu();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL);
virtual void checkCoords();
virtual void updateCoords ();
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
// retrieve the index of a line from its id (-1 if not found)
sint getLineFromId(const std::string &id);
CViewTextMenu* addLine (const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
void addSeparator(const std::string &id = "");
void addSeparatorAtIndex(uint index, const std::string &id = "");
uint getNumLine() const { return (uint)_Lines.size(); }
void removeLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void openSubMenu (sint32 nb);
void hideSubMenus ();
// reset all entries of the sub menu
void reset();
virtual void setActive (bool state);
// Tell if the line is a separator or not
bool isSeparator (uint i) const;
/** Set a user defined group at the given line
* 'ownership' tells whether this menu should remove the group when it is deleted
* Setting a user group on a line with a separator is illegal
*/
void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupRight(uint line) const;
//
void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupLeft(uint line) const;
void removeAllUserGroups();
uint getNumLines() const { return (uint)_Lines.size(); }
// return pointer to submenu or NULL if there's none
CGroupSubMenu *getSubMenu(uint index) const;
void setSubMenu(uint index, CGroupSubMenu *sub);
// if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup)
void setSelectable(uint lineIndex, bool selectable);
bool getSelectable(uint lineIndex) const;
// Gray a line.
void setGrayedLine(uint line, bool g);
// Hide a line.
void setHiddenLine(uint line, bool h);
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl);
sint32 getMaxVisibleLine() { return _MaxVisibleLine; }
// Get the Line Id (not the full Id)
const std::string &getLineId(uint index);
int luaGetNumLine(CLuaState &ls);
int luaGetSubMenu(CLuaState &ls);
int luaAddSubMenu(CLuaState &ls);
int luaGetLineId(CLuaState &ls);
int luaGetLineFromId(CLuaState &ls);
int luaIsSeparator(CLuaState &ls);
int luaAddLine(CLuaState &ls);
int luaAddLineAtIndex(CLuaState &ls);
int luaAddSeparator(CLuaState &ls);
int luaAddSeparatorAtIndex(CLuaState &ls);
int luaRemoveLine(CLuaState &ls);
int luaSetUserGroupRight(CLuaState &ls);
int luaGetUserGroupRight(CLuaState &ls);
int luaSetUserGroupLeft(CLuaState &ls);
int luaGetUserGroupLeft(CLuaState &ls);
int luaReset(CLuaState &ls);
int luaSetMaxVisibleLine(CLuaState &ls);
//
REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase)
REFLECT_LUA_METHOD("getNumLine", luaGetNumLine);
REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index
REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found
REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu);
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
REFLECT_LUA_METHOD("removeLine", luaRemoveLine);
REFLECT_LUA_METHOD("reset", luaReset);
REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line
REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line
REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine);
REFLECT_EXPORT_END
protected:
struct SSubMenuEntry
{
CViewTextMenu *ViewText; // Backup of the children that are in grouplist
CInterfaceGroup *Separator;
std::string AHName;
std::string AHParams;
std::string Id;
std::string Cond; // condition to know if the entry is grayed
CViewBitmap *CheckBox;
CViewBitmap *RightArrow;
CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow
CInterfaceGroup *UserGroupLeft;
bool UserGroupRightOwnership;
bool UserGroupLeftOwnership;
bool Selectable;
sint32 HReal; // max H of the view text and the other user group
sint32 TextDY; // Y of the view text to set
SSubMenuEntry()
{
ViewText = NULL;
Separator = NULL;
CheckBox = NULL;
RightArrow = NULL;
UserGroupRight = NULL;
UserGroupLeft = NULL;
UserGroupRightOwnership = false;
Selectable = true;
HReal= 0;
TextDY= 0;
}
};
protected:
CGroupList *_GroupList;
CCtrlScroll *_ScrollBar;
CViewBitmap *_SelectionView;
std::vector<SSubMenuEntry> _Lines;
std::vector<CGroupSubMenu*> _SubMenus;
CGroupMenu *_GroupMenu; // Master parent
sint32 _Selected;
sint32 _MaxVisibleLine; // -1 == no limit
friend class CGroupMenu;
private:
/** Clone this menu, and set its new father
* If appendToMenu is NULL, the menu is just copied
* otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu.
* NB : user groups are not duplicated
*/
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
void initOptions(CInterfaceGroup *parent);
CViewBitmap *createCheckBox(bool checked);
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
};
/**
* class describing a menu composed of one or more CGroupListSubMenu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupMenu : public CGroupModal
{
public:
CGroupMenu(const TCtorParam &param);
virtual ~CGroupMenu();
TCaseMode getCaseMode() { return _CaseMode; }
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 draw ();
void recurseDraw(CGroupSubMenu *pSubMenu);
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
virtual void setActive (bool state);
virtual bool isWindowUnder (sint32 x, sint32 y);
// add line with a string, for backward compatibility
void addLine (const std::string &name, const std::string &ah, const std::string &params,
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false);
uint getNumLine() const;
void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true);
void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true);
// clear all sub menus
void reset ();
// set the minW of the RootMenu.
void setMinW(sint32 minW);
// Gray a line on the RootMenu
void setGrayedLine(uint line, bool g);
CGroupSubMenu *getRootMenu() const { return _RootMenu; }
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); }
sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); }
// special for menu launched from a modal....
bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;}
void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;}
int luaGetRootMenu(CLuaState &ls);
int luaSetMinW(CLuaState &ls);
REFLECT_EXPORT_START(CGroupMenu, CGroupModal)
REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu);
REFLECT_LUA_METHOD("setMinW", luaSetMinW);
REFLECT_EXPORT_END
protected:
TCaseMode _CaseMode;
CGroupSubMenu *_RootMenu;
std::string _Extends;
// Text lookup
NLMISC::CRGBA _Color;
NLMISC::CRGBA _ShadowColor;
bool _CloseSubMenuUsingPopModal;
bool _Shadow;
bool _Formatted;
uint8 _Space;
sint32 _FontSize;
NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it
NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it
NLMISC::CRGBA _HighLightOver; // Background color of the selection
NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable
NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable
friend class CGroupSubMenu;
};
}
#endif // RZ_GROUP_MENU_H
/* End of group_menu.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_GROUP_MENU_H
#define RZ_GROUP_MENU_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_modal.h"
#include "nel/gui/group_submenu_base.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlScroll;
class CViewBitmap;
class CGroupList;
class CGroupMenu;
/**
* CViewTextMenu is an element of a sub menu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewTextMenu : public CViewText
{
public:
CViewTextMenu(const TCtorParam &param) : CViewText(param)
{
_Grayed = false;
_Checked = false;
_Checkable = false;
_CheckBox = NULL;
Over = false;
}
bool getGrayed() const;
void setGrayed (bool g);
bool getChecked() const { return _Checked; }
void setChecked(bool c);
bool getCheckable() const { return _Checkable; }
void setCheckable(bool c);
void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; }
CViewBitmap * getCheckBox() const { return _CheckBox; }
bool getFormatted () const { return getMultiLine (); }
virtual sint32 getAlpha() const;
virtual void setAlpha (sint32 a);
REFLECT_EXPORT_START(CViewTextMenu, CViewText)
REFLECT_BOOL("grayed", getGrayed, setGrayed);
REFLECT_BOOL("checked", getChecked, setChecked);
REFLECT_EXPORT_END
public:
bool Over;
NLMISC::CRGBA OldColor;
NLMISC::CRGBA OldShadowColor;
NLMISC::CRGBA OldColorOver;
NLMISC::CRGBA OldShadowColorOver;
NLMISC::CRGBA OldColorGrayed;
NLMISC::CRGBA OldShadowColorGrayed;
private:
CViewBitmap *_CheckBox;
bool _Grayed;
bool _Checked;
bool _Checkable;
};
/**
* CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu)
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupSubMenu : public CGroupSubMenuBase
{
public:
CGroupSubMenu(const TCtorParam &param);
virtual ~CGroupSubMenu();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL);
virtual void checkCoords();
virtual void updateCoords ();
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
// retrieve the index of a line from its id (-1 if not found)
sint getLineFromId(const std::string &id);
CViewTextMenu* addLine (const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
void addSeparator(const std::string &id = "");
void addSeparatorAtIndex(uint index, const std::string &id = "");
uint getNumLine() const { return (uint)_Lines.size(); }
void removeLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void openSubMenu (sint32 nb);
void hideSubMenus ();
// reset all entries of the sub menu
void reset();
virtual void setActive (bool state);
// Tell if the line is a separator or not
bool isSeparator (uint i) const;
/** Set a user defined group at the given line
* 'ownership' tells whether this menu should remove the group when it is deleted
* Setting a user group on a line with a separator is illegal
*/
void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupRight(uint line) const;
//
void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupLeft(uint line) const;
void removeAllUserGroups();
uint getNumLines() const { return (uint)_Lines.size(); }
// return pointer to submenu or NULL if there's none
CGroupSubMenu *getSubMenu(uint index) const;
void setSubMenu(uint index, CGroupSubMenu *sub);
// if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup)
void setSelectable(uint lineIndex, bool selectable);
bool getSelectable(uint lineIndex) const;
// Gray a line.
void setGrayedLine(uint line, bool g);
// Hide a line.
void setHiddenLine(uint line, bool h);
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl);
sint32 getMaxVisibleLine() { return _MaxVisibleLine; }
// Get the Line Id (not the full Id)
const std::string &getLineId(uint index);
int luaGetNumLine(CLuaState &ls);
int luaGetSubMenu(CLuaState &ls);
int luaAddSubMenu(CLuaState &ls);
int luaGetLineId(CLuaState &ls);
int luaGetLineFromId(CLuaState &ls);
int luaIsSeparator(CLuaState &ls);
int luaAddLine(CLuaState &ls);
int luaAddLineAtIndex(CLuaState &ls);
int luaAddSeparator(CLuaState &ls);
int luaAddSeparatorAtIndex(CLuaState &ls);
int luaRemoveLine(CLuaState &ls);
int luaSetUserGroupRight(CLuaState &ls);
int luaGetUserGroupRight(CLuaState &ls);
int luaSetUserGroupLeft(CLuaState &ls);
int luaGetUserGroupLeft(CLuaState &ls);
int luaReset(CLuaState &ls);
int luaSetMaxVisibleLine(CLuaState &ls);
//
REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase)
REFLECT_LUA_METHOD("getNumLine", luaGetNumLine);
REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index
REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found
REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu);
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
REFLECT_LUA_METHOD("removeLine", luaRemoveLine);
REFLECT_LUA_METHOD("reset", luaReset);
REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line
REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line
REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine);
REFLECT_EXPORT_END
protected:
struct SSubMenuEntry
{
CViewTextMenu *ViewText; // Backup of the children that are in grouplist
CInterfaceGroup *Separator;
std::string AHName;
std::string AHParams;
std::string Id;
std::string Cond; // condition to know if the entry is grayed
CViewBitmap *CheckBox;
CViewBitmap *RightArrow;
CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow
CInterfaceGroup *UserGroupLeft;
bool UserGroupRightOwnership;
bool UserGroupLeftOwnership;
bool Selectable;
sint32 HReal; // max H of the view text and the other user group
sint32 TextDY; // Y of the view text to set
SSubMenuEntry()
{
ViewText = NULL;
Separator = NULL;
CheckBox = NULL;
RightArrow = NULL;
UserGroupRight = NULL;
UserGroupLeft = NULL;
UserGroupRightOwnership = false;
Selectable = true;
HReal= 0;
TextDY= 0;
}
};
protected:
CGroupList *_GroupList;
CCtrlScroll *_ScrollBar;
CViewBitmap *_SelectionView;
std::vector<SSubMenuEntry> _Lines;
std::vector<CGroupSubMenu*> _SubMenus;
CGroupMenu *_GroupMenu; // Master parent
sint32 _Selected;
sint32 _MaxVisibleLine; // -1 == no limit
friend class CGroupMenu;
private:
/** Clone this menu, and set its new father
* If appendToMenu is NULL, the menu is just copied
* otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu.
* NB : user groups are not duplicated
*/
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
void initOptions(CInterfaceGroup *parent);
CViewBitmap *createCheckBox(bool checked);
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
};
/**
* class describing a menu composed of one or more CGroupListSubMenu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupMenu : public CGroupModal
{
public:
CGroupMenu(const TCtorParam &param);
virtual ~CGroupMenu();
TCaseMode getCaseMode() { return _CaseMode; }
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 draw ();
void recurseDraw(CGroupSubMenu *pSubMenu);
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
virtual void setActive (bool state);
virtual bool isWindowUnder (sint32 x, sint32 y);
// add line with a string, for backward compatibility
void addLine (const std::string &name, const std::string &ah, const std::string &params,
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false);
uint getNumLine() const;
void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true);
void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true);
// clear all sub menus
void reset ();
// set the minW of the RootMenu.
void setMinW(sint32 minW);
// Gray a line on the RootMenu
void setGrayedLine(uint line, bool g);
CGroupSubMenu *getRootMenu() const { return _RootMenu; }
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); }
sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); }
// special for menu launched from a modal....
bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;}
void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;}
int luaGetRootMenu(CLuaState &ls);
int luaSetMinW(CLuaState &ls);
REFLECT_EXPORT_START(CGroupMenu, CGroupModal)
REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu);
REFLECT_LUA_METHOD("setMinW", luaSetMinW);
REFLECT_EXPORT_END
protected:
TCaseMode _CaseMode;
CGroupSubMenu *_RootMenu;
std::string _Extends;
// Text lookup
NLMISC::CRGBA _Color;
NLMISC::CRGBA _ShadowColor;
bool _CloseSubMenuUsingPopModal;
bool _Shadow;
bool _Formatted;
uint8 _Space;
sint32 _FontSize;
NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it
NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it
NLMISC::CRGBA _HighLightOver; // Background color of the selection
NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable
NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable
friend class CGroupSubMenu;
};
}
#endif // RZ_GROUP_MENU_H
/* End of group_menu.h */

@ -1,77 +1,77 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_MODAL_H
#define NL_GROUP_MODAL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A group with special modal options
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupModal : public CGroupFrame
{
public:
bool SpawnOnMousePos : 1;
bool ExitClickOut : 1;
bool ExitClickL : 1;
bool ExitClickR : 1;
bool ForceInsideScreen : 1;
bool ExitKeyPushed : 1;
sint32 SpawnMouseX, SpawnMouseY;
std::string Category;
std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured
std::string OnClickOutParams;
std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured
std::string OnPostClickOutParams;
public:
/// Constructor
CGroupModal(const TCtorParam &param);
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 updateCoords ();
void setBaseX(sint32 x) { _MouseDeltaX = x;}
void setBaseY(sint32 y) { _MouseDeltaY = y;}
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
}
#endif // NL_GROUP_MODAL_H
/* End of group_modal.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_MODAL_H
#define NL_GROUP_MODAL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A group with special modal options
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupModal : public CGroupFrame
{
public:
bool SpawnOnMousePos : 1;
bool ExitClickOut : 1;
bool ExitClickL : 1;
bool ExitClickR : 1;
bool ForceInsideScreen : 1;
bool ExitKeyPushed : 1;
sint32 SpawnMouseX, SpawnMouseY;
std::string Category;
std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured
std::string OnClickOutParams;
std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured
std::string OnPostClickOutParams;
public:
/// Constructor
CGroupModal(const TCtorParam &param);
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 updateCoords ();
void setBaseX(sint32 x) { _MouseDeltaX = x;}
void setBaseY(sint32 y) { _MouseDeltaY = y;}
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
}
#endif // NL_GROUP_MODAL_H
/* End of group_modal.h */

@ -1,313 +1,313 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_PARAGRAPH_H
#define NL_GROUP_PARAGRAPH_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/view_link.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
class CCtrlLink : public CCtrlButton
{
public:
CCtrlLink (const TCtorParam &param) : CCtrlButton(param)
{}
};
// ----------------------------------------------------------------------------
class CGroupParagraph : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupParagraph(const TCtorParam &param);
// dtor
~CGroupParagraph();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/**
* add a link element to the group at the last position
* \param child : pointer to the child element
*/
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
protected:
void delChild (CViewBase* child);
void delChild(uint index);
public:
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
void deleteAllChildren();
// void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
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;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* 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 void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
// swap 2 entries in the list (and also their orders)
// void swapChildren(uint index1, uint index2);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
void setTopSpace(uint topSpace)
{
_TopSpace = topSpace;
setResizeFromChildHMargin(topSpace);
invalidateContent();
};
uint getTopSpace()
{
return _TopSpace;
};
void setIndent(uint indent) { _Indent = indent; }
void setFirstViewIndent(sint indent)
{
_FirstViewIndentView = indent;
invalidateContent();
}
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
protected:
// Content validated
bool _ContentValidated;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
// Last parent width
sint32 _LastW;
// Top space
uint _TopSpace;
// Indent
uint _Indent; // Left margin
sint _FirstViewIndentView; // Additionnal left margin for the first view
// A link structure
class CLink
{
public:
CLink(CViewLink *link);
// The link view
CViewLink *Link;
// The three control button
CCtrlLink *CtrlLink[3];
};
// The links
std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private:
std::string _HardText;
uint32 _TextId;
void setupSizes();
void onTextChanged();
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
};
}
#endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_PARAGRAPH_H
#define NL_GROUP_PARAGRAPH_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/view_link.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
class CCtrlLink : public CCtrlButton
{
public:
CCtrlLink (const TCtorParam &param) : CCtrlButton(param)
{}
};
// ----------------------------------------------------------------------------
class CGroupParagraph : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupParagraph(const TCtorParam &param);
// dtor
~CGroupParagraph();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/**
* add a link element to the group at the last position
* \param child : pointer to the child element
*/
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
protected:
void delChild (CViewBase* child);
void delChild(uint index);
public:
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
void deleteAllChildren();
// void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
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;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* 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 void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
// swap 2 entries in the list (and also their orders)
// void swapChildren(uint index1, uint index2);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
void setTopSpace(uint topSpace)
{
_TopSpace = topSpace;
setResizeFromChildHMargin(topSpace);
invalidateContent();
};
uint getTopSpace()
{
return _TopSpace;
};
void setIndent(uint indent) { _Indent = indent; }
void setFirstViewIndent(sint indent)
{
_FirstViewIndentView = indent;
invalidateContent();
}
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
protected:
// Content validated
bool _ContentValidated;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
// Last parent width
sint32 _LastW;
// Top space
uint _TopSpace;
// Indent
uint _Indent; // Left margin
sint _FirstViewIndentView; // Additionnal left margin for the first view
// A link structure
class CLink
{
public:
CLink(CViewLink *link);
// The link view
CViewLink *Link;
// The three control button
CCtrlLink *CtrlLink[3];
};
// The links
std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private:
std::string _HardText;
uint32 _TextId;
void setupSizes();
void onTextChanged();
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
};
}
#endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */

@ -1,90 +1,90 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_SCROLLTEXT_H
#define CL_GROUP_SCROLLTEXT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
// Can be used to build a chat window or anything that displays sequences of strings
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CGroupScrollText : public CInterfaceGroup
{
public:
/// Constructor
CGroupScrollText(const TCtorParam &param);
~CGroupScrollText();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// get the list associated to this group
CGroupList *getList() const { return _List; }
// Get the scroll bar
CCtrlScroll *getScrollBar() const { return _ScrollBar; }
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup)
REFLECT_EXPORT_END
private:
CGroupList *_List;
CCtrlScroll *_ScrollBar;
CCtrlBaseButton *_ButtonAdd;
CCtrlBaseButton *_ButtonSub;
bool _Settuped;
bool _InvertScrollBar;
sint32 _ListHeight;
protected:
void setup();
void updateScrollBar();
public:
// private use for action handlers
sint32 _StartHeight;
sint64 _EllapsedTime;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_SCROLLTEXT_H
#define CL_GROUP_SCROLLTEXT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
// Can be used to build a chat window or anything that displays sequences of strings
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CGroupScrollText : public CInterfaceGroup
{
public:
/// Constructor
CGroupScrollText(const TCtorParam &param);
~CGroupScrollText();
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;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// get the list associated to this group
CGroupList *getList() const { return _List; }
// Get the scroll bar
CCtrlScroll *getScrollBar() const { return _ScrollBar; }
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup)
REFLECT_EXPORT_END
private:
CGroupList *_List;
CCtrlScroll *_ScrollBar;
CCtrlBaseButton *_ButtonAdd;
CCtrlBaseButton *_ButtonSub;
bool _Settuped;
bool _InvertScrollBar;
sint32 _ListHeight;
protected:
void setup();
void updateScrollBar();
public:
// private use for action handlers
sint32 _StartHeight;
sint64 _EllapsedTime;
};
}
#endif

@ -1,48 +1,48 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_SUBMENU_BASE
#define GROUP_SUBMENU_BASE
#include "nel/gui/group_frame.h"
namespace NLGUI
{
class CGroupSubMenuBase : public CGroupFrame
{
public:
DECLARE_UI_CLASS( CGroupSubMenuBase )
CGroupSubMenuBase( const TCtorParam &param );
~CGroupSubMenuBase();
virtual void openSubMenu( sint32 nb );
virtual void hideSubMenus();
REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame )
REFLECT_EXPORT_END
protected:
private:
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef GROUP_SUBMENU_BASE
#define GROUP_SUBMENU_BASE
#include "nel/gui/group_frame.h"
namespace NLGUI
{
class CGroupSubMenuBase : public CGroupFrame
{
public:
DECLARE_UI_CLASS( CGroupSubMenuBase )
CGroupSubMenuBase( const TCtorParam &param );
~CGroupSubMenuBase();
virtual void openSubMenu( sint32 nb );
virtual void hideSubMenus();
REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame )
REFLECT_EXPORT_END
protected:
private:
};
}
#endif

@ -1,188 +1,188 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TAB_H
#define NL_GROUP_TAB_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlTabButton;
// ***************************************************************************
/**
* Group handling Ctrl Tab, to easily simulate Tab ctrl.
* NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order:
* - in this group
* - in the parent group
* - in global
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CGroupTab : public CInterfaceGroup
{
public:
/// Constructor
CGroupTab(const TCtorParam &param);
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 updateCoords ();
// select the ctrl tab. -1 will invalidate all.
void select(sint index);
sint getSelection() const;
// select with a CCtrlTabButton ptr
void selectFromCtrl(CCtrlTabButton *button);
// select a default activated tab, if the current is a special ctrlTab
void selectDefault(CCtrlTabButton *ifSelectionIs);
// select a default activated tab, if the current is hid
void selectDefaultIfCurrentHid();
// add new tab
void addTab(CCtrlTabButton *tabB);
void addTab(CCtrlTabButton *tabB, sint index);
int luaAddTab(CLuaState &ls);
int luaAddTabWithOrder(CLuaState &ls);
// remove selected tab
void removeTab(sint index);
int luaRemoveTab(CLuaState &ls);
// remove all tabs
void removeAll();
int luaRemoveAll(CLuaState &ls);
// tab number
void setTabButtonNb(sint32 /* val */){}
sint32 getTabButtonNb() const {return (sint32)_Buttons.size();}
// selection index
void setIndexSelection(sint32 val){select((sint)val);}
sint32 getIndexSelection() const {return (sint32)_NextSelection;}
// selection index
void setAssociatedGroupSelection(const std::string & /* assG */){}
std::string getAssociatedGroupSelection() const;
// get group from index
CInterfaceGroup* getGroup(sint index);
int luaGetGroup(CLuaState &ls);
// get tab from index
CCtrlTabButton* getTabButton(sint index);
int luaGetTabButton(CLuaState &ls);
// first showed tab button
sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;}
// last showed tab button
sint32 getLastTabButton() const {return (sint32)_LastTabIndex;}
// update showed tab buttons on function of GroupTab width
void updateFirstTabButton();
int luaShowTabButton(CLuaState &ls);
void dummySet(sint32 /* value */){}
REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup)
REFLECT_LUA_METHOD("addTab", luaAddTab)
REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder)
REFLECT_LUA_METHOD("removeTab", luaRemoveTab)
REFLECT_LUA_METHOD("removeAll", luaRemoveAll)
REFLECT_LUA_METHOD("getGroup", luaGetGroup)
REFLECT_LUA_METHOD("getTabButton", luaGetTabButton)
REFLECT_LUA_METHOD("showTabButton", luaShowTabButton)
REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb)
REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection)
REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet)
REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet)
REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection)
REFLECT_EXPORT_END
private:
std::vector<CCtrlTabButton*> _Buttons; // can't be NULL.
std::vector<CInterfaceGroup*> _Groups; // may be NULL
sint _Selection;
sint _NextSelection;
sint _BaseRenderLayer;
bool _Setuped;
bool _HideOutTabs;
sint _FirstTabIndex;
sint _LastTabIndex;
std::string _AHOnChange;
std::string _ParamsOnChange;
void setup();
};
// ***************************************************************************
/**
* Used with CGroupTab
*/
class CCtrlTabButton : public CCtrlTextButton
{
public:
CCtrlTabButton(const TCtorParam &param);
void setProperty( const std::string &name, const std::string &value );
std::string getProperty( const std::string &name ) const;
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void setActive(bool state);
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setBlink (bool b);
std::string _AssociatedGroup;
IActionHandler *_AHOnLeftClick2;
private:
sint32 _DefaultX;
bool _Blinking;
NLMISC::CRGBA _TextColorNormalBlink;
bool _TextModulateGlobalColorNormalBlink;
sint64 _BlinkDate;
bool _BlinkState;
};
}
#endif // NL_GROUP_TAB_H
/* End of group_tab.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TAB_H
#define NL_GROUP_TAB_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlTabButton;
// ***************************************************************************
/**
* Group handling Ctrl Tab, to easily simulate Tab ctrl.
* NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order:
* - in this group
* - in the parent group
* - in global
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CGroupTab : public CInterfaceGroup
{
public:
/// Constructor
CGroupTab(const TCtorParam &param);
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 updateCoords ();
// select the ctrl tab. -1 will invalidate all.
void select(sint index);
sint getSelection() const;
// select with a CCtrlTabButton ptr
void selectFromCtrl(CCtrlTabButton *button);
// select a default activated tab, if the current is a special ctrlTab
void selectDefault(CCtrlTabButton *ifSelectionIs);
// select a default activated tab, if the current is hid
void selectDefaultIfCurrentHid();
// add new tab
void addTab(CCtrlTabButton *tabB);
void addTab(CCtrlTabButton *tabB, sint index);
int luaAddTab(CLuaState &ls);
int luaAddTabWithOrder(CLuaState &ls);
// remove selected tab
void removeTab(sint index);
int luaRemoveTab(CLuaState &ls);
// remove all tabs
void removeAll();
int luaRemoveAll(CLuaState &ls);
// tab number
void setTabButtonNb(sint32 /* val */){}
sint32 getTabButtonNb() const {return (sint32)_Buttons.size();}
// selection index
void setIndexSelection(sint32 val){select((sint)val);}
sint32 getIndexSelection() const {return (sint32)_NextSelection;}
// selection index
void setAssociatedGroupSelection(const std::string & /* assG */){}
std::string getAssociatedGroupSelection() const;
// get group from index
CInterfaceGroup* getGroup(sint index);
int luaGetGroup(CLuaState &ls);
// get tab from index
CCtrlTabButton* getTabButton(sint index);
int luaGetTabButton(CLuaState &ls);
// first showed tab button
sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;}
// last showed tab button
sint32 getLastTabButton() const {return (sint32)_LastTabIndex;}
// update showed tab buttons on function of GroupTab width
void updateFirstTabButton();
int luaShowTabButton(CLuaState &ls);
void dummySet(sint32 /* value */){}
REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup)
REFLECT_LUA_METHOD("addTab", luaAddTab)
REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder)
REFLECT_LUA_METHOD("removeTab", luaRemoveTab)
REFLECT_LUA_METHOD("removeAll", luaRemoveAll)
REFLECT_LUA_METHOD("getGroup", luaGetGroup)
REFLECT_LUA_METHOD("getTabButton", luaGetTabButton)
REFLECT_LUA_METHOD("showTabButton", luaShowTabButton)
REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb)
REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection)
REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet)
REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet)
REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection)
REFLECT_EXPORT_END
private:
std::vector<CCtrlTabButton*> _Buttons; // can't be NULL.
std::vector<CInterfaceGroup*> _Groups; // may be NULL
sint _Selection;
sint _NextSelection;
sint _BaseRenderLayer;
bool _Setuped;
bool _HideOutTabs;
sint _FirstTabIndex;
sint _LastTabIndex;
std::string _AHOnChange;
std::string _ParamsOnChange;
void setup();
};
// ***************************************************************************
/**
* Used with CGroupTab
*/
class CCtrlTabButton : public CCtrlTextButton
{
public:
CCtrlTabButton(const TCtorParam &param);
void setProperty( const std::string &name, const std::string &value );
std::string getProperty( const std::string &name ) const;
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void setActive(bool state);
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setBlink (bool b);
std::string _AssociatedGroup;
IActionHandler *_AHOnLeftClick2;
private:
sint32 _DefaultX;
bool _Blinking;
NLMISC::CRGBA _TextColorNormalBlink;
bool _TextModulateGlobalColorNormalBlink;
sint64 _BlinkDate;
bool _BlinkState;
};
}
#endif // NL_GROUP_TAB_H
/* End of group_tab.h */

@ -1,224 +1,224 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TABLE_H
#define NL_GROUP_TABLE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
/**
* This group is used to simulate HTML cells.
* They have specific parameters to be aligned like HTML cells.
* (Percent of the table size
*/
class CGroupCell: public CInterfaceGroup
{
friend class CGroupTable;
public:
CGroupCell(const TCtorParam &param);
enum TAlign
{
Left,
Center,
Right
};
enum TVAlign
{
Top,
Middle,
Bottom
};
/// \from CInterfaceElement
virtual void draw();
virtual sint32 getMaxUsedW() const;
virtual sint32 getMinUsedW() const;
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;
// to be called by CGroupTable
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);
// If the cell is a new line. This is the first <td> after a <tr>
bool NewLine;
bool IgnoreMaxWidth;
bool IgnoreMinWidth;
bool AddChildW;
// The table width cell ratio. This is the <td width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <td width="100"> 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 &param);
// dtor
~CGroupTable();
// Add a cell in the table
void addChild (CGroupCell* child);
// The ratio you want [0 ~1]. This is the <table width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <table width="100"> 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<CGroupCell *> _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<CColumn> _Columns;
// Column table
std::vector<CRow> _Rows;
};
}
#endif // NL_GROUP_TABLE_H
/* End of group_table.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TABLE_H
#define NL_GROUP_TABLE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
/**
* This group is used to simulate HTML cells.
* They have specific parameters to be aligned like HTML cells.
* (Percent of the table size
*/
class CGroupCell: public CInterfaceGroup
{
friend class CGroupTable;
public:
CGroupCell(const TCtorParam &param);
enum TAlign
{
Left,
Center,
Right
};
enum TVAlign
{
Top,
Middle,
Bottom
};
/// \from CInterfaceElement
virtual void draw();
virtual sint32 getMaxUsedW() const;
virtual sint32 getMinUsedW() const;
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;
// to be called by CGroupTable
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);
// If the cell is a new line. This is the first <td> after a <tr>
bool NewLine;
bool IgnoreMaxWidth;
bool IgnoreMinWidth;
bool AddChildW;
// The table width cell ratio. This is the <td width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <td width="100"> 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 &param);
// dtor
~CGroupTable();
// Add a cell in the table
void addChild (CGroupCell* child);
// The ratio you want [0 ~1]. This is the <table width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <table width="100"> 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<CGroupCell *> _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<CColumn> _Columns;
// Column table
std::vector<CRow> _Rows;
};
}
#endif // NL_GROUP_TABLE_H
/* End of group_table.h */

@ -1,381 +1,381 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<SNode> 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<CInterfaceGroup> 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<SNode*> 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 &param);
// 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<CViewBitmap*> 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<SLine> _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 */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<SNode> 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<CInterfaceGroup> 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<SNode*> 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 &param);
// 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<CViewBitmap*> 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<SLine> _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 */

@ -1,50 +1,50 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 &param);
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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 &param);
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

@ -1,36 +1,36 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

@ -1,57 +1,57 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

@ -1,135 +1,135 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<SDynKey> _DynKeys;
ETrackType _Type;
NL3D::UTrackKeyframer *_TrackKeyFramer;
std::vector<CInterfaceLink::CTargetInfo> _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<CInterfaceTrack*> _Tracks;
// Current anim
double _CurrentTime;
bool _Finished;
bool _AnimHasToBeStopped;
};
}
#endif // NL_INTERFACE_ANIM_H
/* End of interface_anim.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<SDynKey> _DynKeys;
ETrackType _Type;
NL3D::UTrackKeyframer *_TrackKeyFramer;
std::vector<CInterfaceLink::CTargetInfo> _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<CInterfaceTrack*> _Tracks;
// Current anim
double _CurrentTime;
bool _Finished;
bool _AnimHasToBeStopped;
};
}
#endif // NL_INTERFACE_ANIM_H
/* End of interface_anim.h */

@ -1,68 +1,68 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

File diff suppressed because it is too large Load Diff

@ -1,239 +1,239 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CInterfaceExprValue> 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<NLMISC::ICDBNode *> *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<std::string, TUserFct> 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<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes);
public:
static const char *unpackDBentry(const char *expr, std::vector<NLMISC::ICDBNode *> *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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CInterfaceExprValue> 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<NLMISC::ICDBNode *> *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<std::string, TUserFct> 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<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes);
public:
static const char *unpackDBentry(const char *expr, std::vector<NLMISC::ICDBNode *> *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

@ -1,118 +1,118 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<NLMISC::ICDBNode *> &nodes) = 0;
// Get dependencies of the node (appended to vector)
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
// *******************************************************************************************************
/** A fct call (in a interface expr parse tree)
*/
class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode
{
public:
CInterfaceExpr::TUserFct Func;
// list of parameters
std::vector<CInterfaceExprNode *> Params;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<NLMISC::ICDBNode *> &nodes) = 0;
// Get dependencies of the node (appended to vector)
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
// *******************************************************************************************************
/** A fct call (in a interface expr parse tree)
*/
class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode
{
public:
CInterfaceExpr::TUserFct Func;
// list of parameters
std::vector<CInterfaceExprNode *> Params;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &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<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
}
#endif

@ -1,422 +1,422 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 &param);
/// 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<CInterfaceGroup*> & getGroups () { return _ChildrenGroups; }
const std::vector<CCtrlBase*> & getControls() { return _Controls; }
const std::vector<CViewBase*> & 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<CViewBase*> &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<CCtrlBase*> &vICL);
virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CInterfaceGroup *> &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 &params) { _AHOnLeftClickParams = params; }
void setRightClickHandlerParams(const std::string &params) { _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<CInterfaceGroup*> _ChildrenGroups;
std::vector<CCtrlBase*> _Controls;
std::vector<CViewBase*> _Views;
std::vector<CViewBase*> _EltOrder;
/// Scroll properties
NLMISC::CRefPtr<CInterfaceElement> _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<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLUAOnDbChange;
TLUAOnDbChange _LUAOnDbChange;
void removeAllLUAOnDbChange();
protected:
void parseMaxSizeRef(const char *ptr);
// @}
};
}
#endif // NL_INTERFACE_GROUP_H
/* End of interface_group.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 &param);
/// 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<CInterfaceGroup*> & getGroups () { return _ChildrenGroups; }
const std::vector<CCtrlBase*> & getControls() { return _Controls; }
const std::vector<CViewBase*> & 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<CViewBase*> &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<CCtrlBase*> &vICL);
virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CInterfaceGroup *> &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 &params) { _AHOnLeftClickParams = params; }
void setRightClickHandlerParams(const std::string &params) { _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<CInterfaceGroup*> _ChildrenGroups;
std::vector<CCtrlBase*> _Controls;
std::vector<CViewBase*> _Views;
std::vector<CViewBase*> _EltOrder;
/// Scroll properties
NLMISC::CRefPtr<CInterfaceElement> _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<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLUAOnDbChange;
TLUAOnDbChange _LUAOnDbChange;
void removeAllLUAOnDbChange();
protected:
void parseMaxSizeRef(const char *ptr);
// @}
};
}
#endif // NL_INTERFACE_GROUP_H
/* End of interface_group.h */

@ -1,186 +1,186 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CTargetInfo> &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<CInterfaceLink::CTargetInfo> &targetsVect);
////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
friend struct CRemoveTargetPred;
// a target property
struct CTarget
{
CInterfaceElement *_InterfaceElement;
const CReflectedProperty *_Property;
};
private:
typedef std::list<CInterfaceLink *> TLinkList;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
private:
std::vector<CTarget> _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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CTargetInfo> &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<CInterfaceLink::CTargetInfo> &targetsVect);
////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
friend struct CRemoveTargetPred;
// a target property
struct CTarget
{
CInterfaceElement *_InterfaceElement;
const CReflectedProperty *_Property;
};
private:
typedef std::list<CInterfaceLink *> TLinkList;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
private:
std::vector<CTarget> _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

@ -1,225 +1,225 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<std::string, CInterfaceOptionValue> _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 <param> 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 */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<std::string, CInterfaceOptionValue> _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 <param> 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 */

@ -1,389 +1,389 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<std::string> &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<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true);
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &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<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */);
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &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 &params ) 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<xmlNodePtr> _Templates;
// map linking an element to its parent position used during init only
std::map<CInterfaceElement*,std::string> _ParentPositionsMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMaxMap;
// map linking a group to its lua script. used during init only
std::map<CInterfaceGroup*,std::string> _LuaClassAssociation;
/**
* Data of initialized interface
*/
/// Define Variable list
typedef std::map<std::string, std::string> 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<CStyleProperty> Properties;
};
// mgt of sheet selections (inventory, buy, sell..)
CCtrlSheetSelection _CtrlSheetSelection;
// Map of dynamic links
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLinkMap;
TLinkMap _LinkMap;
// Map of anims
typedef std::map<std::string, CInterfaceAnim *> TAnimMap;
TAnimMap _AnimMap;
// Map of styles.
typedef std::map<std::string, CStyle> TStyleMap;
TStyleMap _StyleMap;
protected:
std::map< std::string, IParserModule* > moduleMap;
// List of script loaded (for reloadLua command)
std::set<std::string> _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 <lua>
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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<std::string> &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<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true);
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &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<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */);
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &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 &params ) 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<xmlNodePtr> _Templates;
// map linking an element to its parent position used during init only
std::map<CInterfaceElement*,std::string> _ParentPositionsMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMaxMap;
// map linking a group to its lua script. used during init only
std::map<CInterfaceGroup*,std::string> _LuaClassAssociation;
/**
* Data of initialized interface
*/
/// Define Variable list
typedef std::map<std::string, std::string> 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<CStyleProperty> Properties;
};
// mgt of sheet selections (inventory, buy, sell..)
CCtrlSheetSelection _CtrlSheetSelection;
// Map of dynamic links
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLinkMap;
TLinkMap _LinkMap;
// Map of anims
typedef std::map<std::string, CInterfaceAnim *> TAnimMap;
TAnimMap _AnimMap;
// Map of styles.
typedef std::map<std::string, CStyle> TStyleMap;
TStyleMap _StyleMap;
protected:
std::map< std::string, IParserModule* > moduleMap;
// List of script loaded (for reloadLua command)
std::set<std::string> _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 <lua>
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

@ -1,106 +1,106 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 */

@ -1,283 +1,283 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

@ -1,28 +1,28 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef LIBWWW_NEL_STREAM_H
#define LIBWWW_NEL_STREAM_H
#include "libwww/HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef LIBWWW_NEL_STREAM_H
#define LIBWWW_NEL_STREAM_H
#include "libwww/HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H

@ -1,42 +1,42 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef LINKDATA_H
#define LINKDATA_H
#include "nel/misc/types_nl.h"
#include <string>
namespace NLGUI
{
struct SLinkData
{
public:
uint32 id;
std::string parent;
std::string expr;
std::string target;
std::string action;
std::string params;
std::string cond;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef LINKDATA_H
#define LINKDATA_H
#include "nel/misc/types_nl.h"
#include <string>
namespace NLGUI
{
struct SLinkData
{
public:
uint32 id;
std::string parent;
std::string expr;
std::string target;
std::string action;
std::string params;
std::string cond;
};
}
#endif

@ -1,388 +1,388 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CLuaState> 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<std::string, uint> 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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<CLuaState> 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<std::string, uint> 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

@ -1,193 +1,193 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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 */

@ -19,9 +19,9 @@
extern "C"
{
#include <lua/lua.h>
#include <lua/lauxlib.h>
#include <lua/lualib.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
// load the lua dll, return 1 on success

@ -1,78 +1,78 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

@ -1,303 +1,303 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<const void *> *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<const void *> *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<CLuaState> _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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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<const void *> *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<const void *> *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<CLuaState> _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

@ -1,93 +1,93 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef PARSER_H
#define PARSER_H
#include <string>
#include <vector>
#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 &params ) 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
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef PARSER_H
#define PARSER_H
#include <string>
#include <vector>
#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 &params ) 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

@ -1,150 +1,150 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef PROC_H
#define PROC_H
#include "nel/misc/types_nl.h"
#include <string>
#include <vector>
#include <map>
#include <algorithm>
namespace NLGUI
{
class CParamBlock
{
public:
// -1 if not a param id, but a string
sint32 NumParam;
std::string String;
CParamBlock()
{
NumParam = -1;
}
};
class CProcAction
{
public:
// a condition to launch this action handler (is an expression)
std::vector< CParamBlock > CondBlocks;
// the action handler (may be proc!!)
std::string Action;
std::string Parameters;
std::string Conditions;
// A list of string/or param number => to build the final params at execution
std::vector< CParamBlock > ParamBlocks;
// build a paramBlock from a string
void buildParamBlock( const std::string &params );
// from ParamBlock, and a paramList (skip the 0th), build params.
void buildParams( const std::vector< std::string > &paramList, std::string &params ) const;
void buildCondBlock( const std::string &params );
void buildCond( const std::vector< std::string > &paramList, std::string &cond ) const;
static void buildBlocks( const std::string &in, std::vector< CParamBlock > &out );
static void eval( const std::vector< std::string > &inArgs, const std::vector< CParamBlock > &inBlocks, std::string &out );
};
class CActionNameIs
{
public:
CActionNameIs( const std::string &n )
{
name = n;
}
bool operator()( const CProcAction &action )
{
if( action.Action == name )
return true;
else
return false;
}
private:
std::string name;
};
class CProcedure
{
public:
// List of the actions
std::vector< CProcAction > Actions;
bool hasAction( const std::string &name ) const
{
std::vector< CProcAction >::const_iterator itr
= std::find_if( Actions.begin(), Actions.end(), CActionNameIs( name ) );
if( itr != Actions.end() )
return true;
else
return false;
}
bool swap( uint32 i1, uint32 i2 )
{
if( i1 == i2 )
return false;
if( i1 >= Actions.size() )
return false;
if( i2 >= Actions.size() )
return false;
CProcAction a = Actions[ i1 ];
Actions[ i1 ] = Actions[ i2 ];
Actions[ i2 ] = a;
return true;
}
bool addAction( const std::string &name )
{
Actions.push_back( CProcAction() );
Actions.back().Action = name;
return true;
}
bool removeAction( uint32 i )
{
if( i >= Actions.size() )
return false;
std::vector< CProcAction >::iterator itr = Actions.begin() + i;
Actions.erase( itr );
return true;
}
};
typedef std::map< std::string, CProcedure > TProcedureMap;
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef PROC_H
#define PROC_H
#include "nel/misc/types_nl.h"
#include <string>
#include <vector>
#include <map>
#include <algorithm>
namespace NLGUI
{
class CParamBlock
{
public:
// -1 if not a param id, but a string
sint32 NumParam;
std::string String;
CParamBlock()
{
NumParam = -1;
}
};
class CProcAction
{
public:
// a condition to launch this action handler (is an expression)
std::vector< CParamBlock > CondBlocks;
// the action handler (may be proc!!)
std::string Action;
std::string Parameters;
std::string Conditions;
// A list of string/or param number => to build the final params at execution
std::vector< CParamBlock > ParamBlocks;
// build a paramBlock from a string
void buildParamBlock( const std::string &params );
// from ParamBlock, and a paramList (skip the 0th), build params.
void buildParams( const std::vector< std::string > &paramList, std::string &params ) const;
void buildCondBlock( const std::string &params );
void buildCond( const std::vector< std::string > &paramList, std::string &cond ) const;
static void buildBlocks( const std::string &in, std::vector< CParamBlock > &out );
static void eval( const std::vector< std::string > &inArgs, const std::vector< CParamBlock > &inBlocks, std::string &out );
};
class CActionNameIs
{
public:
CActionNameIs( const std::string &n )
{
name = n;
}
bool operator()( const CProcAction &action )
{
if( action.Action == name )
return true;
else
return false;
}
private:
std::string name;
};
class CProcedure
{
public:
// List of the actions
std::vector< CProcAction > Actions;
bool hasAction( const std::string &name ) const
{
std::vector< CProcAction >::const_iterator itr
= std::find_if( Actions.begin(), Actions.end(), CActionNameIs( name ) );
if( itr != Actions.end() )
return true;
else
return false;
}
bool swap( uint32 i1, uint32 i2 )
{
if( i1 == i2 )
return false;
if( i1 >= Actions.size() )
return false;
if( i2 >= Actions.size() )
return false;
CProcAction a = Actions[ i1 ];
Actions[ i1 ] = Actions[ i2 ];
Actions[ i2 ] = a;
return true;
}
bool addAction( const std::string &name )
{
Actions.push_back( CProcAction() );
Actions.back().Action = name;
return true;
}
bool removeAction( uint32 i )
{
if( i >= Actions.size() )
return false;
std::vector< CProcAction >::iterator itr = Actions.begin() + i;
Actions.erase( itr );
return true;
}
};
typedef std::map< std::string, CProcedure > TProcedureMap;
}
#endif

@ -1,368 +1,368 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_REFLECT_H
#define CL_REFLECT_H
#include "nel/misc/rgba.h"
#include "nel/gui/lua_object.h"
#include <string>
namespace NLGUI
{
class CReflectable;
class CLuaState;
struct CClassInfo;
/** A property of a reflectable object
* NB: multiple inheritance not supported
*/
class CReflectedProperty
{
public:
enum TType { Boolean = 0,
SInt32,
UInt32,
Float,
String,
UCString,
RGBA,
LuaMethod
}; // other types will be added when needed
// define some pointer-to-member types
typedef bool (CReflectable::* TGetBool) () const;
typedef sint32 (CReflectable::* TGetSInt32) () const;
typedef uint32 (CReflectable::* TGetUInt32) () const;
typedef float (CReflectable::* TGetFloat) () const;
typedef std::string (CReflectable::* TGetString) () const;
typedef ucstring (CReflectable::* TGetUCString) () const;
typedef NLMISC::CRGBA (CReflectable::* TGetRGBA) () const;
//
typedef void (CReflectable::* TSetBool) (bool);
typedef void (CReflectable::* TSetSInt32) (sint32);
typedef void (CReflectable::* TSetUInt32) (uint32);
typedef void (CReflectable::* TSetFloat) (float);
typedef void (CReflectable::* TSetString) (const std::string &);
typedef void (CReflectable::* TSetUCString) (const ucstring &);
typedef void (CReflectable::* TSetRGBA) (NLMISC::CRGBA col);
//
typedef int (CReflectable:: *TLuaMethod) (CLuaState &luaState);
public:
TType Type;
// In each union we have method pointers to retrieve / set the data of the desired type (as told in 'Type')
union
{
TGetBool GetBool;
TGetSInt32 GetSInt32;
TGetUInt32 GetUInt32;
TGetFloat GetFloat;
TGetString GetString;
TGetUCString GetUCString;
TGetRGBA GetRGBA;
TLuaMethod GetLuaMethod; // lua method can only be obtained, not written ...
} GetMethod;
union
{
TSetBool SetBool;
TSetSInt32 SetSInt32;
TSetUInt32 SetUInt32;
TSetFloat SetFloat;
TSetString SetString;
TSetUCString SetUCString;
TSetRGBA SetRGBA;
} SetMethod;
// name of the property
std::string Name;
mutable CLuaObject LuaMethodRef; // cache pointer to function call if type == LuaMethod
const CClassInfo *ParentClass; // filled when 'registerClass' is called
};
// a vector of reflected properties
typedef std::vector<CReflectedProperty> TReflectedProperties;
struct CClassInfo;
/** Base class for a reflectable object
* NB: multiple inheritance not supported
*/
class CReflectable
{
public:
virtual ~CReflectable() {}
virtual const char *getReflectedClassName() const { return "CReflectable"; }
virtual const char *getRflectedParentClassName() const { return ""; }
/** When registering classes, the reflect system will call this function on each class
* to know which properties they exports.
* To defines which properties are exported use the REFLECT_EXPORT_** macros.
* By doing so, a new 'getReflectedProperties' function will be defined
*/
static void getReflectedProperties(TReflectedProperties &/* props */)
{
}
// get class infos for this reflectable object
const CClassInfo *getClassInfo();
/** get a property from this object by name
* TODO nico : optimized version for lua string (found in CLuaIHM) would maybe fit better here ...
*/
const CReflectedProperty *getReflectedProperty(const std::string &propertyName, bool dspWarning= true) const;
};
struct CLuaIndexedProperty
{
const CReflectedProperty *Prop;
CLuaString Id; // must keep id here, so that we are sure the string is not gc in lua and its pointer remains valid
};
struct CClassInfo
{
TReflectedProperties Properties; // the properties exported by this class
const CClassInfo *ParentClass; // pointer to infos of the parent class, or NULL if it is a root class
std::string ClassName;
/** For lua speedup (used by CLuaIHM) : because lua string are unique, we can use them to access property directly.
*/
typedef CHashMap<const char *, CLuaIndexedProperty, CLuaHashMapTraits> TLuaStrToPropMap;
mutable TLuaStrToPropMap LuaStrToProp;
};
/** Simple reflection system.
* Used by the GUI and some other objects.
* It is used to export some properties so that we can easily manipulate them in the GUI scripts (either lua or with CInterfaceExpr).
* NB: multiple inheritance not supported
*
* Example of use : a class exporting a boolean
*
* class CTestClass : public CReflectable
* {
* public:
* void setValue(bool value) { _Value = value; }
* bool getValue() const { return _Value; }
* \\ export the bool value
* REFLECT_EXPORT_START(CTestClass, CReflectable)
* REFLECT_BOOL("myValue", setValue, getValue)
* REFLECT_EXPORT_END
* private:
* bool _Value;
* };
*
* The class must then be registered with :
*
* REGISTER_REFLECTABLE_CLASS(CTestClass, CReflectable)
*
* NB: It should be registered after its parents
*
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CReflectSystem
{
public:
typedef std::map<std::string, CClassInfo> TClassMap;
public:
// release memory
static void release();
/** register a class and its properties
* NB : class should be registered after their parent have been, or an assertion will be raised
*/
static void registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties);
// retrieve a property of a reflectable class, or NULL if unknown
static const CReflectedProperty *getProperty(const std::string &className, const std::string &propertyName, bool dspWarning= true);
// get the list of class for debug or read purpose (NULL if no register has been called)
static const TClassMap *getClassMap() {return _ClassMap;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
static TClassMap *_ClassMap; // each class and its infos
};
/** Helper macros to export properties of a reflectable class
*/
/** Start a declaration of a reflectable class exports
* Should be placed inside the class
*/
#define REFLECT_EXPORT_START(className, parentName) \
virtual const char *getReflectedClassName() const { return #className; } \
virtual const char *getReflectedParentClassName() const { return #parentName; } \
static void getReflectedProperties(TReflectedProperties &props) \
{ \
typedef className A; \
typedef bool (className::* TGetBoola) () const; \
typedef sint32 (className::* TGetSInt32a) () const; \
typedef uint32 (className::* TGetUInt32a) () const; \
typedef float (className::* TGetFloata) () const; \
typedef std::string (className::* TGetStringa) () const; \
typedef ucstring (className::* TGetUCStringa) () const; \
typedef NLMISC::CRGBA (className::* TGetRGBAa) () const; \
typedef void (className::* TSetBoola) (bool); \
typedef void (className::* TSetSInt32a) (sint32); \
typedef void (className::* TSetUInt32a) (uint32); \
typedef void (className::* TSetFloata) (float); \
typedef void (className::* TSetStringa) (const std::string &); \
typedef void (className::* TSetUCStringa) (const ucstring &); \
typedef void (className::* TSetRGBAa) (NLMISC::CRGBA col); \
typedef int (className:: *TLuaMethoda) (CLuaState &luaState); \
nlunreferenced(props);
// export a boolean value, by giving the name of the get and the set method
#define REFLECT_BOOL(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::Boolean; \
prop.GetMethod.GetBool = (CReflectedProperty::TGetBool) (TGetBoola) &A::getMethod; \
prop.SetMethod.SetBool = (CReflectedProperty::TSetBool) (TSetBoola) &A::setMethod; \
props.push_back(prop); \
}
// export a sint32 value, by giving the name of the get and the set method
#define REFLECT_SINT32(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::SInt32; \
prop.GetMethod.GetSInt32 = (CReflectedProperty::TGetSInt32) (TGetSInt32a) &A::getMethod; \
prop.SetMethod.SetSInt32 = (CReflectedProperty::TSetSInt32) (TSetSInt32a) &A::setMethod; \
props.push_back(prop); \
}
// export a sint32 value, by giving the name of the get and the set method
#define REFLECT_UINT32(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::UInt32; \
prop.GetMethod.GetUInt32 = (CReflectedProperty::TGetUInt32) (TGetUInt32a) &A::getMethod; \
prop.SetMethod.SetUInt32 = (CReflectedProperty::TSetUInt32) (TSetUInt32a) &A::setMethod; \
props.push_back(prop); \
}
// export a float value, by giving the name of the get and the set method
#define REFLECT_FLOAT(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::Float; \
prop.GetMethod.GetFloat = (CReflectedProperty::TGetFloat) (TGetFloata) &A::getMethod; \
prop.SetMethod.SetFloat = (CReflectedProperty::TSetFloat) (TSetFloata) &A::setMethod; \
props.push_back(prop); \
}
// export a string value, by giving the name of the get and the set method
#define REFLECT_STRING(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::String; \
prop.GetMethod.GetString = (CReflectedProperty::TGetString) (TGetStringa) &A::getMethod; \
prop.SetMethod.SetString = (CReflectedProperty::TSetString) (TSetStringa) &A::setMethod; \
props.push_back(prop); \
}
// export a unicode string value, by giving the name of the get and the set method
#define REFLECT_UCSTRING(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::UCString; \
prop.GetMethod.GetUCString = (CReflectedProperty::TGetUCString) (TGetUCStringa) &A::getMethod; \
prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) (TSetUCStringa) &A::setMethod; \
props.push_back(prop); \
}
// export a color value, by giving the name of the get and the set method
#define REFLECT_RGBA(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::RGBA; \
prop.GetMethod.GetRGBA = (CReflectedProperty::TGetRGBA) (TGetRGBAa) &A::getMethod; \
prop.SetMethod.SetRGBA = (CReflectedProperty::TSetRGBA) (TSetRGBAa) &A::setMethod; \
props.push_back(prop); \
}
// export a lua method
#define REFLECT_LUA_METHOD(exportName, method) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::LuaMethod; \
prop.GetMethod.GetLuaMethod = (CReflectedProperty::TLuaMethod) (TLuaMethoda) &A::method; \
props.push_back(prop); \
}
// ends an export declaration
#define REFLECT_EXPORT_END }
// This macro registers a reflectable class to the manager
#define REGISTER_REFLECTABLE_CLASS(className, parentName) \
{ \
TReflectedProperties props; \
className::getReflectedProperties(props); \
CReflectSystem::registerClass(#className, #parentName, props); \
}
/** Reflectable refcounted object
* NB nico : added this intermediate class so that the binding from lua to the reflection
* system that are found in CLuaIHM can be reused for other objects as well
* NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount'
* because the refcount part is only used for ref pointing in the ui
*/
class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount
{
public:
virtual ~CReflectableRefPtrTarget();
};
class CReflectableLuaRef
{
public:
CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {}
NLMISC::CRefPtr<CReflectableRefPtrTarget> Ptr;
const CClassInfo &getClassInfo() const;
// IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo
const CReflectedProperty *getProp(const char *luaStringPtr) const;
private:
// cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer)
mutable const CClassInfo *_ClassInfo;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CL_REFLECT_H
#define CL_REFLECT_H
#include "nel/misc/rgba.h"
#include "nel/gui/lua_object.h"
#include <string>
namespace NLGUI
{
class CReflectable;
class CLuaState;
struct CClassInfo;
/** A property of a reflectable object
* NB: multiple inheritance not supported
*/
class CReflectedProperty
{
public:
enum TType { Boolean = 0,
SInt32,
UInt32,
Float,
String,
UCString,
RGBA,
LuaMethod
}; // other types will be added when needed
// define some pointer-to-member types
typedef bool (CReflectable::* TGetBool) () const;
typedef sint32 (CReflectable::* TGetSInt32) () const;
typedef uint32 (CReflectable::* TGetUInt32) () const;
typedef float (CReflectable::* TGetFloat) () const;
typedef std::string (CReflectable::* TGetString) () const;
typedef ucstring (CReflectable::* TGetUCString) () const;
typedef NLMISC::CRGBA (CReflectable::* TGetRGBA) () const;
//
typedef void (CReflectable::* TSetBool) (bool);
typedef void (CReflectable::* TSetSInt32) (sint32);
typedef void (CReflectable::* TSetUInt32) (uint32);
typedef void (CReflectable::* TSetFloat) (float);
typedef void (CReflectable::* TSetString) (const std::string &);
typedef void (CReflectable::* TSetUCString) (const ucstring &);
typedef void (CReflectable::* TSetRGBA) (NLMISC::CRGBA col);
//
typedef int (CReflectable:: *TLuaMethod) (CLuaState &luaState);
public:
TType Type;
// In each union we have method pointers to retrieve / set the data of the desired type (as told in 'Type')
union
{
TGetBool GetBool;
TGetSInt32 GetSInt32;
TGetUInt32 GetUInt32;
TGetFloat GetFloat;
TGetString GetString;
TGetUCString GetUCString;
TGetRGBA GetRGBA;
TLuaMethod GetLuaMethod; // lua method can only be obtained, not written ...
} GetMethod;
union
{
TSetBool SetBool;
TSetSInt32 SetSInt32;
TSetUInt32 SetUInt32;
TSetFloat SetFloat;
TSetString SetString;
TSetUCString SetUCString;
TSetRGBA SetRGBA;
} SetMethod;
// name of the property
std::string Name;
mutable CLuaObject LuaMethodRef; // cache pointer to function call if type == LuaMethod
const CClassInfo *ParentClass; // filled when 'registerClass' is called
};
// a vector of reflected properties
typedef std::vector<CReflectedProperty> TReflectedProperties;
struct CClassInfo;
/** Base class for a reflectable object
* NB: multiple inheritance not supported
*/
class CReflectable
{
public:
virtual ~CReflectable() {}
virtual const char *getReflectedClassName() const { return "CReflectable"; }
virtual const char *getRflectedParentClassName() const { return ""; }
/** When registering classes, the reflect system will call this function on each class
* to know which properties they exports.
* To defines which properties are exported use the REFLECT_EXPORT_** macros.
* By doing so, a new 'getReflectedProperties' function will be defined
*/
static void getReflectedProperties(TReflectedProperties &/* props */)
{
}
// get class infos for this reflectable object
const CClassInfo *getClassInfo();
/** get a property from this object by name
* TODO nico : optimized version for lua string (found in CLuaIHM) would maybe fit better here ...
*/
const CReflectedProperty *getReflectedProperty(const std::string &propertyName, bool dspWarning= true) const;
};
struct CLuaIndexedProperty
{
const CReflectedProperty *Prop;
CLuaString Id; // must keep id here, so that we are sure the string is not gc in lua and its pointer remains valid
};
struct CClassInfo
{
TReflectedProperties Properties; // the properties exported by this class
const CClassInfo *ParentClass; // pointer to infos of the parent class, or NULL if it is a root class
std::string ClassName;
/** For lua speedup (used by CLuaIHM) : because lua string are unique, we can use them to access property directly.
*/
typedef CHashMap<const char *, CLuaIndexedProperty, CLuaHashMapTraits> TLuaStrToPropMap;
mutable TLuaStrToPropMap LuaStrToProp;
};
/** Simple reflection system.
* Used by the GUI and some other objects.
* It is used to export some properties so that we can easily manipulate them in the GUI scripts (either lua or with CInterfaceExpr).
* NB: multiple inheritance not supported
*
* Example of use : a class exporting a boolean
*
* class CTestClass : public CReflectable
* {
* public:
* void setValue(bool value) { _Value = value; }
* bool getValue() const { return _Value; }
* \\ export the bool value
* REFLECT_EXPORT_START(CTestClass, CReflectable)
* REFLECT_BOOL("myValue", setValue, getValue)
* REFLECT_EXPORT_END
* private:
* bool _Value;
* };
*
* The class must then be registered with :
*
* REGISTER_REFLECTABLE_CLASS(CTestClass, CReflectable)
*
* NB: It should be registered after its parents
*
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CReflectSystem
{
public:
typedef std::map<std::string, CClassInfo> TClassMap;
public:
// release memory
static void release();
/** register a class and its properties
* NB : class should be registered after their parent have been, or an assertion will be raised
*/
static void registerClass(const std::string &className, const std::string &parentName, const TReflectedProperties properties);
// retrieve a property of a reflectable class, or NULL if unknown
static const CReflectedProperty *getProperty(const std::string &className, const std::string &propertyName, bool dspWarning= true);
// get the list of class for debug or read purpose (NULL if no register has been called)
static const TClassMap *getClassMap() {return _ClassMap;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
static TClassMap *_ClassMap; // each class and its infos
};
/** Helper macros to export properties of a reflectable class
*/
/** Start a declaration of a reflectable class exports
* Should be placed inside the class
*/
#define REFLECT_EXPORT_START(className, parentName) \
virtual const char *getReflectedClassName() const { return #className; } \
virtual const char *getReflectedParentClassName() const { return #parentName; } \
static void getReflectedProperties(TReflectedProperties &props) \
{ \
typedef className A; \
typedef bool (className::* TGetBoola) () const; \
typedef sint32 (className::* TGetSInt32a) () const; \
typedef uint32 (className::* TGetUInt32a) () const; \
typedef float (className::* TGetFloata) () const; \
typedef std::string (className::* TGetStringa) () const; \
typedef ucstring (className::* TGetUCStringa) () const; \
typedef NLMISC::CRGBA (className::* TGetRGBAa) () const; \
typedef void (className::* TSetBoola) (bool); \
typedef void (className::* TSetSInt32a) (sint32); \
typedef void (className::* TSetUInt32a) (uint32); \
typedef void (className::* TSetFloata) (float); \
typedef void (className::* TSetStringa) (const std::string &); \
typedef void (className::* TSetUCStringa) (const ucstring &); \
typedef void (className::* TSetRGBAa) (NLMISC::CRGBA col); \
typedef int (className:: *TLuaMethoda) (CLuaState &luaState); \
nlunreferenced(props);
// export a boolean value, by giving the name of the get and the set method
#define REFLECT_BOOL(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::Boolean; \
prop.GetMethod.GetBool = (CReflectedProperty::TGetBool) (TGetBoola) &A::getMethod; \
prop.SetMethod.SetBool = (CReflectedProperty::TSetBool) (TSetBoola) &A::setMethod; \
props.push_back(prop); \
}
// export a sint32 value, by giving the name of the get and the set method
#define REFLECT_SINT32(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::SInt32; \
prop.GetMethod.GetSInt32 = (CReflectedProperty::TGetSInt32) (TGetSInt32a) &A::getMethod; \
prop.SetMethod.SetSInt32 = (CReflectedProperty::TSetSInt32) (TSetSInt32a) &A::setMethod; \
props.push_back(prop); \
}
// export a sint32 value, by giving the name of the get and the set method
#define REFLECT_UINT32(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::UInt32; \
prop.GetMethod.GetUInt32 = (CReflectedProperty::TGetUInt32) (TGetUInt32a) &A::getMethod; \
prop.SetMethod.SetUInt32 = (CReflectedProperty::TSetUInt32) (TSetUInt32a) &A::setMethod; \
props.push_back(prop); \
}
// export a float value, by giving the name of the get and the set method
#define REFLECT_FLOAT(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::Float; \
prop.GetMethod.GetFloat = (CReflectedProperty::TGetFloat) (TGetFloata) &A::getMethod; \
prop.SetMethod.SetFloat = (CReflectedProperty::TSetFloat) (TSetFloata) &A::setMethod; \
props.push_back(prop); \
}
// export a string value, by giving the name of the get and the set method
#define REFLECT_STRING(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::String; \
prop.GetMethod.GetString = (CReflectedProperty::TGetString) (TGetStringa) &A::getMethod; \
prop.SetMethod.SetString = (CReflectedProperty::TSetString) (TSetStringa) &A::setMethod; \
props.push_back(prop); \
}
// export a unicode string value, by giving the name of the get and the set method
#define REFLECT_UCSTRING(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::UCString; \
prop.GetMethod.GetUCString = (CReflectedProperty::TGetUCString) (TGetUCStringa) &A::getMethod; \
prop.SetMethod.SetUCString = (CReflectedProperty::TSetUCString) (TSetUCStringa) &A::setMethod; \
props.push_back(prop); \
}
// export a color value, by giving the name of the get and the set method
#define REFLECT_RGBA(exportName, getMethod, setMethod) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::RGBA; \
prop.GetMethod.GetRGBA = (CReflectedProperty::TGetRGBA) (TGetRGBAa) &A::getMethod; \
prop.SetMethod.SetRGBA = (CReflectedProperty::TSetRGBA) (TSetRGBAa) &A::setMethod; \
props.push_back(prop); \
}
// export a lua method
#define REFLECT_LUA_METHOD(exportName, method) \
{ \
CReflectedProperty prop; \
prop.Name = exportName; \
prop.Type = CReflectedProperty::LuaMethod; \
prop.GetMethod.GetLuaMethod = (CReflectedProperty::TLuaMethod) (TLuaMethoda) &A::method; \
props.push_back(prop); \
}
// ends an export declaration
#define REFLECT_EXPORT_END }
// This macro registers a reflectable class to the manager
#define REGISTER_REFLECTABLE_CLASS(className, parentName) \
{ \
TReflectedProperties props; \
className::getReflectedProperties(props); \
CReflectSystem::registerClass(#className, #parentName, props); \
}
/** Reflectable refcounted object
* NB nico : added this intermediate class so that the binding from lua to the reflection
* system that are found in CLuaIHM can be reused for other objects as well
* NOTE: The class is named 'CReflectableRefPtrTarget' and not 'CReflectableRefCount'
* because the refcount part is only used for ref pointing in the ui
*/
class CReflectableRefPtrTarget : public CReflectable, public NLMISC::CRefCount
{
public:
virtual ~CReflectableRefPtrTarget();
};
class CReflectableLuaRef
{
public:
CReflectableLuaRef(CReflectableRefPtrTarget *ptr = NULL) : Ptr(ptr), _ClassInfo(NULL) {}
NLMISC::CRefPtr<CReflectableRefPtrTarget> Ptr;
const CClassInfo &getClassInfo() const;
// IMPORTANT : luaStringPtr should have been obtained from lua, see remark in CClassInfo
const CReflectedProperty *getProp(const char *luaStringPtr) const;
private:
// cache to class definition of the pointee object (once a CReflectableLuaRef created in lua, it remains a *const* pointer)
mutable const CClassInfo *_ClassInfo;
};
}
#endif

@ -1,32 +1,32 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef REFLECT_REG_H
#define REFLECT_REG_H
namespace NLGUI
{
/// Helper class to register reflectable classes
class CReflectableRegister
{
public:
static void registerClasses();
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef REFLECT_REG_H
#define REFLECT_REG_H
namespace NLGUI
{
/// Helper class to register reflectable classes
class CReflectableRegister
{
public:
static void registerClasses();
};
}
#endif

@ -1,29 +1,29 @@
#ifndef STRING_CASE_H
#define STRING_CASE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/ucstring.h"
namespace NLGUI
{
enum TCaseMode
{
CaseNormal = 0, // Nothing done
CaseLower, // All letters in lowercase
CaseUpper, // All letters in uppercase
CaseFirstStringLetterUp, // The first letter of the string is uppercase, the others are lowercase
CaseFirstSentenceLetterUp, // The first letter of the string and each sentences are uppercase, the others are lowercase. Sentences are seprated with '.'.
CaseFirstWordLetterUp, // The first letter of each word is uppercase, the others are lowercase
CaseCount
};
void setCase( ucstring &str, TCaseMode mode );
}
#endif
#ifndef STRING_CASE_H
#define STRING_CASE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/ucstring.h"
namespace NLGUI
{
enum TCaseMode
{
CaseNormal = 0, // Nothing done
CaseLower, // All letters in lowercase
CaseUpper, // All letters in uppercase
CaseFirstStringLetterUp, // The first letter of the string is uppercase, the others are lowercase
CaseFirstSentenceLetterUp, // The first letter of the string and each sentences are uppercase, the others are lowercase. Sentences are seprated with '.'.
CaseFirstWordLetterUp, // The first letter of each word is uppercase, the others are lowercase
CaseCount
};
void setCase( ucstring &str, TCaseMode mode );
}
#endif

@ -1,86 +1,86 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_BASE_H
#define RZ_VIEW_BASE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/factory.h"
#include "nel/gui/interface_element.h"
namespace NLGUI
{
class CViewBase : public CInterfaceElement
{
public:
// for factory construction
struct TCtorParam
{};
/// Constructor
CViewBase(const TCtorParam &/* param */) : CInterfaceElement()
{
}
/// Destructor
virtual ~CViewBase();
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return true; }
/// Draw the view from XReal, YReal, WReal, HReal (implemented by derived classes)
/// this coordinates are relative to the screen bottom left and begins the bottom left of the view
virtual void draw () = 0;
virtual void updateCoords() { CInterfaceElement::updateCoords(); }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Reflection
virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this
virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this
void copyOptionFrom(const CViewBase &other)
{
CInterfaceElement::copyOptionFrom(other);
}
REFLECT_EXPORT_START(CViewBase, CInterfaceElement)
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_EXPORT_END
virtual void dumpSize(uint depth = 0) const;
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
};
}
#endif // RZ_VIEW_BASE_H
/* End of view_base.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_BASE_H
#define RZ_VIEW_BASE_H
#include "nel/misc/types_nl.h"
#include "nel/misc/factory.h"
#include "nel/gui/interface_element.h"
namespace NLGUI
{
class CViewBase : public CInterfaceElement
{
public:
// for factory construction
struct TCtorParam
{};
/// Constructor
CViewBase(const TCtorParam &/* param */) : CInterfaceElement()
{
}
/// Destructor
virtual ~CViewBase();
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return true; }
/// Draw the view from XReal, YReal, WReal, HReal (implemented by derived classes)
/// this coordinates are relative to the screen bottom left and begins the bottom left of the view
virtual void draw () = 0;
virtual void updateCoords() { CInterfaceElement::updateCoords(); }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Reflection
virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this
virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this
void copyOptionFrom(const CViewBase &other)
{
CInterfaceElement::copyOptionFrom(other);
}
REFLECT_EXPORT_START(CViewBase, CInterfaceElement)
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_EXPORT_END
virtual void dumpSize(uint depth = 0) const;
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
};
}
#endif // RZ_VIEW_BASE_H
/* End of view_base.h */

@ -1,150 +1,150 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_BITMAP_H
#define NL_VIEW_BITMAP_H
#include "nel/gui/view_base.h"
#include "nel/3d/u_texture.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
/**
* class implementing a bitmap view
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewBitmap : public CViewBase
{
public:
DECLARE_UI_CLASS(CViewBitmap)
enum EType { Stretched = 0, Tiled, TypeCount };
public:
/// Constructor
CViewBitmap(const TCtorParam &param) : CViewBase(param)
{
_Color = NLMISC::CRGBA(255,255,255,255);
_Scale = false;
_Rot = 0;
_Flip = false;
_Tile = false;
_Align = 0;
_Type = Stretched;
_InheritGCAlpha = false;
// Default parameters for createTexture
_TxtOffsetX = 0;
_TxtOffsetY = 0;
_TxtWidth = -1;
_TxtHeight = -1;
}
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;
/**
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse
* \param cur : pointer to the xml node to be parsed
* \param parentGroup : the parent group of the view
* \partam id : a refence to the string that will receive the view ID
* \return true if success
*/
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
/// Draw the view
virtual void draw ();
bool getScale() const { return _Scale; }
void setScale (bool s) { _Scale = s; }
bool getTile() const { return _Tile; }
void setTile (bool s) { _Tile = s; }
void setColor (const NLMISC::CRGBA &r) { _Color = r; }
// Reflected
virtual void setTexture(const std::string & TxName);
virtual std::string getTexture () const;
/** Force the bitmap to match current texture size
* The 'scale' flag isnot modified
*/
void fitTexture();
bool isTextureValid() const { return _TextureId != -1; }
void setColorAsString(const std::string & col);
std::string getColorAsString() const;
void setColorAsInt(sint32 col);
sint32 getColorAsInt() const;
void setColorRGBA(NLMISC::CRGBA col);
NLMISC::CRGBA getColorRGBA() const;
virtual sint32 getAlpha() const { return _Color.A; }
virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; }
REFLECT_EXPORT_START(CViewBitmap, CViewBase)
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_STRING ("texture", getTexture, setTexture);
REFLECT_BOOL("scale", getScale, setScale);
REFLECT_EXPORT_END
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
virtual void serial(NLMISC::IStream &f);
protected:
CViewRenderer::CTextureId _TextureId; /// Accelerator
NLMISC::CRGBA _Color;
sint32 _Rot;
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
EType _Type;
bool _Scale : 1;
bool _Flip : 1;
bool _Tile : 1;
bool _InheritGCAlpha : 1;
// For single texture
sint32 _TxtOffsetX; // Offset X of the single texture
sint32 _TxtOffsetY; // Offset Y of the single texture
sint32 _TxtWidth; // Width of the single texture
sint32 _TxtHeight; // Height of the single texture
};
}
#endif // NL_VIEW_BITMAP_H
/* End of view_bitmap.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_BITMAP_H
#define NL_VIEW_BITMAP_H
#include "nel/gui/view_base.h"
#include "nel/3d/u_texture.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
/**
* class implementing a bitmap view
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewBitmap : public CViewBase
{
public:
DECLARE_UI_CLASS(CViewBitmap)
enum EType { Stretched = 0, Tiled, TypeCount };
public:
/// Constructor
CViewBitmap(const TCtorParam &param) : CViewBase(param)
{
_Color = NLMISC::CRGBA(255,255,255,255);
_Scale = false;
_Rot = 0;
_Flip = false;
_Tile = false;
_Align = 0;
_Type = Stretched;
_InheritGCAlpha = false;
// Default parameters for createTexture
_TxtOffsetX = 0;
_TxtOffsetY = 0;
_TxtWidth = -1;
_TxtHeight = -1;
}
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;
/**
* parse an xml node and initialize the base view mambers. Must call CViewBase::parse
* \param cur : pointer to the xml node to be parsed
* \param parentGroup : the parent group of the view
* \partam id : a refence to the string that will receive the view ID
* \return true if success
*/
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
/// Draw the view
virtual void draw ();
bool getScale() const { return _Scale; }
void setScale (bool s) { _Scale = s; }
bool getTile() const { return _Tile; }
void setTile (bool s) { _Tile = s; }
void setColor (const NLMISC::CRGBA &r) { _Color = r; }
// Reflected
virtual void setTexture(const std::string & TxName);
virtual std::string getTexture () const;
/** Force the bitmap to match current texture size
* The 'scale' flag isnot modified
*/
void fitTexture();
bool isTextureValid() const { return _TextureId != -1; }
void setColorAsString(const std::string & col);
std::string getColorAsString() const;
void setColorAsInt(sint32 col);
sint32 getColorAsInt() const;
void setColorRGBA(NLMISC::CRGBA col);
NLMISC::CRGBA getColorRGBA() const;
virtual sint32 getAlpha() const { return _Color.A; }
virtual void setAlpha (sint32 a) { _Color.A = (uint8)a; }
REFLECT_EXPORT_START(CViewBitmap, CViewBase)
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_SINT32 ("color_as_int", getColorAsInt, setColorAsInt);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_STRING ("texture", getTexture, setTexture);
REFLECT_BOOL("scale", getScale, setScale);
REFLECT_EXPORT_END
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
virtual void serial(NLMISC::IStream &f);
protected:
CViewRenderer::CTextureId _TextureId; /// Accelerator
NLMISC::CRGBA _Color;
sint32 _Rot;
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
EType _Type;
bool _Scale : 1;
bool _Flip : 1;
bool _Tile : 1;
bool _InheritGCAlpha : 1;
// For single texture
sint32 _TxtOffsetX; // Offset X of the single texture
sint32 _TxtOffsetY; // Offset Y of the single texture
sint32 _TxtWidth; // Width of the single texture
sint32 _TxtHeight; // Height of the single texture
};
}
#endif // NL_VIEW_BITMAP_H
/* End of view_bitmap.h */

@ -1,183 +1,183 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_BITMAP_COMBO_H
#define NL_VIEW_BITMAP_COMBO_H
#include "nel/misc/cdb.h"
#include "nel/gui/view_base.h"
#include "nel/3d/u_texture.h"
#include <string>
#include <vector>
namespace NLGUI
{
/** Description of a combo box, this can be parsed from an xml node
* The bitmap layout is as follow :
*
* I W I W I W
* t G t G t G
* e a e a e a
* m p m p m p
* W S W W
* i e i i
* d l d d
* t e t t
* h c h h
* t
* e
* d
* +----+---+----+---+---+---+---+--...
* |ssss| |****| |***| |***|
* ItemHeight |ssss| |****| |***| |***
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGapSeleted | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGap | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* . . . . . . . .
* . . . . . . . .
* s : selected item. . . . . . .
* * : where bitmap are displayed
*/
struct CComboBoxDesc
{
bool parse(xmlNodePtr cur, CInterfaceElement *owner);
void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs);
void getGridSize(uint &numRow,uint &numCol) const;
void getDimensions(uint &width, uint &height) const;
CInterfaceProperty NumRow;
CInterfaceProperty NumCol;
CInterfaceProperty CurrSelected;
CInterfaceProperty ItemWidth;
CInterfaceProperty ItemHeight;
CInterfaceProperty Unrolled;
CInterfaceProperty WGapSelected;
CInterfaceProperty WGap;
CInterfaceProperty HGapSelected;
CInterfaceProperty HGap;
CInterfaceProperty NumSel;
CInterfaceProperty Align;
};
/**
* A combo box with several bitmaps in it
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
typedef std::vector<sint32> TIdArray;
typedef std::vector<std::string> TStringArray;
typedef std::vector<NLMISC::CRGBA> TColorArray;
public:
/// ctor
CViewBitmapCombo(const TCtorParam &param);
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;
/**
* parse an xml node and initialize the base view members. Must call CViewBase::parse
* \param cur : pointer to the xml node to be parsed
* \param parentGroup : the parent group of the view
* \partam id : a refence to the string that will receive the view ID
* \return true if success
*/
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/**
* draw the view
*/
void draw();
// access to texture & colors
const TStringArray &getTexs() const { return _Texs; }
const TStringArray &getTexsOver() const { return _TexsOver; }
const TStringArray &getTexsPushed() const { return _TexsPushed; }
//
const TColorArray &getColors() const { return _Col; }
const TColorArray &getColorsOver() const { return _ColOver; }
const TColorArray &getColorsPushed() const { return _ColPushed; }
//
void setTexs(const char * const tex[], uint numTex);
void setTexsOver(const char * const tex[], uint numTex);
void setTexsPushed(const char * const tex[], uint numTex);
//
void setColors(const NLMISC::CRGBA colors[], uint numColors);
void setColorsOver(const NLMISC::CRGBA colors[], uint numColors);
void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors);
///////////////////////////////////////////////////////////////////////////////////
private:
//
TStringArray _Texs;
TStringArray _TexsOver;
TStringArray _TexsPushed;
TIdArray _TexsId;
TIdArray _TexsOverId;
TIdArray _TexsPushedId;
TColorArray _Col;
TColorArray _ColOver;
TColorArray _ColPushed;
CComboBoxDesc _CD;
CInterfaceElement *_Owner;
private:
void parseTexList(const std::string &names, TStringArray &dest);
void parseColList(const std::string &names, TColorArray &dest);
void getTexList( const TStringArray &arr, std::string &dest ) const;
void getColList( const TColorArray &arr, std::string &dest ) const;
void setupSize();
void getDimensions(uint &numRow, uint &numCol);
// From ICDBNode::IPropertyObserver
void update(NLMISC::ICDBNode *leaf);
// Return a color from the array, or white if it is empty
static NLMISC::CRGBA getCol(const TColorArray &array, uint index);
static const std::string *getTex(const TStringArray &array, uint index);
static sint32 getTexId(const TIdArray &array, uint index);
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_BITMAP_COMBO_H
#define NL_VIEW_BITMAP_COMBO_H
#include "nel/misc/cdb.h"
#include "nel/gui/view_base.h"
#include "nel/3d/u_texture.h"
#include <string>
#include <vector>
namespace NLGUI
{
/** Description of a combo box, this can be parsed from an xml node
* The bitmap layout is as follow :
*
* I W I W I W
* t G t G t G
* e a e a e a
* m p m p m p
* W S W W
* i e i i
* d l d d
* t e t t
* h c h h
* t
* e
* d
* +----+---+----+---+---+---+---+--...
* |ssss| |****| |***| |***|
* ItemHeight |ssss| |****| |***| |***
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGapSeleted | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* +----+---+----+---+---+---+---+--...
* | | | | | | | |
* HGap | | | | | | | |
* +----+---+----+---+---+---+---+--...
* |****| |****| |***| |***|
* ItemHeight |****| |****| |***| |***|
* . . . . . . . .
* . . . . . . . .
* s : selected item. . . . . . .
* * : where bitmap are displayed
*/
struct CComboBoxDesc
{
bool parse(xmlNodePtr cur, CInterfaceElement *owner);
void addObserver(NLMISC::ICDBNode::IPropertyObserver *obs);
void getGridSize(uint &numRow,uint &numCol) const;
void getDimensions(uint &width, uint &height) const;
CInterfaceProperty NumRow;
CInterfaceProperty NumCol;
CInterfaceProperty CurrSelected;
CInterfaceProperty ItemWidth;
CInterfaceProperty ItemHeight;
CInterfaceProperty Unrolled;
CInterfaceProperty WGapSelected;
CInterfaceProperty WGap;
CInterfaceProperty HGapSelected;
CInterfaceProperty HGap;
CInterfaceProperty NumSel;
CInterfaceProperty Align;
};
/**
* A combo box with several bitmaps in it
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CViewBitmapCombo : public CViewBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
typedef std::vector<sint32> TIdArray;
typedef std::vector<std::string> TStringArray;
typedef std::vector<NLMISC::CRGBA> TColorArray;
public:
/// ctor
CViewBitmapCombo(const TCtorParam &param);
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;
/**
* parse an xml node and initialize the base view members. Must call CViewBase::parse
* \param cur : pointer to the xml node to be parsed
* \param parentGroup : the parent group of the view
* \partam id : a refence to the string that will receive the view ID
* \return true if success
*/
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/**
* draw the view
*/
void draw();
// access to texture & colors
const TStringArray &getTexs() const { return _Texs; }
const TStringArray &getTexsOver() const { return _TexsOver; }
const TStringArray &getTexsPushed() const { return _TexsPushed; }
//
const TColorArray &getColors() const { return _Col; }
const TColorArray &getColorsOver() const { return _ColOver; }
const TColorArray &getColorsPushed() const { return _ColPushed; }
//
void setTexs(const char * const tex[], uint numTex);
void setTexsOver(const char * const tex[], uint numTex);
void setTexsPushed(const char * const tex[], uint numTex);
//
void setColors(const NLMISC::CRGBA colors[], uint numColors);
void setColorsOver(const NLMISC::CRGBA colors[], uint numColors);
void setColorsPushed(const NLMISC::CRGBA colors[], uint numColors);
///////////////////////////////////////////////////////////////////////////////////
private:
//
TStringArray _Texs;
TStringArray _TexsOver;
TStringArray _TexsPushed;
TIdArray _TexsId;
TIdArray _TexsOverId;
TIdArray _TexsPushedId;
TColorArray _Col;
TColorArray _ColOver;
TColorArray _ColPushed;
CComboBoxDesc _CD;
CInterfaceElement *_Owner;
private:
void parseTexList(const std::string &names, TStringArray &dest);
void parseColList(const std::string &names, TColorArray &dest);
void getTexList( const TStringArray &arr, std::string &dest ) const;
void getColList( const TColorArray &arr, std::string &dest ) const;
void setupSize();
void getDimensions(uint &numRow, uint &numCol);
// From ICDBNode::IPropertyObserver
void update(NLMISC::ICDBNode *leaf);
// Return a color from the array, or white if it is empty
static NLMISC::CRGBA getCol(const TColorArray &array, uint index);
static const std::string *getTex(const TStringArray &array, uint index);
static sint32 getTexId(const TIdArray &array, uint index);
};
}
#endif

@ -1,62 +1,62 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_LINK_H
#define NL_VIEW_LINK_H
#include "nel/gui/view_text.h"
namespace NLGUI
{
class CGroupHTML;
/**
* class implementing a link view
* \author Cyril 'Hulud' Corvazier
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CViewLink : public CViewText
{
public:
// Default constructor
CViewLink (const TCtorParam &param);
// The URI
std::string Link;
std::string LinkTitle;
// Set the main group
void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
protected:
// The main HTML group
CGroupHTML *HTML;
};
}
#endif // NL_VIEW_LINK_H
/* End of view_link.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_LINK_H
#define NL_VIEW_LINK_H
#include "nel/gui/view_text.h"
namespace NLGUI
{
class CGroupHTML;
/**
* class implementing a link view
* \author Cyril 'Hulud' Corvazier
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CViewLink : public CViewText
{
public:
// Default constructor
CViewLink (const TCtorParam &param);
// The URI
std::string Link;
std::string LinkTitle;
// Set the main group
void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
protected:
// The main HTML group
CGroupHTML *HTML;
};
}
#endif // NL_VIEW_LINK_H
/* End of view_link.h */

@ -1,143 +1,143 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_POINTER_H
#define RZ_VIEW_POINTER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
#include "nel/gui/view_pointer_base.h"
namespace NLGUI
{
class CCtrlBase;
class CGroupContainer;
/**
* class describing the pointer
* \author Matthieu 'Trap' Besson
* \author Nevrax France
* \date 2002
*/
class CViewPointer : public CViewPointerBase
{
public:
DECLARE_UI_CLASS( CViewPointer )
CViewPointer( const TCtorParam &param );
virtual ~CViewPointer(){}
bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
void draw();
// Set cursor mode
void setStringMode (bool stringCursor);
bool getStringMode() const {return _StringMode;}
// Set cursor string
void setString (const ucstring &str);
// TEMP PATCH
void setCursor (const std::string &name)
{
_TxDefault = name;
_TxIdDefault = -2;
}
// TEMP PATCH
/// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead.
void show(bool s) {_PointerVisible = s;}
static void setHWMouse( bool hw ){ hwMouse = hw; }
static void forceLink();
private:
/// Drawing helpers
virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawCustom(CCtrlBase* pCB);
protected:
// Look of the cursor in different situation
std::string _TxDefault;
std::string _TxMoveWindow;
std::string _TxResizeBRTL;
std::string _TxResizeBLTR;
std::string _TxResizeTB;
std::string _TxResizeLR;
std::string _TxRotate;
std::string _TxScale;
std::string _TxColPick;
std::string _TxPan;
std::string _TxCanPan;
std::string _TxPanR2;
std::string _TxCanPanR2;
sint32 _TxIdDefault;
sint32 _TxIdMoveWindow;
sint32 _TxIdResizeBRTL;
sint32 _TxIdResizeBLTR;
sint32 _TxIdResizeTB;
sint32 _TxIdResizeLR;
sint32 _TxIdRotate;
sint32 _TxIdScale;
sint32 _TxIdColPick;
sint32 _TxIdPan;
sint32 _TxIdCanPan;
sint32 _TxIdPanR2;
sint32 _TxIdCanPanR2;
NLMISC::CRGBA _Color;
sint32 _OffsetX;
sint32 _OffsetY;
CGroupContainer *_LastHightLight;
// Cursor mode
bool _StringMode;
bool _ForceStringMode;
CInterfaceGroup *_StringCursor;
CInterfaceGroup *_StringCursorHardware;
ucstring _ContextString;
// draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape
void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot);
private:
// set the string into frame for software or hardware version
void setString (const ucstring &str, CInterfaceGroup *target);
static bool hwMouse;
};
}
#endif // RZ_VIEW_POINTER_H
/* End of view_pointer.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_POINTER_H
#define RZ_VIEW_POINTER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
#include "nel/gui/view_pointer_base.h"
namespace NLGUI
{
class CCtrlBase;
class CGroupContainer;
/**
* class describing the pointer
* \author Matthieu 'Trap' Besson
* \author Nevrax France
* \date 2002
*/
class CViewPointer : public CViewPointerBase
{
public:
DECLARE_UI_CLASS( CViewPointer )
CViewPointer( const TCtorParam &param );
virtual ~CViewPointer(){}
bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
void draw();
// Set cursor mode
void setStringMode (bool stringCursor);
bool getStringMode() const {return _StringMode;}
// Set cursor string
void setString (const ucstring &str);
// TEMP PATCH
void setCursor (const std::string &name)
{
_TxDefault = name;
_TxIdDefault = -2;
}
// TEMP PATCH
/// Show or hide the pointer. Please, use SetMouseMode (bool freelook) instead.
void show(bool s) {_PointerVisible = s;}
static void setHWMouse( bool hw ){ hwMouse = hw; }
static void forceLink();
private:
/// Drawing helpers
virtual bool drawResizer(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawRotate(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawScale(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawColorPicker(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawLink(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawBrowse(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawPan(CCtrlBase* pCB, NLMISC::CRGBA col){ return false; }
virtual bool drawCustom(CCtrlBase* pCB);
protected:
// Look of the cursor in different situation
std::string _TxDefault;
std::string _TxMoveWindow;
std::string _TxResizeBRTL;
std::string _TxResizeBLTR;
std::string _TxResizeTB;
std::string _TxResizeLR;
std::string _TxRotate;
std::string _TxScale;
std::string _TxColPick;
std::string _TxPan;
std::string _TxCanPan;
std::string _TxPanR2;
std::string _TxCanPanR2;
sint32 _TxIdDefault;
sint32 _TxIdMoveWindow;
sint32 _TxIdResizeBRTL;
sint32 _TxIdResizeBLTR;
sint32 _TxIdResizeTB;
sint32 _TxIdResizeLR;
sint32 _TxIdRotate;
sint32 _TxIdScale;
sint32 _TxIdColPick;
sint32 _TxIdPan;
sint32 _TxIdCanPan;
sint32 _TxIdPanR2;
sint32 _TxIdCanPanR2;
NLMISC::CRGBA _Color;
sint32 _OffsetX;
sint32 _OffsetY;
CGroupContainer *_LastHightLight;
// Cursor mode
bool _StringMode;
bool _ForceStringMode;
CInterfaceGroup *_StringCursor;
CInterfaceGroup *_StringCursorHardware;
ucstring _ContextString;
// draw current cursor with the given texture, or, if in hardware mode, change the hardware cursor shape
void drawCursor(sint32 texId, NLMISC::CRGBA col, uint8 rot);
private:
// set the string into frame for software or hardware version
void setString (const ucstring &str, CInterfaceGroup *target);
static bool hwMouse;
};
}
#endif // RZ_VIEW_POINTER_H
/* End of view_pointer.h */

@ -1,85 +1,85 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_POINTER_BASE_H
#define VIEW_POINTER_BASE_H
#include "nel/misc/events.h"
#include "nel/gui/view_base.h"
namespace NLGUI
{
class CViewPointerBase : public CViewBase
{
public:
DECLARE_UI_CLASS( CViewPointerBase )
CViewPointerBase( const TCtorParam &param );
virtual ~CViewPointerBase();
// Set the pointer position.
void setPointerPos (sint32 x, sint32 y);
void setPointerDispPos (sint32 x, sint32 y);
void resetPointerPos ();
void setPointerDown (bool pd);
void setPointerDownString (const std::string &s);
void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y);
void getPointerOldPos (sint32 &x, sint32 &y);
void getPointerDownPos (sint32 &x, sint32 &y);
bool getPointerDown ();
std::string getPointerDownString ();
bool getPointerDrag ();
/// Is the pointer visible ?
bool show() const {return _PointerVisible;}
void draw(){}
/// set button state
void setButtonState(NLMISC::TMouseButton state) { _Buttons = state; }
/// get buttons state
NLMISC::TMouseButton getButtonState() const { return _Buttons; }
protected:
// (x,y) is from the TopLeft corner of the window
sint32 _PointerX; // Current pointer position (raw, before snapping)
sint32 _PointerY;
sint32 _PointerOldX; // Previous frame pointer position
sint32 _PointerOldY;
bool _PointerDown; // Is the pointer down ?
sint32 _PointerDownX; // Pointer down position
sint32 _PointerDownY;
std::string _PointerDownString; // What is under the pointer at the down position
bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ?
NLMISC::TMouseButton _Buttons;
private:
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_POINTER_BASE_H
#define VIEW_POINTER_BASE_H
#include "nel/misc/events.h"
#include "nel/gui/view_base.h"
namespace NLGUI
{
class CViewPointerBase : public CViewBase
{
public:
DECLARE_UI_CLASS( CViewPointerBase )
CViewPointerBase( const TCtorParam &param );
virtual ~CViewPointerBase();
// Set the pointer position.
void setPointerPos (sint32 x, sint32 y);
void setPointerDispPos (sint32 x, sint32 y);
void resetPointerPos ();
void setPointerDown (bool pd);
void setPointerDownString (const std::string &s);
void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y);
void getPointerOldPos (sint32 &x, sint32 &y);
void getPointerDownPos (sint32 &x, sint32 &y);
bool getPointerDown ();
std::string getPointerDownString ();
bool getPointerDrag ();
/// Is the pointer visible ?
bool show() const {return _PointerVisible;}
void draw(){}
/// set button state
void setButtonState(NLMISC::TMouseButton state) { _Buttons = state; }
/// get buttons state
NLMISC::TMouseButton getButtonState() const { return _Buttons; }
protected:
// (x,y) is from the TopLeft corner of the window
sint32 _PointerX; // Current pointer position (raw, before snapping)
sint32 _PointerY;
sint32 _PointerOldX; // Previous frame pointer position
sint32 _PointerOldY;
bool _PointerDown; // Is the pointer down ?
sint32 _PointerDownX; // Pointer down position
sint32 _PointerDownY;
std::string _PointerDownString; // What is under the pointer at the down position
bool _PointerDrag; // Is the pointer down and we have moved ?
bool _PointerVisible; // Is the pointer visible or hidden ?
NLMISC::TMouseButton _Buttons;
private:
};
}
#endif

@ -1,61 +1,61 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_POLYGON_H
#define RZ_VIEW_POLYGON_H
#include "nel/gui/view_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
#include "nel/misc/polygon.h"
namespace NLGUI
{
/** Display of an arbitrary polygon in the ui.
* polygon is clipped & batched
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 1/2006
*/
class CViewPolygon : public CViewBase
{
public:
CViewPolygon();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords();
virtual void draw();
void setVertices(const std::vector<NLMISC::CVector> &vertices);
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
private:
NLMISC::CPolygon _Poly;
bool _Touched;
NLMISC::CRGBA _Color;
std::vector<NLMISC::CTriangle> _Tris;
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_POLYGON_H
#define RZ_VIEW_POLYGON_H
#include "nel/gui/view_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
#include "nel/misc/polygon.h"
namespace NLGUI
{
/** Display of an arbitrary polygon in the ui.
* polygon is clipped & batched
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 1/2006
*/
class CViewPolygon : public CViewBase
{
public:
CViewPolygon();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords();
virtual void draw();
void setVertices(const std::vector<NLMISC::CVector> &vertices);
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
private:
NLMISC::CPolygon _Poly;
bool _Touched;
NLMISC::CRGBA _Color;
std::vector<NLMISC::CTriangle> _Tris;
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
};
}
#endif

@ -1,94 +1,94 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_QUAD_H
#define RZ_VIEW_QUAD_H
#include "nel/gui/view_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
namespace NLGUI
{
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
* are driven by the quad vertices coordinates (see setQuad)
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 12/2005
*/
class CViewQuad : public CViewBase
{
public:
enum TWrapMode { Repeat = 0, Clamp, WrapModeCount };
CViewQuad();
// from CInterfaceElement
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
virtual void updateCoords();
virtual void draw();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
// texture
void setTexture(const std::string &texName);
std::string getTexture () const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
/** Set a new quad relative to parent pos
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
*/
void setQuad(const NLMISC::CQuad &quad);
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
/** Fit the given texture size (no hotspot for now, always centered)
* NB : current texture is not modified.
*/
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
const NLMISC::CQuad &getQuad() const { return _Quad; }
void setAdditif(bool additif);
bool getAdditif() const { return _Additif; }
void setPattern(float umin, float umax, TWrapMode wrapMode);
private:
NLMISC::CRGBA _Color;
NLMISC::CQuad _Quad;
NLMISC::CQuadUV _RealQuad; // absolute coords
float _ClampedUCorrection;
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _Additif;
float _UMin;
float _UMax;
TWrapMode _WrapMode;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef RZ_VIEW_QUAD_H
#define RZ_VIEW_QUAD_H
#include "nel/gui/view_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
namespace NLGUI
{
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
* are driven by the quad vertices coordinates (see setQuad)
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 12/2005
*/
class CViewQuad : public CViewBase
{
public:
enum TWrapMode { Repeat = 0, Clamp, WrapModeCount };
CViewQuad();
// from CInterfaceElement
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
virtual void updateCoords();
virtual void draw();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
// texture
void setTexture(const std::string &texName);
std::string getTexture () const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
/** Set a new quad relative to parent pos
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
*/
void setQuad(const NLMISC::CQuad &quad);
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
/** Fit the given texture size (no hotspot for now, always centered)
* NB : current texture is not modified.
*/
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
const NLMISC::CQuad &getQuad() const { return _Quad; }
void setAdditif(bool additif);
bool getAdditif() const { return _Additif; }
void setPattern(float umin, float umax, TWrapMode wrapMode);
private:
NLMISC::CRGBA _Color;
NLMISC::CQuad _Quad;
NLMISC::CQuadUV _RealQuad; // absolute coords
float _ClampedUCorrection;
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _Additif;
float _UMin;
float _UMax;
TWrapMode _WrapMode;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,419 +1,419 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_TEXT_H
#define NL_VIEW_TEXT_H
#include "nel/gui/view_base.h"
#include "nel/gui/string_case.h"
#include "nel/3d/u_text_context.h"
namespace NLGUI
{
class CCtrlToolTip;
/**
* class implementing a text view
* \author Matthieu 'TrapII' Besson
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CViewText : public CViewBase
{
public:
enum TTextMode { ClipWord, DontClipWord, Justified };
public:
DECLARE_UI_CLASS(CViewText)
/// Constructor
CViewText (const TCtorParam &param);
/// Constructor
CViewText (const std::string& id, const std::string Text="", sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false);
virtual ~CViewText();
CViewText &operator=(const CViewText &vt);
std::string getProperty( const std::string &name ) const;
std::string getTextProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
bool setTextProperty( const std::string &name, const std::string &value );
bool serializeTextOptions( xmlNodePtr node ) const;
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
void parseTextOptions (xmlNodePtr cur);
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Updating
virtual void draw ();
void updateTextContext ();
virtual void checkCoords();
virtual void updateCoords();
virtual void onAddToGroup();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
/// Accessors
/// Set
void setText (const ucstring &text);
void setFontSize (sint nFontSize);
void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow);
void setShadowColor (const NLMISC::CRGBA &color);
void setLineMaxW (sint nMaxW, bool invalidate=true);
void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state);
void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance
void setFirstLineX (uint firstLineX);
void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
// Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
void enableStringSelection(uint start, uint end);
void disableStringSelection();
/// Get
ucstring getText() const { return _Text; }
sint getFontSize() const;
NLMISC::CRGBA getColor() { return _Color; }
bool getShadow() { return _Shadow; }
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
sint getLineMaxW() const { return _LineMaxW; }
bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
uint32 getMultiMaxLine() const { return _MultiMaxLine; }
// get current Hint font width, in pixels
uint getFontWidth() const;
// get current font height, in pixels
uint getFontHeight() const;
// get current font leg height, in pixels
uint getFontLegHeight() const;
// Set the display mode (supported with multiline only for now)
void setTextMode(TTextMode mode);
TTextMode getTextMode() const { return _TextMode; }
uint getNumLine() const;
uint getFirstLineX() const;
uint getLastLineW () const;
void setUnderlined (bool underlined) { _Underlined = underlined; }
bool getUnderlined () const { return _Underlined; }
// true if the viewText is a single line clamped.
bool isSingleLineTextClamped() const {return _SingleLineTextClamped;}
// Character positions
/** Get position of the ith character, position are relative to the BR corner of the text.
* \param lineEnd. When set to true, return the coordinate of the previous line if the index is at the start of a line.
* When looking at standard edit box, we see that if a line is split accross to line with no
* This also returns the height of the line
*/
void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const;
/** From a coordinate relative to the BR BR corner of the text, return the index of a character.
* If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text)
*/
void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const;
/** From a character index, get the index of the line it belongs to, or -1 if the index is invalid
* \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index
*/
sint getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine = true) const;
/// From a line number, get the character at which it starts, or -1 if invalid
sint getLineStartIndex(uint line) const;
/// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
std::string getHardText() const { std::string result; _Text.toString (result); return result; }
void setHardText (const std::string &ht);
std::string getColorAsString() const;
void setColorAsString(const std::string &ht);
NLMISC::CRGBA getColorRGBA() const;
void setColorRGBA(NLMISC::CRGBA col);
virtual sint32 getAlpha() const { return _Color.A; }
virtual void setAlpha (sint32 a) { _ShadowColor.A = _Color.A = (uint8)a; }
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
*/
void setTextFormatTaged(const ucstring &text);
void setSingleLineTextFormatTaged(const ucstring &text);
// Remove end space
void removeEndSpaces();
// Reset the text index because the text context has changed
void resetTextIndex();
// Case mode
void setCaseMode (TCaseMode caseMode);
TCaseMode getCaseMode () const;
// OverExtendViewText
void setOverExtendViewText(bool state) {_OverExtendViewText= state;}
bool getOverExtendViewText() const {return _OverExtendViewText;}
// OverExtendViewTextUseParentRect
void setOverExtendViewTextUseParentRect(bool state) {_OverExtendViewTextUseParentRect= state;}
bool getOverExtendViewTextUseParentRect() const {return _OverExtendViewTextUseParentRect;}
// see if text ellipsis if done at right side of the text
bool isClampRight() const { return _ClampRight; }
int luaSetLineMaxW(CLuaState &ls);
REFLECT_EXPORT_START(CViewText, CViewBase)
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_UCSTRING("uc_hardtext", getText, setText);
REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged);
REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged);
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_BOOL ("overExtendViewText", getOverExtendViewText, setOverExtendViewText);
REFLECT_BOOL ("overExtendViewTextUseParentRect", getOverExtendViewTextUseParentRect, setOverExtendViewTextUseParentRect);
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
REFLECT_EXPORT_END
virtual void serial(NLMISC::IStream &f);
protected:
std::string _HardtextFormat;
/// Text to display.
ucstring _Text;
/// index of the computed String associated to this text control
uint _Index;
/// info on the computed String associated to this text control
NL3D::UTextContext::CStringInfo _Info;
/// the font size
sint _FontSize;
// width of the font in pixel. Just a Hint for tabing format (computed with '_')
uint _FontWidth;
// height of the font in pixel.
// use getFontHeight
uint _FontHeight;
uint _FontLegHeight;
float _SpaceWidth;
/// the text color
NLMISC::CRGBA _Color;
/// the shadow mode
bool _Shadow;
/// the case mode
TCaseMode _CaseMode;
/// the text shadow color
NLMISC::CRGBA _ShadowColor;
/// Is the line (under p loop) should be considered at bottom (if false bottom is under p leg)
/// maxw for the line/multiline
sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped;
/// Multiple lines handling
bool _MultiLine;
bool _MultiLineMaxWOnly;
bool _MultiLineClipEndSpace;
uint8 _AutoClampOffset;
TTextMode _TextMode;
sint _MultiLineSpace;
sint _LastMultiLineMaxW;
uint32 _MultiMaxLine;
/// FormatTag handling
struct CFormatInfo
{
// The color to change
NLMISC::CRGBA Color;
// The Tabulation to apply, in number of "_" characters.
uint TabX;
// Index in vector
sint IndexTt;
CFormatInfo()
{
Color= NLMISC::CRGBA::White;
TabX= 0;
IndexTt = -1;
}
bool operator==(const CFormatInfo &o) const {return Color==o.Color && TabX==o.TabX && IndexTt==o.IndexTt;}
bool operator!=(const CFormatInfo &o) const {return !operator==(o);}
};
struct CFormatTag : public CFormatInfo
{
uint Index;
// compare 2 tags, not a tag and a CFormatInfo
bool sameTag(const CFormatTag &o) const
{
return CFormatInfo::operator==(o) && Index==o.Index;
}
};
std::vector<CFormatTag> _FormatTags;
/// Get the current maxW for multiline, accordgin to parent and _MultiLineOptionMaxW
sint getCurrentMultiLineMaxW() const;
NL3D::ULetterColors * _LetterColors;
private:
// A word in a line
class CWord
{
public:
// default ctor
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
ucstring Text;
uint Index; // index of the info for this word
NL3D::UTextContext::CStringInfo Info;
uint NumSpaces; // number of spaces before this word
// The specialized color/format of this word. White if none
CFormatInfo Format;
public:
// build from a string, using the current text context
void build(const ucstring &text, uint numSpaces= 0);
};
typedef std::vector<CWord> TWordVect;
// A line of text (which is made of one word with space, or of several words with no spaces in them)
class CLine : public NLMISC::CRefCount
{
public:
// ctor
CLine();
// Clear the line & remove text contexts
void clear();
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth);
void addWord(const CWord &word, uint fontWidth);
uint getNumWords() const { return (uint)_Words.size(); }
CWord &getWord(uint index) { return _Words[index]; }
float getSpaceWidth() const { return _SpaceWidth; }
void setSpaceWidth(float width) { _SpaceWidth = width; }
// Get the number of chars in the line, not counting the end spaces, but couting the spaces in words
uint getNumChars() const { return _NumChars; }
// Get the total number of spaces between words (not including those in words, but there should not be if text is justified)
uint getNumSpaces() const { return _NumSpaces; }
float getStringLine() const { return _StringLine; }
float getWidthWithoutSpaces() const { return _WidthWithoutSpaces; }
// get total width including spaces, but not including end spaces
float getWidth() const { return _WidthWithoutSpaces + _SpaceWidth * _NumSpaces; }
// Get the number of spaces at the end of the line
void setEndSpaces(uint numSpaces) { _EndSpaces = numSpaces; }
// Set the number of spaces at the end of the line
uint getEndSpaces() const { return _EndSpaces; }
// Test if there's a line feed at the end of the line
bool getLF() const { return _HasLF; }
void setLF(bool lf) { _HasLF = lf; }
void resetTextIndex();
private:
TWordVect _Words;
uint _NumChars;
uint _NumSpaces;
float _SpaceWidth; // width of a space, in pixels (used with multispace alignment)
float _StringLine;
float _WidthWithoutSpaces; // width without space (see the Field NumSpaces in the CWord class).
// NB : space inserted inside a word are counted, however!
uint _EndSpaces; // spaces at the end of the line
bool _HasLF; // a linefeed is at end of line (no breaking due to line full)
};
/// NB : we keep pointers on lines (each line contains a vector, that we don't want to be copied, and this occurs as the vector of lines grows..)
typedef NLMISC::CSmartPtr<CLine> TLineSPtr;
typedef std::vector<TLineSPtr> TLinePtVect;
private:
/** Data of the updated text for multiline. It is built from the _Text field in the updateTextContext member function,
* and is used to perform the draw
*/
TLinePtVect _Lines;
/// if true, and if the view text is isSingleLineTextClamped(), then an over will be drawn, with the text
bool _OverExtendViewText : 1;
/// if true and _OverExtendViewText true too, use the parent rectangle to know if must display the over or not
bool _OverExtendViewTextUseParentRect : 1;
/// Letter selection handling
bool _AutoClamp : 1;
bool _ClampRight : 1;
bool _TextSelection : 1;
bool _InvalidTextContext : 1;
bool _Underlined : 1;
bool _ContinuousUpdate : 1;
bool _Setuped : 1;
uint _TextSelectionStart;
uint _TextSelectionEnd;
// First line X coordinate
uint _FirstLineX;
/// Dynamic tooltips
std::vector<CCtrlToolTip*> _Tooltips;
private:
void setup ();
void setupDefault ();
void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd);
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
/// \from CInterfaceElement
void onInvalidateContent();
// may append a new line, and append a word to the last line (no spaces)
void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
// Clear all the lines and free their datas
void clearLines();
// Update in the case of a multiline text
void updateTextContextMultiLine(uint nMaxWidth);
// Update in the case of a multiline text with justification
void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces);
// Recompute font size info
void computeFontSize ();
// used for "donctClipWord" case in updateTextContextMultiLineJustified(). currLine is reseted
void addDontClipWordLine(std::vector<CWord> &currLine);
// FormatTag build.
static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
// FormatTag parsing.
bool isFormatTagChange(uint textIndex, uint ctIndex) const;
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;
};
}
#endif // NL_VIEW_TEXT_H
/* End of view_text.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_TEXT_H
#define NL_VIEW_TEXT_H
#include "nel/gui/view_base.h"
#include "nel/gui/string_case.h"
#include "nel/3d/u_text_context.h"
namespace NLGUI
{
class CCtrlToolTip;
/**
* class implementing a text view
* \author Matthieu 'TrapII' Besson
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CViewText : public CViewBase
{
public:
enum TTextMode { ClipWord, DontClipWord, Justified };
public:
DECLARE_UI_CLASS(CViewText)
/// Constructor
CViewText (const TCtorParam &param);
/// Constructor
CViewText (const std::string& id, const std::string Text="", sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false);
virtual ~CViewText();
CViewText &operator=(const CViewText &vt);
std::string getProperty( const std::string &name ) const;
std::string getTextProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
bool setTextProperty( const std::string &name, const std::string &value );
bool serializeTextOptions( xmlNodePtr node ) const;
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
void parseTextOptions (xmlNodePtr cur);
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Updating
virtual void draw ();
void updateTextContext ();
virtual void checkCoords();
virtual void updateCoords();
virtual void onAddToGroup();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
/// Accessors
/// Set
void setText (const ucstring &text);
void setFontSize (sint nFontSize);
void setColor (const NLMISC::CRGBA &color);
void setShadow (bool bShadow);
void setShadowColor (const NLMISC::CRGBA &color);
void setLineMaxW (sint nMaxW, bool invalidate=true);
void setMultiLine (bool bMultiLine);
void setMultiLineSpace (sint nMultiLineSpace);
void setMultiLineMaxWOnly (bool state);
void setMultiLineClipEndSpace (bool state); // use it for multiline edit box for instance
void setFirstLineX (uint firstLineX);
void setMultiMaxLine(uint l) { _MultiMaxLine = l; }
// Force only a subset of letter to be displayed. Default is 0/0xFFFFFFFF
void enableStringSelection(uint start, uint end);
void disableStringSelection();
/// Get
ucstring getText() const { return _Text; }
sint getFontSize() const;
NLMISC::CRGBA getColor() { return _Color; }
bool getShadow() { return _Shadow; }
NLMISC::CRGBA getShadowColor() { return _ShadowColor; }
sint getLineMaxW() const { return _LineMaxW; }
bool getMultiLine() const { return _MultiLine; }
sint getMultiLineSpace() const { return _MultiLineSpace; }
bool getMultiLineMaxWOnly() const { return _MultiLineMaxWOnly; }
uint32 getMultiMaxLine() const { return _MultiMaxLine; }
// get current Hint font width, in pixels
uint getFontWidth() const;
// get current font height, in pixels
uint getFontHeight() const;
// get current font leg height, in pixels
uint getFontLegHeight() const;
// Set the display mode (supported with multiline only for now)
void setTextMode(TTextMode mode);
TTextMode getTextMode() const { return _TextMode; }
uint getNumLine() const;
uint getFirstLineX() const;
uint getLastLineW () const;
void setUnderlined (bool underlined) { _Underlined = underlined; }
bool getUnderlined () const { return _Underlined; }
// true if the viewText is a single line clamped.
bool isSingleLineTextClamped() const {return _SingleLineTextClamped;}
// Character positions
/** Get position of the ith character, position are relative to the BR corner of the text.
* \param lineEnd. When set to true, return the coordinate of the previous line if the index is at the start of a line.
* When looking at standard edit box, we see that if a line is split accross to line with no
* This also returns the height of the line
*/
void getCharacterPositionFromIndex(sint index, bool lineEnd, sint &x, sint &y, sint &height) const;
/** From a coordinate relative to the BR BR corner of the text, return the index of a character.
* If no character is found at the given position, the closest character is returned (first or last character, for the line or the whole text)
*/
void getCharacterIndexFromPosition(sint x, sint y, uint &index, bool &lineEnd) const;
/** From a character index, get the index of the line it belongs to, or -1 if the index is invalid
* \param cursorDisplayedAtEndOfPreviousLine true if the cursor is displayed at the end of the previous line that match its index
*/
sint getLineFromIndex(uint index, bool cursorDisplayedAtEndOfPreviousLine = true) const;
/// From a line number, get the character at which it starts, or -1 if invalid
sint getLineStartIndex(uint line) const;
/// From a line number, get the character at which it ends (not including any '\n' ), or -1 if invalid
void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const;
std::string getHardText() const { std::string result; _Text.toString (result); return result; }
void setHardText (const std::string &ht);
std::string getColorAsString() const;
void setColorAsString(const std::string &ht);
NLMISC::CRGBA getColorRGBA() const;
void setColorRGBA(NLMISC::CRGBA col);
virtual sint32 getAlpha() const { return _Color.A; }
virtual void setAlpha (sint32 a) { _ShadowColor.A = _Color.A = (uint8)a; }
/** Setup a Text with Format Tags. Text is store without color/format tags, and special array is allocated for Format association
*/
void setTextFormatTaged(const ucstring &text);
void setSingleLineTextFormatTaged(const ucstring &text);
// Remove end space
void removeEndSpaces();
// Reset the text index because the text context has changed
void resetTextIndex();
// Case mode
void setCaseMode (TCaseMode caseMode);
TCaseMode getCaseMode () const;
// OverExtendViewText
void setOverExtendViewText(bool state) {_OverExtendViewText= state;}
bool getOverExtendViewText() const {return _OverExtendViewText;}
// OverExtendViewTextUseParentRect
void setOverExtendViewTextUseParentRect(bool state) {_OverExtendViewTextUseParentRect= state;}
bool getOverExtendViewTextUseParentRect() const {return _OverExtendViewTextUseParentRect;}
// see if text ellipsis if done at right side of the text
bool isClampRight() const { return _ClampRight; }
int luaSetLineMaxW(CLuaState &ls);
REFLECT_EXPORT_START(CViewText, CViewBase)
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_UCSTRING("uc_hardtext", getText, setText);
REFLECT_UCSTRING("uc_hardtext_format", getText, setTextFormatTaged);
REFLECT_UCSTRING("uc_hardtext_single_line_format", getText, setSingleLineTextFormatTaged);
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_RGBA ("color_rgba", getColorRGBA, setColorRGBA);
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_BOOL ("overExtendViewText", getOverExtendViewText, setOverExtendViewText);
REFLECT_BOOL ("overExtendViewTextUseParentRect", getOverExtendViewTextUseParentRect, setOverExtendViewTextUseParentRect);
REFLECT_LUA_METHOD("setLineMaxW", luaSetLineMaxW);
REFLECT_EXPORT_END
virtual void serial(NLMISC::IStream &f);
protected:
std::string _HardtextFormat;
/// Text to display.
ucstring _Text;
/// index of the computed String associated to this text control
uint _Index;
/// info on the computed String associated to this text control
NL3D::UTextContext::CStringInfo _Info;
/// the font size
sint _FontSize;
// width of the font in pixel. Just a Hint for tabing format (computed with '_')
uint _FontWidth;
// height of the font in pixel.
// use getFontHeight
uint _FontHeight;
uint _FontLegHeight;
float _SpaceWidth;
/// the text color
NLMISC::CRGBA _Color;
/// the shadow mode
bool _Shadow;
/// the case mode
TCaseMode _CaseMode;
/// the text shadow color
NLMISC::CRGBA _ShadowColor;
/// Is the line (under p loop) should be considered at bottom (if false bottom is under p leg)
/// maxw for the line/multiline
sint32 _LineMaxW;
/// For single line, true if the text is clamped (ie displayed with "...")
bool _SingleLineTextClamped;
/// Multiple lines handling
bool _MultiLine;
bool _MultiLineMaxWOnly;
bool _MultiLineClipEndSpace;
uint8 _AutoClampOffset;
TTextMode _TextMode;
sint _MultiLineSpace;
sint _LastMultiLineMaxW;
uint32 _MultiMaxLine;
/// FormatTag handling
struct CFormatInfo
{
// The color to change
NLMISC::CRGBA Color;
// The Tabulation to apply, in number of "_" characters.
uint TabX;
// Index in vector
sint IndexTt;
CFormatInfo()
{
Color= NLMISC::CRGBA::White;
TabX= 0;
IndexTt = -1;
}
bool operator==(const CFormatInfo &o) const {return Color==o.Color && TabX==o.TabX && IndexTt==o.IndexTt;}
bool operator!=(const CFormatInfo &o) const {return !operator==(o);}
};
struct CFormatTag : public CFormatInfo
{
uint Index;
// compare 2 tags, not a tag and a CFormatInfo
bool sameTag(const CFormatTag &o) const
{
return CFormatInfo::operator==(o) && Index==o.Index;
}
};
std::vector<CFormatTag> _FormatTags;
/// Get the current maxW for multiline, accordgin to parent and _MultiLineOptionMaxW
sint getCurrentMultiLineMaxW() const;
NL3D::ULetterColors * _LetterColors;
private:
// A word in a line
class CWord
{
public:
// default ctor
CWord(uint numSpaces = 0) : Index(0), NumSpaces(numSpaces) {}
ucstring Text;
uint Index; // index of the info for this word
NL3D::UTextContext::CStringInfo Info;
uint NumSpaces; // number of spaces before this word
// The specialized color/format of this word. White if none
CFormatInfo Format;
public:
// build from a string, using the current text context
void build(const ucstring &text, uint numSpaces= 0);
};
typedef std::vector<CWord> TWordVect;
// A line of text (which is made of one word with space, or of several words with no spaces in them)
class CLine : public NLMISC::CRefCount
{
public:
// ctor
CLine();
// Clear the line & remove text contexts
void clear();
// Add a new word (and its context) in the line + a number of spaces to append at the end of the line
void addWord(const ucstring &word, uint numSpaces, const CFormatInfo &wordFormat, uint fontWidth);
void addWord(const CWord &word, uint fontWidth);
uint getNumWords() const { return (uint)_Words.size(); }
CWord &getWord(uint index) { return _Words[index]; }
float getSpaceWidth() const { return _SpaceWidth; }
void setSpaceWidth(float width) { _SpaceWidth = width; }
// Get the number of chars in the line, not counting the end spaces, but couting the spaces in words
uint getNumChars() const { return _NumChars; }
// Get the total number of spaces between words (not including those in words, but there should not be if text is justified)
uint getNumSpaces() const { return _NumSpaces; }
float getStringLine() const { return _StringLine; }
float getWidthWithoutSpaces() const { return _WidthWithoutSpaces; }
// get total width including spaces, but not including end spaces
float getWidth() const { return _WidthWithoutSpaces + _SpaceWidth * _NumSpaces; }
// Get the number of spaces at the end of the line
void setEndSpaces(uint numSpaces) { _EndSpaces = numSpaces; }
// Set the number of spaces at the end of the line
uint getEndSpaces() const { return _EndSpaces; }
// Test if there's a line feed at the end of the line
bool getLF() const { return _HasLF; }
void setLF(bool lf) { _HasLF = lf; }
void resetTextIndex();
private:
TWordVect _Words;
uint _NumChars;
uint _NumSpaces;
float _SpaceWidth; // width of a space, in pixels (used with multispace alignment)
float _StringLine;
float _WidthWithoutSpaces; // width without space (see the Field NumSpaces in the CWord class).
// NB : space inserted inside a word are counted, however!
uint _EndSpaces; // spaces at the end of the line
bool _HasLF; // a linefeed is at end of line (no breaking due to line full)
};
/// NB : we keep pointers on lines (each line contains a vector, that we don't want to be copied, and this occurs as the vector of lines grows..)
typedef NLMISC::CSmartPtr<CLine> TLineSPtr;
typedef std::vector<TLineSPtr> TLinePtVect;
private:
/** Data of the updated text for multiline. It is built from the _Text field in the updateTextContext member function,
* and is used to perform the draw
*/
TLinePtVect _Lines;
/// if true, and if the view text is isSingleLineTextClamped(), then an over will be drawn, with the text
bool _OverExtendViewText : 1;
/// if true and _OverExtendViewText true too, use the parent rectangle to know if must display the over or not
bool _OverExtendViewTextUseParentRect : 1;
/// Letter selection handling
bool _AutoClamp : 1;
bool _ClampRight : 1;
bool _TextSelection : 1;
bool _InvalidTextContext : 1;
bool _Underlined : 1;
bool _ContinuousUpdate : 1;
bool _Setuped : 1;
uint _TextSelectionStart;
uint _TextSelectionEnd;
// First line X coordinate
uint _FirstLineX;
/// Dynamic tooltips
std::vector<CCtrlToolTip*> _Tooltips;
private:
void setup ();
void setupDefault ();
void setStringSelectionSkipingSpace(uint stringId, const ucstring &text, sint charStart, sint charEnd);
// void pushString(const ucstring &str, bool deleteSpaceAtStart = false);
/// \from CInterfaceElement
void onInvalidateContent();
// may append a new line, and append a word to the last line (no spaces)
void flushWordInLine(ucstring &ucCurrentWord, bool &linePushed, const CFormatInfo &wordFormat);
// Clear all the lines and free their datas
void clearLines();
// Update in the case of a multiline text
void updateTextContextMultiLine(uint nMaxWidth);
// Update in the case of a multiline text with justification
void updateTextContextMultiLineJustified(uint nMaxWidth, bool expandSpaces);
// Recompute font size info
void computeFontSize ();
// used for "donctClipWord" case in updateTextContextMultiLineJustified(). currLine is reseted
void addDontClipWordLine(std::vector<CWord> &currLine);
// FormatTag build.
static void buildFormatTagText(const ucstring &text, ucstring &textBuild, std::vector<CFormatTag> &formatTags, std::vector<ucstring> &tooltips);
// FormatTag parsing.
bool isFormatTagChange(uint textIndex, uint ctIndex) const;
void getFormatTagChange(uint textIndex, uint &ctIndex, CFormatInfo &wordFormat) const;
};
}
#endif // NL_VIEW_TEXT_H
/* End of view_text.h */

@ -1,71 +1,71 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_TEXT_FORMATED_H
#define VIEW_TEXT_FORMATED_H
#include "nel/gui/view_text.h"
namespace NLGUI
{
/** The same as a view text id, but with some display option
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
* $p -> expand the player name
* $P -> expand the player name in uppercase
* $b -> expand the current bot name ( bot with which the player is talking)
* $s -> expand the current short bot name (with no specification/title in it)
* if "ui..." replace the format with CI18N
*/
class CViewTextFormated : public CViewText
{
public:
/// Interface for classes which can format the text for this view.
class IViewTextFormatter
{
public:
virtual ~IViewTextFormatter(){}
virtual ucstring formatString( const ucstring &inputString, const ucstring &paramString ) = 0;
};
CViewTextFormated (const TCtorParam &param) : CViewText(param)
{}
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();
const ucstring &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format);
static ucstring formatString(const ucstring &inputString, const ucstring &paramString);
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
private:
ucstring _FormatString;
static IViewTextFormatter *textFormatter;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_TEXT_FORMATED_H
#define VIEW_TEXT_FORMATED_H
#include "nel/gui/view_text.h"
namespace NLGUI
{
/** The same as a view text id, but with some display option
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
* $p -> expand the player name
* $P -> expand the player name in uppercase
* $b -> expand the current bot name ( bot with which the player is talking)
* $s -> expand the current short bot name (with no specification/title in it)
* if "ui..." replace the format with CI18N
*/
class CViewTextFormated : public CViewText
{
public:
/// Interface for classes which can format the text for this view.
class IViewTextFormatter
{
public:
virtual ~IViewTextFormatter(){}
virtual ucstring formatString( const ucstring &inputString, const ucstring &paramString ) = 0;
};
CViewTextFormated (const TCtorParam &param) : CViewText(param)
{}
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();
const ucstring &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format);
static ucstring formatString(const ucstring &inputString, const ucstring &paramString);
static void setFormatter( IViewTextFormatter *formatter ){ textFormatter = formatter; }
private:
ucstring _FormatString;
static IViewTextFormatter *textFormatter;
};
}
#endif

@ -1,157 +1,157 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_TEXT_ID_H
#define NL_VIEW_TEXT_ID_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLMISC{
class CCDBNodeLeaf;
}
namespace NLGUI
{
// ***************************************************************************
class IOnReceiveTextId
{
public:
virtual ~IOnReceiveTextId() {}
// the deriver may change the input text
virtual void onReceiveTextId(ucstring &str) =0;
};
// ***************************************************************************
/**
* class implementing a text view that take the text from an id
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewTextID : public CViewText
{
public:
/// Interface for classes which can provide text to CViewTextId
class IViewTextProvider
{
public:
virtual ~IViewTextProvider(){}
virtual bool getString( uint32 stringId, ucstring &result ) = 0;
virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0;
};
CViewTextID(const TCtorParam &param) : CViewText(param)
{
_StringModifier= NULL;
_IsDBLink = false;
_TextId = 0xFFFFFFFF;
_Initialized = false;
_DynamicString = false;
_IsTextFormatTaged= false;
}
// ctor with a text id
CViewTextID (const std::string& id, uint32 nID, sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) :
CViewText (id, std::string(""), FontSize, Color, Shadow)
{
_StringModifier= NULL;
_IsDBLink = false;
_TextId = nID;
_Initialized = false;
_DynamicString = false;
_IsTextFormatTaged= false;
}
// ctor with a db path entry
CViewTextID (const std::string& id,
const std::string &idDBPath,
sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255),
bool Shadow=false);
~CViewTextID();
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();
bool parseTextIdOptions(xmlNodePtr cur);
uint32 getTextId () const;
void setTextId (uint32 id);
/** set a text id from a db path
* \return true if the link could be done
*/
bool setDBTextID(const std::string &dbPath);
// set a text from a db leaf
void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf);
std::string getTextIdDbLink() const;
void setTextIdDbLink(const std::string &link);
void setDynamicString(bool state) {_DynamicString= state;}
bool getDynamicString() const {return _DynamicString;}
// modify name when received
void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;}
IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;}
REFLECT_EXPORT_START(CViewTextID, CViewText)
REFLECT_UINT32("textid", getTextId, setTextId);
REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink);
REFLECT_EXPORT_END
static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; }
protected:
bool _IsDBLink;
CInterfaceProperty _DBTextId;
uint32 _TextId;
bool _Initialized;
// If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString)
bool _DynamicString;
// If true, setTextFormatted() is used instead of setText()
bool _IsTextFormatTaged;
// Optional ucstring modifier
IOnReceiveTextId *_StringModifier;
std::string _DBPath;
static IViewTextProvider* getTextProvider(){ return textProvider; }
private:
static IViewTextProvider *textProvider;
};
}
#endif // NL_VIEW_TEXT_ID_H
/* End of view_text_id.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_VIEW_TEXT_ID_H
#define NL_VIEW_TEXT_ID_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLMISC{
class CCDBNodeLeaf;
}
namespace NLGUI
{
// ***************************************************************************
class IOnReceiveTextId
{
public:
virtual ~IOnReceiveTextId() {}
// the deriver may change the input text
virtual void onReceiveTextId(ucstring &str) =0;
};
// ***************************************************************************
/**
* class implementing a text view that take the text from an id
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewTextID : public CViewText
{
public:
/// Interface for classes which can provide text to CViewTextId
class IViewTextProvider
{
public:
virtual ~IViewTextProvider(){}
virtual bool getString( uint32 stringId, ucstring &result ) = 0;
virtual bool getDynString( uint32 dynStringId, ucstring &result ) = 0;
};
CViewTextID(const TCtorParam &param) : CViewText(param)
{
_StringModifier= NULL;
_IsDBLink = false;
_TextId = 0xFFFFFFFF;
_Initialized = false;
_DynamicString = false;
_IsTextFormatTaged= false;
}
// ctor with a text id
CViewTextID (const std::string& id, uint32 nID, sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255), bool Shadow=false) :
CViewText (id, std::string(""), FontSize, Color, Shadow)
{
_StringModifier= NULL;
_IsDBLink = false;
_TextId = nID;
_Initialized = false;
_DynamicString = false;
_IsTextFormatTaged= false;
}
// ctor with a db path entry
CViewTextID (const std::string& id,
const std::string &idDBPath,
sint FontSize=12,
NLMISC::CRGBA Color=NLMISC::CRGBA(255,255,255),
bool Shadow=false);
~CViewTextID();
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();
bool parseTextIdOptions(xmlNodePtr cur);
uint32 getTextId () const;
void setTextId (uint32 id);
/** set a text id from a db path
* \return true if the link could be done
*/
bool setDBTextID(const std::string &dbPath);
// set a text from a db leaf
void setDBLeaf(NLMISC::CCDBNodeLeaf *leaf);
std::string getTextIdDbLink() const;
void setTextIdDbLink(const std::string &link);
void setDynamicString(bool state) {_DynamicString= state;}
bool getDynamicString() const {return _DynamicString;}
// modify name when received
void setOnReceiveTextId(IOnReceiveTextId *callBack) {_StringModifier= callBack;}
IOnReceiveTextId *getOnReceiveTextId() const {return _StringModifier;}
REFLECT_EXPORT_START(CViewTextID, CViewText)
REFLECT_UINT32("textid", getTextId, setTextId);
REFLECT_STRING("textid_dblink", getTextIdDbLink, setTextIdDbLink);
REFLECT_EXPORT_END
static void setTextProvider( IViewTextProvider *provider ){ textProvider = provider; }
protected:
bool _IsDBLink;
CInterfaceProperty _DBTextId;
uint32 _TextId;
bool _Initialized;
// If true, use a dynamic string (CStringManagerClient::getDynString), else use a server string id (CStringManagerClient::getString)
bool _DynamicString;
// If true, setTextFormatted() is used instead of setText()
bool _IsTextFormatTaged;
// Optional ucstring modifier
IOnReceiveTextId *_StringModifier;
std::string _DBPath;
static IViewTextProvider* getTextProvider(){ return textProvider; }
private:
static IViewTextProvider *textProvider;
};
}
#endif // NL_VIEW_TEXT_ID_H
/* End of view_text_id.h */

@ -1,55 +1,55 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_TEXT_ID_FORMATED_H
#define VIEW_TEXT_ID_FORMATED_H
#include "nel/gui/view_text_id.h"
/** The same as a view text id, but with some display option
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
* $t -> expand the value of the text id
* $p -> expand the player name
* $P -> expand the player name in uppercase
* $b -> expand the current bot name ( bot with which the player is talking)
* $s -> expand the current short bot name (with no specification/title in it)
*/
namespace NLGUI
{
class CViewTextIDFormated : public CViewTextID
{
public:
CViewTextIDFormated(const TCtorParam &param) : CViewTextID(param)
{}
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();
const ucstring &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format);
private:
ucstring _FormatString;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef VIEW_TEXT_ID_FORMATED_H
#define VIEW_TEXT_ID_FORMATED_H
#include "nel/gui/view_text_id.h"
/** The same as a view text id, but with some display option
* The input is a formated string, every character is copied, but subsitution is done for each character preceded by $
* $t -> expand the value of the text id
* $p -> expand the player name
* $P -> expand the player name in uppercase
* $b -> expand the current bot name ( bot with which the player is talking)
* $s -> expand the current short bot name (with no specification/title in it)
*/
namespace NLGUI
{
class CViewTextIDFormated : public CViewTextID
{
public:
CViewTextIDFormated(const TCtorParam &param) : CViewTextID(param)
{}
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();
const ucstring &getFormatString() const { return _FormatString; }
void setFormatString(const ucstring &format);
private:
ucstring _FormatString;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,367 +1,367 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_H
#define CDB_H
// misc
#include "types_nl.h"
#include "smart_ptr.h"
#include "string_mapper.h"
#include "sstring.h"
#include <libxml/parser.h>
namespace NLMISC
{
class IProgressCallback;
class CBitMemStream;
class CCDBNodeLeaf;
class CCDBNodeBranch;
class CCDBBankHandler;
/**
* Interface to manage a database node, can contain a unique property or a set of property
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class ICDBNode : public CRefCount
{
//-----------------------------------------------------------------------
// end of IDBNode interface
// start of CDB sub-class definitions
public:
enum EPropType
{
UNKNOWN = 0,
// Unsigned
I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16,
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
// Signed
S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16,
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
TEXT, Nb_Prop_Type
};
/**
* observer interface to a database property
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class IPropertyObserver : public CRefCount
{
public :
virtual ~IPropertyObserver() {}
virtual void update(ICDBNode* node ) = 0;
};
/**
* Text id
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CTextId
{
public:
/**
* Default constructor
*/
CTextId(): _Idx(0) {}
/**
* Init this text id from a string
*/
explicit CTextId( const std::string& str ): _Idx(0)
{
const std::string &s = str;
uint32 i, j;
for (i=0,j=0; i+j<s.size(); j++)
if (s[i+j]==':')
{
_Ids.push_back(s.substr(i,j));
i+=j+1; // +1 to skip the ':'
j=0;
}
// deal with the last id in the string (terminated by a '\x0' and not a ':')
_Ids.push_back(s.substr(i,j));
}
/**
* Build a string from this text id
*/
std::string toString() const
{
if (_Ids.size()==0) return std::string("");
std::string str=_Ids[0];
for (unsigned i=1; i<_Ids.size(); i++)
str +=std::string(":")+ _Ids[i];
return str;
}
/**
* Push back a sub name id to this id
*/
void push( const std::string &str ) { _Ids.push_back( str ); }
/**
* Remove the last sub name id to this id
*/
void pop() { _Ids.pop_back(); }
/**
* Return the next sub id
*/
const std::string &readNext() const
{
nlassert( _Idx < _Ids.size() );
return _Ids[_Idx++];
}
/** return true if a call to readNext can be performed
*/
bool hasElements() const { return _Idx < _Ids.size(); }
/**
* Get the current index in Id
*/
uint getCurrentIndex() const { return _Idx; }
/**
* Return the count of strings composing this id
*/
uint size() const { return (uint)_Ids.size(); }
/** Return an element. empty if bad index
*/
const std::string &getElement(uint idx)
{
static std::string empty;
if(idx>=size())
return empty;
else
return _Ids[idx];
}
private:
std::vector<std::string> _Ids;
mutable uint _Idx;
};
//-----------------------------------------------------------------------
// end of CDB sub-class definitions
//-----------------------------------------------------------------------
// IDBNode interface definition
public :
/**
* destructor
*/
virtual ~ICDBNode() {}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ) = 0;
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
virtual void write( CTextId& id, FILE * f) = 0;
/**
* Update the database from a stream coming from the FE
* \param gc the server gameCycle of this update. Any outdated update are aborted
* \param f : the stream.
*/
virtual void readDelta( TGameCycle gc, CBitMemStream & f ) = 0;
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
virtual ICDBNode * getNode( const CTextId& id, bool bCreate = true )=0 ;
/**
* Get a node
* \param idx is the node index
*/
virtual ICDBNode * getNode( uint16 idx ) = 0;
/**
* Get a node index
* \param node is a pointer to the node
* \param index is a reference that receive the result
* \return true if the node was found
*/
virtual bool getNodeIndex( ICDBNode* node , uint & index) = 0;
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the value of the property
*/
virtual sint64 getProp( CTextId& id ) = 0;
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'true' if property found.
*/
virtual bool setProp( CTextId& id, sint64 value ) = 0;
/// Reset all leaf data from this point
virtual void resetData(TGameCycle gc, bool forceReset=false) = 0;
/**
* Clear the node and his children
*/
virtual void clear() = 0;
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doesn't exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id) = 0;
/** remove an obsever
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id) = 0;
/**
* Inform a node of its parenthood
*/
virtual void setParent(CCDBNodeBranch * /* parent */) { nlassertex(0,("setParent() not overloaded for given node type!")); }
/**
* get the parent of a node
*/
virtual CCDBNodeBranch* getParent() { nlassertex(0,("getParent() not overloaded for given node type!")); return NULL; }
/**
* get the name of this node
*/
const std::string * getName() const { return &_DBSM->localUnmap(_Name); }
/**
* get the full name of this node separator is ':' (ie UI:INTERFACE:REDSTUFF)
* This will not return the fullname with the ROOT !
*/
std::string getFullName();
/// Count the leaves
virtual uint countLeaves() const = 0;
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0;
/// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time)
void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; }
/// Return true if the branch has the atomic flag
bool isAtomic() const { return _AtomicFlag; }
// test if the node is a leaf
virtual bool isLeaf() const = 0;
/// Debug purpose
virtual void display (const std::string &/* prefix */){}
/// Return the string id corresponding to the argument
static TStringId getStringId(const std::string& nodeName)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return _DBSM->localMap(nodeName);
}
/// Return a pointer to the string corresponding to the argument
static const std::string *getStringFromId(TStringId nodeStringId)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return &_DBSM->localUnmap(nodeStringId);
}
/// release string mapper
static void releaseStringMapper();
static bool isDatabaseVerbose(){ return verboseDatabase; }
static void setVerboseDatabase( bool b ){ verboseDatabase = b; }
protected:
/// Constructor
ICDBNode() : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = CStringMapper::emptyId();
}
/// Constructor
ICDBNode (const std::string &name) : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = _DBSM->localMap(name);
//_NameDbg = name;
}
// utility to build full name efficiently (without reallocating the string at each parent level)
void _buildFullName(CSString &fullName);
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
bool _AtomicFlag : 1;
/// Name of the node
TStringId _Name;
//std::string _NameDbg;
static CStringMapper *_DBSM;
static bool verboseDatabase;
};
}
#endif // CDB_H
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_H
#define CDB_H
// misc
#include "types_nl.h"
#include "smart_ptr.h"
#include "string_mapper.h"
#include "sstring.h"
#include <libxml/parser.h>
namespace NLMISC
{
class IProgressCallback;
class CBitMemStream;
class CCDBNodeLeaf;
class CCDBNodeBranch;
class CCDBBankHandler;
/**
* Interface to manage a database node, can contain a unique property or a set of property
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class ICDBNode : public CRefCount
{
//-----------------------------------------------------------------------
// end of IDBNode interface
// start of CDB sub-class definitions
public:
enum EPropType
{
UNKNOWN = 0,
// Unsigned
I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16,
I17, I18, I19, I20, I21, I22, I23, I24, I25, I26, I27, I28, I29, I30, I31, I32,
I33, I34, I35, I36, I37, I38, I39, I40, I41, I42, I43, I44, I45, I46, I47, I48,
I49, I50, I51, I52, I53, I54, I55, I56, I57, I58, I59, I60, I61, I62, I63, I64,
// Signed
S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16,
S17, S18, S19, S20, S21, S22, S23, S24, S25, S26, S27, S28, S29, S30, S31, S32,
S33, S34, S35, S36, S37, S38, S39, S40, S41, S42, S43, S44, S45, S46, S47, S48,
S49, S50, S51, S52, S53, S54, S55, S56, S57, S58, S59, S60, S61, S62, S63, S64,
TEXT, Nb_Prop_Type
};
/**
* observer interface to a database property
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class IPropertyObserver : public CRefCount
{
public :
virtual ~IPropertyObserver() {}
virtual void update(ICDBNode* node ) = 0;
};
/**
* Text id
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CTextId
{
public:
/**
* Default constructor
*/
CTextId(): _Idx(0) {}
/**
* Init this text id from a string
*/
explicit CTextId( const std::string& str ): _Idx(0)
{
const std::string &s = str;
uint32 i, j;
for (i=0,j=0; i+j<s.size(); j++)
if (s[i+j]==':')
{
_Ids.push_back(s.substr(i,j));
i+=j+1; // +1 to skip the ':'
j=0;
}
// deal with the last id in the string (terminated by a '\x0' and not a ':')
_Ids.push_back(s.substr(i,j));
}
/**
* Build a string from this text id
*/
std::string toString() const
{
if (_Ids.size()==0) return std::string("");
std::string str=_Ids[0];
for (unsigned i=1; i<_Ids.size(); i++)
str +=std::string(":")+ _Ids[i];
return str;
}
/**
* Push back a sub name id to this id
*/
void push( const std::string &str ) { _Ids.push_back( str ); }
/**
* Remove the last sub name id to this id
*/
void pop() { _Ids.pop_back(); }
/**
* Return the next sub id
*/
const std::string &readNext() const
{
nlassert( _Idx < _Ids.size() );
return _Ids[_Idx++];
}
/** return true if a call to readNext can be performed
*/
bool hasElements() const { return _Idx < _Ids.size(); }
/**
* Get the current index in Id
*/
uint getCurrentIndex() const { return _Idx; }
/**
* Return the count of strings composing this id
*/
uint size() const { return (uint)_Ids.size(); }
/** Return an element. empty if bad index
*/
const std::string &getElement(uint idx)
{
static std::string empty;
if(idx>=size())
return empty;
else
return _Ids[idx];
}
private:
std::vector<std::string> _Ids;
mutable uint _Idx;
};
//-----------------------------------------------------------------------
// end of CDB sub-class definitions
//-----------------------------------------------------------------------
// IDBNode interface definition
public :
/**
* destructor
*/
virtual ~ICDBNode() {}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
virtual void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL ) = 0;
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
virtual void write( CTextId& id, FILE * f) = 0;
/**
* Update the database from a stream coming from the FE
* \param gc the server gameCycle of this update. Any outdated update are aborted
* \param f : the stream.
*/
virtual void readDelta( TGameCycle gc, CBitMemStream & f ) = 0;
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
virtual ICDBNode * getNode( const CTextId& id, bool bCreate = true )=0 ;
/**
* Get a node
* \param idx is the node index
*/
virtual ICDBNode * getNode( uint16 idx ) = 0;
/**
* Get a node index
* \param node is a pointer to the node
* \param index is a reference that receive the result
* \return true if the node was found
*/
virtual bool getNodeIndex( ICDBNode* node , uint & index) = 0;
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the value of the property
*/
virtual sint64 getProp( CTextId& id ) = 0;
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'true' if property found.
*/
virtual bool setProp( CTextId& id, sint64 value ) = 0;
/// Reset all leaf data from this point
virtual void resetData(TGameCycle gc, bool forceReset=false) = 0;
/**
* Clear the node and his children
*/
virtual void clear() = 0;
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doesn't exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id) = 0;
/** remove an obsever
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id) = 0;
/**
* Inform a node of its parenthood
*/
virtual void setParent(CCDBNodeBranch * /* parent */) { nlassertex(0,("setParent() not overloaded for given node type!")); }
/**
* get the parent of a node
*/
virtual CCDBNodeBranch* getParent() { nlassertex(0,("getParent() not overloaded for given node type!")); return NULL; }
/**
* get the name of this node
*/
const std::string * getName() const { return &_DBSM->localUnmap(_Name); }
/**
* get the full name of this node separator is ':' (ie UI:INTERFACE:REDSTUFF)
* This will not return the fullname with the ROOT !
*/
std::string getFullName();
/// Count the leaves
virtual uint countLeaves() const = 0;
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count ) = 0;
/// Set the atomic branch flag (when all the modified nodes of a branch should be tranmitted at the same time)
void setAtomic( bool atomicBranch ) { _AtomicFlag = atomicBranch; }
/// Return true if the branch has the atomic flag
bool isAtomic() const { return _AtomicFlag; }
// test if the node is a leaf
virtual bool isLeaf() const = 0;
/// Debug purpose
virtual void display (const std::string &/* prefix */){}
/// Return the string id corresponding to the argument
static TStringId getStringId(const std::string& nodeName)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return _DBSM->localMap(nodeName);
}
/// Return a pointer to the string corresponding to the argument
static const std::string *getStringFromId(TStringId nodeStringId)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
return &_DBSM->localUnmap(nodeStringId);
}
/// release string mapper
static void releaseStringMapper();
static bool isDatabaseVerbose(){ return verboseDatabase; }
static void setVerboseDatabase( bool b ){ verboseDatabase = b; }
protected:
/// Constructor
ICDBNode() : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = CStringMapper::emptyId();
}
/// Constructor
ICDBNode (const std::string &name) : _AtomicFlag(false)
{
if (_DBSM == NULL) _DBSM = CStringMapper::createLocalMapper();
_Name = _DBSM->localMap(name);
//_NameDbg = name;
}
// utility to build full name efficiently (without reallocating the string at each parent level)
void _buildFullName(CSString &fullName);
/// Atomic flag: is the branch an atomic group, or is the leaf a member of an atomic group
bool _AtomicFlag : 1;
/// Name of the node
TStringId _Name;
//std::string _NameDbg;
static CStringMapper *_DBSM;
static bool verboseDatabase;
};
}
#endif // CDB_H

@ -1,145 +1,145 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BANK_HANDLER
#define CDB_BANK_HANDLER
#include <vector>
#include "nel/misc/types_nl.h"
namespace NLMISC{
/**
@brief Manages the bank names and mappings of the CDB it's associated with
Banks are numeric identifiers for the top-level branches of the CDB.
They are used for saving bandwidth, because the local CDBs are updated with deltas,
that identify the updatable top-level branch with this id.
The CCDBBankHandler manages the mapping of banks to their names, unified (node) index,
and the other way around.
*/
class CCDBBankHandler{
public:
/**
@brief The class' constructor
@param maxbanks the maximum number of banks we need to handle
*/
CCDBBankHandler( uint maxbanks );
/// Very surprisingly this is the destructor
~CCDBBankHandler(){}
/**
@brief Returns the unified (node) index for the specified bank Id.
@param bank The bank whose uid we need.
@return Returns an uid or static_cast< uint >( -1 ) on failure.
*/
uint getUIDForBank( uint bank ) const;
/**
@brief Returns the bank Id for the specified unified (node) index.
@param uid The unified (node) index we need to translate to bank Id.
@return Returns a bank Id.
*/
uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; }
/// Returns the last unified (node) index we mapped.
uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; }
/**
@brief Returns the number of bits used to store the number of nodes that belong to this bank.
@param bank The banks whose id bits we need.
@return Returns the number of bits used to store the number of nodes that belong to this bank.
*/
uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; }
/**
@brief Returns the name of the specified bank.
@param bank The id of the bank we need the name of.
@return Returns the name of the specified bank.
*/
std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; }
/**
@brief Looks up the bank Id of the bank name specified.
@param name The name of the bank whose Id we need.
@return Returns the id of the bank, or static_cast< uint >( -1 ) on fail.
*/
uint getBankByName( const std::string &name ) const;
/**
@brief Maps the specified bank name to a unified (node) index and vica versa.
@param bankName Name of the bank to map.
*/
void mapNodeByBank( const std::string &bankName );
/**
@brief Loads the known bank names from an array ( the order decides the bank Id ).
@param strings The array of the banks names.
@param size The size of the array.
*/
void fillBankNames( const char **strings, uint size );
/// Resets the node to bank mapping vector
void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); }
/// Resets all maps, and sets _CDBLastUnifiedIndex to 0.
void reset();
uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); }
/// Calculates the number of bits used to store the number of nodes that belong to the banks.
void calcIdBitsByBank();
/**
@brief Looks up the unified (node) index of a bank node.
@param bank The bank id of the node we are looking up.
@param index The index of the node within the bank.
@return Returns the unified (node) index of the specified bank node.
*/
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
/**
@brief Resizes the bank holders. WARNING: Resets data contained.
@param newSize - The new maximum number of banks.
*/
void resize( uint newSize );
private:
/// Mapping from server database index to client database index (first-level nodes)
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
/// Mapping from client database index to bank IDs (first-level nodes)
std::vector< uint > _UnifiedIndexToBank;
/// Last index mapped
uint _CDBLastUnifiedIndex;
/// Number of bits for first-level branches, by bank
std::vector< uint > _FirstLevelIdBitsByBank;
/// Names of the CDB banks
std::vector< std::string > _CDBBankNames;
/// The number of banks used
uint maxBanks;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BANK_HANDLER
#define CDB_BANK_HANDLER
#include <vector>
#include "nel/misc/types_nl.h"
namespace NLMISC{
/**
@brief Manages the bank names and mappings of the CDB it's associated with
Banks are numeric identifiers for the top-level branches of the CDB.
They are used for saving bandwidth, because the local CDBs are updated with deltas,
that identify the updatable top-level branch with this id.
The CCDBBankHandler manages the mapping of banks to their names, unified (node) index,
and the other way around.
*/
class CCDBBankHandler{
public:
/**
@brief The class' constructor
@param maxbanks the maximum number of banks we need to handle
*/
CCDBBankHandler( uint maxbanks );
/// Very surprisingly this is the destructor
~CCDBBankHandler(){}
/**
@brief Returns the unified (node) index for the specified bank Id.
@param bank The bank whose uid we need.
@return Returns an uid or static_cast< uint >( -1 ) on failure.
*/
uint getUIDForBank( uint bank ) const;
/**
@brief Returns the bank Id for the specified unified (node) index.
@param uid The unified (node) index we need to translate to bank Id.
@return Returns a bank Id.
*/
uint getBankForUID( uint uid ) const{ return _UnifiedIndexToBank[ uid ]; }
/// Returns the last unified (node) index we mapped.
uint getLastUnifiedIndex() const{ return _CDBLastUnifiedIndex; }
/**
@brief Returns the number of bits used to store the number of nodes that belong to this bank.
@param bank The banks whose id bits we need.
@return Returns the number of bits used to store the number of nodes that belong to this bank.
*/
uint getFirstLevelIdBits( uint bank ) const{ return _FirstLevelIdBitsByBank[ bank ]; }
/**
@brief Returns the name of the specified bank.
@param bank The id of the bank we need the name of.
@return Returns the name of the specified bank.
*/
std::string getBankName( uint bank ) const{ return _CDBBankNames[ bank ]; }
/**
@brief Looks up the bank Id of the bank name specified.
@param name The name of the bank whose Id we need.
@return Returns the id of the bank, or static_cast< uint >( -1 ) on fail.
*/
uint getBankByName( const std::string &name ) const;
/**
@brief Maps the specified bank name to a unified (node) index and vica versa.
@param bankName Name of the bank to map.
*/
void mapNodeByBank( const std::string &bankName );
/**
@brief Loads the known bank names from an array ( the order decides the bank Id ).
@param strings The array of the banks names.
@param size The size of the array.
*/
void fillBankNames( const char **strings, uint size );
/// Resets the node to bank mapping vector
void resetNodeBankMapping(){ _UnifiedIndexToBank.clear(); }
/// Resets all maps, and sets _CDBLastUnifiedIndex to 0.
void reset();
uint getUnifiedIndexToBankSize() const{ return _UnifiedIndexToBank.size(); }
/// Calculates the number of bits used to store the number of nodes that belong to the banks.
void calcIdBitsByBank();
/**
@brief Looks up the unified (node) index of a bank node.
@param bank The bank id of the node we are looking up.
@param index The index of the node within the bank.
@return Returns the unified (node) index of the specified bank node.
*/
uint getServerToClientUIDMapping( uint bank, uint index ) const{ return _CDBBankToUnifiedIndexMapping[ bank ][ index ]; }
/**
@brief Resizes the bank holders. WARNING: Resets data contained.
@param newSize - The new maximum number of banks.
*/
void resize( uint newSize );
private:
/// Mapping from server database index to client database index (first-level nodes)
std::vector< std::vector< uint > > _CDBBankToUnifiedIndexMapping;
/// Mapping from client database index to bank IDs (first-level nodes)
std::vector< uint > _UnifiedIndexToBank;
/// Last index mapped
uint _CDBLastUnifiedIndex;
/// Number of bits for first-level branches, by bank
std::vector< uint > _FirstLevelIdBitsByBank;
/// Names of the CDB banks
std::vector< std::string > _CDBBankNames;
/// The number of banks used
uint maxBanks;
};
}
#endif

@ -1,260 +1,260 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BRANCH_H
#define CDB_BRANCH_H
#include "cdb.h"
namespace NLMISC{
/**
* Database Node which contains a set of properties
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CCDBNodeBranch : public ICDBNode
{
public:
class ICDBDBBranchObserverHandle
{
public:
virtual ~ICDBDBBranchObserverHandle(){}
virtual ICDBNode* owner() = 0;
virtual IPropertyObserver* observer() = 0;
virtual bool observesLeaf( const std::string &leafName ) = 0;
virtual bool inList( uint list ) = 0;
virtual void addToFlushableList() = 0;
virtual void removeFromFlushableList( uint list ) = 0;
virtual void removeFromFlushableList() = 0;
};
// default constructor
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
{
_Parent = NULL;
_IdBits = 0;
_Sorted = false;
}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Add a new sub node
* \param node is the new subnode
* \param nodeName is the name of the node
*/
void attachChild( ICDBNode * node, std::string nodeName );
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
ICDBNode * getNode (const CTextId& id, bool bCreate=true);
/**
* Get a node. Return NULL if out of bounds (no warning)
* \param idx is the node index
*/
ICDBNode * getNode( uint16 idx );
/**
* Get a node index
* \param node is a pointer to the node
*/
virtual bool getNodeIndex( ICDBNode* node , uint& index)
{
index=0;
for ( std::vector<ICDBNode*>::const_iterator it = _Nodes.begin(); it != _Nodes.end(); it++)
{
if (*it == node)
return true;
index++;
}
return false;
}
// return the child with the given node id, creating it if requested
CCDBNodeLeaf *getLeaf( const char *id, bool bCreate );
CCDBNodeLeaf *getLeaf( const std::string &id, bool bCreate ) { return getLeaf(id.c_str(), bCreate); }
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
void write( CTextId& id, FILE * f);
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler );
/// Update the database from a stream coming from the FE
void readDelta( TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the value of the property
*/
sint64 getProp( CTextId& id );
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'true' if property found.
*/
bool setProp( CTextId& id, sint64 value );
/// Clear the node and his children
void clear();
void resetNode( TGameCycle gc, uint node )
{
if( node > _Nodes.size() )
return;
_Nodes[ node ]->resetData( gc );
}
/// Reset all leaf data from this point
void resetData(TGameCycle gc, bool forceReset=false)
{
for ( uint i=0; i!=_Nodes.size(); ++i )
{
_Nodes[i]->resetData(gc, forceReset);
}
}
/**
* Destructor
*/
virtual ~CCDBNodeBranch() { clear(); }
// the parent node for a branch (NULL by default)
virtual void setParent(CCDBNodeBranch *parent) { _Parent=parent; }
virtual CCDBNodeBranch* getParent()
{
return _Parent;
}
//get the number of nodes
uint16 getNbNodes()
{
return (uint16)_Nodes.size();
}
/// Count the leaves
virtual uint countLeaves() const;
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count );
virtual void display (const std::string &prefix);
void removeNode (const CTextId& id);
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doen t exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
/** remove an obsever
* \param observer : pointer to an observer
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
// Add an observer to this branch. It will be notified of any change in the sub-leaves
/**
* Add observer to all sub-leaves, except if a positive filter is set:
* If positiveLeafNameFilter is non-empty, only changes to leaves having names found in it
* will be notified (this is equivalent to creating a sub-branch containing only the specified leaves
* and setting a branch observer on it, except you don't need to change your database paths
* and update large amounts of code!).
*/
void addBranchObserver( ICDBDBBranchObserverHandle* handle, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
/**
* Easy version of addBranchObserver() (see above).
* Examples of dbPathFromThisNode:
* "" -> this node
* "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node
*/
void addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
// Remove observer from all sub-leaves
bool removeBranchObserver(IPropertyObserver* observer);
/// Easy version of removeBranchObserver() (see above and see easy version of addBranchObserver())
void removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer);
virtual bool isLeaf() const { return false; }
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
void onLeafChanged( TStringId leafName );
/// Find a subnode at this level
ICDBNode * find (const std::string &nodeName);
protected:
typedef std::list< ICDBDBBranchObserverHandle* > TObserverHandleList;
CCDBNodeBranch *_Parent;
/// database subnodes not sorted
std::vector<ICDBNode*> _Nodes;
/// subnodes sorted by name
std::vector<ICDBNode*> _NodesByName;
// number of bits required to stock my children's ids
uint8 _IdBits : 7;
bool _Sorted : 1;
// observers for this node or branch
TObserverHandleList observerHandles;
/// called by clear
void removeAllBranchObserver();
};
}
#endif // CDB_BRANCH_H
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BRANCH_H
#define CDB_BRANCH_H
#include "cdb.h"
namespace NLMISC{
/**
* Database Node which contains a set of properties
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CCDBNodeBranch : public ICDBNode
{
public:
class ICDBDBBranchObserverHandle
{
public:
virtual ~ICDBDBBranchObserverHandle(){}
virtual ICDBNode* owner() = 0;
virtual IPropertyObserver* observer() = 0;
virtual bool observesLeaf( const std::string &leafName ) = 0;
virtual bool inList( uint list ) = 0;
virtual void addToFlushableList() = 0;
virtual void removeFromFlushableList( uint list ) = 0;
virtual void removeFromFlushableList() = 0;
};
// default constructor
CCDBNodeBranch(const std::string &name) : ICDBNode(name)
{
_Parent = NULL;
_IdBits = 0;
_Sorted = false;
}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, class IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Add a new sub node
* \param node is the new subnode
* \param nodeName is the name of the node
*/
void attachChild( ICDBNode * node, std::string nodeName );
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
ICDBNode * getNode (const CTextId& id, bool bCreate=true);
/**
* Get a node. Return NULL if out of bounds (no warning)
* \param idx is the node index
*/
ICDBNode * getNode( uint16 idx );
/**
* Get a node index
* \param node is a pointer to the node
*/
virtual bool getNodeIndex( ICDBNode* node , uint& index)
{
index=0;
for ( std::vector<ICDBNode*>::const_iterator it = _Nodes.begin(); it != _Nodes.end(); it++)
{
if (*it == node)
return true;
index++;
}
return false;
}
// return the child with the given node id, creating it if requested
CCDBNodeLeaf *getLeaf( const char *id, bool bCreate );
CCDBNodeLeaf *getLeaf( const std::string &id, bool bCreate ) { return getLeaf(id.c_str(), bCreate); }
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
void write( CTextId& id, FILE * f);
/// Update the database from the delta, but map the first level with the bank mapping (see _CDBBankToUnifiedIndexMapping)
void readAndMapDelta( TGameCycle gc, CBitMemStream& s, uint bank, CCDBBankHandler *bankHandler );
/// Update the database from a stream coming from the FE
void readDelta( TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the value of the property
*/
sint64 getProp( CTextId& id );
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'true' if property found.
*/
bool setProp( CTextId& id, sint64 value );
/// Clear the node and his children
void clear();
void resetNode( TGameCycle gc, uint node )
{
if( node > _Nodes.size() )
return;
_Nodes[ node ]->resetData( gc );
}
/// Reset all leaf data from this point
void resetData(TGameCycle gc, bool forceReset=false)
{
for ( uint i=0; i!=_Nodes.size(); ++i )
{
_Nodes[i]->resetData(gc, forceReset);
}
}
/**
* Destructor
*/
virtual ~CCDBNodeBranch() { clear(); }
// the parent node for a branch (NULL by default)
virtual void setParent(CCDBNodeBranch *parent) { _Parent=parent; }
virtual CCDBNodeBranch* getParent()
{
return _Parent;
}
//get the number of nodes
uint16 getNbNodes()
{
return (uint16)_Nodes.size();
}
/// Count the leaves
virtual uint countLeaves() const;
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count );
virtual void display (const std::string &prefix);
void removeNode (const CTextId& id);
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doen t exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
/** remove an obsever
* \param observer : pointer to an observer
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
// Add an observer to this branch. It will be notified of any change in the sub-leaves
/**
* Add observer to all sub-leaves, except if a positive filter is set:
* If positiveLeafNameFilter is non-empty, only changes to leaves having names found in it
* will be notified (this is equivalent to creating a sub-branch containing only the specified leaves
* and setting a branch observer on it, except you don't need to change your database paths
* and update large amounts of code!).
*/
void addBranchObserver( ICDBDBBranchObserverHandle* handle, const std::vector<std::string>& positiveLeafNameFilter=std::vector<std::string>());
/**
* Easy version of addBranchObserver() (see above).
* Examples of dbPathFromThisNode:
* "" -> this node
* "FOO:BAR" -> sub-branch "BAR" of "FOO" which is a sub-branch of this node
*/
void addBranchObserver( ICDBDBBranchObserverHandle *handle, const char *dbPathFromThisNode, const char **positiveLeafNameFilter=NULL, uint positiveLeafNameFilterSize=0);
// Remove observer from all sub-leaves
bool removeBranchObserver(IPropertyObserver* observer);
/// Easy version of removeBranchObserver() (see above and see easy version of addBranchObserver())
void removeBranchObserver(const char *dbPathFromThisNode, ICDBNode::IPropertyObserver& observer);
virtual bool isLeaf() const { return false; }
// mark this branch and parent branch as 'modified'. This is usually called by sub-leaves
void onLeafChanged( TStringId leafName );
/// Find a subnode at this level
ICDBNode * find (const std::string &nodeName);
protected:
typedef std::list< ICDBDBBranchObserverHandle* > TObserverHandleList;
CCDBNodeBranch *_Parent;
/// database subnodes not sorted
std::vector<ICDBNode*> _Nodes;
/// subnodes sorted by name
std::vector<ICDBNode*> _NodesByName;
// number of bits required to stock my children's ids
uint8 _IdBits : 7;
bool _Sorted : 1;
// observers for this node or branch
TObserverHandleList observerHandles;
/// called by clear
void removeAllBranchObserver();
};
}
#endif // CDB_BRANCH_H

@ -1,128 +1,128 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BRANCH_OBS_HNDLR
#define CDB_BRANCH_OBS_HNDLR
#include "nel/misc/cdb_branch.h"
namespace NLMISC{
/**
@brief Manages the CDB branch observers.
When a leaf's data changes, it notifies the branch, which then marks the observers as notifiable.
The marked observers can then be notified and flushed on request.
*/
class CCDBBranchObservingHandler{
enum{
MAX_OBS_LST = 2
};
public:
CCDBBranchObservingHandler();
~CCDBBranchObservingHandler();
/// Notifies the observers, and flushes the list
void flushObserverCalls();
void reset();
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter );
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
///Observer for branch observer flush events.
class IBranchObserverCallFlushObserver : public CRefCount{
public:
virtual ~IBranchObserverCallFlushObserver(){}
virtual void onObserverCallFlush() = 0;
};
private:
void triggerFlushObservers();
public:
void addFlushObserver( IBranchObserverCallFlushObserver *observer );
void removeFlushObserver( IBranchObserverCallFlushObserver *observer );
private:
/**
@brief Handle to a branch observer.
The handle stores the owner branch, the observer and remembers if it's marked for notifying the observer.
Also it manages adding/removing itself to/from the marked observer handles list, which is handled by CCDBBranchObservingHandler.
*/
class CCDBDBBranchObserverHandle : public CCDBNodeBranch::ICDBDBBranchObserverHandle{
public:
CCDBDBBranchObserverHandle( ICDBNode::IPropertyObserver *observer, CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler );
~CCDBDBBranchObserverHandle();
ICDBNode* owner(){ return _owner; }
ICDBNode::IPropertyObserver* observer(){ return _observer; }
bool observesLeaf( const std::string &leafName );
bool inList( uint list );
void addToFlushableList();
void removeFromFlushableList( uint list );
void removeFromFlushableList();
private:
bool _inList[ MAX_OBS_LST ];
std::vector< std::string > _observedLeaves;
CCDBNodeBranch *_owner;
NLMISC::CRefPtr< ICDBNode::IPropertyObserver > _observer;
CCDBBranchObservingHandler *_handler;
};
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* > flushableObservers[ MAX_OBS_LST ];
CCDBNodeBranch::ICDBDBBranchObserverHandle *currentHandle;
uint currentList;
std::vector< IBranchObserverCallFlushObserver* > flushObservers;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_BRANCH_OBS_HNDLR
#define CDB_BRANCH_OBS_HNDLR
#include "nel/misc/cdb_branch.h"
namespace NLMISC{
/**
@brief Manages the CDB branch observers.
When a leaf's data changes, it notifies the branch, which then marks the observers as notifiable.
The marked observers can then be notified and flushed on request.
*/
class CCDBBranchObservingHandler{
enum{
MAX_OBS_LST = 2
};
public:
CCDBBranchObservingHandler();
~CCDBBranchObservingHandler();
/// Notifies the observers, and flushes the list
void flushObserverCalls();
void reset();
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter );
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
///Observer for branch observer flush events.
class IBranchObserverCallFlushObserver : public CRefCount{
public:
virtual ~IBranchObserverCallFlushObserver(){}
virtual void onObserverCallFlush() = 0;
};
private:
void triggerFlushObservers();
public:
void addFlushObserver( IBranchObserverCallFlushObserver *observer );
void removeFlushObserver( IBranchObserverCallFlushObserver *observer );
private:
/**
@brief Handle to a branch observer.
The handle stores the owner branch, the observer and remembers if it's marked for notifying the observer.
Also it manages adding/removing itself to/from the marked observer handles list, which is handled by CCDBBranchObservingHandler.
*/
class CCDBDBBranchObserverHandle : public CCDBNodeBranch::ICDBDBBranchObserverHandle{
public:
CCDBDBBranchObserverHandle( ICDBNode::IPropertyObserver *observer, CCDBNodeBranch *owner, CCDBBranchObservingHandler *handler );
~CCDBDBBranchObserverHandle();
ICDBNode* owner(){ return _owner; }
ICDBNode::IPropertyObserver* observer(){ return _observer; }
bool observesLeaf( const std::string &leafName );
bool inList( uint list );
void addToFlushableList();
void removeFromFlushableList( uint list );
void removeFromFlushableList();
private:
bool _inList[ MAX_OBS_LST ];
std::vector< std::string > _observedLeaves;
CCDBNodeBranch *_owner;
NLMISC::CRefPtr< ICDBNode::IPropertyObserver > _observer;
CCDBBranchObservingHandler *_handler;
};
std::list< CCDBNodeBranch::ICDBDBBranchObserverHandle* > flushableObservers[ MAX_OBS_LST ];
CCDBNodeBranch::ICDBDBBranchObserverHandle *currentHandle;
uint currentList;
std::vector< IBranchObserverCallFlushObserver* > flushObservers;
};
}
#endif

@ -1,89 +1,89 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CDB_CHECK_SUM_H
#define NL_CDB_CHECK_SUM_H
#include "types_nl.h"
namespace NLMISC{
/**
* class implementing check sum for the client database
* these check sum can be used to ensure that linked properties have all been modified
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCDBCheckSum
{
public:
///constructor
CCDBCheckSum();
//clear the sum
void clear()
{
_Sum = 0;
};
///add an uint8 to the sum
void add(uint8 el);
///add a value to the check sum
template <class T>
void add(const T & el)
{
T value = el;
for (uint8 i=0; i< sizeof(T); i++)
{
uint8 tmp = (uint8)(value & 0xFF);
add(tmp);
value >>=8;
}
}
///add a vector to the sum
template <class T>
void addVector(const std::vector<T> & vect)
{
for (typename std::vector<T>::const_iterator it = vect.begin(); it != vect.end(); it++)
add(*it);
}
uint32 getSum()
{
return _Sum;
}
private:
///the checsum result
uint32 _Sum;
///the following values are used in the check algorithm
uint32 _Factor;
uint32 _Const1;
uint32 _Const2;
};
}
#endif // NL_CDB_CHECK_SUM_H
/* End of cdb_check_sum.h */
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef NL_CDB_CHECK_SUM_H
#define NL_CDB_CHECK_SUM_H
#include "types_nl.h"
namespace NLMISC{
/**
* class implementing check sum for the client database
* these check sum can be used to ensure that linked properties have all been modified
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCDBCheckSum
{
public:
///constructor
CCDBCheckSum();
//clear the sum
void clear()
{
_Sum = 0;
};
///add an uint8 to the sum
void add(uint8 el);
///add a value to the check sum
template <class T>
void add(const T & el)
{
T value = el;
for (uint8 i=0; i< sizeof(T); i++)
{
uint8 tmp = (uint8)(value & 0xFF);
add(tmp);
value >>=8;
}
}
///add a vector to the sum
template <class T>
void addVector(const std::vector<T> & vect)
{
for (typename std::vector<T>::const_iterator it = vect.begin(); it != vect.end(); it++)
add(*it);
}
uint32 getSum()
{
return _Sum;
}
private:
///the checsum result
uint32 _Sum;
///the following values are used in the check algorithm
uint32 _Factor;
uint32 _Const1;
uint32 _Const2;
};
}
#endif // NL_CDB_CHECK_SUM_H
/* End of cdb_check_sum.h */

@ -1,264 +1,264 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_LEAF_H
#define CDB_LEAF_H
#include "cdb.h"
#include "cdb_branch.h"
#include "time_nl.h"
#include "rgba.h"
namespace NLMISC{
/**
* Database node which contains a unique property
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CCDBNodeLeaf : public ICDBNode
{
public:
// flush all observers calls for modified nodes
static void flushObserversCalls();
/// Return the value of the property.
inline sint64 getValue64() { return _Property; }
/// Set the value of the property (set '_Changed' flag with 'true').
void setValue64 (sint64 prop);
inline sint32 getValue32() { return *((sint32*)&_Property); }
void setValue32 (sint32 prop);
inline sint16 getValue16() { return *((sint16*)&_Property); }
void setValue16 (sint16 prop);
inline sint8 getValue8() { return *((sint8*)&_Property); }
void setValue8 (sint8 prop);
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
void setValueBool (bool prop);
inline CRGBA getValueRGBA()
{
CRGBA col;
col.R = (uint8)(_Property&0xff);
col.G = (uint8)((_Property>>8)&0xff);
col.B = (uint8)((_Property>>16)&0xff);
col.A = (uint8)((_Property>>24)&0xff);
return col;
}
void setValueRGBA (const CRGBA &color);
/// Return the value of the property before the database change
inline sint64 getOldValue64() { return _oldProperty; }
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); }
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); }
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); }
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); }
/// Return the type of the property.
inline const EPropType &type() const {return _Type;}
/// Set the property Type.
inline void type(const EPropType &t) {_Type = t;}
/// Return 'true' if the property changed since last call.
inline const bool &changed() const {return _Changed;}
/// Set the property flag to known if the property changed since last call.
inline void changed(const bool &c) {_Changed = c;}
/**
* Default constructor
*/
CCDBNodeLeaf(const std::string &name) : ICDBNode(name)
{
_Parent=0;
_Property = 0;
_oldProperty = 0;
_Type = UNKNOWN;
_Changed = false;
_LastChangeGC = 0;
}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Get a node
* \param idx is the node index
*/
ICDBNode * getNode( uint16 idx );
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
ICDBNode * getNode (const CTextId& id, bool bCreate);
/**
* Get a node index
* \param node is a pointer to the node
*/
virtual bool getNodeIndex( ICDBNode* /* node */, uint& /* index */)
{
return false;
}
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
void write( CTextId& id, FILE * f);
/**
* Update the database from a stream coming from the FE
* \param f : the stream.
*/
void readDelta(TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the structure of the property
*/
sint64 getProp( CTextId& id );
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'false' if id is too long.
*/
bool setProp( CTextId& id, sint64 value );
/**
* Set the value of a property, only if gc>=_LastChangeGC
*/
bool setPropCheckGC(TGameCycle gc, sint64 value);
/// Reset all leaf data from this point
void resetData(TGameCycle gc, bool forceReset=false);
/**
* Clear the node and his children
*/
void clear();
// the parent node for a branch (NULL by default)
virtual void setParent(CCDBNodeBranch* parent) { _Parent=parent; }
//get the node parent
virtual CCDBNodeBranch *getParent()
{
return _Parent;
}
/// Count the leaves
virtual uint countLeaves() const
{
return 1;
}
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count )
{
if ( count == 0 )
return this;
else
{
--count;
return NULL;
}
}
/// Debug purpose
virtual void display(const std::string &prefix);
virtual bool isLeaf() const { return true; }
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doen t exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
/** remove an obsever
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
/// get the last change GameCycle (server tick) for this value
TGameCycle getLastChangeGC() const {return _LastChangeGC;}
private:
CCDBNodeBranch * _Parent;
/// property value
sint64 _Property;
sint64 _oldProperty;
/// property type
EPropType _Type;
/// true if this value has changed
bool _Changed;
/// gamecycle (servertick) of the last change for this value.
/// change are made in readDelta only for change >= _LastChangeGC
TGameCycle _LastChangeGC;
/// observers to call when the value really change
std::vector<IPropertyObserver*> _Observers;
private:
void notifyObservers();
};
////////////////////
// INLINE MEMBERS //
////////////////////
}
#endif // CDB_LEAF_H
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_LEAF_H
#define CDB_LEAF_H
#include "cdb.h"
#include "cdb_branch.h"
#include "time_nl.h"
#include "rgba.h"
namespace NLMISC{
/**
* Database node which contains a unique property
* \author Stephane Coutelas
* \author Nevrax France
* \date 2002
*/
class CCDBNodeLeaf : public ICDBNode
{
public:
// flush all observers calls for modified nodes
static void flushObserversCalls();
/// Return the value of the property.
inline sint64 getValue64() { return _Property; }
/// Set the value of the property (set '_Changed' flag with 'true').
void setValue64 (sint64 prop);
inline sint32 getValue32() { return *((sint32*)&_Property); }
void setValue32 (sint32 prop);
inline sint16 getValue16() { return *((sint16*)&_Property); }
void setValue16 (sint16 prop);
inline sint8 getValue8() { return *((sint8*)&_Property); }
void setValue8 (sint8 prop);
inline bool getValueBool() { return (_Property!=(sint64)0 ); }
void setValueBool (bool prop);
inline CRGBA getValueRGBA()
{
CRGBA col;
col.R = (uint8)(_Property&0xff);
col.G = (uint8)((_Property>>8)&0xff);
col.B = (uint8)((_Property>>16)&0xff);
col.A = (uint8)((_Property>>24)&0xff);
return col;
}
void setValueRGBA (const CRGBA &color);
/// Return the value of the property before the database change
inline sint64 getOldValue64() { return _oldProperty; }
inline sint32 getOldValue32() { return *((sint32*)&_oldProperty); }
inline sint16 getOldValue16() { return *((sint16*)&_oldProperty); }
inline sint8 getOldValue8() { return *((sint8*)&_oldProperty); }
inline bool getOldValueBool() { return (_oldProperty!=(sint64)0 ); }
/// Return the type of the property.
inline const EPropType &type() const {return _Type;}
/// Set the property Type.
inline void type(const EPropType &t) {_Type = t;}
/// Return 'true' if the property changed since last call.
inline const bool &changed() const {return _Changed;}
/// Set the property flag to known if the property changed since last call.
inline void changed(const bool &c) {_Changed = c;}
/**
* Default constructor
*/
CCDBNodeLeaf(const std::string &name) : ICDBNode(name)
{
_Parent=0;
_Property = 0;
_oldProperty = 0;
_Type = UNKNOWN;
_Changed = false;
_LastChangeGC = 0;
}
/**
* Build the structure of the database from a file
* \param f is the stream
*/
void init( xmlNodePtr node, IProgressCallback &progressCallBack, bool mapBanks=false, CCDBBankHandler *bankHandler = NULL );
/**
* Get a node
* \param idx is the node index
*/
ICDBNode * getNode( uint16 idx );
/**
* Get a node . Create it if it does not exist yet
* \param id : the CTextId identifying the node
*/
ICDBNode * getNode (const CTextId& id, bool bCreate);
/**
* Get a node index
* \param node is a pointer to the node
*/
virtual bool getNodeIndex( ICDBNode* /* node */, uint& /* index */)
{
return false;
}
/**
* Save a backup of the database
* \param id is the text id of the property/grp
* \param f is the stream
*/
void write( CTextId& id, FILE * f);
/**
* Update the database from a stream coming from the FE
* \param f : the stream.
*/
void readDelta(TGameCycle gc, CBitMemStream & f );
/**
* Return the value of a property (the update flag is set to false)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \return the structure of the property
*/
sint64 getProp( CTextId& id );
/**
* Set the value of a property (the update flag is set to true)
* \param id is the text id of the property/grp
* \param name is the name of the property
* \param value is the value of the property
* \return bool : 'false' if id is too long.
*/
bool setProp( CTextId& id, sint64 value );
/**
* Set the value of a property, only if gc>=_LastChangeGC
*/
bool setPropCheckGC(TGameCycle gc, sint64 value);
/// Reset all leaf data from this point
void resetData(TGameCycle gc, bool forceReset=false);
/**
* Clear the node and his children
*/
void clear();
// the parent node for a branch (NULL by default)
virtual void setParent(CCDBNodeBranch* parent) { _Parent=parent; }
//get the node parent
virtual CCDBNodeBranch *getParent()
{
return _Parent;
}
/// Count the leaves
virtual uint countLeaves() const
{
return 1;
}
/// Find the leaf which count is specified (if found, the returned value is non-null and count is 0)
virtual CCDBNodeLeaf *findLeafAtCount( uint& count )
{
if ( count == 0 )
return this;
else
{
--count;
return NULL;
}
}
/// Debug purpose
virtual void display(const std::string &prefix);
virtual bool isLeaf() const { return true; }
/**
* add an observer to a property
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node doen t exist
*/
virtual bool addObserver(IPropertyObserver* observer, CTextId& id);
/** remove an obsever
* \param observer : pointer to an observer
* \param id text id identifying the property
* \return false if the node or observer doesn t exist
*/
virtual bool removeObserver(IPropertyObserver* observer, CTextId& id);
/// get the last change GameCycle (server tick) for this value
TGameCycle getLastChangeGC() const {return _LastChangeGC;}
private:
CCDBNodeBranch * _Parent;
/// property value
sint64 _Property;
sint64 _oldProperty;
/// property type
EPropType _Type;
/// true if this value has changed
bool _Changed;
/// gamecycle (servertick) of the last change for this value.
/// change are made in readDelta only for change >= _LastChangeGC
TGameCycle _LastChangeGC;
/// observers to call when the value really change
std::vector<IPropertyObserver*> _Observers;
private:
void notifyObservers();
};
////////////////////
// INLINE MEMBERS //
////////////////////
}
#endif // CDB_LEAF_H

@ -1,190 +1,190 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_MANAGER_H
#define CDB_MANAGER_H
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/cdb_bank_handler.h"
#include "nel/misc/cdb_branch_observing_handler.h"
namespace NLMISC{
/// Class that encapsulates the separate CDB components
class CCDBManager{
public:
/**
The constructor
@param maxBanks - The maximum number of banks to be used
*/
CCDBManager( const char *rootNodeName, uint maxBanks );
~CCDBManager();
/**
Returns the specified leaf node from the database.
@param name The name of the leaf node.
@param create Specifies if the node should be created if it doesn't exist yet.
*/
CCDBNodeLeaf* getDbLeaf( const std::string &name, bool create = true );
/**
Returns the specified branch node from the database.
@param name The name of the branch.
*/
CCDBNodeBranch* getDbBranch( const std::string &name );
/**
Deletes the specified database node.
@param name The name of the database node.
*/
void delDbNode( const std::string &name );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branch The branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 );
/**
Adds an observer to a branch of the database.
@param branch The branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branch The branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Adds a branch observer call flush observer. ( These are notified after the branch observers are notified )
@param observer The observer
*/
void addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Removes a branch observer call flush observer.
@param observer The observer
*/
void removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Notifies the observers whose observed branches were updated.
*/
void flushObserverCalls();
/**
Resets the specified bank.
@param gc GameCycle ( no idea what it is exactly, probably some time value )
@param bank The banks we want to reset
*/
void resetBank( uint gc, uint bank );
/**
@brief Resizes the bank holders. WARNING: Resets data contained.
@param newSize - The new maximum number of banks.
*/
void resizeBanks( uint newSize );
protected:
CCDBBankHandler bankHandler;
CCDBBranchObservingHandler branchObservingHandler;
CRefPtr< CCDBNodeBranch > _Database;
};
}
#endif
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef CDB_MANAGER_H
#define CDB_MANAGER_H
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/cdb_bank_handler.h"
#include "nel/misc/cdb_branch_observing_handler.h"
namespace NLMISC{
/// Class that encapsulates the separate CDB components
class CCDBManager{
public:
/**
The constructor
@param maxBanks - The maximum number of banks to be used
*/
CCDBManager( const char *rootNodeName, uint maxBanks );
~CCDBManager();
/**
Returns the specified leaf node from the database.
@param name The name of the leaf node.
@param create Specifies if the node should be created if it doesn't exist yet.
*/
CCDBNodeLeaf* getDbLeaf( const std::string &name, bool create = true );
/**
Returns the specified branch node from the database.
@param name The name of the branch.
*/
CCDBNodeBranch* getDbBranch( const std::string &name );
/**
Deletes the specified database node.
@param name The name of the database node.
*/
void delDbNode( const std::string &name );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( const char *branchName, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branch The branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter A vector of strings containing the names of the leaves we want to observe
*/
void addBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver *observer, const std::vector< std::string >& positiveLeafNameFilter = std::vector< std::string >() );
/**
Adds an observer to a branch of the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter = NULL, uint positiveLeafNameFilterSize = 0 );
/**
Adds an observer to a branch of the database.
@param branch The branch we start from
@param dbPathFromThisNode The path to the branch we want to observe
@param observer The observer we want to add
@param positiveLeafNameFilter An array of strings containing the names of the leaves we want to observe
@param positiveLeafNameFilterSize The size of the array
*/
void addBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer, const char **positiveLeafNameFilter, uint positiveLeafNameFilterSize );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branch The branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, ICDBNode::IPropertyObserver* observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( const char *branchName, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Removes an observer from a branch in the database.
@param branchName The name of the branch we start from
@param dbPathFromThisNode The path to the branch we want to observe from the starting branch
@param observer The observer we want to remove
*/
void removeBranchObserver( CCDBNodeBranch *branch, const char *dbPathFromThisNode, ICDBNode::IPropertyObserver &observer );
/**
Adds a branch observer call flush observer. ( These are notified after the branch observers are notified )
@param observer The observer
*/
void addFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Removes a branch observer call flush observer.
@param observer The observer
*/
void removeFlushObserver( CCDBBranchObservingHandler::IBranchObserverCallFlushObserver *observer );
/**
Notifies the observers whose observed branches were updated.
*/
void flushObserverCalls();
/**
Resets the specified bank.
@param gc GameCycle ( no idea what it is exactly, probably some time value )
@param bank The banks we want to reset
*/
void resetBank( uint gc, uint bank );
/**
@brief Resizes the bank holders. WARNING: Resets data contained.
@param newSize - The new maximum number of banks.
*/
void resizeBanks( uint newSize );
protected:
CCDBBankHandler bankHandler;
CCDBBranchObservingHandler branchObservingHandler;
CRefPtr< CCDBNodeBranch > _Database;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,81 +1,81 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef XML_AUTO_PTR_H
#define XML_AUTO_PTR_H
#include <string>
/** Simple auto pointer for xml pointers
*/
class CXMLAutoPtr
{
public:
CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
~CXMLAutoPtr() { destroy(); }
operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; }
operator std::string() const { return std::string(_Value); }
bool operator ! () const { return _Value == NULL; }
operator const unsigned char *() const { return (const unsigned char *) _Value; }
char operator * () const { nlassert(_Value); return *_Value; }
/// NB : This remove previous owned pointer with xmlFree
CXMLAutoPtr &operator = (const char *other)
{
if (other == _Value) return *this;
destroy();
_Value = other;
return *this;
}
CXMLAutoPtr &operator = (const unsigned char *other)
{
*this = (const char *) other;
return *this;
}
char *getDatas() const { return const_cast<char *>(_Value); }
//////////////////////////////////////////////////
private:
const char *_Value;
private:
void destroy()
{
if (_Value)
{
xmlFree(const_cast<char *>(_Value));
_Value = NULL;
}
}
// We'd rather avoid problems
CXMLAutoPtr(const CXMLAutoPtr &/* other */)
{
nlassert(0);
}
CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */)
{
nlassert(0);
return *this;
}
};
#endif
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// 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 <http://www.gnu.org/licenses/>.
#ifndef XML_AUTO_PTR_H
#define XML_AUTO_PTR_H
#include <string>
/** Simple auto pointer for xml pointers
*/
class CXMLAutoPtr
{
public:
CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
~CXMLAutoPtr() { destroy(); }
operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; }
operator std::string() const { return std::string(_Value); }
bool operator ! () const { return _Value == NULL; }
operator const unsigned char *() const { return (const unsigned char *) _Value; }
char operator * () const { nlassert(_Value); return *_Value; }
/// NB : This remove previous owned pointer with xmlFree
CXMLAutoPtr &operator = (const char *other)
{
if (other == _Value) return *this;
destroy();
_Value = other;
return *this;
}
CXMLAutoPtr &operator = (const unsigned char *other)
{
*this = (const char *) other;
return *this;
}
char *getDatas() const { return const_cast<char *>(_Value); }
//////////////////////////////////////////////////
private:
const char *_Value;
private:
void destroy()
{
if (_Value)
{
xmlFree(const_cast<char *>(_Value));
_Value = NULL;
}
}
// We'd rather avoid problems
CXMLAutoPtr(const CXMLAutoPtr &/* other */)
{
nlassert(0);
}
CXMLAutoPtr&operator = (const CXMLAutoPtr &/* other */)
{
nlassert(0);
return *this;
}
};
#endif

@ -1,37 +1,37 @@
ADD_SUBDIRECTORY(misc)
IF(WITH_3D)
ADD_SUBDIRECTORY(3d)
ENDIF(WITH_3D)
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF(WITH_GUI)
IF(WITH_GEORGES)
ADD_SUBDIRECTORY(georges)
ENDIF(WITH_GEORGES)
IF(WITH_LIGO)
ADD_SUBDIRECTORY(ligo)
ENDIF(WITH_LIGO)
IF(WITH_LOGIC)
ADD_SUBDIRECTORY(logic)
ENDIF(WITH_LOGIC)
IF(WITH_NET)
ADD_SUBDIRECTORY(net)
ENDIF(WITH_NET)
IF(WITH_SOUND)
ADD_SUBDIRECTORY(sound)
ENDIF(WITH_SOUND)
IF(WITH_NEL_CEGUI)
ADD_SUBDIRECTORY(cegui)
ENDIF(WITH_NEL_CEGUI)
IF(WITH_PACS)
ADD_SUBDIRECTORY(pacs)
ENDIF(WITH_PACS)
ADD_SUBDIRECTORY(misc)
IF(WITH_3D)
ADD_SUBDIRECTORY(3d)
ENDIF(WITH_3D)
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF(WITH_GUI)
IF(WITH_GEORGES)
ADD_SUBDIRECTORY(georges)
ENDIF(WITH_GEORGES)
IF(WITH_LIGO)
ADD_SUBDIRECTORY(ligo)
ENDIF(WITH_LIGO)
IF(WITH_LOGIC)
ADD_SUBDIRECTORY(logic)
ENDIF(WITH_LOGIC)
IF(WITH_NET)
ADD_SUBDIRECTORY(net)
ENDIF(WITH_NET)
IF(WITH_SOUND)
ADD_SUBDIRECTORY(sound)
ENDIF(WITH_SOUND)
IF(WITH_NEL_CEGUI)
ADD_SUBDIRECTORY(cegui)
ENDIF(WITH_NEL_CEGUI)
IF(WITH_PACS)
ADD_SUBDIRECTORY(pacs)
ENDIF(WITH_PACS)

@ -1,14 +1,33 @@
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../include/nel/gui/*.h)
NL_TARGET_LIB(nelgui ${HEADERS} ${SRC})
SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "")
NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI")
NL_ADD_RUNTIME_FLAGS(nelgui)
NL_ADD_LIB_SUFFIX(nelgui)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelgui LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
FIND_PACKAGE( Libwww REQUIRED )
FIND_PACKAGE( CURL REQUIRED )
FIND_PACKAGE( Lua51 REQUIRED )
FIND_PACKAGE( Luabind REQUIRED )
FILE(GLOB SRC *.cpp *.h)
FILE(GLOB HEADERS ../../include/nel/gui/*.h)
NL_TARGET_LIB(nelgui ${HEADERS} ${SRC})
SET_TARGET_PROPERTIES(nelgui PROPERTIES LINK_INTERFACE_LIBRARIES "")
NL_DEFAULT_PROPS(nelgui "NeL, Library: NeL GUI")
NL_ADD_RUNTIME_FLAGS(nelgui)
INCLUDE_DIRECTORIES( ${LUA_INCLUDE_DIR} )
NL_ADD_LIB_SUFFIX(nelgui)
#MESSAGE( "libww libs: ${LIBWWW_LIBRARIES}" )
TARGET_LINK_LIBRARIES( nelgui
nelmisc
nel3d
${LUA_LIBRARIES}
${LUABIND_LIBRARIES}
${LIBXML2_LIBRARIES}
${LIBWWW_LIBRARIES}
${CURL_LIBRARIES}
)
IF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)
INSTALL(TARGETS nelgui LIBRARY DESTINATION lib ARCHIVE DESTINATION lib COMPONENT libraries)
ENDIF((WITH_INSTALL_LIBRARIES AND WITH_STATIC) OR NOT WITH_STATIC)

File diff suppressed because it is too large Load Diff

@ -1,485 +1,485 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "libxml/globals.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/ctrl_base.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
#include "nel/misc/i18n.h"
using namespace NLMISC;
namespace NLGUI
{
std::map< std::string, std::map< std::string, std::string > > CCtrlBase::AHCache;
// ***************************************************************************
CCtrlBase::~CCtrlBase()
{
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
if (event.getType() == NLGUI::CEventDescriptor::system)
{
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
{
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive())
{
// the mouse capture should be lost when the ctrl is hidden
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
{
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
}
// NB : don't call return here because derived class may be interested
// in handling event more speciffically
}
}
}
return false;
}
std::string CCtrlBase::tooltipParentToString( TToolTipParentType type )
{
switch( type )
{
case TTMouse:
return "mouse";
break;
case TTWindow:
return "win";
break;
case TTSpecialWindow:
return "special";
break;
}
return "";
}
CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str )
{
std::string s = toLower( str );
if( s == "mouse" )
return TTMouse;
else
if( s == "win" )
return TTWindow;
else
if( s == "special" )
return TTSpecialWindow;
else
return TTCtrl;
}
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CViewBase::parse(cur, parentGroup))
return false;
CXMLAutoPtr prop;
// get static toolTip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
if (prop)
{
const char *propPtr = prop;
_ContextHelp = ucstring(propPtr);
if( !editorMode && ( strlen(propPtr) > 2 ) )
{
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
_ContextHelp = CI18N::get ((const char *) prop);
}
}
// Force I18N tooltip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
if ((bool)prop && strlen((const char*)prop)>0)
{
if( !editorMode )
_ContextHelp = CI18N::get ((const char *) prop);
else
_ContextHelp = (const char*)prop;
}
// get dynamic toolTip ActionHandler
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" );
if (prop)
{
_OnContextHelp= (const char*)prop;
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" );
if (prop)
{
_OnContextHelpParams= (const char*)prop;
}
// Tooltip parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" );
_ToolTipParent= TTCtrl;
if(prop)
{
_ToolTipParent = stringToToolTipParent( std::string( prop ) );
}
// Tooltip special parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" );
_ToolTipSpecialParent= CStringShared();
if(prop)
{
_ToolTipSpecialParent= std::string((const char*)prop);
}
// Tooltip posref
THotSpot tmpParentHS, tmpChildHS;
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRef= tmpParentHS;
_ToolTipPosRef= tmpChildHS;
// Alternative tooltip posref : this one will be chosen
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRefAlt = tmpParentHS;
_ToolTipPosRefAlt = tmpChildHS;
// ToolTip instant
prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help");
_ToolTipInstant= true;
if (prop) _ToolTipInstant = convertBool(prop);
return true;
}
std::string CCtrlBase::getProperty( const std::string &name ) const
{
if( name == "tooltip" )
{
return _ContextHelp.toString();
}
else
if( name == "tooltip_i18n" )
{
return _ContextHelp.toString();
}
else
if( name == "on_tooltip" )
{
return _OnContextHelp.toString();
}
else
if( name == "on_tooltip_params" )
{
return _OnContextHelpParams.toString();
}
else
if( name == "tooltip_parent" )
{
return tooltipParentToString( _ToolTipParent );
}
else
if( name == "tooltip_special_parent" )
{
return _ToolTipSpecialParent.toString();
}
else
if( name == "tooltip_posref" )
{
std::string s;
if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) )
return "auto";
else{
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef );
s += " ";
s += CInterfaceElement::HotSpotToString( _ToolTipPosRef );
return s;
}
}
else
if( name == "tooltip_posref_alt" )
{
std::string s;
if( ( _ToolTipParentPosRefAlt == Hotspot_TTAuto ) && ( _ToolTipPosRefAlt == Hotspot_TTAuto ) )
return "auto";
else{
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRefAlt );
s += " ";
s += CInterfaceElement::HotSpotToString( _ToolTipPosRefAlt );
return s;
}
}
else
if( name == "instant_help" )
{
return toString( _ToolTipInstant );
}
else
return CInterfaceElement::getProperty( name );
}
void CCtrlBase::setProperty( const std::string &name, const std::string &value )
{
if( name == "tooltip" )
{
_ContextHelp = value;
return;
}
else
if( name == "tooltip_i18n" )
{
_ContextHelp = value;
return;
}
else
if( name == "on_tooltip" )
{
_OnContextHelp = value;
return;
}
else
if( name == "on_tooltip_params" )
{
_OnContextHelpParams = value;
return;
}
else
if( name == "tooltip_parent" )
{
_ToolTipParent = stringToToolTipParent( value );
return;
}
else
if( name == "tooltip_special_parent" )
{
_ToolTipSpecialParent = value;
return;
}
else
if( name == "tooltip_posref" )
{
THotSpot parentHS;
THotSpot HS;
convertTooltipHotSpot( value.c_str(), parentHS, HS );
_ToolTipParentPosRef = parentHS;
_ToolTipPosRef = HS;
return;
}
else
if( name == "tooltip_posref_alt" )
{
THotSpot parentHS;
THotSpot HS;
convertTooltipHotSpot( value.c_str(), parentHS, HS );
_ToolTipParentPosRefAlt = parentHS;
_ToolTipPosRefAlt = HS;
return;
}
else
if( name == "instant_help" )
{
bool b;
if( fromString( value, b ) )
_ToolTipInstant = b;
return;
}
else
CInterfaceElement::setProperty( name, value );
}
xmlNodePtr CCtrlBase::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node =
CInterfaceElement::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
xmlNewProp( node, BAD_CAST "tooltip_special_parent", BAD_CAST _ToolTipSpecialParent.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_posref",
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRef, _ToolTipPosRef ).c_str() );
xmlNewProp( node, BAD_CAST "tooltip_posref_alt",
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRefAlt, _ToolTipPosRefAlt ).c_str() );
xmlNewProp( node, BAD_CAST "instant_help", BAD_CAST toString( _ToolTipInstant ).c_str() );
return node;
}
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
if(prop)
{
const char *ptr= (const char*)prop;
if(stricmp(ptr, "auto")==0)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
}
// valid ref?
else if(strlen(ptr)>=5)
{
THotSpot parentPosRef;
THotSpot posRef;
CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef);
parentHS = parentPosRef;
childHS = posRef;
}
}
}
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
{
std::string s;
if( ( parent == Hotspot_TTAuto ) && ( child == Hotspot_TTAuto ) )
{
s = "auto";
}
else
{
s = CInterfaceElement::HotSpotToString( parent );
s += " ";
s += CInterfaceElement::HotSpotToString( child );
}
return s;
}
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
ucstring help;
getContextHelp(help);
std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty();
}
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitCtrl(this);
CInterfaceElement::visit(visitor);
}
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
CViewBase::serial(f);
f.serial(_ContextHelp);
f.serial(_OnContextHelp);
f.serial(_OnContextHelpParams);
f.serial(_ToolTipSpecialParent);
f.serialEnum(_ToolTipParent);
//
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
THotSpot tmpToolTipPosRef = _ToolTipPosRef;
THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt;
THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt;
f.serialEnum(tmpToolTipParentPosRef);
f.serialEnum(tmpToolTipPosRef);
f.serialEnum(tmpToolTipParentPosRefAlt);
f.serialEnum(tmpToolTipPosRefAlt);
_ToolTipParentPosRef = tmpToolTipParentPosRef;
_ToolTipPosRef = tmpToolTipPosRef;
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant);
}
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
return "context_help";
}
uint32 CCtrlBase::getDepth( CInterfaceGroup *group )
{
uint32 depth = 1;
CInterfaceGroup *parent = getParent();
while( parent != NULL )
{
if ( parent == group )
break;
else
parent = parent->getParent();
depth++;
}
// The Resizer Ctrls take the precedence over Sons controls.
return depth + getDeltaDepth();
}
void CCtrlBase::mapAHString( const std::string &key, const std::string &value )
{
std::map< std::string, std::map< std::string, std::string > >::iterator itr = AHCache.find( getId() );
if( itr == AHCache.end() )
{
AHCache[ getId() ];
itr = AHCache.find( getId() );
}
std::map< std::string, std::string > &AHMap = itr->second;
AHMap[ key ] = value;
}
std::string CCtrlBase::getAHString( const std::string &key ) const
{
std::map< std::string, std::map< std::string, std::string > >::const_iterator itr = AHCache.find( getId() );
if( itr == AHCache.end() )
return "";
std::map< std::string, std::string >::const_iterator itr2 = itr->second.find( key );
if( itr2 == itr->second.end() )
return "";
else
return itr2->second;
}
}
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "libxml/globals.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/ctrl_base.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
#include "nel/misc/i18n.h"
using namespace NLMISC;
namespace NLGUI
{
std::map< std::string, std::map< std::string, std::string > > CCtrlBase::AHCache;
// ***************************************************************************
CCtrlBase::~CCtrlBase()
{
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
if (event.getType() == NLGUI::CEventDescriptor::system)
{
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
{
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive())
{
// the mouse capture should be lost when the ctrl is hidden
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
{
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
}
// NB : don't call return here because derived class may be interested
// in handling event more speciffically
}
}
}
return false;
}
std::string CCtrlBase::tooltipParentToString( TToolTipParentType type )
{
switch( type )
{
case TTMouse:
return "mouse";
break;
case TTWindow:
return "win";
break;
case TTSpecialWindow:
return "special";
break;
}
return "";
}
CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str )
{
std::string s = toLower( str );
if( s == "mouse" )
return TTMouse;
else
if( s == "win" )
return TTWindow;
else
if( s == "special" )
return TTSpecialWindow;
else
return TTCtrl;
}
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CViewBase::parse(cur, parentGroup))
return false;
CXMLAutoPtr prop;
// get static toolTip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
if (prop)
{
const char *propPtr = prop;
_ContextHelp = ucstring(propPtr);
if( !editorMode && ( strlen(propPtr) > 2 ) )
{
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
_ContextHelp = CI18N::get ((const char *) prop);
}
}
// Force I18N tooltip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
if ((bool)prop && strlen((const char*)prop)>0)
{
if( !editorMode )
_ContextHelp = CI18N::get ((const char *) prop);
else
_ContextHelp = (const char*)prop;
}
// get dynamic toolTip ActionHandler
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" );
if (prop)
{
_OnContextHelp= (const char*)prop;
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" );
if (prop)
{
_OnContextHelpParams= (const char*)prop;
}
// Tooltip parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" );
_ToolTipParent= TTCtrl;
if(prop)
{
_ToolTipParent = stringToToolTipParent( std::string( (const char*)prop ) );
}
// Tooltip special parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" );
_ToolTipSpecialParent= CStringShared();
if(prop)
{
_ToolTipSpecialParent= std::string((const char*)prop);
}
// Tooltip posref
THotSpot tmpParentHS, tmpChildHS;
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRef= tmpParentHS;
_ToolTipPosRef= tmpChildHS;
// Alternative tooltip posref : this one will be chosen
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRefAlt = tmpParentHS;
_ToolTipPosRefAlt = tmpChildHS;
// ToolTip instant
prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help");
_ToolTipInstant= true;
if (prop) _ToolTipInstant = convertBool(prop);
return true;
}
std::string CCtrlBase::getProperty( const std::string &name ) const
{
if( name == "tooltip" )
{
return _ContextHelp.toString();
}
else
if( name == "tooltip_i18n" )
{
return _ContextHelp.toString();
}
else
if( name == "on_tooltip" )
{
return _OnContextHelp.toString();
}
else
if( name == "on_tooltip_params" )
{
return _OnContextHelpParams.toString();
}
else
if( name == "tooltip_parent" )
{
return tooltipParentToString( _ToolTipParent );
}
else
if( name == "tooltip_special_parent" )
{
return _ToolTipSpecialParent.toString();
}
else
if( name == "tooltip_posref" )
{
std::string s;
if( ( _ToolTipParentPosRef == Hotspot_TTAuto ) && ( _ToolTipPosRef == Hotspot_TTAuto ) )
return "auto";
else{
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRef );
s += " ";
s += CInterfaceElement::HotSpotToString( _ToolTipPosRef );
return s;
}
}
else
if( name == "tooltip_posref_alt" )
{
std::string s;
if( ( _ToolTipParentPosRefAlt == Hotspot_TTAuto ) && ( _ToolTipPosRefAlt == Hotspot_TTAuto ) )
return "auto";
else{
s = CInterfaceElement::HotSpotToString( _ToolTipParentPosRefAlt );
s += " ";
s += CInterfaceElement::HotSpotToString( _ToolTipPosRefAlt );
return s;
}
}
else
if( name == "instant_help" )
{
return toString( _ToolTipInstant );
}
else
return CInterfaceElement::getProperty( name );
}
void CCtrlBase::setProperty( const std::string &name, const std::string &value )
{
if( name == "tooltip" )
{
_ContextHelp = value;
return;
}
else
if( name == "tooltip_i18n" )
{
_ContextHelp = value;
return;
}
else
if( name == "on_tooltip" )
{
_OnContextHelp = value;
return;
}
else
if( name == "on_tooltip_params" )
{
_OnContextHelpParams = value;
return;
}
else
if( name == "tooltip_parent" )
{
_ToolTipParent = stringToToolTipParent( value );
return;
}
else
if( name == "tooltip_special_parent" )
{
_ToolTipSpecialParent = value;
return;
}
else
if( name == "tooltip_posref" )
{
THotSpot parentHS;
THotSpot HS;
convertTooltipHotSpot( value.c_str(), parentHS, HS );
_ToolTipParentPosRef = parentHS;
_ToolTipPosRef = HS;
return;
}
else
if( name == "tooltip_posref_alt" )
{
THotSpot parentHS;
THotSpot HS;
convertTooltipHotSpot( value.c_str(), parentHS, HS );
_ToolTipParentPosRefAlt = parentHS;
_ToolTipPosRefAlt = HS;
return;
}
else
if( name == "instant_help" )
{
bool b;
if( fromString( value, b ) )
_ToolTipInstant = b;
return;
}
else
CInterfaceElement::setProperty( name, value );
}
xmlNodePtr CCtrlBase::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node =
CInterfaceElement::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
xmlNewProp( node, BAD_CAST "tooltip_special_parent", BAD_CAST _ToolTipSpecialParent.toString().c_str() );
xmlNewProp( node, BAD_CAST "tooltip_posref",
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRef, _ToolTipPosRef ).c_str() );
xmlNewProp( node, BAD_CAST "tooltip_posref_alt",
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRefAlt, _ToolTipPosRefAlt ).c_str() );
xmlNewProp( node, BAD_CAST "instant_help", BAD_CAST toString( _ToolTipInstant ).c_str() );
return node;
}
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
if(prop)
{
const char *ptr= (const char*)prop;
if(stricmp(ptr, "auto")==0)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
}
// valid ref?
else if(strlen(ptr)>=5)
{
THotSpot parentPosRef;
THotSpot posRef;
CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef);
parentHS = parentPosRef;
childHS = posRef;
}
}
}
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
{
std::string s;
if( ( parent == Hotspot_TTAuto ) && ( child == Hotspot_TTAuto ) )
{
s = "auto";
}
else
{
s = CInterfaceElement::HotSpotToString( parent );
s += " ";
s += CInterfaceElement::HotSpotToString( child );
}
return s;
}
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
ucstring help;
getContextHelp(help);
std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty();
}
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitCtrl(this);
CInterfaceElement::visit(visitor);
}
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
CViewBase::serial(f);
f.serial(_ContextHelp);
f.serial(_OnContextHelp);
f.serial(_OnContextHelpParams);
f.serial(_ToolTipSpecialParent);
f.serialEnum(_ToolTipParent);
//
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
THotSpot tmpToolTipPosRef = _ToolTipPosRef;
THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt;
THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt;
f.serialEnum(tmpToolTipParentPosRef);
f.serialEnum(tmpToolTipPosRef);
f.serialEnum(tmpToolTipParentPosRefAlt);
f.serialEnum(tmpToolTipPosRefAlt);
_ToolTipParentPosRef = tmpToolTipParentPosRef;
_ToolTipPosRef = tmpToolTipPosRef;
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant);
}
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
return "context_help";
}
uint32 CCtrlBase::getDepth( CInterfaceGroup *group )
{
uint32 depth = 1;
CInterfaceGroup *parent = getParent();
while( parent != NULL )
{
if ( parent == group )
break;
else
parent = parent->getParent();
depth++;
}
// The Resizer Ctrls take the precedence over Sons controls.
return depth + getDeltaDepth();
}
void CCtrlBase::mapAHString( const std::string &key, const std::string &value )
{
std::map< std::string, std::map< std::string, std::string > >::iterator itr = AHCache.find( getId() );
if( itr == AHCache.end() )
{
AHCache[ getId() ];
itr = AHCache.find( getId() );
}
std::map< std::string, std::string > &AHMap = itr->second;
AHMap[ key ] = value;
}
std::string CCtrlBase::getAHString( const std::string &key ) const
{
std::map< std::string, std::map< std::string, std::string > >::const_iterator itr = AHCache.find( getId() );
if( itr == AHCache.end() )
return "";
std::map< std::string, std::string >::const_iterator itr2 = itr->second.find( key );
if( itr2 == itr->second.end() )
return "";
else
return itr2->second;
}
}

File diff suppressed because it is too large Load Diff

@ -1,489 +1,489 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_button.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h"
// ----------------------------------------------------------------------------
using namespace std;
using namespace NLMISC;
using namespace NL3D;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button");
namespace NLGUI
{
void CCtrlButton::setAlignFromString( const std::string &s )
{
_Align = 0;
std::string::size_type i;
for( i = 0; i < s.size(); i++ )
{
char c = toLower( s[ i ] );
switch( c ){
case 'l':
_Align &= ~1;
break;
case 'r':
_Align |= 1;
break;
case 'b':
_Align &= ~2;
break;
case 't':
_Align |= 2;
break;
}
}
}
std::string CCtrlButton::getProperty( const std::string &name ) const
{
if( name == "tx_normal" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
}
else
if( name == "tx_pushed" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
}
else
if( name == "tx_over" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
}
else
if( name == "scale" )
{
return toString( _Scale );
}
else
if( name == "align" )
{
std::string align;
if( ( _Align & 1 ) != 0 )
align = "r";
else
align = "l";
if( ( _Align & 2 ) != 0 )
align += "t";
else
align += "b";
return align;
}
else
return CCtrlBaseButton::getProperty( name );
}
void CCtrlButton::setProperty( const std::string &name, const std::string &value )
{
if( name == "tx_normal" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
if( !_TextureIdNormal.setTexture( value.c_str() ) )
{
_TextureIdNormal.setTexture( s.c_str() );
}
return;
}
else
if( name == "tx_pushed" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
if( !_TextureIdPushed.setTexture( value.c_str() ) )
{
_TextureIdPushed.setTexture( s.c_str() );
}
return;
}
else
if( name == "tx_over" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
if( !_TextureIdOver.setTexture( value.c_str() ) )
{
_TextureIdOver.setTexture( s.c_str() );
}
return;
}
else
if( name == "scale" )
{
bool b;
if( fromString( value, b ) )
_Scale = b;
return;
}
else
if( name == "align" )
{
setAlignFromString( value );
return;
}
else
CCtrlBaseButton::setProperty( name, value );
}
xmlNodePtr CCtrlButton::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" );
xmlNewProp( node, BAD_CAST "tx_normal",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal ).c_str() );
xmlNewProp( node, BAD_CAST "tx_pushed",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed ).c_str() );
xmlNewProp( node, BAD_CAST "tx_over",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver ).c_str() );
xmlNewProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() );
std::string align;
if( ( _Align & 1 ) != 0 )
align = "r";
else
align = "l";
if( ( _Align & 2 ) != 0 )
align += "t";
else
align += "b";
xmlNewProp( node, BAD_CAST "align", BAD_CAST align.c_str() );
return node;
}
// ----------------------------------------------------------------------------
bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{
CXMLAutoPtr prop;
//try to get props that can be inherited from groups
//if a property is not defined, try to find it in the parent group.
//if it is undefined, set it to zero
if (! CCtrlBaseButton::parse(cur,parentGroup) )
{
string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId();
nlinfo(tmp.c_str());
return false;
}
// *** Read Textures
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdNormal.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdPushed.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdOver.setTexture(TxName.c_str());
}
// *** Misc.
prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" );
_Scale = false;
if (prop)
_Scale = convertBool(prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"align");
if (prop)
{
setAlignFromString( std::string( prop ) );
}
return true;
}
// ----------------------------------------------------------------------------
void CCtrlButton::draw ()
{
sint32 nTxId = -1;
CRGBA color;
CViewRenderer &rVR = *CViewRenderer::getInstance();
CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent();
// *** Detect Over
bool lastOver = false;
updateOver(lastOver);
sint32 x = _XReal;
sint32 y = _YReal;
sint32 txw, txh;
// the pointer is over the button
if (_Scale)
{
x = _XReal;
y = _YReal;
txw = _WReal;
txh = _HReal;
}
else
{
x = _XReal;
y = _YReal;
}
switch(_Type)
{
case ToggleButton:
{
if (_Pushed && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
}
}
break;
case RadioButton:
{
// CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer();
// Init the radio button
initRBRef();
if (*_RBRef == this)
{
// if it is equal to the ref value, then the button must appear pushed
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
if ( (_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
_Pushed = false;
}
}
}
break;
case PushButton:
{
if ( _Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
_Pushed = false;
}
}
break;
default:
break;
}
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
// Fromzen ?
if (getFrozen() && getFrozenHalfTone())
color.A >>= 2;
if (!_Scale)
{
CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh);
if (_Align&1)
x = x + _WReal - txw;
if (_Align&2)
y = y + _HReal - txh;
}
rVR.drawRotFlipBitmap ( _RenderLayer, x, y, txw, txh,
0, false,
nTxId,
color );
if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this)))
return;
if ( ( _Over && !editorMode ) || editorSelected )
{
if( !editorMode && (lastOver == false) && (_AHOnOver != NULL))
CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams);
// the pointer is over the button
color= getCurrentColorOver(globalColor);
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
// Frozen ?
if (getFrozen())
color.A >>= 2;
// draw the over. force upper layer to avoid problem with DXTC/tga
rVR.drawRotFlipBitmap ( _RenderLayer+1, x, y, txw, txh,
0, false,
_TextureIdOver,
color );
}
}
// ----------------------------------------------------------------------------
void CCtrlButton::updateCoords()
{
if (!_Scale)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 txw, txh;
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
_W = txw;
_H = txh;
}
CViewBase::updateCoords();
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTexture(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdNormal.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTexturePushed(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdPushed.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTextureOver(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdOver.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTexture() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdNormal);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTexturePushed() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdPushed);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTextureOver() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdOver);
}
// ***************************************************************************
sint32 CCtrlButton::getMaxUsedW() const
{
sint32 txw, txh;
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
return txw;
}
// ***************************************************************************
sint32 CCtrlButton::getMinUsedW() const
{
return getMaxUsedW();
}
// ***************************************************************************
void CCtrlButton::fitTexture()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 w, h;
rVR.getTextureSizeFromId(_TextureIdNormal, w, h);
setW(w);
setH(h);
}
// ***************************************************************************
bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
{
if (_AHOnLeftClickString == "browse")
{
if (!_AHOnLeftClickStringParams.empty())
{
texName = "@curs_pick.tga@"+_AHOnLeftClickStringParams;
}
else
{
texName = "curs_pick.tga";
}
rot= 0;
col = CRGBA::White;
return true;
}
return false;
}
}
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_button.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h"
// ----------------------------------------------------------------------------
using namespace std;
using namespace NLMISC;
using namespace NL3D;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlButton, std::string, "button");
namespace NLGUI
{
void CCtrlButton::setAlignFromString( const std::string &s )
{
_Align = 0;
std::string::size_type i;
for( i = 0; i < s.size(); i++ )
{
char c = toLower( s[ i ] );
switch( c ){
case 'l':
_Align &= ~1;
break;
case 'r':
_Align |= 1;
break;
case 'b':
_Align &= ~2;
break;
case 't':
_Align |= 2;
break;
}
}
}
std::string CCtrlButton::getProperty( const std::string &name ) const
{
if( name == "tx_normal" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
}
else
if( name == "tx_pushed" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
}
else
if( name == "tx_over" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
}
else
if( name == "scale" )
{
return toString( _Scale );
}
else
if( name == "align" )
{
std::string align;
if( ( _Align & 1 ) != 0 )
align = "r";
else
align = "l";
if( ( _Align & 2 ) != 0 )
align += "t";
else
align += "b";
return align;
}
else
return CCtrlBaseButton::getProperty( name );
}
void CCtrlButton::setProperty( const std::string &name, const std::string &value )
{
if( name == "tx_normal" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal );
if( !_TextureIdNormal.setTexture( value.c_str() ) )
{
_TextureIdNormal.setTexture( s.c_str() );
}
return;
}
else
if( name == "tx_pushed" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed );
if( !_TextureIdPushed.setTexture( value.c_str() ) )
{
_TextureIdPushed.setTexture( s.c_str() );
}
return;
}
else
if( name == "tx_over" )
{
std::string s = CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver );
if( !_TextureIdOver.setTexture( value.c_str() ) )
{
_TextureIdOver.setTexture( s.c_str() );
}
return;
}
else
if( name == "scale" )
{
bool b;
if( fromString( value, b ) )
_Scale = b;
return;
}
else
if( name == "align" )
{
setAlignFromString( value );
return;
}
else
CCtrlBaseButton::setProperty( name, value );
}
xmlNodePtr CCtrlButton::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CCtrlBaseButton::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "button" );
xmlNewProp( node, BAD_CAST "tx_normal",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdNormal ).c_str() );
xmlNewProp( node, BAD_CAST "tx_pushed",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdPushed ).c_str() );
xmlNewProp( node, BAD_CAST "tx_over",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _TextureIdOver ).c_str() );
xmlNewProp( node, BAD_CAST "scale", BAD_CAST toString( _Scale ).c_str() );
std::string align;
if( ( _Align & 1 ) != 0 )
align = "r";
else
align = "l";
if( ( _Align & 2 ) != 0 )
align += "t";
else
align += "b";
xmlNewProp( node, BAD_CAST "align", BAD_CAST align.c_str() );
return node;
}
// ----------------------------------------------------------------------------
bool CCtrlButton::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
{
CXMLAutoPtr prop;
//try to get props that can be inherited from groups
//if a property is not defined, try to find it in the parent group.
//if it is undefined, set it to zero
if (! CCtrlBaseButton::parse(cur,parentGroup) )
{
string tmp = "cannot parse view:"+getId()+", parent:"+parentGroup->getId();
nlinfo(tmp.c_str());
return false;
}
// *** Read Textures
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdNormal.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdPushed.setTexture(TxName.c_str());
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" );
if (prop)
{
string TxName = (const char *) prop;
TxName = strlwr(TxName);
_TextureIdOver.setTexture(TxName.c_str());
}
// *** Misc.
prop = (char*) xmlGetProp( cur, (xmlChar*)"scale" );
_Scale = false;
if (prop)
_Scale = convertBool(prop);
prop = (char*) xmlGetProp (cur, (xmlChar*)"align");
if (prop)
{
setAlignFromString( std::string( (const char*)prop ) );
}
return true;
}
// ----------------------------------------------------------------------------
void CCtrlButton::draw ()
{
sint32 nTxId = -1;
CRGBA color;
CViewRenderer &rVR = *CViewRenderer::getInstance();
CRGBA globalColor= CWidgetManager::getInstance()->getGlobalColorForContent();
// *** Detect Over
bool lastOver = false;
updateOver(lastOver);
sint32 x = _XReal;
sint32 y = _YReal;
sint32 txw, txh;
// the pointer is over the button
if (_Scale)
{
x = _XReal;
y = _YReal;
txw = _WReal;
txh = _HReal;
}
else
{
x = _XReal;
y = _YReal;
}
switch(_Type)
{
case ToggleButton:
{
if (_Pushed && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
}
}
break;
case RadioButton:
{
// CViewPointer &rIP = *CInterfaceManager::getInstance()->getPointer();
// Init the radio button
initRBRef();
if (*_RBRef == this)
{
// if it is equal to the ref value, then the button must appear pushed
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
if ( (_Over) && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
_Pushed = false;
}
}
}
break;
case PushButton:
{
if ( _Over && (CWidgetManager::getInstance()->getCapturePointerLeft() == this) && !editorMode )
{
nTxId = _TextureIdPushed;
color = getCurrentColorPushed(globalColor);
}
else
{
nTxId = _TextureIdNormal;
color = getCurrentColorNormal(globalColor);
_Pushed = false;
}
}
break;
default:
break;
}
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
// Fromzen ?
if (getFrozen() && getFrozenHalfTone())
color.A >>= 2;
if (!_Scale)
{
CViewRenderer::getInstance()->getTextureSizeFromId (nTxId, txw, txh);
if (_Align&1)
x = x + _WReal - txw;
if (_Align&2)
y = y + _HReal - txh;
}
rVR.drawRotFlipBitmap ( _RenderLayer, x, y, txw, txh,
0, false,
nTxId,
color );
if ((_OverWhenPushed == false) && (_Pushed == true || (CWidgetManager::getInstance()->getCapturePointerLeft() == this)))
return;
if ( ( _Over && !editorMode ) || editorSelected )
{
if( !editorMode && (lastOver == false) && (_AHOnOver != NULL))
CAHManager::getInstance()->runActionHandler (_AHOnOver, this, _AHOverParams);
// the pointer is over the button
color= getCurrentColorOver(globalColor);
color.A = (uint8)(((sint32)color.A*((sint32)globalColor.A+1))>>8);
// Frozen ?
if (getFrozen())
color.A >>= 2;
// draw the over. force upper layer to avoid problem with DXTC/tga
rVR.drawRotFlipBitmap ( _RenderLayer+1, x, y, txw, txh,
0, false,
_TextureIdOver,
color );
}
}
// ----------------------------------------------------------------------------
void CCtrlButton::updateCoords()
{
if (!_Scale)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 txw, txh;
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
_W = txw;
_H = txh;
}
CViewBase::updateCoords();
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTexture(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdNormal.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTexturePushed(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdPushed.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
void CCtrlButton::setTextureOver(const std::string&name)
{
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
_TextureIdOver.setTexture(name.c_str (), 0, 0, -1, -1, false);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTexture() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdNormal);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTexturePushed() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdPushed);
}
// ----------------------------------------------------------------------------
std::string CCtrlButton::getTextureOver() const
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
return rVR.getTextureNameFromId(_TextureIdOver);
}
// ***************************************************************************
sint32 CCtrlButton::getMaxUsedW() const
{
sint32 txw, txh;
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId (_TextureIdNormal, txw, txh);
return txw;
}
// ***************************************************************************
sint32 CCtrlButton::getMinUsedW() const
{
return getMaxUsedW();
}
// ***************************************************************************
void CCtrlButton::fitTexture()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 w, h;
rVR.getTextureSizeFromId(_TextureIdNormal, w, h);
setW(w);
setH(h);
}
// ***************************************************************************
bool CCtrlButton::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
{
if (_AHOnLeftClickString == "browse")
{
if (!_AHOnLeftClickStringParams.empty())
{
texName = "@curs_pick.tga@"+_AHOnLeftClickStringParams;
}
else
{
texName = "curs_pick.tga";
}
rot= 0;
col = CRGBA::White;
return true;
}
return false;
}
}

@ -1,350 +1,350 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_col_pick.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/action_handler.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h"
using namespace NLMISC;
using namespace std;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick");
namespace NLGUI
{
// ------------------------------------------------------------------------------------------------
CCtrlColPick::CCtrlColPick(const TCtorParam &param)
:CCtrlBase(param)
{
_MouseDown = false;
_Texture = -2;
}
// ------------------------------------------------------------------------------------------------
CCtrlColPick::~CCtrlColPick()
{
// Texture has been created ?
if (_Texture>=0)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.deleteTexture (_Texture);
}
}
std::string CCtrlColPick::getProperty( const std::string &name ) const
{
if( name == "texture" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _Texture );
}
else
if( name == "onchange" )
{
return _AHOnChange;
}
else
if( name == "onchange_params" )
{
return _AHOnChangeParams;
}
else
if( name == "dbcolr" )
{
if( _ColSelR.getNodePtr() != NULL )
return _ColSelR.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcolg" )
{
if( _ColSelG.getNodePtr() != NULL )
return _ColSelG.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcolb" )
{
if( _ColSelB.getNodePtr() != NULL )
return _ColSelB.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcola" )
{
if( _ColSelA.getNodePtr() != NULL )
return _ColSelA.getNodePtr()->getFullName();
else
return "";
}
else
return CCtrlBase::getProperty( name );
}
void CCtrlColPick::setProperty( const std::string &name, const std::string &value )
{
if( name == "texture" )
{
CViewRenderer::getInstance()->deleteTexture( _Texture );
_Texture = CViewRenderer::getInstance()->createTexture( value, 0, 0, 256, 64, false, false );
return;
}
else
if( name == "onchange" )
{
_AHOnChange = value;
}
else
if( name == "onchange_params" )
{
_AHOnChangeParams = value;
return;
}
else
if( name == "dbcolr" )
{
_ColSelR.link( value.c_str() );
return;
}
else
if( name == "dbcolg" )
{
_ColSelG.link( value.c_str() );
return;
}
else
if( name == "dbcolb" )
{
_ColSelB.link( value.c_str() );
return;
}
else
if( name == "dbcola" )
{
_ColSelA.link( value.c_str() );
return;
}
else
CCtrlBase::setProperty( name, value );
}
xmlNodePtr CCtrlColPick::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CCtrlBase::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "colpick" );
xmlSetProp( node, BAD_CAST "texture",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _Texture ).c_str() );
xmlSetProp( node, BAD_CAST "onchange", BAD_CAST _AHOnChange.c_str() );
xmlSetProp( node, BAD_CAST "onchange_params", BAD_CAST _AHOnChangeParams.c_str() );
std::string s;
if( _ColSelR.getNodePtr() != NULL )
s = _ColSelR.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolr", BAD_CAST s.c_str() );
if( _ColSelG.getNodePtr() != NULL )
s = _ColSelG.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolg", BAD_CAST s.c_str() );
if( _ColSelB.getNodePtr() != NULL )
s = _ColSelB.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolb", BAD_CAST s.c_str() );
if( _ColSelA.getNodePtr() != NULL )
s = _ColSelA.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcola", BAD_CAST s.c_str() );
return node;
}
// ------------------------------------------------------------------------------------------------
bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup)
{
if (!CCtrlBase::parse(node, parentGroup))
return false;
CXMLAutoPtr prop;
// Read textures
prop = (char*) xmlGetProp( node, (xmlChar*)"texture" );
CViewRenderer &rVR = *CViewRenderer::getInstance();
if(prop)
{
string sTmp = NLMISC::strlwr((const char*)prop);
_Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false);
}
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" );
if (prop) _AHOnChange = NLMISC::strlwr(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" );
if (prop) _AHOnChangeParams = string((const char*)prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolr" );
if (prop) _ColSelR.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolg" );
if (prop) _ColSelG.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolb" );
if (prop) _ColSelB.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcola" );
if (prop) _ColSelA.link(prop);
return true;
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::updateCoords()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 txw, txh;
rVR.getTextureSizeFromId (_Texture, txw, txh);
_W = txw;
_H = txh;
CCtrlBase::updateCoords();
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::draw()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A);
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
_WReal, _HReal,
0, false,
_Texture,
col );
}
// ------------------------------------------------------------------------------------------------
bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event)
{
if (CCtrlBase::handleEvent(event)) return true;
if (!_Active)
return false;
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) &&
(!((eventDesc.getX() >= _XReal) &&
(eventDesc.getX() < (_XReal + _WReal))&&
(eventDesc.getY() > _YReal) &&
(eventDesc.getY() <= (_YReal+ _HReal)))))
return false;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown)
{
_MouseDown = true;
selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal);
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
{
_MouseDown = false;
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove)
{
if (_MouseDown)
{
selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal);
}
return true;
}
}
return false;
}
// ------------------------------------------------------------------------------------------------
string CCtrlColPick::getColor () const
{
return NLMISC::toString(_ColorSelect.R) + " " + NLMISC::toString(_ColorSelect.G) + " " + NLMISC::toString(_ColorSelect.B) + " " + NLMISC::toString(_ColorSelect.A);
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::setColor (const string &col)
{
_ColorSelect = convertColor (col.c_str());
}
// ------------------------------------------------------------------------------------------------
string CCtrlColPick::getColorOver () const
{
return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A);
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::setColorOver (const string &col)
{
_ColorOver = convertColor (col.c_str());
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::selectColor (sint32 x, sint32 y)
{
_ColorSelect = getColor (x, y);
if (_ColSelR.getNodePtr() != NULL)
_ColSelR.setSInt32(_ColorSelect.R);
if (_ColSelG.getNodePtr() != NULL)
_ColSelG.setSInt32(_ColorSelect.G);
if (_ColSelB.getNodePtr() != NULL)
_ColSelB.setSInt32(_ColorSelect.B);
if (_ColSelA.getNodePtr() != NULL)
_ColSelA.setSInt32(_ColorSelect.A);
if (!_AHOnChange.empty())
CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _AHOnChangeParams);
}
// ------------------------------------------------------------------------------------------------
CRGBA CCtrlColPick::getColor (sint32 x, sint32 y)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x >= _WReal) x = _WReal-1;
if (y >= _HReal) y = _HReal-1;
return rVR.getTextureColor (_Texture, x, y);
}
}
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_col_pick.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/action_handler.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/interface_group.h"
using namespace NLMISC;
using namespace std;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlColPick, std::string, "colpick");
namespace NLGUI
{
// ------------------------------------------------------------------------------------------------
CCtrlColPick::CCtrlColPick(const TCtorParam &param)
:CCtrlBase(param)
{
_MouseDown = false;
_Texture = -2;
}
// ------------------------------------------------------------------------------------------------
CCtrlColPick::~CCtrlColPick()
{
// Texture has been created ?
if (_Texture>=0)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.deleteTexture (_Texture);
}
}
std::string CCtrlColPick::getProperty( const std::string &name ) const
{
if( name == "texture" )
{
return CViewRenderer::getInstance()->getTextureNameFromId( _Texture );
}
else
if( name == "onchange" )
{
return _AHOnChange;
}
else
if( name == "onchange_params" )
{
return _AHOnChangeParams;
}
else
if( name == "dbcolr" )
{
if( _ColSelR.getNodePtr() != NULL )
return _ColSelR.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcolg" )
{
if( _ColSelG.getNodePtr() != NULL )
return _ColSelG.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcolb" )
{
if( _ColSelB.getNodePtr() != NULL )
return _ColSelB.getNodePtr()->getFullName();
else
return "";
}
else
if( name == "dbcola" )
{
if( _ColSelA.getNodePtr() != NULL )
return _ColSelA.getNodePtr()->getFullName();
else
return "";
}
else
return CCtrlBase::getProperty( name );
}
void CCtrlColPick::setProperty( const std::string &name, const std::string &value )
{
if( name == "texture" )
{
CViewRenderer::getInstance()->deleteTexture( _Texture );
_Texture = CViewRenderer::getInstance()->createTexture( value, 0, 0, 256, 64, false, false );
return;
}
else
if( name == "onchange" )
{
_AHOnChange = value;
}
else
if( name == "onchange_params" )
{
_AHOnChangeParams = value;
return;
}
else
if( name == "dbcolr" )
{
_ColSelR.link( value.c_str() );
return;
}
else
if( name == "dbcolg" )
{
_ColSelG.link( value.c_str() );
return;
}
else
if( name == "dbcolb" )
{
_ColSelB.link( value.c_str() );
return;
}
else
if( name == "dbcola" )
{
_ColSelA.link( value.c_str() );
return;
}
else
CCtrlBase::setProperty( name, value );
}
xmlNodePtr CCtrlColPick::serialize( xmlNodePtr parentNode, const char *type ) const
{
xmlNodePtr node = CCtrlBase::serialize( parentNode, type );
if( node == NULL )
return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "colpick" );
xmlSetProp( node, BAD_CAST "texture",
BAD_CAST CViewRenderer::getInstance()->getTextureNameFromId( _Texture ).c_str() );
xmlSetProp( node, BAD_CAST "onchange", BAD_CAST _AHOnChange.c_str() );
xmlSetProp( node, BAD_CAST "onchange_params", BAD_CAST _AHOnChangeParams.c_str() );
std::string s;
if( _ColSelR.getNodePtr() != NULL )
s = _ColSelR.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolr", BAD_CAST s.c_str() );
if( _ColSelG.getNodePtr() != NULL )
s = _ColSelG.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolg", BAD_CAST s.c_str() );
if( _ColSelB.getNodePtr() != NULL )
s = _ColSelB.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcolb", BAD_CAST s.c_str() );
if( _ColSelA.getNodePtr() != NULL )
s = _ColSelA.getNodePtr()->getFullName();
else
s = "";
xmlSetProp( node, BAD_CAST "dbcola", BAD_CAST s.c_str() );
return node;
}
// ------------------------------------------------------------------------------------------------
bool CCtrlColPick::parse(xmlNodePtr node, CInterfaceGroup * parentGroup)
{
if (!CCtrlBase::parse(node, parentGroup))
return false;
CXMLAutoPtr prop;
// Read textures
prop = (char*) xmlGetProp( node, (xmlChar*)"texture" );
CViewRenderer &rVR = *CViewRenderer::getInstance();
if(prop)
{
string sTmp = NLMISC::strlwr((const char*)prop);
_Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false);
}
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" );
if (prop) _AHOnChange = NLMISC::strlwr(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" );
if (prop) _AHOnChangeParams = string((const char*)prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolr" );
if (prop) _ColSelR.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolg" );
if (prop) _ColSelG.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcolb" );
if (prop) _ColSelB.link(prop);
prop = (char*) xmlGetProp( node, (xmlChar*)"dbcola" );
if (prop) _ColSelA.link(prop);
return true;
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::updateCoords()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 txw, txh;
rVR.getTextureSizeFromId (_Texture, txw, txh);
_W = txw;
_H = txh;
CCtrlBase::updateCoords();
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::draw()
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A);
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
_WReal, _HReal,
0, false,
_Texture,
col );
}
// ------------------------------------------------------------------------------------------------
bool CCtrlColPick::handleEvent (const NLGUI::CEventDescriptor &event)
{
if (CCtrlBase::handleEvent(event)) return true;
if (!_Active)
return false;
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
if ((CWidgetManager::getInstance()->getCapturePointerLeft() != this) &&
(!((eventDesc.getX() >= _XReal) &&
(eventDesc.getX() < (_XReal + _WReal))&&
(eventDesc.getY() > _YReal) &&
(eventDesc.getY() <= (_YReal+ _HReal)))))
return false;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown)
{
_MouseDown = true;
selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal);
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
{
_MouseDown = false;
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mousemove)
{
if (_MouseDown)
{
selectColor(eventDesc.getX()-_XReal, eventDesc.getY()-_YReal);
}
return true;
}
}
return false;
}
// ------------------------------------------------------------------------------------------------
string CCtrlColPick::getColor () const
{
return NLMISC::toString(_ColorSelect.R) + " " + NLMISC::toString(_ColorSelect.G) + " " + NLMISC::toString(_ColorSelect.B) + " " + NLMISC::toString(_ColorSelect.A);
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::setColor (const string &col)
{
_ColorSelect = convertColor (col.c_str());
}
// ------------------------------------------------------------------------------------------------
string CCtrlColPick::getColorOver () const
{
return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A);
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::setColorOver (const string &col)
{
_ColorOver = convertColor (col.c_str());
}
// ------------------------------------------------------------------------------------------------
void CCtrlColPick::selectColor (sint32 x, sint32 y)
{
_ColorSelect = getColor (x, y);
if (_ColSelR.getNodePtr() != NULL)
_ColSelR.setSInt32(_ColorSelect.R);
if (_ColSelG.getNodePtr() != NULL)
_ColSelG.setSInt32(_ColorSelect.G);
if (_ColSelB.getNodePtr() != NULL)
_ColSelB.setSInt32(_ColorSelect.B);
if (_ColSelA.getNodePtr() != NULL)
_ColSelA.setSInt32(_ColorSelect.A);
if (!_AHOnChange.empty())
CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _AHOnChangeParams);
}
// ------------------------------------------------------------------------------------------------
CRGBA CCtrlColPick::getColor (sint32 x, sint32 y)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
if (x < 0) x = 0;
if (y < 0) y = 0;
if (x >= _WReal) x = _WReal-1;
if (y >= _HReal) y = _HReal-1;
return rVR.getTextureColor (_Texture, x, y);
}
}

@ -1,32 +1,32 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_draggable.h"
namespace NLGUI
{
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
{
dragged = false;
draggable = false;
}
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_draggable.h"
namespace NLGUI
{
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
{
dragged = false;
draggable = false;
}
}

@ -1,306 +1,306 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_polygon.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/interface_group.h"
using namespace NLMISC;
namespace NLGUI
{
// *********************************************************************************
CCtrlPolygon::CCtrlPolygon() : CCtrlBase(TCtorParam())
{
// Construct
_Color = CRGBA::White;
//_Matrix = CMatrix::Identity;
_Valid = true;
}
// *********************************************************************************
void CCtrlPolygon::updateBoudingRect()
{
H_AUTO(Rz_CCtrlPolygon_updateBoudingRect)
if (_Poly.Vertices.empty())
{
setX(0);
setY(0);
setW(0);
setH(0);
return;
}
//
sint32 xmin = INT_MAX;
sint32 ymin = INT_MAX;
sint32 xmax = INT_MIN;
sint32 ymax = INT_MIN;
uint numVerts = (uint)_Poly.Vertices.size();
_XFormPoly.Vertices.resize(numVerts);
for(uint k = 0; k < numVerts; ++k)
{
CVector2f &finalPos = _XFormPoly.Vertices[k];
//finalPos = _Matrix * _Poly.Vertices[k];
computeScaledVertex(finalPos, CVector2f(_Poly.Vertices[k].x, _Poly.Vertices[k].y));
xmin = std::min(xmin, (sint32) floorf(finalPos.x));
xmax = std::max(xmax, (sint32) ceilf(finalPos.x));
ymin = std::min(ymin, (sint32) floorf(finalPos.y));
ymax = std::max(ymax, (sint32) ceilf(finalPos.y));
}
setX(xmin);
setY(ymin);
setW(xmax - xmin);
setH(ymax - ymin);
}
// *********************************************************************************
bool CCtrlPolygon::contains(const CVector2f &pos) const
{
H_AUTO(Rz_CCtrlPolygon_contains)
if (!_Valid) return false;
return _XFormPoly.contains(pos, false);
}
// *********************************************************************************
void CCtrlPolygon::setVertices(const std::vector<NLMISC::CVector> &vertices)
{
H_AUTO(Rz_CCtrlPolygon_setVertices)
if (vertices.size() == _Poly.Vertices.size() &&
std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged
//TTicks startTime = CTime::getPerformanceTime();
_Poly.Vertices = vertices;
_Tris.clear();
std::list<CPolygon> polys;
bool splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity);
if (!splitDone)
{
polys.clear();
// maybe wrong orientation
std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end());
splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity);
std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end());
}
_Tris.clear();
if (splitDone)
{
for(std::list<CPolygon>::iterator it = polys.begin(); it != polys.end(); ++it)
{
it->toTriFan(_Tris);
}
}
_Touched = true;
updateBoudingRect();
_Valid = splitDone;
//TTicks endTime = CTime::getPerformanceTime();
//nlinfo("%d ms for CCtrlPolygon::setVertices", (int) (1000 * CTime::ticksToSecond(endTime - startTime)));
}
static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch)
{
return (sint32) maxCorner.x < (cx + cw) &&
(sint32) minCorner.x >= cx &&
(sint32) maxCorner.y < (cy + ch) &&
(sint32) minCorner.y >= cy;
}
static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch)
{
return (sint32) minCorner.x >= (cx + cw) ||
(sint32) maxCorner.x < cx ||
(sint32) minCorner.y >= (cy + ch) ||
(sint32) maxCorner.y < cy;
}
// *********************************************************************************
/*void CCtrlPolygon::setMatrix(const NLMISC::CMatrix &mat)
{
const float *lhs = mat.get();
const float *rhs = _Matrix.get();
if (std::equal(lhs, lhs + 16, rhs)) return; // unmodified...
_Matrix = mat;
updateBoudingRect();
_Touched = true;
}*/
// *********************************************************************************
void CCtrlPolygon::draw()
{
H_AUTO(Rz_CCtrlPolygon_draw)
if (_Tris.empty()) return;
if (!_Parent) return;
CViewRenderer &vr = *CViewRenderer::getInstance();
if (_Touched)
{
_RealTris.clear();
uint numTris = (uint)_Tris.size();
sint32 cornerX, cornerY;
static std::vector<NLMISC::CTriangle> winTris;
winTris.resize(numTris);
_Parent->getCorner(cornerX, cornerY, _ParentPosRef);
/*CMatrix m = _Matrix;
m.setPos(m.getPos() + CVector((float) cornerX, (float) cornerY, 0.f));*/
for(uint k = 0; k < numTris; ++k)
{
/*winTris[k].V0 = m * _Tris[k].V0;
winTris[k].V1 = m * _Tris[k].V1;
winTris[k].V2 = m * _Tris[k].V2;*/
CVector2f result;
computeScaledVertex(result, _Tris[k].V0);
winTris[k].V0.set(result.x + cornerX, result.y + cornerY, 0.f);
computeScaledVertex(result, _Tris[k].V1);
winTris[k].V1.set(result.x + cornerX, result.y + cornerY, 0.f);
computeScaledVertex(result, _Tris[k].V2);
winTris[k].V2.set(result.x + cornerX, result.y + cornerY, 0.f);
}
// recompute & reclip poly
_RealTris.clear();
sint32 cx, cy, cw, ch;
vr.getClipWindow(cx, cy, cw, ch);
// per tri clip
NLMISC::CVector minCorner;
NLMISC::CVector maxCorner;
for(uint k = 0; k < numTris; ++k)
{
winTris[k].getMinCorner(minCorner);
winTris[k].getMaxCorner(maxCorner);
if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue;
if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch))
{
_RealTris.push_back(winTris[k]);
}
else
{
const uint maxNumCorners = 8;
static CVector outPos0[maxNumCorners];
static CVector outPos1[maxNumCorners];
//
outPos0[0] = winTris[k].V0;
outPos0[1] = winTris[k].V1;
outPos0[2] = winTris[k].V2;
//
CVector *pPos0 = outPos0;
CVector *pPos1 = outPos1;
//
sint count = 3;
//
if ((sint32) minCorner.x < cx)
{
// clip left
CPlane clipper(-1.f, 0.f, 0.f, (float) cx);
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
if ((sint32) maxCorner.x > cx + cw)
{
// clip right
CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw));
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
//
if ((sint32) minCorner.y < cy)
{
// clip bottom
CPlane clipper(0.f, -1.f, 0.f, (float) cy);
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
if ((sint32) maxCorner.y > cy + ch)
{
// clip top
CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch));
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
nlassert(count <= 8);
if (count >= 3)
{
for(uint k = 0; k < (uint) (count - 2); ++k)
{
_RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2]));
}
}
}
}
_Touched = false;
}
if (_RealTris.empty()) return;
CRGBA col;
if(getModulateGlobalColor())
{
col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent());
}
else
{
col= _Color;
col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
}
vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col);
}
// *********************************************************************************
void CCtrlPolygon::updateCoords()
{
H_AUTO(Rz_CCtrlPolygon_updateCoords)
CCtrlBase::updateCoords();
updateBoudingRect();
// assume that clipping will have to be done again, real update of triangle will be done at render time
_Touched = true;
}
// *********************************************************************************
void CCtrlPolygon::setAlpha(sint32 a)
{
H_AUTO(Rz_CCtrlPolygon_setAlpha)
_Color.A = (uint8) a;
}
// *********************************************************************************
bool CCtrlPolygon::handleEvent(const NLGUI::CEventDescriptor &/* event */)
{
H_AUTO(Rz_CCtrlPolygon_handleEvent)
return false;
}
// *********************************************************************************
// TMP TMP
void CCtrlPolygon::computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src)
{
H_AUTO(Rz_CCtrlPolygon_computeScaledVertex)
dest.set(src.x, src.y);
}
// *********************************************************************************
// TMP TMP
void CCtrlPolygon::touch()
{
H_AUTO(Rz_CCtrlPolygon_touch)
updateBoudingRect();
_Touched = true;
}
}
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_polygon.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/interface_group.h"
using namespace NLMISC;
namespace NLGUI
{
// *********************************************************************************
CCtrlPolygon::CCtrlPolygon() : CCtrlBase(TCtorParam())
{
// Construct
_Color = CRGBA::White;
//_Matrix = CMatrix::Identity;
_Valid = true;
}
// *********************************************************************************
void CCtrlPolygon::updateBoudingRect()
{
H_AUTO(Rz_CCtrlPolygon_updateBoudingRect)
if (_Poly.Vertices.empty())
{
setX(0);
setY(0);
setW(0);
setH(0);
return;
}
//
sint32 xmin = INT_MAX;
sint32 ymin = INT_MAX;
sint32 xmax = INT_MIN;
sint32 ymax = INT_MIN;
uint numVerts = (uint)_Poly.Vertices.size();
_XFormPoly.Vertices.resize(numVerts);
for(uint k = 0; k < numVerts; ++k)
{
CVector2f &finalPos = _XFormPoly.Vertices[k];
//finalPos = _Matrix * _Poly.Vertices[k];
computeScaledVertex(finalPos, CVector2f(_Poly.Vertices[k].x, _Poly.Vertices[k].y));
xmin = std::min(xmin, (sint32) floorf(finalPos.x));
xmax = std::max(xmax, (sint32) ceilf(finalPos.x));
ymin = std::min(ymin, (sint32) floorf(finalPos.y));
ymax = std::max(ymax, (sint32) ceilf(finalPos.y));
}
setX(xmin);
setY(ymin);
setW(xmax - xmin);
setH(ymax - ymin);
}
// *********************************************************************************
bool CCtrlPolygon::contains(const CVector2f &pos) const
{
H_AUTO(Rz_CCtrlPolygon_contains)
if (!_Valid) return false;
return _XFormPoly.contains(pos, false);
}
// *********************************************************************************
void CCtrlPolygon::setVertices(const std::vector<NLMISC::CVector> &vertices)
{
H_AUTO(Rz_CCtrlPolygon_setVertices)
if (vertices.size() == _Poly.Vertices.size() &&
std::equal(vertices.begin(), vertices.end(), _Poly.Vertices.begin())) return; // remains unchanged
//TTicks startTime = CTime::getPerformanceTime();
_Poly.Vertices = vertices;
_Tris.clear();
std::list<CPolygon> polys;
bool splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity);
if (!splitDone)
{
polys.clear();
// maybe wrong orientation
std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end());
splitDone = _Poly.toConvexPolygons(polys, NLMISC::CMatrix::Identity);
std::reverse(_Poly.Vertices.begin(), _Poly.Vertices.end());
}
_Tris.clear();
if (splitDone)
{
for(std::list<CPolygon>::iterator it = polys.begin(); it != polys.end(); ++it)
{
it->toTriFan(_Tris);
}
}
_Touched = true;
updateBoudingRect();
_Valid = splitDone;
//TTicks endTime = CTime::getPerformanceTime();
//nlinfo("%d ms for CCtrlPolygon::setVertices", (int) (1000 * CTime::ticksToSecond(endTime - startTime)));
}
static inline bool totallyInside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch)
{
return (sint32) maxCorner.x < (cx + cw) &&
(sint32) minCorner.x >= cx &&
(sint32) maxCorner.y < (cy + ch) &&
(sint32) minCorner.y >= cy;
}
static inline bool totallyOutside(const CVector &minCorner, const CVector &maxCorner, sint32 cx, sint32 cy, sint32 cw, sint32 ch)
{
return (sint32) minCorner.x >= (cx + cw) ||
(sint32) maxCorner.x < cx ||
(sint32) minCorner.y >= (cy + ch) ||
(sint32) maxCorner.y < cy;
}
// *********************************************************************************
/*void CCtrlPolygon::setMatrix(const NLMISC::CMatrix &mat)
{
const float *lhs = mat.get();
const float *rhs = _Matrix.get();
if (std::equal(lhs, lhs + 16, rhs)) return; // unmodified...
_Matrix = mat;
updateBoudingRect();
_Touched = true;
}*/
// *********************************************************************************
void CCtrlPolygon::draw()
{
H_AUTO(Rz_CCtrlPolygon_draw)
if (_Tris.empty()) return;
if (!_Parent) return;
CViewRenderer &vr = *CViewRenderer::getInstance();
if (_Touched)
{
_RealTris.clear();
uint numTris = (uint)_Tris.size();
sint32 cornerX, cornerY;
static std::vector<NLMISC::CTriangle> winTris;
winTris.resize(numTris);
_Parent->getCorner(cornerX, cornerY, _ParentPosRef);
/*CMatrix m = _Matrix;
m.setPos(m.getPos() + CVector((float) cornerX, (float) cornerY, 0.f));*/
for(uint k = 0; k < numTris; ++k)
{
/*winTris[k].V0 = m * _Tris[k].V0;
winTris[k].V1 = m * _Tris[k].V1;
winTris[k].V2 = m * _Tris[k].V2;*/
CVector2f result;
computeScaledVertex(result, _Tris[k].V0);
winTris[k].V0.set(result.x + cornerX, result.y + cornerY, 0.f);
computeScaledVertex(result, _Tris[k].V1);
winTris[k].V1.set(result.x + cornerX, result.y + cornerY, 0.f);
computeScaledVertex(result, _Tris[k].V2);
winTris[k].V2.set(result.x + cornerX, result.y + cornerY, 0.f);
}
// recompute & reclip poly
_RealTris.clear();
sint32 cx, cy, cw, ch;
vr.getClipWindow(cx, cy, cw, ch);
// per tri clip
NLMISC::CVector minCorner;
NLMISC::CVector maxCorner;
for(uint k = 0; k < numTris; ++k)
{
winTris[k].getMinCorner(minCorner);
winTris[k].getMaxCorner(maxCorner);
if (totallyOutside(minCorner, maxCorner, cx, cy, cw, ch)) continue;
if (totallyInside(minCorner, maxCorner, cx, cy, cw, ch))
{
_RealTris.push_back(winTris[k]);
}
else
{
const uint maxNumCorners = 8;
static CVector outPos0[maxNumCorners];
static CVector outPos1[maxNumCorners];
//
outPos0[0] = winTris[k].V0;
outPos0[1] = winTris[k].V1;
outPos0[2] = winTris[k].V2;
//
CVector *pPos0 = outPos0;
CVector *pPos1 = outPos1;
//
sint count = 3;
//
if ((sint32) minCorner.x < cx)
{
// clip left
CPlane clipper(-1.f, 0.f, 0.f, (float) cx);
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
if ((sint32) maxCorner.x > cx + cw)
{
// clip right
CPlane clipper(1.f, 0.f, 0.f, - (float) (cx + cw));
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
//
if ((sint32) minCorner.y < cy)
{
// clip bottom
CPlane clipper(0.f, -1.f, 0.f, (float) cy);
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
if ((sint32) maxCorner.y > cy + ch)
{
// clip top
CPlane clipper(0.f, 1.f, 0.f, - (float) (cy + ch));
count = clipper.clipPolygonBack(pPos0, pPos1, count);
std::swap(pPos0, pPos1);
}
nlassert(count <= 8);
if (count >= 3)
{
for(uint k = 0; k < (uint) (count - 2); ++k)
{
_RealTris.push_back(NLMISC::CTriangle(pPos0[0], pPos0[k + 1], pPos0[k + 2]));
}
}
}
}
_Touched = false;
}
if (_RealTris.empty()) return;
CRGBA col;
if(getModulateGlobalColor())
{
col.modulateFromColor (_Color, CWidgetManager::getInstance()->getGlobalColorForContent());
}
else
{
col= _Color;
col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
}
vr.drawUnclippedTriangles(_RenderLayer, _RealTris, col);
}
// *********************************************************************************
void CCtrlPolygon::updateCoords()
{
H_AUTO(Rz_CCtrlPolygon_updateCoords)
CCtrlBase::updateCoords();
updateBoudingRect();
// assume that clipping will have to be done again, real update of triangle will be done at render time
_Touched = true;
}
// *********************************************************************************
void CCtrlPolygon::setAlpha(sint32 a)
{
H_AUTO(Rz_CCtrlPolygon_setAlpha)
_Color.A = (uint8) a;
}
// *********************************************************************************
bool CCtrlPolygon::handleEvent(const NLGUI::CEventDescriptor &/* event */)
{
H_AUTO(Rz_CCtrlPolygon_handleEvent)
return false;
}
// *********************************************************************************
// TMP TMP
void CCtrlPolygon::computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src)
{
H_AUTO(Rz_CCtrlPolygon_computeScaledVertex)
dest.set(src.x, src.y);
}
// *********************************************************************************
// TMP TMP
void CCtrlPolygon::touch()
{
H_AUTO(Rz_CCtrlPolygon_touch)
updateBoudingRect();
_Touched = true;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save