diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-17 11:51:14 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-05-17 12:25:53 +0900 |
commit | e4164351dc311839f4a7eb2743be8af17592b8e5 (patch) | |
tree | 238d894fa2c4ec95052927de49db77a3d6277935 /svtools | |
parent | 6aab2eceaa386c14c2283631d3107cab7484f0f8 (diff) |
tabbar: use a button for adding of tabs, move button before tabs
Change-Id: I89fcf7427694ea6fc9468220bae639b221d9ec28
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/filectrl.src | 4 | ||||
-rw-r--r-- | svtools/source/control/tabbar.cxx | 69 | ||||
-rw-r--r-- | svtools/source/inc/filectrl.hrc | 9 |
3 files changed, 46 insertions, 36 deletions
diff --git a/svtools/source/control/filectrl.src b/svtools/source/control/filectrl.src index 4c70c58aa11f..357170c4ef1d 100644 --- a/svtools/source/control/filectrl.src +++ b/svtools/source/control/filectrl.src @@ -39,5 +39,9 @@ String STR_TABBAR_PUSHBUTTON_MOVETOEND { Text [ en-US ] = "Move To End" ; }; +String STR_TABBAR_PUSHBUTTON_ADDTAB +{ + Text [ en-US ] = "Add" ; +}; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index f65b7257e0f9..2fe1724eec83 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -166,20 +166,6 @@ public: } } - void drawPlusImage() - { - DecorationView aDecorationView(&mrRenderContext); - sal_Int32 aScaleFactor = mrRenderContext.GetDPIScaleFactor(); - Size aSize(12 * aScaleFactor, 12 * aScaleFactor); - - Point aPosition = maRect.TopLeft(); - long nXOffSet = (maRect.GetWidth() - aSize.Width()) / 2; - long nYOffset = (maRect.GetHeight() - aSize.Height()) / 2; - aPosition += Point(nXOffSet, nYOffset); - - aDecorationView.DrawSymbol(Rectangle(aPosition, aSize), SymbolType::PLUS, mrStyleSettings.GetDarkShadowColor()); - } - void setRect(const Rectangle& rRect) { maRect = rRect; @@ -513,6 +499,7 @@ struct TabBar_Impl ScopedVclPtr<ImplTabButton> mpPrevButton; ScopedVclPtr<ImplTabButton> mpNextButton; ScopedVclPtr<ImplTabButton> mpLastButton; + ScopedVclPtr<ImplTabButton> mpAddButton; ScopedVclPtr<TabBarEdit> mpEdit; ImplTabBarList mpItemList; @@ -556,7 +543,6 @@ void TabBar::dispose() const sal_uInt16 TabBar::APPEND = ::std::numeric_limits<sal_uInt16>::max(); const sal_uInt16 TabBar::PAGE_NOT_FOUND = ::std::numeric_limits<sal_uInt16>::max(); -const sal_uInt16 TabBar::INSERT_TAB_POS = ::std::numeric_limits<sal_uInt16>::max() - 1; void TabBar::ImplInit( WinBits nWinStyle ) { @@ -603,6 +589,9 @@ void TabBar::ImplInit( WinBits nWinStyle ) if (mpImpl->mpLastButton) mpImpl->mpLastButton->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_MOVETOEND)); + if (mpImpl->mpAddButton) + mpImpl->mpAddButton->SetAccessibleName(SVT_RESSTR(STR_TABBAR_PUSHBUTTON_ADDTAB)); + SetSizePixel( Size( 100, CalcWindowSizePixel().Height() ) ); ImplInitSettings( true, true ); } @@ -835,6 +824,15 @@ void TabBar::ImplInitControls() else mpImpl->mpSizer.disposeAndClear(); + if (mbHasInsertTab && !mpImpl->mpAddButton) + { + Link<> aLink = LINK(this, TabBar, ImplAddClickHandler); + mpImpl->mpAddButton.reset(VclPtr<ImplTabButton>::Create(this, WB_REPEAT)); + mpImpl->mpAddButton->SetClickHdl(aLink); + mpImpl->mpAddButton->SetSymbol(SymbolType::PLUS); + mpImpl->mpAddButton->Show(); + } + Link<> aLink = LINK( this, TabBar, ImplClickHdl ); if ( mnWinStyle & (WB_MINSCROLL | WB_SCROLL) ) @@ -975,6 +973,12 @@ IMPL_LINK( TabBar, ImplClickHdl, ImplTabButton*, pBtn ) return 0; } +IMPL_LINK_NOARG(TabBar, ImplAddClickHandler) +{ + AddTabClick(); + return 0; +} + void TabBar::MouseMove( const MouseEvent& rMEvt ) { if ( rMEvt.IsLeaveWindow() ) @@ -1228,15 +1232,6 @@ void TabBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rect) // Now, start drawing the tabs. ImplTabBarItem* pItem = ImplGetLastTabBarItem(nItemCount); - - if (pItem && mbHasInsertTab) - { - // Draw the insert tab at the right end. - Rectangle aRect = ImplGetInsertTabRect(pItem); - aDrawer.setRect(aRect); - aDrawer.drawPlusImage(); - } - ImplTabBarItem* pCurItem = NULL; while (pItem) { @@ -1370,6 +1365,16 @@ void TabBar::Resize() } nButtonWidth += nButtonMargin; + nX += mbMirrored ? -nButtonMargin : nButtonMargin; + + if (mpImpl->mpAddButton) + { + mpImpl->mpAddButton->SetPosSizePixel( Point( nX, 0 ), aBtnSize ); + nX += nXDiff; + nButtonWidth += nHeight; + } + + nButtonWidth += nButtonMargin; // store size maWinSize = aNewSize; @@ -1538,6 +1543,8 @@ void TabBar::StateChanged( StateChangedType nType ) mpImpl->mpLastButton->EnableRTL(IsRTLEnabled()); if (mpImpl->mpSizer) mpImpl->mpSizer->EnableRTL(IsRTLEnabled()); + if (mpImpl->mpAddButton) + mpImpl->mpAddButton->EnableRTL(IsRTLEnabled()); if (mpImpl->mpEdit) mpImpl->mpEdit->EnableRTL(IsRTLEnabled()); } @@ -1696,6 +1703,11 @@ void TabBar::Mirror() } +void TabBar::AddTabClick() +{ + +} + void TabBar::InsertPage( sal_uInt16 nPageId, const OUString& rText, TabBarPageBits nBits, sal_uInt16 nPos ) { @@ -1907,7 +1919,7 @@ sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const return PAGE_NOT_FOUND; } -sal_uInt16 TabBar::GetPageId( const Point& rPos, bool bCheckInsTab ) const +sal_uInt16 TabBar::GetPageId( const Point& rPos ) const { for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i) { @@ -1916,13 +1928,6 @@ sal_uInt16 TabBar::GetPageId( const Point& rPos, bool bCheckInsTab ) const return pItem->mnId; } - if (bCheckInsTab && mbHasInsertTab && !mpImpl->mpItemList.empty()) - { - ImplTabBarItem* pItem = mpImpl->mpItemList.back(); - if (ImplGetInsertTabRect(pItem).IsInside(rPos)) - return INSERT_TAB_POS; - } - return 0; } diff --git a/svtools/source/inc/filectrl.hrc b/svtools/source/inc/filectrl.hrc index 8eb13c2733da..75cf6ace23b7 100644 --- a/svtools/source/inc/filectrl.hrc +++ b/svtools/source/inc/filectrl.hrc @@ -22,10 +22,11 @@ #define STR_FILECTRL_BUTTONTEXT 333 // ID-Range?! -#define STR_TABBAR_PUSHBUTTON_MOVET0HOME ( STR_FILECTRL_BUTTONTEXT+ 1) -#define STR_TABBAR_PUSHBUTTON_MOVELEFT ( STR_FILECTRL_BUTTONTEXT+ 2) -#define STR_TABBAR_PUSHBUTTON_MOVERIGHT ( STR_FILECTRL_BUTTONTEXT+ 3) -#define STR_TABBAR_PUSHBUTTON_MOVETOEND ( STR_FILECTRL_BUTTONTEXT+ 4) +#define STR_TABBAR_PUSHBUTTON_MOVET0HOME (STR_FILECTRL_BUTTONTEXT + 1) +#define STR_TABBAR_PUSHBUTTON_MOVELEFT (STR_FILECTRL_BUTTONTEXT + 2) +#define STR_TABBAR_PUSHBUTTON_MOVERIGHT (STR_FILECTRL_BUTTONTEXT + 3) +#define STR_TABBAR_PUSHBUTTON_MOVETOEND (STR_FILECTRL_BUTTONTEXT + 4) +#define STR_TABBAR_PUSHBUTTON_ADDTAB (STR_FILECTRL_BUTTONTEXT + 5) #endif // INCLUDED_SVTOOLS_SOURCE_INC_FILECTRL_HRC |