/src/libreoffice/include/vcl/split.hxx
Line | Count | Source (jump to first uncovered line) |
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 | 0 | #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF |
28 | | |
29 | | class VCL_DLLPUBLIC Splitter : public vcl::Window |
30 | | { |
31 | | private: |
32 | | VclPtr<vcl::Window> mpRefWin; |
33 | | tools::Long mnSplitPos; |
34 | | tools::Long mnLastSplitPos; |
35 | | tools::Long mnStartSplitPos; |
36 | | Point maDragPos; |
37 | | tools::Rectangle maDragRect; |
38 | | bool mbHorzSplit; |
39 | | bool mbDragFull; |
40 | | bool mbKbdSplitting; |
41 | | bool mbInKeyEvent; |
42 | | tools::Long mnKeyboardStepSize; |
43 | | Link<Splitter*,void> maStartSplitHdl; |
44 | | Link<Splitter*,void> maSplitHdl; |
45 | | Link<Splitter*,void> maEndSplitHdl; |
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( tools::Long nPos ); |
89 | 0 | tools::Long GetSplitPosPixel() const { return mnSplitPos; } |
90 | | |
91 | 0 | 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( tools::Long nStepSize ); |
97 | | |
98 | 0 | void SetStartSplitHdl( const Link<Splitter*,void>& rLink ) { maStartSplitHdl = rLink; } |
99 | 0 | void SetSplitHdl( const Link<Splitter*,void>& rLink ) { maSplitHdl = rLink; } |
100 | 0 | 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: */ |