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