forms/source/solar/control/navtoolbar.cxx |   81 +++++-------------------------
 forms/source/solar/inc/navtoolbar.hxx     |   17 +-----
 svx/uiconfig/ui/absrecbox.ui              |    3 -
 3 files changed, 21 insertions(+), 80 deletions(-)

New commits:
commit 444f3552ac4ecedc076d9f91e6e0e4e463c1f77a
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Jul 22 17:29:51 2020 +0100
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jul 23 13:03:31 2020 +0200

    weld RecordPositionInput
    
    Change-Id: I9ea192c5efe330d150c94d3dcbda6fdc9c15e01d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99248
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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: */
diff --git a/svx/uiconfig/ui/absrecbox.ui b/svx/uiconfig/ui/absrecbox.ui
index f61f75509ecc..5b06bc879578 100644
--- a/svx/uiconfig/ui/absrecbox.ui
+++ b/svx/uiconfig/ui/absrecbox.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
+<!-- Generated with glade 3.36.0 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.18"/>
   <object class="GtkBox" id="AbsRecBox">
@@ -13,6 +13,7 @@
         <property name="can_focus">True</property>
         <property name="hexpand">True</property>
         <property name="width_chars">4</property>
+        <property name="shadow_type">none</property>
       </object>
       <packing>
         <property name="expand">False</property>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to