CHANGED: #1471 The classes moved in the previous commit are now under the NLGUI namespace.

This commit is contained in:
dfighter1985 2012-06-09 03:57:40 +02:00
parent 529dd877fe
commit 3db1f3cc48
44 changed files with 8337 additions and 8074 deletions

View file

@ -24,113 +24,119 @@
#include "nel/misc/xml_auto_ptr.h"
#include <map>
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCtrlBase;
class IActionHandler
namespace NLGUI
{
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);
};
class CCtrlBase;
/**
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);
return it != FactoryMap.end() ? it->second : NULL;
}
/// 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
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
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); }
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 */) { }
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("") );
virtual ~IActionHandler() {}
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
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);
};
/// 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 ; \
\
/**
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);
return it != FactoryMap.end() ? it->second : NULL;
}
/// 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("") );
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
};
/// 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

View file

@ -23,141 +23,144 @@
#include "nel/gui/view_base.h"
#include "nel/gui/event_descriptor.h"
class CCtrlBase : public CViewBase
namespace NLGUI
{
public:
// Tooltip mode
enum TToolTipParentType
class CCtrlBase : public CViewBase
{
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
public:
NumToolTipParentRef
// 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;
}
/// Destructor
virtual ~CCtrlBase();
// 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;}
// 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);
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);
};
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;
}
/// Destructor
virtual ~CCtrlBase();
// 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;}
// 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);
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);
};
}
#endif // RZ_VIEW_BASE_H

View file

@ -1,42 +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"
class CCtrlDraggable : public CCtrlBase
namespace NLGUI
{
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()
class CCtrlDraggable : public CCtrlBase
{
dragged = false;
_LastDraggedSheet = NULL;
}
public:
DECLARE_UI_CLASS( CCtrlDraggable )
// Necessary because of reflection, no other purpose
void draw(){}
CCtrlDraggable( const TCtorParam &param );
virtual ~CCtrlDraggable(){};
REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase)
REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END
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;
}
protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
// Necessary because of reflection, no other purpose
void draw(){}
private:
static CCtrlDraggable *_LastDraggedSheet;
bool dragged;
bool draggable;
};
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

View file

@ -19,37 +19,42 @@
#include "nel/gui/ctrl_base.h"
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
namespace NLGUI
{
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 );
class CInterfaceGroup;
/** 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 );
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(){}
// Necessary because of reflection, no other purpose
void draw(){}
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
private:
private:
};
};
}
#endif

View file

@ -20,75 +20,82 @@
#include "nel/gui/interface_group.h"
class CGroupContainerBase : public CInterfaceGroup
namespace NLGUI
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase();
class CGroupContainerBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
virtual void removeAllContainers();
virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase();
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
virtual void removeAllContainers();
virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
// 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; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
// 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); }
// 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; }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
// 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); }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
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
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
protected:
void triggerAlphaSettingsChangedAH();
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
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;
protected:
void triggerAlphaSettingsChangedAH();
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
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;
private:
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private:
};
}
};
#endif

View file

@ -20,45 +20,50 @@
#include "nel/gui/interface_group.h"
class CGroupEditBoxBase : public CInterfaceGroup
namespace NLGUI
{
public:
DECLARE_UI_CLASS( CGroupEditBoxBase )
CGroupEditBoxBase( const TCtorParam &param );
~CGroupEditBoxBase();
class CGroupEditBoxBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( 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; }
CGroupEditBoxBase( const TCtorParam &param );
~CGroupEditBoxBase();
std::string getAHOnFocus(){ return _AHOnFocus; }
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
// 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; }
// disable any current selection
static void disableSelection(){ _CurrSelection = NULL; }
std::string getAHOnFocus(){ return _AHOnFocus; }
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
// Get / set current selection
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
// disable any current selection
static void disableSelection(){ _CurrSelection = NULL; }
void draw(){}
// Get / set current selection
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
void draw(){}
protected:
bool _RecoverFocusOnEnter : 1;
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
std::string _AHOnFocus;
std::string _AHOnFocusParams;
protected:
bool _RecoverFocusOnEnter : 1;
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
std::string _AHOnFocus;
std::string _AHOnFocusParams;
private:
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
};
private:
};
}
#endif

View file

@ -23,83 +23,88 @@
#include "nel/gui/interface_group.h"
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
namespace NLGUI
{
public:
/// Constructor
CGroupFrame(const TCtorParam &param);
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
void copyOptionFrom(const CGroupFrame &other);
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;
// Fields Defined in the XML => must not herit them from extends=""
bool _DisplayFrameDefined : 1;
bool _ColorDefined : 1;
bool _DispTypeDefined : 1;
// Static stuff
enum
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
{
TextTL= 0,
TextTM,
TextTR,
TextML,
TextMM,
TextMR,
TextBL,
TextBM,
TextBR
};
public:
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;
/// Constructor
CGroupFrame(const TCtorParam &param);
// -----------------------
SDisplayType()
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
void copyOptionFrom(const CGroupFrame &other);
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;
// Fields Defined in the XML => must not herit them from extends=""
bool _DisplayFrameDefined : 1;
bool _ColorDefined : 1;
bool _DispTypeDefined : 1;
// Static stuff
enum
{
for (uint i = 0; i < 9; ++i)
TileBorder[i] = 0;
}
};
static std::vector<SDisplayType> _DispTypes;
};
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

View file

@ -22,48 +22,51 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
// ***************************************************************************
/**
* A group with special modal options
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupModal : public CGroupFrame
namespace NLGUI
{
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:
// ***************************************************************************
/**
* 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;
/// Constructor
CGroupModal(const TCtorParam &param);
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:
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
void setBaseX(sint32 x) { _MouseDeltaX = x;}
void setBaseY(sint32 y) { _MouseDeltaY = y;}
/// Constructor
CGroupModal(const TCtorParam &param);
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
void setBaseX(sint32 x) { _MouseDeltaX = x;}
void setBaseY(sint32 y) { _MouseDeltaY = y;}
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
}
#endif // NL_GROUP_MODAL_H

File diff suppressed because it is too large Load diff

View file

@ -22,382 +22,386 @@
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
// ----------------------------------------------------------------------------
class CInterfaceGroup : public CCtrlBase
namespace NLGUI
{
public:
DECLARE_UI_CLASS(CInterfaceGroup)
/// Constructor
CInterfaceGroup(const TCtorParam &param);
class CInterfaceGroup : public CCtrlBase
{
public:
DECLARE_UI_CLASS(CInterfaceGroup)
/// Destructor
virtual ~CInterfaceGroup();
/// Constructor
CInterfaceGroup(const TCtorParam &param);
virtual void setIdRecurse(const std::string &id);
/// Destructor
virtual ~CInterfaceGroup();
/// Coming from CInterfaceElement
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void setIdRecurse(const std::string &id);
virtual uint32 getMemory ();
virtual CInterfaceElement* getElement (const std::string &id);
CInterfaceElement* findFromShortId(const std::string &id);
/// Coming from CInterfaceElement
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
/// 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);
virtual uint32 getMemory ();
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; }
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);
virtual CInterfaceElement* getElement (const std::string &id);
CInterfaceElement* findFromShortId(const std::string &id);
protected:
/// 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);
/// children interface elements
std::vector<CInterfaceGroup*> _ChildrenGroups;
std::vector<CCtrlBase*> _Controls;
std::vector<CViewBase*> _Views;
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);
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 _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);
// @}
};
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; }
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 _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

View file

@ -27,165 +27,160 @@ namespace NLGUI
class CReflectedProperty;
class CInterfaceExprValue;
class CInterfaceExprNode;
}
class CInterfaceElement;
class CInterfaceGroup;
class CInterfaceElement;
class CInterfaceGroup;
using namespace NLGUI;
/** 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
/** 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:
CInterfaceLinkUpdater();
~CInterfaceLinkUpdater();
void onObserverCallFlush();
#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();
};
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

View file

@ -28,70 +28,73 @@ namespace NL3D
class UAnimationSet;
}
// ***************************************************************************
class CInterfaceOptionValue
namespace NLGUI
{
public:
CInterfaceOptionValue()
// ***************************************************************************
class CInterfaceOptionValue
{
_Color= NLMISC::CRGBA::White;
_Int= 0;
_Float= 0;
_Boolean= false;
}
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;}
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);
void init(const std::string &str);
// returned when InterfaceOptions param not found
static const CInterfaceOptionValue NullValue;
// returned when InterfaceOptions param not found
static const CInterfaceOptionValue NullValue;
private:
private:
std::string _Str;
NLMISC::CRGBA _Color;
sint32 _Int;
float _Float;
bool _Boolean;
};
std::string _Str;
NLMISC::CRGBA _Color;
sint32 _Int;
float _Float;
bool _Boolean;
};
// ***************************************************************************
class CInterfaceOptions : public NLMISC::CRefCount
{
// ***************************************************************************
class CInterfaceOptions : public NLMISC::CRefCount
{
public:
public:
CInterfaceOptions();
virtual ~CInterfaceOptions();
CInterfaceOptions();
virtual ~CInterfaceOptions();
virtual bool parse (xmlNodePtr cur);
virtual bool parse (xmlNodePtr cur);
// return NullValue if param not found
const CInterfaceOptionValue &getValue(const std::string &sParamName) 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;
// 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);
// copy basic map only from other CInterfaceOptions (non virtual method)
void copyBasicMap(const CInterfaceOptions &other);
protected:
protected:
std::map<std::string, CInterfaceOptionValue> _ParamValue;
std::map<std::string, CInterfaceOptionValue> _ParamValue;
};
};
}
#endif // NL_INTERFACE_LAYER_H

View file

@ -23,59 +23,63 @@
#include "nel/misc/factory.h"
#include "nel/gui/interface_element.h"
class CViewBase : public CInterfaceElement
namespace NLGUI
{
public:
// for factory construction
struct TCtorParam
{};
/// Constructor
CViewBase(const TCtorParam &/* param */) : CInterfaceElement()
class CViewBase : public CInterfaceElement
{
}
public:
/// Destructor
virtual ~CViewBase();
// for factory construction
struct TCtorParam
{};
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return true; }
/// Constructor
CViewBase(const TCtorParam &/* param */) : CInterfaceElement()
{
}
/// 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;
/// Destructor
virtual ~CViewBase();
virtual void updateCoords() { CInterfaceElement::updateCoords(); }
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return true; }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// 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;
/// Reflection
virtual sint32 getAlpha() const { return -1; } // Not obliged to implement this
virtual void setAlpha (sint32 /* a */) {} // Not obliged to implement this
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);
}
void copyOptionFrom(const CViewBase &other)
{
CInterfaceElement::copyOptionFrom(other);
}
REFLECT_EXPORT_START(CViewBase, CInterfaceElement)
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_EXPORT_END
REFLECT_EXPORT_START(CViewBase, CInterfaceElement)
REFLECT_SINT32 ("alpha", getAlpha, setAlpha);
REFLECT_EXPORT_END
virtual void dumpSize(uint depth = 0) const;
virtual void dumpSize(uint depth = 0) const;
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
// 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; }
// 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

View file

@ -1,55 +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 VIEW_POINTER_BASE_H
#define VIEW_POINTER_BASE_H
#include "nel/gui/view_base.h"
class CViewPointerBase : public CViewBase
namespace NLGUI
{
public:
DECLARE_UI_CLASS( CViewPointerBase )
CViewPointerBase( const TCtorParam &param );
virtual ~CViewPointerBase();
class CViewPointerBase : public CViewBase
{
public:
DECLARE_UI_CLASS( CViewPointerBase )
// Set the pointer position.
void setPointerPos (sint32 x, sint32 y);
void setPointerDispPos (sint32 x, sint32 y);
CViewPointerBase( const TCtorParam &param );
virtual ~CViewPointerBase();
void resetPointerPos ();
void setPointerDown (bool pd);
void setPointerDownString (const std::string &s);
// Set the pointer position.
void setPointerPos (sint32 x, sint32 y);
void setPointerDispPos (sint32 x, sint32 y);
void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y);
void resetPointerPos ();
void setPointerDown (bool pd);
void setPointerDownString (const std::string &s);
void getPointerOldPos (sint32 &x, sint32 &y);
void getPointerDownPos (sint32 &x, sint32 &y);
bool getPointerDown ();
std::string getPointerDownString ();
bool getPointerDrag ();
void getPointerPos (sint32 &x, sint32 &y);
void getPointerDispPos (sint32 &x, sint32 &y);
/// Is the pointer visible ?
bool show() const {return _PointerVisible;}
void getPointerOldPos (sint32 &x, sint32 &y);
void getPointerDownPos (sint32 &x, sint32 &y);
bool getPointerDown ();
std::string getPointerDownString ();
bool getPointerDrag ();
void draw(){}
/// Is the pointer visible ?
bool show() const {return _PointerVisible;}
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 ?
void draw(){}
private:
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 ?
private:
};
};
}
#endif

View file

@ -23,314 +23,319 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_common.h"
class CInterfaceElement;
class CCtrlBase;
class CViewBase;
class CInterfaceGroup;
class CViewPointerBase;
class CInterfaceOptions;
namespace NLMISC
{
class CCDBNodeLeaf;
}
class IParser
namespace NLGUI
{
public:
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;
};
/// Manages the GUI widgets
class CWidgetManager{
public:
class CInterfaceElement;
class CCtrlBase;
class CViewBase;
class CInterfaceGroup;
class CViewPointerBase;
class CInterfaceOptions;
// Master groups encapsulate all windows
struct SMasterGroup
class IParser
{
SMasterGroup()
{
Group = NULL;
LastTopWindowPriority = WIN_PRIORITY_NORMAL;
}
CInterfaceGroup *Group;
std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ];
void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL );
void delWindow( CInterfaceGroup *pIG );
CInterfaceGroup *getWindowFromId( const std::string &winID );
bool isWindowPresent( CInterfaceGroup *pIG );
// Set a window top in its priority queue
void setTopWindow( CInterfaceGroup *pIG );
void setBackWindow( CInterfaceGroup *pIG );
void deactiveAllContainers();
void centerAllContainers();
void unlockAllContainers();
// Sort the world space group
void sortWorldSpaceGroup ();
uint8 LastTopWindowPriority;
public:
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;
};
/// Manages the GUI widgets
class CWidgetManager{
public:
// Infos about a modal window.
struct SModalWndInfo
{
// Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after)
NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window
NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal;
bool ModalClip;
bool ModalExitClickOut;
bool ModalExitClickL;
bool ModalExitClickR;
bool ModalExitKeyPushed;
std::string ModalHandlerClickOut;
std::string ModalClickOutParams;
SModalWndInfo()
// Master groups encapsulate all windows
struct SMasterGroup
{
ModalWindow = NULL;
CtrlLaunchingModal = NULL;
ModalExitClickOut = false;
ModalExitClickL = false;
ModalExitClickR = false;
ModalExitKeyPushed = false;
SMasterGroup()
{
Group = NULL;
LastTopWindowPriority = WIN_PRIORITY_NORMAL;
}
CInterfaceGroup *Group;
std::list< CInterfaceGroup* > PrioritizedWindows[ WIN_PRIORITY_MAX ];
void addWindow( CInterfaceGroup *pIG, uint8 nPrio = WIN_PRIORITY_NORMAL );
void delWindow( CInterfaceGroup *pIG );
CInterfaceGroup *getWindowFromId( const std::string &winID );
bool isWindowPresent( CInterfaceGroup *pIG );
// Set a window top in its priority queue
void setTopWindow( CInterfaceGroup *pIG );
void setBackWindow( CInterfaceGroup *pIG );
void deactiveAllContainers();
void centerAllContainers();
void unlockAllContainers();
// Sort the world space group
void sortWorldSpaceGroup ();
uint8 LastTopWindowPriority;
};
// Infos about a modal window.
struct SModalWndInfo
{
// Yoyo: store as CRefPtr in case they are deleted (can happen for instance if menu right click on a guild memeber, and guild members are udpated after)
NLMISC::CRefPtr< CInterfaceGroup > ModalWindow; // the current modal window
NLMISC::CRefPtr< CCtrlBase > CtrlLaunchingModal;
bool ModalClip;
bool ModalExitClickOut;
bool ModalExitClickL;
bool ModalExitClickR;
bool ModalExitKeyPushed;
std::string ModalHandlerClickOut;
std::string ModalClickOutParams;
SModalWndInfo()
{
ModalWindow = NULL;
CtrlLaunchingModal = NULL;
ModalExitClickOut = false;
ModalExitClickL = false;
ModalExitClickR = false;
ModalExitKeyPushed = false;
}
};
static CWidgetManager* getInstance();
static void release();
CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName );
std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; }
SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; }
CInterfaceGroup* getWindowFromId( const std::string &groupId );
void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeAllMasterGroups();
void activateMasterGroup (const std::string &sMasterGroupName, bool bActive);
CInterfaceElement* getElementFromId( const std::string &sEltId );
CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId );
/// Get the window from an element (ui:interface:###)
CInterfaceGroup* getWindow(CInterfaceElement*);
/**
* set the top window
* \param win : pointer to the window to be set on top
*/
void setTopWindow (CInterfaceGroup *pWin);
/**
* set the back window
* \param win : pointer to the window to be set on top
*/
void setBackWindow (CInterfaceGroup *pWin);
/** get the top window in the first activated masterGroup
*/
CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
/** get the back window in the first activated masterGroup
*/
CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
/** get the last escapable top window in the first activated masterGroup
*/
CInterfaceGroup* getLastEscapableTopWindow() const;
void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority);
/** return the priority of the Last Window setTopWindow()-ed.
*/
uint8 getLastTopWindowPriority() const;
bool hasModal() const;
SModalWndInfo& getModal();
bool isPreviousModal( CInterfaceGroup *wnd ) const;
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
// Disable all modals windows
void disableModalWindow ();
/** Push a modal window that becomes the current modal window
*/
void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
void popModalWindow();
// pop all top modal windows with the given category (a string stored in the modal)
void popModalWindowCategory(const std::string &category);
CCtrlBase *getCtrlLaunchingModal ()
{
if (_ModalStack.empty()) return NULL;
return _ModalStack.back().CtrlLaunchingModal;
}
/// get the currently active modal window, or NULL if none
CInterfaceGroup *getModalWindow() const
{
if (_ModalStack.empty()) return NULL;
return _ModalStack.back().ModalWindow;
}
void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; }
CCtrlBase* getCurContextHelp(){ return curContextHelp; }
float _DeltaTimeStopingContextHelp;
CViewPointerBase* getPointer(){ return _Pointer; }
void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; }
/**
* get the window under a spot
* \param : X coord of the spot
* \param : Y coord of the spot
* \return : pointer to the window
*/
CInterfaceGroup* getWindowUnder (sint32 x, sint32 y);
CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; }
void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; }
CInterfaceGroup* getGroupUnder (sint32 x, sint32 y);
void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB );
void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL );
void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL );
const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; }
const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; }
const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; }
//
void clearViewUnders(){ _ViewsUnderPointer.clear(); }
void clearGroupsUnders() { _GroupsUnderPointer.clear(); }
void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); }
// Remove all references on a view (called when the ctrl is destroyed)
void removeRefOnView( CViewBase *ctrlBase );
// Remove all references on a ctrl (called when the ctrl is destroyed)
void removeRefOnCtrl (CCtrlBase *ctrlBase);
// Remove all references on a group (called when the group is destroyed)
void removeRefOnGroup (CInterfaceGroup *group);
void reset();
void checkCoords();
// Relative move of pointer
void movePointer (sint32 dx, sint32 dy);
// Set absolute coordinates of pointer
void movePointerAbs(sint32 px, sint32 py);
/**
* Capture
*/
CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; }
CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; }
CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; }
CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; }
CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; }
void setCapturePointerLeft(CCtrlBase *c);
void setCapturePointerRight(CCtrlBase *c);
void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; }
// NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture
// to come back to the last captured window (resetCaptureKeyboard() not)
void setCaptureKeyboard(CCtrlBase *c);
/** Set the default box to use when no keyboard has been previously captured
* The given dialog should be static
*/
void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; }
void resetCaptureKeyboard();
// True if the keyboard is captured
bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;}
// register a view that wants to be notified at each frame (receive the msg 'clocktick')
void registerClockMsgTarget(CCtrlBase *vb);
void unregisterClockMsgTarget(CCtrlBase *vb);
bool isClockMsgTarget(CCtrlBase *vb) const;
void sendClockTickEvent();
void notifyElementCaptured(CCtrlBase *c);
// Add a group into the windows list of its master goup
void makeWindow( CInterfaceGroup *group );
// Remove a group from the windows list of its master group
void unMakeWindow( CInterfaceGroup *group, bool noWarning = false );
void setGlobalColor( NLMISC::CRGBA col );
NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; }
void setContentAlpha( uint8 alpha );
uint8 getContentAlpha() const{ return _ContentAlpha; }
NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; }
void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; }
void resetColorProps();
/// Get options by name
CInterfaceOptions* getOptions( const std::string &optName );
void addOptions( std::string name, CInterfaceOptions *options );
void removeOptions( std::string name );
void removeAllOptions();
static IParser *parser;
private:
CWidgetManager();
~CWidgetManager();
static CWidgetManager *instance;
std::vector< SMasterGroup > _MasterGroups;
std::vector< SModalWndInfo > _ModalStack;
static std::string _CtrlLaunchingModalId;
NLMISC::CRefPtr< CCtrlBase > curContextHelp;
CViewPointerBase *_Pointer;
// Options description
std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap;
NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder;
// Capture
NLMISC::CRefPtr<CCtrlBase> _CaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _OldCaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _DefaultCaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _CapturePointerLeft;
NLMISC::CRefPtr<CCtrlBase> _CapturePointerRight;
// What is under pointer
std::vector< CViewBase* > _ViewsUnderPointer;
std::vector< CCtrlBase* > _CtrlsUnderPointer;
std::vector< CInterfaceGroup* > _GroupsUnderPointer;
// view that should be notified from clock msg
std::vector<CCtrlBase*> _ClockMsgTargets;
NLMISC::CRGBA _GlobalColor;
NLMISC::CRGBA _GlobalColorForContent;
uint8 _ContentAlpha;
NLMISC::CCDBNodeLeaf *_RProp;
NLMISC::CCDBNodeLeaf *_GProp;
NLMISC::CCDBNodeLeaf *_BProp;
NLMISC::CCDBNodeLeaf *_AProp;
};
static CWidgetManager* getInstance();
static void release();
CInterfaceGroup* getMasterGroupFromId( const std::string &MasterGroupName );
std::vector< SMasterGroup > &getAllMasterGroup(){ return _MasterGroups; }
SMasterGroup& getMasterGroup( uint8 i ) { return _MasterGroups[ i ]; }
CInterfaceGroup* getWindowFromId( const std::string &groupId );
void addWindowToMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeWindowFromMasterGroup( const std::string &sMasterGroupName, CInterfaceGroup *pIG );
void removeAllMasterGroups();
void activateMasterGroup (const std::string &sMasterGroupName, bool bActive);
CInterfaceElement* getElementFromId( const std::string &sEltId );
CInterfaceElement* getElementFromId( const std::string &sStart, const std::string &sEltId );
/// Get the window from an element (ui:interface:###)
CInterfaceGroup* getWindow(CInterfaceElement*);
/**
* set the top window
* \param win : pointer to the window to be set on top
*/
void setTopWindow (CInterfaceGroup *pWin);
/**
* set the back window
* \param win : pointer to the window to be set on top
*/
void setBackWindow (CInterfaceGroup *pWin);
/** get the top window in the first activated masterGroup
*/
CInterfaceGroup* getTopWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
/** get the back window in the first activated masterGroup
*/
CInterfaceGroup* getBackWindow (uint8 nPriority = WIN_PRIORITY_NORMAL) const;
/** get the last escapable top window in the first activated masterGroup
*/
CInterfaceGroup* getLastEscapableTopWindow() const;
void setWindowPriority (CInterfaceGroup *pWin, uint8 nPriority);
/** return the priority of the Last Window setTopWindow()-ed.
*/
uint8 getLastTopWindowPriority() const;
bool hasModal() const;
SModalWndInfo& getModal();
bool isPreviousModal( CInterfaceGroup *wnd ) const;
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
void enableModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
// Disable all modals windows
void disableModalWindow ();
/** Push a modal window that becomes the current modal window
*/
void pushModalWindow(CCtrlBase *ctrlLaunchingModal, CInterfaceGroup *pIG);
void pushModalWindow (CCtrlBase *ctrlLaunchingModal, const std::string &groupName);
void popModalWindow();
// pop all top modal windows with the given category (a string stored in the modal)
void popModalWindowCategory(const std::string &category);
CCtrlBase *getCtrlLaunchingModal ()
{
if (_ModalStack.empty()) return NULL;
return _ModalStack.back().CtrlLaunchingModal;
}
/// get the currently active modal window, or NULL if none
CInterfaceGroup *getModalWindow() const
{
if (_ModalStack.empty()) return NULL;
return _ModalStack.back().ModalWindow;
}
void setCurContextHelp( CCtrlBase *curContextHelp ){ this->curContextHelp = curContextHelp; }
CCtrlBase* getCurContextHelp(){ return curContextHelp; }
float _DeltaTimeStopingContextHelp;
CViewPointerBase* getPointer(){ return _Pointer; }
void setPointer( CViewPointerBase *pointer ){ _Pointer = pointer; }
/**
* get the window under a spot
* \param : X coord of the spot
* \param : Y coord of the spot
* \return : pointer to the window
*/
CInterfaceGroup* getWindowUnder (sint32 x, sint32 y);
CInterfaceGroup* getCurrentWindowUnder() { return _WindowUnder; }
void setCurrentWindowUnder( CInterfaceGroup *group ){ _WindowUnder = group; }
CInterfaceGroup* getGroupUnder (sint32 x, sint32 y);
void getViewsUnder( sint32 x, sint32 y, std::vector< CViewBase* > &vVB );
void getCtrlsUnder( sint32 x, sint32 y, std::vector< CCtrlBase* > &vICL );
void getGroupsUnder (sint32 x, sint32 y, std::vector< CInterfaceGroup* > &vIGL );
const std::vector< CViewBase* >& getViewsUnderPointer(){ return _ViewsUnderPointer; }
const std::vector< CInterfaceGroup* >& getGroupsUnderPointer() { return _GroupsUnderPointer; }
const std::vector< CCtrlBase* >& getCtrlsUnderPointer() { return _CtrlsUnderPointer; }
//
void clearViewUnders(){ _ViewsUnderPointer.clear(); }
void clearGroupsUnders() { _GroupsUnderPointer.clear(); }
void clearCtrlsUnders() { _CtrlsUnderPointer.clear(); }
// Remove all references on a view (called when the ctrl is destroyed)
void removeRefOnView( CViewBase *ctrlBase );
// Remove all references on a ctrl (called when the ctrl is destroyed)
void removeRefOnCtrl (CCtrlBase *ctrlBase);
// Remove all references on a group (called when the group is destroyed)
void removeRefOnGroup (CInterfaceGroup *group);
void reset();
void checkCoords();
// Relative move of pointer
void movePointer (sint32 dx, sint32 dy);
// Set absolute coordinates of pointer
void movePointerAbs(sint32 px, sint32 py);
/**
* Capture
*/
CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; }
CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; }
CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; }
CCtrlBase *getOldCaptureKeyboard() { return _OldCaptureKeyboard; }
CCtrlBase *getDefaultCaptureKeyboard() { return _DefaultCaptureKeyboard; }
void setCapturePointerLeft(CCtrlBase *c);
void setCapturePointerRight(CCtrlBase *c);
void setOldCaptureKeyboard(CCtrlBase *c){ _OldCaptureKeyboard = c; }
// NB: setCaptureKeyboard(NULL) has not the same effect as resetCaptureKeyboard(). it allows the capture
// to come back to the last captured window (resetCaptureKeyboard() not)
void setCaptureKeyboard(CCtrlBase *c);
/** Set the default box to use when no keyboard has been previously captured
* The given dialog should be static
*/
void setDefaultCaptureKeyboard(CCtrlBase *c){ _DefaultCaptureKeyboard = c; }
void resetCaptureKeyboard();
// True if the keyboard is captured
bool isKeyboardCaptured() const {return _CaptureKeyboard!=NULL;}
// register a view that wants to be notified at each frame (receive the msg 'clocktick')
void registerClockMsgTarget(CCtrlBase *vb);
void unregisterClockMsgTarget(CCtrlBase *vb);
bool isClockMsgTarget(CCtrlBase *vb) const;
void sendClockTickEvent();
void notifyElementCaptured(CCtrlBase *c);
// Add a group into the windows list of its master goup
void makeWindow( CInterfaceGroup *group );
// Remove a group from the windows list of its master group
void unMakeWindow( CInterfaceGroup *group, bool noWarning = false );
void setGlobalColor( NLMISC::CRGBA col );
NLMISC::CRGBA getGlobalColor() const{ return _GlobalColor; }
void setContentAlpha( uint8 alpha );
uint8 getContentAlpha() const{ return _ContentAlpha; }
NLMISC::CRGBA getGlobalColorForContent() const { return _GlobalColorForContent; }
void setGlobalColorForContent( NLMISC::CRGBA col ){ _GlobalColorForContent = col; }
void resetColorProps();
/// Get options by name
CInterfaceOptions* getOptions( const std::string &optName );
void addOptions( std::string name, CInterfaceOptions *options );
void removeOptions( std::string name );
void removeAllOptions();
static IParser *parser;
private:
CWidgetManager();
~CWidgetManager();
static CWidgetManager *instance;
std::vector< SMasterGroup > _MasterGroups;
std::vector< SModalWndInfo > _ModalStack;
static std::string _CtrlLaunchingModalId;
NLMISC::CRefPtr< CCtrlBase > curContextHelp;
CViewPointerBase *_Pointer;
// Options description
std::map< std::string, NLMISC::CSmartPtr< CInterfaceOptions > > _OptionsMap;
NLMISC::CRefPtr< CInterfaceGroup > _WindowUnder;
// Capture
NLMISC::CRefPtr<CCtrlBase> _CaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _OldCaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _DefaultCaptureKeyboard;
NLMISC::CRefPtr<CCtrlBase> _CapturePointerLeft;
NLMISC::CRefPtr<CCtrlBase> _CapturePointerRight;
// What is under pointer
std::vector< CViewBase* > _ViewsUnderPointer;
std::vector< CCtrlBase* > _CtrlsUnderPointer;
std::vector< CInterfaceGroup* > _GroupsUnderPointer;
// view that should be notified from clock msg
std::vector<CCtrlBase*> _ClockMsgTargets;
NLMISC::CRGBA _GlobalColor;
NLMISC::CRGBA _GlobalColorForContent;
uint8 _ContentAlpha;
NLMISC::CCDBNodeLeaf *_RProp;
NLMISC::CCDBNodeLeaf *_GProp;
NLMISC::CCDBNodeLeaf *_BProp;
NLMISC::CCDBNodeLeaf *_AProp;
};
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -24,200 +24,204 @@
using namespace NLMISC;
// ***************************************************************************
CCtrlBase::~CCtrlBase()
namespace NLGUI
{
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
if (event.getType() == NLGUI::CEventDescriptor::system)
// ***************************************************************************
CCtrlBase::~CCtrlBase()
{
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
CWidgetManager::getInstance()->removeRefOnCtrl (this);
}
// ***************************************************************************
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
{
if (event.getType() == NLGUI::CEventDescriptor::system)
{
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive())
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
if (eds.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
{
// the mouse capture should be lost when the ctrl is hidden
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) eds).getActive())
{
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
// the mouse capture should be lost when the ctrl is hidden
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
CWidgetManager::getInstance()->setCapturePointerLeft(NULL);
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
{
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
}
// NB : don't call return here because derived class may be interested
// in handling event more speciffically
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
{
CWidgetManager::getInstance()->setCapturePointerRight(NULL);
}
// NB : don't call return here because derived class may be interested
// in handling event more speciffically
}
}
return false;
}
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CViewBase::parse(cur, parentGroup))
return false;
CXMLAutoPtr prop;
// get static toolTip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
if (prop)
{
const char *propPtr = prop;
_ContextHelp = ucstring(propPtr);
if (strlen(propPtr) > 2)
{
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
_ContextHelp = CI18N::get ((const char *) prop);
}
}
// Force I18N tooltip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
if ((bool)prop && strlen((const char*)prop)>0)
{
_ContextHelp = CI18N::get ((const char *) prop);
}
// get dynamic toolTip ActionHandler
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" );
if (prop)
{
_OnContextHelp= (const char*)prop;
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" );
if (prop)
{
_OnContextHelpParams= (const char*)prop;
}
// Tooltip parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" );
_ToolTipParent= TTCtrl;
if(prop)
{
if(stricmp((const char*)prop, "win")==0)
_ToolTipParent= TTWindow;
else if(stricmp((const char*)prop, "mouse")==0)
_ToolTipParent= TTMouse;
else if(stricmp((const char*)prop, "special")==0)
_ToolTipParent= TTSpecialWindow;
else
_ToolTipParent= TTCtrl;
}
// Tooltip special parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" );
_ToolTipSpecialParent= CStringShared();
if(prop)
{
_ToolTipSpecialParent= std::string((const char*)prop);
}
// Tooltip posref
THotSpot tmpParentHS, tmpChildHS;
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRef= tmpParentHS;
_ToolTipPosRef= tmpChildHS;
// Alternative tooltip posref : this one will be chosen
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRefAlt = tmpParentHS;
_ToolTipPosRefAlt = tmpChildHS;
// ToolTip instant
prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help");
_ToolTipInstant= true;
if (prop) _ToolTipInstant = convertBool(prop);
return true;
}
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
if(prop)
{
const char *ptr= (const char*)prop;
if(stricmp(ptr, "auto")==0)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
}
// valid ref?
else if(strlen(ptr)>=5)
{
THotSpot parentPosRef;
THotSpot posRef;
CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef);
parentHS = parentPosRef;
childHS = posRef;
}
}
}
return false;
}
// ***************************************************************************
bool CCtrlBase::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CViewBase::parse(cur, parentGroup))
return false;
CXMLAutoPtr prop;
// get static toolTip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip" );
if (prop)
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
const char *propPtr = prop;
_ContextHelp = ucstring(propPtr);
if (strlen(propPtr) > 2)
{
if ((propPtr[0] == 'u') && (propPtr[1] == 'i'))
_ContextHelp = CI18N::get ((const char *) prop);
}
}
// Force I18N tooltip
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_i18n" );
if ((bool)prop && strlen((const char*)prop)>0)
{
_ContextHelp = CI18N::get ((const char *) prop);
ucstring help;
getContextHelp(help);
std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty();
}
// get dynamic toolTip ActionHandler
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip" );
if (prop)
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
_OnContextHelp= (const char*)prop;
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"on_tooltip_params" );
if (prop)
{
_OnContextHelpParams= (const char*)prop;
nlassert(visitor);
visitor->visitCtrl(this);
CInterfaceElement::visit(visitor);
}
// Tooltip parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_parent" );
_ToolTipParent= TTCtrl;
if(prop)
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
if(stricmp((const char*)prop, "win")==0)
_ToolTipParent= TTWindow;
else if(stricmp((const char*)prop, "mouse")==0)
_ToolTipParent= TTMouse;
else if(stricmp((const char*)prop, "special")==0)
_ToolTipParent= TTSpecialWindow;
else
_ToolTipParent= TTCtrl;
CViewBase::serial(f);
f.serial(_ContextHelp);
f.serial(_OnContextHelp);
f.serial(_OnContextHelpParams);
f.serial(_ToolTipSpecialParent);
f.serialEnum(_ToolTipParent);
//
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
THotSpot tmpToolTipPosRef = _ToolTipPosRef;
THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt;
THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt;
f.serialEnum(tmpToolTipParentPosRef);
f.serialEnum(tmpToolTipPosRef);
f.serialEnum(tmpToolTipParentPosRefAlt);
f.serialEnum(tmpToolTipPosRefAlt);
_ToolTipParentPosRef = tmpToolTipParentPosRef;
_ToolTipPosRef = tmpToolTipPosRef;
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant);
}
// Tooltip special parent
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_special_parent" );
_ToolTipSpecialParent= CStringShared();
if(prop)
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
_ToolTipSpecialParent= std::string((const char*)prop);
return "context_help";
}
// Tooltip posref
THotSpot tmpParentHS, tmpChildHS;
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRef= tmpParentHS;
_ToolTipPosRef= tmpChildHS;
// Alternative tooltip posref : this one will be chosen
prop = (char*) xmlGetProp( cur, (xmlChar*)"tooltip_posref_alt" );
convertTooltipHotSpot(prop, tmpParentHS, tmpChildHS);
_ToolTipParentPosRefAlt = tmpParentHS;
_ToolTipPosRefAlt = tmpChildHS;
// ToolTip instant
prop = (char*) xmlGetProp( cur, (xmlChar*)"instant_help");
_ToolTipInstant= true;
if (prop) _ToolTipInstant = convertBool(prop);
return true;
}
// ***************************************************************************
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
if(prop)
{
const char *ptr= (const char*)prop;
if(stricmp(ptr, "auto")==0)
{
parentHS = Hotspot_TTAuto;
childHS = Hotspot_TTAuto;
}
// valid ref?
else if(strlen(ptr)>=5)
{
THotSpot parentPosRef;
THotSpot posRef;
CInterfaceElement::convertHotSpotCouple(ptr, parentPosRef, posRef);
parentHS = parentPosRef;
childHS = posRef;
}
}
}
// ***************************************************************************
bool CCtrlBase::emptyContextHelp() const
{
ucstring help;
getContextHelp(help);
std::string sTmp = _OnContextHelp;
return help.empty() && sTmp.empty();
}
// ***************************************************************************
void CCtrlBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitCtrl(this);
CInterfaceElement::visit(visitor);
}
// ***************************************************************************
void CCtrlBase::serial(NLMISC::IStream &f)
{
CViewBase::serial(f);
f.serial(_ContextHelp);
f.serial(_OnContextHelp);
f.serial(_OnContextHelpParams);
f.serial(_ToolTipSpecialParent);
f.serialEnum(_ToolTipParent);
//
THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef;
THotSpot tmpToolTipPosRef = _ToolTipPosRef;
THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt;
THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt;
f.serialEnum(tmpToolTipParentPosRef);
f.serialEnum(tmpToolTipPosRef);
f.serialEnum(tmpToolTipParentPosRefAlt);
f.serialEnum(tmpToolTipPosRefAlt);
_ToolTipParentPosRef = tmpToolTipParentPosRef;
_ToolTipPosRef = tmpToolTipPosRef;
_ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt;
_ToolTipPosRefAlt = tmpToolTipPosRefAlt;
//
nlSerialBitBool(f, _ToolTipInstant);
}
// ***************************************************************************
std::string CCtrlBase::getContextHelpWindowName() const
{
return "context_help";
}

View file

@ -1,11 +1,32 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/ctrl_draggable.h"
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
namespace NLGUI
{
dragged = false;
draggable = false;
}
CCtrlDraggable* CCtrlDraggable::_LastDraggedSheet = NULL;
CCtrlDraggable::CCtrlDraggable(const TCtorParam &param) :
CCtrlBase( param )
{
dragged = false;
draggable = false;
}
}

View file

@ -16,51 +16,57 @@
#include "nel/gui/ctrl_scroll_base.h"
CCtrlScrollBase::CCtrlScrollBase( const TCtorParam &param ) :
CCtrlBase( param )
namespace NLGUI
{
_Target = NULL;
CCtrlScrollBase::CCtrlScrollBase( const TCtorParam &param ) :
CCtrlBase( param )
{
_Target = NULL;
}
CCtrlScrollBase::~CCtrlScrollBase()
{
}
void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
sint32 CCtrlScrollBase::moveTrackX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
sint32 CCtrlScrollBase::moveTrackY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
void CCtrlScrollBase::moveTargetX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
void CCtrlScrollBase::moveTargetY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}
CCtrlScrollBase::~CCtrlScrollBase()
{
}
void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
sint32 CCtrlScrollBase::moveTrackX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
sint32 CCtrlScrollBase::moveTrackY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
return 0;
}
void CCtrlScrollBase::moveTargetX( sint32 dx )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
void CCtrlScrollBase::moveTargetY( sint32 dy )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}

View file

@ -17,76 +17,81 @@
#include "nel/gui/group_container_base.h"
CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) :
CInterfaceGroup( param )
namespace NLGUI
{
_ContentAlpha = 255;
_ContainerAlpha = 255;
_RolloverAlphaContainer = 0;
_RolloverAlphaContent = 0;
_Locked = false;
_UseGlobalAlpha = true;
}
CGroupContainerBase::~CGroupContainerBase()
{
}
void CGroupContainerBase::removeAllContainers()
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
void CGroupContainerBase::setLocked( bool locked )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
// ***************************************************************************
void CGroupContainerBase::triggerAlphaSettingsChangedAH()
{
if (_AHOnAlphaSettingsChanged != NULL)
CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams);
}
// ***************************************************************************
void CGroupContainerBase::setUseGlobalAlpha(bool use)
{
_UseGlobalAlpha = use;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContentAlpha(uint8 alpha)
{
_ContentAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha)
{
_RolloverAlphaContent = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha)
{
_RolloverAlphaContainer = alpha;
triggerAlphaSettingsChangedAH();
CGroupContainerBase::CGroupContainerBase( const CViewBase::TCtorParam &param ) :
CInterfaceGroup( param )
{
_ContentAlpha = 255;
_ContainerAlpha = 255;
_RolloverAlphaContainer = 0;
_RolloverAlphaContent = 0;
_Locked = false;
_UseGlobalAlpha = true;
}
CGroupContainerBase::~CGroupContainerBase()
{
}
void CGroupContainerBase::removeAllContainers()
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
void CGroupContainerBase::setLocked( bool locked )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
// ***************************************************************************
void CGroupContainerBase::triggerAlphaSettingsChangedAH()
{
if (_AHOnAlphaSettingsChanged != NULL)
CAHManager::getInstance()->runActionHandler(_AHOnAlphaSettingsChanged, this, _AHOnAlphaSettingsChangedParams);
}
// ***************************************************************************
void CGroupContainerBase::setUseGlobalAlpha(bool use)
{
_UseGlobalAlpha = use;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContainerAlpha(uint8 alpha)
{
_ContainerAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setContentAlpha(uint8 alpha)
{
_ContentAlpha = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContent(uint8 alpha)
{
_RolloverAlphaContent = alpha;
triggerAlphaSettingsChangedAH();
}
// ***************************************************************************
void CGroupContainerBase::setRolloverAlphaContainer(uint8 alpha)
{
_RolloverAlphaContainer = alpha;
triggerAlphaSettingsChangedAH();
}
}

View file

@ -1,14 +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/>.
#include "nel/gui/group_editbox_base.h"
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL;
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) :
CInterfaceGroup( param )
{
_RecoverFocusOnEnter = true;
}
CGroupEditBoxBase::~CGroupEditBoxBase()
namespace NLGUI
{
CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL;
CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam &param ) :
CInterfaceGroup( param )
{
_RecoverFocusOnEnter = true;
}
CGroupEditBoxBase::~CGroupEditBoxBase()
{
}
}

View file

@ -24,226 +24,232 @@
using namespace std;
using namespace NLMISC;
NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame");
// ***************************************************************************
vector<CGroupFrame::SDisplayType> CGroupFrame::_DispTypes;
// ***************************************************************************
CGroupFrame::CGroupFrame(const TCtorParam &param)
: CInterfaceGroup(param)
namespace NLGUI
{
_DisplayFrame = true;
_Color = CRGBA(255,255,255,255);
_DispType = 0;
_DisplayFrameDefined= false;
_ColorDefined= false;
_DispTypeDefined= false;
}
// ***************************************************************************
bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CInterfaceGroup::parse(cur, parentGroup))
return false;
NLMISC_REGISTER_OBJECT(CViewBase, CGroupFrame, std::string, "frame");
// display
CXMLAutoPtr ptr((const char*) xmlGetProp (cur, (xmlChar*)"display"));
_DisplayFrame = true;
_DisplayFrameDefined= false;
if (ptr)
// ***************************************************************************
vector<CGroupFrame::SDisplayType> CGroupFrame::_DispTypes;
// ***************************************************************************
CGroupFrame::CGroupFrame(const TCtorParam &param)
: CInterfaceGroup(param)
{
_DisplayFrame = convertBool (ptr);
_DisplayFrameDefined= true;
_DisplayFrame = true;
_Color = CRGBA(255,255,255,255);
_DispType = 0;
_DisplayFrameDefined= false;
_ColorDefined= false;
_DispTypeDefined= false;
}
// color
ptr = (char*) xmlGetProp( cur, (xmlChar*)"color" );
_Color = CRGBA(255,255,255,255);
_ColorDefined= false;
if (ptr)
// ***************************************************************************
bool CGroupFrame::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
_Color = convertColor (ptr);
_ColorDefined= true;
}
if(!CInterfaceGroup::parse(cur, parentGroup))
return false;
// Get the borders texture
_DispTypeDefined= false;
CViewRenderer &rVR = *CViewRenderer::getInstance();
// display
CXMLAutoPtr ptr((const char*) xmlGetProp (cur, (xmlChar*)"display"));
_DisplayFrame = true;
_DisplayFrameDefined= false;
if (ptr)
{
_DisplayFrame = convertBool (ptr);
_DisplayFrameDefined= true;
}
ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" );
CInterfaceOptions *pIO = NULL;
// color
ptr = (char*) xmlGetProp( cur, (xmlChar*)"color" );
_Color = CRGBA(255,255,255,255);
_ColorDefined= false;
if (ptr)
{
_Color = convertColor (ptr);
_ColorDefined= true;
}
if (ptr)
pIO = CWidgetManager::getInstance()->getOptions(ptr);
// Get the borders texture
_DispTypeDefined= false;
CViewRenderer &rVR = *CViewRenderer::getInstance();
// The first type in display type struct is the default display type
if (_DispTypes.size() == 0)
{
SDisplayType dt;
dt.Name = "default";
// get texture ids.
dt.BorderIds[TextTL]= rVR.getTextureIdFromName ("w_modal_tl.tga");
dt.BorderIds[TextTM]= rVR.getTextureIdFromName ("w_modal_t.tga");
dt.BorderIds[TextTR]= rVR.getTextureIdFromName ("w_modal_tr.tga");
// middle
dt.BorderIds[TextML]= rVR.getTextureIdFromName ("w_modal_l.tga");
dt.BorderIds[TextMM]= rVR.getTextureIdFromName ("w_modal_blank.tga");
dt.BorderIds[TextMR]= rVR.getTextureIdFromName ("w_modal_r.tga");
// bottom
dt.BorderIds[TextBL]= rVR.getTextureIdFromName ("w_modal_bl.tga");
dt.BorderIds[TextBM]= rVR.getTextureIdFromName ("w_modal_b.tga");
dt.BorderIds[TextBR]= rVR.getTextureIdFromName ("w_modal_br.tga");
// get size
rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder);
rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder);
_DispTypes.push_back(dt);
}
ptr = (char*) xmlGetProp( cur, (xmlChar*)"options" );
CInterfaceOptions *pIO = NULL;
if (pIO != NULL)
{
_DispTypeDefined= true;
if (ptr)
pIO = CWidgetManager::getInstance()->getOptions(ptr);
// Look if we find the type...
uint32 i;
for (i = 0; i < _DispTypes.size(); ++i)
if (_DispTypes[i].Name == string((const char*)ptr))
break;
if (i == _DispTypes.size())
// The first type in display type struct is the default display type
if (_DispTypes.size() == 0)
{
SDisplayType dt;
dt.Name = string((const char*)ptr);
dt.Name = "default";
// get texture ids.
dt.BorderIds[TextTL]= rVR.getTextureIdFromName (pIO->getValStr("tx_tl"));
dt.BorderIds[TextTM]= rVR.getTextureIdFromName (pIO->getValStr("tx_t"));
dt.BorderIds[TextTR]= rVR.getTextureIdFromName (pIO->getValStr("tx_tr"));
dt.BorderIds[TextTL]= rVR.getTextureIdFromName ("w_modal_tl.tga");
dt.BorderIds[TextTM]= rVR.getTextureIdFromName ("w_modal_t.tga");
dt.BorderIds[TextTR]= rVR.getTextureIdFromName ("w_modal_tr.tga");
// middle
dt.BorderIds[TextML]= rVR.getTextureIdFromName (pIO->getValStr("tx_l"));
dt.BorderIds[TextMM]= rVR.getTextureIdFromName (pIO->getValStr("tx_blank"));
dt.BorderIds[TextMR]= rVR.getTextureIdFromName (pIO->getValStr("tx_r"));
dt.BorderIds[TextML]= rVR.getTextureIdFromName ("w_modal_l.tga");
dt.BorderIds[TextMM]= rVR.getTextureIdFromName ("w_modal_blank.tga");
dt.BorderIds[TextMR]= rVR.getTextureIdFromName ("w_modal_r.tga");
// bottom
dt.BorderIds[TextBL]= rVR.getTextureIdFromName (pIO->getValStr("tx_bl"));
dt.BorderIds[TextBM]= rVR.getTextureIdFromName (pIO->getValStr("tx_b"));
dt.BorderIds[TextBR]= rVR.getTextureIdFromName (pIO->getValStr("tx_br"));
// Tile
dt.TileBorder[TextTM] = (uint8)pIO->getValSInt32("tile_t");
dt.TileBorder[TextML] = (uint8)pIO->getValSInt32("tile_l");
dt.TileBorder[TextMM] = (uint8)pIO->getValSInt32("tile_blank");
dt.TileBorder[TextMR] = (uint8)pIO->getValSInt32("tile_r");
dt.TileBorder[TextBM] = (uint8)pIO->getValSInt32("tile_b");
dt.BorderIds[TextBL]= rVR.getTextureIdFromName ("w_modal_bl.tga");
dt.BorderIds[TextBM]= rVR.getTextureIdFromName ("w_modal_b.tga");
dt.BorderIds[TextBR]= rVR.getTextureIdFromName ("w_modal_br.tga");
// get size
rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder);
rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder);
_DispTypes.push_back(dt);
}
_DispType = (uint8)i;
}
else
{
_DispType = 0;
}
return true;
}
// ***************************************************************************
void CGroupFrame::draw ()
{
if (_DisplayFrame)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
// get global color
CRGBA col;
if(getModulateGlobalColor())
col.modulateFromColor( _Color, CWidgetManager::getInstance()->getGlobalColor() );
else
col= _Color;
// draw the background
sint xId = 0, yId = 0;
for (yId = 0; yId < 3; yId++)
if (pIO != NULL)
{
for (xId = 0; xId < 3; xId++)
_DispTypeDefined= true;
// Look if we find the type...
uint32 i;
for (i = 0; i < _DispTypes.size(); ++i)
if (_DispTypes[i].Name == string((const char*)ptr))
break;
if (i == _DispTypes.size())
{
sint32 x = _XReal;
sint32 y = _YReal;
sint32 w, h;
// top
if (yId == 0)
{
y += _HReal-_DispTypes[_DispType].TopBorder;
h = _DispTypes[_DispType].TopBorder;
}
// Middle
else if (yId == 1)
{
y += _DispTypes[_DispType].BottomBorder;
h = _HReal-_DispTypes[_DispType].TopBorder-_DispTypes[_DispType].BottomBorder;
}
// Bottom
else
{
h = _DispTypes[_DispType].BottomBorder;
}
SDisplayType dt;
dt.Name = string((const char*)ptr);
// get texture ids.
dt.BorderIds[TextTL]= rVR.getTextureIdFromName (pIO->getValStr("tx_tl"));
dt.BorderIds[TextTM]= rVR.getTextureIdFromName (pIO->getValStr("tx_t"));
dt.BorderIds[TextTR]= rVR.getTextureIdFromName (pIO->getValStr("tx_tr"));
// middle
dt.BorderIds[TextML]= rVR.getTextureIdFromName (pIO->getValStr("tx_l"));
dt.BorderIds[TextMM]= rVR.getTextureIdFromName (pIO->getValStr("tx_blank"));
dt.BorderIds[TextMR]= rVR.getTextureIdFromName (pIO->getValStr("tx_r"));
// bottom
dt.BorderIds[TextBL]= rVR.getTextureIdFromName (pIO->getValStr("tx_bl"));
dt.BorderIds[TextBM]= rVR.getTextureIdFromName (pIO->getValStr("tx_b"));
dt.BorderIds[TextBR]= rVR.getTextureIdFromName (pIO->getValStr("tx_br"));
// Left
if (xId == 0)
{
w = _DispTypes[_DispType].LeftBorder;
}
else if (xId == 1)
{
x += _DispTypes[_DispType].LeftBorder;
w = _WReal-_DispTypes[_DispType].LeftBorder-_DispTypes[_DispType].RightBorder;
}
else
{
x += _WReal-_DispTypes[_DispType].RightBorder;
w = _DispTypes[_DispType].RightBorder;
}
// Tile
dt.TileBorder[TextTM] = (uint8)pIO->getValSInt32("tile_t");
dt.TileBorder[TextML] = (uint8)pIO->getValSInt32("tile_l");
dt.TileBorder[TextMM] = (uint8)pIO->getValSInt32("tile_blank");
dt.TileBorder[TextMR] = (uint8)pIO->getValSInt32("tile_r");
dt.TileBorder[TextBM] = (uint8)pIO->getValSInt32("tile_b");
// render
uint8 tile = _DispTypes[_DispType].TileBorder[yId*3+xId];
if (tile == 0)
rVR.drawRotFlipBitmap (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], col);
else
rVR.drawRotFlipBitmapTiled (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], tile-1, col);
// get size
rVR.getTextureSizeFromId (dt.BorderIds[TextTL], dt.LeftBorder, dt.TopBorder);
rVR.getTextureSizeFromId (dt.BorderIds[TextBR], dt.RightBorder, dt.BottomBorder);
_DispTypes.push_back(dt);
}
_DispType = (uint8)i;
}
else
{
_DispType = 0;
}
return true;
}
// ***************************************************************************
void CGroupFrame::draw ()
{
if (_DisplayFrame)
{
CViewRenderer &rVR = *CViewRenderer::getInstance();
// get global color
CRGBA col;
if(getModulateGlobalColor())
col.modulateFromColor( _Color, CWidgetManager::getInstance()->getGlobalColor() );
else
col= _Color;
// draw the background
sint xId = 0, yId = 0;
for (yId = 0; yId < 3; yId++)
{
for (xId = 0; xId < 3; xId++)
{
sint32 x = _XReal;
sint32 y = _YReal;
sint32 w, h;
// top
if (yId == 0)
{
y += _HReal-_DispTypes[_DispType].TopBorder;
h = _DispTypes[_DispType].TopBorder;
}
// Middle
else if (yId == 1)
{
y += _DispTypes[_DispType].BottomBorder;
h = _HReal-_DispTypes[_DispType].TopBorder-_DispTypes[_DispType].BottomBorder;
}
// Bottom
else
{
h = _DispTypes[_DispType].BottomBorder;
}
// Left
if (xId == 0)
{
w = _DispTypes[_DispType].LeftBorder;
}
else if (xId == 1)
{
x += _DispTypes[_DispType].LeftBorder;
w = _WReal-_DispTypes[_DispType].LeftBorder-_DispTypes[_DispType].RightBorder;
}
else
{
x += _WReal-_DispTypes[_DispType].RightBorder;
w = _DispTypes[_DispType].RightBorder;
}
// render
uint8 tile = _DispTypes[_DispType].TileBorder[yId*3+xId];
if (tile == 0)
rVR.drawRotFlipBitmap (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], col);
else
rVR.drawRotFlipBitmapTiled (_RenderLayer, x, y, w, h, 0, false, _DispTypes[_DispType].BorderIds[yId*3+xId], tile-1, col);
}
}
}
// draw the components
CInterfaceGroup::draw();
}
// draw the components
CInterfaceGroup::draw();
// ***************************************************************************
void CGroupFrame::copyOptionFrom(const CGroupFrame &other)
{
CInterfaceGroup::copyOptionFrom(other);
// Copy option only if they were not explicitly defined in xml
if(!_DisplayFrameDefined)
_DisplayFrame = other._DisplayFrame;
if(!_ColorDefined)
_Color = other._Color;
if(!_DispTypeDefined)
_DispType = other._DispType;
}
// ***************************************************************************
void CGroupFrame::setColorAsString(const string & col)
{
_Color = convertColor (col.c_str());
}
// ***************************************************************************
string CGroupFrame::getColorAsString() const
{
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
}
}
// ***************************************************************************
void CGroupFrame::copyOptionFrom(const CGroupFrame &other)
{
CInterfaceGroup::copyOptionFrom(other);
// Copy option only if they were not explicitly defined in xml
if(!_DisplayFrameDefined)
_DisplayFrame = other._DisplayFrame;
if(!_ColorDefined)
_Color = other._Color;
if(!_DispTypeDefined)
_DispType = other._DispType;
}
// ***************************************************************************
void CGroupFrame::setColorAsString(const string & col)
{
_Color = convertColor (col.c_str());
}
// ***************************************************************************
string CGroupFrame::getColorAsString() const
{
return NLMISC::toString(_Color.R) + " " + NLMISC::toString(_Color.G) + " " + NLMISC::toString(_Color.B) + " " + NLMISC::toString(_Color.A);
}

View file

@ -20,156 +20,159 @@
#include "nel/gui/interface_element.h"
#include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/i_xml.h"
using namespace std;
#include "nel/misc/i_xml.h"
NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal");
// ***************************************************************************
CGroupModal::CGroupModal(const TCtorParam &param)
: CGroupFrame(param)
namespace NLGUI
{
SpawnOnMousePos= true;
ExitClickOut= true;
ExitClickL= false;
ExitClickR= false;
ExitKeyPushed = false;
ForceInsideScreen= false;
SpawnMouseX= SpawnMouseY= 0;
_MouseDeltaX= _MouseDeltaY= 0;
//By default, modal are escapable
_Escapable= true;
}
NLMISC_REGISTER_OBJECT(CViewBase, CGroupModal, std::string, "modal");
// ***************************************************************************
bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CGroupFrame::parse(cur, parentGroup))
return false;
// read modal option
CXMLAutoPtr prop;
prop = xmlGetProp (cur, (xmlChar*)"mouse_pos");
if ( prop ) SpawnOnMousePos= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_out");
if ( prop ) ExitClickOut= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_l");
if ( prop ) ExitClickL= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_r");
if ( prop ) ExitClickR= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_b");
if ( prop ) ExitClickR= ExitClickL= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"force_inside_screen");
if ( prop ) ForceInsideScreen= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"category");
if ( prop ) Category= (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onclick_out");
if ( prop ) OnClickOut = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onclick_out_params");
if ( prop ) OnClickOutParams = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out");
if ( prop ) OnPostClickOut = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out_params");
if ( prop ) OnPostClickOutParams = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"exit_key_pushed");
if ( prop ) ExitKeyPushed= convertBool(prop);
// Force parent hotspot for spawn on mouse
if(SpawnOnMousePos)
setParentPosRef(Hotspot_BL);
// bkup x/y as the deltas.
_MouseDeltaX= getX();
_MouseDeltaY= getY();
// Modals are disabled by default
_Active = false;
return true;
}
// ***************************************************************************
void CGroupModal::updateCoords ()
{
// if snap to mouse pos.
if(SpawnOnMousePos)
// ***************************************************************************
CGroupModal::CGroupModal(const TCtorParam &param)
: CGroupFrame(param)
{
// Special for menu for instance: If the size is bigger or equal to the screen, keep 0, because will be clipped just after
CViewRenderer &rVR = *CViewRenderer::getInstance();
uint32 w,h;
rVR.getScreenSize(w,h);
if(_W>=(sint32)w && _H>=(sint32)h)
SpawnOnMousePos= true;
ExitClickOut= true;
ExitClickL= false;
ExitClickR= false;
ExitKeyPushed = false;
ForceInsideScreen= false;
SpawnMouseX= SpawnMouseY= 0;
_MouseDeltaX= _MouseDeltaY= 0;
//By default, modal are escapable
_Escapable= true;
}
// ***************************************************************************
bool CGroupModal::parse (xmlNodePtr cur, CInterfaceGroup *parentGroup)
{
if(!CGroupFrame::parse(cur, parentGroup))
return false;
// read modal option
CXMLAutoPtr prop;
prop = xmlGetProp (cur, (xmlChar*)"mouse_pos");
if ( prop ) SpawnOnMousePos= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_out");
if ( prop ) ExitClickOut= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_l");
if ( prop ) ExitClickL= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_r");
if ( prop ) ExitClickR= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"exit_click_b");
if ( prop ) ExitClickR= ExitClickL= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"force_inside_screen");
if ( prop ) ForceInsideScreen= convertBool(prop);
prop = xmlGetProp (cur, (xmlChar*)"category");
if ( prop ) Category= (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onclick_out");
if ( prop ) OnClickOut = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onclick_out_params");
if ( prop ) OnClickOutParams = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out");
if ( prop ) OnPostClickOut = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"onpostclick_out_params");
if ( prop ) OnPostClickOutParams = (const char *) prop;
prop = xmlGetProp (cur, (xmlChar*)"exit_key_pushed");
if ( prop ) ExitKeyPushed= convertBool(prop);
// Force parent hotspot for spawn on mouse
if(SpawnOnMousePos)
setParentPosRef(Hotspot_BL);
// bkup x/y as the deltas.
_MouseDeltaX= getX();
_MouseDeltaY= getY();
// Modals are disabled by default
_Active = false;
return true;
}
// ***************************************************************************
void CGroupModal::updateCoords ()
{
// if snap to mouse pos.
if(SpawnOnMousePos)
{
_X= _Y= 0;
// Special for menu for instance: If the size is bigger or equal to the screen, keep 0, because will be clipped just after
CViewRenderer &rVR = *CViewRenderer::getInstance();
uint32 w,h;
rVR.getScreenSize(w,h);
if(_W>=(sint32)w && _H>=(sint32)h)
{
_X= _Y= 0;
}
else
{
// change coords
_X= SpawnMouseX+_MouseDeltaX;
_Y= SpawnMouseY+_MouseDeltaY;
}
}
else
// update group
CGroupFrame::updateCoords();
// if snap to mouse pos or ForceInsideScreen
if(SpawnOnMousePos || ForceInsideScreen)
{
// change coords
_X= SpawnMouseX+_MouseDeltaX;
_Y= SpawnMouseY+_MouseDeltaY;
bool clipped = false;
// repos the group according to real size. clip against screen
if(_XReal<0)
{
_X+= -_XReal;
clipped = true;
}
else
{
if (!SpawnOnMousePos)
_X = _MouseDeltaX;
}
if(_XReal+_WReal>_Parent->getW())
{
_X-= _XReal+_WReal-_Parent->getW();
clipped =true;
}
else
{
if ((!SpawnOnMousePos) && (_XReal>=0))
_X = _MouseDeltaX;
}
if(_YReal<0)
{
_Y+= -_YReal;
clipped =true;
}
else
{
if (!SpawnOnMousePos)
_Y = _MouseDeltaY;
}
if(_YReal+_HReal>_Parent->getH())
{
_Y-= _YReal+_HReal-_Parent->getH();
clipped =true;
}
else
{
if ((!SpawnOnMousePos) && (_YReal>=0))
_Y = _MouseDeltaY;
}
if (clipped)
{
CGroupFrame::updateCoords();
}
}
}
// update group
CGroupFrame::updateCoords();
// if snap to mouse pos or ForceInsideScreen
if(SpawnOnMousePos || ForceInsideScreen)
{
bool clipped = false;
// repos the group according to real size. clip against screen
if(_XReal<0)
{
_X+= -_XReal;
clipped = true;
}
else
{
if (!SpawnOnMousePos)
_X = _MouseDeltaX;
}
if(_XReal+_WReal>_Parent->getW())
{
_X-= _XReal+_WReal-_Parent->getW();
clipped =true;
}
else
{
if ((!SpawnOnMousePos) && (_XReal>=0))
_X = _MouseDeltaX;
}
if(_YReal<0)
{
_Y+= -_YReal;
clipped =true;
}
else
{
if (!SpawnOnMousePos)
_Y = _MouseDeltaY;
}
if(_YReal+_HReal>_Parent->getH())
{
_Y-= _YReal+_HReal-_Parent->getH();
clipped =true;
}
else
{
if ((!SpawnOnMousePos) && (_YReal>=0))
_Y = _MouseDeltaY;
}
if (clipped)
{
CGroupFrame::updateCoords();
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,103 +23,106 @@
using namespace std;
using namespace NLMISC;
// ***************************************************************************
const CInterfaceOptionValue CInterfaceOptionValue::NullValue;
// ***************************************************************************
void CInterfaceOptionValue::init(const std::string &str)
namespace NLGUI
{
_Str= str;
fromString(str, _Int);
fromString(str, _Float);
_Color= CInterfaceElement::convertColor (str.c_str());
_Boolean= CInterfaceElement::convertBool(str.c_str());
}
const CInterfaceOptionValue CInterfaceOptionValue::NullValue;
// ----------------------------------------------------------------------------
// CInterfaceOptions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
CInterfaceOptions::CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
CInterfaceOptions::~CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
bool CInterfaceOptions::parse (xmlNodePtr cur)
{
cur = cur->children;
bool ok = true;
while (cur)
// ***************************************************************************
void CInterfaceOptionValue::init(const std::string &str)
{
if ( !stricmp((char*)cur->name,"param") )
{
CXMLAutoPtr ptr, val;
ptr = xmlGetProp (cur, (xmlChar*)"name");
val = xmlGetProp (cur, (xmlChar*)"value");
if (!ptr || !val)
{
nlinfo("param with no name or no value");
ok = false;
}
else
{
string name = NLMISC::toLower(string((const char*)ptr));
string value = (string((const char*)val));
_ParamValue[name].init(value);
}
}
cur = cur->next;
_Str= str;
fromString(str, _Int);
fromString(str, _Float);
_Color= CInterfaceElement::convertColor (str.c_str());
_Boolean= CInterfaceElement::convertBool(str.c_str());
}
return ok;
}
// ***************************************************************************
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
{
_ParamValue= other._ParamValue;
}
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
string sLwrParamName = strlwr (sParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
if (it != _ParamValue.end())
return it->second;
else
return CInterfaceOptionValue::NullValue;
}
// ----------------------------------------------------------------------------
// CInterfaceOptions
// ----------------------------------------------------------------------------
// ***************************************************************************
const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const
{
return getValue(sParamName).getValStr();
}
// ***************************************************************************
sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const
{
return getValue(sParamName).getValSInt32();
}
// ***************************************************************************
float CInterfaceOptions::getValFloat(const std::string &sParamName) const
{
return getValue(sParamName).getValFloat();
}
// ***************************************************************************
NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const
{
return getValue(sParamName).getValColor();
}
// ***************************************************************************
bool CInterfaceOptions::getValBool(const std::string &sParamName) const
{
return getValue(sParamName).getValBool();
}
// ----------------------------------------------------------------------------
CInterfaceOptions::CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
CInterfaceOptions::~CInterfaceOptions()
{
}
// ----------------------------------------------------------------------------
bool CInterfaceOptions::parse (xmlNodePtr cur)
{
cur = cur->children;
bool ok = true;
while (cur)
{
if ( !stricmp((char*)cur->name,"param") )
{
CXMLAutoPtr ptr, val;
ptr = xmlGetProp (cur, (xmlChar*)"name");
val = xmlGetProp (cur, (xmlChar*)"value");
if (!ptr || !val)
{
nlinfo("param with no name or no value");
ok = false;
}
else
{
string name = NLMISC::toLower(string((const char*)ptr));
string value = (string((const char*)val));
_ParamValue[name].init(value);
}
}
cur = cur->next;
}
return ok;
}
// ***************************************************************************
void CInterfaceOptions::copyBasicMap(const CInterfaceOptions &other)
{
_ParamValue= other._ParamValue;
}
// ***************************************************************************
const CInterfaceOptionValue &CInterfaceOptions::getValue(const string &sParamName) const
{
string sLwrParamName = strlwr (sParamName);
std::map<std::string, CInterfaceOptionValue>::const_iterator it = _ParamValue.find (sLwrParamName);
if (it != _ParamValue.end())
return it->second;
else
return CInterfaceOptionValue::NullValue;
}
// ***************************************************************************
const std::string &CInterfaceOptions::getValStr(const std::string &sParamName) const
{
return getValue(sParamName).getValStr();
}
// ***************************************************************************
sint32 CInterfaceOptions::getValSInt32(const std::string &sParamName) const
{
return getValue(sParamName).getValSInt32();
}
// ***************************************************************************
float CInterfaceOptions::getValFloat(const std::string &sParamName) const
{
return getValue(sParamName).getValFloat();
}
// ***************************************************************************
NLMISC::CRGBA CInterfaceOptions::getValColor(const std::string &sParamName) const
{
return getValue(sParamName).getValColor();
}
// ***************************************************************************
bool CInterfaceOptions::getValBool(const std::string &sParamName) const
{
return getValue(sParamName).getValBool();
}
}

View file

@ -18,27 +18,32 @@
#include "nel/gui/interface_group.h"
#include "nel/gui/widget_manager.h"
CViewBase::~CViewBase()
namespace NLGUI
{
CWidgetManager::getInstance()->removeRefOnView (this);
}
// ***************************************************************************
void CViewBase::dumpSize(uint depth /*=0*/) const
{
std::string result;
result.resize(depth * 4, ' ');
std::string::size_type pos = _Id.find_last_of(':');
std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos);
result += NLMISC::toString("id=%s, w=%d, h=%d, x=%d, y=%d, wreal=%d, hreal=%d, xreal=%d, yreal=%d", shortID.c_str(), (int) _W, (int) _H, (int) _X, (int) _Y, (int) _WReal, (int) _HReal, (int) _XReal, (int) _YReal);
nlinfo(result.c_str());
}
// ***************************************************************************
void CViewBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitView(this);
CInterfaceElement::visit(visitor);
CViewBase::~CViewBase()
{
CWidgetManager::getInstance()->removeRefOnView (this);
}
// ***************************************************************************
void CViewBase::dumpSize(uint depth /*=0*/) const
{
std::string result;
result.resize(depth * 4, ' ');
std::string::size_type pos = _Id.find_last_of(':');
std::string shortID = pos == std::string::npos ? _Id : _Id.substr(pos);
result += NLMISC::toString("id=%s, w=%d, h=%d, x=%d, y=%d, wreal=%d, hreal=%d, xreal=%d, yreal=%d", shortID.c_str(), (int) _W, (int) _H, (int) _X, (int) _Y, (int) _WReal, (int) _HReal, (int) _XReal, (int) _YReal);
nlinfo(result.c_str());
}
// ***************************************************************************
void CViewBase::visit(CInterfaceElementVisitor *visitor)
{
nlassert(visitor);
visitor->visitView(this);
CInterfaceElement::visit(visitor);
}
}

View file

@ -1,122 +1,142 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/view_pointer_base.h"
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
CViewBase( param )
namespace NLGUI
{
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerDown = false;
_PointerVisible = true;
}
CViewPointerBase::~CViewPointerBase()
{
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
{
if (_PointerDown)
CViewPointerBase::CViewPointerBase( const CViewBase::TCtorParam &param ) :
CViewBase( param )
{
if (!_PointerDrag)
_PointerX = _PointerY = _PointerOldX = _PointerOldY = _PointerDownX = _PointerDownY = 0;
_PointerDown = false;
_PointerVisible = true;
}
CViewPointerBase::~CViewPointerBase()
{
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerPos (sint32 x, sint32 y)
{
if (_PointerDown)
{
if (((_PointerX - _PointerDownX) != 0) ||
((_PointerY - _PointerDownY) != 0))
if (!_PointerDrag)
{
_PointerDrag = true;
if (((_PointerX - _PointerDownX) != 0) ||
((_PointerY - _PointerDownY) != 0))
{
_PointerDrag = true;
}
}
}
_PointerOldX = getX();
_PointerOldY = getY();
_PointerX = x;
_PointerY = y;
}
_PointerOldX = getX();
_PointerOldY = getY();
_PointerX = x;
_PointerY = y;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
{
setX (x);
setY (y);
updateCoords ();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::resetPointerPos ()
{
_PointerOldX = _PointerX;
_PointerOldY = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDown (bool pd)
{
_PointerDown = pd;
if (_PointerDown == true)
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDispPos (sint32 x, sint32 y)
{
_PointerDownX = _PointerX;
_PointerDownY = _PointerY;
setX (x);
setY (y);
updateCoords ();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::resetPointerPos ()
{
_PointerOldX = _PointerX;
_PointerOldY = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDown (bool pd)
{
_PointerDown = pd;
if (_PointerDown == true)
{
_PointerDownX = _PointerX;
_PointerDownY = _PointerY;
}
if (_PointerDown == false)
_PointerDrag = false;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s)
{
_PointerDownString = s;
}
// +++ GET +++
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
{
x = _PointerX;
y = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
{
x = getX();
y = getY();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
{
x = _PointerOldX;
y = _PointerOldY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
{
x = _PointerDownX;
y = _PointerDownY;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDown ()
{
return _PointerDown;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDrag ()
{
return _PointerDrag;
}
// --------------------------------------------------------------------------------------------------------------------
std::string CViewPointerBase::getPointerDownString ()
{
return _PointerDownString;
}
if (_PointerDown == false)
_PointerDrag = false;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::setPointerDownString (const std::string &s)
{
_PointerDownString = s;
}
// +++ GET +++
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerPos (sint32 &x, sint32 &y)
{
x = _PointerX;
y = _PointerY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDispPos (sint32 &x, sint32 &y)
{
x = getX();
y = getY();
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerOldPos (sint32 &x, sint32 &y)
{
x = _PointerOldX;
y = _PointerOldY;
}
// --------------------------------------------------------------------------------------------------------------------
void CViewPointerBase::getPointerDownPos (sint32 &x, sint32 &y)
{
x = _PointerDownX;
y = _PointerDownY;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDown ()
{
return _PointerDown;
}
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointerBase::getPointerDrag ()
{
return _PointerDrag;
}
// --------------------------------------------------------------------------------------------------------------------
std::string CViewPointerBase::getPointerDownString ()
{
return _PointerDownString;
}

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@
using namespace NLMISC;
using namespace NL3D;
using namespace NLGUI;
// TODO nico : that stuff was coded in a hurry, but could be good to add it to NL3D with a better packaging later...

View file

@ -33,6 +33,8 @@ using namespace NL3D;
#include "../user_entity.h"
#include "../connection.h"
using namespace NLGUI;
////////////
// GLOBAL //
////////////

View file

@ -23,7 +23,10 @@
#include "nel/gui/action_handler.h"
#include "interface_manager.h"
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceGroup;
}
// ***************************************************************************

View file

@ -22,7 +22,11 @@
class CBotChatPage;
class CPrerequisitInfos;
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceGroup;
}
class IMissionPrereqInfosWaiter
{

View file

@ -21,7 +21,11 @@
#include "nel/misc/rgba.h"
class CViewBase;
namespace NLGUI
{
class CViewBase;
}
class ucstring;
namespace NLMISC{
class CCDBNodeLeaf;
@ -46,7 +50,7 @@ public:
* \param col the color of the text
* \param justified Should be true for justified text (stretch spaces of line to fill the full width)
*/
CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false);
NLGUI::CViewBase *createMsgText(const ucstring &msg, NLMISC::CRGBA col, bool justified = false);
// Singleton access
static CChatTextManager &getInstance();

View file

@ -24,10 +24,15 @@
#include "game_share/chat_group.h"
namespace NLGUI
{
class CCtrlBase;
}
class CChatWindow;
class CGroupContainer;
class CGroupEditBox;
class CCtrlBase;
class CViewText;
/** Interface to react to a chat box entry
@ -240,7 +245,7 @@ public:
// Remove a chat window by its pointer
void removeChatWindow(CChatWindow *cw);
/// from a ctrl of a chat box that triggered a menu, or an event, retrieve the associated chat box
CChatWindow *getChatWindowFromCaller(CCtrlBase *caller);
CChatWindow *getChatWindowFromCaller(NLGUI::CCtrlBase *caller);
// Singleton pattern applied to the chat window manager
static CChatWindowManager &getInstance();
// try to rename a window

View file

@ -22,7 +22,11 @@
class CDBCtrlSheet;
class IActionHandler;
namespace NLGUI
{
class IActionHandler;
}
/** Infos about a selection group
*/

View file

@ -107,10 +107,6 @@
#include "../npc_icon.h"
#include "nel/gui/lua_helper.h"
namespace NLGUI
{
extern void luaDebuggerMainLoop();
}
using namespace NLGUI;
#include "nel/gui/lua_ihm.h"
#include "lua_ihm_ryzom.h"
@ -128,9 +124,14 @@ using namespace NLGUI;
using namespace NLMISC;
namespace NLGUI
{
extern void luaDebuggerMainLoop();
extern NLMISC::CStringMapper *_UIStringMapper;
}
extern CClientChatManager ChatMngr;
extern CContinentManager ContinentMngr;
extern CStringMapper *_UIStringMapper;
extern bool IsInRingSession;
extern CEventsListener EventsListener;

View file

@ -69,8 +69,12 @@ extern bool g_hidden;
// #define AJM_DEBUG_TRACK_INTERFACE_GROUPS
namespace NLGUI
{
class CInterfaceOptions;
}
class CGroupContainer;
class CInterfaceOptions;
class CInterfaceAnim;
class CGroupMenu;

View file

@ -20,6 +20,8 @@
#include "nel/gui/interface_options.h"
using namespace NLGUI;
// ***************************************************************************
class COptionsLayer : public CInterfaceOptions
{

View file

@ -29,17 +29,20 @@
#include "nel/gui/widget_manager.h"
using namespace NLGUI;
// ***************************************************************************
class CInterfaceElement;
class CInterfaceGroup;
namespace NLGUI
{
class CInterfaceElement;
class CInterfaceGroup;
class CInterfaceOptions;
class CInterfaceLink;
class CCtrlBase;
}
class CGroupContainer;
class CGroupList;
class CInterfaceOptions;
class CInterfaceAnim;
class CViewPointer;
class CInterfaceLink;
class CBrickJob;
class CCtrlBase;
// ***************************************************************************
/**

View file

@ -21,7 +21,16 @@
#include "nel/misc/resource_ptr.h"
class CInterfaceElement *getInterfaceResource(const std::string &key);
namespace NLGUI
{
class CInterfaceElement;
class CCtrlBase;
class CInterfaceGroup;
}
using namespace NLGUI;
CInterfaceElement *getInterfaceResource(const std::string &key);
/** Interface element ptr
* This pointer uses the NLMISC::CResourcePtr
@ -47,13 +56,12 @@ public:
};
// Some pointers
typedef CInterfacePtr<class CInterfaceElement>::TInterfacePtr CInterfaceElementPtr;
typedef CInterfacePtr<class CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr;
typedef CInterfacePtr<CInterfaceElement>::TInterfacePtr CInterfaceElementPtr;
typedef CInterfacePtr<CInterfaceGroup>::TInterfacePtr CInterfaceGroupPtr;
typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr;
typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<class CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr;

View file

@ -24,7 +24,11 @@
#include "nel/gui/view_pointer_base.h"
class CGroupContainer;
class CCtrlBase;
namespace NLGUI
{
class CCtrlBase;
}
/**
* class describing the pointer

View file

@ -38,7 +38,7 @@ class CObjectTable;
* - one for the ui (displaying instance in the object tree for example)
* - one for the property sheet of the instance
*/
class CDisplayerBase : public NLMISC::IClassable, public CReflectableRefPtrTarget
class CDisplayerBase : public NLMISC::IClassable, public NLGUI::CReflectableRefPtrTarget
{
public:
typedef NLMISC::CSmartPtr<CDisplayerBase> TSmartPtr;