LibreOffice Module sc (master) 1
tabsplit.cxx
Go to the documentation of this file.
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/settings.hxx>
24
25ScTabSplitter::ScTabSplitter( vcl::Window* pParent, WinBits nWinStyle, const ScViewData* pData ) :
26 Splitter(pParent, nWinStyle),
27 pViewData(pData)
28{
29 SetFixed(false);
30 EnableRTL(false);
31}
32
34{
35}
36
38{
39 if (bFixed)
40 Window::MouseButtonDown( rMEvt );
41 else
43}
44
46{
47 bFixed = bSet;
48 if (bSet)
49 SetPointer(PointerStyle::Arrow);
50 else if (IsHorizontal())
51 SetPointer(PointerStyle::HSplit);
52 else
53 SetPointer(PointerStyle::VSplit);
54}
55
56void ScTabSplitter::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect )
57{
59 const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
60
61 if (IsHorizontal())
62 {
63 switch (pViewData->GetHSplitMode())
64 {
65 case SC_SPLIT_NONE:
66 {
67 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
68 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
69 rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
70
71 // Draw handle
72 rRenderContext.SetLineColor(COL_BLACK);
73 rRenderContext.SetFillColor(COL_BLACK);
74 const tools::Long xc = rRect.Right() + rRect.Left();
75 const tools::Long h4 = rRect.GetHeight() / 4;
76 // First xc fraction is truncated, second one is rounded. This will draw a centered line
77 // in handlers with odd width and a centered rectangle in those with even width.
78 rRenderContext.DrawRect(tools::Rectangle(Point(xc / 2, rRect.Top() + h4),
79 Point((xc + 1) / 2, rRect.Bottom() - h4)));
80 break;
81 }
82 case SC_SPLIT_NORMAL:
83 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
84 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
85 rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
86 break;
87 case SC_SPLIT_FIX:
88 // Nothing to draw
89 break;
90 }
91 }
92 else
93 {
94 switch (pViewData->GetVSplitMode())
95 {
96 case SC_SPLIT_NONE:
97 {
98 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
99 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
100 rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
101
102 // Draw handle
103 rRenderContext.SetLineColor(COL_BLACK);
104 rRenderContext.SetFillColor(COL_BLACK);
105 const tools::Long yc = rRect.Top() + rRect.Bottom();
106 const tools::Long w4 = rRect.GetWidth() / 4;
107 // First yc fraction is truncated, second one is rounded. This will draw a centered line
108 // in handlers with odd height and a centered rectangle in those with even height.
109 GetOutDev()->DrawRect(tools::Rectangle(Point(rRect.Left() + w4, yc / 2),
110 Point(rRect.Right() - w4, (yc + 1) / 2)));
111 break;
112 }
113 case SC_SPLIT_NORMAL:
114 rRenderContext.SetLineColor(rStyleSettings.GetShadowColor());
115 rRenderContext.SetFillColor(rStyleSettings.GetShadowColor());
116 rRenderContext.DrawRect(tools::Rectangle(rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom()));
117 break;
118 case SC_SPLIT_FIX:
119 // Nothing to draw
120 break;
121 }
122 }
123
124 rRenderContext.Pop();
125}
126
127/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const StyleSettings & GetStyleSettings() const
void DrawRect(const tools::Rectangle &rRect)
void SetLineColor()
void SetFillColor()
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
const AllSettings & GetSettings() const
virtual ~ScTabSplitter() override
Definition: tabsplit.cxx:33
const ScViewData *const pViewData
Definition: tabsplit.hxx:29
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: tabsplit.cxx:37
void SetFixed(bool bSet)
Definition: tabsplit.cxx:45
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rPaintRect) override
Definition: tabsplit.cxx:56
ScTabSplitter(vcl::Window *pParent, WinBits nWinStyle, const ScViewData *pData)
Definition: tabsplit.cxx:25
ScSplitMode GetHSplitMode() const
Definition: viewdata.hxx:416
ScSplitMode GetVSplitMode() const
Definition: viewdata.hxx:417
bool IsHorizontal() const
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
const Color & GetShadowColor() const
constexpr tools::Long GetWidth() const
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long GetHeight() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
virtual void EnableRTL(bool bEnable=true)
::OutputDevice const * GetOutDev() const
void SetPointer(PointerStyle)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
std::unique_ptr< sal_Int32[]> pData
long Long
@ SC_SPLIT_FIX
Definition: viewdata.hxx:42
@ SC_SPLIT_NORMAL
Definition: viewdata.hxx:42
@ SC_SPLIT_NONE
Definition: viewdata.hxx:42
sal_Int64 WinBits