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 BASCTL_LAYOUT_HXX
21 : #define BASCTL_LAYOUT_HXX
22 :
23 : #include <vcl/window.hxx>
24 : #include <vcl/split.hxx>
25 : #include <unotools/options.hxx>
26 :
27 : #include <vector>
28 : #include <boost/shared_ptr.hpp>
29 :
30 : class DockingWindow;
31 : class SfxRequest;
32 : class SfxItemSet;
33 :
34 : namespace basctl
35 : {
36 :
37 : class DockingWindow;
38 : class BaseWindow;
39 :
40 :
41 : // Layout -- the common base of ModulLayout and DialogLayout.
42 : // Handles the splitting lines and the dockable windows.
43 :
44 : class Layout: public Window
45 : {
46 : public:
47 : void DockaWindow (DockingWindow*);
48 : void ArrangeWindows ();
49 :
50 : virtual void Activating (BaseWindow&);
51 : virtual void Deactivating ();
52 0 : virtual void ExecuteGlobal (SfxRequest&) { }
53 : virtual void GetState (SfxItemSet&, unsigned nWhich) = 0;
54 : virtual void UpdateDebug (bool bBasicStopped ) = 0;
55 :
56 : protected:
57 : Layout (Window* pParent);
58 : virtual ~Layout ();
59 :
60 0 : void AddToLeft (DockingWindow* pWin, Size const& rSize) { aLeftSide.Add(pWin, rSize); }
61 0 : void AddToBottom (DockingWindow* pWin, Size const& rSize) { aBottomSide.Add(pWin, rSize); }
62 : void Remove (DockingWindow*);
63 0 : bool HasSize () const { return !bFirstSize; }
64 :
65 : protected:
66 : // Window:
67 : virtual void Resize () SAL_OVERRIDE;
68 : virtual void DataChanged (DataChangedEvent const& rDCEvt) SAL_OVERRIDE;
69 : // new:
70 : virtual void OnFirstSize (long nWidth, long nHeight) = 0;
71 :
72 : private:
73 : // the main child window (either ModulWindow or DialogWindow)
74 : BaseWindow* pChild;
75 :
76 : // when this window has at first (nonempty) size
77 : bool bFirstSize;
78 :
79 : // horizontal or vertical splitted strip
80 0 : class SplittedSide
81 : {
82 : public:
83 : enum Side {Right, Top, Left, Bottom};
84 : SplittedSide (Layout*, Side);
85 : void Add (DockingWindow*, Size const&);
86 : void Remove (DockingWindow*);
87 : bool IsEmpty () const;
88 : long GetSize () const;
89 : void ArrangeIn (Rectangle const&);
90 :
91 : private:
92 : // the layout window
93 : Layout& rLayout;
94 : // horizontal or vertical strip?
95 : bool bVertical;
96 : // lower (top or left) or higher (bottom or right) strip?
97 : bool bLower;
98 : // rectangle to move in
99 : Rectangle aRect;
100 : // size (width or height)
101 : long nSize;
102 : // the main splitting line
103 : Splitter aSplitter;
104 : // the dockable windows (and some data)
105 0 : struct Item
106 : {
107 : // pointer to the dockable window
108 : DockingWindow* pWin;
109 : // starting and ending position in the strip
110 : // They may be different from the actual window position, because
111 : // the window may fill the space of the adjacent currently
112 : // non-docking windows, but this change is not stored in these
113 : // variables. These change only when the splitter lines are moved.
114 : long nStartPos, nEndPos;
115 : // splitter line window before the window
116 : // (the first one is always nullptr)
117 : boost::shared_ptr<Splitter> pSplit;
118 : };
119 : std::vector<Item> vItems;
120 : private:
121 : Point MakePoint (long, long) const;
122 : Size MakeSize (long, long) const;
123 : private:
124 : static bool IsDocking (DockingWindow const&);
125 : private:
126 : DECL_LINK(SplitHdl, Splitter*);
127 : void CheckMarginsFor (Splitter*);
128 : void InitSplitter (Splitter&);
129 : } aLeftSide, aBottomSide;
130 : };
131 :
132 : } // namespace basctl
133 :
134 : #endif // BASCTL_LAYOUT_HXX
135 :
136 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|