1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabpage.cxx,v $
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 #include <tools/ref.hxx>
39 #include <vcl/svdata.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/event.hxx>
42 #include <vcl/tabpage.hxx>
43 #include <vcl/tabctrl.hxx>
44 #include <vcl/bitmapex.hxx>
45 #include <com/sun/star/accessibility/XAccessible.hpp>
50 // =======================================================================
52 void TabPage::ImplInit( Window
* pParent
, WinBits nStyle
)
54 if ( !(nStyle
& WB_NODIALOGCONTROL
) )
55 nStyle
|= WB_DIALOGCONTROL
;
57 Window::ImplInit( pParent
, nStyle
, NULL
);
61 // if the tabpage is drawn (ie filled) by a native widget, make sure all contols will have transparent background
62 // otherwise they will paint with a wrong background
63 if( IsNativeControlSupported(CTRL_TAB_BODY
, PART_ENTIRE_CONTROL
) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL
) )
64 EnableChildTransparentMode( TRUE
);
67 // -----------------------------------------------------------------------
69 void TabPage::ImplInitSettings()
71 Window
* pParent
= GetParent();
72 if ( pParent
->IsChildTransparentModeEnabled() && !IsControlBackground() )
74 EnableChildTransparentMode( TRUE
);
75 SetParentClipMode( PARENTCLIPMODE_NOCLIP
);
76 SetPaintTransparent( TRUE
);
81 EnableChildTransparentMode( FALSE
);
82 SetParentClipMode( 0 );
83 SetPaintTransparent( FALSE
);
85 if ( IsControlBackground() )
86 SetBackground( GetControlBackground() );
88 SetBackground( pParent
->GetBackground() );
92 // -----------------------------------------------------------------------
94 TabPage::TabPage( Window
* pParent
, WinBits nStyle
) :
95 Window( WINDOW_TABPAGE
)
97 ImplInit( pParent
, nStyle
);
100 // -----------------------------------------------------------------------
102 TabPage::TabPage( Window
* pParent
, const ResId
& rResId
) :
103 Window( WINDOW_TABPAGE
)
105 rResId
.SetRT( RSC_TABPAGE
);
106 WinBits nStyle
= ImplInitRes( rResId
);
107 ImplInit( pParent
, nStyle
);
108 ImplLoadRes( rResId
);
110 if ( !(nStyle
& WB_HIDE
) )
114 // -----------------------------------------------------------------------
116 void TabPage::StateChanged( StateChangedType nType
)
118 Window::StateChanged( nType
);
120 if ( nType
== STATE_CHANGE_INITSHOW
)
122 if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
123 ImplWindowAutoMnemonic( this );
124 // FIXME: no layouting, workaround some clipping issues
125 ImplAdjustNWFSizes();
127 else if ( nType
== STATE_CHANGE_CONTROLBACKGROUND
)
134 // -----------------------------------------------------------------------
136 void TabPage::DataChanged( const DataChangedEvent
& rDCEvt
)
138 Window::DataChanged( rDCEvt
);
140 if ( (rDCEvt
.GetType() == DATACHANGED_SETTINGS
) &&
141 (rDCEvt
.GetFlags() & SETTINGS_STYLE
) )
148 // -----------------------------------------------------------------------
150 void TabPage::Paint( const Rectangle
& )
152 // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design)
153 if( IsNativeControlSupported(CTRL_TAB_BODY
, PART_ENTIRE_CONTROL
) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL
) )
155 const ImplControlValue
aControlValue( BUTTONVALUE_DONTKNOW
, rtl::OUString(), 0 );
157 ControlState nState
= CTRL_STATE_ENABLED
;
158 int part
= PART_ENTIRE_CONTROL
;
160 nState
&= ~CTRL_STATE_ENABLED
;
162 nState
|= CTRL_STATE_FOCUSED
;
164 // pass the whole window region to NWF as the tab body might be a gradient or bitmap
165 // that has to be scaled properly, clipping makes sure that we do not paint too much
166 Region
aCtrlRegion( Rectangle( aPoint
, GetOutputSizePixel() ) );
167 DrawNativeControl( CTRL_TAB_BODY
, part
, aCtrlRegion
, nState
,
168 aControlValue
, rtl::OUString() );
172 // -----------------------------------------------------------------------
173 void TabPage::Draw( OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, ULONG
)
175 Point aPos
= pDev
->LogicToPixel( rPos
);
176 Size aSize
= pDev
->LogicToPixel( rSize
);
178 Wallpaper aWallpaper
= GetBackground();
179 if ( !aWallpaper
.IsBitmap() )
184 pDev
->SetLineColor();
186 if ( aWallpaper
.IsBitmap() )
187 pDev
->DrawBitmapEx( aPos
, aSize
, aWallpaper
.GetBitmap() );
190 if( aWallpaper
.GetColor() == COL_AUTO
)
191 pDev
->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
193 pDev
->SetFillColor( aWallpaper
.GetColor() );
194 pDev
->DrawRect( Rectangle( aPos
, aSize
) );
200 // -----------------------------------------------------------------------
202 void TabPage::ActivatePage()
206 // -----------------------------------------------------------------------
208 void TabPage::DeactivatePage()
212 // -----------------------------------------------------------------------
214 ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> TabPage::CreateAccessible()
216 // TODO: remove this method (incompatible)
218 return Window::CreateAccessible();