[Libreoffice-commits] .: sc/source vcl/inc vcl/source

Jan Holesovsky kendy at kemper.freedesktop.org
Mon May 28 00:27:07 PDT 2012


 sc/source/ui/app/inputwin.cxx  |   74 ++++++++++++++++++-----------------------
 sc/source/ui/inc/inputwin.hxx  |    5 +-
 vcl/inc/vcl/decoview.hxx       |    1 
 vcl/inc/vcl/window.hxx         |    1 
 vcl/source/window/brdwin.cxx   |    4 ++
 vcl/source/window/decoview.cxx |   16 ++++++++
 6 files changed, 57 insertions(+), 44 deletions(-)

New commits:
commit d02e19e3d8697132f63eca353047a572b1e459ea
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Mon May 28 09:07:11 2012 +0200

    calc input line: Native rendering of the input line.
    
    [Including few adjustments in the way the scrollbar is being calculated.]
    
    Change-Id: I247ee139864a119bdec9dead64e51d9aace385ff

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 6f7caa6..53c5962 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -82,12 +82,11 @@
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/frame/XController.hpp>
 
-#define TEXT_STARTPOS       3
-#define TEXT_MULTI_STARTPOS 5
 #define THESIZE             1000000 //!!! langt... :-)
 #define TBX_WINDOW_HEIGHT   22 // in Pixeln - fuer alle Systeme gleich?
 #define LEFT_OFFSET         5
 #define INPUTWIN_MULTILINES 6
+const long BUTTON_OFFSET = 2; // space bettween input line and the button to expand / collapse
 
 using com::sun::star::uno::Reference;
 using com::sun::star::uno::UNO_QUERY;
@@ -114,6 +113,16 @@ enum ScNameInputType
 };
 
 
+ScTextWndBase::ScTextWndBase( Window* pParent,  WinBits nStyle )
+    : Window ( pParent, nStyle )
+{
+    if ( IsNativeControlSupported( CTRL_EDITBOX, PART_ENTIRE_CONTROL ) )
+    {
+        SetType( WINDOW_EDIT );
+        SetBorderStyle( WINDOW_BORDER_NWF );
+    }
+}
+
 //==================================================================
 //  class ScInputWindowWrapper
 //==================================================================
@@ -873,27 +882,24 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt )
 ScInputBarGroup::ScInputBarGroup(Window* pParent, ScTabViewShell* pViewSh)
     :   ScTextWndBase        ( pParent, WinBits(WB_HIDE |  WB_TABSTOP ) ),
         aMultiTextWnd        ( this, pViewSh ),
-        aButton              ( this, WB_TABSTOP | WB_RECTSTYLE ),
+        aButton              ( this, WB_TABSTOP | WB_RECTSTYLE | WB_SMALLSTYLE ),
         aScrollBar           ( this, WB_TABSTOP | WB_VERT | WB_DRAG ),
         nVertOffset          ( 0 )
 {
       aMultiTextWnd.Show();
       aMultiTextWnd.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
-      aMultiTextWnd.SetHelpId		( HID_INSWIN_INPUT );
-
-      // Hmm we can't seem to increase the width of the scrollbar :-/
-      // seems locked to GetSettings().GetStyleSettings().GetScrollBarSize()
-      // But... I guess if needs be we can get around this somehow, doesn't look
-      // too bad at the size from 'Settings' for me
-      // set button width to scrollbar width then for the moment
-      aButton.SetClickHdl	( LINK( this, ScInputBarGroup, ClickHdl ) );
-      // Add 2 pixels to compensate for the fact that scrollbar of the same width doesn't quite match
-      aButton.SetSizePixel(Size(GetSettings().GetStyleSettings().GetScrollBarSize() + 2, aMultiTextWnd.GetPixelHeightForLines(1)) );
+      aMultiTextWnd.SetHelpId( HID_INSWIN_INPUT );
+
+      Size aSize( GetSettings().GetStyleSettings().GetScrollBarSize(), aMultiTextWnd.GetPixelHeightForLines(1) );
+
+      aButton.SetClickHdl( LINK( this, ScInputBarGroup, ClickHdl ) );
+      aButton.SetSizePixel( aSize );
       aButton.Enable();
       aButton.SetSymbol( SYMBOL_SPIN_DOWN  );
       aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) );
       aButton.Show();
-      aScrollBar.SetSizePixel( aButton.GetSizePixel() );
+
+      aScrollBar.SetSizePixel( aSize );
       aScrollBar.SetScrollHdl( LINK( this, ScInputBarGroup, Impl_ScrollHdl ) );
 }
 
@@ -943,10 +949,10 @@ void ScInputBarGroup::Resize()
     Size aSize  = GetSizePixel();
     aSize.Width() = Max( ((long)(nWidth - nLeft - LEFT_OFFSET)), (long)0 );
 
-    aScrollBar.SetPosPixel(Point( aSize.Width() - aButton.GetSizePixel().Width() + 2, aButton.GetSizePixel().Height() ) );
+    aScrollBar.SetPosPixel(Point( aSize.Width() - aButton.GetSizePixel().Width(), aButton.GetSizePixel().Height() ) );
 
     Size aTmpSize( aSize );
-    aTmpSize.Width() = aTmpSize.Width() - aButton.GetSizePixel().Width();
+    aTmpSize.Width() = aTmpSize.Width() - aButton.GetSizePixel().Width() - BUTTON_OFFSET;
     aMultiTextWnd.SetSizePixel(aTmpSize);
 
     aMultiTextWnd.Resize();
@@ -983,7 +989,7 @@ void ScInputBarGroup::Resize()
         aScrollBar.Hide();
     }
 
-    aButton.SetPosPixel(Point(aSize.Width() - ( aButton.GetSizePixel().Width()  ) + 1 ,0));
+    aButton.SetPosPixel(Point(aSize.Width() - aButton.GetSizePixel().Width(), 0));
 
     Invalidate();
 }
@@ -1133,16 +1139,10 @@ ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen, ScTabViewShell* pViewSh
         mnLastExpandedLines( INPUTWIN_MULTILINES ),
         mbInvalidate( false )
 {
-    // Calculate the text height, need to set a font for that. Probably we could set the font
-    // here ( on this Window ) and avoid the temp Window. OTOH vcl is such a mystery I prefer
-    // to minimise possible unexpected side-affects this way
-    Window aTmp(this, WB_BORDER );
-    aTmp.SetFont(aTextFont);
-    mnTextHeight = LogicToPixel(Size(0,aTmp.GetTextHeight())).Height() ;
+    mnTextHeight = GetTextHeight();
     Size aBorder;
     aBorder = CalcWindowSize( aBorder);
     mnBorderHeight = aBorder.Height();
-    nTextStartPos = TEXT_MULTI_STARTPOS;
 }
 
 ScMultiTextWnd::~ScMultiTextWnd()
@@ -1190,21 +1190,17 @@ void ScMultiTextWnd::Resize()
 {
     // Only Height is recalculated here, Width is applied from
     // parent/container window
-    Size aTextBoxSize  = GetSizePixel();
+    Size aTextBoxSize = GetSizePixel();
 
-    aTextBoxSize.Height()=( GetPixelHeightForLines( mnLines ) );
-    SetSizePixel(aTextBoxSize);
+    aTextBoxSize.Height() = GetPixelHeightForLines( mnLines );
+    SetSizePixel( aTextBoxSize );
 
     if(pEditView)
     {
         Size aOutputSize = GetOutputSizePixel();
-        Point aPos1(TEXT_STARTPOS,0);
-        Point aPos2(aOutputSize.Width(),aOutputSize.Height());
 
-        pEditView->SetOutputArea(
-            PixelToLogic(Rectangle(aPos1, aPos2)));
-
-        pEditEngine->SetPaperSize( PixelToLogic(Size((aOutputSize.Width()-= 2 * nTextStartPos - 1), 10000 ) ));
+        pEditView->SetOutputArea( PixelToLogic( Rectangle( Point(), aOutputSize ) ) );
+        pEditEngine->SetPaperSize( PixelToLogic( Size( aOutputSize.Width(), 10000 ) ) );
     }
 
     SetScrollBarRange();
@@ -1340,7 +1336,6 @@ void ScMultiTextWnd::InitEditEngine()
     pEditEngine = pNew;
 
     Size barSize=GetSizePixel();
-    barSize.Width() -= (2*nTextStartPos-4);
     pEditEngine->SetUpdateMode( false );
     pEditEngine->SetPaperSize( PixelToLogic(Size(barSize.Width(),10000)) );
     pEditEngine->SetWordDelimiters(
@@ -1437,7 +1432,6 @@ ScTextWnd::ScTextWnd( Window* pParent, ScTabViewShell* pViewSh )
         bIsInsertMode( sal_True ),
         bFormulaMode ( false ),
         bInputMode   ( false ),
-        nTextStartPos ( TEXT_STARTPOS ),
         mpViewShell(pViewSh)
 {
     EnableRTL( false );     // EditEngine can't be used with VCL EnableRTL
@@ -1492,11 +1486,11 @@ void ScTextWnd::Paint( const Rectangle& rRec )
                     - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
 //      if (nDiff<2) nDiff=2;       // mind. 1 Pixel
 
-        long nStartPos = nTextStartPos;
+        long nStartPos = 0;
         if ( bIsRTL )
         {
             //  right-align
-            nStartPos += GetOutputSizePixel().Width() - 2*nTextStartPos -
+            nStartPos += GetOutputSizePixel().Width() -
                         LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
 
             //  LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem
@@ -1514,10 +1508,8 @@ void ScTextWnd::Resize()
         long nDiff =  aSize.Height()
                     - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
 
-        aSize.Width() -= 2 * nTextStartPos - 1;
-
         pEditView->SetOutputArea(
-            PixelToLogic( Rectangle( Point( nTextStartPos, (nDiff > 0) ? nDiff/2 : 1 ),
+            PixelToLogic( Rectangle( Point( 0, (nDiff > 0) ? nDiff/2 : 1 ),
                                      aSize ) ) );
     }
 }
@@ -1896,7 +1888,7 @@ void ScTextWnd::SetTextString( const String& rNewString )
                     nDifPos = 0;
 
                                                 // -1 wegen Rundung und "A"
-                Point aLogicStart = PixelToLogic(Point(nTextStartPos-1,0));
+                Point aLogicStart = PixelToLogic(Point(0,0));
                 long nStartPos = aLogicStart.X();
                 long nInvPos = nStartPos;
                 if (nDifPos)
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index da12b53..84fb421 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -54,7 +54,7 @@ class ScTabViewShell;
 class ScTextWndBase : public Window
 {
 public:
-    ScTextWndBase( Window* pParent,  WinBits nStyle ) : Window ( pParent, nStyle ) {}
+    ScTextWndBase( Window* pParent,  WinBits nStyle );
     virtual void            InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
     virtual void            RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) = 0;
     virtual void            SetTextString( const String& rString ) = 0;
@@ -134,7 +134,6 @@ protected:
     // #102710#; this flag should be true if a key input or a command is handled
     // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
     sal_Bool        bInputMode;
-    sal_Int16       nTextStartPos;
 
 private:
     ScTabViewShell* mpViewShell;
@@ -242,7 +241,7 @@ public:
 private:
     void            TriggerToolboxLayout();
     ScMultiTextWnd  aMultiTextWnd;
-    PushButton      aButton;
+    ImageButton     aButton;
     ScrollBar       aScrollBar;
     long            nVertOffset;
     DECL_LINK( ClickHdl, void* );
diff --git a/vcl/inc/vcl/decoview.hxx b/vcl/inc/vcl/decoview.hxx
index b6b6f0f..40bdb2c 100644
--- a/vcl/inc/vcl/decoview.hxx
+++ b/vcl/inc/vcl/decoview.hxx
@@ -53,6 +53,7 @@ class OutputDevice;
 #define FRAME_DRAW_DOUBLEIN                 ((sal_uInt16)0x0004)
 #define FRAME_DRAW_DOUBLEOUT                ((sal_uInt16)0x0005)
 #define FRAME_DRAW_TOPBOTTOM                ((sal_uInt16)0x0006)
+#define FRAME_DRAW_NWF                      ((sal_uInt16)0x0007)
 #define FRAME_DRAW_MENU                     ((sal_uInt16)0x0010)
 #define FRAME_DRAW_WINDOWBORDER             ((sal_uInt16)0x0020)
 #define FRAME_DRAW_BORDERWINDOWBORDER       ((sal_uInt16)0x0040)
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 65118ca..eaa90d9 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -293,6 +293,7 @@ typedef sal_uInt16 StateChangedType;
 #define WINDOW_BORDER_DOUBLEOUT         ((sal_uInt16)0x0008)
 #define WINDOW_BORDER_MENU              ((sal_uInt16)0x0010)
 #define WINDOW_BORDER_TOPBOTTOM         ((sal_uInt16)0x0020)
+#define WINDOW_BORDER_NWF               ((sal_uInt16)0x0040)
 #define WINDOW_BORDER_NOBORDER          ((sal_uInt16)0x1000)
 #define WINDOW_BORDER_REMOVEBORDER      ((sal_uInt16)0x2000)
 
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 9d397c2..601a614 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1201,6 +1201,8 @@ void ImplSmallBorderWindowView::Init( OutputDevice* pDev, long nWidth, long nHei
                 nStyle |= FRAME_DRAW_DOUBLEOUT;
             else if ( nBorderStyle & WINDOW_BORDER_TOPBOTTOM )
                 nStyle |= FRAME_DRAW_TOPBOTTOM;
+            else if ( nBorderStyle & WINDOW_BORDER_NWF )
+                nStyle |= FRAME_DRAW_NWF;
             else
                 nStyle |= FRAME_DRAW_DOUBLEIN;
             if ( nBorderStyle & WINDOW_BORDER_MONO )
@@ -1392,6 +1394,8 @@ void ImplSmallBorderWindowView::DrawWindow( sal_uInt16 nDrawFlags, OutputDevice*
                 nStyle |= FRAME_DRAW_DOUBLEOUT;
             else if ( nBorderStyle & WINDOW_BORDER_TOPBOTTOM )
                 nStyle |= FRAME_DRAW_TOPBOTTOM;
+            else if ( nBorderStyle & WINDOW_BORDER_NWF )
+                nStyle |= FRAME_DRAW_NWF;
             else
                 nStyle |= FRAME_DRAW_DOUBLEIN;
             if ( nBorderStyle & WINDOW_BORDER_MONO )
diff --git a/vcl/source/window/decoview.cxx b/vcl/source/window/decoview.cxx
index 878578d..20546e5 100644
--- a/vcl/source/window/decoview.cxx
+++ b/vcl/source/window/decoview.cxx
@@ -739,6 +739,14 @@ void ImplDrawFrame( OutputDevice *const pDev, Rectangle& rRect,
                     ++rRect.Top();
                     --rRect.Bottom();
                     break;
+
+                case FRAME_DRAW_NWF:
+                    // enough space for the native rendering
+                    rRect.Left() += 5;
+                    rRect.Top() += 5;
+                    rRect.Right() -= 5;
+                    rRect.Bottom() -= 5;
+                    break;
             }
         }
         else
@@ -830,6 +838,14 @@ void ImplDrawFrame( OutputDevice *const pDev, Rectangle& rRect,
                     ++rRect.Top();
                     --rRect.Bottom();
                     break;
+
+                case FRAME_DRAW_NWF:
+                    // no rendering, just enough space for the native rendering
+                    rRect.Left() += 5;
+                    rRect.Top() += 5;
+                    rRect.Right() -= 5;
+                    rRect.Bottom() -= 5;
+                    break;
             }
         }
     }


More information about the Libreoffice-commits mailing list