1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26
27 #ifndef _SV_RC_H
28 #include <tools/rc.h>
29 #endif
30 #include <vcl/event.hxx>
31 #include <vcl/fixbrd.hxx>
32
33
34
35 // =======================================================================
36
ImplInit(Window * pParent,WinBits nStyle)37 void FixedBorder::ImplInit( Window* pParent, WinBits nStyle )
38 {
39 mnType = FIXEDBORDER_TYPE_DOUBLEOUT;
40 mbTransparent = sal_True;
41
42 nStyle = ImplInitStyle( nStyle );
43 Control::ImplInit( pParent, nStyle, NULL );
44 ImplInitSettings();
45 }
46
47 // -----------------------------------------------------------------------
48
ImplInitStyle(WinBits nStyle)49 WinBits FixedBorder::ImplInitStyle( WinBits nStyle )
50 {
51 if ( !(nStyle & WB_NOGROUP) )
52 nStyle |= WB_GROUP;
53 return nStyle;
54 }
55
56 // -----------------------------------------------------------------------
57
ImplInitSettings()58 void FixedBorder::ImplInitSettings()
59 {
60 Window* pParent = GetParent();
61 if ( (pParent->IsChildTransparentModeEnabled() ||
62 !(pParent->GetStyle() & WB_CLIPCHILDREN) ) &&
63 !IsControlBackground() && mbTransparent )
64 {
65 SetMouseTransparent( sal_True );
66 EnableChildTransparentMode( sal_True );
67 SetParentClipMode( PARENTCLIPMODE_NOCLIP );
68 SetPaintTransparent( sal_True );
69 SetBackground();
70 }
71 else
72 {
73 SetMouseTransparent( sal_False );
74 EnableChildTransparentMode( sal_False );
75 SetParentClipMode( 0 );
76 SetPaintTransparent( sal_False );
77
78 if ( IsControlBackground() )
79 SetBackground( GetControlBackground() );
80 else
81 SetBackground( pParent->GetBackground() );
82 }
83 }
84
85 // -----------------------------------------------------------------------
86
FixedBorder(Window * pParent,WinBits nStyle)87 FixedBorder::FixedBorder( Window* pParent, WinBits nStyle ) :
88 Control( WINDOW_FIXEDBORDER )
89 {
90 ImplInit( pParent, nStyle );
91 }
92
93 // -----------------------------------------------------------------------
94
FixedBorder(Window * pParent,const ResId & rResId)95 FixedBorder::FixedBorder( Window* pParent, const ResId& rResId ) :
96 Control( WINDOW_FIXEDBORDER )
97 {
98 rResId.SetRT( RSC_CONTROL );
99 WinBits nStyle = ImplInitRes( rResId );
100 ImplInit( pParent, nStyle );
101 ImplLoadRes( rResId );
102
103 if ( !(nStyle & WB_HIDE) )
104 Show();
105 }
106
107 // -----------------------------------------------------------------------
108
~FixedBorder()109 FixedBorder::~FixedBorder()
110 {
111 }
112
113 // -----------------------------------------------------------------------
114
ImplDraw(OutputDevice * pDev,sal_uLong nDrawFlags,const Point & rPos,const Size & rSize)115 void FixedBorder::ImplDraw( OutputDevice* pDev, sal_uLong nDrawFlags,
116 const Point& rPos, const Size& rSize )
117 {
118 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
119 Rectangle aRect( rPos, rSize );
120 sal_uInt16 nBorderStyle = mnType;
121
122 if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
123 (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
124 nBorderStyle |= FRAME_DRAW_MONO;
125
126 /*
127 // seems only to be used in tools->options around a tabpage (ie, no tabcontrol!)
128 // as tabpages that are not embedded in a tabcontrol should not be drawn natively
129 // the fixedborder must also not be drawn (reason was, that it looks too ugly, dialogs must be redesigned)
130 Window *pWin = pDev->GetOutDevType() == OUTDEV_WINDOW ? (Window*) pDev : NULL;
131 if( !(nBorderStyle & FRAME_DRAW_MONO) && pWin && pWin->IsNativeControlSupported( CTRL_FIXEDBORDER, PART_ENTIRE_CONTROL ) )
132 {
133 ImplControlValue aControlValue;
134 Point aPt;
135 Region aCtrlRegion( Rectangle( aPt, GetOutputSizePixel() ) );
136 ControlState nState = IsEnabled() ? CTRL_STATE_ENABLED : 0;
137 pWin->DrawNativeControl( CTRL_FIXEDBORDER, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
138 aControlValue, rtl::OUString() );
139 }
140 else
141 */
142 {
143 DecorationView aDecoView( pDev );
144 aDecoView.DrawFrame( aRect, nBorderStyle );
145 }
146 }
147
148 // -----------------------------------------------------------------------
149
Paint(const Rectangle &)150 void FixedBorder::Paint( const Rectangle& )
151 {
152 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
153 }
154
155 // -----------------------------------------------------------------------
156
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)157 void FixedBorder::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
158 sal_uLong nFlags )
159 {
160 Point aPos = pDev->LogicToPixel( rPos );
161 Size aSize = pDev->LogicToPixel( rSize );
162
163 pDev->Push();
164 pDev->SetMapMode();
165 ImplDraw( pDev, nFlags, aPos, aSize );
166 pDev->Pop();
167 }
168
169 // -----------------------------------------------------------------------
170
Resize()171 void FixedBorder::Resize()
172 {
173 Invalidate();
174 }
175
176 // -----------------------------------------------------------------------
177
StateChanged(StateChangedType nType)178 void FixedBorder::StateChanged( StateChangedType nType )
179 {
180 Control::StateChanged( nType );
181
182 if ( (nType == STATE_CHANGE_DATA) ||
183 (nType == STATE_CHANGE_UPDATEMODE) )
184 {
185 if ( IsUpdateMode() )
186 Invalidate();
187 }
188 else if ( nType == STATE_CHANGE_STYLE )
189 SetStyle( ImplInitStyle( GetStyle() ) );
190 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
191 {
192 ImplInitSettings();
193 Invalidate();
194 }
195 }
196
197 // -----------------------------------------------------------------------
198
DataChanged(const DataChangedEvent & rDCEvt)199 void FixedBorder::DataChanged( const DataChangedEvent& rDCEvt )
200 {
201 Control::DataChanged( rDCEvt );
202
203 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
204 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
205 {
206 ImplInitSettings();
207 Invalidate();
208 }
209 }
210
211 // -----------------------------------------------------------------------
212
SetTransparent(sal_Bool bTransparent)213 void FixedBorder::SetTransparent( sal_Bool bTransparent )
214 {
215 if ( mbTransparent != bTransparent )
216 {
217 mbTransparent = bTransparent;
218 ImplInitSettings();
219 Invalidate();
220 }
221 }
222
223 // -----------------------------------------------------------------------
224
SetBorderType(sal_uInt16 nType)225 void FixedBorder::SetBorderType( sal_uInt16 nType )
226 {
227 if ( mnType != nType )
228 {
229 mnType = nType;
230 Invalidate();
231 }
232 }
233