Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / split.hxx
bloba9a185bb67ebc56e0319bf5e07a77a6a5adef585
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 Rectangle maDragRect;
37 bool mbHorzSplit;
38 bool mbDragFull;
39 bool mbKbdSplitting;
40 long mbInKeyEvent;
41 long mnKeyboardStepSize;
42 Link<> maStartSplitHdl;
43 Link<> maSplitHdl;
44 Link<> maEndSplitHdl;
46 SAL_DLLPRIVATE void ImplInitSplitterData();
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 &) SAL_DELETED_FUNCTION;
57 Splitter& operator= (const Splitter &) SAL_DELETED_FUNCTION;
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();
66 virtual void dispose() SAL_OVERRIDE;
68 void StartSplit();
69 void EndSplit();
70 void Split();
71 virtual void Splitting( Point& rSplitPos );
73 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
74 virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
76 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
78 virtual void GetFocus() SAL_OVERRIDE;
79 virtual void LoseFocus() SAL_OVERRIDE;
80 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
81 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rPaintRect ) SAL_OVERRIDE;
83 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
85 void StartDrag();
87 void SetDragRectPixel( const Rectangle& rDragRect,
88 vcl::Window* pRefWin = NULL );
89 const Rectangle& GetDragRectPixel() const { return maDragRect; }
90 vcl::Window* GetDragWindow() const { return mpRefWin; }
92 void SetSplitPosPixel( long nPos );
93 long GetSplitPosPixel() const { return mnSplitPos; }
95 bool IsHorizontal() const { return mbHorzSplit; }
96 void SetHorizontal(bool bNew);
98 // set the stepsize of the splitter for cursor movement
99 // the default is 10% of the reference window's width/height
100 void SetKeyboardStepSize( long nStepSize );
102 void SetStartSplitHdl( const Link<>& rLink ) { maStartSplitHdl = rLink; }
103 const Link<>& GetStartSplitHdl() const { return maStartSplitHdl; }
104 void SetSplitHdl( const Link<>& rLink ) { maSplitHdl = rLink; }
105 void SetEndSplitHdl( const Link<>& rLink ) { maEndSplitHdl = rLink; }
106 const Link<>& GetEndSplitHdl() const { return maEndSplitHdl; }
107 const Link<>& GetSplitHdl() const { return maSplitHdl; }
110 #endif // INCLUDED_VCL_SPLIT_HXX
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */