From 3c74576ba93d79407ed087e5196532b8616bd085 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 05:11:14 +0200 Subject: [PATCH] CHANGED: #1471 CWidgetManager no longer depends on CGroupEditBox, it depends on a new class CGroupEditBoxBase instead. --HG-- branch : gui-refactoring --- .../src/interface_v3/action_handler_edit.cpp | 2 +- .../client/src/interface_v3/group_editbox.cpp | 4 +- .../client/src/interface_v3/group_editbox.h | 27 ++------ .../src/interface_v3/group_editbox_base.cpp | 14 ++++ .../src/interface_v3/group_editbox_base.h | 64 +++++++++++++++++++ .../register_interface_elements.cpp | 4 +- .../src/interface_v3/widget_manager.cpp | 9 +-- 7 files changed, 93 insertions(+), 31 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/group_editbox_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/group_editbox_base.h diff --git a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp index 8ae94c30f..d16df8fa4 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_edit.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_edit.cpp @@ -145,7 +145,7 @@ protected: if (_GroupEdit) { // If selection active - CGroupEditBox *currSelection = CGroupEditBox::getCurrSelection(); + CGroupEditBox *currSelection = dynamic_cast< CGroupEditBox* >( CGroupEditBox::getCurrSelection() ); if (currSelection != NULL) { if (currSelection != _GroupEdit) diff --git a/code/ryzom/client/src/interface_v3/group_editbox.cpp b/code/ryzom/client/src/interface_v3/group_editbox.cpp index de6f83e3a..83ca1231f 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.cpp +++ b/code/ryzom/client/src/interface_v3/group_editbox.cpp @@ -40,7 +40,6 @@ using namespace NL3D; ///////////// sint32 CGroupEditBox::_SelectCursorPos = 0; -CGroupEditBox *CGroupEditBox::_CurrSelection = NULL; CGroupEditBox *CGroupEditBox::_MenuFather = NULL; @@ -48,7 +47,7 @@ CGroupEditBox *CGroupEditBox::_MenuFather = NULL; NLMISC_REGISTER_OBJECT(CViewBase, CGroupEditBox, std::string, "edit_box"); CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : - CInterfaceGroup(param), + CGroupEditBoxBase(param), _BlinkTime(0.f), _CursorPos(0), _MaxNumChar(std::numeric_limits::max()), @@ -68,7 +67,6 @@ CGroupEditBox::CGroupEditBox(const TCtorParam ¶m) : _BlinkState(false), _CursorAtPreviousLineEnd(false), _LooseFocusOnEnter(true), - _RecoverFocusOnEnter(true), _ResetFocusOnHide(false), _BackupFatherContainerPos(false), _WantReturn(false), diff --git a/code/ryzom/client/src/interface_v3/group_editbox.h b/code/ryzom/client/src/interface_v3/group_editbox.h index e86e2bdcd..e892b134a 100644 --- a/code/ryzom/client/src/interface_v3/group_editbox.h +++ b/code/ryzom/client/src/interface_v3/group_editbox.h @@ -20,6 +20,7 @@ #define RZ_CTRL_EDITBOX_H #include "interface_group.h" +#include "group_editbox_base.h" #include "nel/3d/u_texture.h" namespace NLGUI @@ -27,12 +28,14 @@ namespace NLGUI class CEventDescriptor; } class CViewText; + // ---------------------------------------------------------------------------- -class CGroupEditBox : public CInterfaceGroup +class CGroupEditBox : public CGroupEditBoxBase { public: 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 ¶m); /// Dtor @@ -71,8 +74,6 @@ public: /// force the selection of all the text void setSelectionAll(); - // disable any current selection - static void disableSelection() { _CurrSelection = NULL; } virtual void checkCoords(); virtual void updateCoords(); @@ -99,10 +100,6 @@ public: static sint32 getSelectCursorPos () {return _SelectCursorPos;} static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;} - // Get / set current selection - static CGroupEditBox *getCurrSelection () {return _CurrSelection;} - static void setCurrSelection (CGroupEditBox *selection) {_CurrSelection=selection;} - // Get the view text const CViewText *getViewText () const {return _ViewText;} @@ -141,9 +138,6 @@ public: // True if the editBox loose the focus on enter bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;} - // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus - bool getRecoverFocusOnEnter() const {return _RecoverFocusOnEnter;} - void setRecoverFocusOnEnter(bool state) {_RecoverFocusOnEnter= state;} // virtual void clearAllEditBox(); // From CInterfaceElement @@ -161,10 +155,6 @@ public: // from CCtrlBase virtual void onKeyboardCaptureLost(); - std::string getAHOnFocus() { return _AHOnFocus; } - std::string getAHOnFocusParams() { return _AHOnFocusParams; } - - // set the input string as "default". will be reseted at first click (used for user information) void setDefaultInputString(const ucstring &str); @@ -180,14 +170,13 @@ public: int luaSetupDisplayText(CLuaState &ls); int luaSetFocusOnText(CLuaState &ls); int luaCancelFocusOnText(CLuaState &ls); - REFLECT_EXPORT_START(CGroupEditBox, CInterfaceGroup) + REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase) REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText); REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll); REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText); REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText); REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString); REFLECT_UCSTRING("uc_input_string", getInputString, setInputString); - REFLECT_BOOL("enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter); REFLECT_EXPORT_END /** Restore the original value of the edit box. @@ -220,7 +209,6 @@ protected: // Text selection static sint32 _SelectCursorPos; - static CGroupEditBox *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none bool _SelectingText; NLMISC::CRGBA _TextSelectColor; NLMISC::CRGBA _BackSelectColor; @@ -249,10 +237,6 @@ protected: std::string _AHOnFocusLost; std::string _AHOnFocusLostParams; - std::string _AHOnFocus; - std::string _AHOnFocusParams; - - // entry type TEntryType _EntryType; @@ -263,7 +247,6 @@ protected: bool _BlinkState : 1; bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines) bool _LooseFocusOnEnter : 1; - bool _RecoverFocusOnEnter : 1; bool _ResetFocusOnHide : 1; bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed. // If the edit box is at the bottom of the screen and if it expands on y diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.cpp b/code/ryzom/client/src/interface_v3/group_editbox_base.cpp new file mode 100644 index 000000000..a7c968f97 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_editbox_base.cpp @@ -0,0 +1,14 @@ +#include "group_editbox_base.h" + +CGroupEditBoxBase *CGroupEditBoxBase::_CurrSelection = NULL; + +CGroupEditBoxBase::CGroupEditBoxBase( const TCtorParam ¶m ) : +CInterfaceGroup( param ) +{ + _RecoverFocusOnEnter = true; +} + +CGroupEditBoxBase::~CGroupEditBoxBase() +{ +} + diff --git a/code/ryzom/client/src/interface_v3/group_editbox_base.h b/code/ryzom/client/src/interface_v3/group_editbox_base.h new file mode 100644 index 000000000..77aed7b08 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/group_editbox_base.h @@ -0,0 +1,64 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + + +#ifndef GROUP_EDITBOX_BASE_H +#define GROUP_EDITBOX_BASE_H + +#include "interface_group.h" + +class CGroupEditBoxBase : public CInterfaceGroup +{ +public: + DECLARE_UI_CLASS( CGroupEditBoxBase ) + + CGroupEditBoxBase( const TCtorParam ¶m ); + ~CGroupEditBoxBase(); + + // True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus + bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; } + void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; } + + std::string getAHOnFocus(){ return _AHOnFocus; } + std::string getAHOnFocusParams(){ return _AHOnFocusParams; } + + // disable any current selection + static void disableSelection(){ _CurrSelection = NULL; } + + // Get / set current selection + static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; } + static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; } + + void draw(){} + + REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup ) + REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter ); + REFLECT_EXPORT_END + +protected: + bool _RecoverFocusOnEnter : 1; + + std::string _AHOnFocus; + std::string _AHOnFocusParams; + + static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none + +private: + +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index 8848f5c41..df6c77974 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -37,6 +37,7 @@ #include "ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" +#include "group_editbox_base.h" #include "group_editbox.h" #include "group_tree.h" #include "nel/gui/reflect.h" @@ -84,7 +85,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CGroupContainer, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CDBGroupSelectNumber, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(IListSheetBase, CInterfaceGroup); - REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupEditBoxBase, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CGroupEditBoxBase); REGISTER_REFLECTABLE_CLASS(CGroupTree, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase); diff --git a/code/ryzom/client/src/interface_v3/widget_manager.cpp b/code/ryzom/client/src/interface_v3/widget_manager.cpp index 1c7da44b2..083e9c355 100644 --- a/code/ryzom/client/src/interface_v3/widget_manager.cpp +++ b/code/ryzom/client/src/interface_v3/widget_manager.cpp @@ -19,7 +19,8 @@ #include "group_container.h" #include "group_in_scene.h" #include "view_pointer.h" -#include "group_editbox.h" + +#include "group_editbox_base.h" #include "ctrl_draggable.h" CWidgetManager* CWidgetManager::instance = NULL; @@ -1127,8 +1128,8 @@ void CWidgetManager::setCapturePointerRight(CCtrlBase *c) // ------------------------------------------------------------------------------------------------ void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) { - CGroupEditBox *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); - CGroupEditBox *newEb= dynamic_cast(c); + CGroupEditBoxBase *oldEb= dynamic_cast((CCtrlBase*)_CaptureKeyboard); + CGroupEditBoxBase *newEb= dynamic_cast(c); if (_CaptureKeyboard && _CaptureKeyboard != c) { @@ -1141,7 +1142,7 @@ void CWidgetManager::setCaptureKeyboard(CCtrlBase *c) } if ( newEb ) { - CGroupEditBox::disableSelection(); + CGroupEditBoxBase::disableSelection(); if (!newEb->getAHOnFocus().empty()) {