xref: /aoo41x/main/sd/source/ui/view/grviewsh.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
30 
31 #include "GraphicViewShell.hxx"
32 #include "LayerTabBar.hxx"
33 #include "FrameView.hxx"
34 #include <sfx2/objsh.hxx>
35 #include <sfx2/viewfrm.hxx>
36 #include <vcl/scrbar.hxx>
37 #include <vcl/salbtype.hxx>		// FRound
38 
39 namespace sd {
40 
41 static const int TABCONTROL_INITIAL_SIZE = 350;
42 
43 /*************************************************************************
44 |*
45 |* Standard-Konstruktor
46 |*
47 \************************************************************************/
48 
49 GraphicViewShell::GraphicViewShell (
50     SfxViewFrame* pFrame,
51     ViewShellBase& rViewShellBase,
52     ::Window* pParentWindow,
53     FrameView* pFrameView)
54     : DrawViewShell (
55         pFrame,
56         rViewShellBase,
57         pParentWindow,
58         PK_STANDARD,
59         pFrameView)
60 {
61 	ConstructGraphicViewShell();
62 }
63 
64 GraphicViewShell::~GraphicViewShell (void)
65 {
66 }
67 
68 
69 
70 
71 void GraphicViewShell::ConstructGraphicViewShell(void)
72 {
73     meShellType = ST_DRAW;
74 
75     mpLayerTabBar.reset (new LayerTabBar(this,GetParentWindow()));
76     mpLayerTabBar->SetSplitHdl(LINK(this,GraphicViewShell,TabBarSplitHandler));
77 
78     // pb: #i67363# no layer tabbar on preview mode
79     if ( !GetObjectShell()->IsPreview() )
80         mpLayerTabBar->Show();
81 }
82 
83 
84 
85 
86 void GraphicViewShell::ChangeEditMode (
87     EditMode eMode,
88     bool )
89 {
90     // There is no page tab that could be shown instead of the layer tab.
91     // Therefore we have it allways visible regardless of what the caller
92     // said. (We have to change the callers behaviour, of course.)
93     DrawViewShell::ChangeEditMode (eMode, true);
94 }
95 
96 
97 
98 
99 void GraphicViewShell::ArrangeGUIElements (void)
100 {
101     if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
102     {
103         Size aSize = mpLayerTabBar->GetSizePixel();
104         const Size aFrameSize (
105             GetViewFrame()->GetWindow().GetOutputSizePixel());
106 
107         if (aSize.Width() == 0)
108         {
109             if (mpFrameView->GetTabCtrlPercent() == 0.0)
110                 aSize.Width() = TABCONTROL_INITIAL_SIZE;
111             else
112                 aSize.Width() = FRound(aFrameSize.Width()
113                     * mpFrameView->GetTabCtrlPercent());
114         }
115         aSize.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
116             .GetScrollBarSize();
117 
118         Point aPos (0, maViewSize.Height() - aSize.Height());
119 
120         mpLayerTabBar->SetPosSizePixel (aPos, aSize);
121 
122         if (aFrameSize.Width() > 0)
123             mpFrameView->SetTabCtrlPercent (
124                 (double) maTabControl.GetSizePixel().Width()
125                 / aFrameSize.Width());
126         else
127             mpFrameView->SetTabCtrlPercent( 0.0 );
128     }
129 
130     DrawViewShell::ArrangeGUIElements();
131 }
132 
133 
134 
135 
136 IMPL_LINK(GraphicViewShell, TabBarSplitHandler, TabBar*, pTabBar)
137 {
138     const long int nMax = maViewSize.Width()
139         - maScrBarWH.Width()
140         - pTabBar->GetPosPixel().X();
141 
142 	Size aTabSize = pTabBar->GetSizePixel();
143 	aTabSize.Width() = Min(pTabBar->GetSplitSize(), (long)(nMax-1));
144 
145 	pTabBar->SetSizePixel (aTabSize);
146 
147 	Point aPos = pTabBar->GetPosPixel();
148 	aPos.X() += aTabSize.Width();
149 
150 	Size aScrSize (nMax - aTabSize.Width(), maScrBarWH.Height());
151 	mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
152 
153 	return 0;
154 }
155 
156 } // end of namespace sd
157