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,232 +22,235 @@
#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.
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CCtrlBaseButton : public CCtrlBase
{ {
public: // ***************************************************************************
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount }; /**
* Base Class For Buttons.
/// Constructor * \author Lionel Berenguier
CCtrlBaseButton(const TCtorParam &param); * \author Nevrax France
* \date 2003
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; }
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(); class CCtrlBaseButton : public CCtrlBase
//@}
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
/// \name Handlers
// @{
// Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
// get Event part
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); }
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click
void runLeftClickAction();
// Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
std::string getListMenuRight () { return _ListMenuRight.toString(); }
// @}
int luaRunLeftClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
REFLECT_BOOL("frozen", getFrozen, setFrozen);
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
EType _Type;
// State
bool _Pushed : 1;
bool _Over : 1;
bool _OverWhenPushed : 1;
bool _Frozen : 1;
bool _FrozenHalfTone : 1;
bool _ClickWhenPushed : 1;
bool _ModulateGlobalColorNormal : 1;
bool _ModulateGlobalColorPushed : 1;
bool _ModulateGlobalColorOver : 1;
bool _LeftLongClickHandled : 1; // Is it already handled ?
bool _LeftDblClickHandled : 1;
///\name radio button specific
//@{
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
// There is only one radio button per group that own the reference (the first one)
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
//@}
// Colors
NLMISC::CRGBA _ColorNormal;
NLMISC::CRGBA _ColorPushed;
NLMISC::CRGBA _ColorOver;
///\name Long click specific
//@{
sint64 _LeftLongClickDate; // Time we left click down
//@}
// for double click : last date at which last left click occurred
static sint64 _LastLeftClickDate;
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
///\name Action Handler
//@{
IActionHandler *_AHOnOver;
CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
std::string _AHOnLeftClickStringParams;
IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick;
CStringShared _AHLeftDblClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHRightClickParams;
IActionHandler *_AHOnClockTick;
CStringShared _AHClockTickParams;
IActionHandler *_AHOnLeftLongClick;
CStringShared _AHLeftLongClickParams;
//@}
CStringShared _ListMenuLeft;
CStringShared _ListMenuRight;
// get the colors modulated on request
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
{ {
NLMISC::CRGBA rgba = _ColorNormal;
if(_ModulateGlobalColorNormal)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorPushed;
if(_ModulateGlobalColorPushed)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorOver;
if(_ModulateGlobalColorOver)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
// call it at draw public:
void updateOver(bool &lastOver); enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
virtual void elementCaptured(CCtrlBase *capturedElement);
};
/// Constructor
CCtrlBaseButton(const TCtorParam &param);
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; }
void setClickWhenPushed(bool click) { _ClickWhenPushed = click; }
bool getClickWhenPushed() const { return _ClickWhenPushed; }
void setPushed (bool state);
bool getPushed () const { return _Pushed; }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
// Set half tone mode for the display of frozen buttons. Default is true.
void setFrozenHalfTone(bool enabled);
bool getFrozenHalfTone() const { return _FrozenHalfTone; }
// if the radio is a radio button, then all radio button are unselected
void unselect();
// @}
/// \name Colors
// @{
void setColor(NLMISC::CRGBA col) { _ColorNormal = col; }
void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; }
void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; }
NLMISC::CRGBA getColor() const { return _ColorNormal; }
NLMISC::CRGBA getColorPushed() const { return _ColorPushed; }
NLMISC::CRGBA getColorOver() const { return _ColorOver; }
// Override because mustupdate 3 states
void setModulateGlobalColorAll(bool state);
void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;}
void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;}
void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;}
virtual sint32 getAlpha() const { return _ColorNormal.A; }
virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; }
std::string getColorAsString() const
{ return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " +
NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); }
std::string getColorOverAsString() const
{ return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " +
NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); }
std::string getColorPushedAsString() const
{ return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " +
NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); }
void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); }
void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); }
void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); }
// @}
///\name radio button specific
//@{
/** Initialize radio button reference
* Advanced:
* NB: must call initRBRef() for radio button if button is created without parse().
* NB: setParent() must be called before (else assert)
*/
void initRBRef();
//@}
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
/// \name Handlers
// @{
// Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
// get Event part
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); }
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click
void runLeftClickAction();
// Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
std::string getListMenuRight () { return _ListMenuRight.toString(); }
// @}
int luaRunLeftClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
REFLECT_BOOL("frozen", getFrozen, setFrozen);
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
EType _Type;
// State
bool _Pushed : 1;
bool _Over : 1;
bool _OverWhenPushed : 1;
bool _Frozen : 1;
bool _FrozenHalfTone : 1;
bool _ClickWhenPushed : 1;
bool _ModulateGlobalColorNormal : 1;
bool _ModulateGlobalColorPushed : 1;
bool _ModulateGlobalColorOver : 1;
bool _LeftLongClickHandled : 1; // Is it already handled ?
bool _LeftDblClickHandled : 1;
///\name radio button specific
//@{
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
// There is only one radio button per group that own the reference (the first one)
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
//@}
// Colors
NLMISC::CRGBA _ColorNormal;
NLMISC::CRGBA _ColorPushed;
NLMISC::CRGBA _ColorOver;
///\name Long click specific
//@{
sint64 _LeftLongClickDate; // Time we left click down
//@}
// for double click : last date at which last left click occurred
static sint64 _LastLeftClickDate;
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
///\name Action Handler
//@{
IActionHandler *_AHOnOver;
CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
std::string _AHOnLeftClickStringParams;
IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick;
CStringShared _AHLeftDblClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHRightClickParams;
IActionHandler *_AHOnClockTick;
CStringShared _AHClockTickParams;
IActionHandler *_AHOnLeftLongClick;
CStringShared _AHLeftLongClickParams;
//@}
CStringShared _ListMenuLeft;
CStringShared _ListMenuRight;
// get the colors modulated on request
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorNormal;
if(_ModulateGlobalColorNormal)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorPushed;
if(_ModulateGlobalColorPushed)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorOver;
if(_ModulateGlobalColorOver)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
// call it at draw
void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement);
};
}
#endif // NL_CTRL_BASE_BUTTON_H #endif // NL_CTRL_BASE_BUTTON_H

View file

@ -26,490 +26,495 @@
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)
{ {
_Pushed = _Over = false; const uint KEY_REPEAT_MIN = 100;
_Frozen = false; const uint KEY_REPEAT_MAX = 750;
_FrozenHalfTone = true;
_OverWhenPushed = true;
_ColorOver = _ColorPushed = _ColorNormal = NLMISC::CRGBA(255,255,255,255);
_ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= true;
_LeftLongClickHandled = true;
_LeftDblClickHandled = false;
_ClickWhenPushed = false;
_RBRefBut = NULL;
_RBRef = NULL;
_AHOnOver = NULL;
_AHOnLeftClick = NULL;
_AHOnRightClick = NULL;
_AHOnClockTick = NULL;
_AHOnLeftLongClick = NULL;
_AHOnLeftDblClick = NULL;
} }
namespace NLGUI
// ***************************************************************************
bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup)
{ {
CXMLAutoPtr prop;
//try to get props that can be inherited from groups sint64 CCtrlBaseButton::_LastLeftClickDate = 0;
//if a property is not defined, try to find it in the parent group. NLMISC::CRefPtr<CCtrlBaseButton> CCtrlBaseButton::_LastLeftClickButton;
//if it is undefined, set it to zero
if (! CCtrlBase::parse(cur,parentGroup) )
return false;
_Over = false;
// *** try to get the NEEDED specific props // ***************************************************************************
prop = xmlGetProp (cur, (xmlChar*)"button_type"); CCtrlBaseButton::CCtrlBaseButton(const TCtorParam &param) : CCtrlBase(param), _Type(ToggleButton)
string type;
if (prop) type = (const char*) prop;
if (type.empty() || type == "toggle_button")
{ {
_Type = ToggleButton; _Pushed = _Over = false;
} _Frozen = false;
else if (type == "push_button") _FrozenHalfTone = true;
{ _OverWhenPushed = true;
_Type = PushButton; _ColorOver = _ColorPushed = _ColorNormal = NLMISC::CRGBA(255,255,255,255);
} _ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= true;
else if (type == "radio_button") _LeftLongClickHandled = true;
{ _LeftDblClickHandled = false;
_Type = RadioButton; _ClickWhenPushed = false;
_RBRefBut = NULL;
_RBRef = NULL;
initRBRef(); _AHOnOver = NULL;
if (_Pushed) _AHOnLeftClick = NULL;
*_RBRef = this; _AHOnRightClick = NULL;
} _AHOnClockTick = NULL;
else _AHOnLeftLongClick = NULL;
{ _AHOnLeftDblClick = NULL;
nlinfo(("cannot parse button type for button " + getId()).c_str());
} }
prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed");
_Pushed = false;
if (prop)
_Pushed = convertBool(prop);
prop= (char*) xmlGetProp (cur, (xmlChar*)"over_when_pushed");
_OverWhenPushed = true;
if (prop)
_OverWhenPushed = convertBool(prop);
prop= (char*) xmlGetProp (cur, (xmlChar*)"click_when_pushed");
_ClickWhenPushed = false;
if (prop)
_ClickWhenPushed = convertBool(prop);
// *** Read Colors
// get color normal
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
_ColorNormal = CRGBA(255,255,255,255);
if (prop)
_ColorNormal = convertColor (prop);
// Get ColorPushed
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_pushed" );
_ColorPushed = CRGBA(255,255,255,255);
if (prop)
_ColorPushed = convertColor(prop);
// Get ColorOver
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_over" );
_ColorOver = CRGBA(255,255,255,255);
if (prop)
_ColorOver = convertColor(prop);
// Default: take "global_color" param interface_element option.
_ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= getModulateGlobalColor();
// Read special global_color for each state
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_normal" );
if (prop) _ModulateGlobalColorNormal= convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_pushed" );
if (prop) _ModulateGlobalColorPushed= convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_over" );
if (prop) _ModulateGlobalColorOver= convertBool(prop);
// *** Read Action handlers // ***************************************************************************
CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams); bool CCtrlBaseButton::parse (xmlNodePtr cur,CInterfaceGroup * parentGroup)
CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams);
CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams);
CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams);
CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams);
CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams);
// Context menu association
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" );
if (prop)
{ {
_ListMenuLeft = NLMISC::toLower(std::string((const char *) prop)); CXMLAutoPtr prop;
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
_ListMenuRight = NLMISC::toLower(std::string((const char *) prop));
}
// list menu on both clicks
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" );
if (prop)
{
setListMenuBoth(NLMISC::toLower(std::string((const char *) prop)));
}
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen"); //try to get props that can be inherited from groups
_Frozen = false; //if a property is not defined, try to find it in the parent group.
if (prop) //if it is undefined, set it to zero
_Frozen = convertBool(prop); if (! CCtrlBase::parse(cur,parentGroup) )
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen_half_tone");
_FrozenHalfTone = true;
if (prop)
_FrozenHalfTone = convertBool(prop);
return true;
}
// ***************************************************************************
void CCtrlBaseButton::setModulateGlobalColorAll(bool state)
{
setModulateGlobalColor(state);
setModulateGlobalColorNormal(state);
setModulateGlobalColorPushed(state);
setModulateGlobalColorOver(state);
}
// ***************************************************************************
bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{
if (CCtrlBase::handleEvent(event)) return true;
if (!_Active || _Frozen)
return false;
sint64 T1 = NLMISC::CTime::getLocalTime();
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
{
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
return false;
_LeftLongClickHandled = true;
}
if (!((eventDesc.getX() >= _XReal) &&
(eventDesc.getX() < (_XReal + _WReal))&&
(eventDesc.getY() > _YReal) &&
(eventDesc.getY() <= (_YReal+ _HReal))))
return false; return false;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown) _Over = false;
{
if (_AHOnLeftDblClick)
{
if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay())
{
CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams);
_LeftDblClickHandled = true;
_LastLeftClickButton = NULL;
return true;
}
}
if (_AHOnLeftLongClick != NULL) // *** try to get the NEEDED specific props
{ prop = xmlGetProp (cur, (xmlChar*)"button_type");
_LeftLongClickHandled = false; string type;
_LeftLongClickDate = T1; if (prop) type = (const char*) prop;
} if (type.empty() || type == "toggle_button")
_LeftDblClickHandled = false; {
_LastLeftClickButton = NULL; _Type = ToggleButton;
return true; }
else if (type == "push_button")
{
_Type = PushButton;
}
else if (type == "radio_button")
{
_Type = RadioButton;
initRBRef();
if (_Pushed)
*_RBRef = this;
}
else
{
nlinfo(("cannot parse button type for button " + getId()).c_str());
} }
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup) prop= (char*) xmlGetProp (cur, (xmlChar*)"pushed");
_Pushed = false;
if (prop)
_Pushed = convertBool(prop);
prop= (char*) xmlGetProp (cur, (xmlChar*)"over_when_pushed");
_OverWhenPushed = true;
if (prop)
_OverWhenPushed = convertBool(prop);
prop= (char*) xmlGetProp (cur, (xmlChar*)"click_when_pushed");
_ClickWhenPushed = false;
if (prop)
_ClickWhenPushed = convertBool(prop);
// *** Read Colors
// get color normal
prop= (char*) xmlGetProp( cur, (xmlChar*)"color" );
_ColorNormal = CRGBA(255,255,255,255);
if (prop)
_ColorNormal = convertColor (prop);
// Get ColorPushed
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_pushed" );
_ColorPushed = CRGBA(255,255,255,255);
if (prop)
_ColorPushed = convertColor(prop);
// Get ColorOver
prop= (char*) xmlGetProp( cur, (xmlChar*)"col_over" );
_ColorOver = CRGBA(255,255,255,255);
if (prop)
_ColorOver = convertColor(prop);
// Default: take "global_color" param interface_element option.
_ModulateGlobalColorNormal= _ModulateGlobalColorPushed= _ModulateGlobalColorOver= getModulateGlobalColor();
// Read special global_color for each state
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_normal" );
if (prop) _ModulateGlobalColorNormal= convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_pushed" );
if (prop) _ModulateGlobalColorPushed= convertBool(prop);
prop = (char*) xmlGetProp( cur, (xmlChar*)"global_color_over" );
if (prop) _ModulateGlobalColorOver= convertBool(prop);
// *** Read Action handlers
CAHManager::getInstance()->parseAH(cur, "onover", "params_over", _AHOnOver, _AHOverParams);
CAHManager::getInstance()->parseAH(cur, "onclick_l", "params_l", _AHOnLeftClick, _AHLeftClickParams);
CAHManager::getInstance()->parseAH(cur, "ondblclick_l", "params_dblclick_l", _AHOnLeftDblClick, _AHLeftDblClickParams);
CAHManager::getInstance()->parseAH(cur, "onclick_r", "params_r", _AHOnRightClick, _AHRightClickParams);
CAHManager::getInstance()->parseAH(cur, "onlongclick_l", "params_longclick_l", _AHOnLeftLongClick, _AHLeftLongClickParams);
CAHManager::getInstance()->parseAH(cur, "onclock_tick", "params_clock_tick", _AHOnClockTick, _AHClockTickParams);
// Context menu association
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" );
if (prop)
{ {
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) _ListMenuLeft = NLMISC::toLower(std::string((const char *) prop));
}
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" );
if (prop)
{
_ListMenuRight = NLMISC::toLower(std::string((const char *) prop));
}
// list menu on both clicks
prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" );
if (prop)
{
setListMenuBoth(NLMISC::toLower(std::string((const char *) prop)));
}
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen");
_Frozen = false;
if (prop)
_Frozen = convertBool(prop);
prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen_half_tone");
_FrozenHalfTone = true;
if (prop)
_FrozenHalfTone = convertBool(prop);
return true;
}
// ***************************************************************************
void CCtrlBaseButton::setModulateGlobalColorAll(bool state)
{
setModulateGlobalColor(state);
setModulateGlobalColorNormal(state);
setModulateGlobalColorPushed(state);
setModulateGlobalColorOver(state);
}
// ***************************************************************************
bool CCtrlBaseButton::handleEvent (const NLGUI::CEventDescriptor& event)
{
if (CCtrlBase::handleEvent(event)) return true;
if (!_Active || _Frozen)
return false;
sint64 T1 = NLMISC::CTime::getLocalTime();
if (event.getType() == NLGUI::CEventDescriptor::mouse)
{
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
{
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
return false;
_LeftLongClickHandled = true;
}
if (!((eventDesc.getX() >= _XReal) &&
(eventDesc.getX() < (_XReal + _WReal))&&
(eventDesc.getY() > _YReal) &&
(eventDesc.getY() <= (_YReal+ _HReal))))
return false; return false;
if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown)
{ {
if (_AHOnLeftDblClick)
{
if ((CCtrlBaseButton *) _LastLeftClickButton == this && (T1 - _LastLeftClickDate) < CWidgetManager::getInstance()->getUserDblClickDelay())
{
CAHManager::getInstance()->runActionHandler (_AHOnLeftDblClick, this, _AHLeftDblClickParams);
_LeftDblClickHandled = true;
_LastLeftClickButton = NULL;
return true;
}
}
if (_AHOnLeftLongClick != NULL)
{
_LeftLongClickHandled = false;
_LeftLongClickDate = T1;
}
_LeftDblClickHandled = false; _LeftDblClickHandled = false;
_LastLeftClickButton = NULL;
return true; return true;
} }
// Do not launch 2 times action handler if we are already pushed ! except if we want. if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftup)
if (!_ClickWhenPushed)
{ {
if ((_Type == RadioButton) && _RBRef && (*_RBRef == this)) if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
return true; return false;
}
if (_Type == RadioButton) if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled
{
_Pushed = true;
if(_RBRef) *_RBRef = this;
}
if (_Type == ToggleButton)
_Pushed = !_Pushed;
/*
// RunAction
if(_AHOnLeftClick != NULL)
{
//nlinfo("clicked on %s", _Id.c_str());
pIM->submitEvent ("button_click:"+getId());//TEMP
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId());
}
*/
runLeftClickAction();
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)
// Run Menu
if (!_ListMenuLeft.empty())
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft);
if (_AHOnLeftDblClick != NULL)
{
_LastLeftClickDate = T1;
_LastLeftClickButton = this;
}
// Always return true on LeftClick.
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)
{
_LastLeftClickButton = NULL;
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
{
_LastLeftClickButton = NULL;
bool handled= false;
if (CWidgetManager::getInstance()->getCapturePointerRight() != this)
return false;
// RunAction
if(_AHOnRightClick != NULL)
{
handled= true;
CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams);
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted
// Run Menu
if (!_ListMenuRight .empty())
{
handled= true;
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight);
}
// If not handled here, ret to parent
return handled;
}
}
else if (event.getType() == NLGUI::CEventDescriptor::system)
{
const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event;
if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick)
{
if (_AHOnClockTick != NULL)
{
CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams);
}
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
if (!_LeftLongClickHandled)
{ {
uint nVal = 50; _LeftDblClickHandled = false;
CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED"); return true;
if (pNL != NULL) }
nVal = pNL->getValue32();
uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f); // Do not launch 2 times action handler if we are already pushed ! except if we want.
if ((T1 - _LeftLongClickDate) > repeatDelay) if (!_ClickWhenPushed)
{
if ((_Type == RadioButton) && _RBRef && (*_RBRef == this))
return true;
}
if (_Type == RadioButton)
{
_Pushed = true;
if(_RBRef) *_RBRef = this;
}
if (_Type == ToggleButton)
_Pushed = !_Pushed;
/*
// RunAction
if(_AHOnLeftClick != NULL)
{
//nlinfo("clicked on %s", _Id.c_str());
pIM->submitEvent ("button_click:"+getId());//TEMP
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId());
}
*/
runLeftClickAction();
if (CWidgetManager::getInstance()->getCapturePointerLeft() == NULL) return true; // event handler may release cpature from this object (if it is removed for example)
// Run Menu
if (!_ListMenuLeft.empty())
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuLeft);
if (_AHOnLeftDblClick != NULL)
{
_LastLeftClickDate = T1;
_LastLeftClickButton = this;
}
// Always return true on LeftClick.
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightdown)
{
_LastLeftClickButton = NULL;
return true;
}
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
{
_LastLeftClickButton = NULL;
bool handled= false;
if (CWidgetManager::getInstance()->getCapturePointerRight() != this)
return false;
// RunAction
if(_AHOnRightClick != NULL)
{
handled= true;
CAHManager::getInstance()->runActionHandler (_AHOnRightClick, this, _AHRightClickParams);
}
if (CWidgetManager::getInstance()->getCapturePointerRight() == NULL) return true; // if this become NULL, this ctrl has been deleted
// Run Menu
if (!_ListMenuRight .empty())
{
handled= true;
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight);
}
// If not handled here, ret to parent
return handled;
}
}
else if (event.getType() == NLGUI::CEventDescriptor::system)
{
const NLGUI::CEventDescriptorSystem &systemEvent = (const NLGUI::CEventDescriptorSystem &) event;
if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::clocktick)
{
if (_AHOnClockTick != NULL)
{
CAHManager::getInstance()->runActionHandler(_AHOnClockTick, this, _AHClockTickParams);
}
if (CWidgetManager::getInstance()->getCapturePointerLeft() == this)
{
if (!_LeftLongClickHandled)
{ {
_LeftLongClickHandled = true; uint nVal = 50;
CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams); CCDBNodeLeaf *pNL = NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:KEY_REPEAT_SPEED");
if (pNL != NULL)
nVal = pNL->getValue32();
uint repeatDelay = (uint)(KEY_REPEAT_MIN + (KEY_REPEAT_MAX-KEY_REPEAT_MIN) * (float)nVal / 100.0f);
if ((T1 - _LeftLongClickDate) > repeatDelay)
{
_LeftLongClickHandled = true;
CAHManager::getInstance()->runActionHandler(_AHOnLeftLongClick, this, _AHLeftLongClickParams);
}
} }
} }
} }
} }
return false;
} }
return false;
}
// *************************************************************************** // ***************************************************************************
void CCtrlBaseButton::initRBRef() void CCtrlBaseButton::initRBRef()
{
if (_RBRef != NULL) return;
nlassert(_Parent);
const vector<CCtrlBase*> &vCB = _Parent->getControls();
uint i = 0;
for (i = 0; i < vCB.size(); ++i)
{ {
CCtrlBaseButton *pBut = dynamic_cast<CCtrlBaseButton*>(vCB[i]); if (_RBRef != NULL) return;
if (pBut && pBut->_Type == RadioButton) nlassert(_Parent);
const vector<CCtrlBase*> &vCB = _Parent->getControls();
uint i = 0;
for (i = 0; i < vCB.size(); ++i)
{ {
_RBRef = &pBut->_RBRefBut; CCtrlBaseButton *pBut = dynamic_cast<CCtrlBaseButton*>(vCB[i]);
break; if (pBut && pBut->_Type == RadioButton)
{
_RBRef = &pBut->_RBRefBut;
break;
}
}
// 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)
{
if(pBut && pBut->_Type == RadioButton)
{
_RBRef = &(pBut->_RBRefBut);
_RBRefBut=NULL;
} }
} }
// 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::setPushed (bool state)
if(pBut && pBut->_Type == RadioButton)
{ {
_RBRef = &(pBut->_RBRefBut); _Pushed = state;
_RBRefBut=NULL;
}
}
if (_Type == RadioButton && _RBRef)
// ***************************************************************************
void CCtrlBaseButton::setPushed (bool state)
{
_Pushed = state;
if (_Type == RadioButton && _RBRef)
{
if (state == true)
{ {
*_RBRef = this; if (state == true)
{
*_RBRef = this;
}
else
{
if (*_RBRef == this) // I have to be pushed to unpush me
*_RBRef = NULL; // After that : All radio buttons are NOT pushed
}
}
}
// ***************************************************************************
void CCtrlBaseButton::setFrozen (bool state)
{
_Frozen = state;
if (_Frozen)
{
_Pushed = false;
_Over = false;
}
}
// ***************************************************************************
void CCtrlBaseButton::setFrozenHalfTone(bool enabled)
{
_FrozenHalfTone = enabled;
}
// ***************************************************************************
void CCtrlBaseButton::unselect()
{
if (_Type == RadioButton)
{
if (_RBRef) *_RBRef = NULL;
}
}
// ***************************************************************************
void CCtrlBaseButton::updateOver(bool &lastOver)
{
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
_Over = false;
return;
}
if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL)
{
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
{
_Over = false;
}
return;
}
const vector<CCtrlBase*> &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer ();
if (!_Frozen)
{
uint32 i;
lastOver = _Over;
// show over if it is the last control that has the same father
CCtrlBase *candidate = NULL;
for (i = 0; i < rVB.size(); ++i)
{
if (rVB[i]->getParent() == this->getParent())
{
candidate = rVB[i];
}
}
_Over = (candidate == this);
} }
else else
{ _Over = false;
if (*_RBRef == this) // I have to be pushed to unpush me
*_RBRef = NULL; // After that : All radio buttons are NOT pushed
}
}
}
// ***************************************************************************
void CCtrlBaseButton::setFrozen (bool state)
{
_Frozen = state;
if (_Frozen)
{
_Pushed = false;
_Over = false;
}
}
// ***************************************************************************
void CCtrlBaseButton::setFrozenHalfTone(bool enabled)
{
_FrozenHalfTone = enabled;
}
// ***************************************************************************
void CCtrlBaseButton::unselect()
{
if (_Type == RadioButton)
{
if (_RBRef) *_RBRef = NULL;
}
}
// ***************************************************************************
void CCtrlBaseButton::updateOver(bool &lastOver)
{
if (!CWidgetManager::getInstance()->isMouseHandlingEnabled())
{
_Over = false;
return;
} }
if (CWidgetManager::getInstance()->getCapturePointerLeft() != NULL) // ***************************************************************************
void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement)
{ {
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this) // if not me, then reset my '_Over'
if (capturedElement != this)
{ {
_Over = false; _Over = false;
} }
return;
} }
const vector<CCtrlBase*> &rVB = CWidgetManager::getInstance()->getCtrlsUnderPointer ();
if (!_Frozen) // ***************************************************************************
void CCtrlBaseButton::runLeftClickAction()
{ {
uint32 i; if(_AHOnLeftClick != NULL)
lastOver = _Over;
// show over if it is the last control that has the same father
CCtrlBase *candidate = NULL;
for (i = 0; i < rVB.size(); ++i)
{ {
if (rVB[i]->getParent() == this->getParent())
{ //nlinfo("clicked on %s", _Id.c_str());
candidate = rVB[i]; CAHManager::getInstance()->submitEvent( "button_click:" + getId() );
} CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId());
} }
_Over = (candidate == this);
} }
else
_Over = false;
// ***************************************************************************
} int CCtrlBaseButton::luaRunLeftClickAction(CLuaState &ls)
// ***************************************************************************
void CCtrlBaseButton::elementCaptured(CCtrlBase *capturedElement)
{
// if not me, then reset my '_Over'
if (capturedElement != this)
{ {
_Over = false; const char *funcName = "onLeftClick";
CLuaIHM::checkArgCount(ls, funcName, 0);
runLeftClickAction();
return 0;
} }
}
// ***************************************************************************
void CCtrlBaseButton::runLeftClickAction()
{
if(_AHOnLeftClick != NULL)
{
//nlinfo("clicked on %s", _Id.c_str());
CAHManager::getInstance()->submitEvent( "button_click:" + getId() );
CAHManager::getInstance()->runActionHandler (_AHOnLeftClick, this, _AHLeftClickParams);
//pIM->submitEvent ("button_click:"+getId());
}
}
// ***************************************************************************
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" #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;
// *************************************************************************** // ***************************************************************************