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