Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / sc / source / ui / view / tabsplit.cxx
blobce9d4af38ca7c5f55baee50fe29b0d658e46ac3a
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 //==================================================================
26 ScTabSplitter::ScTabSplitter( Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
27 Splitter( pParent, nWinStyle ),
28 pViewData(pData)
30 SetFixed(false);
31 EnableRTL( false );
35 ScTabSplitter::~ScTabSplitter()
39 void ScTabSplitter::MouseMove( const MouseEvent& rMEvt )
41 if (bFixed)
42 Window::MouseMove( rMEvt );
43 else
44 Splitter::MouseMove( rMEvt );
47 void ScTabSplitter::MouseButtonUp( const MouseEvent& rMEvt )
49 if (bFixed)
50 Window::MouseButtonUp( rMEvt );
51 else
52 Splitter::MouseButtonUp( rMEvt );
55 void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
57 if (bFixed)
58 Window::MouseButtonDown( rMEvt );
59 else
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 );
69 if ( IsHorizontal() )
70 rSplitPos.X() = aNew.X();
71 else
72 rSplitPos.Y() = aNew.Y();
76 void ScTabSplitter::SetFixed(bool bSet)
78 bFixed = bSet;
79 if (bSet)
80 SetPointer(POINTER_ARROW);
81 else if (IsHorizontal())
82 SetPointer(POINTER_HSPLIT);
83 else
84 SetPointer(POINTER_VSPLIT);
87 void ScTabSplitter::Paint( const Rectangle& rRect )
89 const Color oldFillCol = GetFillColor();
90 const Color oldLineCol = GetLineColor();
92 if (IsHorizontal())
94 switch (pViewData->GetHSplitMode())
96 case SC_SPLIT_NONE:
98 // Draw 3D border
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
106 SetLineColor();
107 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
108 DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
109 // Draw handle
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)));
117 break;
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());
124 SetLineColor();
125 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
126 DrawRect(Rectangle(Point(rRect.Left()+1, rRect.Top()), Point(rRect.Right()-1, rRect.Bottom())));
127 break;
128 case SC_SPLIT_FIX:
129 // Nothing to draw
130 break;
133 else
135 switch (pViewData->GetVSplitMode())
137 case SC_SPLIT_NONE:
139 // Draw 3D border
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
147 SetLineColor();
148 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
149 DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
150 // Draw handle
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)));
158 break;
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());
165 SetLineColor();
166 SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
167 DrawRect(Rectangle(Point(rRect.Left(), rRect.Top()+1), Point(rRect.Right(), rRect.Bottom()-1)));
168 break;
169 case SC_SPLIT_FIX:
170 // Nothing to draw
171 break;
175 SetFillColor(oldFillCol);
176 SetLineColor(oldLineCol);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */