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

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-06-22 23:17:55 +02:00
parent c746f81499
commit 3213e52b60
5 changed files with 36 additions and 39 deletions

View file

@ -86,6 +86,9 @@ namespace NLGUI
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();

View file

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

View file

@ -33,8 +33,16 @@ namespace NLGUI
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
public:
DECLARE_UI_CLASS( CGroupEditBox )
/// Constructor
CGroupEditBox(const TCtorParam &param);
@ -341,6 +349,12 @@ private:
}
return false;
}
static IComboKeyHandler *comboKeyHandler;
public:
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
};

View file

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

View file

@ -26,6 +26,7 @@
#include <string>
#include "nel/gui/event_descriptor.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:
/// The EventServer Filled with Filtered Messages the InterfaceManager didn't cactch