CHANGED: #1471 CCtrlBaseButton is now part of the NLGUI namespace.

This commit is contained in:
dfighter1985 2012-06-15 23:30:27 +02:00
parent b90b19358f
commit cbe2e8b1d6
9 changed files with 678 additions and 647 deletions

View file

@ -22,18 +22,20 @@
#include "nel/gui/ctrl_base.h" #include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
namespace NLGUI
{
// *************************************************************************** // ***************************************************************************
/** /**
* Base Class For Buttons. * Base Class For Buttons.
* \author Lionel Berenguier * \author Lionel Berenguier
* \author Nevrax France * \author Nevrax France
* \date 2003 * \date 2003
*/ */
class CCtrlBaseButton : public CCtrlBase class CCtrlBaseButton : public CCtrlBase
{ {
public: public:
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount }; enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
/// Constructor /// Constructor
@ -161,7 +163,7 @@ public:
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction); REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END REFLECT_EXPORT_END
protected: protected:
EType _Type; EType _Type;
// State // State
@ -246,8 +248,9 @@ protected:
// call it at draw // call it at draw
void updateOver(bool &lastOver); void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement); virtual void elementCaptured(CCtrlBase *capturedElement);
}; };
}
#endif // NL_CTRL_BASE_BUTTON_H #endif // NL_CTRL_BASE_BUTTON_H

View file

@ -26,19 +26,22 @@
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
namespace
// ***************************************************************************
static const uint KEY_REPEAT_MIN = 100;
static const uint KEY_REPEAT_MAX = 750;
sint64 CCtrlBaseButton::_LastLeftClickDate = 0;
NLMISC::CRefPtr<CCtrlBaseButton> CCtrlBaseButton::_LastLeftClickButton;
// ***************************************************************************
CCtrlBaseButton::CCtrlBaseButton(const TCtorParam &param) : CCtrlBase(param), _Type(ToggleButton)
{ {
const uint KEY_REPEAT_MIN = 100;
const uint KEY_REPEAT_MAX = 750;
}
namespace NLGUI
{
sint64 CCtrlBaseButton::_LastLeftClickDate = 0;
NLMISC::CRefPtr<CCtrlBaseButton> CCtrlBaseButton::_LastLeftClickButton;
// ***************************************************************************
CCtrlBaseButton::CCtrlBaseButton(const TCtorParam &param) : CCtrlBase(param), _Type(ToggleButton)
{
_Pushed = _Over = false; _Pushed = _Over = false;
_Frozen = false; _Frozen = false;
_FrozenHalfTone = true; _FrozenHalfTone = true;
@ -57,13 +60,13 @@ CCtrlBaseButton::CCtrlBaseButton(const TCtorParam &param) : CCtrlBase(param), _T
_AHOnClockTick = NULL; _AHOnClockTick = NULL;
_AHOnLeftLongClick = NULL; _AHOnLeftLongClick = NULL;
_AHOnLeftDblClick = NULL; _AHOnLeftDblClick = NULL;
} }
// *************************************************************************** // ***************************************************************************
bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup) bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup)
{ {
CXMLAutoPtr prop; CXMLAutoPtr prop;
//try to get props that can be inherited from groups //try to get props that can be inherited from groups
@ -182,22 +185,22 @@ bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup)
_FrozenHalfTone = convertBool(prop); _FrozenHalfTone = convertBool(prop);
return true; return true;
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::setModulateGlobalColorAll(bool state) void CCtrlBaseButton::setModulateGlobalColorAll(bool state)
{ {
setModulateGlobalColor(state); setModulateGlobalColor(state);
setModulateGlobalColorNormal(state); setModulateGlobalColorNormal(state);
setModulateGlobalColorPushed(state); setModulateGlobalColorPushed(state);
setModulateGlobalColorOver(state); setModulateGlobalColorOver(state);
} }
// *************************************************************************** // ***************************************************************************
bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event) bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{ {
if (CCtrlBase::handleEvent(event)) return true; if (CCtrlBase::handleEvent(event)) return true;
if (!_Active || _Frozen) if (!_Active || _Frozen)
return false; return false;
@ -357,11 +360,11 @@ bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
} }
} }
return false; return false;
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::initRBRef() void CCtrlBaseButton::initRBRef()
{ {
if (_RBRef != NULL) return; if (_RBRef != NULL) return;
nlassert(_Parent); nlassert(_Parent);
const vector<CCtrlBase*> &vCB = _Parent->getControls(); const vector<CCtrlBase*> &vCB = _Parent->getControls();
@ -378,22 +381,22 @@ void CCtrlBaseButton::initRBRef()
// If we are the first radio button of the group and not added // If we are the first radio button of the group and not added
if (i == vCB.size()) if (i == vCB.size())
_RBRef = &this->_RBRefBut; _RBRef = &this->_RBRefBut;
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::initRBRefFromRadioButton(CCtrlBaseButton * pBut) void CCtrlBaseButton::initRBRefFromRadioButton(CCtrlBaseButton * pBut)
{ {
if(pBut && pBut->_Type == RadioButton) if(pBut && pBut->_Type == RadioButton)
{ {
_RBRef = &(pBut->_RBRefBut); _RBRef = &(pBut->_RBRefBut);
_RBRefBut=NULL; _RBRefBut=NULL;
} }
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::setPushed (bool state) void CCtrlBaseButton::setPushed (bool state)
{ {
_Pushed = state; _Pushed = state;
if (_Type == RadioButton && _RBRef) if (_Type == RadioButton && _RBRef)
@ -408,38 +411,38 @@ void CCtrlBaseButton::setPushed (bool state)
*_RBRef = NULL; // After that : All radio buttons are NOT pushed *_RBRef = NULL; // After that : All radio buttons are NOT pushed
} }
} }
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::setFrozen (bool state) void CCtrlBaseButton::setFrozen (bool state)
{ {
_Frozen = state; _Frozen = state;
if (_Frozen) if (_Frozen)
{ {
_Pushed = false; _Pushed = false;
_Over = false; _Over = false;
} }
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::setFrozenHalfTone(bool enabled) void CCtrlBaseButton::setFrozenHalfTone(bool enabled)
{ {
_FrozenHalfTone = enabled; _FrozenHalfTone = enabled;
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::unselect() void CCtrlBaseButton::unselect()
{ {
if (_Type == RadioButton) if (_Type == RadioButton)
{ {
if (_RBRef) *_RBRef = NULL; if (_RBRef) *_RBRef = NULL;
} }
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::updateOver(bool &lastOver) void CCtrlBaseButton::updateOver(bool &lastOver)
{ {
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled()) if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
{ {
_Over = false; _Over = false;
@ -476,22 +479,22 @@ void CCtrlBaseButton::updateOver(bool &lastOver)
_Over = false; _Over = false;
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement) void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement)
{ {
// if not me, then reset my '_Over' // if not me, then reset my '_Over'
if (capturedElement != this) if (capturedElement != this)
{ {
_Over = false; _Over = false;
} }
} }
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::runLeftClickAction() void CCtrlBaseButton::runLeftClickAction()
{ {
if(_AHOnLeftClick != NULL) if(_AHOnLeftClick != NULL)
{ {
@ -500,16 +503,18 @@ void CCtrlBaseButton::runLeftClickAction()
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams); CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId()); //pIM->submitEvent ("button_click:"+getId());
} }
} }
// *************************************************************************** // ***************************************************************************
int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls) int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls)
{ {
const char *funcName = "onLeftClick"; const char *funcName = "onLeftClick";
CLuaIHM::checkArgCount(ls, funcName, 0); CLuaIHM::checkArgCount(ls, funcName, 0);
runLeftClickAction(); runLeftClickAction();
return 0; return 0;
}
} }

View file

@ -26,9 +26,14 @@
#include "game_share/skills.h" #include "game_share/skills.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
// *************************************************************************** // ***************************************************************************
class CDBCtrlSheet; class CDBCtrlSheet;
class CCtrlBaseButton;
class CSBrickSheet; class CSBrickSheet;
class CViewBitmap; class CViewBitmap;
class CViewText; class CViewText;

View file

@ -22,11 +22,13 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
// *************************************************************************** // ***************************************************************************
class CViewText; class CViewText;
class CCtrlBaseButton;
class CGroupMenu; class CGroupMenu;
// *************************************************************************** // ***************************************************************************

View file

@ -23,9 +23,12 @@
#include "list_sheet_base.h" #include "list_sheet_base.h"
#include "dbctrl_sheet.h" #include "dbctrl_sheet.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
// *************************************************************************** // ***************************************************************************
class CCtrlBaseButton;
class CCtrlScroll; class CCtrlScroll;
class CGroupContainer; class CGroupContainer;

View file

@ -23,11 +23,15 @@
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
// *************************************************************************** // ***************************************************************************
class CViewBitmap; class CViewBitmap;
class CViewText; class CViewText;
class CCtrlBaseButton;
// *************************************************************************** // ***************************************************************************

View file

@ -23,9 +23,13 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h" #include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
class CGroupList; class CGroupList;
class CCtrlScroll; class CCtrlScroll;
class CCtrlBaseButton;
// Can be used to build a chat window or anything that displays sequences of strings // Can be used to build a chat window or anything that displays sequences of strings
/** /**

View file

@ -25,6 +25,7 @@ namespace NLGUI
{ {
class CInterfaceElement; class CInterfaceElement;
class CCtrlBase; class CCtrlBase;
class CCtrlBaseButton;
class CInterfaceGroup; class CInterfaceGroup;
} }
@ -62,7 +63,7 @@ typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr;
typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr; typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr; typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr; typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr; typedef CInterfacePtr<CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr; typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr;
#endif // NL_INTERFACE_POINTER_H #endif // NL_INTERFACE_POINTER_H

View file

@ -25,9 +25,13 @@ extern "C"
#include "WWWInit.h" #include "WWWInit.h"
} }
namespace NLGUI
{
class CCtrlBaseButton;
}
class CGroupList; class CGroupList;
class CCtrlScroll; class CCtrlScroll;
class CCtrlBaseButton;
// *************************************************************************** // ***************************************************************************