diff options
author | Noel Power <noel.power@novell.com> | 2011-11-23 16:27:17 +0000 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2011-11-23 16:28:35 +0000 |
commit | 6151ec073e86be2fccffd5bf46d31a8261a232d3 (patch) | |
tree | 4fcc3ddad24e67f2f42ac1420d02e3a7a7d215a0 /sc | |
parent | ce2a78b4efe5c62d4aa13109401dc820e3891e71 (diff) |
add mouse resize (and other bits ) to gsoc formulabar
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/sc.hrc | 4 | ||||
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 146 | ||||
-rw-r--r-- | sc/source/ui/inc/inputwin.hxx | 19 | ||||
-rw-r--r-- | sc/source/ui/src/toolbox.src | 11 |
4 files changed, 140 insertions, 40 deletions
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc index 2edba1e9d9f5..6ca8544bf82e 100644 --- a/sc/inc/sc.hrc +++ b/sc/inc/sc.hrc @@ -1006,7 +1006,9 @@ #define SCSTR_SET_TAB_BG_COLOR (STR_START + 403) #define SCSTR_NO_TAB_BG_COLOR (STR_START + 404) #define SCSTR_DDEDOC_NOT_LOADED (STR_START + 405) -#define SCSTR_EXTDOC_NOT_LOADED (STR_START + 406) +#define SCSTR_QHELP_EXPAND_FORMULA (STR_START + 406) +#define SCSTR_QHELP_COLLAPSE_FORMULA (STR_START + 407) +#define SCSTR_EXTDOC_NOT_LOADED (STR_START + 408) #define STR_END (SCSTR_EXTDOC_NOT_LOADED) diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 82d9253f56d4..da067b82002a 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -88,7 +88,7 @@ #define THESIZE 1000000 //!!! langt... :-) #define TBX_WINDOW_HEIGHT 22 // in Pixeln - fuer alle Systeme gleich? #define LEFT_OFFSET 5 -#define INPUTWIN_MULTILINES 10 +#define INPUTWIN_MULTILINES 6 using com::sun::star::uno::Reference; using com::sun::star::uno::UNO_QUERY; @@ -179,7 +179,8 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) : aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ), aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ), bIsOkCancelMode ( false ), - bIsMultiLine ( false ) + bIsMultiLine ( false ), + bInResize ( false ) { ScModule* pScMod = SC_MOD(); SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); @@ -516,7 +517,7 @@ void ScInputWindow::Select() void ScInputWindow::Resize() { - + ToolBox::Resize(); if ( lcl_isExperimentalMode() ) { Size aSize = GetSizePixel(); @@ -536,7 +537,6 @@ void ScInputWindow::Resize() aTextWindow.SetSizePixel( aSize ); aTextWindow.Invalidate(); } - ToolBox::Resize(); } void ScInputWindow::SetFuncString( const String& rString, sal_Bool bDoEdit ) @@ -749,14 +749,72 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt ) ToolBox::DataChanged( rDCEvt ); } -bool ScInputWindow::GetMultiLineStatus() +void ScInputWindow::MouseMove( const MouseEvent& rMEvt ) { - return bIsMultiLine; + if ( lcl_isExperimentalMode() ) + { + Point aPosPixel = GetPointerPosPixel(); + Point aPnt = PixelToLogic( aPosPixel ); + + ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() ); + if ( bInResize || ( GetOutputSizePixel().Height() - aPosPixel.Y() <= 4 ) ) + { + SetPointer( Pointer( POINTER_WINDOW_SSIZE ) ); + + if ( rMEvt.IsLeft() ) + { + // Don't leave the mouse pointer leave *this* window + CaptureMouse(); + bInResize = true; + } + else + { + ReleaseMouse(); + bInResize = false; + } + + if ( bInResize ) + { + // Trigger resize + long nResizeThreshold = ( (long)TBX_WINDOW_HEIGHT * 0.7 ); + bool bResetPointerPos = false; + if ( GetOutputSizePixel().Height() - aPosPixel.Y() < -nResizeThreshold ) + { + pGroupBar->IncrementVerticalSize(); + bResetPointerPos = true; + } + else if ( ( GetOutputSizePixel().Height() - aPosPixel.Y() ) > nResizeThreshold ) + { + bResetPointerPos = true; + pGroupBar->DecrementVerticalSize(); + } + + if ( bResetPointerPos ) + { + aPosPixel.Y() = GetOutputSizePixel().Height(); + SetPointerPosPixel( aPosPixel ); + } + + } + } + else + { + ReleaseMouse(); + SetPointer( Pointer( POINTER_ARROW ) ); + } + } + ToolBox::MouseMove( rMEvt ); } -void ScInputWindow::SetMultiLineStatus(bool bMode) +void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt ) { - bIsMultiLine=bMode; + if ( lcl_isExperimentalMode() ) + { + ReleaseMouse(); + if ( rMEvt.IsLeft() ) + bInResize = false; + } + ToolBox::MouseButtonUp( rMEvt ); } @@ -783,9 +841,9 @@ ScInputBarGroup::ScInputBarGroup(Window* pParent) aButton.SetSizePixel(Size(GetSettings().GetStyleSettings().GetScrollBarSize(), TBX_WINDOW_HEIGHT) ); aButton.Enable(); aButton.SetSymbol( SYMBOL_SPIN_DOWN ); + aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) ); aButton.Show(); aScrollBar.SetSizePixel( aButton.GetSizePixel() ); - aScrollBar.SetScrollHdl( LINK( this, ScInputBarGroup, Impl_ScrollHdl ) ); } @@ -847,9 +905,10 @@ void ScInputBarGroup::Resize() SetSizePixel(aSize); - if(pParent->GetMultiLineStatus()) + if( aMultiTextWnd.GetNumLines() > 1 ) { aButton.SetSymbol( SYMBOL_SPIN_UP ); + aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_COLLAPSE_FORMULA ) ); Size scrollSize = aButton.GetSizePixel(); scrollSize.Height() = aMultiTextWnd.GetSizePixel().Height() - aButton.GetSizePixel().Height(); aScrollBar.SetSizePixel( scrollSize ); @@ -870,6 +929,7 @@ void ScInputBarGroup::Resize() else { aButton.SetSymbol( SYMBOL_SPIN_DOWN ); + aButton.SetQuickHelpText( ScResId( SCSTR_QHELP_EXPAND_FORMULA ) ); aScrollBar.Hide(); } @@ -917,6 +977,21 @@ void ScInputBarGroup::SetFormulaMode(sal_Bool bSet) aMultiTextWnd.SetFormulaMode(bSet); } +void ScInputBarGroup::IncrementVerticalSize() +{ + aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() + 1 ); + TriggerToolboxLayout(); +} + +void ScInputBarGroup::DecrementVerticalSize() +{ + if ( aMultiTextWnd.GetNumLines() > 1 ) + { + aMultiTextWnd.SetNumLines( aMultiTextWnd.GetNumLines() - 1 ); + TriggerToolboxLayout(); + } +} + IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, EMPTYARG ) { Window *w=GetParent(); @@ -929,17 +1004,23 @@ IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, EMPTYARG ) return 1; } - if(!pParent->GetMultiLineStatus()) + if( aMultiTextWnd.GetNumLines() > 1 ) { - pParent->SetMultiLineStatus(true); - aMultiTextWnd.SetNumLines( INPUTWIN_MULTILINES ); + aMultiTextWnd.SetNumLines( 1 ); } else { - pParent->SetMultiLineStatus(false); - aMultiTextWnd.SetNumLines( 1 ); + aMultiTextWnd.SetNumLines( aMultiTextWnd.GetLastNumExpandedLines() ); } + TriggerToolboxLayout(); + return 0; +} +void ScInputBarGroup::TriggerToolboxLayout() +{ + Window *w=GetParent(); + ScInputWindow *pParent; + pParent=dynamic_cast<ScInputWindow*>(w); SfxViewFrame* pViewFrm = SfxViewFrame::Current(); if ( pViewFrm ) { @@ -968,12 +1049,11 @@ IMPL_LINK( ScInputBarGroup, ClickHdl, PushButton*, EMPTYARG ) xLayoutManager->unlock(); } } - return 0; } -IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, pCurScrollBar ) +IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, EMPTYARG ) { - aMultiTextWnd.DoScroll( pCurScrollBar ); + aMultiTextWnd.DoScroll(); return 0; } @@ -982,10 +1062,11 @@ IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, pCurScrollBar ) // ScMultiTextWnd //======================================================================== -ScMultiTextWnd::ScMultiTextWnd( Window* pParen ) : ScTextWnd( pParen ) +ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen ) : ScTextWnd( pParen ), mrGroupBar(* pParen ) { nTextStartPos = TEXT_MULTI_STARTPOS; mnLines = 1; + mnLastExpandedLines = INPUTWIN_MULTILINES; } int ScMultiTextWnd::GetLineCount() @@ -1027,6 +1108,8 @@ long ScMultiTextWnd::GetPixelHeightForLines( long nLines ) void ScMultiTextWnd::SetNumLines( long nLines ) { mnLines = nLines; + if ( nLines > 1 ) + mnLastExpandedLines = nLines; } void ScMultiTextWnd::Resize() @@ -1049,8 +1132,8 @@ void ScMultiTextWnd::Resize() PixelToLogic(Rectangle(aPos1, aPos2))); pEditEngine->SetPaperSize( PixelToLogic(Size((aOutputSize.Width()-= 2 * nTextStartPos - 1), 10000 ) )); - } + SetScrollBarRange(); SetSizePixel(aTextBoxSize); } @@ -1075,13 +1158,9 @@ long ScMultiTextWnd::GetEditEngTxtHeight() void ScMultiTextWnd::SetScrollBarRange() { - // #FIXME lets do better that this ( and ditto for the DoScroll - // method above ) probably need to pass in ScInputBarGroup* as parent - // in the ctor - ScInputBarGroup* pBarGroup = dynamic_cast<ScInputBarGroup*>( GetParent() ); - if ( pBarGroup && pEditView ) + if ( pEditView ) { - ScrollBar& rVBar = pBarGroup->GetScrollBar(); + ScrollBar& rVBar = mrGroupBar.GetScrollBar(); rVBar.SetRange( Range( 0, GetEditEngTxtHeight() ) ); long currentDocPos = pEditView->GetVisArea().TopLeft().Y(); rVBar.SetThumbPos( currentDocPos ); @@ -1089,16 +1168,16 @@ void ScMultiTextWnd::SetScrollBarRange() } void -ScMultiTextWnd::DoScroll( ScrollBar* pCurScrollBar ) +ScMultiTextWnd::DoScroll() { if ( pEditView ) { - long currentDocPos = LogicToPixel(Size(0,pEditView->GetVisArea().TopLeft().Y() )).Height(); - long nDiff = currentDocPos - pCurScrollBar->GetThumbPos(); - Point aPos1(nDiff, nDiff); - pEditView->Scroll( 0, PixelToLogic(Rectangle(aPos1,aPos1) ).TopLeft().Y() ); - currentDocPos = LogicToPixel(Size(0,pEditView->GetVisArea().TopLeft().Y() )).Height(); - pCurScrollBar->SetThumbPos( currentDocPos ); + ScrollBar& rVBar = mrGroupBar.GetScrollBar(); + long currentDocPos = pEditView->GetVisArea().TopLeft().Y(); + long nDiff = currentDocPos - rVBar.GetThumbPos(); + pEditView->Scroll( 0, nDiff ); + currentDocPos = pEditView->GetVisArea().TopLeft().Y(); + rVBar.SetThumbPos( currentDocPos ); } } @@ -1291,6 +1370,7 @@ void ScMultiTextWnd::SetTextString( const String& rNewString ) } ScTextWnd::SetTextString( rNewString ); SetScrollBarRange(); + DoScroll(); } //======================================================================== // ScTextWnd diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx index 38c10932c0f2..789cb5712bfa 100644 --- a/sc/source/ui/inc/inputwin.hxx +++ b/sc/source/ui/inc/inputwin.hxx @@ -166,11 +166,12 @@ private: }; //======================================================================== +class ScInputBarGroup; class ScMultiTextWnd : public ScTextWnd { public: - ScMultiTextWnd( Window* pParent ); + ScMultiTextWnd( ScInputBarGroup* pParent ); virtual void StartEditEngine(); virtual void StopEditEngine( sal_Bool bAll ); int GetLineCount(); @@ -178,9 +179,11 @@ public: long GetPixelTextHeight(); long GetPixelHeightForLines( long nLines ); long GetEditEngTxtHeight(); - void DoScroll( ScrollBar* ); + void DoScroll(); virtual void SetTextString( const String& rString ); void SetNumLines( long nLines ); + long GetNumLines() { return mnLines; } + long GetLastNumExpandedLines() { return mnLastExpandedLines; } protected: void SetScrollBarRange(); void InitEditEngine(SfxObjectShell* pObjSh); @@ -189,7 +192,9 @@ protected: DECL_LINK( NotifyHdl, EENotify* ); DECL_LINK( ModifyHdl, EENotify* ); private: + ScInputBarGroup& mrGroupBar; long mnLines; + long mnLastExpandedLines; }; class ScInputBarGroup : public ScTextWndBase @@ -215,8 +220,10 @@ public: void MakeDialogEditView(); sal_Bool IsInputActive(); ScrollBar& GetScrollBar() { return aScrollBar; } + void IncrementVerticalSize(); + void DecrementVerticalSize(); private: - + void TriggerToolboxLayout(); ScMultiTextWnd aMultiTextWnd; PushButton aButton; ScrollBar aScrollBar; @@ -266,9 +273,8 @@ public: void StateChanged( StateChangedType nType ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); - void SetMultiLineStatus(bool bMode); - bool GetMultiLineStatus(); - + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); protected: virtual void SetText( const String& rString ); virtual String GetText() const; @@ -287,6 +293,7 @@ private: String aTextEqual; sal_Bool bIsOkCancelMode; bool bIsMultiLine; + bool bInResize; }; //================================================================== diff --git a/sc/source/ui/src/toolbox.src b/sc/source/ui/src/toolbox.src index 88b217662ea1..4eeec32a11d4 100644 --- a/sc/source/ui/src/toolbox.src +++ b/sc/source/ui/src/toolbox.src @@ -122,6 +122,17 @@ String SCSTR_QHELP_BTNEQUAL Text [ en-US ] = "Function" ; }; + +String SCSTR_QHELP_EXPAND_FORMULA +{ + Text [ en-US ] = "Expand Formula Bar" ; +}; + +String SCSTR_QHELP_COLLAPSE_FORMULA +{ + Text [ en-US ] = "Collapse Formula Bar" ; +}; + // Don't use this image list for normal toolbar images. We have now our commandimagelist // folder in default_images. This list is now only used for special toolboxes that are // used in floating windows. |