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 : :
30 : : #include <vcl/outdev.hxx>
31 : : #include <vcl/window.hxx>
32 : : #include <vcl/decoview.hxx>
33 : : #include <vcl/svapp.hxx>
34 : : #include "cbutton.hxx"
35 : :
36 : : //========================================================================
37 : : // class ScDDComboBoxButton
38 : : //========================================================================
39 : :
40 : 229 : ScDDComboBoxButton::ScDDComboBoxButton( OutputDevice* pOutputDevice )
41 : 229 : : pOut( pOutputDevice )
42 : : {
43 : 229 : SetOptSizePixel();
44 : 229 : }
45 : :
46 : : // -------------------------------------------------------------------------
47 : :
48 : 225 : ScDDComboBoxButton::~ScDDComboBoxButton()
49 : : {
50 : 225 : }
51 : :
52 : : // -------------------------------------------------------------------------
53 : :
54 : 2556 : void ScDDComboBoxButton::SetOutputDevice( OutputDevice* pOutputDevice )
55 : : {
56 : 2556 : pOut = pOutputDevice;
57 : 2556 : }
58 : :
59 : : // -------------------------------------------------------------------------
60 : :
61 : 229 : void ScDDComboBoxButton::SetOptSizePixel()
62 : : {
63 [ + - ]: 229 : aBtnSize = pOut->LogicToPixel( Size(0,11), MAP_APPFONT );
64 : : //aBtnSize.Width() = GetSystemMetrics( SM_CXVSCROLL ) - 1; // Win SDK-Funktion
65 : 229 : aBtnSize.Width() = pOut->GetSettings().GetStyleSettings().GetScrollBarSize();
66 : 229 : }
67 : :
68 : : // -------------------------------------------------------------------------
69 : :
70 : 0 : void ScDDComboBoxButton::Draw( const Point& rAt,
71 : : const Size& rSize,
72 : : sal_Bool bState,
73 : : sal_Bool bBtnIn /* = sal_False */ )
74 : : {
75 [ # # ][ # # ]: 0 : if ( rSize.Width() == 0 || rSize.Height() == 0 )
[ # # ]
76 : 0 : return; // #i43092# rectangle with size 0 would have RECT_EMPTY as end position
77 : :
78 : : // save old state
79 : 0 : sal_Bool bHadFill = pOut->IsFillColor();
80 : 0 : Color aOldFill = pOut->GetFillColor();
81 : 0 : sal_Bool bHadLine = pOut->IsLineColor();
82 : 0 : Color aOldLine = pOut->GetLineColor();
83 : 0 : sal_Bool bOldEnable = pOut->IsMapModeEnabled();
84 : :
85 : 0 : Size aLogPix( 1, 1 );
86 [ # # ]: 0 : Rectangle aBtnRect( rAt, rSize );
87 : 0 : Rectangle aInnerRect = aBtnRect;
88 : :
89 [ # # ]: 0 : pOut->EnableMapMode( false );
90 : :
91 : 0 : DecorationView aDecoView( pOut);
92 : :
93 : 0 : sal_uInt16 nButtonStyle = BUTTON_DRAW_DEFAULT;
94 [ # # ]: 0 : if( bBtnIn ) // gedrueckt?
95 : : {
96 : 0 : nButtonStyle = BUTTON_DRAW_PRESSED;
97 : : }
98 : :
99 [ # # ]: 0 : aInnerRect=aDecoView.DrawButton( aBtnRect, nButtonStyle );
100 : :
101 : :
102 : 0 : aInnerRect.Left() += 1;
103 : 0 : aInnerRect.Top() += 1;
104 : 0 : aInnerRect.Right() -= 1;
105 : 0 : aInnerRect.Bottom() -= 1;
106 : :
107 [ # # ]: 0 : Size aInnerSize = aInnerRect.GetSize();
108 [ # # ]: 0 : Point aInnerCenter = aInnerRect.Center();
109 : :
110 : 0 : aInnerRect.Top() = aInnerCenter.Y() - (aInnerSize.Width()>>1);
111 : 0 : aInnerRect.Bottom()= aInnerCenter.Y() + (aInnerSize.Width()>>1);
112 : :
113 [ # # ]: 0 : ImpDrawArrow( aInnerRect, bState );
114 : :
115 : :
116 : : // restore old state
117 [ # # ]: 0 : pOut->EnableMapMode( bOldEnable );
118 [ # # ]: 0 : if (bHadLine)
119 [ # # ]: 0 : pOut->SetLineColor(aOldLine);
120 : : else
121 [ # # ]: 0 : pOut->SetLineColor();
122 [ # # ]: 0 : if (bHadFill)
123 [ # # ]: 0 : pOut->SetFillColor(aOldFill);
124 : : else
125 [ # # ]: 0 : pOut->SetFillColor();
126 : : }
127 : :
128 : : //------------------------------------------------------------------------
129 : :
130 : 0 : void ScDDComboBoxButton::ImpDrawArrow( const Rectangle& rRect,
131 : : sal_Bool bState )
132 : : {
133 : : // no need to save old line and fill color here (is restored after the call)
134 : :
135 : 0 : Rectangle aPixRect = rRect;
136 [ # # ]: 0 : Point aCenter = aPixRect.Center();
137 [ # # ]: 0 : Size aSize = aPixRect.GetSize();
138 : :
139 : 0 : Size aSize3;
140 : 0 : aSize3.Width() = aSize.Width() >> 1;
141 : 0 : aSize3.Height() = aSize.Height() >> 1;
142 : :
143 : 0 : Size aSize4;
144 : 0 : aSize4.Width() = aSize.Width() >> 2;
145 : 0 : aSize4.Height() = aSize.Height() >> 2;
146 : :
147 : 0 : Rectangle aTempRect = aPixRect;
148 : :
149 [ # # ]: 0 : const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
150 [ # # ]: 0 : Color aColor( bState ? COL_LIGHTBLUE : rSett.GetButtonTextColor().GetColor() );
151 [ # # ]: 0 : pOut->SetFillColor( aColor );
152 [ # # ]: 0 : pOut->SetLineColor( aColor );
153 : :
154 : 0 : aTempRect.Left() = aCenter.X() - aSize4.Width();
155 : 0 : aTempRect.Right() = aCenter.X() + aSize4.Width();
156 : 0 : aTempRect.Top() = aCenter.Y() - aSize3.Height();
157 : 0 : aTempRect.Bottom() = aCenter.Y() - 1;
158 : :
159 [ # # ]: 0 : pOut->DrawRect( aTempRect );
160 : :
161 : 0 : Point aPos1( aCenter.X()-aSize3.Width(), aCenter.Y() );
162 : 0 : Point aPos2( aCenter.X()+aSize3.Width(), aCenter.Y() );
163 [ # # ]: 0 : while( aPos1.X() <= aPos2.X() )
164 : : {
165 [ # # ]: 0 : pOut->DrawLine( aPos1, aPos2 );
166 : 0 : aPos1.X()++; aPos2.X()--;
167 : 0 : aPos1.Y()++; aPos2.Y()++;
168 : : }
169 : :
170 : 0 : pOut->DrawLine( Point( aCenter.X() - aSize3.Width(), aPos1.Y()+1 ),
171 [ # # ]: 0 : Point( aCenter.X() + aSize3.Width(), aPos1.Y()+1 ) );
172 : 0 : }
173 : :
174 : :
175 : :
176 : :
177 : :
178 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|