Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / split.hxx
blob448894d746ec548a903afa3fdeeb4a585b35f110
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_SPLIT_HXX
21 #define INCLUDED_VCL_SPLIT_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/window.hxx>
26 #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF
28 class VCL_DLLPUBLIC Splitter : public vcl::Window
30 private:
31 VclPtr<vcl::Window> mpRefWin;
32 long mnSplitPos;
33 long mnLastSplitPos;
34 long mnStartSplitPos;
35 Point maDragPos;
36 tools::Rectangle maDragRect;
37 bool mbHorzSplit;
38 bool mbDragFull;
39 bool mbKbdSplitting;
40 long mbInKeyEvent;
41 long mnKeyboardStepSize;
42 Link<Splitter*,void> maStartSplitHdl;
43 Link<Splitter*,void> maSplitHdl;
44 Link<Splitter*,void> maEndSplitHdl;
46 SAL_DLLPRIVATE void ImplDrawSplitter();
47 SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos );
48 SAL_DLLPRIVATE void ImplStartKbdSplitting();
49 SAL_DLLPRIVATE void ImplKbdTracking( vcl::KeyCode aKeyCode );
50 SAL_DLLPRIVATE bool ImplSplitterActive();
51 SAL_DLLPRIVATE Splitter* ImplFindSibling();
52 SAL_DLLPRIVATE void ImplRestoreSplitter();
53 SAL_DLLPRIVATE void ImplInitHorVer(bool bNew);
55 Splitter (const Splitter &) = delete;
56 Splitter& operator= (const Splitter &) = delete;
58 protected:
59 using Window::ImplInit;
60 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nWinStyle );
62 public:
63 explicit Splitter( vcl::Window* pParent, WinBits nStyle = WB_VSCROLL );
64 virtual ~Splitter() override;
65 virtual void dispose() override;
67 void StartSplit();
68 void EndSplit();
69 void Split();
71 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
72 virtual void Tracking( const TrackingEvent& rTEvt ) override;
74 virtual void GetFocus() override;
75 virtual void LoseFocus() override;
76 virtual void KeyInput( const KeyEvent& rKEvt ) override;
77 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rPaintRect ) override;
78 virtual Size GetOptimalSize() const override;
80 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
82 void StartDrag();
84 void SetDragRectPixel( const tools::Rectangle& rDragRect,
85 vcl::Window* pRefWin = nullptr );
87 void SetSplitPosPixel( long nPos );
88 long GetSplitPosPixel() const { return mnSplitPos; }
90 bool IsHorizontal() const { return mbHorzSplit; }
91 void SetHorizontal(bool bNew);
93 // set the stepsize of the splitter for cursor movement
94 // the default is 10% of the reference window's width/height
95 void SetKeyboardStepSize( long nStepSize );
97 void SetStartSplitHdl( const Link<Splitter*,void>& rLink ) { maStartSplitHdl = rLink; }
98 void SetSplitHdl( const Link<Splitter*,void>& rLink ) { maSplitHdl = rLink; }
99 void SetEndSplitHdl( const Link<Splitter*,void>& rLink ) { maEndSplitHdl = rLink; }
102 #endif // INCLUDED_VCL_SPLIT_HXX
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */