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