summaryrefslogtreecommitdiff
path: root/basctl/source/basicide/layout.hxx
blob: 6adaeebde151dc85f8b5e0b8f93391670eec289a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef BASCTL_LAYOUT_HXX
#define BASCTL_LAYOUT_HXX

#include <vcl/window.hxx>
#include <vcl/split.hxx>
#include <unotools/options.hxx>

#include <vector>
#include <boost/shared_ptr.hpp>

class DockingWindow;
class SfxRequest;
class SfxItemSet;

namespace basctl
{

class DockingWindow;
class BaseWindow;

//
// Layout -- the common base of ModulLayout and DialogLayout.
// Handles the splitting lines and the dockable windows.
//
class Layout: public Window
{
public:
    void DockaWindow (DockingWindow*);
    void ArrangeWindows ();

    virtual void Activating (BaseWindow&);
    virtual void Deactivating ();
    virtual void GetState (SfxItemSet&, unsigned nWhich) = 0;
    virtual void UpdateDebug (bool bBasicStopped ) = 0;

protected:
    Layout (Window* pParent);
    virtual ~Layout ();

    void AddToLeft   (DockingWindow* pWin, Size const& rSize) { aLeftSide.Add(pWin, rSize); }
    void AddToBottom (DockingWindow* pWin, Size const& rSize) { aBottomSide.Add(pWin, rSize); }

protected:
    // Window:
    virtual void Resize ();
    virtual void DataChanged (DataChangedEvent const& rDCEvt);
    // new:
    virtual void OnFirstSize (int nWidth, int nHeight) = 0;

private:
    // the main child window (either ModulWindow or DialogWindow)
    BaseWindow* pChild;

    // when this window has at first (nonempty) size
    bool bFirstSize;

    // horizontal or vertical splitted strip
    class SplittedSide
    {
    public:
        enum Side {Right, Top, Left, Bottom};
        SplittedSide (Layout*, Side);
        void Add (DockingWindow*, Size const&);
        bool IsEmpty () const;
        int  GetSize () const;
        void ArrangeIn (Rectangle const&);

    private:
        // the layout window
        Layout& rLayout;
        // ArrangeIn() is called at first time?
        bool bFirstArrange;
        // horizontal or vertical strip?
        bool bVertical;
        // lower (top or left) or higher (bottom or right) strip?
        bool bLower;
        // rectangle to move in
        Rectangle aRect;
        // size (width or height)
        int nSize;
        // last position (between Add()s)
        int nLastPos;
        // the main splitting line
        Splitter aSplitter;
        // the dockable windows
        std::vector<DockingWindow*> vWindows;
        // splitting lines between the docking windows (vWindows.size() - 1)
        std::vector<boost::shared_ptr<Splitter> > vSplitters;

    private:
        Point MakePoint (int, int) const;
        Size MakeSize (int, int) const;
    private:
        DECL_LINK(SplitHdl, Splitter*);
        void CheckMarginsFor (Splitter*);
        void InitSplitter (Splitter&);
    } aLeftSide, aBottomSide;
};

} // namespace basctl

#endif // BASCTL_LAYOUT_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */