Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "textcontrolcombo.hxx"
30 : :
31 : :
32 : 0 : TextControlCombo::TextControlCombo( Window* _pParent, const ResId& _rResId,
33 : : Control& _rCtrl, FixedText& _rFTbefore, FixedText& _rFTafter )
34 : : :Window ( _pParent, _rResId )
35 : : ,mrCtrl ( _rCtrl )
36 : : ,mrFTbefore ( _rFTbefore )
37 : 0 : ,mrFTafter ( _rFTafter )
38 : : {
39 : 0 : }
40 : :
41 : 0 : TextControlCombo::~TextControlCombo()
42 : : {
43 [ # # ]: 0 : }
44 : :
45 : 0 : void TextControlCombo::Arrange( FixedText& _rFTcomplete, sal_Bool /*bShow*/ )
46 : : {
47 [ # # ]: 0 : Point aBasePos( GetPosPixel() );
48 [ # # ]: 0 : Size aMetricVals( GetSizePixel() );
49 : :
50 [ # # ]: 0 : long nTextHeight = _rFTcomplete.GetSizePixel().Height();
51 [ # # ]: 0 : long nCtrlHeight = mrCtrl.GetSizePixel().Height();
52 : :
53 : : // calc y positions / center vertical
54 : 0 : long nYFT = aBasePos.Y();
55 : 0 : long nYCtrl = nYFT;
56 [ # # ]: 0 : if( nCtrlHeight > nTextHeight )
57 : 0 : nYFT += aMetricVals.Height();
58 : : else
59 : 0 : nYCtrl += aMetricVals.Height();
60 : :
61 : : // separate text parts
62 [ # # ]: 0 : const String aReplStr( RTL_CONSTASCII_USTRINGPARAM( "%POSITION_OF_CONTROL" ) );
63 [ # # ]: 0 : String aTxtBefore( _rFTcomplete.GetText() );
64 [ # # ]: 0 : String aTxtAfter;
65 [ # # ]: 0 : xub_StrLen nReplPos = aTxtBefore.Search( aReplStr );
66 [ # # ]: 0 : if( nReplPos != STRING_NOTFOUND )
67 : : {
68 : 0 : xub_StrLen nStrStartAfter = nReplPos + aReplStr.Len();
69 [ # # ][ # # ]: 0 : aTxtAfter = String( aTxtBefore, nStrStartAfter, aTxtBefore.Len() - nStrStartAfter );
[ # # ]
70 [ # # ]: 0 : aTxtBefore.Erase( nReplPos );
71 : : }
72 : :
73 : : // arrange and fill Fixed Texts
74 : 0 : long nX = aBasePos.X();
75 [ # # ]: 0 : long nWidth = GetTextWidth( aTxtBefore );
76 : :
77 [ # # ]: 0 : mrFTbefore.SetText( aTxtBefore );
78 [ # # ]: 0 : mrFTbefore.SetPosSizePixel( nX, nYFT, nWidth, nTextHeight );
79 : :
80 : 0 : nX += nWidth;
81 : 0 : nX += aMetricVals.Width();
82 [ # # ]: 0 : mrCtrl.SetPosPixel( Point( nX, nYCtrl ) );
83 : :
84 [ # # ]: 0 : nX += mrCtrl.GetSizePixel().Width();
85 : 0 : nX += aMetricVals.Width();
86 [ # # ]: 0 : mrFTafter.SetText( aTxtAfter );
87 [ # # ][ # # ]: 0 : mrFTafter.SetPosSizePixel( nX, nYFT, GetTextWidth( aTxtAfter ), nTextHeight );
88 : :
89 [ # # ]: 0 : _rFTcomplete.Hide();
90 : :
91 [ # # ]: 0 : Show();
92 : :
93 [ # # ][ # # ]: 0 : Window::Hide();
[ # # ][ # # ]
94 : 0 : }
95 : :
96 : 0 : void TextControlCombo::Show( sal_Bool _bVisible, sal_uInt16 _nFlags )
97 : : {
98 : 0 : mrCtrl.Show( _bVisible, _nFlags );
99 : 0 : mrFTbefore.Show( _bVisible, _nFlags );
100 : 0 : mrFTafter.Show( _bVisible, _nFlags );
101 : 0 : }
102 : :
103 : 0 : void TextControlCombo::Enable( sal_Bool _bEnable, sal_Bool _bChild )
104 : : {
105 : 0 : mrCtrl.Enable( _bEnable, _bChild );
106 : 0 : mrFTbefore.Enable( _bEnable, _bChild );
107 : 0 : mrFTafter.Enable( _bEnable, _bChild );
108 : 0 : }
109 : :
110 : :
111 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|