LibreOffice Module basctl (master) 1
layout.hxx
Go to the documentation of this file.
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#pragma once
21
22#include "bastypes.hxx"
23#include <vcl/split.hxx>
24#include <vcl/vclptr.hxx>
25
26#include <vector>
27
28class DockingWindow;
29class SfxRequest;
30class SfxItemSet;
31
32namespace basctl
33{
34class DockingWindow;
35class BaseWindow;
36
37// Layout -- the common base of ModulLayout and DialogLayout.
38// Handles the splitting lines and the dockable windows.
39
40class Layout : public vcl::Window
41{
42public:
43 void ArrangeWindows();
44
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;
50
51 virtual ~Layout() override;
52 virtual void dispose() override;
53
54protected:
55 explicit Layout(vcl::Window* pParent);
56
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; }
61
62 // Window:
63 virtual void Resize() override;
64 virtual void DataChanged(DataChangedEvent const& rDCEvt) override;
65 // new:
66 virtual void OnFirstSize(tools::Long nWidth, tools::Long nHeight) = 0;
67
68private:
69 // the main child window (either ModulWindow or DialogWindow)
71
72 // when this window has at first (nonempty) size
74
75 // horizontal or vertical split strip
77 {
78 public:
79 enum class Side
80 {
81 Left,
82 Bottom
83 };
85 void Add(DockingWindow*, Size const&);
86 void Remove(DockingWindow*);
87 bool IsEmpty() const;
88 tools::Long GetSize() const;
89 void ArrangeIn(tools::Rectangle const&);
90 void dispose();
91
92 private:
93 // the layout window
95 // horizontal or vertical strip?
97 // lower (top or left) or higher (bottom or right) strip?
98 bool bLower;
99 // rectangle to move in
101 // size (width or height)
103 // the main splitting line
105 // the dockable windows (and some data)
106 struct Item
107 {
108 // pointer to the dockable window
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.
116 // splitter line window before the window
117 // (the first one is always nullptr)
119 };
120 std::vector<Item> vItems;
121
124 static bool IsDocking(DockingWindow const&);
125 DECL_LINK(SplitHdl, Splitter*, void);
127 void InitSplitter(Splitter&);
129};
130
131} // namespace basctl
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle aRect
Definition: layout.hxx:100
void Add(DockingWindow *, Size const &)
Definition: layout.cxx:187
std::vector< Item > vItems
Definition: layout.hxx:120
Point MakePoint(tools::Long, tools::Long) const
Definition: layout.cxx:236
tools::Long GetSize() const
Definition: layout.cxx:257
VclPtr< Splitter > aSplitter
Definition: layout.hxx:104
DECL_LINK(SplitHdl, Splitter *, void)
void Remove(DockingWindow *)
Definition: layout.cxx:212
static bool IsDocking(DockingWindow const &)
Definition: layout.cxx:242
void ArrangeIn(tools::Rectangle const &)
Definition: layout.cxx:264
void InitSplitter(Splitter &)
Definition: layout.cxx:417
SplittedSide(Layout *, Side)
Definition: layout.cxx:166
Size MakeSize(tools::Long, tools::Long) const
Definition: layout.cxx:232
void CheckMarginsFor(Splitter *)
Definition: layout.cxx:395
virtual void DataChanged(DataChangedEvent const &rDCEvt) override
Definition: layout.cxx:135
virtual void Resize() override
Definition: layout.cxx:76
class basctl::Layout::SplittedSide aLeftSide
virtual ~Layout() override
Definition: layout.cxx:55
void Remove(DockingWindow *)
Definition: layout.cxx:69
class basctl::Layout::SplittedSide aBottomSide
virtual void dispose() override
Definition: layout.cxx:60
virtual void GetState(SfxItemSet &, unsigned nWhich)=0
void AddToLeft(DockingWindow *pWin, Size const &rSize)
Definition: layout.hxx:57
Layout(vcl::Window *pParent)
Definition: layout.cxx:37
virtual void ExecuteGlobal(SfxRequest &)
Definition: layout.hxx:47
virtual void UpdateDebug(bool bBasicStopped)=0
bool HasSize() const
Definition: layout.hxx:60
virtual void OnFirstSize(tools::Long nWidth, tools::Long nHeight)=0
VclPtr< BaseWindow > pChild
Definition: layout.hxx:70
virtual void Deactivating()
Definition: layout.cxx:126
virtual void Activating(BaseWindow &)
Definition: layout.cxx:117
void AddToBottom(DockingWindow *pWin, Size const &rSize)
Definition: layout.hxx:58
bool bFirstSize
Definition: layout.hxx:73
void ArrangeWindows()
Definition: layout.cxx:83
long Long
VclPtr< DockingWindow > pWin
Definition: layout.hxx:109
Left