update credits
[LibreOffice.git] / sd / source / ui / view / grviewsh.cxx
blob26279941d69c1515c43e557aec1cc63825195b97
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 .
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>
29 namespace sd {
31 static const int TABCONTROL_INITIAL_SIZE = 350;
34 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 pFrameView)
46 ConstructGraphicViewShell();
49 GraphicViewShell::~GraphicViewShell (void)
56 void GraphicViewShell::ConstructGraphicViewShell(void)
58 meShellType = ST_DRAW;
60 mpLayerTabBar.reset (new LayerTabBar(this,GetParentWindow()));
61 mpLayerTabBar->SetSplitHdl(LINK(this,GraphicViewShell,TabBarSplitHandler));
63 // pb: #i67363# no layer tabbar on preview mode
64 if ( !GetObjectShell()->IsPreview() )
65 mpLayerTabBar->Show();
71 void GraphicViewShell::ChangeEditMode (
72 EditMode eMode,
73 bool )
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 DrawViewShell::ChangeEditMode (eMode, true);
84 void GraphicViewShell::ArrangeGUIElements (void)
86 if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
88 Size aSize = mpLayerTabBar->GetSizePixel();
89 const Size aFrameSize (
90 GetViewFrame()->GetWindow().GetOutputSizePixel());
92 if (aSize.Width() == 0)
94 if (mpFrameView->GetTabCtrlPercent() == 0.0)
95 aSize.Width() = TABCONTROL_INITIAL_SIZE;
96 else
97 aSize.Width() = FRound(aFrameSize.Width()
98 * mpFrameView->GetTabCtrlPercent());
100 aSize.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
101 .GetScrollBarSize();
103 Point aPos (0, maViewSize.Height() - aSize.Height());
105 mpLayerTabBar->SetPosSizePixel (aPos, aSize);
107 if (aFrameSize.Width() > 0)
108 mpFrameView->SetTabCtrlPercent (
109 (double) maTabControl.GetSizePixel().Width()
110 / aFrameSize.Width());
111 else
112 mpFrameView->SetTabCtrlPercent( 0.0 );
115 DrawViewShell::ArrangeGUIElements();
121 IMPL_LINK(GraphicViewShell, TabBarSplitHandler, TabBar*, pTabBar)
123 const long int nMax = maViewSize.Width()
124 - maScrBarWH.Width()
125 - pTabBar->GetPosPixel().X();
127 Size aTabSize = pTabBar->GetSizePixel();
128 aTabSize.Width() = std::min(pTabBar->GetSplitSize(), (long)(nMax-1));
130 pTabBar->SetSizePixel (aTabSize);
132 Point aPos = pTabBar->GetPosPixel();
133 aPos.X() += aTabSize.Width();
135 Size aScrSize (nMax - aTabSize.Width(), maScrBarWH.Height());
136 mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
138 return 0;
141 } // end of namespace sd
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */