Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/rc.h>
31 : :
32 : : #include <vcl/svapp.hxx>
33 : : #include <vcl/event.hxx>
34 : : #include <vcl/tabpage.hxx>
35 : : #include <vcl/tabctrl.hxx>
36 : : #include <vcl/bitmapex.hxx>
37 : :
38 : : #include <svdata.hxx>
39 : :
40 : : #include <com/sun/star/accessibility/XAccessible.hpp>
41 : :
42 : : // =======================================================================
43 : :
44 : 26 : void TabPage::ImplInit( Window* pParent, WinBits nStyle )
45 : : {
46 [ + - ]: 26 : if ( !(nStyle & WB_NODIALOGCONTROL) )
47 : 26 : nStyle |= WB_DIALOGCONTROL;
48 : :
49 : 26 : Window::ImplInit( pParent, nStyle, NULL );
50 : :
51 : 26 : ImplInitSettings();
52 : :
53 : : // if the tabpage is drawn (ie filled) by a native widget, make sure all contols will have transparent background
54 : : // otherwise they will paint with a wrong background
55 [ # # ][ # # ]: 26 : if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
[ - + ][ - + ]
56 : 0 : EnableChildTransparentMode( sal_True );
57 : 26 : }
58 : :
59 : : // -----------------------------------------------------------------------
60 : :
61 : 26 : void TabPage::ImplInitSettings()
62 : : {
63 : 26 : Window* pParent = GetParent();
64 [ # # ][ - + ]: 26 : if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
[ - + ]
65 : : {
66 : 0 : EnableChildTransparentMode( sal_True );
67 : 0 : SetParentClipMode( PARENTCLIPMODE_NOCLIP );
68 : 0 : SetPaintTransparent( sal_True );
69 : 0 : SetBackground();
70 : : }
71 : : else
72 : : {
73 : 26 : EnableChildTransparentMode( sal_False );
74 : 26 : SetParentClipMode( 0 );
75 : 26 : SetPaintTransparent( sal_False );
76 : :
77 [ - + ]: 26 : if ( IsControlBackground() )
78 [ # # ][ # # ]: 0 : SetBackground( GetControlBackground() );
[ # # ]
79 : : else
80 : 26 : SetBackground( pParent->GetBackground() );
81 : : }
82 : 26 : }
83 : :
84 : : // -----------------------------------------------------------------------
85 : :
86 : 26 : TabPage::TabPage( Window* pParent, WinBits nStyle ) :
87 : 26 : Window( WINDOW_TABPAGE )
88 : : {
89 [ + - ]: 26 : ImplInit( pParent, nStyle );
90 : 26 : }
91 : :
92 : : // -----------------------------------------------------------------------
93 : :
94 : 0 : TabPage::TabPage( Window* pParent, const ResId& rResId ) :
95 : 0 : Window( WINDOW_TABPAGE )
96 : : {
97 : 0 : rResId.SetRT( RSC_TABPAGE );
98 [ # # ]: 0 : WinBits nStyle = ImplInitRes( rResId );
99 [ # # ]: 0 : ImplInit( pParent, nStyle );
100 [ # # ]: 0 : ImplLoadRes( rResId );
101 : :
102 [ # # ]: 0 : if ( !(nStyle & WB_HIDE) )
103 [ # # ]: 0 : Show();
104 : 0 : }
105 : :
106 : : // -----------------------------------------------------------------------
107 : :
108 : 60 : void TabPage::StateChanged( StateChangedType nType )
109 : : {
110 : 60 : Window::StateChanged( nType );
111 : :
112 [ - + ]: 60 : if ( nType == STATE_CHANGE_INITSHOW )
113 : : {
114 [ # # ]: 0 : if ( GetSettings().GetStyleSettings().GetAutoMnemonic() )
115 : 0 : ImplWindowAutoMnemonic( this );
116 : : // FIXME: no layouting, workaround some clipping issues
117 : 0 : ImplAdjustNWFSizes();
118 : : }
119 [ - + ]: 60 : else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
120 : : {
121 : 0 : ImplInitSettings();
122 : 0 : Invalidate();
123 : : }
124 : 60 : }
125 : :
126 : : // -----------------------------------------------------------------------
127 : :
128 : 0 : void TabPage::DataChanged( const DataChangedEvent& rDCEvt )
129 : : {
130 : 0 : Window::DataChanged( rDCEvt );
131 : :
132 [ # # ]: 0 : if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
[ # # # # ]
133 : 0 : (rDCEvt.GetFlags() & SETTINGS_STYLE) )
134 : : {
135 : 0 : ImplInitSettings();
136 : 0 : Invalidate();
137 : : }
138 : 0 : }
139 : :
140 : : // -----------------------------------------------------------------------
141 : :
142 : 0 : void TabPage::Paint( const Rectangle& )
143 : : {
144 : : // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design)
145 [ # # ][ # # ]: 0 : if( IsNativeControlSupported(CTRL_TAB_BODY, PART_ENTIRE_CONTROL) && GetParent() && (GetParent()->GetType() == WINDOW_TABCONTROL) )
[ # # ][ # # ]
146 : : {
147 : 0 : const ImplControlValue aControlValue;
148 : :
149 : 0 : ControlState nState = CTRL_STATE_ENABLED;
150 : 0 : int part = PART_ENTIRE_CONTROL;
151 [ # # ][ # # ]: 0 : if ( !IsEnabled() )
152 : 0 : nState &= ~CTRL_STATE_ENABLED;
153 [ # # ][ # # ]: 0 : if ( HasFocus() )
154 : 0 : nState |= CTRL_STATE_FOCUSED;
155 : 0 : Point aPoint;
156 : : // pass the whole window region to NWF as the tab body might be a gradient or bitmap
157 : : // that has to be scaled properly, clipping makes sure that we do not paint too much
158 [ # # ]: 0 : Rectangle aCtrlRegion( aPoint, GetOutputSizePixel() );
159 : : DrawNativeControl( CTRL_TAB_BODY, part, aCtrlRegion, nState,
160 [ # # ][ # # ]: 0 : aControlValue, rtl::OUString() );
161 : : }
162 : 0 : }
163 : :
164 : : // -----------------------------------------------------------------------
165 : 0 : void TabPage::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong )
166 : : {
167 [ # # ]: 0 : Point aPos = pDev->LogicToPixel( rPos );
168 [ # # ]: 0 : Size aSize = pDev->LogicToPixel( rSize );
169 : :
170 [ # # ]: 0 : Wallpaper aWallpaper = GetBackground();
171 [ # # ][ # # ]: 0 : if ( !aWallpaper.IsBitmap() )
172 [ # # ]: 0 : ImplInitSettings();
173 : :
174 [ # # ]: 0 : pDev->Push();
175 [ # # ]: 0 : pDev->SetMapMode();
176 [ # # ]: 0 : pDev->SetLineColor();
177 : :
178 [ # # ][ # # ]: 0 : if ( aWallpaper.IsBitmap() )
179 [ # # ][ # # ]: 0 : pDev->DrawBitmapEx( aPos, aSize, aWallpaper.GetBitmap() );
[ # # ]
180 : : else
181 : : {
182 [ # # ][ # # ]: 0 : if( aWallpaper.GetColor() == COL_AUTO )
183 [ # # ]: 0 : pDev->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
184 : : else
185 [ # # ][ # # ]: 0 : pDev->SetFillColor( aWallpaper.GetColor() );
186 [ # # ][ # # ]: 0 : pDev->DrawRect( Rectangle( aPos, aSize ) );
187 : : }
188 : :
189 [ # # ][ # # ]: 0 : pDev->Pop();
190 : 0 : }
191 : :
192 : : // -----------------------------------------------------------------------
193 : :
194 : 26 : void TabPage::ActivatePage()
195 : : {
196 : 26 : }
197 : :
198 : : // -----------------------------------------------------------------------
199 : :
200 : 0 : void TabPage::DeactivatePage()
201 : : {
202 : 0 : }
203 : :
204 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|