Update ooo320-m1
[ooovba.git] / toolkit / source / awt / vclxtabpage.cxx
blob6d71427c0bca0b33319f00871c26666e92ea4528
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile$
7 * $Revision$
9 * last change: $Author$ $Date$
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston,
32 * MA 02110-1301 USA
34 ************************************************************************/
36 #include "vclxtabpage.hxx"
37 #include "forward.hxx"
39 #include <com/sun/star/awt/PosSize.hpp>
40 #include <toolkit/helper/convert.hxx>
41 #include <vcl/tabpage.hxx>
42 #include <vcl/tabctrl.hxx>
44 #if !defined (__GNUC__)
45 #define __PRETTY_FUNCTION__ __FUNCTION__
46 #endif /* !__GNUC__ */
48 namespace layoutimpl
51 using namespace ::com::sun::star;
53 // XInterface
54 IMPLEMENT_FORWARD_XINTERFACE2( VCLXTabPage, VCLXWindow, Bin );
56 // XTypeProvider
57 IMPLEMENT_FORWARD_XTYPEPROVIDER1( VCLXTabPage, VCLXWindow );
59 VCLXTabPage::VCLXTabPage( Window *p )
60 : VCLXWindow()
61 , Bin()
62 , bRealized( false )
64 /* FIXME: before Window is set, setLabel, setProperty->setImage
65 * are silent no-ops. */
66 p->SetComponentInterface( this );
69 VCLXTabPage::~VCLXTabPage()
73 void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException)
76 ::vos::OGuard aGuard( GetMutex() );
78 lang::EventObject aDisposeEvent;
79 aDisposeEvent.Source = W3K_EXPLICIT_CAST (*this);
82 VCLXWindow::dispose();
85 void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area )
86 throw (uno::RuntimeException)
88 awt::Size currentSize = getSize();
89 awt::Size requestedSize = getMinimumSize();
90 requestedSize.Height = getHeightForWidth( area.Width );
92 if ( currentSize.Width > 0 && currentSize.Height > 0
93 && requestedSize.Width > currentSize.Width )
94 requestedSize.Width = currentSize.Width;
95 if ( currentSize.Width > 0 && currentSize.Height > 0
96 && requestedSize.Height > currentSize.Height )
97 requestedSize.Height = currentSize.Height;
99 // FIXME: missing destructor?
100 if ( !GetWindow() )
101 return;
103 Size windowSize = GetWindow()->GetSizePixel();
104 Window *parent = GetWindow()->GetParent();
105 Size parentSize = parent->GetSizePixel();
107 Point pos = GetWindow()->GetPosPixel();
108 #ifndef __SUNPRO_CC
109 OSL_TRACE ("\n%s", __PRETTY_FUNCTION__);
110 OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() );
112 OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height );
113 OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height );
114 OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height );
115 OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() );
116 OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() );
117 #endif
119 #if 0
120 if (requestedSize.Width > parentSize.Width ()
121 || requestedSize.Height > parentSize.Height ())
123 #ifndef __SUNPRO_CC
124 OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height );
125 #endif
126 parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) );
128 if (Window *grand_parent = parent->GetParent ())
129 grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) );
131 #endif
133 if ( !bRealized )
135 setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE );
136 bRealized = true;
138 else
140 if ( requestedSize.Width > currentSize.Width + 10)
141 setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH );
142 if ( requestedSize.Height > currentSize.Height + 10)
143 setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT );
146 awt::Size newSize = getSize();
147 #ifndef __SUNPRO_CC
148 OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height );
149 #endif
150 maAllocation.Width = newSize.Width;
151 maAllocation.Height = newSize.Height;
153 Bin::allocateArea( maAllocation );
156 awt::Size SAL_CALL VCLXTabPage::getMinimumSize()
157 throw(uno::RuntimeException)
159 ::vos::OGuard aGuard( GetMutex() );
161 return Bin::getMinimumSize();
164 } // namespace layoutimpl