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 #include "vclxtabpage.hxx" 29 #include "forward.hxx" 30 31 #include <com/sun/star/awt/PosSize.hpp> 32 #include <toolkit/helper/convert.hxx> 33 #include <vcl/tabpage.hxx> 34 #include <vcl/tabctrl.hxx> 35 36 #if !defined (__GNUC__) 37 #define __PRETTY_FUNCTION__ __FUNCTION__ 38 #endif /* !__GNUC__ */ 39 40 namespace layoutimpl 41 { 42 43 using namespace ::com::sun::star; 44 45 // XInterface 46 IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin ); 47 48 // XTypeProvider 49 IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow ); 50 51 VCLXTabPage::VCLXTabPage( Window *p ) 52 : VCLXWindow() 53 , Bin() 54 , bRealized( false ) 55 { 56 /* FIXME: before Window is set, setLabel, setProperty->setImage 57 * are silent no-ops. */ 58 p->SetComponentInterface( this ); 59 } 60 61 VCLXTabPage::~VCLXTabPage() 62 { 63 } 64 65 void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException) 66 { 67 { 68 ::vos::OGuard aGuard( GetMutex() ); 69 70 lang::EventObject aDisposeEvent; 71 aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); 72 } 73 74 VCLXWindow::dispose(); 75 } 76 77 void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area ) 78 throw (uno::RuntimeException) 79 { 80 awt::Size currentSize = getSize(); 81 awt::Size requestedSize = getMinimumSize(); 82 requestedSize.Height = getHeightForWidth( area.Width ); 83 84 if ( currentSize.Width > 0 && currentSize.Height > 0 85 && requestedSize.Width > currentSize.Width ) 86 requestedSize.Width = currentSize.Width; 87 if ( currentSize.Width > 0 && currentSize.Height > 0 88 && requestedSize.Height > currentSize.Height ) 89 requestedSize.Height = currentSize.Height; 90 91 // FIXME: missing destructor? 92 if ( !GetWindow() ) 93 return; 94 95 Size windowSize = GetWindow()->GetSizePixel(); 96 Window *parent = GetWindow()->GetParent(); 97 Size parentSize = parent->GetSizePixel(); 98 99 Point pos = GetWindow()->GetPosPixel(); 100 #ifndef __SUNPRO_CC 101 OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); 102 OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() ); 103 104 OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height ); 105 OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height ); 106 OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 107 OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() ); 108 OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() ); 109 #endif 110 111 #if 0 112 if (requestedSize.Width > parentSize.Width () 113 || requestedSize.Height > parentSize.Height ()) 114 { 115 #ifndef __SUNPRO_CC 116 OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 117 #endif 118 parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 119 120 if (Window *grand_parent = parent->GetParent ()) 121 grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 122 } 123 #endif 124 125 if ( !bRealized ) 126 { 127 setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE ); 128 bRealized = true; 129 } 130 else 131 { 132 if ( requestedSize.Width > currentSize.Width + 10) 133 setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH ); 134 if ( requestedSize.Height > currentSize.Height + 10) 135 setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT ); 136 } 137 138 awt::Size newSize = getSize(); 139 #ifndef __SUNPRO_CC 140 OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height ); 141 #endif 142 maAllocation.Width = newSize.Width; 143 maAllocation.Height = newSize.Height; 144 145 Bin::allocateArea( maAllocation ); 146 } 147 148 awt::Size SAL_CALL VCLXTabPage::getMinimumSize() 149 throw(uno::RuntimeException) 150 { 151 ::vos::OGuard aGuard( GetMutex() ); 152 153 return Bin::getMinimumSize(); 154 } 155 156 } // namespace layoutimpl 157