1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
24 //==================================================================
26 ScTabSplitter::ScTabSplitter( Window
* pParent
, WinBits nWinStyle
, ScViewData
* pData
) :
27 Splitter( pParent
, nWinStyle
),
35 ScTabSplitter::~ScTabSplitter()
39 void ScTabSplitter::MouseMove( const MouseEvent
& rMEvt
)
42 Window::MouseMove( rMEvt
);
44 Splitter::MouseMove( rMEvt
);
47 void ScTabSplitter::MouseButtonUp( const MouseEvent
& rMEvt
)
50 Window::MouseButtonUp( rMEvt
);
52 Splitter::MouseButtonUp( rMEvt
);
55 void ScTabSplitter::MouseButtonDown( const MouseEvent
& rMEvt
)
58 Window::MouseButtonDown( rMEvt
);
60 Splitter::MouseButtonDown( rMEvt
);
63 void ScTabSplitter::Splitting( Point
& rSplitPos
)
65 Window
* pParent
= GetParent();
66 Point aScreenPos
= pParent
->OutputToNormalizedScreenPixel( rSplitPos
);
67 pViewData
->GetView()->SnapSplitPos( aScreenPos
);
68 Point aNew
= pParent
->NormalizedScreenToOutputPixel( aScreenPos
);
70 rSplitPos
.X() = aNew
.X();
72 rSplitPos
.Y() = aNew
.Y();
76 void ScTabSplitter::SetFixed(bool bSet
)
80 SetPointer(POINTER_ARROW
);
81 else if (IsHorizontal())
82 SetPointer(POINTER_HSPLIT
);
84 SetPointer(POINTER_VSPLIT
);
87 void ScTabSplitter::Paint( const Rectangle
& rRect
)
89 const Color oldFillCol
= GetFillColor();
90 const Color oldLineCol
= GetLineColor();
94 switch (pViewData
->GetHSplitMode())
99 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
100 DrawLine(rRect
.TopRight(), rRect
.BottomRight());
101 DrawLine(rRect
.BottomLeft(), rRect
.BottomRight());
102 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
103 DrawLine(rRect
.TopLeft(), rRect
.TopRight());
104 DrawLine(rRect
.TopLeft(), rRect
.BottomLeft());
105 // Fill internal rectangle
107 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
108 DrawRect(Rectangle(rRect
.Left()+1, rRect
.Top()+1, rRect
.Right()-1, rRect
.Bottom()-1));
110 SetLineColor(Color(COL_BLACK
));
111 SetFillColor(Color(COL_BLACK
));
112 const long xc
= rRect
.Right()+rRect
.Left();
113 const long h4
= rRect
.GetHeight()/4;
114 // First xc fraction is truncated, second one is rounded. This will draw a centered line
115 // in handlers with odd width and a centered rectangle in those with even width.
116 DrawRect(Rectangle(Point(xc
/2, rRect
.Top()+h4
), Point((xc
+1)/2, rRect
.Bottom()-h4
)));
119 case SC_SPLIT_NORMAL
:
120 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
121 DrawLine(rRect
.TopLeft(), rRect
.BottomLeft());
122 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
123 DrawLine(rRect
.TopRight(), rRect
.BottomRight());
125 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
126 DrawRect(Rectangle(Point(rRect
.Left()+1, rRect
.Top()), Point(rRect
.Right()-1, rRect
.Bottom())));
135 switch (pViewData
->GetVSplitMode())
140 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
141 DrawLine(rRect
.TopRight(), rRect
.BottomRight());
142 DrawLine(rRect
.BottomLeft(), rRect
.BottomRight());
143 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
144 DrawLine(rRect
.TopLeft(), rRect
.TopRight());
145 DrawLine(rRect
.TopLeft(), rRect
.BottomLeft());
146 // Fill internal rectangle
148 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
149 DrawRect(Rectangle(rRect
.Left()+1, rRect
.Top()+1, rRect
.Right()-1, rRect
.Bottom()-1));
151 SetLineColor(Color(COL_BLACK
));
152 SetFillColor(Color(COL_BLACK
));
153 const long yc
= rRect
.Top()+rRect
.Bottom();
154 const long w4
= rRect
.GetWidth()/4;
155 // First yc fraction is truncated, second one is rounded. This will draw a centered line
156 // in handlers with odd height and a centered rectangle in those with even height.
157 DrawRect(Rectangle(Point(rRect
.Left()+w4
, yc
/2), Point(rRect
.Right()-w4
, (yc
+1)/2)));
160 case SC_SPLIT_NORMAL
:
161 SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
162 DrawLine(rRect
.TopLeft(), rRect
.TopRight());
163 SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
164 DrawLine(rRect
.BottomLeft(), rRect
.BottomRight());
166 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
167 DrawRect(Rectangle(Point(rRect
.Left(), rRect
.Top()+1), Point(rRect
.Right(), rRect
.Bottom()-1)));
175 SetFillColor(oldFillCol
);
176 SetLineColor(oldLineCol
);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */