xref: /aoo41x/main/toolkit/source/awt/vclxtabpage.cxx (revision b0724fc6)
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 
VCLXTabPage(Window * p)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 
~VCLXTabPage()57 VCLXTabPage::~VCLXTabPage()
58 {
59 }
60 
dispose()61 void SAL_CALL VCLXTabPage::dispose() throw(uno::RuntimeException)
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 
allocateArea(awt::Rectangle const & area)73 void SAL_CALL VCLXTabPage::allocateArea( awt::Rectangle const& area )
74     throw (uno::RuntimeException)
75 {
76     awt::Size currentSize = getSize();
77     awt::Size requestedSize = getMinimumSize();
78     requestedSize.Height = getHeightForWidth( area.Width );
79 
80     if ( currentSize.Width > 0 && currentSize.Height > 0
81          && requestedSize.Width > currentSize.Width )
82         requestedSize.Width = currentSize.Width;
83     if ( currentSize.Width > 0 && currentSize.Height > 0
84          && requestedSize.Height > currentSize.Height )
85         requestedSize.Height = currentSize.Height;
86 
87     // FIXME: missing destructor?
88     if ( !GetWindow() )
89         return;
90 
91     Size windowSize = GetWindow()->GetSizePixel();
92     Window *parent = GetWindow()->GetParent();
93     Size parentSize = parent->GetSizePixel();
94 
95     Point pos = GetWindow()->GetPosPixel();
96 #ifndef __SUNPRO_CC
97     OSL_TRACE ("\n%s", __PRETTY_FUNCTION__);
98     OSL_TRACE ("%s: curpos: %d ,%d", __FUNCTION__, pos.X(), pos.Y() );
99 
100     OSL_TRACE ("%s: cursize: %d ,%d", __FUNCTION__, currentSize.Width, currentSize.Height );
101     OSL_TRACE ("%s: area: %d, %d", __FUNCTION__, area.Width, area.Height );
102     OSL_TRACE ("%s: requestedSize: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height );
103     OSL_TRACE ("%s: parent: %d, %d", __FUNCTION__, parentSize.Width(), parentSize.Height() );
104     OSL_TRACE ("%s: window: %d, %d", __FUNCTION__, windowSize.Width(), windowSize.Height() );
105 #endif
106 
107 #if 0
108     if (requestedSize.Width > parentSize.Width ()
109         || requestedSize.Height > parentSize.Height ())
110     {
111 #ifndef __SUNPRO_CC
112         OSL_TRACE ("%s: ***setting parent: %d, %d", __FUNCTION__, requestedSize.Width, requestedSize.Height );
113 #endif
114         parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) );
115 
116         if (Window *grand_parent = parent->GetParent ())
117             grand_parent->SetSizePixel ( Size (requestedSize.Width, requestedSize.Height) );
118     }
119 #endif
120 
121     if ( !bRealized )
122     {
123         setPosSize( area.X, area.Y, requestedSize.Width, requestedSize.Height, awt::PosSize::SIZE );
124         bRealized = true;
125     }
126     else
127     {
128         if ( requestedSize.Width > currentSize.Width + 10)
129             setPosSize( 0, 0, requestedSize.Width, 0, awt::PosSize::WIDTH );
130         if ( requestedSize.Height > currentSize.Height + 10)
131             setPosSize( 0, 0, 0, requestedSize.Height, awt::PosSize::HEIGHT );
132     }
133 
134     awt::Size newSize = getSize();
135 #ifndef __SUNPRO_CC
136     OSL_TRACE ("%s: newSize: %d, %d", __FUNCTION__, newSize.Width, newSize.Height );
137 #endif
138     maAllocation.Width = newSize.Width;
139     maAllocation.Height = newSize.Height;
140 
141     Bin::allocateArea( maAllocation );
142 }
143 
getMinimumSize()144 awt::Size SAL_CALL VCLXTabPage::getMinimumSize()
145     throw(uno::RuntimeException)
146 {
147     ::vos::OGuard aGuard( GetMutex() );
148 
149     return Bin::getMinimumSize();
150 }
151 
152 } // namespace layoutimpl
153