diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index 1c339fef8..7f6402238 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -293,6 +293,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS) ### OPTION(WITH_NET "Build NLNET" ON ) OPTION(WITH_3D "Build NL3D" ON ) + OPTION(WITH_GUI "Build GUI" ON ) OPTION(WITH_PACS "Build NLPACS" ON ) OPTION(WITH_GEORGES "Build NLGEORGES" ON ) OPTION(WITH_LIGO "Build NLLIGO" ON ) diff --git a/code/nel/include/nel/CMakeLists.txt b/code/nel/include/nel/CMakeLists.txt index 874073eb7..5f2bca43c 100644 --- a/code/nel/include/nel/CMakeLists.txt +++ b/code/nel/include/nel/CMakeLists.txt @@ -1,33 +1,37 @@ -SUBDIRS(misc) - -IF(WITH_3D) - SUBDIRS(3d) -ENDIF(WITH_3D) - -IF(WITH_GEORGES) - SUBDIRS(georges) -ENDIF(WITH_GEORGES) - -IF(WITH_LIGO) - SUBDIRS(ligo) -ENDIF(WITH_LIGO) - -IF(WITH_LOGIC) - SUBDIRS(logic) -ENDIF(WITH_LOGIC) - -IF(WITH_NET) - SUBDIRS(net) -ENDIF(WITH_NET) - -IF(WITH_SOUND) - SUBDIRS(sound) -ENDIF(WITH_SOUND) - -IF(WITH_PACS) - SUBDIRS(pacs) -ENDIF(WITH_PACS) - -IF(WITH_NEL_CEGUI) - SUBDIRS(cegui) -ENDIF(WITH_NEL_CEGUI) +SUBDIRS(misc) + +IF(WITH_3D) + SUBDIRS(3d) +ENDIF(WITH_3D) + +IF(WITH_GUI) + ADD_SUBDIRECTORY(gui) +ENDIF(WITH_GUI) + +IF(WITH_GEORGES) + SUBDIRS(georges) +ENDIF(WITH_GEORGES) + +IF(WITH_LIGO) + SUBDIRS(ligo) +ENDIF(WITH_LIGO) + +IF(WITH_LOGIC) + SUBDIRS(logic) +ENDIF(WITH_LOGIC) + +IF(WITH_NET) + SUBDIRS(net) +ENDIF(WITH_NET) + +IF(WITH_SOUND) + SUBDIRS(sound) +ENDIF(WITH_SOUND) + +IF(WITH_PACS) + SUBDIRS(pacs) +ENDIF(WITH_PACS) + +IF(WITH_NEL_CEGUI) + SUBDIRS(cegui) +ENDIF(WITH_NEL_CEGUI) diff --git a/code/nel/include/nel/gui/CMakeLists.txt b/code/nel/include/nel/gui/CMakeLists.txt new file mode 100644 index 000000000..ba66d4451 --- /dev/null +++ b/code/nel/include/nel/gui/CMakeLists.txt @@ -0,0 +1,3 @@ +FILE(GLOB HEADERS *.h) + +INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers) diff --git a/code/nel/include/nel/gui/action_handler.h b/code/nel/include/nel/gui/action_handler.h new file mode 100644 index 000000000..8f90cb942 --- /dev/null +++ b/code/nel/include/nel/gui/action_handler.h @@ -0,0 +1,153 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef NL_ACTION_HANDLER_H +#define NL_ACTION_HANDLER_H + +#include "nel/misc/types_nl.h" +#include +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/xml_auto_ptr.h" +#include + +namespace NLGUI +{ + + class CCtrlBase; + + + /** + * interface for action handlers + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class IActionHandler + { + public: + // Execute the answer to the action + // Params has the following form : paramName=theParam|paramName2=theParam2|... + virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { } + + virtual ~IActionHandler() {} + + static std::string getParam (const std::string &Params, const std::string &ParamName); + + static void getAllParams (const std::string &Params, std::vector< std::pair > &AllParams); + }; + + + /** + interface for action handlers factory + no release in this factory : a handler must be destroyed by the control that created it + */ + class CAHManager + { + public: + typedef std::map< std::string, IActionHandler* > TFactoryMap; + typedef std::map< IActionHandler*, std::string > TNameMap; + + static CAHManager* getInstance() + { + if (_GlobalInstance == NULL) + _GlobalInstance = new CAHManager; + return _GlobalInstance; + } + + /// return pointer to action handler or null if it doesn't exist + IActionHandler *getActionHandler(const std::string &name) const + { + TFactoryMap::const_iterator it = FactoryMap.find(name); + if( it == FactoryMap.end() ) + { + nlwarning( "Couldn't find action handler %s", name.c_str() ); + return NULL; + } + else + return it->second; + } + + /// Return the name of the action handler given its pointer + const std::string &getActionHandlerName(IActionHandler *pAH) const + { + TNameMap::const_iterator it = NameMap.find(pAH); + return it != NameMap.end() ? it->second : EmptyName; + } + + /// map of action handler factories + TFactoryMap FactoryMap; + TNameMap NameMap; + std::string EmptyName; + + /// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed) + IActionHandler *getAH(const std::string &name, std::string ¶ms); + IActionHandler *getAH(const std::string &name, class CStringShared ¶ms); + + /** 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 ¶ms); + void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared ¶ms); + + /// Get the AH name from ptr + const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); } + + void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") ); + + // Submit a generic event + void submitEvent( const std::string &evt ); + static void setEditorMode( bool b ){ editorMode = b; } + + private: + CAHManager(){} + static CAHManager *_GlobalInstance; + static bool editorMode; + + }; + + /// Ah name must all be lower case + #define REGISTER_ACTION_HANDLER(handler ,name) \ + class handler##Factory : public handler \ + { \ + public: \ + handler##Factory () \ + { \ + nlassert(name!=NULL); \ + const char *c= name; \ + while(*c!='\0') \ + { \ + nlassert(islower(*c) || !isalpha(*c)); \ + c++; \ + } \ + CAHManager *pAHFM = CAHManager::getInstance(); \ + pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \ + pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \ + }; \ + }; \ + handler##Factory handler##FactoryInstance ; \ + \ + + +} + +#endif //NL_ACTION_HANDLER_H diff --git a/code/nel/include/nel/gui/ctrl_base.h b/code/nel/include/nel/gui/ctrl_base.h new file mode 100644 index 000000000..dc8425973 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_base.h @@ -0,0 +1,190 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_BASE_H +#define RZ_CTRL_BASE_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_base.h" +#include "nel/gui/event_descriptor.h" + +namespace NLGUI +{ + class CCtrlBase : public CViewBase + { + public: + + // Tooltip mode + enum TToolTipParentType + { + TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears + TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears + TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies. + TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window + + NumToolTipParentRef + }; + + public: + + /// Constructor + CCtrlBase(const TCtorParam ¶m) : CViewBase(param) + { + _ToolTipInstant= true; + _ToolTipParent= TTCtrl; + // see interface.txt for meaning of auto + _ToolTipParentPosRef= Hotspot_TTAuto; + _ToolTipPosRef= Hotspot_TTAuto; + resizer = false; + } + + /// Destructor + virtual ~CCtrlBase(); + + static std::string tooltipParentToString( TToolTipParentType type ); + static TToolTipParentType stringToToolTipParent( const std::string &str ); + + std::string getProperty( const std::string &name ) const; + + void setProperty( const std::string &name, const std::string &value ); + + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + // special parse + virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup); + + + /// Handle all events (implemented by derived classes) (return true to signal event handled) + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; } + + /// Debug + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + + /// Get the ContextHelp for this control. Default is to return _ContextHelp + virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;} + /// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp. + virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); } + // Get the name of the context help window. Default to "context_help" + virtual std::string getContextHelpWindowName() const; + /// Get the ContextHelp ActionHandler. If "", noop + const std::string &getContextHelpActionHandler() const {return _OnContextHelp;} + /// Get the ContextHelp ActionHandler Params + const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;} + /// true if both are empty + bool emptyContextHelp() const; + // Should return true if the context help should be displayed instantly + bool wantInstantContextHelp() const { return _ToolTipInstant; } + /// Set true if ToolTip should be displayed instantly + void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;} + + /** If ctrl has a non rectangle shape, perform further test to know + * if control should be taken in account for context help + */ + virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; } + + + /// return the type of anchor for the tooltip of this control + TToolTipParentType getToolTipParent() const { return _ToolTipParent;} + const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();} + /// Set the type of anchor for the tooltip of this control + void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; } + void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; } + /// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) + THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;} + THotSpot getToolTipPosRef() const { return _ToolTipPosRef;} + THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;} + THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;} + /// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse) + void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;} + void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;} + + /// replace the default contextHelp + ucstring getDefaultContextHelp() const {return _ContextHelp;} + void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;} + void setOnContextHelp(const std::string &help) {_OnContextHelp= help;} + void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;} + + + + // called when this element or a son has been captured + virtual void elementCaptured(CCtrlBase * /* capturedElement */) {} + + virtual bool isCtrl() const { return true; } + + // Made for CtrlResizer to take the precedence over son controls. + virtual uint getDeltaDepth() const { return 0; } + + // true if this ctrl is capturable (true by default, false for tooltip) + virtual bool isCapturable() const {return true;} + + bool isResizer() const{ return resizer; } + + // from CInterfaceElement + virtual void visit(CInterfaceElementVisitor *visitor); + + /** test if virtual desktop change is possible while this element is captured by the mouse + * Useful for resizers + */ + virtual bool canChangeVirtualDesktop() const { return true; } + + // called when keyboard capture has been lost + virtual void onKeyboardCaptureLost() {} + + REFLECT_EXPORT_START(CCtrlBase, CViewBase) + REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp); + REFLECT_EXPORT_END + + // special for mouse over : return true and fill the name of the cursor to display + virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; } + + virtual void serial(NLMISC::IStream &f); + + uint32 getDepth( CInterfaceGroup *group ); + + protected: + // This is the ContextHelp filled by default in parse() + ucstring _ContextHelp; + CStringShared _OnContextHelp; + CStringShared _OnContextHelpParams; + CStringShared _ToolTipSpecialParent; + TToolTipParentType _ToolTipParent; + bool _ToolTipInstant : 1; + THotSpot _ToolTipParentPosRef : 6; + THotSpot _ToolTipPosRef : 6; + THotSpot _ToolTipParentPosRefAlt : 6; + THotSpot _ToolTipPosRefAlt : 6; + protected: + void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS); + static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child ); + + void mapAHString( const std::string &key, const std::string &value ); + std::string getAHString( const std::string &key ) const; + + static std::map< std::string, std::map< std::string, std::string > > AHCache; + + bool resizer; + }; + +} + +#endif // RZ_VIEW_BASE_H + +/* End of ctrl_base.h */ diff --git a/code/nel/include/nel/gui/ctrl_base_button.h b/code/nel/include/nel/gui/ctrl_base_button.h new file mode 100644 index 000000000..0ba1af0b6 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_base_button.h @@ -0,0 +1,270 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_CTRL_BASE_BUTTON_H +#define NL_CTRL_BASE_BUTTON_H + +#include "nel/gui/ctrl_base.h" +#include "nel/gui/action_handler.h" + +namespace NLGUI +{ + + // *************************************************************************** + /** + * Base Class For Buttons. + * \author Lionel Berenguier + * \author Nevrax France + * \date 2003 + */ + class CCtrlBaseButton : public CCtrlBase + { + + public: + enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount }; + + /// Constructor + CCtrlBaseButton(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual bool handleEvent (const NLGUI::CEventDescriptor& event); + + /// \name Misc + // @{ + void setType (EType t) { _Type = t; } + EType getType() { return _Type; } + std::string getTypeString() const; + void setTypeFromString( const std::string &type ); + + void setClickWhenPushed(bool click) { _ClickWhenPushed = click; } + bool getClickWhenPushed() const { return _ClickWhenPushed; } + + void setPushed (bool state); + bool getPushed () const { return _Pushed; } + + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + // Set half tone mode for the display of frozen buttons. Default is true. + void setFrozenHalfTone(bool enabled); + bool getFrozenHalfTone() const { return _FrozenHalfTone; } + + // if the radio is a radio button, then all radio button are unselected + void unselect(); + // @} + + + /// \name Colors + // @{ + void setColor(NLMISC::CRGBA col) { _ColorNormal = col; } + void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; } + void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; } + + NLMISC::CRGBA getColor() const { return _ColorNormal; } + NLMISC::CRGBA getColorPushed() const { return _ColorPushed; } + NLMISC::CRGBA getColorOver() const { return _ColorOver; } + + // Override because mustupdate 3 states + void setModulateGlobalColorAll(bool state); + void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;} + void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;} + void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;} + + virtual sint32 getAlpha() const { return _ColorNormal.A; } + virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; } + + std::string getColorAsString() const + { return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " + + NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); } + std::string getColorOverAsString() const + { return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " + + NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); } + std::string getColorPushedAsString() const + { return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " + + NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); } + + void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); } + void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); } + void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); } + // @} + + ///\name radio button specific + //@{ + /** Initialize radio button reference + * Advanced: + * NB: must call initRBRef() for radio button if button is created without parse(). + * NB: setParent() must be called before (else assert) + */ + void initRBRef(); + //@} + void initRBRefFromRadioButton(CCtrlBaseButton * pBut); + + + /// \name Handlers + // @{ + // Event part + void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); } + void setActionOnLeftClickParams(const std::string ¶ms) { _AHOnLeftClickStringParams = params; } + void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); } + void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); } + void setParamsOnLeftClick (const std::string ¶msHandlerName) { _AHLeftClickParams = paramsHandlerName; } + void setParamsOnRightClick (const std::string ¶msHandlerName) { _AHRightClickParams = paramsHandlerName; } + void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; } + + // get Event part + std::string _getActionOnOver() const{ return CAHManager::getInstance()->getAHName( _AHOnOver ); } + std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftClick ); } + std::string _getActionOnLeftLongClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftLongClick ); } + std::string _getActionOnDblLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftDblClick ); } + std::string _getActionOnRightClick() const { return CAHManager::getInstance()->getAHName( _AHOnRightClick ); } + std::string _getActionOnClockTick() const { return CAHManager::getInstance()->getAHName( _AHOnClockTick ); } + + IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; } + IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; } + IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; } + std::string _getParamsOnOver() const{ return _AHOverParams.toString(); } + std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); } + const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; } + const std::string &getParamsOnRightClick () const { return _AHRightClickParams; } + const std::string &getParamsOnClockTick () const { return _AHClockTickParams; } + + // run action on left click + void runLeftClickAction(); + + // Context menu accessor/ One for each button + void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; } + void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; } + void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; } + std::string getListMenuLeft () { return _ListMenuLeft.toString(); } + std::string getListMenuRight () { return _ListMenuRight.toString(); } + // @} + + + + int luaRunLeftClickAction(CLuaState &ls); + REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase) + REFLECT_BOOL("pushed", getPushed, setPushed); + REFLECT_STRING("col_normal", getColorAsString, setColorAsString); + REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString); + REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString); + REFLECT_RGBA("col_normal_rgba", getColor, setColor); + REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver); + REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed); + REFLECT_BOOL("frozen", getFrozen, setFrozen); + REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone); + REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick); + REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick); + REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); + REFLECT_EXPORT_END + + protected: + EType _Type; + + // State + bool _Pushed : 1; + bool _Over : 1; + bool _OverWhenPushed : 1; + bool _Frozen : 1; + bool _FrozenHalfTone : 1; + bool _ClickWhenPushed : 1; + bool _ModulateGlobalColorNormal : 1; + bool _ModulateGlobalColorPushed : 1; + bool _ModulateGlobalColorOver : 1; + bool _LeftLongClickHandled : 1; // Is it already handled ? + bool _LeftDblClickHandled : 1; + + + ///\name radio button specific + //@{ + CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference + // There is only one radio button per group that own the reference (the first one) + CCtrlBaseButton **_RBRef; // The pointer onto the reference button + //@} + + + // Colors + NLMISC::CRGBA _ColorNormal; + NLMISC::CRGBA _ColorPushed; + NLMISC::CRGBA _ColorOver; + + ///\name Long click specific + //@{ + sint64 _LeftLongClickDate; // Time we left click down + //@} + + // for double click : last date at which last left click occurred + static sint64 _LastLeftClickDate; + static NLMISC::CRefPtr _LastLeftClickButton; + + ///\name Action Handler + //@{ + IActionHandler *_AHOnOver; + CStringShared _AHOverParams; + std::string _AHOnLeftClickString; + std::string _AHOnLeftClickStringParams; + IActionHandler *_AHOnLeftClick; + CStringShared _AHLeftClickParams; + IActionHandler *_AHOnLeftDblClick; + CStringShared _AHLeftDblClickParams; + IActionHandler *_AHOnRightClick; + CStringShared _AHRightClickParams; + IActionHandler *_AHOnClockTick; + CStringShared _AHClockTickParams; + IActionHandler *_AHOnLeftLongClick; + CStringShared _AHLeftLongClickParams; + //@} + CStringShared _ListMenuLeft; + CStringShared _ListMenuRight; + + // get the colors modulated on request + NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorNormal; + if(_ModulateGlobalColorNormal) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorPushed; + if(_ModulateGlobalColorPushed) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const + { + NLMISC::CRGBA rgba = _ColorOver; + if(_ModulateGlobalColorOver) + rgba.modulateFromColor(rgba, globalColor); + return rgba; + } + + // call it at draw + void updateOver(bool &lastOver); + virtual void elementCaptured(CCtrlBase *capturedElement); + }; + +} + +#endif // NL_CTRL_BASE_BUTTON_H + +/* End of ctrl_base_button.h */ diff --git a/code/nel/include/nel/gui/ctrl_button.h b/code/nel/include/nel/gui/ctrl_button.h new file mode 100644 index 000000000..8ec5c23e9 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_button.h @@ -0,0 +1,108 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_BUTTON_H +#define RZ_CTRL_BUTTON_H + +#include "nel/gui/ctrl_base_button.h" +#include "nel/gui/view_renderer.h" + +namespace NLGUI +{ + class CEventDescriptor; + + /** + * + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CCtrlButton : public CCtrlBaseButton + { + public: + + /// Constructor + CCtrlButton(const TCtorParam ¶m) : CCtrlBaseButton(param) + { + _Scale = false; + _Align = 0; + } + + void setAlignFromString( const std::string &s ); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + // Init part + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */); + + // Display part + virtual void draw(); + + void setTexture (const std::string&name); + void setTexturePushed (const std::string&name); + void setTextureOver (const std::string&name); + + void fitTexture(); + + std::string getTexture () const; + std::string getTexturePushed () const; + std::string getTextureOver() const; + + bool isTextureValid() const { return _TextureIdNormal != -1; } + + // test if the texture must scale + bool getScale() const { return _Scale; } + void setScale(bool scale) { _Scale = scale; } + + + /// \from CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton) + REFLECT_STRING("texture", getTexture, setTexture); + REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed); + REFLECT_STRING("texture_over", getTextureOver, setTextureOver); + REFLECT_BOOL("scale", getScale, setScale); + REFLECT_EXPORT_END + + protected: + + CViewRenderer::CTextureId _TextureIdNormal; + CViewRenderer::CTextureId _TextureIdPushed; + CViewRenderer::CTextureId _TextureIdOver; + + private: + + bool _Scale; + sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1) + }; + +} + +#endif // RZ_CTRL_BUTTON_H + +/* End of ctrl_button.h */ diff --git a/code/nel/include/nel/gui/ctrl_col_pick.h b/code/nel/include/nel/gui/ctrl_col_pick.h new file mode 100644 index 000000000..546aeef60 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_col_pick.h @@ -0,0 +1,110 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_COL_PICK_H +#define RZ_CTRL_COL_PICK_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/ctrl_base.h" + + +namespace NLGUI +{ + + /** + * Class handling a Color Picker + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2003 + */ + class CCtrlColPick : public CCtrlBase + { + + public: + + CCtrlColPick(const TCtorParam ¶m); + ~CCtrlColPick(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + virtual void draw(); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + sint32 getColorR () const { return _ColorSelect.R; } + sint32 getColorG () const { return _ColorSelect.G; } + sint32 getColorB () const { return _ColorSelect.B; } + sint32 getColorA () const { return _ColorSelect.A; } + + void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; } + void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; } + void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; } + void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; } + + + std::string getColor () const; // Get Color Selected + void setColor (const std::string &col); // Set Color Selected + + std::string getColorOver () const; // Get Color Over + void setColorOver (const std::string &col); // Set Color Over + + REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase) + REFLECT_SINT32("r", getColorR, setColorR); + REFLECT_SINT32("g", getColorG, setColorG); + REFLECT_SINT32("b", getColorB, setColorB); + REFLECT_SINT32("a", getColorA, setColorA); + REFLECT_STRING("color", getColor, setColor); + REFLECT_STRING("color_over", getColorOver, setColorOver); + REFLECT_EXPORT_END + + + protected: + + void selectColor (sint32 x, sint32 y); + NLMISC::CRGBA getColor (sint32 x, sint32 y); + + protected: + + bool _MouseDown; + + sint32 _Texture; + + NLMISC::CRGBA _ColorSelect; // Last Color selected + NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer + + std::string _AHOnChange; + std::string _AHOnChangeParams; + + CInterfaceProperty _ColSelR; + CInterfaceProperty _ColSelG; + CInterfaceProperty _ColSelB; + CInterfaceProperty _ColSelA; + }; + +} + + +#endif // RZ_CTRL_COL_PICK_H + +/* End of ctrl_col_pick.h */ + + diff --git a/code/nel/include/nel/gui/ctrl_draggable.h b/code/nel/include/nel/gui/ctrl_draggable.h new file mode 100644 index 000000000..de2432137 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_draggable.h @@ -0,0 +1,64 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef CTRL_DRAGGABLE_H +#define CTRL_DRAGGABLE_H + +#include "nel/gui/ctrl_base.h" + +namespace NLGUI +{ + + class CCtrlDraggable : public CCtrlBase + { + public: + DECLARE_UI_CLASS( CCtrlDraggable ) + + CCtrlDraggable( const TCtorParam ¶m ); + virtual ~CCtrlDraggable(){}; + + static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; } + bool isDragged() const{ return dragged; } + void setDragged( bool dragged ){ this->dragged = dragged; } + bool isDraggable() const{ return draggable; } + void setDraggable( bool draggable ){ this->draggable = draggable; } + + void abortDragging() + { + dragged = false; + _LastDraggedSheet = NULL; + } + + // Necessary because of reflection, no other purpose + void draw(){} + + REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) + REFLECT_BOOL("dragable", isDraggable, setDraggable); + REFLECT_EXPORT_END + + protected: + static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; } + + private: + static CCtrlDraggable *_LastDraggedSheet; + bool dragged; + bool draggable; + }; + +} + +#endif diff --git a/code/nel/include/nel/gui/ctrl_polygon.h b/code/nel/include/nel/gui/ctrl_polygon.h new file mode 100644 index 000000000..dc785e250 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_polygon.h @@ -0,0 +1,94 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef RZ_CTRL_POLYGON_H +#define RZ_CTRL_POLYGON_H + +#include "nel/gui/ctrl_base.h" +#include "nel/gui/view_renderer.h" +#include "nel/misc/geom_ext.h" +#include "nel/misc/polygon.h" + +namespace NLMISC +{ + class CVector2f; +} + +namespace NLGUI +{ + + /** Display of an arbitrary polygon in the ui. + * polygons are clipped & batched. + * + * Derives from CCtrlBase in order to provide button / tooltip capability + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 1/2006 + */ + class CCtrlPolygon : public CCtrlBase + { + public: + CCtrlPolygon(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords(); + virtual void draw(); + /** Change the vertices. This is costly because concav / complex polys are split in a list of triangles + */ + void setVertices(const std::vector &vertices); + const std::vector &getVertices() const { return _Poly.Vertices; } + // test if current position in inside the current (transformed) poly (in window space) + bool contains(const NLMISC::CVector2f &pos) const; + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha(sint32 a); + /** Change the matrix for this poly. Changing the matrix is usually cheaper than changing + * The vertices because complex poly do not have to be split again + */ + //void setMatrix(const NLMISC::CMatrix &mat); + //const NLMISC::CMatrix &getMatrix() const { return _Matrix; } + // test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself) + bool isValid() const { return _Valid; } + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + // no capturable by default (just tooltip capability wanted) + virtual bool isCapturable() const { return false; } + private: + NLMISC::CPolygon _Poly; + NLMISC::CPolygon2D _XFormPoly; + //NLMISC::CMatrix _Matrix; + bool _Valid; + bool _Touched; + NLMISC::CRGBA _Color; + std::vector _Tris; + std::vector _RealTris; // clipped tris in screen coordinates + private: + void updateBoudingRect(); + protected: + // TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ... + virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src); + public: + void touch(); + }; + +} + + +#endif diff --git a/code/nel/include/nel/gui/ctrl_quad.h b/code/nel/include/nel/gui/ctrl_quad.h new file mode 100644 index 000000000..2be7b5b94 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_quad.h @@ -0,0 +1,116 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef RZ_CTRL_QUAD_H +#define RZ_CTRL_QUAD_H + +#include "nel/gui/ctrl_base.h" +#include "nel/gui/view_renderer.h" +#include "nel/misc/geom_ext.h" + +namespace NLGUI +{ + + /** Display of an arbitrary textured quad in the UI. The applied texture is filtered. + * Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates + * are driven by the quad vertices coordinates (see setQuad). + * + * Derives from CCtrlBase for tooltipping support + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 12/2005 + */ + class CCtrlQuad : public CCtrlBase + { + public: + enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount }; + + + CCtrlQuad(); + + // from CInterfaceElement + bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup); + virtual void updateCoords(); + virtual void draw(); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + // from CViewBase + virtual sint32 getAlpha() const { return (sint32) _Color.A; } + virtual void setAlpha (sint32 a); + + // texture + void setTexture(const std::string &texName); + std::string getTexture () const; + + // color + void setColorRGBA(NLMISC::CRGBA col) { _Color = col; } + NLMISC::CRGBA getColorRGBA() const { return _Color; } + + /** Set a new quad relative to parent pos + * x,y, w, h & hotspot are updated to fit the bounding rect of the quad + */ + void setQuad(const NLMISC::CQuad &quad); + void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness); + /** Fit the given texture size (no hotspot for now, always centered) + * NB : current texture is not modified. + */ + void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f); + void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f); + const NLMISC::CQuad &getQuad() const { return _Quad; } + + void setAdditif(bool additif); + bool getAdditif() const { return _Additif; } + + void setFiltered(bool filtered); + bool getFiltered() const { return _Filtered; } + + void setPattern(float umin, float umax, TWrapMode wrapMode); + + /** Set uvs for each corners -> this will change the wrap mode to CustomUVs + * Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior + */ + void setCustomUVs(const NLMISC::CUV uvs[4]); + + + // from CCtrlBase, no op by default + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + // see if this control contains the given point (in parent coords) + bool contains(const NLMISC::CVector2f &pos) const; + + // no capturable by default (just tooltip capability wanted) + virtual bool isCapturable() const { return false; } + + + private: + NLMISC::CRGBA _Color; + NLMISC::CQuad _Quad; + NLMISC::CQuadUV _RealQuad; // absolute coords + float _ClampedUCorrection; + CViewRenderer::CTextureId _TextureId; /// Accelerator + bool _Additif; + bool _Filtered; + float _UMin; + float _UMax; + TWrapMode _WrapMode; + NLMISC::CUV _CustomUVs[4]; + }; + +} + +#endif diff --git a/code/nel/include/nel/gui/ctrl_scroll.h b/code/nel/include/nel/gui/ctrl_scroll.h new file mode 100644 index 000000000..2952f9d4f --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_scroll.h @@ -0,0 +1,206 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_SCROLL_H +#define RZ_CTRL_SCROLL_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/ctrl_scroll_base.h" + + +namespace NLGUI +{ + + /** + * Class handling scollbar function + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver + { + + public: + DECLARE_UI_CLASS( CCtrlScroll ) + CCtrlScroll(const TCtorParam ¶m); + ~CCtrlScroll(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + virtual void draw(); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + + void setTarget (CInterfaceGroup *pIG); + // Return the delta value the track has moved + sint32 moveTrackX (sint32 dx); + sint32 moveTrackY (sint32 dy); + + /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. + * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) + */ + void moveTargetX (sint32 dx); + void moveTargetY (sint32 dy); + + void setAlign (sint32 nAlign) { _Aligned = nAlign; } + // invert the factor for target + void setInverted(bool invert) { _Inverted = invert; } + + void setTextureBottomOrLeft (const std::string &txName); + void setTextureMiddle (const std::string &txName); + void setTextureTopOrRight (const std::string &txName); + std::string getTextureBottomOrLeft() const; + std::string getTextureMiddle() const; + std::string getTextureTopOrRight() const; + + void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; } + void setTextureMiddle (sint32 txid) { _TxIdM = txid; } + void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR) + void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; } + + // number scroller + sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; } + // NB: the value is clamped (see setMinMax) and stepped (see setStepValue()) + void setValue(sint32 value); + void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; } + void setStepValue(uint32 step) { _StepValue= step; } + + void setTrackPos(sint32 pos); + sint32 getTrackPos() const { return _TrackPos; } + sint32 getTrackSize() const { return _TrackSize; } + // dummy set for track size (forlua export) + void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); } + + + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + int luaSetTarget(CLuaState &ls); + int luaEnsureVisible(CLuaState &ls); + + // name + void setName(const std::string & val) {_Name = val;} + std::string getName() const {return _Name;} + + // max + void setMax(sint32 max) {_Max = max;} + sint32 getMax() const {return _Max;} + + REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase) + REFLECT_LUA_METHOD("setTarget", luaSetTarget) + REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible); + REFLECT_SINT32("value", getValue, setValue); + REFLECT_SINT32("trackPos", getTrackPos, setTrackPos); + REFLECT_SINT32("trackSize", getTrackSize, setTrackSize); + REFLECT_STRING("name", getName, setName); + REFLECT_SINT32("max", getMax, setMax); + REFLECT_EXPORT_END + + /** Ensure that a child element be visible into the frame through which + * its parent group is displayed. + * Example : Had we a list of items for which we want some item 'itemPtr' to have its top position + * matching the middle of the list, we would do : + * this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx); + * + * The scrollbar will be moved accordingly. + */ + void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot); + + + protected: + + CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db + sint32 _Value; // Or we can use a normal value + sint32 _InitialValue; + + sint32 _Min, _Max; + std::string _AHOnScroll; + std::string _AHOnScrollParams; + // + std::string _AHOnScrollEnd; + std::string _AHOnScrollEndParams; + // + // + std::string _AHOnScrollCancel; + std::string _AHOnScrollCancelParams; + + + sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right + + sint32 _TrackDispPos; + sint32 _TrackPos; + sint32 _TrackSize; + sint32 _TrackSizeMin; + + sint32 _MouseDownOffsetX; + sint32 _MouseDownOffsetY; + + sint32 _TxIdB; // Same as Left if Horizontal sb + sint32 _TxIdM; + sint32 _TxIdT; // Same as Right if Horizontal sb + + uint8 _TileM; + + sint32 _LastTargetHReal; + sint32 _LastTargetMaxHReal; + sint32 _LastTargetOfsY; + sint32 _LastTargetWReal; + sint32 _LastTargetMaxWReal; + sint32 _LastTargetOfsX; + + bool _Vertical : 1; // true if vertical track bar + bool _IsDBLink : 1; + bool _ObserverOn : 1; + bool _Inverted : 1; + bool _MouseDown : 1; + bool _CallingAH : 1; + bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button + bool _Frozen : 1; + + // For Target Scroller only: the target offset step in pixel. + sint32 _TargetStepX; + sint32 _TargetStepY; + + // For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step + uint32 _StepValue; + + // Slider's name + std::string _Name; + + void computeTargetOfsFromPos(); + + // from IPropertyObserver + virtual void update(NLMISC::ICDBNode *node); + + // step the value, and clamp it + void normalizeValue(sint32 &value); + + void runAH(const std::string &name, const std::string ¶ms); + + }; +} + +#endif // RZ_CTRL_SCROLL_H + +/* End of ctrl_scroll.h */ + + diff --git a/code/nel/include/nel/gui/ctrl_scroll_base.h b/code/nel/include/nel/gui/ctrl_scroll_base.h new file mode 100644 index 000000000..8e3d6de2f --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_scroll_base.h @@ -0,0 +1,60 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CTRL_SCROLL_BASE_H +#define CTRL_SCROLL_BASE_H + +#include "nel/gui/ctrl_base.h" + +namespace NLGUI +{ + + class CInterfaceGroup; + + class CCtrlScrollBase : public CCtrlBase + { + public: + DECLARE_UI_CLASS( CCtrlScrollBase ) + + CCtrlScrollBase( const TCtorParam ¶m ); + virtual ~CCtrlScrollBase(); + + virtual void setTarget( CInterfaceGroup *pIG ); + CInterfaceGroup* getTarget(){ return _Target; } + virtual sint32 moveTrackX( sint32 dx ); + virtual sint32 moveTrackY( sint32 dy ); + + /** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs. + * Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons) + */ + virtual void moveTargetX( sint32 dx ); + virtual void moveTargetY( sint32 dy ); + + + // Necessary because of reflection, no other purpose + void draw(){} + + protected: + CInterfaceGroup *_Target; // If NULL the scroller is a value scroller + + private: + + }; + +} + +#endif + diff --git a/code/nel/include/nel/gui/ctrl_sheet_selection.h b/code/nel/include/nel/gui/ctrl_sheet_selection.h new file mode 100644 index 000000000..4ca52427e --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_sheet_selection.h @@ -0,0 +1,83 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef CL_SHEET_CTRL_SELECTION_H +#define CL_SHEET_CTRL_SELECTION_H + +namespace NLGUI +{ + class IActionHandler; + + /** Infos about a selection group + */ + class CSheetSelectionGroup + { + public: + CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {} + void setTexture(const std::string &texName); + sint32 getTextureIndex() const { return _TextureIndex; } + sint32 getTextureWidth() const { return _TextureWidth; } + sint32 getTextureHeight() const { return _TextureHeight; } + void setColor(NLMISC::CRGBA color) { _Color = color; } + NLMISC::CRGBA getColor() const { return _Color; } + void setActive(bool active) { _Active = active; } + bool isActive() const { return _Active; } + const std::string &getName() const { return _Name; } + void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; } + bool isGlobalColorEnabled() const { return _GlobalColorEnabled; } + private: + std::string _Name; + bool _Active; + sint32 _TextureIndex; // index for the selection texture + sint32 _TextureWidth; + sint32 _TextureHeight; + NLMISC::CRGBA _Color; // color that modulate the texture of selection + bool _GlobalColorEnabled; + }; + + /** Class to manage selection of sheet. + * Sheet are managed by groups, identified by their ID. + */ + class CCtrlSheetSelection + { + public: + // Add a group, and returns its index, or -1 if already created. + sint addGroup(const std::string &name); + // Get a group by its name (must exist) + CSheetSelectionGroup *getGroup(const std::string &name); + const CSheetSelectionGroup *getGroup(const std::string &name) const; + // Get a group by its index + CSheetSelectionGroup *getGroup(uint index); + const CSheetSelectionGroup *getGroup(uint index) const; + // Get the index of a group from its name, return -1 if not a group + sint getGroupIndex(const std::string &name) const; + // Deactivate all groups + void deactivateAll(); + // delete all groups + void deleteGroups(); + private: + // + typedef std::vector TGroupVect; + typedef std::map TGroupNameToIndex; + private: + TGroupVect _Groups; + TGroupNameToIndex _GroupNameToIndex; + }; + +} + +#endif diff --git a/code/nel/include/nel/gui/ctrl_text_button.h b/code/nel/include/nel/gui/ctrl_text_button.h new file mode 100644 index 000000000..17514c367 --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_text_button.h @@ -0,0 +1,170 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_CTRL_TEXT_BUTTON_H +#define NL_CTRL_TEXT_BUTTON_H + +#include "nel/gui/ctrl_base_button.h" +#include "nel/gui/view_renderer.h" + + +namespace NLGUI +{ + class CEventDescriptor; + class CViewText; + + // *************************************************************************** + /** + * Text Button that can be either Push or Toggle button. Localized, auto-resize + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CCtrlTextButton : public CCtrlBaseButton + { + public: + + /// Constructor + CCtrlTextButton(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + // Init part + virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup); + + virtual void updateCoords(); + + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + // Display part + virtual void draw(); + + // Hide/Show the text also. + virtual void setActive(bool state); + + // Add also our ViewText + virtual void onAddToGroup(); + + + /// \from CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + // Special Text Colors accessors + // Colors + NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;} + void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;} + NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;} + void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;} + NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;} + void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;} + // Shadow Colors + NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;} + void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;} + NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;} + void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;} + NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;} + void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;} + // Global Modulate Colors + bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;} + void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;} + bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;} + void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;} + bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;} + void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;} + // Set text (noop if text id) + void setText (const ucstring &text); + ucstring getText () const; + + void setHardText (const std::string &text); + std::string getHardText () const; + + CViewText* getViewText(); + void setViewText(CViewText* text) {_ViewText=text;} + + void setTextX(sint32 x); + sint32 getTextX() const { return _TextX; } + + void setWMargin(sint32 w) { _WMargin = w; } + sint32 getWMargin() const { return _WMargin; } + + sint32 getWMin() const { return _WMin; } + void setWMin( sint32 wmin ) { _WMin = wmin; } + + // Compute Size according to bitmap and Text (Ensure as big as possible button) + sint32 getWMax() const; + + int luaGetViewText(CLuaState &ls); + + REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton) + REFLECT_UCSTRING("uc_hardtext", getText, setText); + REFLECT_STRING("hardtext", getHardText, setHardText); + REFLECT_SINT32("text_x", getTextX, setTextX) + REFLECT_SINT32("wmargin", getWMargin, setWMargin) + REFLECT_SINT32("wmin", getWMin, setWMin) + REFLECT_LUA_METHOD("getViewText", luaGetViewText) + REFLECT_EXPORT_END + + protected: + + enum {NumTexture= 3}; + + CViewRenderer::CTextureId _TextureIdNormal[NumTexture]; + CViewRenderer::CTextureId _TextureIdPushed[NumTexture]; + CViewRenderer::CTextureId _TextureIdOver[NumTexture]; + + // setup + void setup(); + + private: + + CViewText *_ViewText; + + bool _Setuped; + bool _IsViewTextId; + bool _ForceTextOver; // text is displayed over the "over" texture + // Size of Bitmaps + sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH; + // Value to add to TextW to get button W. + sint32 _WMargin; + // Min W Value + sint32 _WMin; + sint32 _TextY; + sint32 _TextX; + THotSpot _TextPosRef; + THotSpot _TextParentPosRef; + // Special Colors for text + NLMISC::CRGBA _TextColorNormal; + NLMISC::CRGBA _TextColorPushed; + NLMISC::CRGBA _TextColorOver; + NLMISC::CRGBA _TextShadowColorNormal; + NLMISC::CRGBA _TextShadowColorPushed; + NLMISC::CRGBA _TextShadowColorOver; + bool _TextModulateGlobalColorNormal; + bool _TextModulateGlobalColorPushed; + bool _TextModulateGlobalColorOver; + bool _TextHeaderColor; + }; + +} + +#endif // NL_CTRL_TEXT_BUTTON_H + +/* End of ctrl_text_button.h */ diff --git a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h b/code/nel/include/nel/gui/ctrl_tooltip.h similarity index 54% rename from code/ryzom/client/src/interface_v3/ctrl_tooltip.h rename to code/nel/include/nel/gui/ctrl_tooltip.h index da5e17468..e70f55108 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_tooltip.h +++ b/code/nel/include/nel/gui/ctrl_tooltip.h @@ -1,53 +1,59 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef RZ_CTRL_TOOLTIP_H -#define RZ_CTRL_TOOLTIP_H - -#include "ctrl_base.h" -#include "nel/3d/u_texture.h" - -class CEventDescriptor; -class CInterfaceManager; - -/** - * \author Matthieu 'Mr TRAP' Besson - * \author Nevrax France - * \date 2003 - */ -class CCtrlToolTip : public CCtrlBase -{ -public: - DECLARE_UI_CLASS(CCtrlToolTip) - /// Constructor - CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {} - - virtual bool handleEvent (const CEventDescriptor& eventDesc); - virtual void draw(); - virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); - // Can do nothing with tooltip (but display it :) ) - virtual bool isCapturable() const {return false;} - virtual void serial(NLMISC::IStream &f); -public: - -}; - - -#endif // RZ_CTRL_TOOLTIP_H - -/* End of ctrl_tooltip.h */ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_TOOLTIP_H +#define RZ_CTRL_TOOLTIP_H + +#include "nel/gui/ctrl_base.h" +#include "nel/3d/u_texture.h" + +namespace NLGUI +{ + class CEventDescriptor; + + + /** + * \author Matthieu 'Mr TRAP' Besson + * \author Nevrax France + * \date 2003 + */ + class CCtrlToolTip : public CCtrlBase + { + public: + DECLARE_UI_CLASS(CCtrlToolTip) + /// Constructor + CCtrlToolTip(const TCtorParam ¶m) : CCtrlBase(param) {} + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + virtual void draw(); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + // Can do nothing with tooltip (but display it :) ) + virtual bool isCapturable() const {return false;} + virtual void serial(NLMISC::IStream &f); + public: + + }; + + +} + +#endif // RZ_CTRL_TOOLTIP_H + +/* End of ctrl_tooltip.h */ + diff --git a/code/nel/include/nel/gui/db_manager.h b/code/nel/include/nel/gui/db_manager.h new file mode 100644 index 000000000..72f665923 --- /dev/null +++ b/code/nel/include/nel/gui/db_manager.h @@ -0,0 +1,71 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef DBMANAGER_H +#define DBMANAGER_H + +#include "nel/misc/cdb_manager.h" + +namespace NLGUI +{ + + /** + Database Manager + + Provides access to a simple CDB based tree hierarchical data store + */ + class CDBManager : public NLMISC::CCDBManager + { + public: + static CDBManager* getInstance(); + static void release(); + + /** + Retrieves a leaf node from the database. + @param name - name of the data leaf node we are querying. + @param create - when true if a node cannot be found it is created. + */ + NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true ); + + /** + Deletes a node from the database. + @param name - name of the node. + */ + void delDbProp( const std::string &name ); + + /** + Returns a leaf node's content as an sint32 + @param name - name of the leaf node. + */ + sint32 getDbValue32( const std::string &name ); + + /** + Returns the root branch of the database. + */ + NLMISC::CCDBNodeBranch* getDB() const; + + private: + CDBManager(); + ~CDBManager(); + + static CDBManager *instance; + + }; + +} + +#endif diff --git a/code/nel/include/nel/gui/dbgroup_combo_box.h b/code/nel/include/nel/gui/dbgroup_combo_box.h new file mode 100644 index 000000000..7d421450f --- /dev/null +++ b/code/nel/include/nel/gui/dbgroup_combo_box.h @@ -0,0 +1,169 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_DBGROUP_COMBO_BOX_H +#define NL_DBGROUP_COMBO_BOX_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + +namespace NLGUI +{ + class CCtrlBaseButton; + class CViewText; + class CGroupMenu; + + + // *************************************************************************** + /** + * Widget: ComboBox of text + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBGroupComboBox : public CInterfaceGroup + { + public: + + /// Constructor + CDBGroupComboBox(const TCtorParam ¶m); + ~CDBGroupComboBox(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + /// CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + virtual void checkCoords (); + + // Combo Texts + void resetTexts(); + void addText(const ucstring &text); + void setText(uint i, const ucstring &text); + void insertText(uint i, const ucstring &text); + const ucstring &getText(uint i) const; + const uint &getTextId(uint i) const; + uint getTextPos(uint nId) const; + const ucstring &getTexture(uint i) const; + void removeText(uint nPos); + uint getNumTexts() const {return (uint)_Texts.size();} + void sortText(); + + // selection + void setSelection(sint32 val); + void setSelectionNoTrigger(sint32 val); + sint32 getSelection() const; + + // selection number + void setSelectionNb(sint32 /* val */){} + sint32 getSelectionNb() const {return (sint32)_Texts.size();} + + // selection text + void setSelectionText(const std::string & val); + std::string getSelectionText() const; + + // view text + void setViewText(const ucstring & text); + ucstring getViewText() const; + + void setTexture(uint i, const ucstring &texture); + + sint32 evalContentWidth() const; + + + int luaAddText(CLuaState &ls); + int luaRemoveSelection(CLuaState &ls); + int luaRemoveText(CLuaState &ls); + int luaRemoveTextByIndex(CLuaState &ls); + int luaResetTexts(CLuaState &ls); + int luaSetText(CLuaState &ls); + int luaInsertText(CLuaState &ls); + int luaGetText(CLuaState &ls); + int luaGetNumTexts(CLuaState &ls); + int luaSetTexture(CLuaState &ls); + + + REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup) + REFLECT_SINT32("selection", getSelection, setSelection) + REFLECT_LUA_METHOD("addText", luaAddText) + REFLECT_LUA_METHOD("setText", luaSetText) + REFLECT_LUA_METHOD("insertText", luaInsertText) + REFLECT_LUA_METHOD("setTexture", luaSetTexture) + REFLECT_LUA_METHOD("getText", luaGetText) + REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts) + REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection) + REFLECT_LUA_METHOD("removeText", luaRemoveText) + REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex) + REFLECT_LUA_METHOD("resetTexts", luaResetTexts) + REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb) + REFLECT_STRING ("selection_text", getSelectionText, setSelectionText) + REFLECT_UCSTRING ("view_text", getViewText, setViewText) + REFLECT_EXPORT_END + + + protected: + friend class CHandlerComboBoxSelectStart; + + bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead + bool _Setuped; + bool _DirtySelection; + sint32 _CacheSelection; + + // sint32 + CInterfaceProperty _Selection; + sint32 _NotLinkedToDBSelection; + std::vector > _Texts; + std::vector _Textures; + + // Action Handler called on combo click + std::string _AHOnSelectStart; + + // Action handler called when the content is changed + std::string _AHOnChange; + std::string _AHOnChangeParams; + bool _CallingOnChangeActionHandler; // avoid infinite loop here + + + // Children + CViewText *_ViewText; + CCtrlBaseButton *_SelectButton; + + bool _IsExternViewText; + ucstring _ExternViewText; + + + private: + void setup(); + void dirt(); + public: + // private : fill a menu with current content + void fillMenu(CGroupMenu *groupMenu) const; + + + static std::string measureMenu; + static std::string selectMenu; + static std::string selectMenuOut; + }; + +} + +#endif // NL_DBGROUP_COMBO_BOX_H + +/* End of dbgroup_combo_box.h */ diff --git a/code/nel/include/nel/gui/dbgroup_select_number.h b/code/nel/include/nel/gui/dbgroup_select_number.h new file mode 100644 index 000000000..7dc53b6ed --- /dev/null +++ b/code/nel/include/nel/gui/dbgroup_select_number.h @@ -0,0 +1,100 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_DBGROUP_SELECT_NUMBER_H +#define NL_DBGROUP_SELECT_NUMBER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + + +namespace NLGUI +{ + class CCtrlBaseButton; + class CViewText; + class CViewBitmap; + + // *************************************************************************** + /** + * Widget to select a number + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBGroupSelectNumber : public CInterfaceGroup + { + public: + + /// Constructor + CDBGroupSelectNumber(const TCtorParam ¶m); + ~CDBGroupSelectNumber(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + /// CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void updateCoords (); + virtual void checkCoords(); + virtual void draw (); + virtual void clearViews (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + // mod interface + void changeValue(sint delta); + + sint32 getMinValue () const { return _MinValue; } + void setMinValue (sint32 m) { _MinValue = m; } + sint32 getMaxValue () const { return _MaxValue; } + void setMaxValue (sint32 m) { _MaxValue = m; } + + sint32 getCurrentValue () const { return _Number.getSInt32(); } + void setCurrentValue (sint32 val) { _Number.setSInt32(val); } + + REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup) + REFLECT_SINT32("min", getMinValue, setMinValue); + REFLECT_SINT32("max", getMaxValue, setMaxValue); + REFLECT_EXPORT_END + + protected: + + // sint32 + CInterfaceProperty _Number; + bool _LoopMode; + sint _MinValue; + sint _MaxValue; + sint _DeltaMultiplier; + + // Children + CViewBitmap *_SlotNumber; + CViewText *_TextNumber; + CCtrlBaseButton *_ButtonUp; + CCtrlBaseButton *_ButtonDown; + + private: + + void setup(); + + }; + +} + +#endif // NL_DBGROUP_SELECT_NUMBER_H + +/* End of dbgroup_select_number.h */ diff --git a/code/nel/include/nel/gui/dbview_bar.h b/code/nel/include/nel/gui/dbview_bar.h new file mode 100644 index 000000000..b1232f06d --- /dev/null +++ b/code/nel/include/nel/gui/dbview_bar.h @@ -0,0 +1,115 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_DBVIEW_BAR_H +#define RZ_DBVIEW_BAR_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + + /** + * class implementing a bitmap used as the front texture of a progress bar + * the bitmap is drawn from _X to _W * _Range/_RangeMax + * \author Nicolas Brigand + * \author Nevrax France + * \date 2002 + */ + class CDBViewBar : public CViewBitmap + { + public: + enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick }; + public: + + /// Constructor + CDBViewBar(const TCtorParam ¶m) + : CViewBitmap(param), + _Slot(TCtorParam()) + { + _Color= NLMISC::CRGBA::White; + _ValueInt= 0; + _RangeInt = 255; + _ReferenceInt= 0; + _Type = ViewBar_Normal; + } + + void setType (TViewBar vb); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords (); + virtual void draw (); + + /// Nbs: Values by Int are not used if the Links are setuped + void setValue (sint32 r) { _ValueInt = r; } + void setRange (sint32 r) { _RangeInt = r; } + void setReference (sint32 r) { _ReferenceInt = r; } + sint32 getValue () const { return _ValueInt; } + sint32 getRange () const { return _RangeInt; } + sint32 getReference () const { return _ReferenceInt; } + + void setValueDbLink (const std::string &r); + void setRangeDbLink (const std::string &r); + void setReferenceDbLink (const std::string &r); + std::string getValueDbLink () const; + std::string getRangeDbLink () const; + std::string getReferenceDbLink () const; + + // Reflect ValueInt (ie not used if the link is setuped) + REFLECT_EXPORT_START(CDBViewBar, CViewBitmap) + REFLECT_SINT32 ("value", getValue, setValue); + REFLECT_SINT32 ("range", getRange, setRange); + REFLECT_SINT32 ("reference", getReference, setReference); + REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink); + REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink); + REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink); + REFLECT_EXPORT_END + + protected: + + CViewBitmap _Slot; + TViewBar _Type; + sint32 _HBar; + NLMISC::CRGBA _ColorNegative; + + // Value of the progression in arbitrary units. should be integer + CInterfaceProperty _Value; + // Max range of the progression in arbitrary units. should be integer + CInterfaceProperty _Range; + // Reference of the progression (substracted from value and range). + CInterfaceProperty _Reference; + + /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links + sint32 _ValueInt; + sint32 _RangeInt; + sint32 _ReferenceInt; + + void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); + sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); + }; + +} + +#endif // RZ_DBVIEW_BAR_H + +/* End of dbview_bar.h */ diff --git a/code/nel/include/nel/gui/dbview_bar3.h b/code/nel/include/nel/gui/dbview_bar3.h new file mode 100644 index 000000000..ab984ae63 --- /dev/null +++ b/code/nel/include/nel/gui/dbview_bar3.h @@ -0,0 +1,110 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_DBVIEW_BAR3_H +#define RZ_DBVIEW_BAR3_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_bitmap.h" + +namespace NLGUI +{ + + /** + * class implementing a 3 Bar widget + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CDBViewBar3 : public CViewBitmap + { + public: + + /// Constructor + CDBViewBar3(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + virtual void updateCoords (); + + void setMini (bool mini); + + virtual void draw (); + + /// Nbs: Values by Int are not used if the Links are setuped + void setValue0 (sint32 r) { _ValueInt[0] = r; } + void setValue1 (sint32 r) { _ValueInt[1] = r; } + void setValue2 (sint32 r) { _ValueInt[2] = r; } + void setRange0 (sint32 r) { _RangeInt[0] = r; } + void setRange1 (sint32 r) { _RangeInt[1] = r; } + void setRange2 (sint32 r) { _RangeInt[2] = r; } + sint32 getValue0 () const { return _ValueInt[0]; } + sint32 getValue1 () const { return _ValueInt[1]; } + sint32 getValue2 () const { return _ValueInt[2]; } + sint32 getRange0 () const { return _RangeInt[0]; } + sint32 getRange1 () const { return _RangeInt[1]; } + sint32 getRange2 () const { return _RangeInt[2]; } + + // Reflect ValueInt (ie not used if the link is setuped) + REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap) + REFLECT_SINT32 ("value1", getValue0, setValue0); + REFLECT_SINT32 ("value2", getValue1, setValue1); + REFLECT_SINT32 ("value3", getValue2, setValue2); + REFLECT_SINT32 ("range1", getRange0, setRange0); + REFLECT_SINT32 ("range2", getRange1, setRange1); + REFLECT_SINT32 ("range3", getRange2, setRange2); + REFLECT_EXPORT_END + + static void forceLink(); + + protected: + + CViewBitmap _Slot; + + // Value of the progression in arbitrary units. should be integer + CInterfaceProperty _Value[3]; + // Max range of the progression in arbitrary units. should be integer + CInterfaceProperty _Range[3]; + + /// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links + sint32 _ValueInt[3]; + sint32 _RangeInt[3]; + + + NLMISC::CRGBA _Colors[3]; + NLMISC::CRGBA _ColorsNegative[3]; + + bool _Mini; + + // Height of the bitmap + sint32 _BarH; + + void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name); + void setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp ); + sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp); + std::string getValProp( const CInterfaceProperty &prop, sint32 intProp ) const; + }; + +} + +#endif // RZ_DBVIEW_BAR3_H + +/* End of dbview_bar3.h */ diff --git a/code/nel/include/nel/gui/dbview_digit.h b/code/nel/include/nel/gui/dbview_digit.h new file mode 100644 index 000000000..a587a4524 --- /dev/null +++ b/code/nel/include/nel/gui/dbview_digit.h @@ -0,0 +1,67 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef NL_DBVIEW_DIGIT_H +#define NL_DBVIEW_DIGIT_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_base.h" + +namespace NLGUI +{ + + // *************************************************************************** + /** + * A number displayed with special bitmaps + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewDigit : public CViewBase + { + public: + + /// Constructor + CDBViewDigit(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void draw (); + virtual void updateCoords(); + + protected: + CInterfaceProperty _Number; + sint32 _Cache; + sint32 _NumDigit; + NLMISC::CRGBA _Color; + // space between each digit + sint32 _WSpace; + // The texture digit for the current number + sint32 _DigitId[10]; + uint _DivBase; + + + }; + +} + +#endif // NL_DBVIEW_DIGIT_H + +/* End of dbview_digit.h */ diff --git a/code/nel/include/nel/gui/dbview_number.h b/code/nel/include/nel/gui/dbview_number.h new file mode 100644 index 000000000..08c65be00 --- /dev/null +++ b/code/nel/include/nel/gui/dbview_number.h @@ -0,0 +1,77 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_DBVIEW_NUMBER_H +#define NL_DBVIEW_NUMBER_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_text.h" + +namespace NLGUI +{ + + // *************************************************************************** + /** + * Display a text from a database number + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewNumber : public CViewText + { + public: + + /// Constructor + CDBViewNumber(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void checkCoords(); + virtual void draw (); + + void link (const std::string &dbprop) + { + _Number.link (dbprop.c_str()); + } + + static void forceLink(); + + protected: + + sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor); + else return (_Number.getSInt64() / _Divisor)%_Modulo; } + + protected: + + CInterfaceProperty _Number; + sint64 _Cache; + bool _Positive; // only positive values are displayed + bool _Format; // the number will be formatted (like "1,000,000") if >= 10k + sint64 _Divisor, _Modulo; + // string to append to the value (eg: meters) + CStringShared _Suffix; + CStringShared _Prefix; + }; + +} + +#endif // NL_DBVIEW_NUMBER_H + +/* End of dbview_number.h */ diff --git a/code/nel/include/nel/gui/dbview_quantity.h b/code/nel/include/nel/gui/dbview_quantity.h new file mode 100644 index 000000000..4522b9b9e --- /dev/null +++ b/code/nel/include/nel/gui/dbview_quantity.h @@ -0,0 +1,65 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_DBVIEW_QUANTITY_H +#define NL_DBVIEW_QUANTITY_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/view_text.h" + +namespace NLGUI +{ + + // *************************************************************************** + /** + * Display a text in the form of val / max or "empty" + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CDBViewQuantity : public CViewText + { + public: + + /// Constructor + CDBViewQuantity(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); + virtual void draw (); + + static void forceLink(); + + + protected: + CInterfaceProperty _Number; + CInterfaceProperty _NumberMax; + sint32 _Cache; + sint32 _CacheMax; + ucstring _EmptyText; + + void buildTextFromCache(); + }; + +} + +#endif // NL_DBVIEW_QUANTITY_H + +/* End of dbview_quantity.h */ diff --git a/code/ryzom/client/src/interface_v3/event_descriptor.h b/code/nel/include/nel/gui/event_descriptor.h similarity index 94% rename from code/ryzom/client/src/interface_v3/event_descriptor.h rename to code/nel/include/nel/gui/event_descriptor.h index fcb9d5f3a..1c543d7ea 100644 --- a/code/ryzom/client/src/interface_v3/event_descriptor.h +++ b/code/nel/include/nel/gui/event_descriptor.h @@ -1,252 +1,257 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef RZ_EVENT_DESCRIPTOR_H -#define RZ_EVENT_DESCRIPTOR_H - -#include "nel/misc/types_nl.h" - - -// ---------------------------------------------------------------------------- -class CEventDescriptor -{ -public: - enum EEventType - { - key = 0, - mouse = 1, - system = 2 - }; - - EEventType getType() const - { - return _EventType; - } - -protected: - //type of the event - EEventType _EventType; -}; - - -/** encode key events. - */ -class CEventDescriptorKey : public CEventDescriptor -{ -public: - enum EKeyEventType - { - keydown = 0, // a key has been press down. The key value is stored as a TKey - keyup, // a key has been released. The key value is stored as a TKey - keychar, // a key has been stroke. The key is a ucchar - keystring, // a string has been sent. The string is a ucstring - unknown, // uninitialized event - }; - CEventDescriptorKey() : _KeyEvent(unknown) - { - _EventType = key; - } - // ctrcuct from a CEventKey obj - CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown) - { - _EventType = key; - init(ev); - } - // get the type of the key event - EKeyEventType getKeyEventType() const { return _KeyEvent; } - // return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert - NLMISC::TKey getKey() const - { - nlassert(_KeyEvent == keydown || _KeyEvent == keyup); - return _Key; - } - // return the char that has been pressed. The key event type MUST be 'keychar', else => assert - ucchar getChar() const - { - nlassert(_KeyEvent == keychar); - return _Char; - } - // return the string that has been sent. The key event type MUST be 'keystring', else => assert - ucstring getString() const - { - nlassert(_KeyEvent == keystring); - return _String; - } - bool getKeyCtrl() const // is CTRL pressed ? - { - return _CtrlState; - } - bool getKeyShift() const // is SHIFT (right or left) pressed ? - { - return _ShiftState; - } - bool getKeyAlt() const // is ALT (right or left) pressed ? - { - return _AltState; - } - // init from a CEventKey obj - void init(const NLMISC::CEventKey &ev); - -private: - EKeyEventType _KeyEvent; - bool _CtrlState; - bool _ShiftState; - bool _AltState; - union - { - NLMISC::TKey _Key; - ucchar _Char; - }; - ucstring _String; -}; - -// ---------------------------------------------------------------------------- -class CEventDescriptorMouse : public CEventDescriptor -{ -public: - enum EEventTypeExtended - { - mouseleftdown=0, - mouseleftup=1, - mouserightdown=2, - mouserightup=3, - mousewheel=4, // Complementary info stored in wheel - mousemove=5, // Complementary info stored in x and y - mouseleftdblclk= 6, - mouserightdblclk= 7, - }; - - CEventDescriptorMouse() - { - _EventType = mouse; - _X = _Y = _Wheel = 0; - } - - CEventDescriptorMouse (sint32 x, sint32 y) - { - _X = x; - _Y = y; - } - - sint32 getX() const - { - return _X; - } - - sint32 getY() const - { - return _Y; - } - - sint32 getWheel() const - { - return _Wheel; - } - - sint32 getEventTypeExtended() const - { - return _EventTypeExtended; - } - - void setX (sint32 x) - { - _X = x; - } - - void setY (sint32 y) - { - _Y = y; - } - - void setWheel (sint32 w) - { - _Wheel = w; - } - - void setEventTypeExtended (sint32 e) - { - _EventTypeExtended = e; - } - -protected: - sint32 _X; - sint32 _Y; - sint32 _Wheel; - sint32 _EventTypeExtended; -}; - - -// ---------------------------------------------------------------------------- -class CEventDescriptorSystem : public CEventDescriptor -{ -public: - enum EEventTypeExtended - { - activecalledonparent= 0, - clocktick, - setfocus, - unknown - }; - - sint32 getEventTypeExtended() const - { - return _EventTypeExtended; - } - void setEventTypeExtended (sint32 e) - { - _EventTypeExtended = e; - } - CEventDescriptorSystem() : _EventTypeExtended(unknown) - { - _EventType = system; - } -protected: - sint32 _EventTypeExtended; -}; - -// ---------------------------------------------------------------------------- -class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem -{ -public: - bool getActive() const { return _Active; } - void setActive(bool active) { _Active = active; } - CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active) - { - setEventTypeExtended(activecalledonparent); - } -protected: - bool _Active; -}; - - -// ---------------------------------------------------------------------------- -class CEventDescriptorSetFocus : public CEventDescriptorSystem -{ -public: - bool hasFocus() const { return _HasFocus; } - CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus) - { - setEventTypeExtended(setfocus); - } -protected: - bool _HasFocus; -}; - -#endif // RZ_EVENT_DESCRIPTOR_H - -/* End of event_descriptor.h */ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_EVENT_DESCRIPTOR_H +#define RZ_EVENT_DESCRIPTOR_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/events.h" + +namespace NLGUI +{ + +// ---------------------------------------------------------------------------- +class CEventDescriptor +{ +public: + enum EEventType + { + key = 0, + mouse = 1, + system = 2 + }; + + EEventType getType() const + { + return _EventType; + } + +protected: + //type of the event + EEventType _EventType; +}; + + +/** encode key events. + */ +class CEventDescriptorKey : public CEventDescriptor +{ +public: + enum EKeyEventType + { + keydown = 0, // a key has been press down. The key value is stored as a TKey + keyup, // a key has been released. The key value is stored as a TKey + keychar, // a key has been stroke. The key is a ucchar + keystring, // a string has been sent. The string is a ucstring + unknown, // uninitialized event + }; + CEventDescriptorKey() : _KeyEvent(unknown) + { + _EventType = key; + } + // ctrcuct from a CEventKey obj + CEventDescriptorKey(const NLMISC::CEventKey &ev) : _KeyEvent(unknown) + { + _EventType = key; + init(ev); + } + // get the type of the key event + EKeyEventType getKeyEventType() const { return _KeyEvent; } + // return the key that has been pressed. The key event type MUST be 'keydown' or 'keyup', else => assert + NLMISC::TKey getKey() const + { + nlassert(_KeyEvent == keydown || _KeyEvent == keyup); + return _Key; + } + // return the char that has been pressed. The key event type MUST be 'keychar', else => assert + ucchar getChar() const + { + nlassert(_KeyEvent == keychar); + return _Char; + } + // return the string that has been sent. The key event type MUST be 'keystring', else => assert + ucstring getString() const + { + nlassert(_KeyEvent == keystring); + return _String; + } + bool getKeyCtrl() const // is CTRL pressed ? + { + return _CtrlState; + } + bool getKeyShift() const // is SHIFT (right or left) pressed ? + { + return _ShiftState; + } + bool getKeyAlt() const // is ALT (right or left) pressed ? + { + return _AltState; + } + // init from a CEventKey obj + void init(const NLMISC::CEventKey &ev); + +private: + EKeyEventType _KeyEvent; + bool _CtrlState; + bool _ShiftState; + bool _AltState; + union + { + NLMISC::TKey _Key; + ucchar _Char; + }; + ucstring _String; +}; + +// ---------------------------------------------------------------------------- +class CEventDescriptorMouse : public CEventDescriptor +{ +public: + enum EEventTypeExtended + { + mouseleftdown=0, + mouseleftup=1, + mouserightdown=2, + mouserightup=3, + mousewheel=4, // Complementary info stored in wheel + mousemove=5, // Complementary info stored in x and y + mouseleftdblclk= 6, + mouserightdblclk= 7, + }; + + CEventDescriptorMouse() + { + _EventType = mouse; + _X = _Y = _Wheel = 0; + } + + CEventDescriptorMouse (sint32 x, sint32 y) + { + _X = x; + _Y = y; + } + + sint32 getX() const + { + return _X; + } + + sint32 getY() const + { + return _Y; + } + + sint32 getWheel() const + { + return _Wheel; + } + + sint32 getEventTypeExtended() const + { + return _EventTypeExtended; + } + + void setX (sint32 x) + { + _X = x; + } + + void setY (sint32 y) + { + _Y = y; + } + + void setWheel (sint32 w) + { + _Wheel = w; + } + + void setEventTypeExtended (sint32 e) + { + _EventTypeExtended = e; + } + +protected: + sint32 _X; + sint32 _Y; + sint32 _Wheel; + sint32 _EventTypeExtended; +}; + + +// ---------------------------------------------------------------------------- +class CEventDescriptorSystem : public CEventDescriptor +{ +public: + enum EEventTypeExtended + { + activecalledonparent= 0, + clocktick, + setfocus, + unknown + }; + + sint32 getEventTypeExtended() const + { + return _EventTypeExtended; + } + void setEventTypeExtended (sint32 e) + { + _EventTypeExtended = e; + } + CEventDescriptorSystem() : _EventTypeExtended(unknown) + { + _EventType = system; + } +protected: + sint32 _EventTypeExtended; +}; + +// ---------------------------------------------------------------------------- +class CEventDescriptorActiveCalledOnParent : public CEventDescriptorSystem +{ +public: + bool getActive() const { return _Active; } + void setActive(bool active) { _Active = active; } + CEventDescriptorActiveCalledOnParent(bool active = false) : _Active(active) + { + setEventTypeExtended(activecalledonparent); + } +protected: + bool _Active; +}; + + +// ---------------------------------------------------------------------------- +class CEventDescriptorSetFocus : public CEventDescriptorSystem +{ +public: + bool hasFocus() const { return _HasFocus; } + CEventDescriptorSetFocus(bool hasFocus = false) : _HasFocus(hasFocus) + { + setEventTypeExtended(setfocus); + } +protected: + bool _HasFocus; +}; + +} + +#endif // RZ_EVENT_DESCRIPTOR_H + +/* End of event_descriptor.h */ diff --git a/code/ryzom/client/src/interface_v3/group_wheel.h b/code/nel/include/nel/gui/event_listener.h similarity index 58% rename from code/ryzom/client/src/interface_v3/group_wheel.h rename to code/nel/include/nel/gui/event_listener.h index dc299a9ca..233746997 100644 --- a/code/ryzom/client/src/interface_v3/group_wheel.h +++ b/code/nel/include/nel/gui/event_listener.h @@ -1,42 +1,44 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - - - -#ifndef RZ_GROUP_CONTAINER_H -#define RZ_GROUP_CONTAINER_H - -#include "interface_group.h" - - - -// Special group to handle the mouse wheel message -class CInterfaceGroupWheel : public CInterfaceGroup -{ -public: - /// Constructor - CInterfaceGroupWheel(const TCtorParam ¶m); - /// Coming from CInterfaceElement - virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); - virtual bool handleEvent (const CEventDescriptor &event); -private: - IActionHandler *_AHWheelUp; - CStringShared _AHWheelUpParams; - IActionHandler *_AHWheelDown; - CStringShared _AHWheelDownParams; -}; - -#endif +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef EVENT_LISTENER +#define EVENT_LISTENER + +#include "nel/misc/event_listener.h" +#include "nel/gui/input_handler.h" + +namespace NLGUI +{ + class CEventListener : public NLMISC::IEventListener + { + public: + CEventListener(); + ~CEventListener(); + void addToServer( NLMISC::CEventServer *server ); + void removeFromServer(); + void operator()( const NLMISC::CEvent &evnt ); + + private: + NLGUI::CInputHandler inputHandler; + NLMISC::CEventServer *eventServer; + }; + +} + +#endif + + diff --git a/code/nel/include/nel/gui/group_container.h b/code/nel/include/nel/gui/group_container.h new file mode 100644 index 000000000..d405b8ec6 --- /dev/null +++ b/code/nel/include/nel/gui/group_container.h @@ -0,0 +1,661 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_GROUP_CONTAINER_H +#define RZ_GROUP_CONTAINER_H + +#include "nel/gui/interface_group.h" +#include "nel/gui/group_container_base.h" +#include "nel/misc/smart_ptr.h" + +namespace NLGUI +{ + class CEventDescriptorLocalised; + class CCtrlButton; + class CCtrlScroll; + class CViewText; + class CViewBitmap; + class CGroupList; + class COptionsContainerInsertion; + class COptionsContainerMove; + class COptionsLayer; + class CGroupContainer; + + + + // *************************************************************************** + /** + * class describing a resizer for the container + * \author Matthieu 'TrapII' Besson + * \date 2003 + */ + class CCtrlResizer : public CCtrlBase + { + + public: + + CCtrlResizer(const TCtorParam ¶m); + virtual void draw (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + // Add a big delta so when the user is over the Resizer, always take it whatever other controls under + virtual uint getDeltaDepth() const { return 100; } + + // get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded + // if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded + THotSpot getRealResizerPos() const; + THotSpot getResizerPos() const { return _ResizerPos; } + void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; } + + bool IsMaxH; // Do this resizer is a MaxH resizer ? + + // Max sizes for the parent + sint32 WMin, WMax; + sint32 HMin, HMax; + + // from CCtrlBase + virtual bool canChangeVirtualDesktop() const { return !_MouseDown; } + + private: + + sint32 resizeW (sint32 dx); + sint32 resizeH (sint32 dy); + + private: + THotSpot _ResizerPos; // how the resizer should resize its parent + bool _MouseDown; + sint32 _MouseDownX; + sint32 _MouseDownY; + sint32 _XBias; + sint32 _YBias; + }; + + + // *************************************************************************** + /** + * Class describing a Mover for the container + * Clicking on it can also open the container + * This can be used to move a container if it is movable. + * If the container is popable, it will first pull it of the hierarchy, then it becomes movable. + * It can also be used to change the position of a group container that is inserted in the list of another container. + * \author Lionel Berenguier + * \date 2003 + */ + class CCtrlMover : public CCtrlBase + { + public: + + CCtrlMover(const TCtorParam ¶m, bool canMove, bool canOpen); + ~CCtrlMover(); + virtual void draw (); + virtual bool handleEvent (const NLGUI::CEventDescriptor &event); + bool canMove() { return _CanMove; } + + bool isMoving() const {return _Moving;} + bool isMovingInParentList() const { return _MovingInParentList; } + + // from CCtrlBase + virtual bool canChangeVirtualDesktop() const { return !_Moving; } + + private: + sint32 _MoveStartX, _MoveStartY; + sint32 _MoveDeltaXReal, _MoveDeltaYReal; + sint64 _ScrollTime; + sint32 _StartIndex; + sint32 _InsertionIndex; + // clip window from parent list + sint32 _ParentListTop; + sint32 _ParentListBottom; + // + sint64 _WaitToOpenCloseDate; + // + bool _CanMove : 1; + bool _CanOpen : 1; + bool _Moving : 1; + bool _MovingInParentList : 1; + bool _HasMoved : 1; + bool _ParentScrollingUp : 1; + bool _ParentScrollingDown : 1; + bool _StopScrolling : 1; // stop scrolling at next draw + bool _WaitToOpenClose : 1; + // + static COptionsContainerInsertion *getInsertionOptions(); + private: + void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); + void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc); + void updateInsertionIndex(const CGroupList *gl, sint32 posY); + void stopMove(); + bool runTitleActionHandler(); + void handleScrolling(); + + }; + + + // *************************************************************************** + /** + * class describing a group of views controls and other groups + * \author Matthieu 'TrapII' Besson + * \author Nevrax France + * \date 2002 + */ + class CGroupContainer : public CGroupContainerBase + { + public: + enum { NumResizers = 8 }; + public: + // observer to know when children have moved. This can be used to keep external datas in sync + struct IChildrenObs + { + virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0; + }; + public: + CGroupContainer(const TCtorParam ¶m); + ~CGroupContainer(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const; + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + + virtual void updateCoords (); + + virtual void draw (); + + virtual void clearViews (); + + virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc); + + virtual void launch (); + + virtual void setActive (bool state); + + virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vVB); // Return true if x,y under the group + + virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector &vICL); + + void open(); + + void close(); + + void setup(); // Create the container + + /** If insertion order is -1, pIC is added at the end of the container + * otherwise it is inserted after containers of a lower order + */ + void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1); + // Insert a container at the given index. + bool attachContainerAtIndex(CGroupContainer *pIC, uint index); + + // Before a container is detached from parent, it should be pop in + void detachContainer (CGroupContainer *pIC); + void removeAllContainers(); + + void setOpen(bool opened) + { + if (opened) + { + open(); + } + else + { + close(); + } + } + bool isOpen() const { return _Opened; } + + // Force Open for container setActive and open() + virtual void forceOpen(); + + /// Set the title open and close + virtual bool isMovable() const {return _Movable;} + void setMovable(bool b); + + void setContent (CInterfaceGroup *pC); + + std::string getTitle () const; + void setTitle (const std::string &title); + std::string getTitleOpened () const; + void setTitleOpened (const std::string &title); + std::string getTitleClosed () const; + void setTitleClosed (const std::string &title); + std::string getTitleColorAsString() const; + void setTitleColorAsString(const std::string &col); + + void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); } + + // Get the header color draw. NB: depends if grayed, and if active. + NLMISC::CRGBA getDrawnHeaderColor () const; + + ucstring getUCTitleOpened () const; + void setUCTitleOpened (const ucstring &title); + ucstring getUCTitleClosed () const; + void setUCTitleClosed (const ucstring &title); + ucstring getUCTitle () const; + void setUCTitle (const ucstring &title); + + void setPopable(bool popable) { _Popable = popable; } + bool isPopable() const { return _Popable; } + bool isPopuped() const { return _Poped; } + + + void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; } + bool isMovableInParentList() const { return _MovableInParentList; } + + // high light the border of the container + void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; } + bool isHighLighted() const { return _HighLighted; } + + // y offset for content of container + sint32 getContentYOffset() const { return (sint32) _ContentYOffset; } + void setContentYOffset(sint32 value); + + // Window requires attention + void requireAttention(); + + // Lua exports + int luaBlink(CLuaState &ls); + int luaSetHeaderColor(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase) + REFLECT_LUA_METHOD("blink", luaBlink); + REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor); + REFLECT_STRING("title", getTitle, setTitle); + REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); + REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); + REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); + REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); + REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); + REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString); + REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH); + REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH); + REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW); + REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW); + REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW); + REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset); + REFLECT_BOOL("openable", isOpenable, setOpenable); + REFLECT_BOOL("opened", isOpen, setOpen); + REFLECT_BOOL("lockable", isLockable, setLockable); + REFLECT_BOOL("locked", isLocked, setLocked); + + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); + REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); + REFLECT_EXPORT_END + + sint32 getLayerSetup() const { return _LayerSetup; } + + // if this window is popable, pop it at its actual position + void popupCurrentPos(); + // Popup at previous memorized position + void popup(); + /** Popin the window and possibly put it back in its father container, using the order defined in the list of the container. + * \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL) + * \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list + */ + void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true); + + // get the mover control associated with that control, or NULL if none + CCtrlMover *getCtrlMover() const { return _Mover; } + + // true if there is a mover and if the window is being moved + bool isMoving() const { return _Mover && _Mover->isMoving(); } + + /** Force the container to blink (to tell the user that an event has happened). + * This uses the global color, so the container must use it + * This state is automatically disabled if the container is opened + * \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise + */ + virtual void enableBlink(uint numBlinks = 0); + virtual void disableBlink(); + virtual bool isBlinking() const { return _Blinking; } + + CGroupList *getList() const { return _List; } + + CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; } + CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; } + CInterfaceGroup *getContent() const { return _Content; } + + void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; } + IChildrenObs *getChildrenObs() const { return _ChildrenObs; } + + // Get current father container (if any). + CGroupContainer *getFatherContainer() const; + // Get current father container (if any). If the container is popup, it gives the proprietary container + CGroupContainer *getProprietaryContainer() const; + + + bool isOpenable() const { return _Openable; } + void setOpenable(bool openable); + + bool getHeaderActive() const { return _HeaderActive; } + void setHeaderActive(bool active) { _HeaderActive = active; } + + bool getRightButtonEnabled() const { return _EnabledRightButton; } + void setRightButtonEnabled(bool enabled); + + CCtrlScroll *getScroll() const { return _ScrollBar; } + + bool isSavable() const { return _Savable; } + void setSavable(bool savable) { _Savable = savable; } + bool isActiveSavable() const { return _ActiveSavable; } + + bool isLocalize() const { return _Localize; } + void setLocalize(bool localize) { _Localize = localize; } + + void setPopupX(sint32 x) { _PopupX = x; } + void setPopupY(sint32 y) { _PopupY = y; } + void setPopupW(sint32 w) { _PopupW = w; } + void setPopupH(sint32 h) { _PopupH = h; } + + sint32 getPopupX() const { return _PopupX; } + sint32 getPopupY() const { return _PopupY; } + sint32 getPopupW() const { return _PopupW; } + sint32 getPopupH() const { return _PopupH; } + + sint32 getRefW() const { return _RefW; } + + /** Increase the rollover alpha for the current frame. + * Example of use : an edit box that has focus in a group container + */ + void rollOverAlphaUp(); + // force the rollover alpha to its max value, depending on there's keyboard focus or not + void forceRolloverAlpha(); + + bool isOpenWhenPopup() const { return _OpenWhenPopup; } + + /// Locking of window (prevent it from being moved) + void setLockable(bool lockable); + bool isLockable() const { return _Lockable; } + void setLocked(bool locked); + + // to be called by the 'deactive check' handler + static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; } + const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); } + const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; } + // + const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); } + const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; } + // + IActionHandler *getAHOnMovePtr() const { return _AHOnMove; } + const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); } + const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; } + // + IActionHandler *getAHOnResizePtr() const { return _AHOnResize; } + const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); } + const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } + // + IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; } + const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); } + const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; } + + // + void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); } + void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; } + + void setModalParentList (const std::string &name); + bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window) + bool isGrayed() const; + bool blinkAllSons(); + + // true if the resizer is enabled. + bool getEnabledResizer() const {return _EnabledResizer;} + + sint32 getPopupMinW() const {return _PopupMinW;} + sint32 getPopupMaxW() const {return _PopupMaxW;} + sint32 getPopupMinH() const {return _PopupMinH;} + sint32 getPopupMaxH() const {return _PopupMaxH;} + sint32 getMinW() const {return _MinW;} + void setMinW(sint32 minW) { _MinW = minW;} + void setMaxW(sint32 maxW) { _MaxW = maxW;} + sint32 getMaxW() const {return _MaxW;} + void setPopupMinW(sint32 minW); + void setPopupMaxW(sint32 maxW); + void setPopupMinH(sint32 minW); + void setPopupMaxH(sint32 maxW); + + + // backup the current position of this container + void backupPosition(); + // restore the current position of this container + void restorePosition(); + // get x for backup position + sint32 getBackupX() const { return _BackupX; } + sint32 getBackupY() const { return _BackupY; } + // Set backup position + void setBackupPosition(sint32 x, sint32 y); + // clear backup + void clearBackup() { _PositionBackuped = false; } + // Test if position has been backuped (flag cleared by 'restorePosition()') + bool isPositionBackuped() const { return _PositionBackuped; } + // check if the container has been moved, resized, or popuped by the user (and eventually clear that flag) + bool getTouchFlag(bool clearFlag) const; + // from CInterfaceGroup + virtual void restoreAllContainersBackupPosition() { restorePosition(); } + + // when isModal() is true, the whole interface cannot switch desktop + bool isModal() const { return _Modal; } + void setModal(bool modal) { _Modal = modal; } + + // return true if the container has a modal parent window setuped => the whole interface cannot switch desktop + bool isModalSon() const { return !_ModalParents.empty(); } + + // return the help web page of this container. "" if none + const std::string &getHelpPage() const { return _HelpPage; } + // set the help web page of this container. "" if none. NB: the help button is not updated + void setHelpPage(const std::string &newPage); + + void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; } + sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; } + + protected: + uint8 _ICurrentRolloverAlphaContainer; + uint8 _HighLightedAlpha; + float _CurrentRolloverAlphaContainer; + float _CurrentRolloverAlphaContent; + sint32 _LayerSetup; + ucstring _TitleTextOpened; + ucstring _TitleTextClosed; + CViewText *_TitleOpened; + CViewText *_TitleClosed; + sint32 _TitleDeltaMaxW; + CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable) + CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin + CCtrlButton *_HelpButton; // Help button + + CGroupList *_List; + CCtrlScroll *_ScrollBar; + CGroupContainer *_OldFatherContainer; + + // NB: _ModalParentNames is a list of modal parent, separated by '|' + std::string _ModalParentNames; // Modal handling between container (container can be linked together, + std::vector _ModalSons; // when the son is active the parent is not active + std::vector _ModalParents; // (but the rest of the interface is)) + + uint _InsertionOrder; + uint _BlinkDT; + uint _NumBlinks; + + CInterfaceGroup *_Content; // Read From Script + CInterfaceGroup *_HeaderOpened; // Read From Script + CInterfaceGroup *_HeaderClosed; // Read From Script + + CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available + + // + CCtrlMover *_Mover; + + IChildrenObs *_Obs; + + // If layer==0 constraint on resize + sint32 _PopupMinW; + sint32 _PopupMaxW; + sint32 _PopupMinH; + sint32 _PopupMaxH; + // If layer>0 constraint on resize + sint32 _MinW; + sint32 _MaxW; + + // backuped position + sint32 _BackupX; + sint32 _BackupY; + + // old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet + sint32 _PopupX; + sint32 _PopupY; + sint32 _PopupW; + sint32 _PopupH; + // + sint32 _RefW; + + + sint32 _MoverDeltaW; + + // action handler + IActionHandler *_AHOnOpen; + CStringShared _AHOnOpenParams; + IActionHandler *_AHOnClose; + CStringShared _AHOnCloseParams; + IActionHandler *_AHOnCloseButton; + CStringShared _AHOnCloseButtonParams; + IActionHandler *_AHOnMove; + CStringShared _AHOnMoveParams; + IActionHandler *_AHOnResize; + CStringShared _AHOnResizeParams; + IActionHandler *_AHOnBeginMove; + CStringShared _AHOnBeginMoveParams; + + // action handler to test whether the windows can be deactivated (when the close button is pressed) + IActionHandler *_AHOnDeactiveCheck; + CStringShared _AHOnDeactiveCheckParams; + + + // Observer to know when children have moved + IChildrenObs *_ChildrenObs; + + // list of container that are poped up + std::vector _PopedCont; + + // Open management + bool _Openable : 1; // Is the container can be manually opened or closed ? + bool _Opened : 1; // Is the container currently opened or closed ? + bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0) + // and close when poped in... + bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start + bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0) + + // Move management + bool _Movable : 1; // Is the container movable ? + bool _MovableInParentList: 1; + bool _Lockable : 1; + bool _MovingInParentList : 1; // Mgt : currently moving ? + + // Pop up / pop in + bool _Popable : 1; + bool _Poped : 1; + + bool _EnabledResizer : 1; + + bool _HighLighted : 1; + bool _Blinking : 1; + bool _BlinkState : 1; + + bool _Savable : 1; + bool _ActiveSavable : 1; + + // Display title background or not + bool _HeaderActive : 1; + bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ? + // + enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString}; + uint8 _TitleClass : 2; + // + mutable bool _TouchFlag : 1; + bool _PositionBackuped : 1; + bool _Modal : 1; // the container is modal and prevent from switching virtual desktop + // + bool _EnabledHelpButton : 1; // Is the Button Help is enabled ? + // + bool _TitleOverExtendViewText : 1; // Does the title over extend view text + bool _Localize : 1; + + CInterfaceProperty _HeaderColor; + + + + sint8 _ContentYOffset; + + // Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value + sint8 _ResizerTopSize; + uint8 _ICurrentRolloverAlphaContent; + + + static bool _ValidateCanDeactivate; + + CStringShared _OptionsName; + + // Web Page used for help + CStringShared _HelpPage; + + private: + + sint32 getLayer(); + void updateResizerSize(CCtrlResizer *cr); + void updateRightButton(); + void updateHelpButton(); + void updateMover(); + void updateViewOpenState(); + void updateTitle(); + + void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH); + void createResizerMaxH(); + void removeResizerMaxH(); + + TTileClass convertTitleClass(const char *ptr); + + static COptionsContainerMove *getMoveOptions(); + + COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used + + bool hasKeyboardFocus() const; + + // private for modal system + void addModalParent (CGroupContainer *pParent); + void addModalSon (CGroupContainer *pSon); + + // Avoid each frame setup layer0, layer1 etc... + enum {NumLayerName=10}; + static const std::string _OptionLayerName[NumLayerName]; + + public: + // for use by CCtrlMover + // Tell that this group is moving in its parent list + void setMovingInParentList(bool enable); + CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; } + CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; } + CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; } + // set the 'hasMoved' flag + void touch(bool touched = true) { _TouchFlag = touched; } + + friend class CICDeactive; + }; + +} + +#endif // RZ_INTERFACE_CONTAINER_H + +/* End of interface_container.h */ diff --git a/code/nel/include/nel/gui/group_container_base.h b/code/nel/include/nel/gui/group_container_base.h new file mode 100644 index 000000000..b961f5da3 --- /dev/null +++ b/code/nel/include/nel/gui/group_container_base.h @@ -0,0 +1,117 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef GROUP_CONTAINER_BASE_H +#define GROUP_CONTAINER_BASE_H + +#include "nel/gui/interface_group.h" +#include "nel/misc/rgba.h" + +namespace NLGUI +{ + + class CGroupContainerBase : public CInterfaceGroup + { + public: + DECLARE_UI_CLASS( CGroupContainerBase ) + + CGroupContainerBase( const TCtorParam ¶m ); + virtual ~CGroupContainerBase(); + + virtual void removeAllContainers(); + virtual void setLocked( bool locked ); + bool isLocked() const { return _Locked; } + + uint8 getContainerAlpha() const { return _ContainerAlpha; } + uint8 getContentAlpha() const { return _ContentAlpha; } + uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; } + uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; } + + void setContainerAlpha( uint8 alpha ); + void setContentAlpha( uint8 alpha ); + void setRolloverAlphaContent( uint8 alpha ); + void setRolloverAlphaContainer( uint8 alpha ); + + // for export + sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; } + sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; } + sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; } + sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; } + + // sin32 versions for export + void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); } + void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); } + void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); } + void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); } + + void setUseGlobalAlpha( bool use ); + bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; } + + std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); } + std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; } + + void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); } + void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; } + + REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup ) + REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha); + REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha); + REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent); + REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer); + REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha); + REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged); + REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams); + REFLECT_EXPORT_END + + virtual bool isMoving() const{ return false; } + + // Get the header color draw. NB: depends if grayed, and if active. + virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); }; + + uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; } + uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; } + + virtual bool isGrayed() const{ return false; } + virtual bool getTouchFlag(bool clearFlag) const{ return false; } + virtual void backupPosition(){} + virtual void restorePosition(){} + + protected: + void triggerAlphaSettingsChangedAH(); + + uint8 _CurrentContainerAlpha; + uint8 _CurrentContentAlpha; + uint8 _ContainerAlpha; + uint8 _ContentAlpha; + uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it + uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it + bool _Locked : 1; // Is the container locked (ie override movable, openable ...) + bool _UseGlobalAlpha : 1; + + IActionHandler *_AHOnAlphaSettingsChanged; + CStringShared _AHOnAlphaSettingsChangedParams; + + private: + + }; + + + +} + + +#endif diff --git a/code/nel/include/nel/gui/group_editbox.h b/code/nel/include/nel/gui/group_editbox.h new file mode 100644 index 000000000..9d7494cfd --- /dev/null +++ b/code/nel/include/nel/gui/group_editbox.h @@ -0,0 +1,368 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef RZ_CTRL_EDITBOX_H +#define RZ_CTRL_EDITBOX_H + +#include "nel/gui/interface_group.h" +#include "nel/gui/group_editbox_base.h" +#include "nel/3d/u_texture.h" + +namespace NLGUI +{ + class CEventDescriptor; + class CViewText; + + // ---------------------------------------------------------------------------- + class CGroupEditBox : public CGroupEditBoxBase + { + public: + + class IComboKeyHandler + { + public: + virtual ~IComboKeyHandler(){} + virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0; + }; + + enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with + + DECLARE_UI_CLASS( CGroupEditBox ) + /// Constructor + CGroupEditBox(const TCtorParam ¶m); + /// Dtor + ~CGroupEditBox(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup); + virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); } + + virtual void draw(); + + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + /// Accessors + ucstring getInputString() const { return _InputString; } + const ucstring &getInputStringRef() const { return _InputString; } + const ucstring &getPrompt() const { return _Prompt; } + + /** Set the prompt + * NB : line returns are encoded as '\n', not '\r\n' + */ + void setPrompt(const ucstring &s) { _Prompt = s; } + void setInputString(const ucstring &str); + void setInputStringRef(const ucstring &str) {_InputString = str; }; + void setInputStringAsInt(sint32 val); + sint32 getInputStringAsInt() const; + void setInputStringAsInt64(sint64 val); + sint64 getInputStringAsInt64() const; + void setInputStringAsFloat(float val); + float getInputStringAsFloat() const; + void setInputStringAsStdString(const std::string &str); + std::string getInputStringAsStdString() const; + void setInputStringAsUtf8(const std::string &str); + std::string getInputStringAsUtf8() const; + void setColor(NLMISC::CRGBA col); + + + /// force the selection of all the text + void setSelectionAll(); + + virtual void checkCoords(); + virtual void updateCoords(); + virtual void clearViews (); + + virtual void setActive (bool state); + + static CGroupEditBox *getMenuFather() { return _MenuFather; } + + void setCommand(const ucstring &command, bool execute); + + // Stop parent from blinking + void stopParentBlink() { if (_Parent) _Parent->disableBlink(); } + + // Get / set cursor position + sint32 getCursorPos () const {return _CursorPos;} + void setCursorPos (sint32 pos) {_CursorPos=pos;} + + // Get / set cursor at previous line end + bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;} + void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;} + + // Get / set current selection position + static sint32 getSelectCursorPos () {return _SelectCursorPos;} + static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;} + + // Get the view text + const CViewText *getViewText () const {return _ViewText;} + + // Get the historic information + sint32 getMaxHistoric() const {return _MaxHistoric;} + sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;} + void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;} + const ucstring &getHistoric(uint32 index) const {return _Historic[index];} + uint32 getNumHistoric() const {return (uint32)_Historic.size ();} + + // Get on change action handler + const std::string &getAHOnChange() const {return _AHOnChange;} + const std::string &getParamsOnChange() const {return _ParamsOnChange;} + + void cutSelection(); + + /// From CInterfaceElement + sint32 getMaxUsedW() const; + sint32 getMinUsedW() const; + + // Copy the selection into buffer + void copy(); + // Paste the selection into buffer + void paste(); + // Write the string into buffer + void writeString(const ucstring &str, bool replace = true, bool atEnd = true); + + // Expand the expression (true if there was a '/' at the start of the line) + bool expand(); + + // Back space + void back(); + + // ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant) + void bypassNextKey() { _BypassNextKey = true; } + + // True if the editBox loose the focus on enter + bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;} + // + virtual void clearAllEditBox(); + // From CInterfaceElement + virtual bool wantSerialConfig() const; + // From CInterfaceElement + virtual void serialConfig(NLMISC::IStream &f); + // From CInterfaceElement + virtual void onQuit(); + // From CInterfaceElement + virtual void onLoadConfig(); + + // from CCtrlBase + virtual void elementCaptured(CCtrlBase *capturedElement); + + // from CCtrlBase + virtual void onKeyboardCaptureLost(); + + // set the input string as "default". will be reseted at first click (used for user information) + void setDefaultInputString(const ucstring &str); + + // For Interger and PositiveInteger, can specify min and max values + void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;} + void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;} + void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;} + void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;} + + void setFocusOnText(); + + int luaSetSelectionAll(CLuaState &ls); + int luaSetupDisplayText(CLuaState &ls); + int luaSetFocusOnText(CLuaState &ls); + int luaCancelFocusOnText(CLuaState &ls); + REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase) + REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText); + REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); + REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); + REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); + REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); + REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); + REFLECT_EXPORT_END + + /** Restore the original value of the edit box. + * This value is captured when the edit box get focus + * (return true if no undo was available) + * Will always fails ifthe edito box do not have the focus + */ + bool undo(); + + /** Cancel last undo operation + * Return true if redo operation is available + */ + bool redo(); + + /// freeze the control (loose focus, and cannot edit) + void setFrozen (bool state); + bool getFrozen () const { return _Frozen; } + + protected: + + // Cursor infos + float _BlinkTime; + sint32 _CursorPos; + uint32 _MaxNumChar; + uint32 _MaxNumReturn; + uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only + sint32 _MaxCharsSize; + sint32 _FirstVisibleChar; + sint32 _LastVisibleChar; + + // Text selection + static sint32 _SelectCursorPos; + bool _SelectingText; + NLMISC::CRGBA _TextSelectColor; + NLMISC::CRGBA _BackSelectColor; + + // Text info + ucstring _Prompt; + ucstring _InputString; + CViewText *_ViewText; + + // undo / redo + ucstring _StartInputString; // value of the input string when focus was acuired first + ucstring _ModifiedInputString; + + + // Historic info + typedef std::deque THistoric; + THistoric _Historic; + uint32 _MaxHistoric; + sint32 _CurrentHistoricIndex; + sint32 _PrevNumLine; + + // Action Handler + std::string _AHOnChange; + std::string _ParamsOnChange; + std::string _ListMenuRight; + + std::string _AHOnFocusLost; + std::string _AHOnFocusLostParams; + + // entry type + TEntryType _EntryType; + + + bool _Setupped : 1; // setup + bool _BypassNextKey : 1; + bool _BlinkState : 1; + bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines) + bool _LooseFocusOnEnter : 1; + bool _ResetFocusOnHide : 1; + bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed. + // If the edit box is at the bottom of the screen and if it expands on y + // because of multiline, thz parent container will be moved to top + // The good position can be restored by a press on enter then + bool _WantReturn : 1; // Want return char, don't call the enter action handler + bool _Savable : 1; // should content be saved ? + bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited) + bool _Frozen : 1; // is the control frozen? (cannot edit in it) + + bool _CanRedo : 1; + bool _CanUndo : 1; + + std::vector _NegativeFilter; + + sint _CursorTexID; + sint32 _CursorWidth; + + sint32 _IntegerMinValue; + sint32 _IntegerMaxValue; + uint32 _PositiveIntegerMinValue; + uint32 _PositiveIntegerMaxValue; + + sint32 _ViewTextDeltaX; + + private: + void setupDisplayText(); + void makeTopWindow(); + void handleEventChar(const NLGUI::CEventDescriptorKey &event); + void handleEventString(const NLGUI::CEventDescriptorKey &event); + void setup(); + void triggerOnChangeAH(); + void appendStringFromClipboard(const ucstring &str); + + ucstring getSelection(); + + static CGroupEditBox *_MenuFather; + + static bool isValidAlphaNumSpace(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= '0' && ac <= '9') || + (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z') || + ac==' '; + } + + static bool isValidAlphaNum(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= '0' && ac <= '9') || + (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z'); + } + + static bool isValidAlpha(ucchar c) + { + if (c > 255) return false; + char ac = (char) c; + return (ac >= 'a' && ac <= 'z') || + (ac >= 'A' && ac <= 'Z'); + } + + static bool isValidPlayerNameChar(ucchar c) + { + // valid player name (with possible shard prefix / suffix format + return isValidAlpha(c) || c=='.' || c=='(' || c==')'; + } + + static bool isValidFilenameChar(ucchar c) + { + if (c == '\\' || + c == '/' || + c == ':' || + c == '*' || + c == '?' || + c == '\"' || + c == '<' || + c == '>' || + c == '|') return false; + return true; + } + // + bool isFiltered(ucchar c) + { + uint length = (uint)_NegativeFilter.size(); + for (uint k = 0; k < length; ++k) + { + if ((ucchar) _NegativeFilter[k] == c) return true; + } + return false; + } + + static IComboKeyHandler *comboKeyHandler; + + public: + static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; } + + }; + + +} + +#endif // RZ_CTRL_EDITBOX_H + +/* End of ctrl_editbox.h */ diff --git a/code/nel/include/nel/gui/group_editbox_base.h b/code/nel/include/nel/gui/group_editbox_base.h new file mode 100644 index 000000000..b84fa29dc --- /dev/null +++ b/code/nel/include/nel/gui/group_editbox_base.h @@ -0,0 +1,67 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef GROUP_EDITBOX_BASE_H +#define GROUP_EDITBOX_BASE_H + +#include "nel/gui/interface_group.h" + +namespace NLGUI +{ + + class CGroupEditBoxBase : public CInterfaceGroup + { + public: + DECLARE_UI_CLASS( CGroupEditBoxBase ) + + CGroupEditBoxBase( const TCtorParam ¶m ); + ~CGroupEditBoxBase(); + + // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus + bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; } + void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; } + + std::string getAHOnFocus(){ return _AHOnFocus; } + std::string getAHOnFocusParams(){ return _AHOnFocusParams; } + + // disable any current selection + static void disableSelection(){ _CurrSelection = NULL; } + + // Get / set current selection + static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; } + static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; } + + void draw(){} + + REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup ) + REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter ); + REFLECT_EXPORT_END + + protected: + bool _RecoverFocusOnEnter : 1; + + std::string _AHOnFocus; + std::string _AHOnFocusParams; + + static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none + + }; + +} + +#endif + diff --git a/code/nel/include/nel/gui/group_frame.h b/code/nel/include/nel/gui/group_frame.h new file mode 100644 index 000000000..0efaa2188 --- /dev/null +++ b/code/nel/include/nel/gui/group_frame.h @@ -0,0 +1,118 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + + +#ifndef NL_GROUP_FRAME_H +#define NL_GROUP_FRAME_H + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" + + +namespace NLGUI +{ + + + // *************************************************************************** + /** A Group with a background and a frame displayed + * \author Lionel Berenguier + * \author Nevrax France + * \date 2002 + */ + class CGroupFrame : public CInterfaceGroup + { + public: + + /// Constructor + CGroupFrame(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void draw (); + + void copyOptionFrom(const CGroupFrame &other); + void setupOptions(); + + + void setColorAsString(const std::string & col); + std::string getColorAsString() const; + + REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup) + REFLECT_STRING ("color", getColorAsString, setColorAsString); + REFLECT_EXPORT_END + + + static void resetDisplayTypes() { _DispTypes.clear(); } + + // ****************** + protected: + + bool _DisplayFrame; + + NLMISC::CRGBA _Color; + + uint8 _DispType; + + std::string _Options; + + // Fields Defined in the XML => must not herit them from extends="" + bool _DisplayFrameDefined : 1; + bool _ColorDefined : 1; + bool _DispTypeDefined : 1; + + // Static stuff + enum + { + TextTL= 0, + TextTM, + TextTR, + TextML, + TextMM, + TextMR, + TextBL, + TextBM, + TextBR + }; + + struct SDisplayType + { + std::string Name; + sint32 BorderIds[9]; + uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR + sint32 LeftBorder; // enum + sint32 RightBorder; + sint32 TopBorder; + sint32 BottomBorder; + + // ----------------------- + SDisplayType() + { + for (uint i = 0; i < 9; ++i) + TileBorder[i] = 0; + } + }; + static std::vector _DispTypes; + }; + +} + +#endif // NL_GROUP_FRAME_H + +/* End of group_frame.h */ diff --git a/code/nel/include/nel/gui/group_header.h b/code/nel/include/nel/gui/group_header.h new file mode 100644 index 000000000..06f211f9b --- /dev/null +++ b/code/nel/include/nel/gui/group_header.h @@ -0,0 +1,93 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_GROUP_HEADER_H +#define CL_GROUP_HEADER_H + +#include "nel/gui/group_list.h" + +namespace NLGUI +{ + + class CGroupHeaderEntry; + + // ***************************************************************************************************************** + /** Display a header with movable entries. + * Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode) + * + * \author Nicolas Vizerie + * \author Nevrax France + * \date 2006 + */ + class CGroupHeader : public CGroupList + { + public: + REFLECT_EXPORT_START(CGroupHeader, CGroupList) + REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns); + REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer); + REFLECT_EXPORT_END + + CGroupHeader(const TCtorParam ¶m); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + // from CInterfaceGroup + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + sint32 getHeaderMaxSize() const { return _HeaderMaxSize; } + // get the entries in this header + void getEntries(std::vector &dest); + // ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()' + void enlargeColumns(sint32 margin); + // ensure that content of each column is visible + void resizeColumnsAndContainer(sint32 margin); + private: + sint32 _HeaderMaxSize; + int luaEnlargeColumns(CLuaState &ls); + int luaResizeColumnsAndContainer(CLuaState &ls); + }; + + // ***************************************************************************************************************** + // an entry in a header, includes a "mover control" to move it inside its parent header + // NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size' + class CGroupHeaderEntry : public CInterfaceGroup + { + public: + CGroupHeaderEntry(const TCtorParam ¶m); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + // from CInterfaceGroup + virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup); + sint32 getMinSize() const { return _MinSize; } + virtual void updateCoords(); + CInterfaceGroup *getTargetColumn() const; + + const std::string &getAHOnResize() const { return _AHOnResize; } + const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; } + + private: + sint32 _MinSize; + sint32 _ResizerSize; + std::string _TargetColumnId; + std::string _AHOnResize; + std::string _AHOnResizeParams; + }; + + +} + +#endif + diff --git a/code/nel/include/nel/gui/group_html.h b/code/nel/include/nel/gui/group_html.h new file mode 100644 index 000000000..5cdf2f930 --- /dev/null +++ b/code/nel/include/nel/gui/group_html.h @@ -0,0 +1,669 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef CL_GROUP_HTML_H +#define CL_GROUP_HTML_H + +#define CURL_STATICLIB 1 +#include + +#include "nel/misc/types_nl.h" +#include "nel/gui/interface_group.h" +#include "nel/gui/group_scrolltext.h" +#include "nel/gui/group_tree.h" +#include "nel/gui/ctrl_button.h" +#include "nel/gui/group_table.h" + +typedef std::map TStyle; + +extern "C" +{ +#include "libwww/WWWInit.h" +} + +namespace NLGUI +{ + class CCtrlButton; + class CCtrlScroll; + class CGroupList; + class CDBGroupComboBox; + class CGroupParagraph; + + + + // HTML group + /** + * Widget to have a resizable scrolltext and its scrollbar + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2002 + */ + class CGroupHTML : public CGroupScrollText + { + public: + friend void TextAdd (struct _HText *me, const char * buf, int len); + friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value); + friend void TextEndElement (_HText *me, int element_number); + friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value); + friend void TextBuild (HText * me, HTextStatus status); + friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length); + friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); + friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); + + /// Web browser options for CGroupHTML + struct SWebOptions + { + public: + /// Id of the browser ( e.g.: Chrome, Firefox, Ryzom ) + std::string appName; + /// Version of the browser + std::string appVersion; + /// Language code of the browser( e.g.: en, hu ) + std::string languageCode; + /// List of domains the widget can consider secure. + std::vector< std::string > trustedDomains; + + SWebOptions() + { + } + }; + + static SWebOptions options; + + // Constructor + CGroupHTML(const TCtorParam ¶m); + ~CGroupHTML(); + + std::string getProperty( const std::string &name ) const; + void setProperty( const std::string &name, const std::string &value ); + xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; + + // CInterfaceGroup Interface + virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); + virtual void draw (); + + // Events + virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc); + + // Browse + virtual void browse (const char *url); + + // Refresh + void refresh(); + + // submit form + void submitForm (uint formId, const char *submitButtonName); + + // Browse error + void browseError (const char *msg); + + // stop browse + void stopBrowse (); + + bool isBrowsing(); + + void clean() { stopBrowse(); updateRefreshButton(); removeContent(); } + + // Update coords + void updateCoords(); + + // New paragraph + void newParagraph(uint beginSpace); + + // End of the paragraph + void endParagraph(); + + // Timeout + void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);} + float getTimeout() const {return (float)_TimeoutValue;} + + // Some constants + NLMISC::CRGBA BgColor; + NLMISC::CRGBA ErrorColor; + NLMISC::CRGBA LinkColor; + NLMISC::CRGBA TextColor; + NLMISC::CRGBA H1Color; + NLMISC::CRGBA H2Color; + NLMISC::CRGBA H3Color; + NLMISC::CRGBA H4Color; + NLMISC::CRGBA H5Color; + NLMISC::CRGBA H6Color; + bool ErrorColorGlobalColor; + bool LinkColorGlobalColor; + bool TextColorGlobalColor; + bool H1ColorGlobalColor; + bool H2ColorGlobalColor; + bool H3ColorGlobalColor; + bool H4ColorGlobalColor; + bool H5ColorGlobalColor; + bool H6ColorGlobalColor; + uint TextFontSize; + uint H1FontSize; + uint H2FontSize; + uint H3FontSize; + uint H4FontSize; + uint H5FontSize; + uint H6FontSize; + uint TDBeginSpace; + uint PBeginSpace; + uint LIBeginSpace; + uint ULBeginSpace; + uint LIIndent; + uint ULIndent; + float LineSpaceFontFactor; + std::string DefaultButtonGroup; + std::string DefaultFormTextGroup; + std::string DefaultFormTextAreaGroup; + std::string DefaultFormSelectGroup; + std::string DefaultCheckBoxBitmapNormal; + std::string DefaultCheckBoxBitmapPushed; + std::string DefaultCheckBoxBitmapOver; + std::string DefaultBackgroundBitmapView; + std::string CurrentLinkTitle; + + // Browser home + std::string Home; + + // Undo browse: Browse the precedent url browsed. no op if none + void browseUndo (); + // Redo browse: Browse the precedent url undoed. no op if none + void browseRedo (); + // clear undo/redo + void clearUndoRedo(); + + + std::string getURL() const { return _URL; } + void setURL(const std::string &url); + + + int luaBrowse(CLuaState &ls); + int luaRefresh(CLuaState &ls); + int luaRemoveContent(CLuaState &ls); + int luaInsertText(CLuaState &ls); + int luaAddString(CLuaState &ls); + int luaAddImage(CLuaState &ls); + int luaBeginElement(CLuaState &ls); + int luaEndElement(CLuaState &ls); + int luaShowDiv(CLuaState &ls); + + REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText) + REFLECT_LUA_METHOD("browse", luaBrowse) + REFLECT_LUA_METHOD("refresh", luaRefresh) + REFLECT_LUA_METHOD("removeContent", luaRemoveContent) + REFLECT_LUA_METHOD("insertText", luaInsertText) + REFLECT_LUA_METHOD("addString", luaAddString) + REFLECT_LUA_METHOD("addImage", luaAddImage) + REFLECT_LUA_METHOD("beginElement", luaBeginElement) + REFLECT_LUA_METHOD("endElement", luaEndElement) + REFLECT_LUA_METHOD("showDiv", luaShowDiv) + REFLECT_STRING("url", getURL, setURL) + REFLECT_FLOAT("timeout", getTimeout, setTimeout) + REFLECT_EXPORT_END + + protected : + + // \name callback from libwww + + // Begin of the parsing of a HTML document + virtual void beginBuild (); + + // End of the parsing of a HTML document + virtual void endBuild (); + + // A new text block has been parsed + virtual void addText (const char * buf, int len); + + // A link has been parsed + virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value); + + // A new begin HTML element has been parsed ( for exemple) + virtual void beginElement (uint element_number, const BOOL *present, const char **value); + + // A new end HTML element has been parsed ( for exemple) + virtual void endElement (uint element_number); + + // A new begin unparsed element has been found + virtual void beginUnparsedElement(const char *buffer, int length); + + // A new end unparsed element has been found + virtual void endUnparsedElement(const char *buffer, int length); + + // Add GET params to the url + virtual void addHTTPGetParams (std::string &url, bool trustedDomain); + + // Add POST params to the libwww list + virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain); + + // the current request is terminated + virtual void requestTerminated(HTRequest *request); + + // Get Home URL + virtual std::string home(); + + // Parse style html tag + TStyle parseStyle(const std::string &str_styles); + + // Handle some work at each pass + virtual void handle (); + + // \name internal methods + + // Add a group in the current parent group + void addGroup (CInterfaceGroup *group, uint beginSpace); + + // Get the current parent group + CInterfaceGroup *getCurrentGroup(); + + // Update current paragraph dependent data + void paragraphChange (); + + // Clear the contexts info + void clearContext(); + + // Translate a char + bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const; + + // Add a string in the current paragraph + void addString(const ucstring &str); + + // Add an image in the current paragraph + void addImage(const char *image, bool globalColor, bool reloadImg=false); + + // Add a text area in the current paragraph + CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content); + + // Add a combo box in the current paragraph + CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name); + + // Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL. + CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap, + const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip); + + // Set the background color + void setBackgroundColor (const NLMISC::CRGBA &bgcolor); + + // Set the background + void setBackground (const std::string &bgtex, bool scale, bool tile); + + // Force the current string to be in a single string + void flushString(); + + // Set the title + void setTitle (const ucstring &title); + + // Lookup a url in local file system + bool lookupLocalFile (std::string &result, const char *url, bool isUrl); + + // Delete page content and prepare next page + void removeContent (); + + // Current URL + std::string _URL; + + // Current DOMAIN + bool _TrustedDomain; + + // Title prefix + ucstring _TitlePrefix; + + // Title string + ucstring _TitleString; + + // Need to browse next update coords.. + bool _BrowseNextTime; + bool _PostNextTime; + uint _PostFormId; + std::string _PostFormSubmitButton; + + // Browsing.. + bool _Browsing; + bool _Connecting; + double _TimeoutValue; // the timeout in seconds + double _ConnectingTimeout; + + // minimal embeded lua script support + // Note : any embeded script is executed immediately after the closing + // element has been found + // True when the element has been encountered + bool _ParsingLua; + bool _IgnoreText; + // the script to execute + std::string _LuaScript; + + bool _Object; + std::string _ObjectScript; + + // Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client. + static CGroupHTML *_ConnectingLock; + + // LibWWW data + class CLibWWWData *_LibWWW; + + // Current paragraph + std::string _DivName; + CGroupParagraph* _Paragraph; + inline CGroupParagraph *getParagraph() + { + return _Paragraph; + /*if (_Paragraph.empty()) + return NULL; + return _Paragraph.back();*/ + } + + // PRE mode + std::vector _PRE; + inline bool getPRE() const + { + if (_PRE.empty()) + return false; + return _PRE.back(); + } + + // UL mode + std::vector _UL; + inline bool getUL() const + { + if (_UL.empty()) + return false; + return _UL.back(); + } + + // A mode + std::vector _A; + inline bool getA() const + { + if (_A.empty()) + return false; + return _A.back(); + } + + // IL mode + bool _LI; + + // Current text color + std::vector _TextColor; + inline const NLMISC::CRGBA &getTextColor() const + { + if (_TextColor.empty()) + return TextColor; + return _TextColor.back(); + } + + // Current global color flag + std::vector _GlobalColor; + inline bool getGlobalColor() const + { + if (_GlobalColor.empty()) + return false; + return _GlobalColor.back(); + } + + // Current font size + std::vector _FontSize; + inline uint getFontSize() const + { + if (_FontSize.empty()) + return TextFontSize; + return _FontSize.back(); + } + + // Current link + std::vector _Link; + inline const char *getLink() const + { + if (_Link.empty()) + return ""; + return _Link.back().c_str(); + } + + std::vector _LinkTitle; + inline const char *getLinkTitle() const + { + if (_LinkTitle.empty()) + return ""; + return _LinkTitle.back().c_str(); + } + std::vector _LinkClass; + inline const char *getLinkClass() const + { + if (_LinkClass.empty()) + return ""; + return _LinkClass.back().c_str(); + } + + // Divs (i.e. interface group) + std::vector _Divs; + inline CInterfaceGroup *getDiv() const + { + if (_Divs.empty()) + return NULL; + return _Divs.back(); + } + + // Tables + std::vector _Tables; + inline CGroupTable *getTable() const + { + if (_Tables.empty()) + return NULL; + return _Tables.back(); + } + + // Cells + std::vector _Cells; + + // TR + std::vector _TR; + inline bool getTR() const + { + if (_TR.empty()) + return false; + return _TR.back(); + } + + // Forms + class CForm + { + public: + + class CEntry + { + public: + CEntry () + { + TextArea = NULL; + Checkbox = NULL; + ComboBox = NULL; + InitialSelection = 0; + } + + // Variable name + std::string Name; + + // Variable value + ucstring Value; + + // Text area group + CInterfaceGroup *TextArea; + + // Checkbox + CCtrlButton *Checkbox; + + // Combobox group + CDBGroupComboBox *ComboBox; + + // select values (for the