LibreOffice Module extensions (master) 1
bibcont.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
21#include <vcl/event.hxx>
22#include "bibconfig.hxx"
23
24
25#include "bibcont.hxx"
26
27
29{
30}
31
33{
34 return false;
35}
36
37
38BibWindow::BibWindow( vcl::Window* pParent, WinBits nStyle ) : Window( pParent, nStyle ), BibShortCutHandler( this )
39{
40}
41
43{
44}
45
46
47BibSplitWindow::BibSplitWindow( vcl::Window* pParent, WinBits nStyle ) : SplitWindow( pParent, nStyle ), BibShortCutHandler( this )
48{
49}
50
51using namespace ::com::sun::star;
52using namespace ::com::sun::star::uno;
53
54//split window size is a percent value
55#define WIN_MIN_HEIGHT 10
56#define WIN_STEP_SIZE 5
57
59 BibWindow( pParent, WB_3DLOOK ),
60 pChild( pChildWin )
61{
62 if(pChild!=nullptr)
63 {
64 vcl::Window* pChildWindow = GetChild();
65 pChildWindow->SetParent(this);
66 pChildWindow->Show();
67 pChildWindow->SetPosPixel(Point(0,0));
68 }
69}
70
72{
74}
75
77{
78 if( pChild )
79 {
81 pChild = nullptr; // prevents GetFocus for child while deleting!
82 pDel.disposeAndClear();
83 }
85}
86
88{
89 if( pChild )
91}
92
94{
95 if( pChild )
97}
98
100{
101 return pChild && pChild->HandleShortCutKey( rKeyEvent );
102}
103
104
106 BibSplitWindow(pParent,WB_3DLOOK),
107 pTopWin(nullptr),
108 pBottomWin(nullptr),
109 aIdle("extensions BibBookContainer Split Idle")
110{
112 aIdle.SetInvokeHandler(LINK( this, BibBookContainer, SplitHdl));
113 aIdle.SetPriority(TaskPriority::LOWEST);
114}
115
117{
118 disposeOnce();
119}
120
122{
123 if( pTopWin )
124 {
126 pTopWin = nullptr; // prevents GetFocus for child while deleting!
127 pDel.disposeAndClear();
128 }
129
130 if( pBottomWin )
131 {
133 pBottomWin = nullptr; // prevents GetFocus for child while deleting!
134 pDel.disposeAndClear();
135 }
136
138 pTopWin.clear();
141}
142
144{
145 aIdle.Start();
146}
148{
149 tools::Long nSize= GetItemSize( TOP_WINDOW);
150 BibConfig* pConfig = BibModul::GetConfig();
151 pConfig->setBeamerSize(nSize);
152 nSize = GetItemSize( BOTTOM_WINDOW);
153 pConfig->setViewSize(nSize);
154}
155
157{
158 if(pTopWin)
159 {
162 }
164 pTopWin->Show();
165 BibConfig* pConfig = BibModul::GetConfig();
166 tools::Long nSize = pConfig->getBeamerSize();
167 InsertItem(TOP_WINDOW, pTopWin, nSize, 1, 0, SplitWindowItemFlags::PercentSize );
168
169}
170
172{
173 if(pBottomWin)
174 {
177 }
178
180
181 BibConfig* pConfig = BibModul::GetConfig();
182 tools::Long nSize = pConfig->getViewSize();
183 InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SplitWindowItemFlags::PercentSize );
184
185}
186
188{
189 if( pBottomWin )
190 pBottomWin->GrabFocus();
191}
192
194{
195 bool bHandled = false;
196 if( NotifyEventType::KEYINPUT == rNEvt.GetType() )
197 {
198 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
199 const vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
200 sal_uInt16 nKey = aKeyCode.GetCode();
201 const sal_uInt16 nModifier = aKeyCode.GetModifier();
202
203 if( KEY_MOD2 == nModifier )
204 {
205 if( KEY_UP == nKey || KEY_DOWN == nKey )
206 {
207 if(pTopWin && pBottomWin)
208 {
209 sal_uInt16 nFirstWinId = KEY_UP == nKey ? TOP_WINDOW : BOTTOM_WINDOW;
210 sal_uInt16 nSecondWinId = KEY_UP == nKey ? BOTTOM_WINDOW : TOP_WINDOW;
211 tools::Long nHeight = GetItemSize( nFirstWinId );
212 nHeight -= WIN_STEP_SIZE;
213 if(nHeight < WIN_MIN_HEIGHT)
214 nHeight = WIN_MIN_HEIGHT;
215 SetItemSize( nFirstWinId, nHeight );
216 SetItemSize( nSecondWinId, 100 - nHeight );
217 }
218 bHandled = true;
219 }
220 else if( pKEvt->GetCharCode() && HandleShortCutKey( *pKEvt ) )
221 bHandled = true;
222 }
223 }
224
225 return bHandled;
226}
227
229{
230 bool bRet = false;
231
232 if( pTopWin )
233 bRet = pTopWin->HandleShortCutKey( rKeyEvent );
234
235 if( !bRet && pBottomWin )
236 bRet = pBottomWin->HandleShortCutKey( rKeyEvent );
237
238 return bRet;
239}
240
241/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
IMPL_LINK_NOARG(BibBookContainer, SplitHdl, Timer *, void)
Definition: bibcont.cxx:147
#define WIN_STEP_SIZE
Definition: bibcont.cxx:56
#define WIN_MIN_HEIGHT
Definition: bibcont.cxx:55
#define BOTTOM_WINDOW
Definition: bibcont.hxx:29
#define TOP_WINDOW
Definition: bibcont.hxx:28
void CloseBibModul(HdlBibModul ppBibModul)
Definition: bibmod.cxx:47
HdlBibModul OpenBibModul()
Definition: bibmod.cxx:37
virtual void GetFocus() override
Definition: bibcont.cxx:187
VclPtr< BibWindowContainer > pTopWin
Definition: bibcont.hxx:64
virtual bool HandleShortCutKey(const KeyEvent &rKeyEvent) override
Definition: bibcont.cxx:228
void createTopFrame(BibShortCutHandler *pWin)
Definition: bibcont.cxx:156
BibBookContainer(vcl::Window *pParent)
Definition: bibcont.cxx:105
virtual void Split() override
Definition: bibcont.cxx:143
virtual void dispose() override
Definition: bibcont.cxx:121
VclPtr< BibWindowContainer > pBottomWin
Definition: bibcont.hxx:65
HdlBibModul pBibMod
Definition: bibcont.hxx:66
virtual ~BibBookContainer() override
Definition: bibcont.cxx:116
void createBottomFrame(BibShortCutHandler *pWin)
Definition: bibcont.cxx:171
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: bibcont.cxx:193
tools::Long getViewSize() const
Definition: bibconfig.hxx:128
tools::Long getBeamerSize() const
Definition: bibconfig.hxx:126
void setBeamerSize(tools::Long nSize)
Definition: bibconfig.hxx:125
void setViewSize(tools::Long nSize)
Definition: bibconfig.hxx:127
static BibConfig * GetConfig()
Definition: bibmod.cxx:82
virtual bool HandleShortCutKey(const KeyEvent &rKeyEvent)
Definition: bibcont.cxx:32
virtual ~BibShortCutHandler()
Definition: bibcont.cxx:28
BibSplitWindow(vcl::Window *pParent, WinBits nStyle)
Definition: bibcont.cxx:47
vcl::Window * GetChild()
Definition: bibcont.hxx:54
virtual void Resize() override
Definition: bibcont.cxx:87
virtual void GetFocus() override
Definition: bibcont.cxx:93
virtual ~BibWindowContainer() override
Definition: bibcont.cxx:71
virtual void dispose() override
Definition: bibcont.cxx:76
BibWindowContainer(vcl::Window *pParent, BibShortCutHandler *pChild)
Definition: bibcont.cxx:58
BibShortCutHandler * pChild
Definition: bibcont.hxx:35
virtual bool HandleShortCutKey(const KeyEvent &rKeyEvent) override
Definition: bibcont.cxx:99
BibWindow(vcl::Window *pParent, WinBits nStyle)
Definition: bibcont.cxx:38
virtual ~BibWindow() override
Definition: bibcont.cxx:42
virtual void Start(bool bStartTimer=true) override
sal_Unicode GetCharCode() const
const vcl::KeyCode & GetKeyCode() const
const KeyEvent * GetKeyEvent() const
NotifyEventType GetType() const
tools::Long GetItemSize(sal_uInt16 nId) const
virtual void dispose() override
void InsertItem(sal_uInt16 nId, vcl::Window *pWindow, tools::Long nSize, sal_uInt16 nPos, sal_uInt16 nIntoSetId, SplitWindowItemFlags nBits)
void RemoveItem(sal_uInt16 nId)
void SetItemSize(sal_uInt16 nId, tools::Long nNewSize)
void SetPriority(TaskPriority ePriority)
void SetInvokeHandler(const Link< Timer *, void > &rLink)
void disposeAndClear()
void clear()
static VclPtr< reference_type > Create(Arg &&... arg)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void dispose() override
virtual void SetSizePixel(const Size &rNewSize)
void GrabFocus()
void SetParent(vcl::Window *pNewParent)
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
Size GetOutputSizePixel() const
virtual void SetPosPixel(const Point &rNewPos)
constexpr sal_uInt16 KEY_MOD2
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_DOWN
long Long
sal_Int64 WinBits
WinBits const WB_3DLOOK