tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / basctl / source / inc / layout.hxx
blob29b44896b331835b844f1ff95e6be63d2e1551d5
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 #pragma once
22 #include "bastypes.hxx"
23 #include <vcl/split.hxx>
24 #include <vcl/vclptr.hxx>
26 #include <vector>
28 class DockingWindow;
29 class SfxRequest;
30 class SfxItemSet;
32 namespace basctl
34 class DockingWindow;
35 class BaseWindow;
37 // Layout -- the common base of ModulLayout and DialogLayout.
38 // Handles the splitting lines and the dockable windows.
40 class Layout : public vcl::Window
42 public:
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;
54 protected:
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; }
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;
68 private:
69 // the main child window (either ModulWindow or DialogWindow)
70 VclPtr<BaseWindow> pChild;
72 // when this window has at first (nonempty) size
73 bool bFirstSize;
75 // horizontal or vertical split strip
76 class SplittedSide
78 public:
79 enum class Side
81 Left,
82 Bottom
84 SplittedSide(Layout*, Side);
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();
92 private:
93 // the layout window
94 Layout& rLayout;
95 // horizontal or vertical strip?
96 bool bVertical;
97 // lower (top or left) or higher (bottom or right) strip?
98 bool bLower;
99 // rectangle to move in
100 tools::Rectangle aRect;
101 // size (width or height)
102 tools::Long nSize;
103 // the main splitting line
104 VclPtr<Splitter> aSplitter;
105 // the dockable windows (and some data)
106 struct Item
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: */