LibreOffice Module vcl (master) 1
InterimItemWindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
11#include <vcl/layout.hxx>
12#include <salobj.hxx>
13#include <window.h>
14
15InterimItemWindow::InterimItemWindow(vcl::Window* pParent, const OUString& rUIXMLDescription,
16 const OString& rID, bool bAllowCycleFocusOut,
17 sal_uInt64 nLOKWindowId)
18 : Control(pParent, WB_TABSTOP)
19 , m_pWidget(nullptr) // inheritors are expected to call InitControlBase
20 , m_aLayoutIdle("InterimItemWindow m_aLayoutIdle")
21{
24
28 bAllowCycleFocusOut, nLOKWindowId);
29 m_xContainer = m_xBuilder->weld_container(rID);
30
33}
34
36{
37 if (nStateChange == StateChangedType::Enable)
38 m_xContainer->set_sensitive(IsEnabled());
39 Control::StateChanged(nStateChange);
40}
41
43
45{
46 m_pWidget = nullptr;
47
48 m_xContainer.reset();
49 m_xBuilder.reset();
51
53
55}
56
58{
60 return;
62 return;
64}
65
67{
68 Control::queue_resize(eReason);
70}
71
73
75{
76 if (!IsVisible())
77 return;
79 if (!pChild)
80 return;
81 WindowImpl* pWindowImpl = pChild->ImplGetWindowImpl();
82 if (!pWindowImpl)
83 return;
84 if (!pWindowImpl->mpSysObj)
85 return;
86 pWindowImpl->mpSysObj->Show(true);
87 pWindowImpl->mpSysObj->ResetClipRegion();
88 // flag that sysobj clip is dirty and needs to be recalculated on next use
89 pWindowImpl->mbInitWinClipRegion = true;
90}
91
93
95{
98 assert(pChild);
101}
102
104{
106}
107
109{
110 // find the bottom vcl::Window of the hierarchy and queue_resize on that
111 // one will invalidate all the size caches upwards
113 while (true)
114 {
115 vcl::Window* pSubChild = pChild->GetWindow(GetWindowType::FirstChild);
116 if (!pSubChild)
117 break;
118 pChild = pSubChild;
119 }
120 pChild->queue_resize();
121}
122
124{
125 if (!m_pWidget)
126 return false;
127 return m_pWidget->has_focus();
128}
129
131
133{
134 if (m_pWidget)
136
137 /* let toolbox know this item window has focus so it updates its mnHighItemId to point
138 to this toolitem in case tab means to move to another toolitem within
139 the toolbox
140 */
141 vcl::Window* pToolBox = GetParent();
143 pToolBox->EventNotify(aNEvt);
144}
145
147{
148 sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
149 if (nCode != KEY_TAB)
150 return false;
151
152 /* if the native widget has focus, then no vcl window has focus.
153
154 We want to grab focus to this vcl widget so that pressing tab will traverse
155 to the next vcl widget.
156
157 But just using GrabFocus will, because no vcl widget has focus, trigger
158 bringing the toplevel to front with the expectation that a suitable widget
159 will be picked for focus when that happen, which is no use to us here.
160
161 SetFakeFocus avoids the problem, allowing GrabFocus to do the expected thing
162 then sending the Tab to our parent will do the right traversal
163 */
164 SetFakeFocus(true);
165 GrabFocus();
166
167 /* now give focus to our toolbox parent */
168 vcl::Window* pToolBox = GetParent();
169 pToolBox->GrabFocus();
170
171 /* let toolbox know this item window has focus so it updates its mnHighItemId to point
172 to this toolitem in case tab means to move to another toolitem within
173 the toolbox
174 */
176 pToolBox->EventNotify(aNEvt);
177
178 /* send parent the tab */
179 pToolBox->KeyInput(rKEvt);
180
181 return true;
182}
183
184void InterimItemWindow::Draw(OutputDevice* pDevice, const Point& rPos,
185 SystemTextColorFlags /*nFlags*/)
186{
187 m_xContainer->draw(*pDevice, rPos, GetSizePixel());
188}
189
190void InterimItemWindow::ImplPaintToDevice(::OutputDevice* pTargetOutDev, const Point& rPos)
191{
192 Draw(pTargetOutDev, rPos, SystemTextColorFlags::NONE);
193}
194
195/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
IMPL_LINK_NOARG(InterimItemWindow, DoLayout, Timer *, void)
SystemTextColorFlags
static std::unique_ptr< weld::Builder > CreateInterimBuilder(vcl::Window *pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId=0)
Definition: builder.cxx:201
Definition: ctrl.hxx:82
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:264
virtual void Resize() override
Definition: ctrl.cxx:77
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:61
virtual void Start(bool bStartTimer=true) override
Schedules the task for execution.
Definition: idle.cxx:34
virtual void Resize() override
bool ChildKeyInput(const KeyEvent &rKEvt)
virtual void Layout()
virtual ~InterimItemWindow() override
bool ControlHasFocus() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
virtual void StateChanged(StateChangedType nStateChange) override
virtual void Draw(OutputDevice *pDevice, const Point &rPos, SystemTextColorFlags nFlags) override
InterimItemWindow(vcl::Window *pParent, const OUString &rUIXMLDescription, const OString &rID, bool bAllowCycleFocusOut=true, sal_uInt64 nLOKWindowId=0)
virtual void ImplPaintToDevice(::OutputDevice *pTargetOutDev, const Point &rPos) override
std::unique_ptr< weld::Builder > m_xBuilder
virtual void GetFocus() override
VclPtr< vcl::Window > m_xVclContentArea
weld::Widget * m_pWidget
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout) override
std::unique_ptr< weld::Container > m_xContainer
void InitControlBase(weld::Widget *pWidget)
virtual Size GetOptimalSize() const override
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:57
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:170
virtual void ResetClipRegion()=0
virtual void Show(bool bVisible)=0
bool IsActive() const
Definition: task.hxx:101
void SetPriority(TaskPriority ePriority)
Definition: scheduler.cxx:607
void Stop()
Definition: scheduler.cxx:600
Definition: timer.hxx:27
void SetInvokeHandler(const Link< Timer *, void > &rLink)
Definition: timer.hxx:56
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
void disposeAndClear()
Definition: vclptr.hxx:200
static VclPtr< reference_type > Create(Arg &&... arg)
A construction helper for VclPtr.
Definition: vclptr.hxx:127
bool mbInitWinClipRegion
Definition: window.h:350
SalObject * mpSysObj
Definition: window.h:230
sal_uInt16 GetCode() const
Definition: keycod.hxx:49
vcl::Window * GetParent() const
Definition: window2.cxx:1136
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1035
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1366
void GrabFocus()
Definition: window.cxx:2983
void SetFakeFocus(bool bFocus)
Set this when you need to act as if the window has focus even if it doesn't.
Definition: window.cxx:3006
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Definition: window.cxx:2191
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1809
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
virtual Size GetSizePixel() const
Definition: window.cxx:2406
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
bool IsVisible() const
Definition: window2.cxx:1141
virtual bool EventNotify(NotifyEvent &rNEvt)
Definition: event.cxx:104
bool IsEnabled() const
Definition: window2.cxx:1161
void SetBackground()
Definition: window3.cxx:100
virtual void grab_focus()=0
virtual bool has_focus() const =0
constexpr sal_uInt16 KEY_TAB
Definition: keycodes.hxx:121
sal_uInt16 nCode
Layout
@ RESIZE
Resize runs before repaint, so we won't paint twice.
StateChangedType
Definition: window.hxx:291
WinBits const WB_TABSTOP
Definition: wintypes.hxx:140