1*5b190011SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*5b190011SAndrew Rist * distributed with this work for additional information
6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance
9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at
10*5b190011SAndrew Rist *
11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*5b190011SAndrew Rist *
13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*5b190011SAndrew Rist * software distributed under the License is distributed on an
15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the
17*5b190011SAndrew Rist * specific language governing permissions and limitations
18*5b190011SAndrew Rist * under the License.
19*5b190011SAndrew Rist *
20*5b190011SAndrew Rist *************************************************************/
21*5b190011SAndrew Rist
22*5b190011SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sd.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "GraphicViewShell.hxx"
28cdf0e10cSrcweir #include "LayerTabBar.hxx"
29cdf0e10cSrcweir #include "FrameView.hxx"
30cdf0e10cSrcweir #include <sfx2/objsh.hxx>
31cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
32cdf0e10cSrcweir #include <vcl/scrbar.hxx>
33cdf0e10cSrcweir #include <vcl/salbtype.hxx> // FRound
34cdf0e10cSrcweir
35cdf0e10cSrcweir namespace sd {
36cdf0e10cSrcweir
37cdf0e10cSrcweir static const int TABCONTROL_INITIAL_SIZE = 350;
38cdf0e10cSrcweir
39cdf0e10cSrcweir /*************************************************************************
40cdf0e10cSrcweir |*
41cdf0e10cSrcweir |* Standard-Konstruktor
42cdf0e10cSrcweir |*
43cdf0e10cSrcweir \************************************************************************/
44cdf0e10cSrcweir
GraphicViewShell(SfxViewFrame * pFrame,ViewShellBase & rViewShellBase,::Window * pParentWindow,FrameView * pFrameView)45cdf0e10cSrcweir GraphicViewShell::GraphicViewShell (
46cdf0e10cSrcweir SfxViewFrame* pFrame,
47cdf0e10cSrcweir ViewShellBase& rViewShellBase,
48cdf0e10cSrcweir ::Window* pParentWindow,
49cdf0e10cSrcweir FrameView* pFrameView)
50cdf0e10cSrcweir : DrawViewShell (
51cdf0e10cSrcweir pFrame,
52cdf0e10cSrcweir rViewShellBase,
53cdf0e10cSrcweir pParentWindow,
54cdf0e10cSrcweir PK_STANDARD,
55cdf0e10cSrcweir pFrameView)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir ConstructGraphicViewShell();
58cdf0e10cSrcweir }
59cdf0e10cSrcweir
~GraphicViewShell(void)60cdf0e10cSrcweir GraphicViewShell::~GraphicViewShell (void)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir
64cdf0e10cSrcweir
65cdf0e10cSrcweir
66cdf0e10cSrcweir
ConstructGraphicViewShell(void)67cdf0e10cSrcweir void GraphicViewShell::ConstructGraphicViewShell(void)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir meShellType = ST_DRAW;
70cdf0e10cSrcweir
71cdf0e10cSrcweir mpLayerTabBar.reset (new LayerTabBar(this,GetParentWindow()));
72cdf0e10cSrcweir mpLayerTabBar->SetSplitHdl(LINK(this,GraphicViewShell,TabBarSplitHandler));
73cdf0e10cSrcweir
74cdf0e10cSrcweir // pb: #i67363# no layer tabbar on preview mode
75cdf0e10cSrcweir if ( !GetObjectShell()->IsPreview() )
76cdf0e10cSrcweir mpLayerTabBar->Show();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir
79cdf0e10cSrcweir
80cdf0e10cSrcweir
81cdf0e10cSrcweir
ChangeEditMode(EditMode eMode,bool)82cdf0e10cSrcweir void GraphicViewShell::ChangeEditMode (
83cdf0e10cSrcweir EditMode eMode,
84cdf0e10cSrcweir bool )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir // There is no page tab that could be shown instead of the layer tab.
87cdf0e10cSrcweir // Therefore we have it allways visible regardless of what the caller
88cdf0e10cSrcweir // said. (We have to change the callers behaviour, of course.)
89cdf0e10cSrcweir DrawViewShell::ChangeEditMode (eMode, true);
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir
93cdf0e10cSrcweir
94cdf0e10cSrcweir
ArrangeGUIElements(void)95cdf0e10cSrcweir void GraphicViewShell::ArrangeGUIElements (void)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
98cdf0e10cSrcweir {
99cdf0e10cSrcweir Size aSize = mpLayerTabBar->GetSizePixel();
100cdf0e10cSrcweir const Size aFrameSize (
101cdf0e10cSrcweir GetViewFrame()->GetWindow().GetOutputSizePixel());
102cdf0e10cSrcweir
103cdf0e10cSrcweir if (aSize.Width() == 0)
104cdf0e10cSrcweir {
105cdf0e10cSrcweir if (mpFrameView->GetTabCtrlPercent() == 0.0)
106cdf0e10cSrcweir aSize.Width() = TABCONTROL_INITIAL_SIZE;
107cdf0e10cSrcweir else
108cdf0e10cSrcweir aSize.Width() = FRound(aFrameSize.Width()
109cdf0e10cSrcweir * mpFrameView->GetTabCtrlPercent());
110cdf0e10cSrcweir }
111cdf0e10cSrcweir aSize.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
112cdf0e10cSrcweir .GetScrollBarSize();
113cdf0e10cSrcweir
114cdf0e10cSrcweir Point aPos (0, maViewSize.Height() - aSize.Height());
115cdf0e10cSrcweir
116cdf0e10cSrcweir mpLayerTabBar->SetPosSizePixel (aPos, aSize);
117cdf0e10cSrcweir
118cdf0e10cSrcweir if (aFrameSize.Width() > 0)
119cdf0e10cSrcweir mpFrameView->SetTabCtrlPercent (
120cdf0e10cSrcweir (double) maTabControl.GetSizePixel().Width()
121cdf0e10cSrcweir / aFrameSize.Width());
122cdf0e10cSrcweir else
123cdf0e10cSrcweir mpFrameView->SetTabCtrlPercent( 0.0 );
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir DrawViewShell::ArrangeGUIElements();
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir
130cdf0e10cSrcweir
131cdf0e10cSrcweir
IMPL_LINK(GraphicViewShell,TabBarSplitHandler,TabBar *,pTabBar)132cdf0e10cSrcweir IMPL_LINK(GraphicViewShell, TabBarSplitHandler, TabBar*, pTabBar)
133cdf0e10cSrcweir {
134cdf0e10cSrcweir const long int nMax = maViewSize.Width()
135cdf0e10cSrcweir - maScrBarWH.Width()
136cdf0e10cSrcweir - pTabBar->GetPosPixel().X();
137cdf0e10cSrcweir
138cdf0e10cSrcweir Size aTabSize = pTabBar->GetSizePixel();
139cdf0e10cSrcweir aTabSize.Width() = Min(pTabBar->GetSplitSize(), (long)(nMax-1));
140cdf0e10cSrcweir
141cdf0e10cSrcweir pTabBar->SetSizePixel (aTabSize);
142cdf0e10cSrcweir
143cdf0e10cSrcweir Point aPos = pTabBar->GetPosPixel();
144cdf0e10cSrcweir aPos.X() += aTabSize.Width();
145cdf0e10cSrcweir
146cdf0e10cSrcweir Size aScrSize (nMax - aTabSize.Width(), maScrBarWH.Height());
147cdf0e10cSrcweir mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
148cdf0e10cSrcweir
149cdf0e10cSrcweir return 0;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
152cdf0e10cSrcweir } // end of namespace sd
153