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