1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabdlg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <vcl/fixed.hxx>
34 #include <vcl/tabctrl.hxx>
35 #include <vcl/tabdlg.hxx>
42 // =======================================================================
44 void TabDialog::ImplInitTabDialogData()
48 meViewAlign
= WINDOWALIGN_LEFT
;
52 // -----------------------------------------------------------------------
54 void TabDialog::ImplPosControls()
56 Size
aCtrlSize( IMPL_MINSIZE_BUTTON_WIDTH
, IMPL_MINSIZE_BUTTON_HEIGHT
);
59 TabControl
* pTabControl
= NULL
;
61 Window
* pChild
= GetWindow( WINDOW_FIRSTCHILD
);
64 if ( pChild
->IsVisible() && (pChild
!= mpViewWindow
) )
66 if ( pChild
->GetType() == WINDOW_TABCONTROL
)
67 pTabControl
= (TabControl
*)pChild
;
68 else if ( pTabControl
)
70 long nTxtWidth
= pChild
->GetCtrlTextWidth( pChild
->GetText() );
71 nTxtWidth
+= IMPL_EXTRA_BUTTON_WIDTH
;
72 if ( nTxtWidth
> aCtrlSize
.Width() )
73 aCtrlSize
.Width() = nTxtWidth
;
74 long nTxtHeight
= pChild
->GetTextHeight();
75 nTxtHeight
+= IMPL_EXTRA_BUTTON_HEIGHT
;
76 if ( nTxtHeight
> aCtrlSize
.Height() )
77 aCtrlSize
.Height() = nTxtHeight
;
82 long nHeight
= pChild
->GetSizePixel().Height();
83 if ( nHeight
> nOffY
)
88 pChild
= pChild
->GetWindow( WINDOW_NEXT
);
91 // Haben wir ueberhaupt ein TabControl
94 // Offset bei weiteren Controls um einen weiteren Abstand anpassen
96 nOffY
+= IMPL_DIALOG_BAR_OFFSET
*2 + 2;
98 Point
aTabOffset( IMPL_DIALOG_OFFSET
, IMPL_DIALOG_OFFSET
+nOffY
);
99 Size aTabSize
= pTabControl
->GetSizePixel();
100 Size
aDlgSize( aTabSize
.Width() + IMPL_DIALOG_OFFSET
*2,
101 aTabSize
.Height() + IMPL_DIALOG_OFFSET
*2 + nOffY
);
104 // Preview-Fenster beruecksichtigen und die Groessen/Offsets anpassen
105 if ( mpViewWindow
&& mpViewWindow
->IsVisible() )
110 long nViewHeight
= 0;
111 USHORT nViewPosFlags
= WINDOW_POSSIZE_POS
;
112 Size aViewSize
= mpViewWindow
->GetSizePixel();
113 if ( meViewAlign
== WINDOWALIGN_TOP
)
115 nViewOffX
= aTabOffset
.X();
116 nViewOffY
= nOffY
+IMPL_DIALOG_OFFSET
;
117 nViewWidth
= aTabSize
.Width();
118 nViewPosFlags
|= WINDOW_POSSIZE_WIDTH
;
119 aTabOffset
.Y() += aViewSize
.Height()+IMPL_DIALOG_OFFSET
;
120 aDlgSize
.Height() += aViewSize
.Height()+IMPL_DIALOG_OFFSET
;
122 else if ( meViewAlign
== WINDOWALIGN_BOTTOM
)
124 nViewOffX
= aTabOffset
.X();
125 nViewOffY
= aTabOffset
.Y()+aTabSize
.Height()+IMPL_DIALOG_OFFSET
;
126 nViewWidth
= aTabSize
.Width();
127 nViewPosFlags
|= WINDOW_POSSIZE_WIDTH
;
128 aDlgSize
.Height() += aViewSize
.Height()+IMPL_DIALOG_OFFSET
;
130 else if ( meViewAlign
== WINDOWALIGN_RIGHT
)
132 nViewOffX
= aTabOffset
.X()+aTabSize
.Width()+IMPL_DIALOG_OFFSET
;
133 nViewOffY
= aTabOffset
.Y();
134 nViewHeight
= aTabSize
.Height();
135 nViewPosFlags
|= WINDOW_POSSIZE_HEIGHT
;
136 aDlgSize
.Width() += aViewSize
.Width()+IMPL_DIALOG_OFFSET
;
137 nBtnEx
= aViewSize
.Width()+IMPL_DIALOG_OFFSET
;
139 else // meViewAlign == WINDOWALIGN_LEFT
141 nViewOffX
= IMPL_DIALOG_OFFSET
;
142 nViewOffY
= aTabOffset
.Y();
143 nViewHeight
= aTabSize
.Height();
144 nViewPosFlags
|= WINDOW_POSSIZE_HEIGHT
;
145 aTabOffset
.X() += aViewSize
.Width()+IMPL_DIALOG_OFFSET
;
146 aDlgSize
.Width() += aViewSize
.Width()+IMPL_DIALOG_OFFSET
;
147 nBtnEx
= aViewSize
.Width()+IMPL_DIALOG_OFFSET
;
150 mpViewWindow
->SetPosSizePixel( nViewOffX
, nViewOffY
,
151 nViewWidth
, nViewHeight
,
155 // Positionierung vornehmen
156 pTabControl
->SetPosPixel( aTabOffset
);
158 // Alle anderen Childs positionieren
159 BOOL bTabCtrl
= FALSE
;
162 long nY
= aDlgSize
.Height();
163 long nTopX
= IMPL_DIALOG_OFFSET
;
165 // Unter Windows 95 werden die Buttons rechtsbuendig angeordnet
166 nX
= IMPL_DIALOG_OFFSET
;
167 long nCtrlBarWidth
= ((aCtrlSize
.Width()+IMPL_DIALOG_OFFSET
)*nDownCtrl
)-IMPL_DIALOG_OFFSET
;
168 if ( nCtrlBarWidth
<= (aTabSize
.Width()+nBtnEx
) )
169 nX
= (aTabSize
.Width()+nBtnEx
) - nCtrlBarWidth
+ IMPL_DIALOG_OFFSET
;
171 Window
* pChild2
= GetWindow( WINDOW_FIRSTCHILD
);
174 if ( pChild2
->IsVisible() && (pChild2
!= mpViewWindow
) )
176 if ( pChild2
== pTabControl
)
183 if ( nX
+aCtrlSize
.Width()-IMPL_DIALOG_OFFSET
> (aTabSize
.Width()+nBtnEx
) )
185 nY
+= aCtrlSize
.Height()+IMPL_DIALOG_OFFSET
;
186 nX
= IMPL_DIALOG_OFFSET
;
190 pChild2
->SetPosSizePixel( Point( nX
, nY
), aCtrlSize
);
191 nX
+= aCtrlSize
.Width()+IMPL_DIALOG_OFFSET
;
195 Size aChildSize
= pChild2
->GetSizePixel();
196 pChild2
->SetPosPixel( Point( nTopX
, (nOffY
-aChildSize
.Height())/2 ) );
197 nTopX
+= aChildSize
.Width()+2;
201 pChild2
= pChild2
->GetWindow( WINDOW_NEXT
);
204 aDlgSize
.Height() += nLines
* (aCtrlSize
.Height()+IMPL_DIALOG_OFFSET
);
205 SetOutputSizePixel( aDlgSize
);
211 Size aDlgSize
= GetOutputSizePixel();
213 mpFixedLine
= new FixedLine( this );
214 mpFixedLine
->SetPosSizePixel( Point( 0, nOffY
),
215 Size( aDlgSize
.Width(), 2 ) );
219 mbPosControls
= FALSE
;
222 // -----------------------------------------------------------------------
224 TabDialog::TabDialog( Window
* pParent
, WinBits nStyle
) :
225 Dialog( WINDOW_TABDIALOG
)
227 ImplInitTabDialogData();
228 ImplInit( pParent
, nStyle
);
231 // -----------------------------------------------------------------------
233 TabDialog::TabDialog( Window
* pParent
, const ResId
& rResId
) :
234 Dialog( WINDOW_TABDIALOG
)
236 ImplInitTabDialogData();
237 rResId
.SetRT( RSC_TABDIALOG
);
238 ImplInit( pParent
, ImplInitRes( rResId
) );
239 ImplLoadRes( rResId
);
242 // -----------------------------------------------------------------------
244 TabDialog::~TabDialog()
250 // -----------------------------------------------------------------------
252 void TabDialog::Resize()
254 // !!! In the future the controls should be automaticly rearrange
255 // !!! if the window is resized
256 // !!! if ( !IsRollUp() )
257 // !!! ImplPosControls();
260 // -----------------------------------------------------------------------
262 void TabDialog::StateChanged( StateChangedType nType
)
264 if ( nType
== STATE_CHANGE_INITSHOW
)
266 // Calculate the Layout only for the initialized state
270 Dialog::StateChanged( nType
);
273 // -----------------------------------------------------------------------
275 void TabDialog::AdjustLayout()