Kaydet (Commit) fb8f83c1 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

refactor TabBar to use RenderContext

Change-Id: Id29cbf407fe96fceb326b1197991baf4698e5177
üst 2db379e2
...@@ -358,8 +358,9 @@ private: ...@@ -358,8 +358,9 @@ private:
using Window::ImplInit; using Window::ImplInit;
SVT_DLLPRIVATE void ImplInit( WinBits nWinStyle ); SVT_DLLPRIVATE void ImplInit( WinBits nWinStyle );
SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bBackground ); SVT_DLLPRIVATE void ImplInitSettings( bool bFont, bool bBackground );
SVT_DLLPRIVATE void ImplGetColors( Color& rFaceColor, Color& rFaceTextColor, SVT_DLLPRIVATE void ImplGetColors(const StyleSettings& rStyleSettings,
Color& rSelectColor, Color& rSelectTextColor ); Color& rFaceColor, Color& rFaceTextColor,
Color& rSelectColor, Color& rSelectTextColor);
SVT_DLLPRIVATE void ImplShowPage( sal_uInt16 nPos ); SVT_DLLPRIVATE void ImplShowPage( sal_uInt16 nPos );
SVT_DLLPRIVATE bool ImplCalcWidth(); SVT_DLLPRIVATE bool ImplCalcWidth();
SVT_DLLPRIVATE void ImplFormat(); SVT_DLLPRIVATE void ImplFormat();
...@@ -369,7 +370,7 @@ private: ...@@ -369,7 +370,7 @@ private:
SVT_DLLPRIVATE void ImplSelect(); SVT_DLLPRIVATE void ImplSelect();
SVT_DLLPRIVATE void ImplActivatePage(); SVT_DLLPRIVATE void ImplActivatePage();
SVT_DLLPRIVATE bool ImplDeactivatePage(); SVT_DLLPRIVATE bool ImplDeactivatePage();
SVT_DLLPRIVATE void ImplPrePaint(); SVT_DLLPRIVATE void ImplPrePaint(vcl::RenderContext& rRenderContext);
SVT_DLLPRIVATE ImplTabBarItem* ImplGetLastTabBarItem( sal_uInt16 nItemCount ); SVT_DLLPRIVATE ImplTabBarItem* ImplGetLastTabBarItem( sal_uInt16 nItemCount );
SVT_DLLPRIVATE Rectangle ImplGetInsertTabRect(ImplTabBarItem* pItem) const; SVT_DLLPRIVATE Rectangle ImplGetInsertTabRect(ImplTabBarItem* pItem) const;
......
...@@ -36,7 +36,9 @@ ...@@ -36,7 +36,9 @@
#include <limits> #include <limits>
#include <utility> #include <utility>
namespace { namespace
{
#define TABBAR_DRAG_SCROLLOFF 5 #define TABBAR_DRAG_SCROLLOFF 5
#define TABBAR_MINSIZE 5 #define TABBAR_MINSIZE 5
...@@ -44,6 +46,181 @@ const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10; ...@@ -44,6 +46,181 @@ const sal_uInt16 ADDNEWPAGE_AREAWIDTH = 10;
const sal_uInt16 INSERT_TAB_WIDTH = 32; const sal_uInt16 INSERT_TAB_WIDTH = 32;
const sal_uInt16 BUTTON_MARGIN = 6; const sal_uInt16 BUTTON_MARGIN = 6;
class TabDrawer
{
private:
TabBar& mrParent;
vcl::RenderContext& mrRenderContext;
const StyleSettings& mrStyleSettings;
Rectangle maRect;
Color maSelectedColor;
Color maCustomColor;
Color maUnselectedColor;
bool mbSelected:1;
bool mbCustomColored:1;
bool mbSpecialTab:1;
bool mbEnabled:1;
public:
explicit TabDrawer(TabBar& rParent, vcl::RenderContext& rRenderContext)
: mrParent(rParent)
, mrRenderContext(rRenderContext)
, mrStyleSettings(rRenderContext.GetSettings().GetStyleSettings())
, mbSelected(false)
, mbCustomColored(false)
, mbSpecialTab(false)
, mbEnabled(false)
{
}
void drawOutputAreaBorder()
{
WinBits nWinStyle = mrParent.GetStyle();
// draw extra line if above and below border
if ((nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER))
{
Size aOutputSize = mrRenderContext.GetOutputSizePixel();
Rectangle aOutRect = mrParent.GetPageArea();
// also draw border in 3D for 3D-tabs
if (nWinStyle & WB_3DTAB)
{
mrRenderContext.SetLineColor(mrStyleSettings.GetShadowColor());
mrRenderContext.DrawLine(Point(aOutRect.Left(), 0), Point(aOutputSize.Width(), 0));
}
// draw border (line above and line below)
mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
mrRenderContext.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
}
}
void drawOuterFrame()
{
mrRenderContext.SetLineColor(mrStyleSettings.GetDarkShadowColor());
// set correct FillInBrush depending on status
if (mbSelected)
{
// Currently selected Tab
mrRenderContext.SetFillColor(maSelectedColor);
}
else if (mbCustomColored)
{
mrRenderContext.SetFillColor(maCustomColor);
}
else
{
mrRenderContext.SetFillColor(maUnselectedColor);
}
mrRenderContext.DrawRect(maRect);
}
void drawText(const OUString& aText)
{
Rectangle aRect = maRect;
long nTextWidth = mrRenderContext.GetTextWidth(aText);
long nTextHeight = mrRenderContext.GetTextHeight();
Point aPos = aRect.TopLeft();
aPos.X() += (aRect.getWidth() - nTextWidth) / 2;
aPos.Y() += (aRect.getHeight() - nTextHeight) / 2;
if (mbEnabled)
mrRenderContext.DrawText(aPos, aText);
else
mrRenderContext.DrawCtrlText(aPos, aText, 0, aText.getLength(), (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
}
void drawOverTopBorder()
{
Point aTopLeft = maRect.TopLeft() + Point(1, 0);
Point aTopRight = maRect.TopRight() + Point(-1, 0);
Rectangle aDelRect(aTopLeft, aTopRight);
mrRenderContext.DrawRect(aDelRect);
}
void drawColorLine()
{
mrRenderContext.SetFillColor(maCustomColor);
mrRenderContext.SetLineColor(maCustomColor);
Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
aLineRect.Top() -= 3;
mrRenderContext.DrawRect(aLineRect);
}
void drawTab()
{
drawOuterFrame();
if (mbCustomColored && mbSelected)
{
drawColorLine();
}
}
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;
}
void setSelected(bool bSelected)
{
mbSelected = bSelected;
}
void setCustomColored(bool bCustomColored)
{
mbCustomColored = bCustomColored;
}
void setSpecialTab(bool bSpecialTab)
{
mbSpecialTab = bSpecialTab;
}
void setEnabled(bool bEnabled)
{
mbEnabled = bEnabled;
}
void setSelectedFillColor(const Color& rColor)
{
maSelectedColor = rColor;
}
void setUnselectedFillColor(const Color& rColor)
{
maUnselectedColor = rColor;
}
void setCustomColor(const Color& rColor)
{
maCustomColor = rColor;
}
};
} // anonymous namespace } // anonymous namespace
struct ImplTabBarItem struct ImplTabBarItem
...@@ -221,10 +398,10 @@ void ImplTabSizer::Tracking( const TrackingEvent& rTEvt ) ...@@ -221,10 +398,10 @@ void ImplTabSizer::Tracking( const TrackingEvent& rTEvt )
ImplTrack( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) ); ImplTrack( OutputToScreenPixel( rTEvt.GetMouseEvent().GetPosPixel() ) );
} }
void ImplTabSizer::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& ) void ImplTabSizer::Paint( vcl::RenderContext& rRenderContext, const Rectangle& )
{ {
DecorationView aDecoView(this); DecorationView aDecoView(&rRenderContext);
Rectangle aOutputRect(Point(0, 0), GetOutputSizePixel()); Rectangle aOutputRect(Point(0, 0), rRenderContext.GetOutputSizePixel());
aDecoView.DrawHandle(aOutputRect, true); aDecoView.DrawHandle(aOutputRect, true);
} }
...@@ -494,31 +671,30 @@ void TabBar::ImplInitSettings( bool bFont, bool bBackground ) ...@@ -494,31 +671,30 @@ void TabBar::ImplInitSettings( bool bFont, bool bBackground )
} }
} }
void TabBar::ImplGetColors( Color& rFaceColor, Color& rFaceTextColor, void TabBar::ImplGetColors(const StyleSettings& rStyleSettings,
Color& rSelectColor, Color& rSelectTextColor ) Color& rFaceColor, Color& rFaceTextColor,
Color& rSelectColor, Color& rSelectTextColor)
{ {
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); if (IsControlBackground())
if ( IsControlBackground() )
rFaceColor = GetControlBackground(); rFaceColor = GetControlBackground();
else else
rFaceColor = rStyleSettings.GetInactiveTabColor(); rFaceColor = rStyleSettings.GetInactiveTabColor();
if ( IsControlForeground() ) if (IsControlForeground())
rFaceTextColor = GetControlForeground(); rFaceTextColor = GetControlForeground();
else else
rFaceTextColor = rStyleSettings.GetButtonTextColor(); rFaceTextColor = rStyleSettings.GetButtonTextColor();
if ( mbSelColor ) if (mbSelColor)
rSelectColor = maSelColor; rSelectColor = maSelColor;
else else
rSelectColor = rStyleSettings.GetActiveTabColor(); rSelectColor = rStyleSettings.GetActiveTabColor();
if ( mbSelTextColor ) if (mbSelTextColor)
rSelectTextColor = maSelTextColor; rSelectTextColor = maSelTextColor;
else else
rSelectTextColor = rStyleSettings.GetWindowTextColor(); rSelectTextColor = rStyleSettings.GetWindowTextColor();
// For 3D-tabs the selection- and face-colours are swapped, // For 3D-tabs the selection- and face-colours are swapped,
// as the selected tabs should appear in 3D // as the selected tabs should appear in 3D
if ( mnWinStyle & WB_3DTAB ) if (mnWinStyle & WB_3DTAB)
{ {
using std::swap; using std::swap;
swap(rFaceColor, rSelectColor); swap(rFaceColor, rSelectColor);
...@@ -1017,233 +1193,33 @@ void TabBar::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -1017,233 +1193,33 @@ void TabBar::MouseButtonUp( const MouseEvent& rMEvt )
Window::MouseButtonUp( rMEvt ); Window::MouseButtonUp( rMEvt );
} }
namespace { void TabBar::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rect)
class TabBarPaintGuard
{ {
public: if (rRenderContext.IsNativeControlSupported(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL))
explicit TabBarPaintGuard(TabBar& rParent) :
mrParent(rParent),
maFont(rParent.GetFont())
{
// #i36013# exclude push buttons from painting area
mrParent.SetClipRegion( vcl::Region(mrParent.GetPageArea()) );
}
~TabBarPaintGuard()
{ {
// Restore original font. rRenderContext.DrawNativeControl(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL,rect,
mrParent.SetFont(maFont);
// remove clip region
mrParent.SetClipRegion();
}
private:
TabBar& mrParent;
vcl::Font maFont;
};
class TabDrawer
{
public:
explicit TabDrawer(TabBar& rParent) :
mrParent(rParent),
mpStyleSettings(&mrParent.GetSettings().GetStyleSettings()),
mbSelected(false),
mbCustomColored(false),
mbSpecialTab(false),
mbEnabled(false)
{
}
void drawOutputAreaBorder()
{
WinBits nWinStyle = mrParent.GetStyle();
// draw extra line if above and below border
if ((nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER))
{
Size aOutputSize = mrParent.GetOutputSizePixel();
Rectangle aOutRect = mrParent.GetPageArea();
// also draw border in 3D for 3D-tabs
if (nWinStyle & WB_3DTAB)
{
mrParent.SetLineColor(mpStyleSettings->GetShadowColor());
mrParent.DrawLine(Point(aOutRect.Left(), 0), Point(aOutputSize.Width(), 0));
}
// draw border (line above and line below)
mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
mrParent.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
}
}
void drawOuterFrame()
{
mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
// set correct FillInBrush depending on status
if (mbSelected)
{
// Currently selected Tab
mrParent.SetFillColor(maSelectedColor);
}
else if (mbCustomColored)
{
mrParent.SetFillColor(maCustomColor);
}
else
{
mrParent.SetFillColor(maUnselectedColor);
}
mrParent.DrawRect(maRect);
}
void drawText(const OUString& aText)
{
Rectangle aRect = maRect;
long nTextWidth = mrParent.GetTextWidth(aText);
long nTextHeight = mrParent.GetTextHeight();
Point aPos = aRect.TopLeft();
aPos.X() += (aRect.getWidth() - nTextWidth) / 2;
aPos.Y() += (aRect.getHeight() - nTextHeight) / 2;
if (mbEnabled)
mrParent.DrawText(aPos, aText);
else
mrParent.DrawCtrlText(aPos, aText, 0, aText.getLength(),
(TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
}
void drawOverTopBorder()
{
Point aTopLeft = maRect.TopLeft() + Point(1, 0);
Point aTopRight = maRect.TopRight() + Point(-1, 0);
Rectangle aDelRect(aTopLeft, aTopRight);
mrParent.DrawRect(aDelRect);
}
void drawColorLine()
{
mrParent.SetFillColor(maCustomColor);
mrParent.SetLineColor(maCustomColor);
Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
aLineRect.Top() -= 3;
mrParent.DrawRect(aLineRect);
}
void drawTab()
{
drawOuterFrame();
if (mbCustomColored && mbSelected)
{
drawColorLine();
}
}
void drawPlusImage()
{
const StyleSettings& rStyleSettings = mrParent.GetSettings().GetStyleSettings();
DecorationView aDecorationView(&mrParent);
sal_Int32 aScaleFactor = mrParent.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, rStyleSettings.GetDarkShadowColor());
}
void setRect(const Rectangle& rRect)
{
maRect = rRect;
}
void setSelected(bool bSelected)
{
mbSelected = bSelected;
}
void setCustomColored(bool bCustomColored)
{
mbCustomColored = bCustomColored;
}
void setSpecialTab(bool bSpecialTab)
{
mbSpecialTab = bSpecialTab;
}
void setEnabled(bool bEnabled)
{
mbEnabled = bEnabled;
}
void setSelectedFillColor(const Color& rColor)
{
maSelectedColor = rColor;
}
void setUnselectedFillColor(const Color& rColor)
{
maUnselectedColor = rColor;
}
void setCustomColor(const Color& rColor)
{
maCustomColor = rColor;
}
private:
TabBar& mrParent;
const StyleSettings* mpStyleSettings;
Rectangle maRect;
Color maSelectedColor;
Color maCustomColor;
Color maUnselectedColor;
bool mbSelected:1;
bool mbCustomColored:1;
bool mbSpecialTab:1;
bool mbEnabled:1;
};
} // anonymous namespace
void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rect )
{
if(IsNativeControlSupported(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL))
DrawNativeControl(CTRL_WINDOW_BACKGROUND,PART_ENTIRE_CONTROL,rect,
ControlState::ENABLED,ImplControlValue(0),OUString()); ControlState::ENABLED,ImplControlValue(0),OUString());
}
// calculate items and emit // calculate items and emit
sal_uInt16 nItemCount = mpImpl->getItemSize(); sal_uInt16 nItemCount = mpImpl->getItemSize();
if (!nItemCount) if (!nItemCount)
return; return;
ImplPrePaint(); ImplPrePaint(rRenderContext);
Color aFaceColor, aSelectColor, aFaceTextColor, aSelectTextColor; Color aFaceColor, aSelectColor, aFaceTextColor, aSelectTextColor;
ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor ); const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
ImplGetColors(rStyleSettings, aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
rRenderContext.Push(PushFlags::FONT | PushFlags::CLIPREGION);
rRenderContext.SetClipRegion(vcl::Region(GetPageArea()));
// select font // select font
vcl::Font aFont = GetFont(); vcl::Font aFont = rRenderContext.GetFont();
vcl::Font aLightFont = aFont; vcl::Font aLightFont = aFont;
aLightFont.SetWeight( WEIGHT_NORMAL ); aLightFont.SetWeight(WEIGHT_NORMAL);
TabBarPaintGuard aGuard(*this); TabDrawer aDrawer(*this, rRenderContext);
TabDrawer aDrawer(*this);
aDrawer.setSelectedFillColor(aSelectColor); aDrawer.setSelectedFillColor(aSelectColor);
aDrawer.setUnselectedFillColor(aFaceColor); aDrawer.setUnselectedFillColor(aFaceColor);
...@@ -1262,23 +1238,22 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec ...@@ -1262,23 +1238,22 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
aDrawer.drawPlusImage(); aDrawer.drawPlusImage();
} }
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
ImplTabBarItem* pCurItem = NULL; ImplTabBarItem* pCurItem = NULL;
while ( pItem ) while (pItem)
{ {
// emit CurrentItem last, as it covers all others // emit CurrentItem last, as it covers all others
if ( !pCurItem && (pItem->mnId == mnCurPageId) ) if (!pCurItem && (pItem->mnId == mnCurPageId))
{ {
pCurItem = pItem; pCurItem = pItem;
pItem = prev(); pItem = prev();
if ( !pItem ) if (!pItem)
pItem = pCurItem; pItem = pCurItem;
continue; continue;
} }
bool bCurrent = pItem == pCurItem; bool bCurrent = pItem == pCurItem;
if ( !pItem->maRect.IsEmpty() ) if (!pItem->maRect.IsEmpty())
{ {
Rectangle aRect = pItem->maRect; Rectangle aRect = pItem->maRect;
bool bSelected = pItem->IsSelected(pCurItem); bool bSelected = pItem->IsSelected(pCurItem);
...@@ -1286,8 +1261,7 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec ...@@ -1286,8 +1261,7 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode(); bool bCustomBgColor = !pItem->IsDefaultTabBgColor() && !rStyleSettings.GetHighContrastMode();
bool bSpecialTab = (pItem->mnBits & TPB_SPECIAL); bool bSpecialTab = (pItem->mnBits & TPB_SPECIAL);
bool bEnabled = pItem->mbEnable; bool bEnabled = pItem->mbEnable;
OUString aText = pItem->mbShort ? OUString aText = pItem->mbShort ? rRenderContext.GetEllipsisString(pItem->maText, mnCurMaxWidth, TEXT_DRAW_ENDELLIPSIS) : pItem->maText;
GetEllipsisString(pItem->maText, mnCurMaxWidth, TEXT_DRAW_ENDELLIPSIS) : pItem->maText;
aDrawer.setRect(aRect); aDrawer.setRect(aRect);
aDrawer.setSelected(bSelected); aDrawer.setSelected(bSelected);
...@@ -1298,30 +1272,30 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec ...@@ -1298,30 +1272,30 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
aDrawer.drawTab(); aDrawer.drawTab();
// actual page is drawn using a bold font // actual page is drawn using a bold font
if ( bCurrent ) if (bCurrent)
SetFont( aFont ); rRenderContext.SetFont(aFont);
else else
SetFont( aLightFont ); rRenderContext.SetFont(aLightFont);
// Set the correct FillInBrush depending on status // Set the correct FillInBrush depending on status
if ( bSelected ) if (bSelected)
SetTextColor( aSelectTextColor ); rRenderContext.SetTextColor(aSelectTextColor);
else if ( bCustomBgColor ) else if (bCustomBgColor)
SetTextColor( pItem->maTabTextColor ); rRenderContext.SetTextColor(pItem->maTabTextColor);
else else
SetTextColor( aFaceTextColor ); rRenderContext.SetTextColor(aFaceTextColor);
// This tab is "special", and a special tab needs a blue text. // This tab is "special", and a special tab needs a blue text.
if (bSpecialTab) if (bSpecialTab)
SetTextColor(Color(COL_LIGHTBLUE)); rRenderContext.SetTextColor(Color(COL_LIGHTBLUE));
aDrawer.drawText(aText); aDrawer.drawText(aText);
if ( bCurrent ) if (bCurrent)
{ {
SetLineColor(); rRenderContext.SetLineColor();
SetFillColor(aSelectColor); rRenderContext.SetFillColor(aSelectColor);
aDrawer.drawOverTopBorder(); aDrawer.drawOverTopBorder();
return; return;
} }
...@@ -1330,13 +1304,13 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec ...@@ -1330,13 +1304,13 @@ void TabBar::Paint( vcl::RenderContext& /*rRenderContext*/, const Rectangle& rec
} }
else else
{ {
if ( bCurrent ) if (bCurrent)
return; return;
pItem = NULL; pItem = NULL;
} }
if ( !pItem ) if (!pItem)
pItem = pCurItem; pItem = pCurItem;
} }
} }
...@@ -1624,7 +1598,7 @@ bool TabBar::ImplDeactivatePage() ...@@ -1624,7 +1598,7 @@ bool TabBar::ImplDeactivatePage()
return nRet; return nRet;
} }
void TabBar::ImplPrePaint() void TabBar::ImplPrePaint(vcl::RenderContext& /*rRenderContext*/)
{ {
sal_uInt16 nItemCount = mpImpl->getItemSize(); sal_uInt16 nItemCount = mpImpl->getItemSize();
if (!nItemCount) if (!nItemCount)
...@@ -1635,20 +1609,20 @@ void TabBar::ImplPrePaint() ...@@ -1635,20 +1609,20 @@ void TabBar::ImplPrePaint()
ImplFormat(); ImplFormat();
// assure the actual tabpage becomes visible at first format // assure the actual tabpage becomes visible at first format
if ( mbFirstFormat ) if (mbFirstFormat)
{ {
mbFirstFormat = false; mbFirstFormat = false;
if ( mnCurPageId && (mnFirstPos == 0) && !mbDropPos ) if (mnCurPageId && (mnFirstPos == 0) && !mbDropPos)
{ {
ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)]; ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)];
if ( pItem->maRect.IsEmpty() ) if (pItem->maRect.IsEmpty())
{ {
// set mbDropPos (or misuse) to prevent Invalidate() // set mbDropPos (or misuse) to prevent Invalidate()
mbDropPos = true; mbDropPos = true;
SetFirstPageId( mnCurPageId ); SetFirstPageId(mnCurPageId);
mbDropPos = false; mbDropPos = false;
if ( mnFirstPos != 0 ) if (mnFirstPos != 0)
ImplFormat(); ImplFormat();
} }
} }
...@@ -2164,16 +2138,16 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const ...@@ -2164,16 +2138,16 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const
return false; return false;
} }
bool TabBar::StartEditMode( sal_uInt16 nPageId ) bool TabBar::StartEditMode(sal_uInt16 nPageId)
{ {
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if (mpImpl->mpEdit || (nPos == PAGE_NOT_FOUND) || (mnLastOffX < 8)) if (mpImpl->mpEdit || (nPos == PAGE_NOT_FOUND) || (mnLastOffX < 8))
return false; return false;
mnEditId = nPageId; mnEditId = nPageId;
if ( StartRenaming() ) if (StartRenaming())
{ {
ImplShowPage( nPos ); ImplShowPage(nPos);
ImplFormat(); ImplFormat();
Update(); Update();
...@@ -2181,11 +2155,11 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId ) ...@@ -2181,11 +2155,11 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
Rectangle aRect = GetPageRect( mnEditId ); Rectangle aRect = GetPageRect( mnEditId );
long nX = aRect.Left(); long nX = aRect.Left();
long nWidth = aRect.GetWidth(); long nWidth = aRect.GetWidth();
if ( mnEditId != GetCurPageId() ) if (mnEditId != GetCurPageId())
nX += 1; nX += 1;
if ( nX+nWidth > mnLastOffX ) if (nX + nWidth > mnLastOffX)
nWidth = mnLastOffX-nX; nWidth = mnLastOffX-nX;
if ( nWidth < 3 ) if (nWidth < 3)
{ {
nX = aRect.Left(); nX = aRect.Left();
nWidth = aRect.GetWidth(); nWidth = aRect.GetWidth();
...@@ -2193,16 +2167,21 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId ) ...@@ -2193,16 +2167,21 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
mpImpl->mpEdit->SetText(GetPageText(mnEditId)); mpImpl->mpEdit->SetText(GetPageText(mnEditId));
mpImpl->mpEdit->setPosSizePixel(nX, aRect.Top() + mnOffY + 1, nWidth, aRect.GetHeight() - 3); mpImpl->mpEdit->setPosSizePixel(nX, aRect.Top() + mnOffY + 1, nWidth, aRect.GetHeight() - 3);
vcl::Font aFont = GetPointFont(); vcl::Font aFont = GetPointFont();
Color aForegroundColor; Color aForegroundColor;
Color aBackgroundColor; Color aBackgroundColor;
Color aFaceColor; Color aFaceColor;
Color aSelectColor; Color aSelectColor;
Color aFaceTextColor; Color aFaceTextColor;
Color aSelectTextColor; Color aSelectTextColor;
ImplGetColors( aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor );
if ( mnEditId != GetCurPageId() ) ImplGetColors(Application::GetSettings().GetStyleSettings(), aFaceColor, aFaceTextColor, aSelectColor, aSelectTextColor);
aFont.SetWeight( WEIGHT_LIGHT );
if ( IsPageSelected( mnEditId ) || (mnEditId == GetCurPageId()) ) if (mnEditId != GetCurPageId())
{
aFont.SetWeight(WEIGHT_LIGHT);
}
if (IsPageSelected(mnEditId) || mnEditId == GetCurPageId())
{ {
aForegroundColor = aSelectTextColor; aForegroundColor = aSelectTextColor;
aBackgroundColor = aSelectColor; aBackgroundColor = aSelectColor;
...@@ -2212,8 +2191,10 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId ) ...@@ -2212,8 +2191,10 @@ bool TabBar::StartEditMode( sal_uInt16 nPageId )
aForegroundColor = aFaceTextColor; aForegroundColor = aFaceTextColor;
aBackgroundColor = aFaceColor; aBackgroundColor = aFaceColor;
} }
if ( GetPageBits( mnEditId ) & TPB_SPECIAL ) if (GetPageBits( mnEditId ) & TPB_SPECIAL)
aForegroundColor = Color( COL_LIGHTBLUE ); {
aForegroundColor = Color(COL_LIGHTBLUE);
}
mpImpl->mpEdit->SetControlFont(aFont); mpImpl->mpEdit->SetControlFont(aFont);
mpImpl->mpEdit->SetControlForeground(aForegroundColor); mpImpl->mpEdit->SetControlForeground(aForegroundColor);
mpImpl->mpEdit->SetControlBackground(aBackgroundColor); mpImpl->mpEdit->SetControlBackground(aBackgroundColor);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment