diff options
-rw-r--r-- | sc/source/ui/app/inputwin.cxx | 110 | ||||
-rw-r--r-- | sc/source/ui/inc/inputwin.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/vcl/toolbox.hxx | 9 | ||||
-rw-r--r-- | vcl/source/window/toolbox.cxx | 17 |
4 files changed, 99 insertions, 42 deletions
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 427c2d99ed6a..685dc4f618e3 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -179,6 +179,7 @@ ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) : aTextCancel ( ScResId( SCSTR_QHELP_BTNCANCEL ) ), aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ), aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ), + mnMaxY (0), bIsOkCancelMode ( false ), bIsMultiLine ( false ), bInResize ( false ) @@ -750,6 +751,14 @@ void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt ) ToolBox::DataChanged( rDCEvt ); } +bool ScInputWindow::IsPointerAtResizePos() +{ + if ( GetOutputSizePixel().Height() - GetPointerPosPixel().Y() <= 4 ) + return true; + else + return false; +} + void ScInputWindow::MouseMove( const MouseEvent& rMEvt ) { if ( lcl_isExperimentalMode() ) @@ -757,62 +766,79 @@ void ScInputWindow::MouseMove( const MouseEvent& rMEvt ) Point aPosPixel = GetPointerPosPixel(); ScInputBarGroup* pGroupBar = dynamic_cast< ScInputBarGroup* > ( pRuntimeWindow.get() ); - if ( bInResize || ( GetOutputSizePixel().Height() - aPosPixel.Y() <= 4 ) ) - { + + if ( bInResize || IsPointerAtResizePos() ) SetPointer( Pointer( POINTER_WINDOW_SSIZE ) ); + else + SetPointer( Pointer( POINTER_ARROW ) ); - if ( rMEvt.IsLeft() ) + if ( bInResize ) + { + // detect direction + long nResizeThreshold = ( (long)TBX_WINDOW_HEIGHT * 0.7 ); + bool bResetPointerPos = false; + + // Detect attempt to expand toolbar too much + if ( aPosPixel.Y() >= mnMaxY ) { - // Don't leave the mouse pointer leave *this* window - CaptureMouse(); - bInResize = true; - } - else + bResetPointerPos = true; + aPosPixel.Y() = mnMaxY; + } // or expanding down + else if ( GetOutputSizePixel().Height() - aPosPixel.Y() < -nResizeThreshold ) + { + pGroupBar->IncrementVerticalSize(); + bResetPointerPos = true; + } // or shrinking up + else if ( ( GetOutputSizePixel().Height() - aPosPixel.Y() ) > nResizeThreshold ) { - ReleaseMouse(); - bInResize = false; + bResetPointerPos = true; + pGroupBar->DecrementVerticalSize(); } - if ( bInResize ) + if ( bResetPointerPos ) { - // 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 ); - } - + aPosPixel.Y() = GetOutputSizePixel().Height(); + SetPointerPosPixel( aPosPixel ); } } - else - { - ReleaseMouse(); - SetPointer( Pointer( POINTER_ARROW ) ); - } } ToolBox::MouseMove( rMEvt ); } +void ScInputWindow::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if ( lcl_isExperimentalMode() ) + { + if ( rMEvt.IsLeft() ) + { + if ( IsPointerAtResizePos() ) + { + // Don't leave the mouse pointer leave *this* window + CaptureMouse(); + bInResize = true; + // find the height of the gridwin, we don't wan't to be + // able to expand the toolbar too far so we need to + // caculate an upper limit + // I'd prefer to leave at least a single column header and a + // row but I don't know how to get that value in pixels. + // Use TBX_WINDOW_HEIGHT for the moment + ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); + mnMaxY = GetOutputSizePixel().Height() + ( pViewSh->GetGridHeight(SC_SPLIT_TOP) + pViewSh->GetGridHeight(SC_SPLIT_BOTTOM) ) - TBX_WINDOW_HEIGHT; + } + } + } + ToolBox::MouseButtonDown( rMEvt ); +} void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt ) { if ( lcl_isExperimentalMode() ) { ReleaseMouse(); if ( rMEvt.IsLeft() ) + { bInResize = false; + mnMaxY = 0; + } } ToolBox::MouseButtonUp( rMEvt ); } @@ -823,10 +849,10 @@ void ScInputWindow::MouseButtonUp( const MouseEvent& rMEvt ) //======================================================================== ScInputBarGroup::ScInputBarGroup(Window* pParent) - : ScTextWndBase ( pParent, WinBits(WB_HIDE) ), + : ScTextWndBase ( pParent, WinBits(WB_HIDE | WB_TABSTOP ) ), aMultiTextWnd ( this ), - aButton ( this, WB_RECTSTYLE ), - aScrollBar ( this, WB_VERT | WB_DRAG ) + aButton ( this, WB_TABSTOP | WB_RECTSTYLE ), + aScrollBar ( this, WB_TABSTOP | WB_VERT | WB_DRAG ) { aMultiTextWnd.Show(); aMultiTextWnd.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) ); @@ -1035,6 +1061,10 @@ void ScInputBarGroup::TriggerToolboxLayout() if ( xLayoutManager.is() ) { + if ( aMultiTextWnd.GetNumLines() > 1) + pParent->SetToolbarLayoutMode( TBX_LAYOUT_TOP ); + else + pParent->SetToolbarLayoutMode( TBX_LAYOUT_NORMAL ); xLayoutManager->lock(); pParent->Resize(); DataChangedEvent aFakeUpdate( DATACHANGED_SETTINGS, NULL, SETTINGS_STYLE ); @@ -1062,7 +1092,7 @@ IMPL_LINK( ScInputBarGroup, Impl_ScrollHdl, ScrollBar*, EMPTYARG ) // ScMultiTextWnd //======================================================================== -ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen ) : ScTextWnd( pParen ), mrGroupBar(* pParen ) +ScMultiTextWnd::ScMultiTextWnd( ScInputBarGroup* pParen ) : ScTextWnd( pParen/*, WB_TABSTOP*/ ), mrGroupBar(* pParen ) { nTextStartPos = TEXT_MULTI_STARTPOS; mnLines = 1; diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx index 789cb5712bfa..f6aacb38b6b1 100644 --- a/sc/source/ui/inc/inputwin.hxx +++ b/sc/source/ui/inc/inputwin.hxx @@ -179,6 +179,7 @@ public: long GetPixelTextHeight(); long GetPixelHeightForLines( long nLines ); long GetEditEngTxtHeight(); + void DoScroll(); virtual void SetTextString( const String& rString ); void SetNumLines( long nLines ); @@ -274,13 +275,14 @@ public: void StateChanged( StateChangedType nType ); virtual void DataChanged( const DataChangedEvent& rDCEvt ); virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); virtual void MouseMove( const MouseEvent& rMEvt ); protected: virtual void SetText( const String& rString ); virtual String GetText() const; bool UseSubTotal( ScRangeList* pRangeList ) const; - + bool IsPointerAtResizePos(); private: ScPosWnd aWndPos; std::auto_ptr<ScTextWndBase> pRuntimeWindow; @@ -291,6 +293,7 @@ private: String aTextCancel; String aTextSum; String aTextEqual; + long mnMaxY; sal_Bool bIsOkCancelMode; bool bIsMultiLine; bool bInResize; diff --git a/vcl/inc/vcl/toolbox.hxx b/vcl/inc/vcl/toolbox.hxx index dd482c610d95..8b39005b3fb5 100644 --- a/vcl/inc/vcl/toolbox.hxx +++ b/vcl/inc/vcl/toolbox.hxx @@ -160,6 +160,12 @@ enum ToolBoxButtonSize { TOOLBOX_BUTTONSIZE_DONTCARE, TOOLBOX_BUTTONSIZE_SMALL, // used for internal sizing calculations enum FloatingSizeMode { FSMODE_AUTO, FSMODE_FAVOURWIDTH, FSMODE_FAVOURHEIGHT }; +// TBX_LAYOUT_NORMAL - traditional layout, items are centered in the toolbar +// TBX_LAYOUT_TOP - special mode (currently used for calc input/formula bar) +// where items are aligned with the top of highest item +// ( currently only valid for docked, single line, horizontal +// toolbars ) +enum ToolBoxLayoutMode { TBX_LAYOUT_NORMAL, TBX_LAYOUT_TOP }; // ----------- // - ToolBox - // ----------- @@ -239,6 +245,7 @@ private: ButtonType meButtonType; PointerStyle meLastStyle; WinBits mnWinStyle; + ToolBoxLayoutMode meLayoutMode; Link maClickHdl; Link maDoubleClickHdl; Link maActivateHdl; @@ -606,6 +613,8 @@ public: void ChangeHighlight( sal_uInt16 nPos ); void SetImageListProvider(vcl::IImageListProvider* _pProvider); + ToolBoxLayoutMode GetToolbarLayoutMode(); + void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout ); }; inline void ToolBox::CheckItem( sal_uInt16 nItemId, sal_Bool bCheck ) diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx index 13a56487340f..1016301ca157 100644 --- a/vcl/source/window/toolbox.cxx +++ b/vcl/source/window/toolbox.cxx @@ -1596,6 +1596,7 @@ void ToolBox::ImplInit( Window* pParent, WinBits nStyle ) meAlign = WINDOWALIGN_TOP; meLastStyle = POINTER_ARROW; mnWinStyle = nStyle; + meLayoutMode = TBX_LAYOUT_NORMAL; mnLastFocusItemId = 0; mnKeyModifier = 0; mnActivateCount = 0; @@ -2720,7 +2721,10 @@ void ToolBox::ImplFormat( sal_Bool bResize ) if ( mbHorz ) { it->maCalcRect.Left() = nX; - it->maCalcRect.Top() = nY+(nLineSize-aCurrentItemSize.Height())/2; + if ( meLayoutMode == TBX_LAYOUT_TOP && mnLines ) + it->maCalcRect.Top() = nY/2; + else + it->maCalcRect.Top() = nY+(nLineSize-aCurrentItemSize.Height())/2; it->maCalcRect.Right() = nX+aCurrentItemSize.Width()-1; it->maCalcRect.Bottom() = it->maCalcRect.Top()+aCurrentItemSize.Height()-1; nX += aCurrentItemSize.Width(); @@ -6014,4 +6018,15 @@ void ToolBox::ImplDisableFlatButtons() #endif } +ToolBoxLayoutMode ToolBox::GetToolbarLayoutMode() +{ + return meLayoutMode; +} + +void ToolBox::SetToolbarLayoutMode( ToolBoxLayoutMode eLayout ) +{ + if ( meLayoutMode != eLayout ) + meLayoutMode = eLayout; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |