1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*9f62ea84SAndrew Rist * distributed with this work for additional information
6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at
10*9f62ea84SAndrew Rist *
11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist *
13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the
17*9f62ea84SAndrew Rist * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist * under the License.
19*9f62ea84SAndrew Rist *
20*9f62ea84SAndrew Rist *************************************************************/
21*9f62ea84SAndrew Rist
22*9f62ea84SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/ref.hxx>
28cdf0e10cSrcweir #include <tools/rc.h>
29cdf0e10cSrcweir
30cdf0e10cSrcweir #include <vcl/svapp.hxx>
31cdf0e10cSrcweir #include <vcl/event.hxx>
32cdf0e10cSrcweir #include <vcl/tabpage.hxx>
33cdf0e10cSrcweir #include <vcl/tabctrl.hxx>
34cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <svdata.hxx>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp>
39cdf0e10cSrcweir
40cdf0e10cSrcweir // =======================================================================
41cdf0e10cSrcweir
ImplInit(Window * pParent,WinBits nStyle)42cdf0e10cSrcweir void TabPage::ImplInit( Window* pParent, WinBits nStyle )
43cdf0e10cSrcweir {
44cdf0e10cSrcweir if ( !(nStyle & WB_NODIALOGCONTROL) )
45cdf0e10cSrcweir nStyle |= WB_DIALOGCONTROL;
46cdf0e10cSrcweir
47cdf0e10cSrcweir Window::ImplInit( pParent, nStyle, NULL );
48cdf0e10cSrcweir
49cdf0e10cSrcweir ImplInitSettings();
50cdf0e10cSrcweir
51cdf0e10cSrcweir // if the tabpage is drawn (ie filled) by a native widget, make sure all contols will have transparent background
52cdf0e10cSrcweir // otherwise they will paint with a wrong background
53cdf0e10cSrcweir if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
54cdf0e10cSrcweir EnableChildTransparentMode( sal_True );
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir // -----------------------------------------------------------------------
58cdf0e10cSrcweir
ImplInitSettings()59cdf0e10cSrcweir void TabPage::ImplInitSettings()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir Window* pParent = GetParent();
62cdf0e10cSrcweir if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
63cdf0e10cSrcweir {
64cdf0e10cSrcweir EnableChildTransparentMode( sal_True );
65cdf0e10cSrcweir SetParentClipMode( PARENTCLIPMODE_NOCLIP );
66cdf0e10cSrcweir SetPaintTransparent( sal_True );
67cdf0e10cSrcweir SetBackground();
68cdf0e10cSrcweir }
69cdf0e10cSrcweir else
70cdf0e10cSrcweir {
71cdf0e10cSrcweir EnableChildTransparentMode( sal_False );
72cdf0e10cSrcweir SetParentClipMode( 0 );
73cdf0e10cSrcweir SetPaintTransparent( sal_False );
74cdf0e10cSrcweir
75cdf0e10cSrcweir if ( IsControlBackground() )
76cdf0e10cSrcweir SetBackground( GetControlBackground() );
77cdf0e10cSrcweir else
78cdf0e10cSrcweir SetBackground( pParent->GetBackground() );
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir // -----------------------------------------------------------------------
83cdf0e10cSrcweir
TabPage(Window * pParent,WinBits nStyle)84cdf0e10cSrcweir TabPage::TabPage( Window* pParent, WinBits nStyle ) :
85cdf0e10cSrcweir Window( WINDOW_TABPAGE )
86cdf0e10cSrcweir {
87cdf0e10cSrcweir ImplInit( pParent, nStyle );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir
90cdf0e10cSrcweir // -----------------------------------------------------------------------
91cdf0e10cSrcweir
TabPage(Window * pParent,const ResId & rResId)92cdf0e10cSrcweir TabPage::TabPage( Window* pParent, const ResId& rResId ) :
93cdf0e10cSrcweir Window( WINDOW_TABPAGE )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir rResId.SetRT( RSC_TABPAGE );
96cdf0e10cSrcweir WinBits nStyle = ImplInitRes( rResId );
97cdf0e10cSrcweir ImplInit( pParent, nStyle );
98cdf0e10cSrcweir ImplLoadRes( rResId );
99cdf0e10cSrcweir
100cdf0e10cSrcweir if ( !(nStyle & WB_HIDE) )
101cdf0e10cSrcweir Show();
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir // -----------------------------------------------------------------------
105cdf0e10cSrcweir
StateChanged(StateChangedType nType)106cdf0e10cSrcweir void TabPage::StateChanged( StateChangedType nType )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir Window::StateChanged( nType );
109cdf0e10cSrcweir
110cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
113cdf0e10cSrcweir ImplWindowAutoMnemonic( this );
114cdf0e10cSrcweir // FIXME: no layouting, workaround some clipping issues
115cdf0e10cSrcweir ImplAdjustNWFSizes();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir ImplInitSettings();
120cdf0e10cSrcweir Invalidate();
121cdf0e10cSrcweir }
122cdf0e10cSrcweir }
123cdf0e10cSrcweir
124cdf0e10cSrcweir // -----------------------------------------------------------------------
125cdf0e10cSrcweir
DataChanged(const DataChangedEvent & rDCEvt)126cdf0e10cSrcweir void TabPage::DataChanged( const DataChangedEvent& rDCEvt )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir Window::DataChanged( rDCEvt );
129cdf0e10cSrcweir
130cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
131cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir ImplInitSettings();
134cdf0e10cSrcweir Invalidate();
135cdf0e10cSrcweir }
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir
Paint(const Rectangle &)140cdf0e10cSrcweir void TabPage::Paint( const Rectangle& )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design)
143cdf0e10cSrcweir if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir const ImplControlValue aControlValue;
146cdf0e10cSrcweir
147cdf0e10cSrcweir ControlState nState = CTRL_STATE_ENABLED;
148cdf0e10cSrcweir int part = PART_ENTIRE_CONTROL;
149cdf0e10cSrcweir if ( !IsEnabled() )
150cdf0e10cSrcweir nState &= ~CTRL_STATE_ENABLED;
151cdf0e10cSrcweir if ( HasFocus() )
152cdf0e10cSrcweir nState |= CTRL_STATE_FOCUSED;
153cdf0e10cSrcweir Point aPoint;
154cdf0e10cSrcweir // pass the whole window region to NWF as the tab body might be a gradient or bitmap
155cdf0e10cSrcweir // that has to be scaled properly, clipping makes sure that we do not paint too much
156cdf0e10cSrcweir Rectangle aCtrlRegion( aPoint, GetOutputSizePixel() );
157cdf0e10cSrcweir DrawNativeControl( CTRL_TAB_BODY, part, aCtrlRegion, nState,
158cdf0e10cSrcweir aControlValue, rtl::OUString() );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir
162cdf0e10cSrcweir // -----------------------------------------------------------------------
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong)163cdf0e10cSrcweir void TabPage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir Point aPos = pDev->LogicToPixel( rPos );
166cdf0e10cSrcweir Size aSize = pDev->LogicToPixel( rSize );
167cdf0e10cSrcweir
168cdf0e10cSrcweir Wallpaper aWallpaper = GetBackground();
169cdf0e10cSrcweir if ( !aWallpaper.IsBitmap() )
170cdf0e10cSrcweir ImplInitSettings();
171cdf0e10cSrcweir
172cdf0e10cSrcweir pDev->Push();
173cdf0e10cSrcweir pDev->SetMapMode();
174cdf0e10cSrcweir pDev->SetLineColor();
175cdf0e10cSrcweir
176cdf0e10cSrcweir if ( aWallpaper.IsBitmap() )
177cdf0e10cSrcweir pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
178cdf0e10cSrcweir else
179cdf0e10cSrcweir {
180cdf0e10cSrcweir if( aWallpaper.GetColor() == COL_AUTO )
181cdf0e10cSrcweir pDev->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
182cdf0e10cSrcweir else
183cdf0e10cSrcweir pDev->SetFillColor( aWallpaper.GetColor() );
184cdf0e10cSrcweir pDev->DrawRect( Rectangle( aPos, aSize ) );
185cdf0e10cSrcweir }
186cdf0e10cSrcweir
187cdf0e10cSrcweir pDev->Pop();
188cdf0e10cSrcweir }
189cdf0e10cSrcweir
190cdf0e10cSrcweir // -----------------------------------------------------------------------
191cdf0e10cSrcweir
ActivatePage()192cdf0e10cSrcweir void TabPage::ActivatePage()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir }
195cdf0e10cSrcweir
196cdf0e10cSrcweir // -----------------------------------------------------------------------
197cdf0e10cSrcweir
DeactivatePage()198cdf0e10cSrcweir void TabPage::DeactivatePage()
199cdf0e10cSrcweir {
200cdf0e10cSrcweir }
201cdf0e10cSrcweir
202cdf0e10cSrcweir // -----------------------------------------------------------------------
203cdf0e10cSrcweir
CreateAccessible()204cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > TabPage::CreateAccessible()
205cdf0e10cSrcweir {
206cdf0e10cSrcweir // TODO: remove this method (incompatible)
207cdf0e10cSrcweir
208cdf0e10cSrcweir return Window::CreateAccessible();
209cdf0e10cSrcweir }
210