1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grviewsh.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #include "GraphicViewShell.hxx"
35 #include "LayerTabBar.hxx"
36 #include "FrameView.hxx"
37 #include <sfx2/objsh.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <vcl/scrbar.hxx>
40 #include <vcl/salbtype.hxx> // FRound
44 static const int TABCONTROL_INITIAL_SIZE
= 350;
46 /*************************************************************************
48 |* Standard-Konstruktor
50 \************************************************************************/
52 GraphicViewShell::GraphicViewShell (
54 ViewShellBase
& rViewShellBase
,
55 ::Window
* pParentWindow
,
56 FrameView
* pFrameView
)
64 ConstructGraphicViewShell();
67 /*************************************************************************
71 \************************************************************************/
73 GraphicViewShell::GraphicViewShell (
75 ::Window
* pParentWindow
,
76 const DrawViewShell
& rShell
)
77 : DrawViewShell (pFrame
, pParentWindow
, rShell
)
79 ConstructGraphicViewShell();
85 GraphicViewShell::~GraphicViewShell (void)
92 void GraphicViewShell::ConstructGraphicViewShell(void)
94 meShellType
= ST_DRAW
;
96 mpLayerTabBar
.reset (new LayerTabBar(this,GetParentWindow()));
97 mpLayerTabBar
->SetSplitHdl(LINK(this,GraphicViewShell
,TabBarSplitHandler
));
99 // pb: #i67363# no layer tabbar on preview mode
100 if ( !GetObjectShell()->IsPreview() )
101 mpLayerTabBar
->Show();
107 void GraphicViewShell::ChangeEditMode (
111 // There is no page tab that could be shown instead of the layer tab.
112 // Therefore we have it allways visible regardless of what the caller
113 // said. (We have to change the callers behaviour, of course.)
114 DrawViewShell::ChangeEditMode (eMode
, true);
120 void GraphicViewShell::ArrangeGUIElements (void)
122 if (mpLayerTabBar
.get()!=NULL
&& mpLayerTabBar
->IsVisible())
124 Size aSize
= mpLayerTabBar
->GetSizePixel();
125 const Size
aFrameSize (
126 GetViewFrame()->GetWindow().GetOutputSizePixel());
128 if (aSize
.Width() == 0)
130 if (mpFrameView
->GetTabCtrlPercent() == 0.0)
131 aSize
.Width() = TABCONTROL_INITIAL_SIZE
;
133 aSize
.Width() = FRound(aFrameSize
.Width()
134 * mpFrameView
->GetTabCtrlPercent());
136 aSize
.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
139 Point
aPos (0, maViewSize
.Height() - aSize
.Height());
141 mpLayerTabBar
->SetPosSizePixel (aPos
, aSize
);
143 if (aFrameSize
.Width() > 0)
144 mpFrameView
->SetTabCtrlPercent (
145 (double) maTabControl
.GetSizePixel().Width()
146 / aFrameSize
.Width());
148 mpFrameView
->SetTabCtrlPercent( 0.0 );
151 DrawViewShell::ArrangeGUIElements();
157 IMPL_LINK(GraphicViewShell
, TabBarSplitHandler
, TabBar
*, pTabBar
)
159 const long int nMax
= maViewSize
.Width()
161 - pTabBar
->GetPosPixel().X();
163 Size aTabSize
= pTabBar
->GetSizePixel();
164 aTabSize
.Width() = Min(pTabBar
->GetSplitSize(), (long)(nMax
-1));
166 pTabBar
->SetSizePixel (aTabSize
);
168 Point aPos
= pTabBar
->GetPosPixel();
169 aPos
.X() += aTabSize
.Width();
171 Size
aScrSize (nMax
- aTabSize
.Width(), maScrBarWH
.Height());
172 mpHorizontalScrollBar
->SetPosSizePixel(aPos
, aScrSize
);
177 } // end of namespace sd