Line data Source code
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/window.hxx>
25 :
26 : #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF
27 :
28 : class VCL_DLLPUBLIC Splitter : public Window
29 : {
30 : private:
31 : 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;
45 :
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( 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 : // Copy assignment is forbidden and not implemented.
57 : SAL_DLLPRIVATE Splitter (const Splitter &);
58 : SAL_DLLPRIVATE Splitter& operator= (const Splitter &);
59 :
60 : protected:
61 : using Window::ImplInit;
62 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nWinStyle );
63 :
64 : public:
65 : explicit Splitter( Window* pParent, WinBits nStyle = WB_VSCROLL );
66 : explicit Splitter( Window* pParent, const ResId& );
67 : virtual ~Splitter();
68 :
69 : virtual void StartSplit();
70 : virtual void EndSplit();
71 : virtual void Split();
72 : virtual void Splitting( Point& rSplitPos );
73 :
74 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
75 : virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
76 :
77 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
78 :
79 : virtual void GetFocus() SAL_OVERRIDE;
80 : virtual void LoseFocus() SAL_OVERRIDE;
81 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
82 : virtual void Paint( const Rectangle& rPaintRect ) SAL_OVERRIDE;
83 :
84 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
85 :
86 : void StartDrag();
87 :
88 : void SetDragRectPixel( const Rectangle& rDragRect,
89 : Window* pRefWin = NULL );
90 : const Rectangle& GetDragRectPixel() const { return maDragRect; }
91 : Window* GetDragWindow() const { return mpRefWin; }
92 :
93 : virtual void SetSplitPosPixel( long nPos );
94 0 : long GetSplitPosPixel() const { return mnSplitPos; }
95 :
96 0 : bool IsHorizontal() const { return mbHorzSplit; }
97 : void SetHorizontal(bool bNew);
98 :
99 : // set the stepsize of the splitter for cursor movement
100 : // the default is 10% of the reference window's width/height
101 : void SetKeyboardStepSize( long nStepSize );
102 :
103 0 : void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; }
104 : const Link& GetStartSplitHdl() const { return maStartSplitHdl; }
105 0 : void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; }
106 0 : void SetEndSplitHdl( const Link& rLink ) { maEndSplitHdl = rLink; }
107 : const Link& GetEndSplitHdl() const { return maEndSplitHdl; }
108 : const Link& GetSplitHdl() const { return maSplitHdl; }
109 : };
110 :
111 : #endif // INCLUDED_VCL_SPLIT_HXX
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|