Line data Source code
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 : #include "dbfunc.hxx"
23 :
24 : #include <vcl/settings.hxx>
25 :
26 0 : ScTabSplitter::ScTabSplitter( Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
27 : Splitter( pParent, nWinStyle ),
28 0 : pViewData(pData)
29 : {
30 0 : SetFixed(false);
31 0 : EnableRTL( false );
32 0 : }
33 :
34 :
35 0 : ScTabSplitter::~ScTabSplitter()
36 : {
37 0 : }
38 :
39 0 : void ScTabSplitter::MouseMove( const MouseEvent& rMEvt )
40 : {
41 0 : if (bFixed)
42 0 : Window::MouseMove( rMEvt );
43 : else
44 0 : Splitter::MouseMove( rMEvt );
45 0 : }
46 :
47 0 : void ScTabSplitter::MouseButtonUp( const MouseEvent& rMEvt )
48 : {
49 0 : if (bFixed)
50 0 : Window::MouseButtonUp( rMEvt );
51 : else
52 0 : Splitter::MouseButtonUp( rMEvt );
53 0 : }
54 :
55 0 : void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
56 : {
57 0 : if (bFixed)
58 0 : Window::MouseButtonDown( rMEvt );
59 : else
60 0 : Splitter::MouseButtonDown( rMEvt );
61 0 : }
62 :
63 0 : void ScTabSplitter::Splitting( Point& rSplitPos )
64 : {
65 0 : Window* pParent = GetParent();
66 0 : Point aScreenPos = pParent->OutputToNormalizedScreenPixel( rSplitPos );
67 0 : pViewData->GetView()->SnapSplitPos( aScreenPos );
68 0 : Point aNew = pParent->NormalizedScreenToOutputPixel( aScreenPos );
69 0 : if ( IsHorizontal() )
70 0 : rSplitPos.X() = aNew.X();
71 : else
72 0 : rSplitPos.Y() = aNew.Y();
73 0 : }
74 :
75 :
76 0 : void ScTabSplitter::SetFixed(bool bSet)
77 : {
78 0 : bFixed = bSet;
79 0 : if (bSet)
80 0 : SetPointer(POINTER_ARROW);
81 0 : else if (IsHorizontal())
82 0 : SetPointer(POINTER_HSPLIT);
83 : else
84 0 : SetPointer(POINTER_VSPLIT);
85 0 : }
86 :
87 0 : void ScTabSplitter::Paint( const Rectangle& rRect )
88 : {
89 0 : const Color oldFillCol = GetFillColor();
90 0 : const Color oldLineCol = GetLineColor();
91 :
92 0 : if (IsHorizontal())
93 : {
94 0 : switch (pViewData->GetHSplitMode())
95 : {
96 : case SC_SPLIT_NONE:
97 : {
98 : // Draw 3D border
99 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
100 0 : DrawLine(rRect.TopRight(), rRect.BottomRight());
101 0 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
102 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
103 0 : DrawLine(rRect.TopLeft(), rRect.TopRight());
104 0 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
105 : // Fill internal rectangle
106 0 : SetLineColor();
107 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
108 0 : DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
109 : // Draw handle
110 0 : SetLineColor(Color(COL_BLACK));
111 0 : SetFillColor(Color(COL_BLACK));
112 0 : const long xc = rRect.Right()+rRect.Left();
113 0 : 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 0 : DrawRect(Rectangle(Point(xc/2, rRect.Top()+h4), Point((xc+1)/2, rRect.Bottom()-h4)));
117 0 : break;
118 : }
119 : case SC_SPLIT_NORMAL:
120 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
121 0 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
122 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
123 0 : DrawLine(rRect.TopRight(), rRect.BottomRight());
124 0 : SetLineColor();
125 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
126 0 : DrawRect(Rectangle(Point(rRect.Left()+1, rRect.Top()), Point(rRect.Right()-1, rRect.Bottom())));
127 0 : break;
128 : case SC_SPLIT_FIX:
129 : // Nothing to draw
130 0 : break;
131 : }
132 : }
133 : else
134 : {
135 0 : switch (pViewData->GetVSplitMode())
136 : {
137 : case SC_SPLIT_NONE:
138 : {
139 : // Draw 3D border
140 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
141 0 : DrawLine(rRect.TopRight(), rRect.BottomRight());
142 0 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
143 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
144 0 : DrawLine(rRect.TopLeft(), rRect.TopRight());
145 0 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
146 : // Fill internal rectangle
147 0 : SetLineColor();
148 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
149 0 : DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
150 : // Draw handle
151 0 : SetLineColor(Color(COL_BLACK));
152 0 : SetFillColor(Color(COL_BLACK));
153 0 : const long yc = rRect.Top()+rRect.Bottom();
154 0 : 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 0 : DrawRect(Rectangle(Point(rRect.Left()+w4, yc/2), Point(rRect.Right()-w4, (yc+1)/2)));
158 0 : break;
159 : }
160 : case SC_SPLIT_NORMAL:
161 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
162 0 : DrawLine(rRect.TopLeft(), rRect.TopRight());
163 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
164 0 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
165 0 : SetLineColor();
166 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
167 0 : DrawRect(Rectangle(Point(rRect.Left(), rRect.Top()+1), Point(rRect.Right(), rRect.Bottom()-1)));
168 0 : break;
169 : case SC_SPLIT_FIX:
170 : // Nothing to draw
171 0 : break;
172 : }
173 : }
174 :
175 0 : SetFillColor(oldFillCol);
176 0 : SetLineColor(oldLineCol);
177 0 : }
178 :
179 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|