Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "tabsplit.hxx"
30 : : #include "viewdata.hxx"
31 : : #include "dbfunc.hxx"
32 : :
33 : : //==================================================================
34 : :
35 : 458 : ScTabSplitter::ScTabSplitter( Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
36 : : Splitter( pParent, nWinStyle ),
37 : 458 : pViewData(pData)
38 : : {
39 [ + - ]: 458 : SetFixed(false);
40 [ + - ]: 458 : EnableRTL( false );
41 : 458 : }
42 : :
43 : :
44 : 450 : ScTabSplitter::~ScTabSplitter()
45 : : {
46 [ - + ]: 900 : }
47 : :
48 : 0 : void ScTabSplitter::MouseMove( const MouseEvent& rMEvt )
49 : : {
50 [ # # ]: 0 : if (bFixed)
51 : 0 : Window::MouseMove( rMEvt );
52 : : else
53 : 0 : Splitter::MouseMove( rMEvt );
54 : 0 : }
55 : :
56 : 0 : void ScTabSplitter::MouseButtonUp( const MouseEvent& rMEvt )
57 : : {
58 [ # # ]: 0 : if (bFixed)
59 : 0 : Window::MouseButtonUp( rMEvt );
60 : : else
61 : 0 : Splitter::MouseButtonUp( rMEvt );
62 : 0 : }
63 : :
64 : 0 : void ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
65 : : {
66 [ # # ]: 0 : if (bFixed)
67 : 0 : Window::MouseButtonDown( rMEvt );
68 : : else
69 : 0 : Splitter::MouseButtonDown( rMEvt );
70 : 0 : }
71 : :
72 : 0 : void ScTabSplitter::Splitting( Point& rSplitPos )
73 : : {
74 [ # # ]: 0 : Window* pParent = GetParent();
75 [ # # ]: 0 : Point aScreenPos = pParent->OutputToNormalizedScreenPixel( rSplitPos );
76 [ # # ]: 0 : pViewData->GetView()->SnapSplitPos( aScreenPos );
77 [ # # ]: 0 : Point aNew = pParent->NormalizedScreenToOutputPixel( aScreenPos );
78 [ # # ]: 0 : if ( IsHorizontal() )
79 : 0 : rSplitPos.X() = aNew.X();
80 : : else
81 : 0 : rSplitPos.Y() = aNew.Y();
82 : 0 : }
83 : :
84 : :
85 : 1064 : void ScTabSplitter::SetFixed(bool bSet)
86 : : {
87 : 1064 : bFixed = bSet;
88 [ - + ]: 1064 : if (bSet)
89 [ # # ]: 0 : SetPointer(POINTER_ARROW);
90 [ + + ]: 1064 : else if (IsHorizontal())
91 [ + - ]: 532 : SetPointer(POINTER_HSPLIT);
92 : : else
93 [ + - ]: 532 : SetPointer(POINTER_VSPLIT);
94 : 1064 : }
95 : :
96 : 422 : void ScTabSplitter::Paint( const Rectangle& rRect )
97 : : {
98 : 422 : const Color oldFillCol = GetFillColor();
99 : 422 : const Color oldLineCol = GetLineColor();
100 : :
101 [ + + ]: 422 : if (IsHorizontal())
102 : : {
103 [ + - - - ]: 211 : switch (pViewData->GetHSplitMode())
104 : : {
105 : : case SC_SPLIT_NONE:
106 : : {
107 : : // Draw 3D border
108 [ + - ]: 211 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
109 [ + - ][ + - ]: 211 : DrawLine(rRect.TopRight(), rRect.BottomRight());
[ + - ]
110 [ + - ][ + - ]: 211 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
[ + - ]
111 [ + - ]: 211 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
112 [ + - ][ + - ]: 211 : DrawLine(rRect.TopLeft(), rRect.TopRight());
113 [ + - ][ + - ]: 211 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
114 : : // Fill internal rectangle
115 [ + - ]: 211 : SetLineColor();
116 [ + - ]: 211 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
117 [ + - ][ + - ]: 211 : DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
118 : : // Draw handle
119 [ + - ]: 211 : SetLineColor(Color(COL_BLACK));
120 [ + - ]: 211 : SetFillColor(Color(COL_BLACK));
121 : 211 : const long xc = rRect.Right()+rRect.Left();
122 [ + - ]: 211 : const long h4 = rRect.GetHeight()/4;
123 : : // First xc fraction is truncated, second one is rounded. This will draw a centered line
124 : : // in handlers with odd width and a centered rectangle in those with even width.
125 [ + - ][ + - ]: 211 : DrawRect(Rectangle(Point(xc/2, rRect.Top()+h4), Point((xc+1)/2, rRect.Bottom()-h4)));
126 : 211 : break;
127 : : }
128 : : case SC_SPLIT_NORMAL:
129 [ # # ]: 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
130 [ # # ][ # # ]: 0 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
131 [ # # ]: 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
132 [ # # ][ # # ]: 0 : DrawLine(rRect.TopRight(), rRect.BottomRight());
[ # # ]
133 [ # # ]: 0 : SetLineColor();
134 [ # # ]: 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
135 [ # # ][ # # ]: 0 : DrawRect(Rectangle(Point(rRect.Left()+1, rRect.Top()), Point(rRect.Right()-1, rRect.Bottom())));
136 : 0 : break;
137 : : case SC_SPLIT_FIX:
138 : : // Nothing to draw
139 : 211 : break;
140 : : }
141 : : }
142 : : else
143 : : {
144 [ + - - - ]: 211 : switch (pViewData->GetVSplitMode())
145 : : {
146 : : case SC_SPLIT_NONE:
147 : : {
148 : : // Draw 3D border
149 [ + - ]: 211 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
150 [ + - ][ + - ]: 211 : DrawLine(rRect.TopRight(), rRect.BottomRight());
[ + - ]
151 [ + - ][ + - ]: 211 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
[ + - ]
152 [ + - ]: 211 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
153 [ + - ][ + - ]: 211 : DrawLine(rRect.TopLeft(), rRect.TopRight());
154 [ + - ][ + - ]: 211 : DrawLine(rRect.TopLeft(), rRect.BottomLeft());
155 : : // Fill internal rectangle
156 [ + - ]: 211 : SetLineColor();
157 [ + - ]: 211 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
158 [ + - ][ + - ]: 211 : DrawRect(Rectangle(rRect.Left()+1, rRect.Top()+1, rRect.Right()-1, rRect.Bottom()-1));
159 : : // Draw handle
160 [ + - ]: 211 : SetLineColor(Color(COL_BLACK));
161 [ + - ]: 211 : SetFillColor(Color(COL_BLACK));
162 : 211 : const long yc = rRect.Top()+rRect.Bottom();
163 [ + - ]: 211 : const long w4 = rRect.GetWidth()/4;
164 : : // First yc fraction is truncated, second one is rounded. This will draw a centered line
165 : : // in handlers with odd height and a centered rectangle in those with even height.
166 [ + - ][ + - ]: 211 : DrawRect(Rectangle(Point(rRect.Left()+w4, yc/2), Point(rRect.Right()-w4, (yc+1)/2)));
167 : 211 : break;
168 : : }
169 : : case SC_SPLIT_NORMAL:
170 [ # # ]: 0 : SetLineColor(GetSettings().GetStyleSettings().GetLightColor());
171 [ # # ][ # # ]: 0 : DrawLine(rRect.TopLeft(), rRect.TopRight());
172 [ # # ]: 0 : SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
173 [ # # ][ # # ]: 0 : DrawLine(rRect.BottomLeft(), rRect.BottomRight());
[ # # ]
174 [ # # ]: 0 : SetLineColor();
175 [ # # ]: 0 : SetFillColor(GetSettings().GetStyleSettings().GetFaceColor());
176 [ # # ][ # # ]: 0 : DrawRect(Rectangle(Point(rRect.Left(), rRect.Top()+1), Point(rRect.Right(), rRect.Bottom()-1)));
177 : 0 : break;
178 : : case SC_SPLIT_FIX:
179 : : // Nothing to draw
180 : 0 : break;
181 : : }
182 : : }
183 : :
184 [ + - ]: 422 : SetFillColor(oldFillCol);
185 [ + - ]: 422 : SetLineColor(oldLineCol);
186 : 422 : }
187 : :
188 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|