LibreOffice Module vcl (master) 1
tabpage.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <vcl/event.hxx>
21#include <vcl/layout.hxx>
22#include <vcl/tabpage.hxx>
23#include <vcl/bitmapex.hxx>
24#include <vcl/settings.hxx>
26#include <svdata.hxx>
27
28void TabPage::ImplInit( vcl::Window* pParent, WinBits nStyle )
29{
30 if ( !(nStyle & WB_NODIALOGCONTROL) )
31 nStyle |= WB_DIALOGCONTROL;
32
33 Window::ImplInit( pParent, nStyle, nullptr );
34
35 mbHasHoriBar = false;
36 mbHasVertBar = false;
37
38 Link<ScrollBar*,void> aLink( LINK( this, TabPage, ScrollBarHdl ) );
39
40 if ( nStyle & ( WB_AUTOHSCROLL | WB_AUTOVSCROLL ) )
41 {
42 if ( nStyle & WB_AUTOHSCROLL )
43 {
44 mbHasHoriBar = true;
48 }
49 if ( nStyle & WB_AUTOVSCROLL )
50 {
51 mbHasVertBar = true;
55 }
56 }
57
59 {
61 }
62
64
66
67 // if the tabpage is drawn (ie filled) by a native widget, make sure all controls will have transparent background
68 // otherwise they will paint with a wrong background
71}
72
74{
75 vcl::Window* pParent = GetParent();
76 if (pParent && pParent->IsChildTransparentModeEnabled() && !IsControlBackground())
77 {
80 SetPaintTransparent( true );
82 }
83 else
84 {
87 SetPaintTransparent( false );
88
89 if (IsControlBackground() || !pParent)
91 else
92 SetBackground( pParent->GetBackground() );
93 }
94}
95
98{
99 ImplInit( pParent, nStyle );
100}
101
103{
104 disposeOnce();
105}
106
108{
112}
113
115{
116 Window::StateChanged( nType );
117
119 {
120 if (GetSettings().GetStyleSettings().GetAutoMnemonic())
122 // FIXME: no layouting, workaround some clipping issues
124 }
126 {
128 Invalidate();
129 }
130}
131
133{
134 Window::DataChanged( rDCEvt );
135
136 if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
137 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
138 {
140 Invalidate();
141 }
142}
143
145{
146 // draw native tabpage only inside tabcontrols, standalone tabpages look ugly (due to bad dialog design)
148 return;
149
150 const ImplControlValue aControlValue;
151
153 if ( !IsEnabled() )
154 nState &= ~ControlState::ENABLED;
155 if ( HasFocus() )
157 // pass the whole window region to NWF as the tab body might be a gradient or bitmap
158 // that has to be scaled properly, clipping makes sure that we do not paint too much
159 tools::Rectangle aCtrlRegion( Point(), GetOutputSizePixel() );
161 aControlValue, OUString() );
162}
163
165{
166 Size aSize = GetSizePixel();
167
168 Wallpaper aWallpaper = GetBackground();
169 if ( !aWallpaper.IsBitmap() )
171
172 pDev->Push();
173 pDev->SetMapMode();
174 pDev->SetLineColor();
175
176 if ( aWallpaper.IsBitmap() )
177 pDev->DrawBitmapEx( rPos, aSize, aWallpaper.GetBitmap() );
178 else
179 {
180 if( aWallpaper.GetColor() == COL_AUTO )
181 pDev->SetFillColor( GetSettings().GetStyleSettings().GetDialogColor() );
182 else
183 pDev->SetFillColor( aWallpaper.GetColor() );
184 pDev->DrawRect( tools::Rectangle( rPos, aSize ) );
185 }
186
187 pDev->Pop();
188}
189
191{
192 if (isLayoutEnabled(this))
194 return getLegacyBestSizeForChildren(*this);
195}
196
197void TabPage::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
198{
199 Window::SetPosSizePixel(rAllocPos, rAllocation);
200 if (isLayoutEnabled(this) && rAllocation.Width() && rAllocation.Height())
202}
203
204void TabPage::SetSizePixel(const Size& rAllocation)
205{
206 Window::SetSizePixel(rAllocation);
207 if (isLayoutEnabled(this) && rAllocation.Width() && rAllocation.Height())
209}
210
211void TabPage::SetPosPixel(const Point& rAllocPos)
212{
213 Window::SetPosPixel(rAllocPos);
214 Size aAllocation(GetOutputSizePixel());
215 if (isLayoutEnabled(this) && aAllocation.Width() && aAllocation.Height())
216 {
218 }
219}
220
222{
223 tools::Long nXScroll = mnScrollPos.X() - nX;
224 tools::Long nYScroll = mnScrollPos.Y() - nY;
225 mnScrollPos = Point( nX, nY );
226
227 tools::Rectangle aScrollableArea( 0, 0, maScrollArea.Width(), maScrollArea.Height() );
228 Scroll(nXScroll, nYScroll, aScrollableArea );
229 // Manually scroll all children ( except the scrollbars )
230 for ( int index = 0; index < GetChildCount(); ++index )
231 {
232 vcl::Window* pChild = GetChild( index );
233 if ( pChild && pChild != m_pVScroll.get() && pChild != m_pHScroll.get() )
234 {
235 Point aPos = pChild->GetPosPixel();
236 aPos += Point( nXScroll, nYScroll );
237 pChild->SetPosPixel( aPos );
238 }
239 }
240}
241
242IMPL_LINK( TabPage, ScrollBarHdl, ScrollBar*, pSB, void )
243{
244 sal_uInt16 nPos = static_cast<sal_uInt16>(pSB->GetThumbPos());
245 if( pSB == m_pVScroll.get() )
246 lcl_Scroll(mnScrollPos.X(), nPos );
247 else if( pSB == m_pHScroll.get() )
248 lcl_Scroll(nPos, mnScrollPos.Y() );
249}
250
252{
253 Point aOld = mnScrollPos;
254 lcl_Scroll( mnScrollPos.X() , mnScrollPos.Y() - nTop );
255 if( m_pHScroll )
257 // new pos is 0,0
258 mnScrollPos = aOld;
259}
261{
262 Point aOld = mnScrollPos;
263 lcl_Scroll( mnScrollPos.X() - nLeft , mnScrollPos.Y() );
264 if( m_pVScroll )
266 // new pos is 0,0
267 mnScrollPos = aOld;
268}
269
271{
272 maScrollArea.setWidth( nWidth );
274}
275
277{
278 maScrollArea.setHeight( nHeight );
280}
281
283{
285}
286
288{
289 Size aOutSz = GetOutputSizePixel();
290
291 Point aVPos( aOutSz.Width() - mnScrWidth, 0 );
292 Point aHPos( 0, aOutSz.Height() - mnScrWidth );
293
294 if( m_pVScroll )
295 {
299 }
300
301 if( m_pHScroll )
302 {
306 }
307}
308
309/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SystemTextColorFlags
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:638
DataChangedEventType GetType() const
Definition: event.hxx:362
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
Definition: bitmapex.cxx:33
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:50
void SetLineColor()
Definition: line.cxx:37
void SetMapMode()
Definition: map.cxx:597
void SetFillColor()
Definition: fill.cxx:29
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
Definition: stack.cxx:32
void Pop()
Definition: stack.cxx:91
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
constexpr tools::Long Y() const
constexpr tools::Long X() const
void SetThumbPos(tools::Long nThumbPos) override
Definition: scrbar.cxx:1362
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:130
void SetVisibleSize(tools::Long nNewSize) override
Definition: scrbar.cxx:1376
void SetRangeMax(tools::Long nNewRange) override
Definition: scrbar.cxx:1333
constexpr tools::Long Height() const
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
constexpr tools::Long Width() const
sal_Int32 GetScrollBarSize() const
virtual void StateChanged(StateChangedType nStateChange) override
Definition: tabpage.cxx:114
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: tabpage.cxx:28
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize) override
Definition: tabpage.cxx:197
virtual Size GetOptimalSize() const override
Definition: tabpage.cxx:190
virtual void SetSizePixel(const Size &rNewSize) override
Definition: tabpage.cxx:204
bool mbHasHoriBar
Definition: tabpage.hxx:43
void ResetScrollBars()
Definition: tabpage.cxx:287
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: tabpage.cxx:132
bool mbHasVertBar
Definition: tabpage.hxx:44
VclPtr< ScrollBar > m_pVScroll
Definition: tabpage.hxx:40
VclPtr< ScrollBar > m_pHScroll
Definition: tabpage.hxx:41
virtual void Resize() override
Definition: tabpage.cxx:282
void SetScrollLeft(tools::Long nLeft)
Definition: tabpage.cxx:260
Size maScrollArea
Definition: tabpage.hxx:42
tools::Long mnScrWidth
Definition: tabpage.hxx:46
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: tabpage.cxx:107
void SetScrollTop(tools::Long Top)
Definition: tabpage.cxx:251
void SetScrollWidth(tools::Long nWidth)
Definition: tabpage.cxx:270
Point mnScrollPos
Definition: tabpage.hxx:45
SAL_DLLPRIVATE void ImplInitSettings()
Definition: tabpage.cxx:73
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: tabpage.cxx:144
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: tabpage.cxx:164
TabPage(vcl::Window *pParent, WinBits nStyle=0)
Definition: tabpage.cxx:96
virtual void SetPosPixel(const Point &rNewPos) override
Definition: tabpage.cxx:211
virtual ~TabPage() override
Definition: tabpage.cxx:102
void SetScrollHeight(tools::Long nHeight)
Definition: tabpage.cxx:276
void lcl_Scroll(tools::Long nX, tools::Long nY)
Definition: tabpage.cxx:221
static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize)
Definition: layout.cxx:95
static Size getLayoutRequisition(const vcl::Window &rWindow)
Definition: layout.cxx:170
A thin wrapper around rtl::Reference to implement the acquire and dispose semantics we want for refer...
Definition: vclptr.hxx:58
void disposeAndClear()
Definition: vclptr.hxx:200
void set(reference_type *pBody)
Definition: vclptr.hxx:148
reference_type * get() const
Get the body.
Definition: vclptr.hxx:143
const BitmapEx & GetBitmap() const
Definition: wall.cxx:184
const Color & GetColor() const
Definition: wall.hxx:71
bool IsBitmap() const
Definition: wall.cxx:189
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: window.cxx:140
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
void SetStyle(WinBits nStyle)
Definition: window.cxx:1962
vcl::Window * GetParent() const
Definition: window2.cxx:1123
sal_uInt16 GetChildCount() const
Definition: stacking.cxx:1002
WindowType GetType() const
Definition: window2.cxx:1000
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1053
bool HasFocus() const
Definition: window.cxx:2981
virtual Point GetPosPixel() const
Definition: window.cxx:2794
WinBits GetStyle() const
Definition: window2.cxx:979
const AllSettings & GetSettings() const
Definition: window3.cxx:129
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2187
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
Definition: window3.cxx:74
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2944
virtual Size GetSizePixel() const
Definition: window.cxx:2402
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1113
const Color & GetControlBackground() const
Definition: window2.cxx:1108
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
virtual void ImplAdjustNWFSizes()
Definition: window3.cxx:28
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
virtual void SetPosPixel(const Point &rNewPos)
Definition: window2.cxx:1283
virtual void SetPosSizePixel(const Point &rNewPos, const Size &rNewSize)
Definition: window2.cxx:1294
vcl::Window * GetChild(sal_uInt16 nChild) const
Definition: stacking.cxx:1018
bool IsEnabled() const
Definition: window2.cxx:1148
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1048
void SetBackground()
Definition: window3.cxx:100
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
void GenerateAutoMnemonicsOnHierarchy(const vcl::Window *pWindow)
Definition: dialog.cxx:205
sal_Int32 nState
bool isLayoutEnabled(const vcl::Window *pWindow)
Definition: layout.cxx:3005
Size getLegacyBestSizeForChildren(const vcl::Window &rWindow)
Definition: layout.cxx:2943
sal_uInt16 nPos
index
long Long
QPRO_FUNC_TYPE nType
IMPL_LINK(TabPage, ScrollBarHdl, ScrollBar *, pSB, void)
Definition: tabpage.cxx:242
StateChangedType
Definition: window.hxx:291
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_DIALOGCONTROL
Definition: wintypes.hxx:113
WinBits const WB_DRAG
Definition: wintypes.hxx:152
WindowType
Definition: wintypes.hxx:27
WinBits const WB_AUTOVSCROLL
Definition: wintypes.hxx:163
WinBits const WB_AUTOHSCROLL
Definition: wintypes.hxx:161
WinBits const WB_VSCROLL
Definition: wintypes.hxx:178
WinBits const WB_NODIALOGCONTROL
Definition: wintypes.hxx:114
WinBits const WB_CLIPCHILDREN
Definition: wintypes.hxx:112
WinBits const WB_HSCROLL
Definition: wintypes.hxx:177