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 _SV_SPLIT_HXX
21 : #define _SV_SPLIT_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/window.hxx>
26 :
27 : #define SPLITTER_DEFAULTSTEPSIZE 0xFFFF
28 :
29 : // ------------
30 : // - Splitter -
31 : // ------------
32 :
33 : class VCL_DLLPUBLIC Splitter : public Window
34 : {
35 : private:
36 : Window* mpRefWin;
37 : long mnSplitPos;
38 : long mnLastSplitPos;
39 : long mnStartSplitPos;
40 : Point maDragPos;
41 : Rectangle maDragRect;
42 : sal_Bool mbHorzSplit;
43 : sal_Bool mbDragFull;
44 : sal_Bool mbKbdSplitting;
45 : long mbInKeyEvent;
46 : long mnKeyboardStepSize;
47 : Link maStartSplitHdl;
48 : Link maSplitHdl;
49 : Link maEndSplitHdl;
50 :
51 : SAL_DLLPRIVATE void ImplInitSplitterData();
52 : SAL_DLLPRIVATE void ImplDrawSplitter();
53 : SAL_DLLPRIVATE void ImplSplitMousePos( Point& rPos );
54 : SAL_DLLPRIVATE void ImplStartKbdSplitting();
55 : SAL_DLLPRIVATE void ImplKbdTracking( KeyCode aKeyCode );
56 : SAL_DLLPRIVATE sal_Bool ImplSplitterActive();
57 : SAL_DLLPRIVATE Splitter* ImplFindSibling();
58 : SAL_DLLPRIVATE void ImplRestoreSplitter();
59 :
60 : // Copy assignment is forbidden and not implemented.
61 : SAL_DLLPRIVATE Splitter (const Splitter &);
62 : SAL_DLLPRIVATE Splitter& operator= (const Splitter &);
63 :
64 : protected:
65 : using Window::ImplInit;
66 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nWinStyle );
67 :
68 : public:
69 : Splitter( Window* pParent, WinBits nStyle = WB_VSCROLL );
70 : Splitter( Window* pParent, const ResId& rResId );
71 : ~Splitter();
72 :
73 : virtual void StartSplit();
74 : virtual void EndSplit();
75 : virtual void Split();
76 : virtual void Splitting( Point& rSplitPos );
77 :
78 : virtual void MouseButtonDown( const MouseEvent& rMEvt );
79 : virtual void Tracking( const TrackingEvent& rTEvt );
80 :
81 : virtual long Notify( NotifyEvent& rNEvt );
82 :
83 : virtual void GetFocus();
84 : virtual void LoseFocus();
85 : virtual void KeyInput( const KeyEvent& rKEvt );
86 : virtual void Paint( const Rectangle& rPaintRect );
87 :
88 : virtual void DataChanged( const DataChangedEvent& rDCEvt );
89 :
90 : void StartDrag();
91 :
92 : void SetDragRectPixel( const Rectangle& rDragRect,
93 : Window* pRefWin = NULL );
94 : const Rectangle& GetDragRectPixel() const { return maDragRect; }
95 : Window* GetDragWindow() const { return mpRefWin; }
96 :
97 : virtual void SetSplitPosPixel( long nPos );
98 0 : long GetSplitPosPixel() const { return mnSplitPos; }
99 :
100 0 : sal_Bool IsHorizontal() const { return mbHorzSplit; }
101 :
102 : // set the stepsize of the splitter for cursor movement
103 : // the default is 10% of the reference window's width/height
104 : void SetKeyboardStepSize( long nStepSize );
105 :
106 0 : void SetStartSplitHdl( const Link& rLink ) { maStartSplitHdl = rLink; }
107 : const Link& GetStartSplitHdl() const { return maStartSplitHdl; }
108 0 : void SetSplitHdl( const Link& rLink ) { maSplitHdl = rLink; }
109 0 : void SetEndSplitHdl( const Link& rLink ) { maEndSplitHdl = rLink; }
110 : const Link& GetEndSplitHdl() const { return maEndSplitHdl; }
111 : const Link& GetSplitHdl() const { return maSplitHdl; }
112 : };
113 :
114 : #endif // _SV_SPLIT_HXX
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|