diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-07-22 17:29:51 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-23 13:03:31 +0200 |
commit | 444f3552ac4ecedc076d9f91e6e0e4e463c1f77a (patch) | |
tree | c22b2878b7c6a1ad38c7de2e366a14bf9f3d41a5 /forms | |
parent | 89e97b7e5d309ccfd0ea44e455105520ff557eb1 (diff) |
weld RecordPositionInput
Change-Id: I9ea192c5efe330d150c94d3dcbda6fdc9c15e01d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99248
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/solar/control/navtoolbar.cxx | 81 | ||||
-rw-r--r-- | forms/source/solar/inc/navtoolbar.hxx | 17 |
2 files changed, 19 insertions, 79 deletions
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx index 687f4dffd1b7..2f0147d04307 100644 --- a/forms/source/solar/control/navtoolbar.cxx +++ b/forms/source/solar/control/navtoolbar.cxx @@ -147,7 +147,6 @@ namespace frm implInit( ); } - NavigationToolBar::~NavigationToolBar( ) { disposeOnce(); @@ -162,7 +161,6 @@ namespace frm vcl::Window::dispose(); } - void NavigationToolBar::setDispatcher( const IFeatureDispatcher* _pDispatcher ) { m_pDispatcher = _pDispatcher; @@ -188,7 +186,6 @@ namespace frm } } - void NavigationToolBar::implEnableItem( sal_uInt16 _nItemId, bool _bEnabled ) { m_pToolbar->EnableItem( _nItemId, _bEnabled ); @@ -200,7 +197,6 @@ namespace frm m_pToolbar->EnableItem( LID_RECORD_FILLER, _bEnabled ); } - void NavigationToolBar::enableFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( static_cast<sal_uInt16>(_nFeatureId) ) != ToolBox::ITEM_NOTFOUND, @@ -209,7 +205,6 @@ namespace frm implEnableItem( static_cast<sal_uInt16>(_nFeatureId), _bEnabled ); } - void NavigationToolBar::checkFeature( sal_Int16 _nFeatureId, bool _bEnabled ) { DBG_ASSERT( m_pToolbar->GetItemPos( static_cast<sal_uInt16>(_nFeatureId) ) != ToolBox::ITEM_NOTFOUND, @@ -218,7 +213,6 @@ namespace frm m_pToolbar->CheckItem( static_cast<sal_uInt16>(_nFeatureId), _bEnabled ); } - void NavigationToolBar::setFeatureText( sal_Int16 _nFeatureId, const OUString& _rText ) { DBG_ASSERT( m_pToolbar->GetItemPos( static_cast<sal_uInt16>(_nFeatureId) ) != ToolBox::ITEM_NOTFOUND, @@ -229,14 +223,13 @@ namespace frm { if (_nFeatureId == FormFeature::TotalRecords) static_cast<LabelItemWindow*>(pItemWindow)->set_label(_rText); - else - pItemWindow->SetText( _rText ); + else if (_nFeatureId == FormFeature::MoveAbsolute) + static_cast<RecordPositionInput*>(pItemWindow)->set_text(_rText); } else m_pToolbar->SetItemText( static_cast<sal_uInt16>(_nFeatureId), _rText ); } - void NavigationToolBar::implInit( ) { m_pToolbar = VclPtr<ImplNavToolBar>::Create( this ); @@ -488,7 +481,6 @@ namespace frm } } - void NavigationToolBar::Resize() { // resize/position the toolbox as a whole @@ -501,7 +493,6 @@ namespace frm Window::Resize(); } - void NavigationToolBar::SetControlBackground() { Window::SetControlBackground(); @@ -511,7 +502,6 @@ namespace frm implUpdateImages(); } - void NavigationToolBar::SetControlBackground( const Color& _rColor ) { Window::SetControlBackground( _rColor ); @@ -521,7 +511,6 @@ namespace frm implUpdateImages(); } - void NavigationToolBar::SetTextLineColor( ) { Window::SetTextLineColor( ); @@ -529,7 +518,6 @@ namespace frm forEachItemWindow( &NavigationToolBar::setTextLineColor, nullptr ); } - void NavigationToolBar::SetTextLineColor( const Color& _rColor ) { Window::SetTextLineColor( _rColor ); @@ -537,7 +525,6 @@ namespace frm forEachItemWindow( &NavigationToolBar::setTextLineColor, &_rColor ); } - void NavigationToolBar::forEachItemWindow( ItemWindowHandler _handler ) { for ( ToolBox::ImplToolItems::size_type item = 0; item < m_pToolbar->GetItemCount(); ++item ) @@ -568,7 +555,6 @@ namespace frm _pItemWindow->SetControlBackground(); } - void NavigationToolBar::setTextLineColor( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow, const void* _pColor ) { if ( _pColor ) @@ -576,14 +562,6 @@ namespace frm else _pItemWindow->SetTextLineColor(); } -#if 0 - - void NavigationToolBar::setItemWindowZoom( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow, const void* /* _pParam */ ) const - { - _pItemWindow->SetZoom( GetZoom() ); - _pItemWindow->SetZoomedPointFont( IsControlFont() ? GetControlFont() : GetPointFont() ); - } -#endif void NavigationToolBar::setItemControlFont( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow ) const { @@ -593,7 +571,6 @@ namespace frm _pItemWindow->SetControlFont( ); } - void NavigationToolBar::setItemControlForeground( sal_uInt16 /* _nItemId */, vcl::Window* _pItemWindow ) const { if ( IsControlForeground() ) @@ -603,9 +580,10 @@ namespace frm _pItemWindow->SetTextColor( GetTextColor() ); } - void NavigationToolBar::adjustItemWindowWidth( sal_uInt16 _nItemId, vcl::Window* _pItemWindow ) const { + int nHeight = 0; + OUString sItemText; switch ( _nItemId ) { @@ -619,6 +597,7 @@ namespace frm case FormFeature::MoveAbsolute: sItemText = "12345678"; + nHeight = _pItemWindow->get_preferred_size().Height(); break; case FormFeature::TotalRecords: @@ -626,7 +605,10 @@ namespace frm break; } - Size aSize( _pItemWindow->GetTextWidth( sItemText ), /* _pItemWindow->GetSizePixel( ).Height() */ _pItemWindow->GetTextHeight() + 4 ); + if (nHeight == 0) + nHeight = _pItemWindow->GetTextHeight() + 4; + + Size aSize(_pItemWindow->GetTextWidth(sItemText), nHeight); aSize.AdjustWidth(6 ); _pItemWindow->SetSizePixel( aSize ); @@ -638,16 +620,10 @@ namespace frm _pItemWindow->EnableRTL( *static_cast< const sal_Bool* >( _pIsRTLEnabled ) ); } - RecordPositionInput::RecordPositionInput( vcl::Window* _pParent ) - :NumericField( _pParent, WB_BORDER | WB_VCENTER ) - ,m_pDispatcher( nullptr ) + RecordPositionInput::RecordPositionInput(vcl::Window* pParent) + : RecordItemWindow(pParent) + , m_pDispatcher( nullptr ) { - SetMin( 1 ); - SetFirst( 1 ); - SetSpinSize( 1 ); - SetDecimalDigits( 0 ); - SetStrictFormat( true ); - SetBorderStyle( WindowBorderStyle::MONO ); } void RecordPositionInput::setDispatcher( const IFeatureDispatcher* _pDispatcher ) @@ -655,38 +631,13 @@ namespace frm m_pDispatcher = _pDispatcher; } - void RecordPositionInput::FirePosition( bool _bForce ) - { - if ( _bForce || IsValueChangedFromSaved() ) - { - sal_Int64 nRecord = GetValue(); - if ( nRecord < GetMin() || nRecord > GetMax() ) - return; - - if ( m_pDispatcher ) - m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( static_cast<sal_Int32>(nRecord) ) ); - - SaveValue(); - } - } - - - void RecordPositionInput::LoseFocus() - { - FirePosition( false ); - } - - - void RecordPositionInput::KeyInput( const KeyEvent& rKeyEvent ) + void RecordPositionInput::PositionFired(sal_Int64 nRecord) { - if( rKeyEvent.GetKeyCode() == KEY_RETURN && !GetText().isEmpty() ) - FirePosition( true ); - else - NumericField::KeyInput( rKeyEvent ); + if (!m_pDispatcher) + return; + m_pDispatcher->dispatchWithArgument( FormFeature::MoveAbsolute, "Position", makeAny( static_cast<sal_Int32>(nRecord) ) ); } - } // namespace frm - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx index 5b643b367ce1..576ddb951293 100644 --- a/forms/source/solar/inc/navtoolbar.hxx +++ b/forms/source/solar/inc/navtoolbar.hxx @@ -20,15 +20,11 @@ #ifndef INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX #define INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX -#include <vcl/field.hxx> - +#include <svx/recorditemwindow.hxx> #include <memory> - namespace frm { - - class IFeatureDispatcher; class DocumentCommandImageProvider; class ICommandDescriptionProvider; @@ -148,7 +144,7 @@ namespace frm static void enableItemRTL( sal_uInt16 /*_nItemId*/, vcl::Window* _pItemWindow, const void* _pIsRTLEnabled ); }; - class RecordPositionInput : public NumericField + class RecordPositionInput final : public RecordItemWindow { private: const IFeatureDispatcher* m_pDispatcher; @@ -160,19 +156,12 @@ namespace frm */ void setDispatcher( const IFeatureDispatcher* _pDispatcher ); - protected: - // Window overridables - virtual void LoseFocus() override; - virtual void KeyInput( const KeyEvent& rKeyEvent ) override; - private: - void FirePosition( bool _bForce ); + virtual void PositionFired(sal_Int64 nRecord) override; }; - } // namespace frm - #endif // INCLUDED_FORMS_SOURCE_SOLAR_INC_NAVTOOLBAR_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |