LibreOffice Module vcl (master)  1
split.hxx
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 #ifndef INCLUDED_VCL_SPLIT_HXX
21 #define INCLUDED_VCL_SPLIT_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/keycod.hxx>
25 #include <vcl/window.hxx>
26 
27 #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF
28 
30 {
31 private:
33  long mnSplitPos;
39  bool mbDragFull;
46 
47  SAL_DLLPRIVATE void ImplDrawSplitter();
48  SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos );
49  SAL_DLLPRIVATE void ImplStartKbdSplitting();
50  SAL_DLLPRIVATE void ImplKbdTracking( vcl::KeyCode aKeyCode );
51  SAL_DLLPRIVATE bool ImplSplitterActive();
52  SAL_DLLPRIVATE Splitter* ImplFindSibling();
53  SAL_DLLPRIVATE void ImplRestoreSplitter();
54  SAL_DLLPRIVATE void ImplInitHorVer(bool bNew);
55 
56  Splitter (const Splitter &) = delete;
57  Splitter& operator= (const Splitter &) = delete;
58 
59 protected:
60  using Window::ImplInit;
61  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nWinStyle );
62 
63 public:
64  explicit Splitter( vcl::Window* pParent, WinBits nStyle = WB_VSCROLL );
65  virtual ~Splitter() override;
66  virtual void dispose() override;
67 
68  void StartSplit();
69  void EndSplit();
70  void Split();
71 
72  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
73  virtual void Tracking( const TrackingEvent& rTEvt ) override;
74 
75  virtual void GetFocus() override;
76  virtual void LoseFocus() override;
77  virtual void KeyInput( const KeyEvent& rKEvt ) override;
78  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rPaintRect ) override;
79  virtual Size GetOptimalSize() const override;
80 
81  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
82 
83  void StartDrag();
84 
85  void SetDragRectPixel( const tools::Rectangle& rDragRect,
86  vcl::Window* pRefWin = nullptr );
87 
88  void SetSplitPosPixel( long nPos );
89  long GetSplitPosPixel() const { return mnSplitPos; }
90 
91  bool IsHorizontal() const { return mbHorzSplit; }
92  void SetHorizontal(bool bNew);
93 
94  // set the stepsize of the splitter for cursor movement
95  // the default is 10% of the reference window's width/height
96  void SetKeyboardStepSize( long nStepSize );
97 
98  void SetStartSplitHdl( const Link<Splitter*,void>& rLink ) { maStartSplitHdl = rLink; }
99  void SetSplitHdl( const Link<Splitter*,void>& rLink ) { maSplitHdl = rLink; }
100  void SetEndSplitHdl( const Link<Splitter*,void>& rLink ) { maEndSplitHdl = rLink; }
101 };
102 
103 #endif // INCLUDED_VCL_SPLIT_HXX
104 
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetEndSplitHdl(const Link< Splitter *, void > &rLink)
Definition: split.hxx:100
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:413
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool IsHorizontal() const
Definition: split.hxx:91
virtual Size GetOptimalSize() const
Definition: window3.cxx:33
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: window.cxx:141
sal_Int64 WinBits
Link< Splitter *, void > maEndSplitHdl
Definition: split.hxx:45
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1895
bool mbKbdSplitting
Definition: split.hxx:40
long mnLastSplitPos
Definition: split.hxx:34
Link< Splitter *, void > maSplitHdl
Definition: split.hxx:44
Link< Splitter *, void > maStartSplitHdl
Definition: split.hxx:43
void SetSplitHdl(const Link< Splitter *, void > &rLink)
Definition: split.hxx:99
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
VclPtr< vcl::Window > mpRefWin
Definition: split.hxx:32
tools::Rectangle maDragRect
Definition: split.hxx:37
bool mbHorzSplit
Definition: split.hxx:38
virtual void LoseFocus()
Definition: window.cxx:1818
void SetStartSplitHdl(const Link< Splitter *, void > &rLink)
Definition: split.hxx:98
long mnStartSplitPos
Definition: split.hxx:35
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1768
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:931
long GetSplitPosPixel() const
Definition: split.hxx:89
virtual void GetFocus()
Definition: window.cxx:1804
bool mbDragFull
Definition: split.hxx:39
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1013
bool mbInKeyEvent
Definition: split.hxx:41
Point maDragPos
Definition: split.hxx:36
long mnKeyboardStepSize
Definition: split.hxx:42
OutputDevice & operator=(const OutputDevice &)=delete
long mnSplitPos
Definition: split.hxx:33
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35