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