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 :
21 : #include "GraphicViewShell.hxx"
22 : #include "LayerTabBar.hxx"
23 : #include "FrameView.hxx"
24 : #include <sfx2/objsh.hxx>
25 : #include <sfx2/viewfrm.hxx>
26 : #include <vcl/scrbar.hxx>
27 : #include <tools/helpers.hxx>
28 :
29 : namespace sd {
30 :
31 : static const int TABCONTROL_INITIAL_SIZE = 350;
32 :
33 :
34 52 : GraphicViewShell::GraphicViewShell (
35 : SfxViewFrame* pFrame,
36 : ViewShellBase& rViewShellBase,
37 : ::Window* pParentWindow,
38 : FrameView* pFrameView)
39 : : DrawViewShell (
40 : pFrame,
41 : rViewShellBase,
42 : pParentWindow,
43 : PK_STANDARD,
44 52 : pFrameView)
45 : {
46 52 : ConstructGraphicViewShell();
47 52 : }
48 :
49 104 : GraphicViewShell::~GraphicViewShell (void)
50 : {
51 104 : }
52 :
53 :
54 :
55 :
56 52 : void GraphicViewShell::ConstructGraphicViewShell(void)
57 : {
58 52 : meShellType = ST_DRAW;
59 :
60 52 : mpLayerTabBar.reset (new LayerTabBar(this,GetParentWindow()));
61 52 : mpLayerTabBar->SetSplitHdl(LINK(this,GraphicViewShell,TabBarSplitHandler));
62 :
63 : // pb: #i67363# no layer tabbar on preview mode
64 52 : if ( !GetObjectShell()->IsPreview() )
65 52 : mpLayerTabBar->Show();
66 52 : }
67 :
68 :
69 :
70 :
71 234 : void GraphicViewShell::ChangeEditMode (
72 : EditMode eMode,
73 : bool )
74 : {
75 : // There is no page tab that could be shown instead of the layer tab.
76 : // Therefore we have it always visible regardless of what the caller
77 : // said. (We have to change the callers behaviour, of course.)
78 234 : DrawViewShell::ChangeEditMode (eMode, true);
79 234 : }
80 :
81 :
82 :
83 :
84 156 : void GraphicViewShell::ArrangeGUIElements (void)
85 : {
86 156 : if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
87 : {
88 156 : Size aSize = mpLayerTabBar->GetSizePixel();
89 : const Size aFrameSize (
90 156 : GetViewFrame()->GetWindow().GetOutputSizePixel());
91 :
92 156 : if (aSize.Width() == 0)
93 : {
94 52 : if (mpFrameView->GetTabCtrlPercent() == 0.0)
95 52 : aSize.Width() = TABCONTROL_INITIAL_SIZE;
96 : else
97 0 : aSize.Width() = FRound(aFrameSize.Width()
98 0 : * mpFrameView->GetTabCtrlPercent());
99 : }
100 156 : aSize.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
101 156 : .GetScrollBarSize();
102 :
103 156 : Point aPos (0, maViewSize.Height() - aSize.Height());
104 :
105 156 : mpLayerTabBar->SetPosSizePixel (aPos, aSize);
106 :
107 156 : if (aFrameSize.Width() > 0)
108 : mpFrameView->SetTabCtrlPercent (
109 312 : (double) maTabControl.GetSizePixel().Width()
110 156 : / aFrameSize.Width());
111 : else
112 0 : mpFrameView->SetTabCtrlPercent( 0.0 );
113 : }
114 :
115 156 : DrawViewShell::ArrangeGUIElements();
116 156 : }
117 :
118 :
119 :
120 :
121 0 : IMPL_LINK(GraphicViewShell, TabBarSplitHandler, TabBar*, pTabBar)
122 : {
123 0 : const long int nMax = maViewSize.Width()
124 0 : - maScrBarWH.Width()
125 0 : - pTabBar->GetPosPixel().X();
126 :
127 0 : Size aTabSize = pTabBar->GetSizePixel();
128 0 : aTabSize.Width() = std::min(pTabBar->GetSplitSize(), (long)(nMax-1));
129 :
130 0 : pTabBar->SetSizePixel (aTabSize);
131 :
132 0 : Point aPos = pTabBar->GetPosPixel();
133 0 : aPos.X() += aTabSize.Width();
134 :
135 0 : Size aScrSize (nMax - aTabSize.Width(), maScrBarWH.Height());
136 0 : mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
137 :
138 0 : return 0;
139 : }
140 :
141 33 : } // end of namespace sd
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|