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