merge from default

--HG--
branch : gsoc2012-achievements
hg/feature/gsoc2013-dfighter
SirCotare 12 years ago
commit 3cf378c5e7

@ -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

@ -293,6 +293,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
###
OPTION(WITH_NET "Build NLNET" ON )
OPTION(WITH_3D "Build NL3D" ON )
OPTION(WITH_GUI "Build GUI" ON )
OPTION(WITH_PACS "Build NLPACS" ON )
OPTION(WITH_GEORGES "Build NLGEORGES" ON )
OPTION(WITH_LIGO "Build NLLIGO" ON )

@ -71,7 +71,7 @@ public:
// For clipTrav. cleared at beginning of CClipTrav::traverse
void clearVisibleList();
// For ClipTrav only. NB: list is cleared at begining of traverse(). NB: only CTransform are supported
// For ClipTrav only. NB: list is cleared at begininng of traverse(). NB: only CTransform are supported
void addVisibleModel(CTransform *model)
{
_VisibleList[_CurrentNumVisibleModels]= model;

@ -68,7 +68,7 @@ public:
class CCamera : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -93,7 +93,7 @@ public:
/// \name Visible List mgt. Those visible models are updated each traverse().
//@{
// NB: list is cleared at begining of traverse().
// NB: list is cleared at beginning of traverse().
void addVisibleModel(CTransform *model)
{
model->_IndexInVisibleList= _CurrentNumVisibleModels;

@ -81,14 +81,14 @@ class IDriver;
class CLandscapeGlobals
{
public:
// LANDSCAPE RENDERING CONTEXT. Landscape must setup it at the begining at refine()/render().
// LANDSCAPE RENDERING CONTEXT. Landscape must setup it at the beginning at refine()/render().
// The current date of LandScape for refine only.
static sint CurrentDate;
// The current date of LandScape for render only.
static sint CurrentRenderDate;
// The center view for refinement.
static CVector RefineCenter;
// What is the treshold for tessellation.
// What is the threshold for tessellation.
static float RefineThreshold;
// Guess.
static float OORefineThreshold;
@ -143,7 +143,7 @@ public:
static CLandscapeVBAllocator *CurrentTileVBAllocator;
// PATCH GLOBAL INTERFACE. patch must setup them at the begining at refine()/render().
// PATCH GLOBAL INTERFACE. patch must setup them at the beginning at refine()/render().
// NO!!! REMIND: can't have any patch global, since a propagated split()/updateErrorMetric()
// can arise. must use Patch pointer.

@ -42,7 +42,7 @@ const NLMISC::CClassId LandscapeModelId=NLMISC::CClassId(0x5a573b55, 0x6b395829
class CLandscapeModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -165,7 +165,7 @@ public:
// For clipTrav. cleared at beginning of CClipTrav::traverse
void clearVisibleList();
// For ClipTrav only. NB: list is cleared at begining of traverse().
// For ClipTrav only. NB: list is cleared at beginning of traverse().
void addVisibleModel(CTransform *model)
{
_VisibleList[_CurrentNumVisibleModels]= model;

@ -53,7 +53,7 @@ const NLMISC::CClassId MeshBaseInstanceId=NLMISC::CClassId(0xef44331, 0x739f6bc
class CMeshBaseInstance : public CTransformShape
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshInstanceId=NLMISC::CClassId(0x6bfe0a34, 0x23b26dc9);
class CMeshInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshMRMInstanceId=NLMISC::CClassId(0xec608f3, 0x1111c33)
class CMeshMRMInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
protected:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshMRMSkinnedInstanceId=NLMISC::CClassId(0x6cfd2619, 0x
class CMeshMRMSkinnedInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
protected:

@ -61,7 +61,7 @@ public:
Lod0Blend = 0x1,
};
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// Last Matrix date for Lods

@ -29,7 +29,7 @@ namespace NL3D {
/**
* This vertex program is used to perform perpixel lighting with meshs. Its ouputs are :
* This vertex program is used to perform perpixel lighting with meshs. Its outputs are :
*
* Coord Tex 0 : duplicate the tex Coord 0 set from the v.b.
* Coord Tex 1 : The light vector in tangent space.

@ -808,7 +808,7 @@ private:
CTessFarVertex BaseFarVertices[4];
// Local info for CTessFace tiles. CPatch must setup them at the begining at refine()/render().
// Local info for CTessFace tiles. CPatch must setup them at the beginning at refine()/render().
// For Far Texture coordinates.
float Far0UScale, Far0VScale, Far0UBias, Far0VBias;
float Far1UScale, Far1VScale, Far1UBias, Far1VBias;

@ -55,7 +55,7 @@ const NLMISC::CClassId PointLightModelId=NLMISC::CClassId(0x7e842eba, 0x140b6c6
class CPointLightModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -29,7 +29,7 @@ namespace NL3D {
/*
* In this file, we define several template that helps to create attributes maker such as gradient (of float, int, vector etc)
* attributes maker are used in the particle system to generate values, such as size, color etc. see ps_attrib_maker.h
* for more informations
* for more information
*/

@ -55,7 +55,7 @@ const NLMISC::CClassId QuadGridClipManagerId=NLMISC::CClassId(0x1ffb079a, 0x6c5
class CQuadGridClipManager : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -227,7 +227,7 @@ public:
enum {MaxVPLight= 4};
/** reset the lighting setup in the driver (all lights are disabled).
* called at begining of traverse(). Must be called by any model (before and after rendering)
* called at beginning of traverse(). Must be called by any model (before and after rendering)
* that wish to use CDriver::setLight() instead of the standard behavior with changeLightSetup()
*/
void resetLightSetup();

@ -39,7 +39,7 @@ const NLMISC::CClassId RootModelId=NLMISC::CClassId(0x25f0505d, 0x75c69f9);
class CRootModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -54,7 +54,7 @@ public:
CSegRemanence(CSegRemanence &other);
CSegRemanence &operator = (CSegRemanence &other);
//@}
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// to instanciate that model from a scene
static CTransform *creator() { return new CSegRemanence; }

@ -79,7 +79,7 @@ public:
/// max number of bones supported in skeleton
enum { MaxNumBones = 256 };
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -90,7 +90,7 @@ const NLMISC::CClassId TransformId=NLMISC::CClassId(0x174750cb, 0xf952024);
class CTransform : public ITransformable
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// get the scene which has created us
@ -113,7 +113,7 @@ public:
/**
* Extra init for a model. this method is called by the framework at the very end of CScene::createModel()
* Warning! if the model is a CTransformShape, then when initModel() is called, Shape and other related member/setup
* of IShape::createInstance() are not yet done (because createModel() is called at the begining in createInstance()).
* of IShape::createInstance() are not yet done (because createModel() is called at the beginning in createInstance()).
*
* Because initModel() is called at the very end, deriver could implement anything like creating other models,
* but not deleting this model...

@ -55,7 +55,7 @@ const NLMISC::CClassId TransformShapeId=NLMISC::CClassId(0x1e6115e6, 0x63502517
class CTransformShape : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -48,7 +48,7 @@ const NLMISC::CClassId VegetableBlendLayerModelId=NLMISC::CClassId(0x77375163,
class CVegetableBlendLayerModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -188,7 +188,7 @@ public:
* \warning: Only syntax is checked. It doesn't check that a register has been initialised before use.
* \param src The input text of a vertex program, in OpenGL format.
* \param result The result program.
* \param errorOuput If parsing failed, contains the reason
* \param errorOutput If parsing failed, contains the reason
* \result true if the parsing succeeded
*/
bool parse(const char *src, TProgram &result, std::string &errorOutput);

@ -4,6 +4,10 @@ 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)

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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -19,35 +19,41 @@
#ifndef RZ_CTRL_TOOLTIP_H
#define RZ_CTRL_TOOLTIP_H
#include "ctrl_base.h"
#include "nel/gui/ctrl_base.h"
#include "nel/3d/u_texture.h"
class CEventDescriptor;
class CInterfaceManager;
/**
* \author Matthieu 'Mr TRAP' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlToolTip : public CCtrlBase
namespace NLGUI
{
public:
DECLARE_UI_CLASS(CCtrlToolTip)
/// Constructor
CCtrlToolTip(const TCtorParam &param) : CCtrlBase(param) {}
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 CEventDescriptor& eventDesc);
virtual void draw();
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:
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 */

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -20,7 +20,10 @@
#define RZ_EVENT_DESCRIPTOR_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CEventDescriptor
@ -247,6 +250,8 @@ protected:
bool _HasFocus;
};
}
#endif // RZ_EVENT_DESCRIPTOR_H
/* End of event_descriptor.h */

@ -15,28 +15,30 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef EVENT_LISTENER
#define EVENT_LISTENER
#ifndef RZ_GROUP_CONTAINER_H
#define RZ_GROUP_CONTAINER_H
#include "nel/misc/event_listener.h"
#include "nel/gui/input_handler.h"
#include "interface_group.h"
// Special group to handle the mouse wheel message
class CInterfaceGroupWheel : public CInterfaceGroup
namespace NLGUI
{
public:
/// Constructor
CInterfaceGroupWheel(const TCtorParam &param);
/// Coming from CInterfaceElement
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual bool handleEvent (const CEventDescriptor &event);
private:
IActionHandler *_AHWheelUp;
CStringShared _AHWheelUpParams;
IActionHandler *_AHWheelDown;
CStringShared _AHWheelDownParams;
};
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

@ -0,0 +1,661 @@
// 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"
#include "nel/gui/group_container_base.h"
#include "nel/misc/smart_ptr.h"
namespace NLGUI
{
class CEventDescriptorLocalised;
class CCtrlButton;
class CCtrlScroll;
class CViewText;
class CViewBitmap;
class CGroupList;
class COptionsContainerInsertion;
class COptionsContainerMove;
class COptionsLayer;
class CGroupContainer;
// ***************************************************************************
/**
* class describing a resizer for the container
* \author Matthieu 'TrapII' Besson
* \date 2003
*/
class CCtrlResizer : public CCtrlBase
{
public:
CCtrlResizer(const TCtorParam &param);
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// Add a big delta so when the user is over the Resizer, always take it whatever other controls under
virtual uint getDeltaDepth() const { return 100; }
// get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded
// if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded
THotSpot getRealResizerPos() const;
THotSpot getResizerPos() const { return _ResizerPos; }
void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; }
bool IsMaxH; // Do this resizer is a MaxH resizer ?
// Max sizes for the parent
sint32 WMin, WMax;
sint32 HMin, HMax;
// from CCtrlBase
virtual bool canChangeVirtualDesktop() const { return !_MouseDown; }
private:
sint32 resizeW (sint32 dx);
sint32 resizeH (sint32 dy);
private:
THotSpot _ResizerPos; // how the resizer should resize its parent
bool _MouseDown;
sint32 _MouseDownX;
sint32 _MouseDownY;
sint32 _XBias;
sint32 _YBias;
};
// ***************************************************************************
/**
* Class describing a Mover for the container
* Clicking on it can also open the container
* This can be used to move a container if it is movable.
* If the container is popable, it will first pull it of the hierarchy, then it becomes movable.
* It can also be used to change the position of a group container that is inserted in the list of another container.
* \author Lionel Berenguier
* \date 2003
*/
class CCtrlMover : public CCtrlBase
{
public:
CCtrlMover(const TCtorParam &param, bool canMove, bool canOpen);
~CCtrlMover();
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
bool canMove() { return _CanMove; }
bool isMoving() const {return _Moving;}
bool isMovingInParentList() const { return _MovingInParentList; }
// from CCtrlBase
virtual bool canChangeVirtualDesktop() const { return !_Moving; }
private:
sint32 _MoveStartX, _MoveStartY;
sint32 _MoveDeltaXReal, _MoveDeltaYReal;
sint64 _ScrollTime;
sint32 _StartIndex;
sint32 _InsertionIndex;
// clip window from parent list
sint32 _ParentListTop;
sint32 _ParentListBottom;
//
sint64 _WaitToOpenCloseDate;
//
bool _CanMove : 1;
bool _CanOpen : 1;
bool _Moving : 1;
bool _MovingInParentList : 1;
bool _HasMoved : 1;
bool _ParentScrollingUp : 1;
bool _ParentScrollingDown : 1;
bool _StopScrolling : 1; // stop scrolling at next draw
bool _WaitToOpenClose : 1;
//
static COptionsContainerInsertion *getInsertionOptions();
private:
void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
void updateInsertionIndex(const CGroupList *gl, sint32 posY);
void stopMove();
bool runTitleActionHandler();
void handleScrolling();
};
// ***************************************************************************
/**
* class describing a group of views controls and other groups
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupContainer : public CGroupContainerBase
{
public:
enum { NumResizers = 8 };
public:
// observer to know when children have moved. This can be used to keep external datas in sync
struct IChildrenObs
{
virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0;
};
public:
CGroupContainer(const TCtorParam &param);
~CGroupContainer();
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 serializeTreeData( xmlNodePtr parentNode ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual void launch ();
virtual void setActive (bool state);
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);
void open();
void close();
void setup(); // Create the container
/** If insertion order is -1, pIC is added at the end of the container
* otherwise it is inserted after containers of a lower order
*/
void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1);
// Insert a container at the given index.
bool attachContainerAtIndex(CGroupContainer *pIC, uint index);
// Before a container is detached from parent, it should be pop in
void detachContainer (CGroupContainer *pIC);
void removeAllContainers();
void setOpen(bool opened)
{
if (opened)
{
open();
}
else
{
close();
}
}
bool isOpen() const { return _Opened; }
// Force Open for container setActive and open()
virtual void forceOpen();
/// Set the title open and close
virtual bool isMovable() const {return _Movable;}
void setMovable(bool b);
void setContent (CInterfaceGroup *pC);
std::string getTitle () const;
void setTitle (const std::string &title);
std::string getTitleOpened () const;
void setTitleOpened (const std::string &title);
std::string getTitleClosed () const;
void setTitleClosed (const std::string &title);
std::string getTitleColorAsString() const;
void setTitleColorAsString(const std::string &col);
void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); }
// Get the header color draw. NB: depends if grayed, and if active.
NLMISC::CRGBA getDrawnHeaderColor () const;
ucstring getUCTitleOpened () const;
void setUCTitleOpened (const ucstring &title);
ucstring getUCTitleClosed () const;
void setUCTitleClosed (const ucstring &title);
ucstring getUCTitle () const;
void setUCTitle (const ucstring &title);
void setPopable(bool popable) { _Popable = popable; }
bool isPopable() const { return _Popable; }
bool isPopuped() const { return _Poped; }
void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; }
bool isMovableInParentList() const { return _MovableInParentList; }
// high light the border of the container
void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; }
bool isHighLighted() const { return _HighLighted; }
// y offset for content of container
sint32 getContentYOffset() const { return (sint32) _ContentYOffset; }
void setContentYOffset(sint32 value);
// Window requires attention
void requireAttention();
// Lua exports
int luaBlink(CLuaState &ls);
int luaSetHeaderColor(CLuaState &ls);
REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase)
REFLECT_LUA_METHOD("blink", luaBlink);
REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor);
REFLECT_STRING("title", getTitle, setTitle);
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened);
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed);
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle);
REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString);
REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH);
REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH);
REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW);
REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW);
REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW);
REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset);
REFLECT_BOOL("openable", isOpenable, setOpenable);
REFLECT_BOOL("opened", isOpen, setOpen);
REFLECT_BOOL("lockable", isLockable, setLockable);
REFLECT_BOOL("locked", isLocked, setLocked);
REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive);
REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled);
REFLECT_EXPORT_END
sint32 getLayerSetup() const { return _LayerSetup; }
// if this window is popable, pop it at its actual position
void popupCurrentPos();
// Popup at previous memorized position
void popup();
/** Popin the window and possibly put it back in its father container, using the order defined in the list of the container.
* \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL)
* \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list
*/
void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true);
// get the mover control associated with that control, or NULL if none
CCtrlMover *getCtrlMover() const { return _Mover; }
// true if there is a mover and if the window is being moved
bool isMoving() const { return _Mover && _Mover->isMoving(); }
/** Force the container to blink (to tell the user that an event has happened).
* This uses the global color, so the container must use it
* This state is automatically disabled if the container is opened
* \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise
*/
virtual void enableBlink(uint numBlinks = 0);
virtual void disableBlink();
virtual bool isBlinking() const { return _Blinking; }
CGroupList *getList() const { return _List; }
CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; }
CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; }
CInterfaceGroup *getContent() const { return _Content; }
void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; }
IChildrenObs *getChildrenObs() const { return _ChildrenObs; }
// Get current father container (if any).
CGroupContainer *getFatherContainer() const;
// Get current father container (if any). If the container is popup, it gives the proprietary container
CGroupContainer *getProprietaryContainer() const;
bool isOpenable() const { return _Openable; }
void setOpenable(bool openable);
bool getHeaderActive() const { return _HeaderActive; }
void setHeaderActive(bool active) { _HeaderActive = active; }
bool getRightButtonEnabled() const { return _EnabledRightButton; }
void setRightButtonEnabled(bool enabled);
CCtrlScroll *getScroll() const { return _ScrollBar; }
bool isSavable() const { return _Savable; }
void setSavable(bool savable) { _Savable = savable; }
bool isActiveSavable() const { return _ActiveSavable; }
bool isLocalize() const { return _Localize; }
void setLocalize(bool localize) { _Localize = localize; }
void setPopupX(sint32 x) { _PopupX = x; }
void setPopupY(sint32 y) { _PopupY = y; }
void setPopupW(sint32 w) { _PopupW = w; }
void setPopupH(sint32 h) { _PopupH = h; }
sint32 getPopupX() const { return _PopupX; }
sint32 getPopupY() const { return _PopupY; }
sint32 getPopupW() const { return _PopupW; }
sint32 getPopupH() const { return _PopupH; }
sint32 getRefW() const { return _RefW; }
/** Increase the rollover alpha for the current frame.
* Example of use : an edit box that has focus in a group container
*/
void rollOverAlphaUp();
// force the rollover alpha to its max value, depending on there's keyboard focus or not
void forceRolloverAlpha();
bool isOpenWhenPopup() const { return _OpenWhenPopup; }
/// Locking of window (prevent it from being moved)
void setLockable(bool lockable);
bool isLockable() const { return _Lockable; }
void setLocked(bool locked);
// to be called by the 'deactive check' handler
static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; }
const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); }
const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; }
//
const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); }
const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; }
//
IActionHandler *getAHOnMovePtr() const { return _AHOnMove; }
const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); }
const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; }
//
IActionHandler *getAHOnResizePtr() const { return _AHOnResize; }
const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); }
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
//
IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; }
const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); }
const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; }
//
void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); }
void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; }
void setModalParentList (const std::string &name);
bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window)
bool isGrayed() const;
bool blinkAllSons();
// true if the resizer is enabled.
bool getEnabledResizer() const {return _EnabledResizer;}
sint32 getPopupMinW() const {return _PopupMinW;}
sint32 getPopupMaxW() const {return _PopupMaxW;}
sint32 getPopupMinH() const {return _PopupMinH;}
sint32 getPopupMaxH() const {return _PopupMaxH;}
sint32 getMinW() const {return _MinW;}
void setMinW(sint32 minW) { _MinW = minW;}
void setMaxW(sint32 maxW) { _MaxW = maxW;}
sint32 getMaxW() const {return _MaxW;}
void setPopupMinW(sint32 minW);
void setPopupMaxW(sint32 maxW);
void setPopupMinH(sint32 minW);
void setPopupMaxH(sint32 maxW);
// backup the current position of this container
void backupPosition();
// restore the current position of this container
void restorePosition();
// get x for backup position
sint32 getBackupX() const { return _BackupX; }
sint32 getBackupY() const { return _BackupY; }
// Set backup position
void setBackupPosition(sint32 x, sint32 y);
// clear backup
void clearBackup() { _PositionBackuped = false; }
// Test if position has been backuped (flag cleared by 'restorePosition()')
bool isPositionBackuped() const { return _PositionBackuped; }
// check if the container has been moved, resized, or popuped by the user (and eventually clear that flag)
bool getTouchFlag(bool clearFlag) const;
// from CInterfaceGroup
virtual void restoreAllContainersBackupPosition() { restorePosition(); }
// when isModal() is true, the whole interface cannot switch desktop
bool isModal() const { return _Modal; }
void setModal(bool modal) { _Modal = modal; }
// return true if the container has a modal parent window setuped => the whole interface cannot switch desktop
bool isModalSon() const { return !_ModalParents.empty(); }
// return the help web page of this container. "" if none
const std::string &getHelpPage() const { return _HelpPage; }
// set the help web page of this container. "" if none. NB: the help button is not updated
void setHelpPage(const std::string &newPage);
void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; }
sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; }
protected:
uint8 _ICurrentRolloverAlphaContainer;
uint8 _HighLightedAlpha;
float _CurrentRolloverAlphaContainer;
float _CurrentRolloverAlphaContent;
sint32 _LayerSetup;
ucstring _TitleTextOpened;
ucstring _TitleTextClosed;
CViewText *_TitleOpened;
CViewText *_TitleClosed;
sint32 _TitleDeltaMaxW;
CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable)
CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin
CCtrlButton *_HelpButton; // Help button
CGroupList *_List;
CCtrlScroll *_ScrollBar;
CGroupContainer *_OldFatherContainer;
// NB: _ModalParentNames is a list of modal parent, separated by '|'
std::string _ModalParentNames; // Modal handling between container (container can be linked together,
std::vector<CGroupContainer*> _ModalSons; // when the son is active the parent is not active
std::vector<CGroupContainer*> _ModalParents; // (but the rest of the interface is))
uint _InsertionOrder;
uint _BlinkDT;
uint _NumBlinks;
CInterfaceGroup *_Content; // Read From Script
CInterfaceGroup *_HeaderOpened; // Read From Script
CInterfaceGroup *_HeaderClosed; // Read From Script
CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available
//
CCtrlMover *_Mover;
IChildrenObs *_Obs;
// If layer==0 constraint on resize
sint32 _PopupMinW;
sint32 _PopupMaxW;
sint32 _PopupMinH;
sint32 _PopupMaxH;
// If layer>0 constraint on resize
sint32 _MinW;
sint32 _MaxW;
// backuped position
sint32 _BackupX;
sint32 _BackupY;
// old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet
sint32 _PopupX;
sint32 _PopupY;
sint32 _PopupW;
sint32 _PopupH;
//
sint32 _RefW;
sint32 _MoverDeltaW;
// action handler
IActionHandler *_AHOnOpen;
CStringShared _AHOnOpenParams;
IActionHandler *_AHOnClose;
CStringShared _AHOnCloseParams;
IActionHandler *_AHOnCloseButton;
CStringShared _AHOnCloseButtonParams;
IActionHandler *_AHOnMove;
CStringShared _AHOnMoveParams;
IActionHandler *_AHOnResize;
CStringShared _AHOnResizeParams;
IActionHandler *_AHOnBeginMove;
CStringShared _AHOnBeginMoveParams;
// action handler to test whether the windows can be deactivated (when the close button is pressed)
IActionHandler *_AHOnDeactiveCheck;
CStringShared _AHOnDeactiveCheckParams;
// Observer to know when children have moved
IChildrenObs *_ChildrenObs;
// list of container that are poped up
std::vector<CGroupContainer *> _PopedCont;
// Open management
bool _Openable : 1; // Is the container can be manually opened or closed ?
bool _Opened : 1; // Is the container currently opened or closed ?
bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0)
// and close when poped in...
bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start
bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0)
// Move management
bool _Movable : 1; // Is the container movable ?
bool _MovableInParentList: 1;
bool _Lockable : 1;
bool _MovingInParentList : 1; // Mgt : currently moving ?
// Pop up / pop in
bool _Popable : 1;
bool _Poped : 1;
bool _EnabledResizer : 1;
bool _HighLighted : 1;
bool _Blinking : 1;
bool _BlinkState : 1;
bool _Savable : 1;
bool _ActiveSavable : 1;
// Display title background or not
bool _HeaderActive : 1;
bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ?
//
enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString};
uint8 _TitleClass : 2;
//
mutable bool _TouchFlag : 1;
bool _PositionBackuped : 1;
bool _Modal : 1; // the container is modal and prevent from switching virtual desktop
//
bool _EnabledHelpButton : 1; // Is the Button Help is enabled ?
//
bool _TitleOverExtendViewText : 1; // Does the title over extend view text
bool _Localize : 1;
CInterfaceProperty _HeaderColor;
sint8 _ContentYOffset;
// Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value
sint8 _ResizerTopSize;
uint8 _ICurrentRolloverAlphaContent;
static bool _ValidateCanDeactivate;
CStringShared _OptionsName;
// Web Page used for help
CStringShared _HelpPage;
private:
sint32 getLayer();
void updateResizerSize(CCtrlResizer *cr);
void updateRightButton();
void updateHelpButton();
void updateMover();
void updateViewOpenState();
void updateTitle();
void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH);
void createResizerMaxH();
void removeResizerMaxH();
TTileClass convertTitleClass(const char *ptr);
static COptionsContainerMove *getMoveOptions();
COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used
bool hasKeyboardFocus() const;
// private for modal system
void addModalParent (CGroupContainer *pParent);
void addModalSon (CGroupContainer *pSon);
// Avoid each frame setup layer0, layer1 etc...
enum {NumLayerName=10};
static const std::string _OptionLayerName[NumLayerName];
public:
// for use by CCtrlMover
// Tell that this group is moving in its parent list
void setMovingInParentList(bool enable);
CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; }
CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; }
CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; }
// set the 'hasMoved' flag
void touch(bool touched = true) { _TouchFlag = touched; }
friend class CICDeactive;
};
}
#endif // RZ_INTERFACE_CONTAINER_H
/* End of interface_container.h */

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +1,669 @@
// 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_HTML_H
#define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_scrolltext.h"
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
typedef std::map<std::string, std::string> TStyle;
extern "C"
{
#include "libwww/WWWInit.h"
}
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
class CGroupList;
class CDBGroupComboBox;
class CGroupParagraph;
// HTML group
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Cyril 'Hulud' Corvazier
* \author Nevrax France
* \date 2002
*/
class CGroupHTML : public CGroupScrollText
{
public:
friend void TextAdd (struct _HText *me, const char * buf, int len);
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
friend void TextEndElement (_HText *me, int element_number);
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
friend void TextBuild (HText * me, HTextStatus status);
friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length);
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
/// Web browser options for CGroupHTML
struct SWebOptions
{
public:
/// Id of the browser ( e.g.: Chrome, Firefox, Ryzom )
std::string appName;
/// Version of the browser
std::string appVersion;
/// Language code of the browser( e.g.: en, hu )
std::string languageCode;
/// List of domains the widget can consider secure.
std::vector< std::string > trustedDomains;
SWebOptions()
{
}
};
static SWebOptions options;
// Constructor
CGroupHTML(const TCtorParam &param);
~CGroupHTML();
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 draw ();
// Events
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
// Browse
virtual void browse (const char *url);
// Refresh
void refresh();
// submit form
void submitForm (uint formId, const char *submitButtonName);
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
// New paragraph
void newParagraph(uint beginSpace);
// End of the paragraph
void endParagraph();
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
float getTimeout() const {return (float)_TimeoutValue;}
// Some constants
NLMISC::CRGBA BgColor;
NLMISC::CRGBA ErrorColor;
NLMISC::CRGBA LinkColor;
NLMISC::CRGBA TextColor;
NLMISC::CRGBA H1Color;
NLMISC::CRGBA H2Color;
NLMISC::CRGBA H3Color;
NLMISC::CRGBA H4Color;
NLMISC::CRGBA H5Color;
NLMISC::CRGBA H6Color;
bool ErrorColorGlobalColor;
bool LinkColorGlobalColor;
bool TextColorGlobalColor;
bool H1ColorGlobalColor;
bool H2ColorGlobalColor;
bool H3ColorGlobalColor;
bool H4ColorGlobalColor;
bool H5ColorGlobalColor;
bool H6ColorGlobalColor;
uint TextFontSize;
uint H1FontSize;
uint H2FontSize;
uint H3FontSize;
uint H4FontSize;
uint H5FontSize;
uint H6FontSize;
uint TDBeginSpace;
uint PBeginSpace;
uint LIBeginSpace;
uint ULBeginSpace;
uint LIIndent;
uint ULIndent;
float LineSpaceFontFactor;
std::string DefaultButtonGroup;
std::string DefaultFormTextGroup;
std::string DefaultFormTextAreaGroup;
std::string DefaultFormSelectGroup;
std::string DefaultCheckBoxBitmapNormal;
std::string DefaultCheckBoxBitmapPushed;
std::string DefaultCheckBoxBitmapOver;
std::string DefaultBackgroundBitmapView;
std::string CurrentLinkTitle;
// Browser home
std::string Home;
// Undo browse: Browse the precedent url browsed. no op if none
void browseUndo ();
// Redo browse: Browse the precedent url undoed. no op if none
void browseRedo ();
// clear undo/redo
void clearUndoRedo();
std::string getURL() const { return _URL; }
void setURL(const std::string &url);
int luaBrowse(CLuaState &ls);
int luaRefresh(CLuaState &ls);
int luaRemoveContent(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END
protected :
// \name callback from libwww
// Begin of the parsing of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
// Add POST params to the libwww list
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated(HTRequest *request);
// Get Home URL
virtual std::string home();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
// Handle some work at each pass
virtual void handle ();
// \name internal methods
// Add a group in the current parent group
void addGroup (CInterfaceGroup *group, uint beginSpace);
// Get the current parent group
CInterfaceGroup *getCurrentGroup();
// Update current paragraph dependent data
void paragraphChange ();
// Clear the contexts info
void clearContext();
// Translate a char
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const;
// Add a string in the current paragraph
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const char *image, bool globalColor, bool reloadImg=false);
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content);
// Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip);
// Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
// Set the background
void setBackground (const std::string &bgtex, bool scale, bool tile);
// Force the current string to be in a single string
void flushString();
// Set the title
void setTitle (const ucstring &title);
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
// Delete page content and prepare next page
void removeContent ();
// Current URL
std::string _URL;
// Current DOMAIN
bool _TrustedDomain;
// Title prefix
ucstring _TitlePrefix;
// Title string
ucstring _TitleString;
// Need to browse next update coords..
bool _BrowseNextTime;
bool _PostNextTime;
uint _PostFormId;
std::string _PostFormSubmitButton;
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
// minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing
// element has been found
// True when the <lua> element has been encountered
bool _ParsingLua;
bool _IgnoreText;
// the script to execute
std::string _LuaScript;
bool _Object;
std::string _ObjectScript;
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client.
static CGroupHTML *_ConnectingLock;
// LibWWW data
class CLibWWWData *_LibWWW;
// Current paragraph
std::string _DivName;
CGroupParagraph* _Paragraph;
inline CGroupParagraph *getParagraph()
{
return _Paragraph;
/*if (_Paragraph.empty())
return NULL;
return _Paragraph.back();*/
}
// PRE mode
std::vector<bool> _PRE;
inline bool getPRE() const
{
if (_PRE.empty())
return false;
return _PRE.back();
}
// UL mode
std::vector<bool> _UL;
inline bool getUL() const
{
if (_UL.empty())
return false;
return _UL.back();
}
// A mode
std::vector<bool> _A;
inline bool getA() const
{
if (_A.empty())
return false;
return _A.back();
}
// IL mode
bool _LI;
// Current text color
std::vector<NLMISC::CRGBA> _TextColor;
inline const NLMISC::CRGBA &getTextColor() const
{
if (_TextColor.empty())
return TextColor;
return _TextColor.back();
}
// Current global color flag
std::vector<bool> _GlobalColor;
inline bool getGlobalColor() const
{
if (_GlobalColor.empty())
return false;
return _GlobalColor.back();
}
// Current font size
std::vector<uint> _FontSize;
inline uint getFontSize() const
{
if (_FontSize.empty())
return TextFontSize;
return _FontSize.back();
}
// Current link
std::vector<std::string> _Link;
inline const char *getLink() const
{
if (_Link.empty())
return "";
return _Link.back().c_str();
}
std::vector<std::string> _LinkTitle;
inline const char *getLinkTitle() const
{
if (_LinkTitle.empty())
return "";
return _LinkTitle.back().c_str();
}
std::vector<std::string> _LinkClass;
inline const char *getLinkClass() const
{
if (_LinkClass.empty())
return "";
return _LinkClass.back().c_str();
}
// Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const
{
if (_Divs.empty())
return NULL;
return _Divs.back();
}
// Tables
std::vector<class CGroupTable*> _Tables;
inline CGroupTable *getTable() const
{
if (_Tables.empty())
return NULL;
return _Tables.back();
}
// Cells
std::vector<class CGroupCell*> _Cells;
// TR
std::vector<bool> _TR;
inline bool getTR() const
{
if (_TR.empty())
return false;
return _TR.back();
}
// Forms
class CForm
{
public:
class CEntry
{
public:
CEntry ()
{
TextArea = NULL;
Checkbox = NULL;
ComboBox = NULL;
InitialSelection = 0;
}
// Variable name
std::string Name;
// Variable value
ucstring Value;
// Text area group
CInterfaceGroup *TextArea;
// Checkbox
CCtrlButton *Checkbox;
// Combobox group
CDBGroupComboBox *ComboBox;
// select values (for the <select> tag)
std::vector<std::string> SelectValues;
sint InitialSelection; // initial selection for the combo box
};
// The action the form has to perform
std::string Action;
// The text area associated with the form
std::vector<CEntry> Entries;
};
std::vector<CForm> _Forms;
std::vector<CInterfaceGroup *> _Groups;
// Cells parameters
class CCellParams
{
public:
CCellParams () : BgColor(0,0,0,0)
{
Align = CGroupCell::Left;
VAlign = CGroupCell::Top;
LeftMargin = 0;
NoWrap = false;
}
NLMISC::CRGBA BgColor;
std::string Style;
CGroupCell::TAlign Align;
CGroupCell::TVAlign VAlign;
sint32 LeftMargin;
bool NoWrap;
};
std::vector<CCellParams> _CellParams;
// Indentation
uint _Indent;
// Current node is a title
bool _Title;
// Current node must be localized
bool _Localize;
// Current node is a text area
bool _TextArea;
std::string _TextAreaTemplate;
ucstring _TextAreaContent;
std::string _TextAreaName;
uint _TextAreaRow;
uint _TextAreaCols;
// current mode is in select option
bool _SelectOption;
ucstring _SelectOptionStr;
// Current node is a object
std::string _ObjectType;
std::string _ObjectData;
std::string _ObjectMD5Sum;
std::string _ObjectAction;
std::string _TextAreaScript;
// Get last char
ucchar getLastChar() const;
// Current link view
class CViewLink *_CurrentViewLink;
class CViewBitmap *_CurrentViewImage;
// Current group table
class CGroupCell *_CurrentCell;
// The main group
class CGroupListAdaptor *_GroupListAdaptor;
// For auto selecting the node in a BrowseTree bound to this HTML web page
std::string _BrowseTree;
// select the tree node that has the correct url
const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url);
// search if the action / params match the url. look recurs into procedures
bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url);
// Browse undo and redo
enum {MaxUrlUndoRedo= 256};
std::string _BrowseUndoButton;
std::string _BrowseRedoButton;
std::string _BrowseRefreshButton;
// _BrowseUrl is different from _URL, in that _URL may change in handle()
std::string _AskedUrl;
std::deque<std::string> _BrowseUndo;
std::deque<std::string> _BrowseRedo;
void pushUrlUndoRedo(const std::string &url);
void doBrowse(const char *url);
void updateUndoRedoButtons();
void updateRefreshButton();
// For Killing request. Associate each CGroupHTML object with a unique ID.
uint32 _GroupHtmlUID;
static uint32 _GroupHtmlUIDPool;
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
private:
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
struct CDataDownload
{
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f)
{
if (t == ImgType) imgs.push_back(i);
}
CURL *curl;
std::string url;
std::string luaScript;
std::string md5sum;
TDataType type;
FILE *fp;
std::vector<CViewBase *> imgs;
};
std::vector<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img);
std::string localImageName(const std::string &url);
bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();
bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
void releaseDownloads();
void checkDownloads();
};
// adapter group that store y offset for inputs inside an html form
class CGroupHTMLInputOffset : public CInterfaceGroup
{
public:
sint32 Offset;
CGroupHTMLInputOffset(const TCtorParam &param);
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
};
}
#endif

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +1,637 @@
// 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_ELEMENT_H
#define NL_INTERFACE_ELEMENT_H
#include "nel/misc/types_nl.h"
#include "nel/misc/string_mapper.h"
#include "nel/misc/smart_ptr.h"
#include "nel/misc/vector.h"
#include "nel/gui/interface_property.h"
#include "nel/gui/reflect.h"
#include "nel/gui/interface_common.h"
namespace NLGUI
{
class CGroupList;
class CInterfaceLink;
class CInterfaceElement;
class CInterfaceGroup;
class CViewBase;
class CCtrlBase;
class IActionHandler;
class CGroupParagraph;
/**
* A visitor to walk a tree of interface elements and apply a teartment on them.
*
* For each vsited element, visitElement() is called
* If the element is a control, then visitCtrl() is called, and then visitElement()
* If the element is a view, then visitView() is called, and then visitElement()
* If the element is a group, then visitGoup() is called, and then visitElement()
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CInterfaceElementVisitor
{
public:
virtual void visit(CInterfaceElement * /* elem */) {}
virtual void visitGroup(CInterfaceGroup * /* group */) {}
virtual void visitView(CViewBase * /* view */) {}
virtual void visitCtrl(CCtrlBase * /* ctrl */) {}
};
/**
* class describing a localisable interface element, i.e. : an element with coordinates
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
{
public:
enum EStrech
{
none=0,
width=1,
height=2
};
/// Constructor
CInterfaceElement()
{
_Parent = NULL;
_XReal = _YReal = _WReal = _HReal = 0;
_X = _Y = _W = _H = 0;
//_Snap = 1;
_PosRef = Hotspot_BL;
_ParentPosRef = Hotspot_BL;
_ParentPos = NULL;
_SizeRef = 0;
_SizeDivW = 10;
_SizeDivH = 10;
_ParentSize = NULL;
_Links = NULL;
_Active= true;
// default to 3 pass
_InvalidCoords= 3;
_ModulateGlobalColor= true;
_RenderLayer= 0;
_AvoidResizeParent= false;
editorSelected = false;
serializable = true;
}
// dtor
virtual ~CInterfaceElement();
/** Cloning
* Cloning is actually performed using a serial / unserial in a memory stream
* NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only
*/
virtual CInterfaceElement *clone();
// help to serialize an action handler
static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
static std::string stripId( const std::string &fullId );
virtual std::string getProperty( const std::string &name ) const;
virtual void setProperty( const std::string &name, const std::string &value );
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// Parse the element and initalize it
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
/// Debug info on memory
virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); }
/// helper: display a parse error with the id of the lement
void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL);
/// Accessors : GET
const std::string& getId() const { return _Id; }
std::string getShortId() const;
std::string getIdByValue() const { return _Id; }
CInterfaceGroup* getParent() const { return _Parent; }
CInterfaceElement* getParentPos() const { return _ParentPos; }
CInterfaceElement* getParentSize() const { return _ParentSize; }
/// Get the master group of this element (recurs call.
CInterfaceElement* getMasterGroup() const;
// get a possible group container
CInterfaceGroup* getParentContainer();
bool getActive() const { return _Active; }
sint32 getX() const { return _X; }
sint32 getY() const { return _Y; }
sint32 getW() const { return (_Active?_W:0); }
sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); }
sint32 getH() const { return (_Active?_H:0); }
sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); }
/**
* Get the max width used by the window.
*
* The view must return the largest width its content can take if it will be resized at maximum.
* Typical use : for a CTextView multiline, it returns the size of the whole string.
*
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
*/
virtual sint32 getMaxUsedW() const { return INT_MAX; };
/**
* Get the min width used by the window.
*
* The view must return the smallest width its content can take if it will be resized at minimum.
* Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word.
*
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
*/
virtual sint32 getMinUsedW() const { return 0; };
//bool isSnapped() const { return (_Snap>1); }
//sint32 getSnapping() const { return _Snap; }
sint32 getXReal() const { return _XReal; }
sint32 getYReal() const { return _YReal; }
sint32 getWReal() const { return (_Active?_WReal:0); }
sint32 getHReal() const { return (_Active?_HReal:0); }
THotSpot getPosRef () const { return _PosRef; }
THotSpot getParentPosRef () const { return _ParentPosRef; }
sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3
void setSizeRef(sint32 value) { _SizeRef = value; }
/// Accessors : SET
void setId (const std::string &newID) { _Id = newID; }
inline void setName(const std::string &name) { _Name = name; }
inline const std::string& getName() { return _Name; }
virtual void setIdRecurse(const std::string &newID);
void setParent (CInterfaceGroup *pIG) { _Parent = pIG; }
void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; }
void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; }
virtual void setActive (bool state);
void setX (sint32 x) { _X = x; }
void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); }
void setY (sint32 y) { _Y = y; }
void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); }
void setW (sint32 w);
void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); }
void setH (sint32 h);
void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); }
void setPosRef (THotSpot hs) { _PosRef = hs; }
void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; }
// Get the coordinate of a corner on screen
void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot);
/** Test if the given coordinates are inside this element
*/
bool isIn(sint x, sint y) const;
/** Test if the given box intersect the element
*/
bool isIn(sint x, sint y, uint width, uint height) const;
/** Test if another interface element intersect this one
*/
bool isIn(const CInterfaceElement &other) const;
/**
* get the window containing the element
* \return NULL if the element is not on the window, otherwise returns a pointer to the window
*/
CInterfaceGroup* getRootWindow();
/** get the element Depth, ie the number of parent he has (0 if _Parent==NULL)
* \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual)
*/
uint getParentDepth() const;
/**
* true if the element and all its parents are active (recurs up to the root window)
*/
bool isActiveThroughParents() const;
/**
* move the element (add dx and dy to its coords)
* \param dx : value added to _X
* \param dy : value added to _Y
*/
virtual void move (sint32 dx, sint32 dy);
//void resizeBR (sint32 sizex, sint32 sizey);
//void stopResizeBR();
//void startResizeBR();
// Some tools
void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
// Parse tools
static std::string HotSpotToString( THotSpot spot );
static std::string HotSpotCoupleToString( THotSpot parentPosRef, THotSpot posRef );
static THotSpot convertHotSpot (const char *ptr); //
static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
static NLMISC::CRGBA convertColor (const char *ptr);
static bool convertBool (const char *ptr);
static NLMISC::CVector convertVector (const char *ptr);
/** Convert a value that is in the form like width="50" or width="10%"
* if the value is absolute like '50' then 'pixels' is filled, else
* the ratio is remapped to the [0, 1] range and is copied in 'ratio'
*/
static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio);
// add an interface link to that element (kept in a smart ptr)
void addLink(CInterfaceLink *link);
// remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr)
void removeLink(CInterfaceLink *link);
/** Update all links for this instance and its sons.
* Derivers should override this to update their sons.
*/
virtual void updateAllLinks();
/** This allow to force opening an element. By default it just activate the element.
* It allow to have different behaviour on more complex containers
*/
virtual void forceOpen() { setActive(true); }
virtual void enableBlink(uint /* numBlinks */ = 0) {}
virtual void disableBlink() {}
virtual bool getBlink() const { return false; }
// Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true
void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;}
bool getModulateGlobalColor() const {return _ModulateGlobalColor;}
void dummySet(sint32 value);
void dummySet(const std::string &value);
// lua methods
int luaUpdateCoords(CLuaState &ls);
int luaInvalidateCoords(CLuaState &ls);
int luaInvalidateContent(CLuaState &ls);
int luaCenter(CLuaState &ls);
int luaSetPosRef(CLuaState &ls);
int luaSetParentPos(CLuaState &ls);
// set sizeref as a string, like "wh", "wh5" ....
void setSizeRef(const std::string &sizeref);
std::string getSizeRefAsString() const;
std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const;
// export some properties
REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
REFLECT_BOOL ("active", getActive, setActive);
REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor);
REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords);
REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords);
REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords);
REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords);
REFLECT_SINT32 ("x_real", getXReal, dummySet);
REFLECT_SINT32 ("y_real", getYReal, dummySet);
REFLECT_SINT32 ("w_real", getWReal, dummySet);
REFLECT_SINT32 ("h_real", getHReal, dummySet);
REFLECT_STRING ("id", getIdByValue, dummySet);
REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef);
REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords);
REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords);
REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent);
REFLECT_LUA_METHOD("center", luaCenter);
REFLECT_LUA_METHOD("setPosRef", luaSetPosRef);
REFLECT_LUA_METHOD("setParentPos", luaSetParentPos);
REFLECT_EXPORT_END
/* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated
* Default 3 is needed for:
* 1: update _W/_H and _WReal/_HReal according to Sons
* 2: update XReal/YReal (eg: according to Scroll offset)
*/
void invalidateCoords(uint8 numPass= 2);
uint8 getInvalidCoords() const {return _InvalidCoords;}
/* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable).
* It invalidates the content of the parent too.
*/
void invalidateContent();
/* This call back is called when the content or the content of a child is been invalidated.
*/
virtual void onInvalidateContent() {}
// called by interfaceManager for master window only
void resetInvalidCoords();
/// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord)
virtual void updateCoords();
/// Called each frame before draw to possibly invalidateCoords().
virtual void checkCoords();
/// Test if this element is son of the given element
bool isSonOf(const CInterfaceElement *other) const;
/// Called after first frame initialised
virtual void launch () {}
void setRenderLayer(sint8 rl) {_RenderLayer= rl;}
sint8 getRenderLayer() const { return _RenderLayer; }
void copyOptionFrom(const CInterfaceElement &other);
// center the element in middle of screen
void center();
// for debug only: draw wired quad to see where groups and hotspots are
enum TRenderWired
{
RenderView,
RenderCtrl,
RenderGroup
};
// if uiFilter is not empty, draw a quad only if the element id match
virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter);
void drawHotSpot(THotSpot hs, NLMISC::CRGBA col);
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return false; }
// Returns 'true' if that element can be downcasted to a ctrl
virtual bool isCtrl() const { return false; }
// Returns 'true' if that element can be downcasted to an interface group
virtual bool isGroup() const { return false; }
/** This is called before the config loading begins. This is the place to restore default state for config info.
*/
virtual void onLoadConfig() {}
/** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig
* is called.
*/
virtual bool wantSerialConfig() const { return false; }
// Serial config info about that element. This is called only if wantSerialConfig() returns true
virtual void serialConfig(NLMISC::IStream &f);
// visit the node of the ui tree
virtual void visit(CInterfaceElementVisitor *visitor);
/** When user is quitting the interface, this is called. Then the interface config is saved
* This is where the element get the opportunity to do some cleanup.
*/
virtual void onQuit() {}
/// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add.
virtual void onAddToGroup() {}
/** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so
* this function is called on each children elements to move the XReal/Yreal only (with a delta)
*/
virtual void onFrameUpdateWindowPos(sint dx, sint dy);
/// if true, InterfaceGroup child resize won't take this element into account
bool avoidResizeParent() const {return _AvoidResizeParent;}
void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;}
virtual std::string getClassName()
{
nlassert(0); // forgot to implement serial & to register the class ?
return "";
}
bool isInGroup( CInterfaceGroup *group );
static void setEditorMode( bool b ){ editorMode = b; }
void setEditorSelected( bool b ){ editorSelected = b; }
bool isEditorSelected() const{ return editorSelected; }
void setPosParent( const std::string &id );
void setSizeParent( const std::string &id );
void setSerializable( bool b ){ serializable = b; }
bool IsSerializable() const{ return serializable; }
protected:
bool editorSelected;
static bool editorMode;
///the parent
CInterfaceGroup* _Parent;
///the id of the element
std::string _Id;
std::string _Name;
///is the element active?
bool _Active;
// if 0, don't need updateCoords(), else tell the number of pass needed
uint8 _InvalidCoords;
// Real display coords
sint32 _XReal, _YReal, _WReal, _HReal;
// Relative coords
sint32 _X;
sint32 _Y;
sint32 _W;
sint32 _H;
//sint32 _Snap;
// position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element
// will be placed on the center (middle middle) of the parent window
THotSpot _PosRef;
THotSpot _ParentPosRef;
NLMISC::CRefPtr<CInterfaceElement> _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it
sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3
sint32 _SizeDivW, _SizeDivH;
NLMISC::CRefPtr<CInterfaceElement> _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it
// Friend Class
friend class CGroupList;
friend class CGroupParagraph;
// True if must modulate the global color with the view
bool _ModulateGlobalColor;
// Index of layer to render it.
sint8 _RenderLayer;
// Used for CInterfaceGroup ChildResize feature
bool _AvoidResizeParent;
virtual void serial(NLMISC::IStream &f);
void parseSizeRef(const char *sizeRef);
void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH);
private:
//void snapSize();
bool serializable;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
TLinkVect *_Links; // links, or NULL if no link
};
/**
* class to compress string usage in the interface
* \author Matthieu 'Trap' Besson
* \author Nevrax France
* \date October 2003
*/
class CStringShared
{
public:
CStringShared()
{
_Id = NLMISC::CStringMapper::emptyId();
}
const CStringShared& operator=(const std::string &str)
{
_Id = _UIStringMapper->localMap(str);
return *this;
}
const CStringShared& operator=(const CStringShared &str)
{
_Id = str._Id;
return *this;
}
const std::string &toString() const
{
return _UIStringMapper->localUnmap(_Id);
}
operator const std::string &() const
{
return _UIStringMapper->localUnmap(_Id);
}
bool empty() const
{
return _Id == NLMISC::CStringMapper::emptyId();
}
static CStringShared emptyString()
{
return CStringShared();
}
NLMISC::TStringId getStringId() const { return _Id; }
void serial(NLMISC::IStream &f)
{
std::string str;
if (f.isReading())
{
f.serial(str);
*this = str;
}
else
{
str = this->toString();
f.serial(str);
}
}
static void createStringMapper();
static void deleteStringMapper();
private:
NLMISC::TStringId _Id;
static NLMISC::CStringMapper *_UIStringMapper;
};
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
}
using namespace NLGUI;
#endif // NL_INTERFACE_ELEMENT_H
/* End of interface_element.h */

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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

@ -20,11 +20,9 @@
#define LIBWWW_NEL_STREAM_H
#include "HTProt.h"
#include "libwww/HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
void * param, int mode);
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H

@ -14,45 +14,29 @@
// 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
#ifndef LINKDATA_H
#define LINKDATA_H
#include "nel/misc/types_nl.h"
#include <string>
#include "view_text.h"
// ***************************************************************************
/**
* Display a text in the form of val / max or "empty"
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewQuantity : public CViewText
namespace NLGUI
{
public:
/// Constructor
CDBViewQuantity(const TCtorParam &param);
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void draw ();
protected:
CInterfaceProperty _Number;
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
ucstring _EmptyText;
struct SLinkData
{
public:
uint32 id;
std::string parent;
std::string expr;
std::string target;
std::string action;
std::string params;
std::string cond;
};
void buildTextFromCache();
};
}
#endif // NL_DBVIEW_QUANTITY_H
/* End of dbview_quantity.h */
#endif

@ -0,0 +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

@ -0,0 +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 */

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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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

@ -0,0 +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 */

@ -0,0 +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 */

@ -0,0 +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

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

@ -0,0 +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 */

@ -0,0 +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

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

Loading…
Cancel
Save