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: textcontrolcombo.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_sw.hxx"
35 #include "textcontrolcombo.hxx"
38 TextControlCombo::TextControlCombo( Window
* _pParent
, const ResId
& _rResId
,
39 Control
& _rCtrl
, FixedText
& _rFTbefore
, FixedText
& _rFTafter
)
40 :Window ( _pParent
, _rResId
)
42 ,mrFTbefore ( _rFTbefore
)
43 ,mrFTafter ( _rFTafter
)
47 TextControlCombo::~TextControlCombo()
51 void TextControlCombo::Arrange( FixedText
& _rFTcomplete
, BOOL
/*bShow*/ )
53 Point
aBasePos( GetPosPixel() );
54 Size
aMetricVals( GetSizePixel() );
56 long nTextHeight
= _rFTcomplete
.GetSizePixel().Height();
57 long nCtrlHeight
= mrCtrl
.GetSizePixel().Height();
59 // calc y positions / center vertical
60 long nYFT
= aBasePos
.Y();
62 if( nCtrlHeight
> nTextHeight
)
63 nYFT
+= aMetricVals
.Height();
65 nYCtrl
+= aMetricVals
.Height();
67 // separate text parts
68 const String
aReplStr( RTL_CONSTASCII_STRINGPARAM( "%POSITION_OF_CONTROL" ) );
69 String
aTxtBefore( _rFTcomplete
.GetText() );
71 xub_StrLen nReplPos
= aTxtBefore
.Search( aReplStr
);
72 if( nReplPos
!= STRING_NOTFOUND
)
74 xub_StrLen nStrStartAfter
= nReplPos
+ aReplStr
.Len();
75 aTxtAfter
= String( aTxtBefore
, nStrStartAfter
, aTxtBefore
.Len() - nStrStartAfter
);
76 aTxtBefore
.Erase( nReplPos
);
79 // arrange and fill Fixed Texts
80 long nX
= aBasePos
.X();
81 long nWidth
= GetTextWidth( aTxtBefore
);
83 mrFTbefore
.SetText( aTxtBefore
);
84 mrFTbefore
.SetPosSizePixel( nX
, nYFT
, nWidth
, nTextHeight
);
87 nX
+= aMetricVals
.Width();
88 mrCtrl
.SetPosPixel( Point( nX
, nYCtrl
) );
90 nX
+= mrCtrl
.GetSizePixel().Width();
91 nX
+= aMetricVals
.Width();
92 mrFTafter
.SetText( aTxtAfter
);
93 mrFTafter
.SetPosSizePixel( nX
, nYFT
, GetTextWidth( aTxtAfter
), nTextHeight
);
102 void TextControlCombo::Show( BOOL _bVisible
, USHORT _nFlags
)
104 mrCtrl
.Show( _bVisible
, _nFlags
);
105 mrFTbefore
.Show( _bVisible
, _nFlags
);
106 mrFTafter
.Show( _bVisible
, _nFlags
);
109 void TextControlCombo::Enable( BOOL _bEnable
, BOOL _bChild
)
111 mrCtrl
.Enable( _bEnable
, _bChild
);
112 mrFTbefore
.Enable( _bEnable
, _bChild
);
113 mrFTafter
.Enable( _bEnable
, _bChild
);