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