update dev300-m58
[ooovba.git] / vcl / source / control / fixbrd.cxx
blobfbbc9d2ff4e14895a0493c80fc45cbd1bfaf2d72
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fixbrd.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #ifndef _SV_RC_H
35 #include <tools/rc.h>
36 #endif
37 #include <vcl/event.hxx>
38 #include <vcl/fixbrd.hxx>
42 // =======================================================================
44 void FixedBorder::ImplInit( Window* pParent, WinBits nStyle )
46 mnType = FIXEDBORDER_TYPE_DOUBLEOUT;
47 mbTransparent = TRUE;
49 nStyle = ImplInitStyle( nStyle );
50 Control::ImplInit( pParent, nStyle, NULL );
51 ImplInitSettings();
54 // -----------------------------------------------------------------------
56 WinBits FixedBorder::ImplInitStyle( WinBits nStyle )
58 if ( !(nStyle & WB_NOGROUP) )
59 nStyle |= WB_GROUP;
60 return nStyle;
63 // -----------------------------------------------------------------------
65 void FixedBorder::ImplInitSettings()
67 Window* pParent = GetParent();
68 if ( (pParent->IsChildTransparentModeEnabled() ||
69 !(pParent->GetStyle() & WB_CLIPCHILDREN) ) &&
70 !IsControlBackground() && mbTransparent )
72 SetMouseTransparent( TRUE );
73 EnableChildTransparentMode( TRUE );
74 SetParentClipMode( PARENTCLIPMODE_NOCLIP );
75 SetPaintTransparent( TRUE );
76 SetBackground();
78 else
80 SetMouseTransparent( FALSE );
81 EnableChildTransparentMode( FALSE );
82 SetParentClipMode( 0 );
83 SetPaintTransparent( FALSE );
85 if ( IsControlBackground() )
86 SetBackground( GetControlBackground() );
87 else
88 SetBackground( pParent->GetBackground() );
92 // -----------------------------------------------------------------------
94 FixedBorder::FixedBorder( Window* pParent, WinBits nStyle ) :
95 Control( WINDOW_FIXEDBORDER )
97 ImplInit( pParent, nStyle );
100 // -----------------------------------------------------------------------
102 FixedBorder::FixedBorder( Window* pParent, const ResId& rResId ) :
103 Control( WINDOW_FIXEDBORDER )
105 rResId.SetRT( RSC_CONTROL );
106 WinBits nStyle = ImplInitRes( rResId );
107 ImplInit( pParent, nStyle );
108 ImplLoadRes( rResId );
110 if ( !(nStyle & WB_HIDE) )
111 Show();
114 // -----------------------------------------------------------------------
116 FixedBorder::~FixedBorder()
120 // -----------------------------------------------------------------------
122 void FixedBorder::ImplDraw( OutputDevice* pDev, ULONG nDrawFlags,
123 const Point& rPos, const Size& rSize )
125 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
126 Rectangle aRect( rPos, rSize );
127 USHORT nBorderStyle = mnType;
129 if ( (nDrawFlags & WINDOW_DRAW_MONO) ||
130 (rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
131 nBorderStyle |= FRAME_DRAW_MONO;
134 // seems only to be used in tools->options around a tabpage (ie, no tabcontrol!)
135 // as tabpages that are not embedded in a tabcontrol should not be drawn natively
136 // the fixedborder must also not be drawn (reason was, that it looks too ugly, dialogs must be redesigned)
137 Window *pWin = pDev->GetOutDevType() == OUTDEV_WINDOW ? (Window*) pDev : NULL;
138 if( !(nBorderStyle & FRAME_DRAW_MONO) && pWin && pWin->IsNativeControlSupported( CTRL_FIXEDBORDER, PART_ENTIRE_CONTROL ) )
140 ImplControlValue aControlValue;
141 Point aPt;
142 Region aCtrlRegion( Rectangle( aPt, GetOutputSizePixel() ) );
143 ControlState nState = IsEnabled() ? CTRL_STATE_ENABLED : 0;
144 pWin->DrawNativeControl( CTRL_FIXEDBORDER, PART_ENTIRE_CONTROL, aCtrlRegion, nState,
145 aControlValue, rtl::OUString() );
147 else
150 DecorationView aDecoView( pDev );
151 aDecoView.DrawFrame( aRect, nBorderStyle );
155 // -----------------------------------------------------------------------
157 void FixedBorder::Paint( const Rectangle& )
159 ImplDraw( this, 0, Point(), GetOutputSizePixel() );
162 // -----------------------------------------------------------------------
164 void FixedBorder::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
165 ULONG nFlags )
167 Point aPos = pDev->LogicToPixel( rPos );
168 Size aSize = pDev->LogicToPixel( rSize );
170 pDev->Push();
171 pDev->SetMapMode();
172 ImplDraw( pDev, nFlags, aPos, aSize );
173 pDev->Pop();
176 // -----------------------------------------------------------------------
178 void FixedBorder::Resize()
180 Invalidate();
183 // -----------------------------------------------------------------------
185 void FixedBorder::StateChanged( StateChangedType nType )
187 Control::StateChanged( nType );
189 if ( (nType == STATE_CHANGE_DATA) ||
190 (nType == STATE_CHANGE_UPDATEMODE) )
192 if ( IsUpdateMode() )
193 Invalidate();
195 else if ( nType == STATE_CHANGE_STYLE )
196 SetStyle( ImplInitStyle( GetStyle() ) );
197 else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
199 ImplInitSettings();
200 Invalidate();
204 // -----------------------------------------------------------------------
206 void FixedBorder::DataChanged( const DataChangedEvent& rDCEvt )
208 Control::DataChanged( rDCEvt );
210 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
211 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
213 ImplInitSettings();
214 Invalidate();
218 // -----------------------------------------------------------------------
220 void FixedBorder::SetTransparent( BOOL bTransparent )
222 if ( mbTransparent != bTransparent )
224 mbTransparent = bTransparent;
225 ImplInitSettings();
226 Invalidate();
230 // -----------------------------------------------------------------------
232 void FixedBorder::SetBorderType( USHORT nType )
234 if ( mnType != nType )
236 mnType = nType;
237 Invalidate();