Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hello Kohei,

Please find the patch for resizing the ScInputWindow. I've tried doing
it the way you suggested; using proper typecasting I've moved the
bIsMultiLine to the ScInputWindow and able to access the status in
other classes too. Still this patch needs lots of improvement as the
transition is not smooth. On first click the textbox resizes outwards
which used to resize in hidden manner previously.  But when the
textbox is given focus in multiline mode,  the whole toolbar resizes
to the desired state. Similar is the case for reverse process. As of
now I do not know why is it becoming a two state process. Please
review this patch and please

1: Make me figure out where the mistake might be. I guess there are
some more functions in ScInputWindow I'd need to touch into and also
some methods from Window.hxx.
2: Check the order in which various resize are getting called. I guess
there are various do's and undo's happening under the hood.
3: Still I'm not able to figure out what Invalidate() is for and when
it should be used and when not.

Thanks and regards.
-- 
Anurag Jain
Final yr B.Tech CSE
SASTRA University
Thanjavur(T.N.)-613402
From c43c07532edc3f1f1c70f20deebc86e563eadcb5 Mon Sep 17 00:00:00 2001
From: ANURAG JAIN <anuragjainfzd@gmail.com>
Date: Mon, 25 Jul 2011 00:07:42 +0530
Subject: [PATCH] Made the tool bar to resize. But still the transition is not smooth.

---
 sc/source/ui/app/inputwin.cxx |   76 +++++++++++++++++++++++++++--------------
 sc/source/ui/inc/inputwin.hxx |   11 +++---
 2 files changed, 55 insertions(+), 32 deletions(-)

diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 943eb82..58d9af8 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -161,7 +161,8 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
         aTextCancel            ( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
         aTextSum               ( ScResId( SCSTR_QHELP_BTNSUM ) ),
         aTextEqual             ( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
-        bIsOkCancelMode ( false )
+        bIsOkCancelMode ( false ),
+        bIsMultiLine    ( false )
 {
     ScModule*           pScMod  = SC_MOD();
     SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
@@ -505,8 +506,20 @@ void ScInputWindow::Resize()
 
     if ( lcl_isExperimentalMode() )
     {
-        //aSize.Height()= TBX_WINDOW_HEIGHT;
+        Size aSize = GetSizePixel();
         //aTextWindow.SetSizePixel( aSize );
+        if( bIsMultiLine )
+        {
+        printf("increased\n");
+        aSize.Height()=77;
+        }
+        else
+        {
+        printf("reduced\n");
+        aSize.Height()=33;
+        }
+        SetSizePixel(aSize);
+        //Invalidate();
         aTextWindow.Resize();
     }
     else
@@ -705,7 +718,7 @@ void ScInputWindow::EnableButtons( sal_Bool bEnable )
 void ScInputWindow::StateChanged( StateChangedType nType )
 {
     ToolBox::StateChanged( nType );
-
+    printf("here\n");
     if ( nType == STATE_CHANGE_INITSHOW ) Resize();
 }
 
@@ -734,6 +747,17 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
     ToolBox::DataChanged( rDCEvt );
 }
 
+bool ScInputWindow::GetMultiLineStatus()
+{
+    return bIsMultiLine;
+}
+
+void ScInputWindow::SetMultiLineStatus(bool bMode)
+{
+    bIsMultiLine=bMode;
+}
+
+
 //========================================================================
 //                  ScInputBarGroup
 //========================================================================
@@ -741,8 +765,7 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
 ScInputBarGroup::ScInputBarGroup(Window* pParent)
     :   ScTextWndBase        ( pParent, WinBits(WB_HIDE) ),
         aMultiTextWnd        ( this ),
-        aButton              ( this),
-        bIsMultiLine         ( false )
+        aButton              ( this)
 {
       aMultiTextWnd.Show();
       aMultiTextWnd.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
@@ -783,11 +806,16 @@ void ScInputBarGroup::SetTextString( const String& rString )
 
 void ScInputBarGroup::Resize()
 {
-    long nWidth = GetParent()->GetSizePixel().Width();
+    Window *w=GetParent();
+    ScInputWindow *sw;
+    sw=dynamic_cast<ScInputWindow*>(w);
+
+    long nWidth = sw->GetSizePixel().Width();
     long nLeft  = GetPosPixel().X();
     Size aSize  = GetSizePixel();
-    aSize.Width() = Max( ((long)(nWidth - nLeft - 2*LEFT_OFFSET)), (long)0 );
-    if(bIsMultiLine)
+    aSize.Width() = Max( ((long)(nWidth - nLeft - LEFT_OFFSET)), (long)0 );
+
+    if(sw->GetMultiLineStatus())
     {
         aSize.Height()=3*TBX_WINDOW_HEIGHT;
     }
@@ -844,16 +872,19 @@ void ScInputBarGroup::SetFormulaMode(sal_Bool bSet)
 
 IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, pBtn )
 {
-    if(!bIsMultiLine)
+    Window *w=GetParent();
+    ScInputWindow *sw;
+    sw=dynamic_cast<ScInputWindow*>(w);
+
+    if(!sw->GetMultiLineStatus())
     {
-        bIsMultiLine=true;
+        sw->SetMultiLineStatus(true);
     }
     else
     {
-        bIsMultiLine=false;
+        sw->SetMultiLineStatus(false);
     }
-    aMultiTextWnd.SetMultiLineStatus(bIsMultiLine);
-    Resize();
+    sw->Resize();
     return 0;
 }
 
@@ -861,22 +892,11 @@ IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, pBtn )
 //                      ScMultiTextWnd
 //========================================================================
 
-ScMultiTextWnd::ScMultiTextWnd( Window* pParen ) : ScTextWnd( pParen ),
-                                                   bIsMultiLine(false)
+ScMultiTextWnd::ScMultiTextWnd( Window* pParen ) : ScTextWnd( pParen )
 {
     nTextStartPos = TEXT_MULTI_STARTPOS;
 }
 
-bool ScMultiTextWnd::GetMultiLineStatus()
-{
-    return bIsMultiLine;
-}
-
-void ScMultiTextWnd::SetMultiLineStatus(bool bMode)
-{
-    bIsMultiLine=bMode;
-}
-
 int ScMultiTextWnd::GetLineCount()
 {
    if(pEditView)
@@ -900,12 +920,16 @@ void ScMultiTextWnd::Paint( const Rectangle& rRec )
 
 void ScMultiTextWnd::Resize()
 {
+    Window *w=GetParent()->GetParent();
+    ScInputWindow *sw;
+    sw=dynamic_cast<ScInputWindow*>(w);
+
     long nWidth = GetParent()->GetSizePixel().Width();
     long nLeft  = GetPosPixel().X();
     Size cSize  = GetSizePixel();
     cSize.Width() = Max( ((long)(nWidth - nLeft - 3*LEFT_OFFSET)), (long)0 );
 
-    if(bIsMultiLine)
+    if(sw->GetMultiLineStatus())
     {
         cSize.Height()=3*TBX_WINDOW_HEIGHT;
     }
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
index 6437bf8..dc457f2 100644
--- a/sc/source/ui/inc/inputwin.hxx
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -172,17 +172,14 @@ public:
     ScMultiTextWnd( Window* pParent );
     virtual void StartEditEngine();
     virtual void StopEditEngine( sal_Bool bAll );
-    void SetMultiLineStatus(bool bMode);
-    bool GetMultiLineStatus();
     int GetLineCount();
-    void SetSize(bool bIsMultiLine);
     virtual void Resize();
 protected:
     void InitEditEngine(SfxObjectShell* pObjSh);
 
     virtual void Paint( const Rectangle& rRec );
 private:
-    bool bIsMultiLine;
+//    bool bIsMultiLine;
 };
 
 //================================================================================
@@ -214,7 +211,7 @@ private:
 
     ScMultiTextWnd  aMultiTextWnd;
     PushButton      aButton;
-    bool            bIsMultiLine;
+//    bool            bIsMultiLine;
 
     DECL_LINK( ClickHdl,        PushButton* );
 
@@ -261,7 +258,8 @@ public:
 
     void                       StateChanged( StateChangedType nType );
     virtual void       DataChanged( const DataChangedEvent& rDCEvt );
-
+    void SetMultiLineStatus(bool bMode);
+    bool GetMultiLineStatus();
 
 protected:
     virtual void       SetText( const String& rString );
@@ -280,6 +278,7 @@ private:
     String                     aTextSum;
     String                     aTextEqual;
     sal_Bool                   bIsOkCancelMode;
+    bool            bIsMultiLine;
 };
 
 //==================================================================
-- 
1.7.0.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.