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