1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include "bastypes.hxx"
23 #include <vcl/split.hxx>
24 #include <vcl/vclptr.hxx>
37 // Layout -- the common base of ModulLayout and DialogLayout.
38 // Handles the splitting lines and the dockable windows.
40 class Layout
: public vcl::Window
43 void ArrangeWindows();
45 virtual void Activating(BaseWindow
&);
46 virtual void Deactivating();
47 virtual void ExecuteGlobal(SfxRequest
&) {}
48 virtual void GetState(SfxItemSet
&, unsigned nWhich
) = 0;
49 virtual void UpdateDebug(bool bBasicStopped
) = 0;
51 virtual ~Layout() override
;
52 virtual void dispose() override
;
55 explicit Layout(vcl::Window
* pParent
);
57 void AddToLeft(DockingWindow
* pWin
, Size
const& rSize
) { aLeftSide
.Add(pWin
, rSize
); }
58 void AddToBottom(DockingWindow
* pWin
, Size
const& rSize
) { aBottomSide
.Add(pWin
, rSize
); }
59 void Remove(DockingWindow
*);
60 bool HasSize() const { return !bFirstSize
; }
63 virtual void Resize() override
;
64 virtual void DataChanged(DataChangedEvent
const& rDCEvt
) override
;
66 virtual void OnFirstSize(tools::Long nWidth
, tools::Long nHeight
) = 0;
69 // the main child window (either ModulWindow or DialogWindow)
70 VclPtr
<BaseWindow
> pChild
;
72 // when this window has at first (nonempty) size
75 // horizontal or vertical split strip
84 SplittedSide(Layout
*, Side
);
85 void Add(DockingWindow
*, Size
const&);
86 void Remove(DockingWindow
*);
88 tools::Long
GetSize() const;
89 void ArrangeIn(tools::Rectangle
const&);
95 // horizontal or vertical strip?
97 // lower (top or left) or higher (bottom or right) strip?
99 // rectangle to move in
100 tools::Rectangle aRect
;
101 // size (width or height)
103 // the main splitting line
104 VclPtr
<Splitter
> aSplitter
;
105 // the dockable windows (and some data)
108 // pointer to the dockable window
109 VclPtr
<DockingWindow
> pWin
;
110 // starting and ending position in the strip
111 // They may be different from the actual window position, because
112 // the window may fill the space of the adjacent currently
113 // non-docking windows, but this change is not stored in these
114 // variables. These change only when the splitter lines are moved.
115 tools::Long nStartPos
, nEndPos
;
116 // splitter line window before the window
117 // (the first one is always nullptr)
118 VclPtr
<Splitter
> pSplit
;
120 std::vector
<Item
> vItems
;
122 Point
MakePoint(tools::Long
, tools::Long
) const;
123 Size
MakeSize(tools::Long
, tools::Long
) const;
124 static bool IsDocking(DockingWindow
const&);
125 DECL_LINK(SplitHdl
, Splitter
*, void);
126 void CheckMarginsFor(Splitter
*);
127 void InitSplitter(Splitter
&);
128 } aLeftSide
, aBottomSide
;
131 } // namespace basctl
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */