/src/libreoffice/sc/source/ui/view/tabsplit.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | |
20 | | #include <tabsplit.hxx> |
21 | | #include <viewdata.hxx> |
22 | | |
23 | | #include <vcl/ptrstyle.hxx> |
24 | | #include <vcl/settings.hxx> |
25 | | |
26 | | ScTabSplitter::ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, ScViewData& rData ) : |
27 | 0 | Splitter(pParent, nWinStyle), |
28 | 0 | rViewData(rData) |
29 | 0 | { |
30 | 0 | SetFixed(false); |
31 | 0 | EnableRTL(false); |
32 | 0 | } Unexecuted instantiation: ScTabSplitter::ScTabSplitter(vcl::Window*, long, ScViewData&) Unexecuted instantiation: ScTabSplitter::ScTabSplitter(vcl::Window*, long, ScViewData&) |
33 | | |
34 | | ScTabSplitter::~ScTabSplitter() |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt ) |
39 | 0 | { |
40 | 0 | if (bFixed) |
41 | 0 | Window::MouseButtonDown( rMEvt ); |
42 | 0 | else |
43 | 0 | Splitter::MouseButtonDown( rMEvt ); |
44 | 0 | } |
45 | | |
46 | | void ScTabSplitter::SetFixed(bool bSet) |
47 | 0 | { |
48 | 0 | bFixed = bSet; |
49 | 0 | if (bSet) |
50 | 0 | SetPointer(PointerStyle::Arrow); |
51 | 0 | else if (IsHorizontal()) |
52 | 0 | SetPointer(PointerStyle::HSplit); |
53 | 0 | else |
54 | 0 | SetPointer(PointerStyle::VSplit); |
55 | 0 | } |
56 | | |
57 | | void ScTabSplitter::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) |
58 | 0 | { |
59 | 0 | auto popIt = rRenderContext.ScopedPush(vcl::PushFlags::FILLCOLOR | vcl::PushFlags::LINECOLOR); |
60 | 0 | const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); |
61 | |
|
62 | 0 | if (IsHorizontal()) |
63 | 0 | { |
64 | 0 | switch (rViewData.GetHSplitMode()) |
65 | 0 | { |
66 | 0 | case SC_SPLIT_NONE: |
67 | 0 | { |
68 | 0 | rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); |
69 | 0 | rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); |
70 | 0 | rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom())); |
71 | | |
72 | | // Draw handle |
73 | 0 | rRenderContext.SetLineColor(COL_BLACK); |
74 | 0 | rRenderContext.SetFillColor(COL_BLACK); |
75 | 0 | const tools::Long xc = rRect.Right() + rRect.Left(); |
76 | 0 | const tools::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 | 0 | rRenderContext.DrawRect(tools::Rectangle(Point(xc / 2, rRect.Top() + h4), |
80 | 0 | Point((xc + 1) / 2, rRect.Bottom() - h4))); |
81 | 0 | break; |
82 | 0 | } |
83 | 0 | case SC_SPLIT_NORMAL: |
84 | 0 | rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); |
85 | 0 | rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); |
86 | 0 | rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom())); |
87 | 0 | break; |
88 | 0 | case SC_SPLIT_FIX: |
89 | | // Nothing to draw |
90 | 0 | break; |
91 | 0 | } |
92 | 0 | } |
93 | 0 | else |
94 | 0 | { |
95 | 0 | switch (rViewData.GetVSplitMode()) |
96 | 0 | { |
97 | 0 | case SC_SPLIT_NONE: |
98 | 0 | { |
99 | 0 | rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); |
100 | 0 | rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); |
101 | 0 | rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom())); |
102 | | |
103 | | // Draw handle |
104 | 0 | rRenderContext.SetLineColor(COL_BLACK); |
105 | 0 | rRenderContext.SetFillColor(COL_BLACK); |
106 | 0 | const tools::Long yc = rRect.Top() + rRect.Bottom(); |
107 | 0 | const tools::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 | 0 | GetOutDev()->DrawRect(tools::Rectangle(Point(rRect.Left() + w4, yc / 2), |
111 | 0 | Point(rRect.Right() - w4, (yc + 1) / 2))); |
112 | 0 | break; |
113 | 0 | } |
114 | 0 | case SC_SPLIT_NORMAL: |
115 | 0 | rRenderContext.SetLineColor(rStyleSettings.GetShadowColor()); |
116 | 0 | rRenderContext.SetFillColor(rStyleSettings.GetShadowColor()); |
117 | 0 | rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom())); |
118 | 0 | break; |
119 | 0 | case SC_SPLIT_FIX: |
120 | | // Nothing to draw |
121 | 0 | break; |
122 | 0 | } |
123 | 0 | } |
124 | 0 | } |
125 | | |
126 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |