1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include "vclxtabpage.hxx" 29*cdf0e10cSrcweir #include "forward.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 32*cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 33*cdf0e10cSrcweir #include <vcl/tabpage.hxx> 34*cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #if !defined (__GNUC__) 37*cdf0e10cSrcweir #define __PRETTY_FUNCTION__ __FUNCTION__ 38*cdf0e10cSrcweir #endif /* !__GNUC__ */ 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir namespace layoutimpl 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir using namespace ::com::sun::star; 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir // XInterface 46*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin ); 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // XTypeProvider 49*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow ); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir VCLXTabPage::VCLXTabPage( Window *p ) 52*cdf0e10cSrcweir : VCLXWindow() 53*cdf0e10cSrcweir , Bin() 54*cdf0e10cSrcweir , bRealized( false ) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir /* FIXME: before Window is set, setLabel, setProperty->setImage 57*cdf0e10cSrcweir * are silent no-ops. */ 58*cdf0e10cSrcweir p->SetComponentInterface( this ); 59*cdf0e10cSrcweir } 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir VCLXTabPage::~VCLXTabPage() 62*cdf0e10cSrcweir { 63*cdf0e10cSrcweir } 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException) 66*cdf0e10cSrcweir { 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir lang::EventObject aDisposeEvent; 71*cdf0e10cSrcweir aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir VCLXWindow::dispose(); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area ) 78*cdf0e10cSrcweir throw (uno::RuntimeException) 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir awt::Size currentSize = getSize(); 81*cdf0e10cSrcweir awt::Size requestedSize = getMinimumSize(); 82*cdf0e10cSrcweir requestedSize.Height = getHeightForWidth( area.Width ); 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir if ( currentSize.Width > 0 && currentSize.Height > 0 85*cdf0e10cSrcweir && requestedSize.Width > currentSize.Width ) 86*cdf0e10cSrcweir requestedSize.Width = currentSize.Width; 87*cdf0e10cSrcweir if ( currentSize.Width > 0 && currentSize.Height > 0 88*cdf0e10cSrcweir && requestedSize.Height > currentSize.Height ) 89*cdf0e10cSrcweir requestedSize.Height = currentSize.Height; 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // FIXME: missing destructor? 92*cdf0e10cSrcweir if ( !GetWindow() ) 93*cdf0e10cSrcweir return; 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir Size windowSize = GetWindow()->GetSizePixel(); 96*cdf0e10cSrcweir Window *parent = GetWindow()->GetParent(); 97*cdf0e10cSrcweir Size parentSize = parent->GetSizePixel(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir Point pos = GetWindow()->GetPosPixel(); 100*cdf0e10cSrcweir #ifndef __SUNPRO_CC 101*cdf0e10cSrcweir OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); 102*cdf0e10cSrcweir OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() ); 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height ); 105*cdf0e10cSrcweir OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height ); 106*cdf0e10cSrcweir OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 107*cdf0e10cSrcweir OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() ); 108*cdf0e10cSrcweir OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() ); 109*cdf0e10cSrcweir #endif 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir #if 0 112*cdf0e10cSrcweir if (requestedSize.Width > parentSize.Width () 113*cdf0e10cSrcweir || requestedSize.Height > parentSize.Height ()) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir #ifndef __SUNPRO_CC 116*cdf0e10cSrcweir OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 117*cdf0e10cSrcweir #endif 118*cdf0e10cSrcweir parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir if (Window *grand_parent = parent->GetParent ()) 121*cdf0e10cSrcweir grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir #endif 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if ( !bRealized ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE ); 128*cdf0e10cSrcweir bRealized = true; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir else 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir if ( requestedSize.Width > currentSize.Width + 10) 133*cdf0e10cSrcweir setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH ); 134*cdf0e10cSrcweir if ( requestedSize.Height > currentSize.Height + 10) 135*cdf0e10cSrcweir setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT ); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir awt::Size newSize = getSize(); 139*cdf0e10cSrcweir #ifndef __SUNPRO_CC 140*cdf0e10cSrcweir OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height ); 141*cdf0e10cSrcweir #endif 142*cdf0e10cSrcweir maAllocation.Width = newSize.Width; 143*cdf0e10cSrcweir maAllocation.Height = newSize.Height; 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir Bin::allocateArea( maAllocation ); 146*cdf0e10cSrcweir } 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir awt::Size SAL_CALL VCLXTabPage::getMinimumSize() 149*cdf0e10cSrcweir throw(uno::RuntimeException) 150*cdf0e10cSrcweir { 151*cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir return Bin::getMinimumSize(); 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir } // namespace layoutimpl 157