lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / vcl / splitwin.hxx
blob022695e3f2f6a0029ad4db0b329fdf1df0cffe4d
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_SPLITWIN_HXX
21 #define INCLUDED_VCL_SPLITWIN_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/dockwin.hxx>
25 #include <o3tl/typed_flags_set.hxx>
27 class ImplSplitSet;
29 enum class SplitWindowItemFlags
31 NONE = 0x0000,
32 Fixed = 0x0001,
33 RelativeSize = 0x0002,
34 PercentSize = 0x0004,
35 ColSet = 0x0008,
37 namespace o3tl
39 template<> struct typed_flags<SplitWindowItemFlags> : is_typed_flags<SplitWindowItemFlags, 0x0f> {};
42 #define SPLITWINDOW_APPEND (sal_uInt16(0xFFFF))
43 #define SPLITWINDOW_ITEM_NOTFOUND (sal_uInt16(0xFFFF))
45 class VCL_DLLPUBLIC SplitWindow : public DockingWindow
47 private:
48 std::unique_ptr<ImplSplitSet> mpMainSet;
49 ImplSplitSet* mpBaseSet;
50 ImplSplitSet* mpSplitSet;
51 long* mpLastSizes;
52 tools::Rectangle maDragRect;
53 long mnDX;
54 long mnDY;
55 long mnLeftBorder;
56 long mnTopBorder;
57 long mnRightBorder;
58 long mnBottomBorder;
59 long mnMaxSize;
60 long mnMouseOff;
61 long mnMStartPos;
62 long mnMSplitPos;
63 WinBits mnWinStyle;
64 WindowAlign meAlign;
65 sal_uInt16 mnSplitTest;
66 sal_uInt16 mnSplitPos;
67 sal_uInt16 mnMouseModifier;
68 bool mbDragFull:1,
69 mbHorz:1,
70 mbBottomRight:1,
71 mbCalc:1,
72 mbRecalc:1,
73 mbInvalidate:1,
74 mbFadeIn:1,
75 mbFadeOut:1,
76 mbFadeInDown:1,
77 mbFadeOutDown:1,
78 mbFadeInPressed:1,
79 mbFadeOutPressed:1,
80 mbFadeNoButtonMode:1;
81 Link<SplitWindow*,void> maSplitHdl;
83 using Window::ImplInit;
84 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
85 SAL_DLLPRIVATE void ImplInitSettings();
86 SAL_DLLPRIVATE void ImplCalcLayout();
87 SAL_DLLPRIVATE void ImplUpdate();
88 SAL_DLLPRIVATE void ImplSetWindowSize( long nDelta );
89 SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos );
90 SAL_DLLPRIVATE void ImplGetButtonRect( tools::Rectangle& rRect, bool bTest ) const;
91 SAL_DLLPRIVATE void ImplGetFadeInRect( tools::Rectangle& rRect, bool bTest = false ) const;
92 SAL_DLLPRIVATE void ImplGetFadeOutRect( tools::Rectangle& rRect ) const;
93 SAL_DLLPRIVATE void ImplDrawFadeIn(vcl::RenderContext& rRenderContext);
94 SAL_DLLPRIVATE void ImplDrawFadeOut(vcl::RenderContext& rRenderContext);
95 SAL_DLLPRIVATE void ImplNewAlign();
96 SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, bool bHorz, bool bLeft);
97 SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt );
99 SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext);
100 SAL_DLLPRIVATE void ImplDrawBorderLine(vcl::RenderContext& rRenderContext);
101 static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, bool bHide,
102 bool bRows );
103 SAL_DLLPRIVATE void ImplDrawBack(vcl::RenderContext& rRenderContext, ImplSplitSet* pSet );
104 static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
105 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
106 bool bRows );
107 static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( const SplitWindow* pWindow, const Point& rPos,
108 long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos );
109 SAL_DLLPRIVATE void ImplDrawSplitTracking(const Point& rPos);
111 SplitWindow (const SplitWindow &) = delete;
112 SplitWindow & operator= (const SplitWindow &) = delete;
113 public:
114 SplitWindow( vcl::Window* pParent, WinBits nStyle = 0 );
115 virtual ~SplitWindow() override;
116 virtual void dispose() override;
118 virtual void StartSplit();
119 virtual void Split();
120 virtual void SplitResize();
121 virtual void FadeIn();
122 virtual void FadeOut();
124 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
125 virtual void MouseMove( const MouseEvent& rMEvt ) override;
126 virtual void Tracking( const TrackingEvent& rTEvt ) override;
127 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
128 virtual void Resize() override;
129 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
130 virtual void StateChanged( StateChangedType nType ) override;
131 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
132 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
134 void InsertItem( sal_uInt16 nId, vcl::Window* pWindow, long nSize,
135 sal_uInt16 nPos, sal_uInt16 nIntoSetId,
136 SplitWindowItemFlags nBits );
137 void InsertItem( sal_uInt16 nId, long nSize,
138 sal_uInt16 nPos, sal_uInt16 nIntoSetId,
139 SplitWindowItemFlags nBits );
140 void RemoveItem( sal_uInt16 nId );
141 void Clear();
143 void SplitItem( sal_uInt16 nId, long nNewSize,
144 bool bPropSmall,
145 bool bPropGreat );
146 void SetItemSize( sal_uInt16 nId, long nNewSize );
147 long GetItemSize( sal_uInt16 nId ) const;
148 /** Set a range that limits the (variable part of the) size with an
149 upper and a lower bound (both are valid values themselves.)
150 @param nId
151 Id of the item for which the size limits are set.
152 @param rRange
153 Values of -1 define missing bounds, thus setting a range (-1,-1)
154 (the default) removes the size limit.
156 void SetItemSizeRange (sal_uInt16 nId, const Range& rRange);
157 /** Return the current size limits for the specified item.
159 long GetItemSize( sal_uInt16 nId, SplitWindowItemFlags nBits ) const;
160 sal_uInt16 GetSet( sal_uInt16 nId ) const;
161 sal_uInt16 GetItemId( vcl::Window* pWindow ) const;
162 sal_uInt16 GetItemId( const Point& rPos ) const;
163 sal_uInt16 GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const;
164 sal_uInt16 GetItemId( sal_uInt16 nPos ) const;
165 sal_uInt16 GetItemCount( sal_uInt16 nSetId = 0 ) const;
166 bool IsItemValid( sal_uInt16 nId ) const;
168 void SetAlign( WindowAlign eNewAlign );
169 WindowAlign GetAlign() const { return meAlign; }
170 bool IsHorizontal() const { return mbHorz; }
172 void SetMaxSizePixel( long nNewMaxSize ) { mnMaxSize = nNewMaxSize; }
174 Size CalcLayoutSizePixel( const Size& aNewSize );
176 void ShowFadeInHideButton();
177 void ShowFadeOutButton();
178 long GetFadeInSize() const;
179 bool IsFadeNoButtonMode() const { return mbFadeNoButtonMode; }
181 void SetSplitHdl( const Link<SplitWindow*,void>& rLink ) { maSplitHdl = rLink; }
184 #endif // INCLUDED_VCL_SPLITWIN_HXX
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */