CHANGED: #1471 CGroupEditBox no longer depends on CGroupContainer, and CInputHandlerManager.

This commit is contained in:
dfighter1985 2012-06-22 23:17:55 +02:00
parent ab8b296adc
commit 2da27bdc2d
5 changed files with 36 additions and 39 deletions

View file

@ -86,6 +86,9 @@ namespace NLGUI
uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; } uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; }
virtual bool isGrayed() const{ return false; } virtual bool isGrayed() const{ return false; }
virtual bool getTouchFlag(bool clearFlag) const{ return false; }
virtual void backupPosition(){}
virtual void restorePosition(){}
protected: protected:
void triggerAlphaSettingsChangedAH(); void triggerAlphaSettingsChangedAH();

View file

@ -14,21 +14,17 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "group_editbox.h" #include "group_editbox.h"
#include "interface_manager.h"
#include "input_handler_manager.h"
#include "nel/misc/command.h" #include "nel/misc/command.h"
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/interface_options.h" #include "nel/gui/interface_options.h"
#include "dbctrl_sheet.h" #include "nel/gui/ctrl_draggable.h"
#include "group_container.h" #include "nel/gui/group_container_base.h"
#include "../time_client.h"
#include "nel/gui/lua_ihm.h" #include "nel/gui/lua_ihm.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/db_manager.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -41,6 +37,7 @@ using namespace NL3D;
sint32 CGroupEditBox::_SelectCursorPos = 0; sint32 CGroupEditBox::_SelectCursorPos = 0;
CGroupEditBox *CGroupEditBox::_MenuFather = NULL; CGroupEditBox *CGroupEditBox::_MenuFather = NULL;
CGroupEditBox::IComboKeyHandler* CGroupEditBox::comboKeyHandler = NULL;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -93,7 +90,6 @@ CGroupEditBox::CGroupEditBox(const TCtorParam &param) :
CGroupEditBox::~CGroupEditBox() CGroupEditBox::~CGroupEditBox()
{ {
if (this == _CurrSelection) _CurrSelection = NULL; if (this == _CurrSelection) _CurrSelection = NULL;
CInterfaceManager *im = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this) if (CWidgetManager::getInstance()->getCaptureKeyboard() == this || CWidgetManager::getInstance()->getOldCaptureKeyboard() == this)
{ {
CWidgetManager::getInstance()->resetCaptureKeyboard(); CWidgetManager::getInstance()->resetCaptureKeyboard();
@ -106,8 +102,6 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
if(!CInterfaceGroup::parse(cur, parentGroup)) if(!CInterfaceGroup::parse(cur, parentGroup))
return false; return false;
CXMLAutoPtr prop; CXMLAutoPtr prop;
// CInterfaceManager *pIM = CInterfaceManager::getInstance();
// CViewRenderer &rVR = *CViewRenderer::getInstance();
if (! CInterfaceGroup::parse(cur,parentGroup) ) if (! CInterfaceGroup::parse(cur,parentGroup) )
{ {
@ -216,7 +210,6 @@ bool CGroupEditBox::parse(xmlNodePtr cur, CInterfaceGroup * parentGroup)
void CGroupEditBox::draw () void CGroupEditBox::draw ()
{ {
// //
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
// //
/*CRGBA col; /*CRGBA col;
@ -296,7 +289,7 @@ void CGroupEditBox::draw ()
// Display the cursor if needed // Display the cursor if needed
if (CWidgetManager::getInstance()->getCaptureKeyboard () == this) if (CWidgetManager::getInstance()->getCaptureKeyboard () == this)
{ {
_BlinkTime += DT; _BlinkTime += 0.0025f;
if (_BlinkTime > 0.25f) if (_BlinkTime > 0.25f)
{ {
_BlinkTime = fmodf(_BlinkTime, 0.25f); _BlinkTime = fmodf(_BlinkTime, 0.25f);
@ -566,7 +559,6 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK)
break; break;
// OTHER // OTHER
default: default:
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if ((rEDK.getChar() == KeyRETURN) && !_WantReturn) if ((rEDK.getChar() == KeyRETURN) && !_WantReturn)
{ {
// update historic. // update historic.
@ -583,7 +575,6 @@ void CGroupEditBox::handleEventChar(const NLGUI::CEventDescriptorKey &rEDK)
_CursorPos = 0; _CursorPos = 0;
// loose the keyboard focus // loose the keyboard focus
CInterfaceManager *im = CInterfaceManager::getInstance();
if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0) if (NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:ENTER_DONT_QUIT_CB")->getValue32() == 0)
{ {
if(_LooseFocusOnEnter) if(_LooseFocusOnEnter)
@ -717,7 +708,6 @@ void CGroupEditBox::handleEventString(const NLGUI::CEventDescriptorKey &rEDK)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CGroupEditBox::undo() bool CGroupEditBox::undo()
{ {
CInterfaceManager *im = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanUndo) return false; if (!_CanUndo) return false;
_ModifiedInputString = _InputString; _ModifiedInputString = _InputString;
@ -732,7 +722,6 @@ bool CGroupEditBox::undo()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool CGroupEditBox::redo() bool CGroupEditBox::redo()
{ {
CInterfaceManager *im = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false; if (CWidgetManager::getInstance()->getCaptureKeyboard() != this) return false;
if (!_CanRedo) return false; if (!_CanRedo) return false;
setInputString(_ModifiedInputString); setInputString(_ModifiedInputString);
@ -748,11 +737,10 @@ void CGroupEditBox::triggerOnChangeAH()
{ {
_CanUndo = true; _CanUndo = true;
_CanRedo = false; _CanRedo = false;
if (!_AHOnChange.empty()) if (!_AHOnChange.empty())
{
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange); CAHManager::getInstance()->runActionHandler(_AHOnChange, this, _ParamsOnChange);
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -856,8 +844,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event)
else else
{ {
// Look into the input handler Manager if the key combo has to be considered as handled // Look into the input handler Manager if the key combo has to be considered as handled
CInputHandlerManager *pIH= CInputHandlerManager::getInstance(); if( ( CGroupEditBox::comboKeyHandler != NULL ) && comboKeyHandler->isComboKeyChat(rEDK) )
if( pIH->isComboKeyChat(rEDK) )
return true; return true;
else else
return false; return false;
@ -871,8 +858,6 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event)
///////////////// /////////////////
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup) if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
{ {
if (CWidgetManager::getInstance()->getCapturePointerRight() == this) if (CWidgetManager::getInstance()->getCapturePointerRight() == this)
@ -880,7 +865,7 @@ bool CGroupEditBox::handleEvent (const NLGUI::CEventDescriptor& event)
CWidgetManager::getInstance()->setCapturePointerRight(NULL); CWidgetManager::getInstance()->setCapturePointerRight(NULL);
if (!_ListMenuRight.empty()) if (!_ListMenuRight.empty())
{ {
if (CDBCtrlSheet::getDraggedSheet() == NULL) if (CCtrlDraggable::getDraggedSheet() == NULL)
{ {
_MenuFather = this; _MenuFather = this;
CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight); CWidgetManager::getInstance()->enableModalWindow (this, _ListMenuRight);
@ -1069,7 +1054,7 @@ void CGroupEditBox::updateCoords()
if (_BackupFatherContainerPos) if (_BackupFatherContainerPos)
{ {
CGroupContainer *gc = static_cast< CGroupContainer* >( getEnclosingContainer() ); CGroupContainerBase *gc = static_cast< CGroupContainerBase* >( getEnclosingContainer() );
if (gc && !gc->getTouchFlag(true)) if (gc && !gc->getTouchFlag(true))
{ {
@ -1301,12 +1286,9 @@ void CGroupEditBox::setCommand(const ucstring &command, bool execute)
// *************************************************************************** // ***************************************************************************
void CGroupEditBox::makeTopWindow() void CGroupEditBox::makeTopWindow()
{ {
CInterfaceManager *im = CInterfaceManager::getInstance();
CInterfaceGroup *root = getRootWindow(); CInterfaceGroup *root = getRootWindow();
if (root) if(root)
{
CWidgetManager::getInstance()->setTopWindow(root); CWidgetManager::getInstance()->setTopWindow(root);
}
} }
// *************************************************************************** // ***************************************************************************
@ -1405,10 +1387,8 @@ void CGroupEditBox::elementCaptured(CCtrlBase *capturedElement)
void CGroupEditBox::onKeyboardCaptureLost() void CGroupEditBox::onKeyboardCaptureLost()
{ {
if (!_AHOnFocusLost.empty()) if (!_AHOnFocusLost.empty())
{
CInterfaceManager *im = CInterfaceManager::getInstance();
CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams); CAHManager::getInstance()->runActionHandler(_AHOnFocusLost, this, _AHOnFocusLostParams);
}
} }
// *************************************************************************** // ***************************************************************************
@ -1428,7 +1408,6 @@ void CGroupEditBox::setFocusOnText()
return; return;
// else set the focus // else set the focus
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CWidgetManager::getInstance()->setCaptureKeyboard (this); CWidgetManager::getInstance()->setCaptureKeyboard (this);
_CurrSelection = this; _CurrSelection = this;
@ -1454,7 +1433,6 @@ int CGroupEditBox::luaCancelFocusOnText(CLuaState &ls)
const char *funcName = "cancelFocusOnText"; const char *funcName = "cancelFocusOnText";
CLuaIHM::checkArgCount(ls, funcName, 0); CLuaIHM::checkArgCount(ls, funcName, 0);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this) if (CWidgetManager::getInstance()->getCaptureKeyboard()==this || CWidgetManager::getInstance()->getOldCaptureKeyboard()==this)
CWidgetManager::getInstance()->resetCaptureKeyboard(); CWidgetManager::getInstance()->resetCaptureKeyboard();
@ -1490,7 +1468,6 @@ void CGroupEditBox::setFrozen (bool state)
// if frozen, loose the focus // if frozen, loose the focus
if(_Frozen) if(_Frozen)
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
// stop capture and selection // stop capture and selection
CWidgetManager::getInstance()->setCaptureKeyboard (NULL); CWidgetManager::getInstance()->setCaptureKeyboard (NULL);
if(_CurrSelection==this) _CurrSelection = NULL; if(_CurrSelection==this) _CurrSelection = NULL;

View file

@ -33,8 +33,16 @@ namespace NLGUI
class CGroupEditBox : public CGroupEditBoxBase class CGroupEditBox : public CGroupEditBoxBase
{ {
public: 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 enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with
public:
DECLARE_UI_CLASS( CGroupEditBox ) DECLARE_UI_CLASS( CGroupEditBox )
/// Constructor /// Constructor
CGroupEditBox(const TCtorParam &param); CGroupEditBox(const TCtorParam &param);
@ -341,6 +349,12 @@ private:
} }
return false; return false;
} }
static IComboKeyHandler *comboKeyHandler;
public:
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
}; };

View file

@ -67,11 +67,13 @@ CInputHandlerManager::CInputHandlerManager()
_RecoverFocusLost = false; _RecoverFocusLost = false;
inputHandler.setListener( CInterfaceManager::getInstance() ); inputHandler.setListener( CInterfaceManager::getInstance() );
CGroupEditBox::setComboKeyHandler( this );
} }
// *************************************************************************** // ***************************************************************************
CInputHandlerManager::~CInputHandlerManager() CInputHandlerManager::~CInputHandlerManager()
{ {
CGroupEditBox::setComboKeyHandler( NULL );
} }
// ******************************************************************************************** // ********************************************************************************************

View file

@ -26,6 +26,7 @@
#include <string> #include <string>
#include "nel/gui/event_descriptor.h" #include "nel/gui/event_descriptor.h"
#include "nel/gui/input_handler.h" #include "nel/gui/input_handler.h"
#include "group_editbox.h"
/** /**
@ -40,7 +41,7 @@
*/ */
class CInputHandlerManager : public NLMISC::IEventListener class CInputHandlerManager : public NLMISC::IEventListener, public CGroupEditBox::IComboKeyHandler
{ {
public: public:
/// The EventServer Filled with Filtered Messages the InterfaceManager didn't cactch /// The EventServer Filled with Filtered Messages the InterfaceManager didn't cactch