fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / view / tabsplit.cxx
blob2ba86b514965c0dd873c75222eceaf76c75ba2b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "tabsplit.hxx"
21 #include "viewdata.hxx"
22 #include "dbfunc.hxx"
24 #include <vcl/settings.hxx>
26 ScTabSplitter::ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
27 Splitter(pParent, nWinStyle),
28 pViewData(pData)
30 SetFixed(false);
31 EnableRTL(false);
34 ScTabSplitter::~ScTabSplitter()
38 void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
40 if (bFixed)
41 Window::MouseButtonDown( rMEvt );
42 else
43 Splitter::MouseButtonDown( rMEvt );
46 void ScTabSplitter::SetFixed(bool bSet)
48 bFixed = bSet;
49 if (bSet)
50 SetPointer(PointerStyle::Arrow);
51 else if (IsHorizontal())
52 SetPointer(PointerStyle::HSplit);
53 else
54 SetPointer(PointerStyle::VSplit);
57 void ScTabSplitter::Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect )
59 rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
60 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
62 if (IsHorizontal())
64 switch (pViewData->GetHSplitMode())
66 case SC_SPLIT_NONE:
68 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
69 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
70 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
72 // Draw handle
73 rRenderContext.SetLineColor(Color(COL_BLACK));
74 rRenderContext.SetFillColor(Color(COL_BLACK));
75 const long xc = rRect.Right() + rRect.Left();
76 const long h4 = rRect.GetHeight() / 4;
77 // First xc fraction is truncated, second one is rounded. This will draw a centered line
78 // in handlers with odd width and a centered rectangle in those with even width.
79 rRenderContext.DrawRect(Rectangle(Point(xc / 2, rRect.Top() + h4),
80 Point((xc + 1) / 2, rRect.Bottom() - h4)));
81 break;
83 case SC_SPLIT_NORMAL:
84 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
85 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
86 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
87 break;
88 case SC_SPLIT_FIX:
89 // Nothing to draw
90 break;
93 else
95 switch (pViewData->GetVSplitMode())
97 case SC_SPLIT_NONE:
99 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
100 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
101 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
103 // Draw handle
104 rRenderContext.SetLineColor(Color(COL_BLACK));
105 rRenderContext.SetFillColor(Color(COL_BLACK));
106 const long yc = rRect.Top() + rRect.Bottom();
107 const long w4 = rRect.GetWidth() / 4;
108 // First yc fraction is truncated, second one is rounded. This will draw a centered line
109 // in handlers with odd height and a centered rectangle in those with even height.
110 DrawRect(Rectangle(Point(rRect.Left() + w4, yc / 2),
111 Point(rRect.Right() - w4, (yc + 1) / 2)));
112 break;
114 case SC_SPLIT_NORMAL:
115 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
116 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
117 rRenderContext.DrawRect(Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
118 break;
119 case SC_SPLIT_FIX:
120 // Nothing to draw
121 break;
125 rRenderContext.Pop();
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */