summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-03-04 13:42:48 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-03-04 13:42:48 +0100
commitdae64ecf7507f1b8f8f021bc367f0ef69cac0b03 (patch)
tree72fbc3fc5f0f9f8da9f729eb749016bf95de10f6 /svtools
parent0bfe5e8c35f2e5b529d928cae9cc22998469520f (diff)
slidecopy: allow to toggle whether the tab bar items contain images and text, images only, or text only
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/toolpanel/tabitemcontent.hxx46
-rw-r--r--svtools/inc/svtools/toolpanel/tablayouter.hxx17
-rw-r--r--svtools/source/toolpanel/paneltabbar.cxx245
-rw-r--r--svtools/source/toolpanel/paneltabbar.hxx7
-rw-r--r--svtools/source/toolpanel/tablayouter.cxx39
-rw-r--r--svtools/source/toolpanel/toolpaneldeck.cxx2
-rw-r--r--svtools/workben/toolpanel/toolpaneltest.cxx135
7 files changed, 358 insertions, 133 deletions
diff --git a/svtools/inc/svtools/toolpanel/tabitemcontent.hxx b/svtools/inc/svtools/toolpanel/tabitemcontent.hxx
new file mode 100644
index 000000000000..295a644e7566
--- /dev/null
+++ b/svtools/inc/svtools/toolpanel/tabitemcontent.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef TABITEMCONTENT_HXX
+#define TABITEMCONTENT_HXX
+
+//........................................................................
+namespace svt
+{
+//........................................................................
+
+ enum TabItemContent
+ {
+ TABITEM_IMAGE_AND_TEXT,
+ TABITEM_IMAGE_ONLY,
+ TABITEM_TEXT_ONLY
+ };
+
+//........................................................................
+} // namespace svt
+//........................................................................
+
+#endif // TABITEMCONTENT_HXX
diff --git a/svtools/inc/svtools/toolpanel/tablayouter.hxx b/svtools/inc/svtools/toolpanel/tablayouter.hxx
index 522739fc76e0..0c1d850a487d 100644
--- a/svtools/inc/svtools/toolpanel/tablayouter.hxx
+++ b/svtools/inc/svtools/toolpanel/tablayouter.hxx
@@ -30,6 +30,7 @@
#include "svtools/toolpanel/decklayouter.hxx"
#include "svtools/toolpanel/toolpanelcontainer.hxx"
#include "svtools/toolpanel/tabalignment.hxx"
+#include "svtools/toolpanel/tabitemcontent.hxx"
#include "svtools/toolpanel/refbase.hxx"
#include <memory>
@@ -51,16 +52,26 @@ namespace svt
{
public:
/** creates a new layouter
- @param i_eAlignment
- specifies the alignment of the panel selector
@param i_rPanelDeck
the panel deck which the layouter is responsible for. Provides access to the panels
container, and can and should be used as parent for any other windows which the layouter
needs to create.
+ @param i_eAlignment
+ specifies the alignment of the panel selector
+ @param TabItemContent
+ specifies the content to show on the tab items
*/
- TabDeckLayouter( const TabAlignment i_eAlignment, ToolPanelDeck& i_rPanelDeck );
+ TabDeckLayouter(
+ ToolPanelDeck& i_rPanelDeck,
+ const TabAlignment i_eAlignment,
+ const TabItemContent i_eItemContent
+ );
~TabDeckLayouter();
+ // attribute access
+ TabItemContent GetTabItemContent() const;
+ void SetTabItemContent( const TabItemContent& i_eItemContent );
+
// IDeckLayouter
virtual Rectangle Layout( const Rectangle& i_rDeckPlayground );
virtual void Destroy();
diff --git a/svtools/source/toolpanel/paneltabbar.cxx b/svtools/source/toolpanel/paneltabbar.cxx
index faaf22c91efa..063210e0e0be 100644
--- a/svtools/source/toolpanel/paneltabbar.cxx
+++ b/svtools/source/toolpanel/paneltabbar.cxx
@@ -68,22 +68,36 @@ namespace svt
//==================================================================================================================
struct ItemDescriptor
{
- PToolPanel pPanel;
- Rectangle aMinArea;
- Rectangle aPrefArea;
- bool bUseMinimal;
+ PToolPanel pPanel;
+ Rectangle aCompleteArea;
+ Rectangle aIconOnlyArea;
+ Rectangle aTextOnlyArea;
+ TabItemContent eContent;
+ // content to be used for this particular item. Might differ from item content which has been set
+ // up for the complete control, in case not the complete content fits into the available space.
ItemDescriptor()
:pPanel()
- ,aMinArea()
- ,aPrefArea()
- ,bUseMinimal( false )
+ ,aCompleteArea()
+ ,aIconOnlyArea()
+ ,aTextOnlyArea()
+ ,eContent( TABITEM_IMAGE_AND_TEXT )
{
}
+ const Rectangle& GetRect( const TabItemContent i_eItemContent ) const
+ {
+ return ( i_eItemContent == TABITEM_IMAGE_AND_TEXT )
+ ? aCompleteArea
+ : ( ( i_eItemContent == TABITEM_TEXT_ONLY )
+ ? aTextOnlyArea
+ : aIconOnlyArea
+ );
+ }
+
const Rectangle& GetCurrentRect() const
{
- return bUseMinimal ? aMinArea : aPrefArea;
+ return GetRect( eContent );
}
};
@@ -105,8 +119,8 @@ namespace svt
/** calculates the size of the area occupied by the item representing the given tool panel
@param i_pPanel
denotes the panel whose item's size should be calculated
- @param i_bMinimum
- <TRUE/> if and only if the minimal version of the item should be rendered
+ @param i_eItemContent
+ defines which content to draw on the tab item
@param o_rBoundingSize
contains, upon return, the overall size needed to render the item, including possible decorations which are
<em>not</em> available for the item content
@@ -118,7 +132,7 @@ namespace svt
*/
virtual void CalculateItemSize(
const PToolPanel& i_pPanel,
- const bool i_bMinimum,
+ const TabItemContent i_eItemContent,
Size& o_rBoundingSize,
Rectangle& o_rContentArea
) const = 0;
@@ -139,16 +153,11 @@ namespace svt
as "bounding size" in CalculateItemSize might be used.
@param i_nItemFlags
defines in which state to draw the item
- @param i_bDrawMinimal
- defines whether the minimal version of the item should be drawn
+ @param i_eItemContent
+ defines which content to draw on the tab item
*/
virtual void DrawItem( const PToolPanel& i_pPanel, const Point& i_rPosition,
- const ItemFlags i_nItemFlags, const bool i_bDrawMinimal ) = 0;
-
- /** updates the given items to use their minimal or optimal size, so they fit (if possible) into the given
- area.
- */
- virtual void FitItemRects( ItemDescriptors& i_rItems, const Rectangle& i_rFitInto ) = 0;
+ const ItemFlags i_nItemFlags, const TabItemContent i_eItemContent ) = 0;
};
typedef ::boost::shared_ptr< IItemsLayout > PItemsLayout;
@@ -164,7 +173,7 @@ namespace svt
// IItemsLayout overridables
virtual void CalculateItemSize(
const PToolPanel& i_pPanel,
- const bool i_bMinimum,
+ const TabItemContent i_eItemContent,
Size& o_rBoundingSize,
Rectangle& o_rContentArea
) const;
@@ -174,9 +183,8 @@ namespace svt
const PToolPanel& i_pPanel,
const Point& i_rPosition,
const ItemFlags i_nItemFlags,
- const bool i_bDrawMinimal
+ const TabItemContent i_eItemContent
);
- virtual void FitItemRects( ItemDescriptors& i_rItems, const Rectangle& i_rFitInto );
private:
void impl_preRender(
@@ -187,7 +195,7 @@ namespace svt
void impl_renderContent(
const PToolPanel& i_pPanel,
const Rectangle& i_rContentArea,
- const bool i_bMinimal
+ const TabItemContent i_eItemContent
);
void impl_postRender(
const Rectangle& i_rBoundingArea,
@@ -202,8 +210,8 @@ namespace svt
impl_rotateFormation( Rectangle& io_rBoundingRect, Rectangle& io_rContentRect, const bool i_bLeft );
private:
- Window& m_rTargetWindow;
- const bool m_bLeft;
+ Window& m_rTargetWindow;
+ const bool m_bLeft;
enum ItemRenderMode
{
@@ -269,22 +277,24 @@ namespace svt
}
//------------------------------------------------------------------------------------------------------------------
- void VerticalItemLayout::CalculateItemSize( const PToolPanel& i_pPanel, const bool i_bMinimum,
+ void VerticalItemLayout::CalculateItemSize( const PToolPanel& i_pPanel, const TabItemContent i_eItemContent,
Size& o_rBoundingSize, Rectangle& o_rContentArea ) const
{
const Image aImage( i_pPanel->GetImage() );
+ const bool bUseImage = !!aImage && ( i_eItemContent != TABITEM_TEXT_ONLY );
+
const ::rtl::OUString sItemText( i_pPanel->GetDisplayName() );
+ const bool bUseText = ( sItemText.getLength() != 0 ) && ( i_eItemContent != TABITEM_IMAGE_ONLY );
- // for the moment, we display the icons only
Size aItemContentSize;
- if ( !!aImage )
+ if ( bUseImage )
{
aItemContentSize = aImage.GetSizePixel();
}
- if ( !i_bMinimum && sItemText.getLength() )
+ if ( bUseText )
{
- if ( !!aImage )
+ if ( bUseImage )
aItemContentSize.Height() += ITEM_ICON_TEXT_DISTANCE;
// add space for vertical text
@@ -439,25 +449,32 @@ namespace svt
}
//------------------------------------------------------------------------------------------------------------------
- void VerticalItemLayout::impl_renderContent( const PToolPanel& i_pPanel, const Rectangle& i_rContentArea, const bool i_bDrawMinimal )
+ void VerticalItemLayout::impl_renderContent( const PToolPanel& i_pPanel, const Rectangle& i_rContentArea, const TabItemContent i_eItemContent )
{
Point aDrawPos( i_rContentArea.TopLeft() );
aDrawPos.Y() += ITEM_OUTER_SPACE;
// draw the image
const Image aItemImage( i_pPanel->GetImage() );
- if ( !!aItemImage )
+ const Size aImageSize( aItemImage.GetSizePixel() );
+ const bool bUseImage = !!aItemImage && ( i_eItemContent != TABITEM_TEXT_ONLY );
+
+ if ( bUseImage )
{
- const Size aImageSize( aItemImage.GetSizePixel() );
m_rTargetWindow.DrawImage(
Point( aDrawPos.X() + ( i_rContentArea.GetWidth() - aImageSize.Width() ) / 2, aDrawPos.Y() ),
aItemImage
);
- aDrawPos.Y() += aImageSize.Height() + ITEM_ICON_TEXT_DISTANCE;
}
- if ( !i_bDrawMinimal )
+ const ::rtl::OUString sItemText( i_pPanel->GetDisplayName() );
+ const bool bUseText = ( sItemText.getLength() != 0 ) && ( i_eItemContent != TABITEM_IMAGE_ONLY );
+
+ if ( bUseText )
{
+ if ( bUseImage )
+ aDrawPos.Y() += aImageSize.Height() + ITEM_ICON_TEXT_DISTANCE;
+
aDrawPos.Y() += ITEM_TEXT_FLOW_SPACE;
// draw the text
@@ -468,7 +485,6 @@ namespace svt
aFont.SetVertical( TRUE );
m_rTargetWindow.SetFont( aFont );
- const ::rtl::OUString sItemText( i_pPanel->GetDisplayName() );
const Size aTextSize( m_rTargetWindow.GetCtrlTextWidth( sItemText ), m_rTargetWindow.GetTextHeight() );
Point aTextPos( aDrawPos );
@@ -543,39 +559,20 @@ namespace svt
//------------------------------------------------------------------------------------------------------------------
void VerticalItemLayout::DrawItem( const PToolPanel& i_pPanel, const Point& i_rPosition,
- const ItemFlags i_nItemFlags, const bool i_bDrawMinimal )
+ const ItemFlags i_nItemFlags, const TabItemContent i_eItemContent )
{
Rectangle aContentArea;
Size aBoundingSize;
- CalculateItemSize( i_pPanel, i_bDrawMinimal, aBoundingSize, aContentArea );
+ CalculateItemSize( i_pPanel, i_eItemContent, aBoundingSize, aContentArea );
aContentArea.Move( i_rPosition.X(), i_rPosition.Y() );
const Rectangle aBoundingArea( i_rPosition, aBoundingSize );
impl_preRender( aBoundingArea, aContentArea, i_nItemFlags );
- impl_renderContent( i_pPanel, aContentArea, i_bDrawMinimal );
+ impl_renderContent( i_pPanel, aContentArea, i_eItemContent );
impl_postRender( aBoundingArea, aContentArea, i_nItemFlags );
}
- //------------------------------------------------------------------------------------------------------------------
- void VerticalItemLayout::FitItemRects( ItemDescriptors& i_rItems, const Rectangle& i_rFitInto )
- {
- if ( i_rItems.empty() )
- // nothing to do
- return;
-
- // use the minimal sizes if and only if the preferred sizes do not fit
- const Point aBottomRight( i_rItems.rbegin()->aPrefArea.BottomRight() );
- bool bUseMinimal = ( aBottomRight.Y() >= i_rFitInto.Bottom() );
- for ( ItemDescriptors::iterator item = i_rItems.begin();
- item != i_rItems.end();
- ++item
- )
- {
- item->bUseMinimal = bUseMinimal;
- }
- }
-
//==================================================================================================================
//= PanelTabBar_Data
//==================================================================================================================
@@ -583,9 +580,11 @@ namespace svt
,public IToolPanelDeckListener
{
public:
- PanelTabBar_Data( PanelTabBar& i_rTabBar, const TabAlignment i_eAlignment )
+ PanelTabBar_Data( PanelTabBar& i_rTabBar, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
:rTabBar( i_rTabBar )
,rPanelDeck( dynamic_cast< ToolPanelDeck& >( *i_rTabBar.GetParent() ) )
+ ,eAlignment( i_eAlignment )
+ ,eTabItemContent( i_eItemContent )
,pLayout( new VerticalItemLayout( i_rTabBar, i_eAlignment == TABS_LEFT ) )
,aHoveredItem()
,aFocusedItem()
@@ -621,7 +620,9 @@ namespace svt
public:
PanelTabBar& rTabBar;
ToolPanelDeck& rPanelDeck;
- const PItemsLayout pLayout;
+ const TabAlignment eAlignment;
+ TabItemContent eTabItemContent;
+ PItemsLayout pLayout;
::boost::optional< size_t > aHoveredItem;
::boost::optional< size_t > aFocusedItem;
bool bMouseButtonDown;
@@ -674,8 +675,9 @@ namespace svt
{
io_rData.aItems.resize(0);
- Point aMinItemPos( TAB_BAR_OUTER_SPACE, TAB_BAR_OUTER_SPACE );
- Point aPrefItemPos( TAB_BAR_OUTER_SPACE, TAB_BAR_OUTER_SPACE );
+ Point aCompletePos( TAB_BAR_OUTER_SPACE, TAB_BAR_OUTER_SPACE );
+ Point aIconOnlyPos( TAB_BAR_OUTER_SPACE, TAB_BAR_OUTER_SPACE );
+ Point aTextOnlyPos( TAB_BAR_OUTER_SPACE, TAB_BAR_OUTER_SPACE );
for ( size_t i = 0;
i < io_rData.rPanelDeck.GetPanels()->GetPanelCount();
@@ -689,21 +691,26 @@ namespace svt
Rectangle aContentArea;
- Size aMinItemSize;
- io_rData.pLayout->CalculateItemSize( pPanel, true, aMinItemSize, aContentArea );
+ Size aCompleteSize;
+ io_rData.pLayout->CalculateItemSize( pPanel, TABITEM_IMAGE_AND_TEXT, aCompleteSize, aContentArea );
- Size aPrefItemSize;
- io_rData.pLayout->CalculateItemSize( pPanel, false, aPrefItemSize, aContentArea );
+ Size aIconOnlySize;
+ io_rData.pLayout->CalculateItemSize( pPanel, TABITEM_IMAGE_ONLY, aIconOnlySize, aContentArea );
- // TODO: have one method calculating both sizes?
+ Size aTextOnlySize;
+ io_rData.pLayout->CalculateItemSize( pPanel, TABITEM_TEXT_ONLY, aTextOnlySize, aContentArea );
- aItem.aMinArea = Rectangle( aMinItemPos, aMinItemSize );
- aItem.aPrefArea = Rectangle( aPrefItemPos, aPrefItemSize );
+ // TODO: have one method calculating all sizes?
+
+ aItem.aCompleteArea = Rectangle( aCompletePos, aCompleteSize );
+ aItem.aIconOnlyArea = Rectangle( aIconOnlyPos, aIconOnlySize );
+ aItem.aTextOnlyArea = Rectangle( aTextOnlyPos, aTextOnlySize );
io_rData.aItems.push_back( aItem );
- aMinItemPos = io_rData.pLayout->GetNextItemPosition( aItem.aMinArea );
- aPrefItemPos = io_rData.pLayout->GetNextItemPosition( aItem.aPrefArea );
+ aCompletePos = io_rData.pLayout->GetNextItemPosition( aItem.aCompleteArea );
+ aIconOnlyPos = io_rData.pLayout->GetNextItemPosition( aItem.aIconOnlyArea );
+ aTextOnlyPos = io_rData.pLayout->GetNextItemPosition( aItem.aTextOnlyArea );
}
io_rData.bItemsDirty = false;
@@ -766,9 +773,63 @@ namespace svt
nItemFlags |= ITEM_POSITION_LAST;
i_rData.rTabBar.SetUpdateMode( FALSE );
- i_rData.pLayout->DrawItem( rItem.pPanel, rItem.GetCurrentRect().TopLeft(), nItemFlags, rItem.bUseMinimal );
+ i_rData.pLayout->DrawItem( rItem.pPanel, rItem.GetCurrentRect().TopLeft(), nItemFlags, rItem.eContent );
i_rData.rTabBar.SetUpdateMode( TRUE );
}
+
+ //--------------------------------------------------------------------------------------------------------------
+ static void lcl_fitItems( PanelTabBar_Data& io_rData )
+ {
+ if ( io_rData.aItems.empty() )
+ // nothing to do
+ return;
+
+ // the available size
+ Size aOutputSize( io_rData.rTabBar.GetOutputSizePixel() );
+ // shrunk by the outer space
+ aOutputSize.Width() -= TAB_BAR_OUTER_SPACE;
+ aOutputSize.Height() -= TAB_BAR_OUTER_SPACE;
+ const Rectangle aFitInto( Point( 0, 0 ), aOutputSize );
+
+ // the "content modes" to try
+ TabItemContent eTryThis[] =
+ {
+ TABITEM_IMAGE_ONLY, // assumed to have the smalles rects
+ TABITEM_TEXT_ONLY,
+ TABITEM_IMAGE_AND_TEXT // assumed to have the largest rects
+ };
+
+ // do not start with the largest, but with the one currently set up for the TabBar
+ size_t nTryIndex = 0;
+ while ( ( nTryIndex < ( sizeof( eTryThis ) / sizeof( eTryThis[0] ) ) )
+ && ( eTryThis[nTryIndex] != io_rData.eTabItemContent )
+ )
+ {
+ ++nTryIndex;
+ }
+
+ // determine which of the different version fits
+ TabItemContent eContent = eTryThis[0];
+ while ( nTryIndex > 0 )
+ {
+ const Point aBottomRight( io_rData.aItems.rbegin()->GetRect( eTryThis[ nTryIndex ] ).BottomRight() );
+ if ( aFitInto.IsInside( aBottomRight ) )
+ {
+ eContent = eTryThis[ nTryIndex ];
+ break;
+ }
+ --nTryIndex;
+ }
+
+ // propagate to the items
+ for ( ItemDescriptors::iterator item = io_rData.aItems.begin();
+ item != io_rData.aItems.end();
+ ++item
+ )
+ {
+ item->eContent = eContent;
+ }
+ }
}
//==================================================================================================================
@@ -787,9 +848,9 @@ namespace svt
//= PanelTabBar
//==================================================================================================================
//------------------------------------------------------------------------------------------------------------------
- PanelTabBar::PanelTabBar( ToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment )
+ PanelTabBar::PanelTabBar( ToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
:Control( &i_rPanelDeck, 0 )
- ,m_pData( new PanelTabBar_Data( *this, i_eAlignment ) )
+ ,m_pData( new PanelTabBar_Data( *this, i_eAlignment, i_eItemContent ) )
{
DBG_CHECK( *m_pData );
@@ -803,6 +864,20 @@ namespace svt
}
//------------------------------------------------------------------------------------------------------------------
+ TabItemContent PanelTabBar::GetTabItemContent() const
+ {
+ return m_pData->eTabItemContent;
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
+ void PanelTabBar::SetTabItemContent( const TabItemContent& i_eItemContent )
+ {
+ m_pData->eTabItemContent = i_eItemContent;
+ lcl_fitItems( *m_pData );
+ Invalidate();
+ }
+
+ //------------------------------------------------------------------------------------------------------------------
Size PanelTabBar::GetOptimalSize( WindowSizeType i_eType ) const
{
lcl_ensureItemsCache( *m_pData );
@@ -810,27 +885,18 @@ namespace svt
if ( m_pData->aItems.empty() )
return Size( 2 * TAB_BAR_OUTER_SPACE, 2 * TAB_BAR_OUTER_SPACE );
- const bool nMinimalSize = ( i_eType == WINDOWSIZE_MINIMUM );
+ const bool bMinimalSize = ( i_eType == WINDOWSIZE_MINIMUM );
// the rect of the last item
- const Rectangle& rLastItemRect( nMinimalSize ? m_pData->aItems.rbegin()->aMinArea : m_pData->aItems.rbegin()->aPrefArea );
+ const Rectangle& rLastItemRect( bMinimalSize ? m_pData->aItems.rbegin()->aIconOnlyArea : m_pData->aItems.rbegin()->aCompleteArea );
const Point aBottomRight( rLastItemRect.BottomRight() );
- return Size( aBottomRight.X() + TAB_BAR_OUTER_SPACE, aBottomRight.Y() + TAB_BAR_OUTER_SPACE );
+ return Size( aBottomRight.X() + 1 + TAB_BAR_OUTER_SPACE, aBottomRight.Y() + 1 + TAB_BAR_OUTER_SPACE );
}
//------------------------------------------------------------------------------------------------------------------
void PanelTabBar::Resize()
{
Control::Resize();
-
- // decide whether we should use the minimal or the prefered version of the items
-
- // the available size
- Size aOutputSize( GetOutputSizePixel() );
- // shrunk by the outer space
- aOutputSize.Width() -= TAB_BAR_OUTER_SPACE;
- aOutputSize.Height() -= TAB_BAR_OUTER_SPACE;
- // let the layouter decide
- m_pData->pLayout->FitItemRects( m_pData->aItems, Rectangle( Point(), aOutputSize ) );
+ lcl_fitItems( *m_pData );
}
//------------------------------------------------------------------------------------------------------------------
@@ -936,9 +1002,8 @@ namespace svt
return;
const ItemDescriptor& rItem( m_pData->aItems[ *aHelpItem ] );
- if ( !rItem.bUseMinimal )
- // if we do not use the minimal representation of the item, then the text is completely drawn - no
- // need to show it as tooltip, too
+ if ( rItem.eContent != TABITEM_IMAGE_ONLY )
+ // if the text is displayed for the item, we do not need to show it as tooltip
return;
const ::rtl::OUString sItemText( rItem.pPanel->GetDisplayName() );
diff --git a/svtools/source/toolpanel/paneltabbar.hxx b/svtools/source/toolpanel/paneltabbar.hxx
index f53f68cbf5ee..7a272205f382 100644
--- a/svtools/source/toolpanel/paneltabbar.hxx
+++ b/svtools/source/toolpanel/paneltabbar.hxx
@@ -28,6 +28,7 @@
#include "svtools/toolpanel/toolpanelcontainer.hxx"
#include "svtools/toolpanel/tabalignment.hxx"
+#include "svtools/toolpanel/tabitemcontent.hxx"
#include <vcl/ctrl.hxx>
@@ -52,9 +53,13 @@ namespace svt
class PanelTabBar : public Control
{
public:
- PanelTabBar( ToolPanelDeck& i_rParent, const TabAlignment i_eAlignment );
+ PanelTabBar( ToolPanelDeck& i_rParent, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent );
~PanelTabBar();
+ // attribute access
+ TabItemContent GetTabItemContent() const;
+ void SetTabItemContent( const TabItemContent& i_eItemContent );
+
// Window overridables
virtual Size GetOptimalSize( WindowSizeType i_eType ) const;
virtual void Paint( const Rectangle& i_rRect );
diff --git a/svtools/source/toolpanel/tablayouter.cxx b/svtools/source/toolpanel/tablayouter.cxx
index 10405c0b75aa..e3213bd75267 100644
--- a/svtools/source/toolpanel/tablayouter.cxx
+++ b/svtools/source/toolpanel/tablayouter.cxx
@@ -47,10 +47,10 @@ namespace svt
::std::auto_ptr< PanelTabBar >
pTabBar;
- TabDeckLayouter_Data( const TabAlignment i_eAlignment, ToolPanelDeck& i_rPanelDeck )
+ TabDeckLayouter_Data( ToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
:eAlignment( i_eAlignment )
,pPanels( i_rPanelDeck.GetPanels() )
- ,pTabBar( new PanelTabBar( i_rPanelDeck, i_eAlignment ) )
+ ,pTabBar( new PanelTabBar( i_rPanelDeck, i_eAlignment, i_eItemContent ) )
{
pTabBar->Show();
}
@@ -66,14 +66,24 @@ namespace svt
return ( i_eAlignment == TABS_RIGHT )
|| ( i_eAlignment == TABS_LEFT );
}
+
+ static bool lcl_checkDisposed( const TabDeckLayouter_Data& i_rData )
+ {
+ if ( !i_rData.pTabBar.get() )
+ {
+ OSL_ENSURE( false, "lcl_checkDisposed: already disposed!" );
+ return true;
+ }
+ return false;
+ }
}
//====================================================================
//= TabDeckLayouter
//====================================================================
//--------------------------------------------------------------------
- TabDeckLayouter::TabDeckLayouter( const TabAlignment i_eAlignment, ToolPanelDeck& i_rPanelDeck )
- :m_pData( new TabDeckLayouter_Data( i_eAlignment, i_rPanelDeck ) )
+ TabDeckLayouter::TabDeckLayouter( ToolPanelDeck& i_rPanelDeck, const TabAlignment i_eAlignment, const TabItemContent i_eItemContent )
+ :m_pData( new TabDeckLayouter_Data( i_rPanelDeck, i_eAlignment, i_eItemContent ) )
{
}
@@ -86,13 +96,26 @@ namespace svt
IMPLEMENT_IREFERENCE( TabDeckLayouter )
//--------------------------------------------------------------------
+ TabItemContent TabDeckLayouter::GetTabItemContent() const
+ {
+ if ( lcl_checkDisposed( *m_pData ) )
+ return TABITEM_IMAGE_AND_TEXT;
+ return m_pData->pTabBar->GetTabItemContent();
+ }
+
+ //--------------------------------------------------------------------
+ void TabDeckLayouter::SetTabItemContent( const TabItemContent& i_eItemContent )
+ {
+ if ( lcl_checkDisposed( *m_pData ) )
+ return;
+ m_pData->pTabBar->SetTabItemContent( i_eItemContent );
+ }
+
+ //--------------------------------------------------------------------
Rectangle TabDeckLayouter::Layout( const Rectangle& i_rDeckPlayground )
{
- if ( !m_pData->pTabBar.get() )
- {
- OSL_ENSURE( false, "TabDeckLayouter::Layout: disposed!" );
+ if ( lcl_checkDisposed( *m_pData ) )
return i_rDeckPlayground;
- }
if ( lcl_isVerticalTabBar( m_pData->eAlignment ) )
{
diff --git a/svtools/source/toolpanel/toolpaneldeck.cxx b/svtools/source/toolpanel/toolpaneldeck.cxx
index f6ae7993b8ec..b6dcc0598bb8 100644
--- a/svtools/source/toolpanel/toolpaneldeck.cxx
+++ b/svtools/source/toolpanel/toolpaneldeck.cxx
@@ -279,7 +279,7 @@ namespace svt
,m_pImpl( new ToolPanelDeck_Impl( *this ) )
{
// use a default layouter
- SetLayouter( PDeckLayouter( new TabDeckLayouter( TABS_RIGHT, *this ) ) );
+ SetLayouter( PDeckLayouter( new TabDeckLayouter( *this, TABS_RIGHT, TABITEM_IMAGE_AND_TEXT ) ) );
}
//--------------------------------------------------------------------
diff --git a/svtools/workben/toolpanel/toolpaneltest.cxx b/svtools/workben/toolpanel/toolpaneltest.cxx
index e09e6e362e59..51f3001e761a 100644
--- a/svtools/workben/toolpanel/toolpaneltest.cxx
+++ b/svtools/workben/toolpanel/toolpaneltest.cxx
@@ -39,6 +39,7 @@
#include <ucbhelper/contentbroker.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
#include <vcl/help.hxx>
#include <vcl/svapp.hxx>
#include <vcl/taskpanelist.hxx>
@@ -223,11 +224,16 @@ public:
virtual void GetFocus();
private:
- DECL_LINK( OnAlignmentChanged, void* );
+ DECL_LINK( OnRadioToggled, RadioButton* );
private:
+ FixedLine m_aAlignmentHeader;
RadioButton m_aAlignLeft;
RadioButton m_aAlignRight;
+ FixedLine m_aTabItemContent;
+ RadioButton m_aImagesAndText;
+ RadioButton m_aImagesOnly;
+ RadioButton m_aTextOnly;
};
//=============================================================================
@@ -245,6 +251,7 @@ public:
public:
// operations
void AlignTabs( const ::svt::TabAlignment i_eAlignment );
+ void SetTabItemContent( const TabItemContent i_eItemContent );
protected:
virtual void GetFocus();
@@ -260,30 +267,38 @@ private:
//-----------------------------------------------------------------------------
OptionsWindow::OptionsWindow( PanelDemoMainWindow& i_rParent )
:Window( &i_rParent, WB_BORDER | WB_DIALOGCONTROL )
+ ,m_aAlignmentHeader( this )
,m_aAlignLeft( this, WB_GROUP )
,m_aAlignRight( this, 0 )
+ ,m_aTabItemContent( this )
+ ,m_aImagesAndText( this )
+ ,m_aImagesOnly( this )
+ ,m_aTextOnly( this )
{
SetBorderStyle( WINDOW_BORDER_MONO );
const Color aFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
SetBackground( aFaceColor );
- RadioButton* pRadios[] =
+ Window* pControls[] =
{
- &m_aAlignLeft, &m_aAlignRight
+ &m_aAlignmentHeader, &m_aAlignLeft, &m_aAlignRight, &m_aTabItemContent, &m_aImagesAndText, &m_aImagesOnly, &m_aTextOnly
};
const sal_Char* pTexts[] =
{
- "Left", "Right"
+ "Tab Bar Alignment", "Left", "Right", "Tab Items", "Images and Text", "Images only", "Text only"
};
- for ( size_t i=0; i < sizeof( pRadios ) / sizeof( pRadios[0] ); ++i )
+ for ( size_t i=0; i < sizeof( pControls ) / sizeof( pControls[0] ); ++i )
{
- pRadios[i]->SetText( String::CreateFromAscii( pTexts[i] ) );
- pRadios[i]->SetControlBackground( aFaceColor );
- pRadios[i]->Show();
- pRadios[i]->SetToggleHdl( LINK( this, OptionsWindow, OnAlignmentChanged ) );
+ pControls[i]->SetText( String::CreateFromAscii( pTexts[i] ) );
+ pControls[i]->SetControlBackground( aFaceColor );
+ pControls[i]->Show();
+
+ if ( pControls[i]->GetType() == WINDOW_RADIOBUTTON )
+ static_cast< RadioButton* >( pControls[i] )->SetToggleHdl( LINK( this, OptionsWindow, OnRadioToggled ) );
}
m_aAlignRight.Check();
+ m_aImagesAndText.Check();
Show();
}
@@ -311,37 +326,79 @@ void OptionsWindow::Resize()
{
Window::Resize();
- const Size aSpacing( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
const Size aOutputSize( GetOutputSizePixel() );
- const Size aRadioSize(
- aOutputSize.Width() - 2 * aSpacing.Width(),
- LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height()
- );
+ const Size aSpacing( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
+ const long nIndent( LogicToPixel( Size( 6, 9 ), MAP_APPFONT ).Width() );
+ const long nLineHeight( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height() );
- Point aRadioPos( aSpacing.Width(), aSpacing.Height() );
- RadioButton* pRadios[] =
+ const Size aSuperordinateSize( aOutputSize.Width() - 2 * aSpacing.Width(), nLineHeight );
+ const long nSuperordinateX = aSpacing.Width();
+
+ const Size aSubordinateSize( aOutputSize.Width() - 2 * aSpacing.Width() - nIndent, nLineHeight );
+ const long nSubordinateX = aSpacing.Width() + nIndent;
+
+ Point aItemPos( nSuperordinateX, aSpacing.Height() );
+
+ struct ControlRow
{
- &m_aAlignLeft, &m_aAlignRight
+ Window* pWindow;
+ bool bSubordinate;
+ ControlRow( Window& i_rWindow, const bool i_bSubordinate ) : pWindow( &i_rWindow ), bSubordinate( i_bSubordinate ) { }
};
- for ( size_t i=0; i < sizeof( pRadios ) / sizeof( pRadios[0] ); ++i )
+ ControlRow aControlRows[] =
+ {
+ ControlRow( m_aAlignmentHeader, false ),
+ ControlRow( m_aAlignLeft, true ),
+ ControlRow( m_aAlignRight, true ),
+ ControlRow( m_aTabItemContent, false ),
+ ControlRow( m_aImagesAndText, true ),
+ ControlRow( m_aImagesOnly, true ),
+ ControlRow( m_aTextOnly, true )
+ };
+ bool bPreviousWasSubordinate = false;
+ for ( size_t i=0; i < sizeof( aControlRows ) / sizeof( aControlRows[0] ); ++i )
{
- pRadios[i]->SetPosSizePixel( aRadioPos, aRadioSize );
- aRadioPos.Move( 0, aRadioSize.Height() + aSpacing.Height() );
+ aItemPos.X() = ( aControlRows[i].bSubordinate ) ? nSubordinateX : nSuperordinateX;
+
+ if ( bPreviousWasSubordinate && !aControlRows[i].bSubordinate )
+ aItemPos.Y() += aSpacing.Height();
+ bPreviousWasSubordinate = aControlRows[i].bSubordinate;
+
+ const Size& rControlSize = ( aControlRows[i].bSubordinate ) ? aSubordinateSize : aSuperordinateSize;
+ aControlRows[i].pWindow->SetPosSizePixel( aItemPos, rControlSize );
+
+ aItemPos.Move( 0, rControlSize.Height() + aSpacing.Height() );
}
}
//-----------------------------------------------------------------------------
-IMPL_LINK( OptionsWindow, OnAlignmentChanged, void*, /**/ )
+IMPL_LINK( OptionsWindow, OnRadioToggled, RadioButton*, i_pRadioButton )
{
PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) );
- if ( m_aAlignLeft.IsChecked() )
- {
- rController.AlignTabs( TABS_LEFT );
- }
- else if ( m_aAlignRight.IsChecked() )
+
+ if ( i_pRadioButton->IsChecked() )
{
- rController.AlignTabs( TABS_RIGHT );
+ if ( i_pRadioButton == &m_aAlignLeft )
+ {
+ rController.AlignTabs( TABS_LEFT );
+ }
+ else if ( i_pRadioButton == &m_aAlignRight )
+ {
+ rController.AlignTabs( TABS_RIGHT );
+ }
+ else if ( i_pRadioButton == &m_aImagesAndText )
+ {
+ rController.SetTabItemContent( TABITEM_IMAGE_AND_TEXT );
+ }
+ else if ( i_pRadioButton == &m_aImagesOnly )
+ {
+ rController.SetTabItemContent( TABITEM_IMAGE_ONLY );
+ }
+ else if ( i_pRadioButton == &m_aTextOnly )
+ {
+ rController.SetTabItemContent( TABITEM_TEXT_ONLY );
+ }
}
return 0L;
}
@@ -397,20 +454,38 @@ void PanelDemoMainWindow::Resize()
{
WorkWindow::Resize();
Size aSize( GetOutputSizePixel() );
- aSize.Width() -= 140;
+ aSize.Width() -= 190;
aSize.Height() -= 40;
m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), aSize );
m_aDemoOptions.SetPosSizePixel(
Point( 20 + aSize.Width(), 20 ),
- Size( 100, aSize.Height() )
+ Size( 150, aSize.Height() )
);
}
//-----------------------------------------------------------------------------
void PanelDemoMainWindow::AlignTabs( const ::svt::TabAlignment i_eAlignment )
{
- m_aToolPanelDeck.SetLayouter( PDeckLayouter( new TabDeckLayouter( i_eAlignment, m_aToolPanelDeck ) ) );
+ TabItemContent eCurrentItemContent( TABITEM_IMAGE_AND_TEXT );
+ TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() );
+ OSL_ENSURE( pLayouter, "PanelDemoMainWindow::AlignTabs: wrong layouter!" );
+ if ( pLayouter )
+ eCurrentItemContent = pLayouter->GetTabItemContent();
+
+ m_aToolPanelDeck.SetLayouter( PDeckLayouter( new TabDeckLayouter( m_aToolPanelDeck, i_eAlignment, eCurrentItemContent ) ) );
+}
+
+//-----------------------------------------------------------------------------
+void PanelDemoMainWindow::SetTabItemContent( const TabItemContent i_eItemContent )
+{
+ TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() );
+ OSL_ENSURE( pLayouter, "PanelDemoMainWindow::SetTabItemContent: wrong layouter!" );
+ // we currently use tab layouters only ...
+ if ( !pLayouter )
+ return;
+
+ pLayouter->SetTabItemContent( i_eItemContent );
}
//=============================================================================