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

Cleanup and simplify TabDrawer & remove maPoly

Change-Id: Ib11a610bafcc54516b873304f778ee92603d5c31
üst e4de5b40
...@@ -1066,9 +1066,6 @@ void TabBar::MouseButtonUp( const MouseEvent& rMEvt ) ...@@ -1066,9 +1066,6 @@ void TabBar::MouseButtonUp( const MouseEvent& rMEvt )
Window::MouseButtonUp( rMEvt ); Window::MouseButtonUp( rMEvt );
} }
namespace { namespace {
class TabBarPaintGuard class TabBarPaintGuard
...@@ -1101,7 +1098,6 @@ public: ...@@ -1101,7 +1098,6 @@ public:
explicit TabDrawer(TabBar& rParent) : explicit TabDrawer(TabBar& rParent) :
mrParent(rParent), mrParent(rParent),
mpStyleSettings(&mrParent.GetSettings().GetStyleSettings()), mpStyleSettings(&mrParent.GetSettings().GetStyleSettings()),
maPoly(4),
mbSelected(false), mbSelected(false),
mbCustomColored(false), mbCustomColored(false),
mbSpecialTab(false), mbSpecialTab(false),
...@@ -1114,27 +1110,44 @@ public: ...@@ -1114,27 +1110,44 @@ public:
WinBits nWinStyle = mrParent.GetStyle(); WinBits nWinStyle = mrParent.GetStyle();
// draw extra line if above and below border // draw extra line if above and below border
if ( (nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER) ) if ((nWinStyle & WB_BORDER) || (nWinStyle & WB_TOPBORDER))
{ {
Size aOutputSize = mrParent.GetOutputSizePixel(); Size aOutputSize = mrParent.GetOutputSizePixel();
Rectangle aOutRect = mrParent.GetPageArea(); Rectangle aOutRect = mrParent.GetPageArea();
// also draw border in 3D for 3D-tabs // also draw border in 3D for 3D-tabs
if ( nWinStyle & WB_3DTAB ) if (nWinStyle & WB_3DTAB)
{ {
mrParent.SetLineColor( mpStyleSettings->GetShadowColor() ); mrParent.SetLineColor(mpStyleSettings->GetShadowColor());
mrParent.DrawLine( Point( aOutRect.Left(), 0 ), Point( aOutputSize.Width(), 0 ) ); mrParent.DrawLine(Point(aOutRect.Left(), 0), Point(aOutputSize.Width(), 0));
} }
// draw border (line above and line below) // draw border (line above and line below)
mrParent.SetLineColor( mpStyleSettings->GetDarkShadowColor() ); mrParent.SetLineColor(mpStyleSettings->GetDarkShadowColor());
mrParent.DrawLine( aOutRect.TopLeft(), Point( aOutputSize.Width()-1, aOutRect.Top() ) ); mrParent.DrawLine(aOutRect.TopLeft(), Point(aOutputSize.Width() - 1, aOutRect.Top()));
} }
} }
void drawOuterFrame() void drawOuterFrame()
{ {
mrParent.DrawPolygon(maPoly); 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) void drawText(const OUString& aText)
...@@ -1149,60 +1162,36 @@ public: ...@@ -1149,60 +1162,36 @@ public:
if (mbEnabled) if (mbEnabled)
mrParent.DrawText(aPos, aText); mrParent.DrawText(aPos, aText);
else else
mrParent.DrawCtrlText( aPos, aText, 0, aText.getLength(), mrParent.DrawCtrlText(aPos, aText, 0, aText.getLength(),
(TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC)); (TEXT_DRAW_DISABLE | TEXT_DRAW_MNEMONIC));
} }
void drawOverTopBorder(bool b3DTab) void drawOverTopBorder()
{ {
Point p1 = maPoly[0]; Point aTopLeft = maRect.TopLeft() + Point(1, 0);
Point p2 = maPoly[3]; Point aTopRight = maRect.TopRight() + Point(-1, 0);
p1.X() += 1;
p2.X() -= 1; Rectangle aDelRect(aTopLeft, aTopRight);
Rectangle aDelRect(p1, p2);
mrParent.DrawRect(aDelRect); mrParent.DrawRect(aDelRect);
if (b3DTab)
{
aDelRect.Top()--;
mrParent.DrawRect(aDelRect);
}
} }
void drawColorLine() void drawColorLine()
{ {
Point p1 = maPoly[1]; mrParent.SetFillColor(maCustomColor);
Point p2 = maPoly[2]; mrParent.SetLineColor(maCustomColor);
p1 += Point(1, 0);
p2 += Point(-1, -3);
mrParent.DrawRect(Rectangle(p1, p2)); Rectangle aLineRect(maRect.BottomLeft(), maRect.BottomRight());
aLineRect.Top() -= 3;
mrParent.DrawRect(aLineRect);
} }
void drawTab() void drawTab()
{ {
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 );
}
drawOuterFrame(); drawOuterFrame();
if (mbCustomColored && mbSelected) if (mbCustomColored && mbSelected)
{ {
mrParent.SetFillColor(maCustomColor);
mrParent.SetLineColor(maCustomColor);
drawColorLine(); drawColorLine();
} }
} }
...@@ -1233,34 +1222,26 @@ public: ...@@ -1233,34 +1222,26 @@ public:
void setRect(const Rectangle& rRect) void setRect(const Rectangle& rRect)
{ {
maRect = rRect; maRect = rRect;
long nOffY = mrParent.GetPageArea().getY();
// first draw filled polygon
maPoly[0] = Point( rRect.Left(), nOffY );
maPoly[1] = Point( rRect.Left(), rRect.Bottom() );
maPoly[2] = Point( rRect.Right(), rRect.Bottom() );
maPoly[3] = Point( rRect.Right(), nOffY );
} }
void setSelected(bool b) void setSelected(bool bSelected)
{ {
mbSelected = b; mbSelected = bSelected;
} }
void setCustomColored(bool b) void setCustomColored(bool bCustomColored)
{ {
mbCustomColored = b; mbCustomColored = bCustomColored;
} }
void setSpecialTab(bool b) void setSpecialTab(bool bSpecialTab)
{ {
mbSpecialTab = b; mbSpecialTab = bSpecialTab;
} }
void setEnabled(bool b) void setEnabled(bool bEnabled)
{ {
mbEnabled = b; mbEnabled = bEnabled;
} }
void setSelectedFillColor(const Color& rColor) void setSelectedFillColor(const Color& rColor)
...@@ -1283,7 +1264,6 @@ private: ...@@ -1283,7 +1264,6 @@ private:
const StyleSettings* mpStyleSettings; const StyleSettings* mpStyleSettings;
Rectangle maRect; Rectangle maRect;
Polygon maPoly;
Color maSelectedColor; Color maSelectedColor;
Color maCustomColor; Color maCustomColor;
...@@ -1295,7 +1275,7 @@ private: ...@@ -1295,7 +1275,7 @@ private:
bool mbEnabled:1; bool mbEnabled:1;
}; };
} } // anonymous namespace
void TabBar::Paint( const Rectangle& rect ) void TabBar::Paint( const Rectangle& rect )
{ {
...@@ -1399,7 +1379,7 @@ void TabBar::Paint( const Rectangle& rect ) ...@@ -1399,7 +1379,7 @@ void TabBar::Paint( const Rectangle& rect )
{ {
SetLineColor(); SetLineColor();
SetFillColor(aSelectColor); SetFillColor(aSelectColor);
aDrawer.drawOverTopBorder(mnWinStyle & WB_3DTAB); aDrawer.drawOverTopBorder();
return; return;
} }
......
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