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 c57c909ed7
commit 8226c2b897
9 changed files with 678 additions and 647 deletions

View file

@ -22,18 +22,20 @@
#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
{
class CCtrlBaseButton : public CCtrlBase
{
public:
public:
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
/// Constructor
@ -161,7 +163,7 @@ public:
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
protected:
EType _Type;
// State
@ -246,8 +248,9 @@ protected:
// call it at draw
void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement);
};
};
}
#endif // NL_CTRL_BASE_BUTTON_H

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,9 +23,13 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
}
class CGroupList;
class CCtrlScroll;
class CCtrlBaseButton;
// 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 CCtrlBase;
class CCtrlBaseButton;
class CInterfaceGroup;
}
@ -62,7 +63,7 @@ typedef CInterfacePtr<class CCtrlTextButton>::TInterfacePtr CCtrlTextButtonPtr;
typedef CInterfacePtr<class CViewText>::TInterfacePtr CViewTextPtr;
typedef CInterfacePtr<class CViewTextMenu>::TInterfacePtr CViewTextMenuPtr;
typedef CInterfacePtr<CCtrlBase>::TInterfacePtr CCtrlBasePtr;
typedef CInterfacePtr<class CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<CCtrlBaseButton>::TInterfacePtr CCtrlBaseButtonPtr;
typedef CInterfacePtr<class CGroupContainer>::TInterfacePtr CGroupContainerPtr;
#endif // NL_INTERFACE_POINTER_H

View file

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