vcl: 'horizontically'
[LibreOffice.git] / include / vcl / split.hxx
blob4d8624c49b2e3214cf9cf327954fc738ae5d42ad
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/keycod.hxx>
25 #include <vcl/window.hxx>
27 #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF
29 class VCL_DLLPUBLIC Splitter : public vcl::Window
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;
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);
56 Splitter (const Splitter &) = delete;
57 Splitter& operator= (const Splitter &) = delete;
59 protected:
60 using Window::ImplInit;
61 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nWinStyle );
63 public:
64 explicit Splitter( vcl::Window* pParent, WinBits nStyle = WB_VSCROLL );
65 virtual ~Splitter() override;
66 virtual void dispose() override;
68 void StartSplit();
69 void EndSplit();
70 void Split();
72 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
73 virtual void Tracking( const TrackingEvent& rTEvt ) override;
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;
81 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
83 void StartDrag();
85 void SetDragRectPixel( const tools::Rectangle& rDragRect,
86 vcl::Window* pRefWin = nullptr );
88 void SetSplitPosPixel( tools::Long nPos );
89 tools::Long GetSplitPosPixel() const { return mnSplitPos; }
91 bool IsHorizontal() const { return mbHorzSplit; }
92 void SetHorizontal(bool bNew);
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 );
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; }
103 #endif // INCLUDED_VCL_SPLIT_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */