1*b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b0724fc6SAndrew Rist * distributed with this work for additional information 6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17*b0724fc6SAndrew Rist * specific language governing permissions and limitations 18*b0724fc6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b0724fc6SAndrew Rist *************************************************************/ 21*b0724fc6SAndrew Rist 22*b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "vclxtabpage.hxx" 25cdf0e10cSrcweir #include "forward.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 28cdf0e10cSrcweir #include <toolkit/helper/convert.hxx> 29cdf0e10cSrcweir #include <vcl/tabpage.hxx> 30cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #if !defined (__GNUC__) 33cdf0e10cSrcweir #define __PRETTY_FUNCTION__ __FUNCTION__ 34cdf0e10cSrcweir #endif /* !__GNUC__ */ 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace layoutimpl 37cdf0e10cSrcweir { 38cdf0e10cSrcweir 39cdf0e10cSrcweir using namespace ::com::sun::star; 40cdf0e10cSrcweir 41cdf0e10cSrcweir // XInterface 42cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin ); 43cdf0e10cSrcweir 44cdf0e10cSrcweir // XTypeProvider 45cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow ); 46cdf0e10cSrcweir 47cdf0e10cSrcweir VCLXTabPage::VCLXTabPage( Window *p ) 48cdf0e10cSrcweir : VCLXWindow() 49cdf0e10cSrcweir , Bin() 50cdf0e10cSrcweir , bRealized( false ) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir /* FIXME: before Window is set, setLabel, setProperty->setImage 53cdf0e10cSrcweir * are silent no-ops. */ 54cdf0e10cSrcweir p->SetComponentInterface( this ); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir 57cdf0e10cSrcweir VCLXTabPage::~VCLXTabPage() 58cdf0e10cSrcweir { 59cdf0e10cSrcweir } 60cdf0e10cSrcweir 61cdf0e10cSrcweir void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir { 64cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir lang::EventObject aDisposeEvent; 67cdf0e10cSrcweir aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir VCLXWindow::dispose(); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area ) 74cdf0e10cSrcweir throw (uno::RuntimeException) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir awt::Size currentSize = getSize(); 77cdf0e10cSrcweir awt::Size requestedSize = getMinimumSize(); 78cdf0e10cSrcweir requestedSize.Height = getHeightForWidth( area.Width ); 79cdf0e10cSrcweir 80cdf0e10cSrcweir if ( currentSize.Width > 0 && currentSize.Height > 0 81cdf0e10cSrcweir && requestedSize.Width > currentSize.Width ) 82cdf0e10cSrcweir requestedSize.Width = currentSize.Width; 83cdf0e10cSrcweir if ( currentSize.Width > 0 && currentSize.Height > 0 84cdf0e10cSrcweir && requestedSize.Height > currentSize.Height ) 85cdf0e10cSrcweir requestedSize.Height = currentSize.Height; 86cdf0e10cSrcweir 87cdf0e10cSrcweir // FIXME: missing destructor? 88cdf0e10cSrcweir if ( !GetWindow() ) 89cdf0e10cSrcweir return; 90cdf0e10cSrcweir 91cdf0e10cSrcweir Size windowSize = GetWindow()->GetSizePixel(); 92cdf0e10cSrcweir Window *parent = GetWindow()->GetParent(); 93cdf0e10cSrcweir Size parentSize = parent->GetSizePixel(); 94cdf0e10cSrcweir 95cdf0e10cSrcweir Point pos = GetWindow()->GetPosPixel(); 96cdf0e10cSrcweir #ifndef __SUNPRO_CC 97cdf0e10cSrcweir OSL_TRACE ("\n%s", __PRETTY_FUNCTION__); 98cdf0e10cSrcweir OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() ); 99cdf0e10cSrcweir 100cdf0e10cSrcweir OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height ); 101cdf0e10cSrcweir OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height ); 102cdf0e10cSrcweir OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 103cdf0e10cSrcweir OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() ); 104cdf0e10cSrcweir OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() ); 105cdf0e10cSrcweir #endif 106cdf0e10cSrcweir 107cdf0e10cSrcweir #if 0 108cdf0e10cSrcweir if (requestedSize.Width > parentSize.Width () 109cdf0e10cSrcweir || requestedSize.Height > parentSize.Height ()) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir #ifndef __SUNPRO_CC 112cdf0e10cSrcweir OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height ); 113cdf0e10cSrcweir #endif 114cdf0e10cSrcweir parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir if (Window *grand_parent = parent->GetParent ()) 117cdf0e10cSrcweir grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) ); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir #endif 120cdf0e10cSrcweir 121cdf0e10cSrcweir if ( !bRealized ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE ); 124cdf0e10cSrcweir bRealized = true; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir else 127cdf0e10cSrcweir { 128cdf0e10cSrcweir if ( requestedSize.Width > currentSize.Width + 10) 129cdf0e10cSrcweir setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH ); 130cdf0e10cSrcweir if ( requestedSize.Height > currentSize.Height + 10) 131cdf0e10cSrcweir setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT ); 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir awt::Size newSize = getSize(); 135cdf0e10cSrcweir #ifndef __SUNPRO_CC 136cdf0e10cSrcweir OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height ); 137cdf0e10cSrcweir #endif 138cdf0e10cSrcweir maAllocation.Width = newSize.Width; 139cdf0e10cSrcweir maAllocation.Height = newSize.Height; 140cdf0e10cSrcweir 141cdf0e10cSrcweir Bin::allocateArea( maAllocation ); 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir awt::Size SAL_CALL VCLXTabPage::getMinimumSize() 145cdf0e10cSrcweir throw(uno::RuntimeException) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir ::vos::OGuard aGuard( GetMutex() ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir return Bin::getMinimumSize(); 150cdf0e10cSrcweir } 151cdf0e10cSrcweir 152cdf0e10cSrcweir } // namespace layoutimpl 153