xref: /AOO41X/main/toolkit/source/layout/vcl/wfield.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #include "wrapper.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/awt/XMetricField.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/awt/XNumericField.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/awt/XTextComponent.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/awt/XListBox.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/XComboBox.hpp>
36*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
37*cdf0e10cSrcweir #include <com/sun/star/awt/XActionListener.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/awt/XItemListener.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/awt/XMouseListener.hpp>
40*cdf0e10cSrcweir #include <vcl/combobox.hxx>
41*cdf0e10cSrcweir #include <vcl/lstbox.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir #include <toolkit/awt/vclxwindows.hxx>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using namespace ::com::sun::star;
46*cdf0e10cSrcweir using rtl::OUString;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir #define LAYOUT_API_CALLS_HANDLER 0
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir namespace layout
51*cdf0e10cSrcweir {
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class EditImpl : public ControlImpl
54*cdf0e10cSrcweir                , public ::cppu::WeakImplHelper1< awt::XTextListener >
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir public:
57*cdf0e10cSrcweir     Link maModifyHdl;
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir     uno::Reference< awt::XTextComponent > mxEdit;
60*cdf0e10cSrcweir     EditImpl( Context *context, const PeerHandle &peer, Window *window )
61*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
62*cdf0e10cSrcweir         , mxEdit( peer, uno::UNO_QUERY )
63*cdf0e10cSrcweir     {
64*cdf0e10cSrcweir     }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir     ~EditImpl ();
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir     virtual void SAL_CALL disposing( lang::EventObject const& e )
69*cdf0e10cSrcweir         throw (uno::RuntimeException);
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     virtual void SetModifyHdl( Link const& link );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir     void SAL_CALL textChanged( const awt::TextEvent& /* rEvent */ )
74*cdf0e10cSrcweir         throw (uno::RuntimeException)
75*cdf0e10cSrcweir     {
76*cdf0e10cSrcweir         maModifyHdl.Call( mpWindow );
77*cdf0e10cSrcweir     }
78*cdf0e10cSrcweir };
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir EditImpl::~EditImpl ()
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir void SAL_CALL EditImpl::disposing( lang::EventObject const& e )
85*cdf0e10cSrcweir     throw (uno::RuntimeException)
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     ControlImpl::disposing (e);
88*cdf0e10cSrcweir     mxEdit.clear ();
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir void EditImpl::SetModifyHdl( Link const& link )
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir     if (!link && !!maModifyHdl)
94*cdf0e10cSrcweir         mxEdit->removeTextListener( this );
95*cdf0e10cSrcweir     else if (!!link && !maModifyHdl)
96*cdf0e10cSrcweir         mxEdit->addTextListener( this );
97*cdf0e10cSrcweir     maModifyHdl = link;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir Edit::~Edit ()
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     SetModifyHdl (Link ());
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir void Edit::SetSelection( Selection const& rSelection )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir #if LAYOUT_API_CALLS_HANDLER
108*cdf0e10cSrcweir     if ( !getImpl().mxEdit.is() )
109*cdf0e10cSrcweir         getImpl().mxEdit->setSelection( awt::Selection( rSelection.Min(), rSelection.Max() ) );
110*cdf0e10cSrcweir #else /* !LAYOUT_API_CALLS_HANDLER */
111*cdf0e10cSrcweir     GetEdit ()->SetSelection (rSelection);
112*cdf0e10cSrcweir #endif /* !LAYOUT_API_CALLS_HANDLER */
113*cdf0e10cSrcweir }
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir void Edit::SetText( OUString const& rStr )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir #if LAYOUT_API_CALLS_HANDLER
118*cdf0e10cSrcweir     if ( getImpl().mxEdit.is() )
119*cdf0e10cSrcweir         /// this calls handlers; endless loop in numfmt.cxx
120*cdf0e10cSrcweir         getImpl().mxEdit->setText( rStr );
121*cdf0e10cSrcweir #else /* !LAYOUT_API_CALLS_HANDLER */
122*cdf0e10cSrcweir     GetEdit ()->SetText (rStr);
123*cdf0e10cSrcweir #endif /* !LAYOUT_API_CALLS_HANDLER */
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir String Edit::GetText() const
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     if ( !getImpl().mxEdit.is() )
129*cdf0e10cSrcweir         return getImpl().mxEdit->getText();
130*cdf0e10cSrcweir     return OUString();
131*cdf0e10cSrcweir }
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir void Edit::SetModifyHdl( const Link& link )
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxEdit.is ())
136*cdf0e10cSrcweir         getImpl().SetModifyHdl( link );
137*cdf0e10cSrcweir }
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir IMPL_CONSTRUCTORS( Edit, Control, "edit" );
140*cdf0e10cSrcweir IMPL_GET_IMPL( Edit );
141*cdf0e10cSrcweir IMPL_GET_WINDOW (Edit);
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir class MultiLineEditImpl : public EditImpl
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir public:
146*cdf0e10cSrcweir     MultiLineEditImpl( Context *context, const PeerHandle &peer, Window *window )
147*cdf0e10cSrcweir         : EditImpl( context, peer, window )
148*cdf0e10cSrcweir     {
149*cdf0e10cSrcweir     }
150*cdf0e10cSrcweir };
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir IMPL_CONSTRUCTORS( MultiLineEdit, Edit, "multilineedit" );
153*cdf0e10cSrcweir IMPL_GET_IMPL( MultiLineEdit );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir class SpinFieldImpl : public EditImpl
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir   public:
158*cdf0e10cSrcweir     SpinFieldImpl( Context *context, const PeerHandle &peer, Window *window )
159*cdf0e10cSrcweir         : EditImpl( context, peer, window )
160*cdf0e10cSrcweir     {
161*cdf0e10cSrcweir     }
162*cdf0e10cSrcweir };
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir IMPL_CONSTRUCTORS( SpinField, Edit, "spinfield" );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir class NumericFieldImpl : public SpinFieldImpl
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir   public:
169*cdf0e10cSrcweir     NumericFieldImpl( Context *context, const PeerHandle &peer, Window *window )
170*cdf0e10cSrcweir         : SpinFieldImpl( context, peer, window )
171*cdf0e10cSrcweir     {
172*cdf0e10cSrcweir     }
173*cdf0e10cSrcweir };
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir class MetricFieldImpl : public SpinFieldImpl
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir   public:
178*cdf0e10cSrcweir     MetricFieldImpl( Context *context, const PeerHandle &peer, Window *window )
179*cdf0e10cSrcweir         : SpinFieldImpl( context, peer, window )
180*cdf0e10cSrcweir     {
181*cdf0e10cSrcweir     }
182*cdf0e10cSrcweir };
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir IMPL_GET_IMPL( SpinField );
185*cdf0e10cSrcweir IMPL_GET_IMPL( NumericField );
186*cdf0e10cSrcweir IMPL_GET_IMPL( MetricField );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir class FormatterBaseImpl
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir   protected:
191*cdf0e10cSrcweir     PeerHandle mpeer;
192*cdf0e10cSrcweir   public:
193*cdf0e10cSrcweir     explicit FormatterBaseImpl( const PeerHandle &peer )
194*cdf0e10cSrcweir         : mpeer( peer )
195*cdf0e10cSrcweir     {
196*cdf0e10cSrcweir     };
197*cdf0e10cSrcweir };
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir FormatterBase::FormatterBase( FormatterBaseImpl *pFormatImpl )
200*cdf0e10cSrcweir     : mpFormatImpl( pFormatImpl )
201*cdf0e10cSrcweir {
202*cdf0e10cSrcweir }
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir class NumericFormatterImpl : public FormatterBaseImpl
205*cdf0e10cSrcweir {
206*cdf0e10cSrcweir   public:
207*cdf0e10cSrcweir     uno::Reference< awt::XNumericField > mxField;
208*cdf0e10cSrcweir     explicit NumericFormatterImpl( const PeerHandle &peer )
209*cdf0e10cSrcweir         : FormatterBaseImpl( peer )
210*cdf0e10cSrcweir         , mxField( peer, uno::UNO_QUERY )
211*cdf0e10cSrcweir     {
212*cdf0e10cSrcweir     }
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir     // FIXME: burn that CPU ! cut/paste from vclxwindows.cxx
215*cdf0e10cSrcweir     double valueToDouble( sal_Int64 nValue )
216*cdf0e10cSrcweir     {
217*cdf0e10cSrcweir         sal_Int16 nDigits = mxField->getDecimalDigits();
218*cdf0e10cSrcweir         double n = (double)nValue;
219*cdf0e10cSrcweir         for ( sal_uInt16 d = 0; d < nDigits; d++ )
220*cdf0e10cSrcweir             n /= 10;
221*cdf0e10cSrcweir         return n;
222*cdf0e10cSrcweir     } // FIXME: burn that CPU ! cut/paste from vclxwindows.cxx
223*cdf0e10cSrcweir     sal_Int64 doubleToValue( double nValue )
224*cdf0e10cSrcweir     {
225*cdf0e10cSrcweir         sal_Int16 nDigits = mxField->getDecimalDigits();
226*cdf0e10cSrcweir         double n = nValue;
227*cdf0e10cSrcweir         for ( sal_uInt16 d = 0; d < nDigits; d++ )
228*cdf0e10cSrcweir             n *= 10;
229*cdf0e10cSrcweir         return (sal_Int64) n;
230*cdf0e10cSrcweir     }
231*cdf0e10cSrcweir };
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir class MetricFormatterImpl : public FormatterBaseImpl
234*cdf0e10cSrcweir {
235*cdf0e10cSrcweir   public:
236*cdf0e10cSrcweir     uno::Reference< awt::XMetricField > mxField;
237*cdf0e10cSrcweir     explicit MetricFormatterImpl( const PeerHandle &peer )
238*cdf0e10cSrcweir         : FormatterBaseImpl( peer )
239*cdf0e10cSrcweir         , mxField( peer, uno::UNO_QUERY )
240*cdf0e10cSrcweir     {
241*cdf0e10cSrcweir     }
242*cdf0e10cSrcweir };
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir NumericFormatter::NumericFormatter( FormatterBaseImpl *pImpl )
245*cdf0e10cSrcweir     : FormatterBase( pImpl )
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir NumericFormatterImpl& NumericFormatter::getFormatImpl() const
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     return *( static_cast<NumericFormatterImpl *>( mpFormatImpl ) );
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir #define SET_IMPL(vclmethod, idlmethod) \
255*cdf0e10cSrcweir     void NumericFormatter::vclmethod( sal_Int64 nValue ) \
256*cdf0e10cSrcweir     { \
257*cdf0e10cSrcweir         if ( !getFormatImpl().mxField.is() ) \
258*cdf0e10cSrcweir             return; \
259*cdf0e10cSrcweir         getFormatImpl().mxField->idlmethod( getFormatImpl().valueToDouble( nValue ) ); \
260*cdf0e10cSrcweir     }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir SET_IMPL( SetMin, setMin )
263*cdf0e10cSrcweir SET_IMPL( SetMax, setMax )
264*cdf0e10cSrcweir SET_IMPL( SetLast, setLast )
265*cdf0e10cSrcweir SET_IMPL( SetFirst, setFirst )
266*cdf0e10cSrcweir SET_IMPL( SetValue, setValue )
267*cdf0e10cSrcweir SET_IMPL( SetSpinSize, setSpinSize )
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir sal_Int64 NumericFormatter::GetValue() const
270*cdf0e10cSrcweir {
271*cdf0e10cSrcweir     if ( !getFormatImpl().mxField.is() )
272*cdf0e10cSrcweir         return 0;
273*cdf0e10cSrcweir     return getFormatImpl().doubleToValue( getFormatImpl().mxField->getValue() );
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir #undef SET_IMPL
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir IMPL_CONSTRUCTORS_2( NumericField, SpinField, NumericFormatter, "numericfield" );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir MetricFormatter::MetricFormatter( FormatterBaseImpl *pImpl )
281*cdf0e10cSrcweir     : FormatterBase( pImpl )
282*cdf0e10cSrcweir {
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir MetricFormatterImpl& MetricFormatter::getFormatImpl() const
285*cdf0e10cSrcweir {    return *( static_cast<MetricFormatterImpl *>( mpFormatImpl ) );   }
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir #define MetricUnitVclToUno(a) ((sal_uInt16)(a))
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir #define SET_IMPL(vclmethod, idlmethod) \
290*cdf0e10cSrcweir     void MetricFormatter::vclmethod( sal_Int64 nValue, FieldUnit nUnit ) \
291*cdf0e10cSrcweir     { \
292*cdf0e10cSrcweir         if ( !getFormatImpl().mxField.is() ) \
293*cdf0e10cSrcweir             return; \
294*cdf0e10cSrcweir         getFormatImpl().mxField->idlmethod( nValue, MetricUnitVclToUno( nUnit ) ); \
295*cdf0e10cSrcweir     }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir SET_IMPL( SetMin, setMin )
298*cdf0e10cSrcweir SET_IMPL( SetMax, setMax )
299*cdf0e10cSrcweir SET_IMPL( SetLast, setLast )
300*cdf0e10cSrcweir SET_IMPL( SetFirst, setFirst )
301*cdf0e10cSrcweir SET_IMPL( SetValue, setValue )
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir #undef SET_IMPL
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir void MetricFormatter::SetSpinSize( sal_Int64 nValue )
306*cdf0e10cSrcweir {
307*cdf0e10cSrcweir     if ( !getFormatImpl().mxField.is() )
308*cdf0e10cSrcweir         return;
309*cdf0e10cSrcweir     getFormatImpl().mxField->setSpinSize( nValue );
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir sal_Int64 MetricFormatter::GetValue( FieldUnit nUnit ) const
313*cdf0e10cSrcweir {
314*cdf0e10cSrcweir     if ( !getFormatImpl().mxField.is() )
315*cdf0e10cSrcweir         return 0;
316*cdf0e10cSrcweir     return getFormatImpl().mxField->getValue( MetricUnitVclToUno( nUnit ) );
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir IMPL_CONSTRUCTORS_2( MetricField, SpinField, MetricFormatter, "metricfield" );
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir class ComboBoxImpl : public EditImpl
322*cdf0e10cSrcweir                    , public ::cppu::WeakImplHelper1< awt::XActionListener >
323*cdf0e10cSrcweir                    , public ::cppu::WeakImplHelper1< awt::XItemListener >
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir public:
326*cdf0e10cSrcweir     uno::Reference< awt::XComboBox > mxComboBox;
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir     Link maClickHdl;
329*cdf0e10cSrcweir     Link maSelectHdl;
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir     Window *parent;
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     ComboBoxImpl( Context *context, const PeerHandle &peer, Window *window )
334*cdf0e10cSrcweir         : EditImpl( context, peer, window )
335*cdf0e10cSrcweir         , mxComboBox( peer, uno::UNO_QUERY )
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir     }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir     ~ComboBoxImpl ();
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir     sal_uInt16 InsertEntry( OUString const& rStr, sal_uInt16 nPos )
342*cdf0e10cSrcweir     {
343*cdf0e10cSrcweir         if ( nPos == COMBOBOX_APPEND )
344*cdf0e10cSrcweir             nPos = GetEntryCount();
345*cdf0e10cSrcweir         mxComboBox->addItem( rtl::OUString( rStr ), nPos );
346*cdf0e10cSrcweir         return nPos;
347*cdf0e10cSrcweir     }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir     void RemoveEntry( sal_uInt16 nPos )
350*cdf0e10cSrcweir     {
351*cdf0e10cSrcweir         mxComboBox->removeItems( nPos, 1 );
352*cdf0e10cSrcweir     }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     sal_uInt16 GetEntryPos( String const& rStr ) const
355*cdf0e10cSrcweir     {
356*cdf0e10cSrcweir         uno::Sequence< rtl::OUString> aItems( mxComboBox->getItems() );
357*cdf0e10cSrcweir         rtl::OUString rKey( rStr );
358*cdf0e10cSrcweir         sal_uInt16 n = sal::static_int_cast< sal_uInt16 >(aItems.getLength());
359*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < n; i++)
360*cdf0e10cSrcweir         {
361*cdf0e10cSrcweir             if ( aItems[ i ] == rKey )
362*cdf0e10cSrcweir                 return i;
363*cdf0e10cSrcweir         }
364*cdf0e10cSrcweir         return COMBOBOX_ENTRY_NOTFOUND;
365*cdf0e10cSrcweir     }
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir     OUString GetEntry( sal_uInt16 nPos ) const
368*cdf0e10cSrcweir     {
369*cdf0e10cSrcweir         return OUString( mxComboBox->getItem( nPos ) );
370*cdf0e10cSrcweir     }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir     sal_uInt16 GetEntryCount() const
373*cdf0e10cSrcweir     {
374*cdf0e10cSrcweir         return mxComboBox->getItemCount();
375*cdf0e10cSrcweir     }
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir     void SetClickHdl( Link const& link )
378*cdf0e10cSrcweir     {
379*cdf0e10cSrcweir         if (!link && !!maClickHdl)
380*cdf0e10cSrcweir             mxComboBox->removeActionListener( this );
381*cdf0e10cSrcweir         else if (!!link && !maClickHdl)
382*cdf0e10cSrcweir             mxComboBox->addActionListener( this );
383*cdf0e10cSrcweir         maClickHdl = link;
384*cdf0e10cSrcweir     }
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     void SetSelectHdl( Link const& link )
387*cdf0e10cSrcweir     {
388*cdf0e10cSrcweir         if (!link && !!maSelectHdl)
389*cdf0e10cSrcweir             mxComboBox->removeItemListener( this );
390*cdf0e10cSrcweir         else if (!!link && !maSelectHdl)
391*cdf0e10cSrcweir             mxComboBox->addItemListener( this );
392*cdf0e10cSrcweir         maSelectHdl = link;
393*cdf0e10cSrcweir     }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     void SAL_CALL disposing( lang::EventObject const& e )
396*cdf0e10cSrcweir         throw (uno::RuntimeException);
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     void SAL_CALL actionPerformed (const awt::ActionEvent&)
399*cdf0e10cSrcweir         throw (uno::RuntimeException)
400*cdf0e10cSrcweir     {
401*cdf0e10cSrcweir         ComboBox* pComboBox = static_cast<ComboBox*>( mpWindow );
402*cdf0e10cSrcweir         if ( !pComboBox )
403*cdf0e10cSrcweir             return;
404*cdf0e10cSrcweir         maClickHdl.Call( pComboBox );
405*cdf0e10cSrcweir     }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir     void SAL_CALL itemStateChanged( awt::ItemEvent const&)
408*cdf0e10cSrcweir         throw (uno::RuntimeException)
409*cdf0e10cSrcweir     {
410*cdf0e10cSrcweir         ComboBox* pComboBox = static_cast<ComboBox*>( mpWindow );
411*cdf0e10cSrcweir         if ( !pComboBox )
412*cdf0e10cSrcweir             return;
413*cdf0e10cSrcweir         maSelectHdl.Call( pComboBox );
414*cdf0e10cSrcweir     }
415*cdf0e10cSrcweir };
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir ComboBox::~ComboBox ()
418*cdf0e10cSrcweir {
419*cdf0e10cSrcweir #ifndef __SUNPRO_CC
420*cdf0e10cSrcweir     OSL_TRACE ("%s: deleting ComboBox for window: %p", __FUNCTION__, GetWindow ());
421*cdf0e10cSrcweir #endif
422*cdf0e10cSrcweir }
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir ComboBoxImpl::~ComboBoxImpl ()
425*cdf0e10cSrcweir {
426*cdf0e10cSrcweir #ifndef __SUNPRO_CC
427*cdf0e10cSrcweir     OSL_TRACE ("%s: deleting ComboBoxImpl for window: %p", __FUNCTION__, mpWindow ? mpWindow->GetWindow () : 0);
428*cdf0e10cSrcweir     OSL_TRACE ("%s: deleting ComboBoxImpl for listener: %p", __FUNCTION__, static_cast<XFocusListener*> (this));
429*cdf0e10cSrcweir #endif
430*cdf0e10cSrcweir }
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir void ComboBoxImpl::disposing( lang::EventObject const& e )
433*cdf0e10cSrcweir     throw (uno::RuntimeException)
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir     EditImpl::disposing (e);
436*cdf0e10cSrcweir     mxComboBox.clear ();
437*cdf0e10cSrcweir }
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir sal_uInt16 ComboBox::InsertEntry( String const& rStr, sal_uInt16 nPos )
440*cdf0e10cSrcweir {
441*cdf0e10cSrcweir     return getImpl().InsertEntry( rStr, nPos );
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir void ComboBox::RemoveEntry( String const& rStr )
445*cdf0e10cSrcweir {
446*cdf0e10cSrcweir     getImpl().RemoveEntry( GetEntryPos( rStr ) );
447*cdf0e10cSrcweir }
448*cdf0e10cSrcweir 
449*cdf0e10cSrcweir void ComboBox::RemoveEntry( sal_uInt16 nPos )
450*cdf0e10cSrcweir {
451*cdf0e10cSrcweir     getImpl().RemoveEntry( nPos );
452*cdf0e10cSrcweir }
453*cdf0e10cSrcweir 
454*cdf0e10cSrcweir void ComboBox::Clear()
455*cdf0e10cSrcweir {
456*cdf0e10cSrcweir     uno::Sequence< rtl::OUString> aNoItems;
457*cdf0e10cSrcweir     getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) );
458*cdf0e10cSrcweir }
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir sal_uInt16 ComboBox::GetEntryPos( String const& rStr ) const
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir     return getImpl().GetEntryPos( rStr );
463*cdf0e10cSrcweir }
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir String ComboBox::GetEntry( sal_uInt16 nPos ) const
466*cdf0e10cSrcweir {
467*cdf0e10cSrcweir     rtl::OUString rItem = getImpl().mxComboBox->getItem( nPos );
468*cdf0e10cSrcweir     return OUString( rItem );
469*cdf0e10cSrcweir }
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir sal_uInt16 ComboBox::GetEntryCount() const
472*cdf0e10cSrcweir {
473*cdf0e10cSrcweir     return getImpl().GetEntryCount();
474*cdf0e10cSrcweir }
475*cdf0e10cSrcweir 
476*cdf0e10cSrcweir void ComboBox::SetClickHdl( const Link& link )
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxComboBox.is ())
479*cdf0e10cSrcweir         getImpl().SetClickHdl( link );
480*cdf0e10cSrcweir }
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir void ComboBox::SetSelectHdl( const Link& link )
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxComboBox.is ())
485*cdf0e10cSrcweir         getImpl().SetSelectHdl( link );
486*cdf0e10cSrcweir }
487*cdf0e10cSrcweir 
488*cdf0e10cSrcweir void ComboBox::EnableAutocomplete (bool enable, bool matchCase)
489*cdf0e10cSrcweir {
490*cdf0e10cSrcweir     GetComboBox ()->EnableAutocomplete (enable, matchCase);
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir 
493*cdf0e10cSrcweir IMPL_CONSTRUCTORS_BODY( ComboBox, Edit, "combobox", getImpl().parent = parent; );
494*cdf0e10cSrcweir IMPL_GET_WINDOW (ComboBox);
495*cdf0e10cSrcweir /// IMPL_GET_IMPL( ComboBox );
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir static ComboBoxImpl* null_combobox_impl = 0;
498*cdf0e10cSrcweir 
499*cdf0e10cSrcweir ComboBoxImpl &ComboBox::getImpl () const
500*cdf0e10cSrcweir {
501*cdf0e10cSrcweir     if (ComboBoxImpl* c = static_cast<ComboBoxImpl *>(mpImpl))
502*cdf0e10cSrcweir         return *c;
503*cdf0e10cSrcweir     return *null_combobox_impl;
504*cdf0e10cSrcweir }
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir class ListBoxImpl : public ControlImpl
507*cdf0e10cSrcweir                   , public ::cppu::WeakImplHelper1< awt::XActionListener >
508*cdf0e10cSrcweir                   , public ::cppu::WeakImplHelper1< awt::XItemListener >
509*cdf0e10cSrcweir                   , public ::cppu::WeakImplHelper1< awt::XMouseListener >
510*cdf0e10cSrcweir {
511*cdf0e10cSrcweir     Link maClickHdl;
512*cdf0e10cSrcweir     Link maSelectHdl;
513*cdf0e10cSrcweir     Link maDoubleClickHdl;
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir public:
516*cdf0e10cSrcweir     uno::Reference< awt::XListBox > mxListBox;
517*cdf0e10cSrcweir     ListBoxImpl( Context *context, const PeerHandle &peer, Window *window )
518*cdf0e10cSrcweir         : ControlImpl( context, peer, window )
519*cdf0e10cSrcweir         , mxListBox( peer, uno::UNO_QUERY )
520*cdf0e10cSrcweir     {
521*cdf0e10cSrcweir         SelectEntryPos (0, true);
522*cdf0e10cSrcweir     }
523*cdf0e10cSrcweir 
524*cdf0e10cSrcweir     sal_uInt16 InsertEntry (String const& rStr, sal_uInt16 nPos)
525*cdf0e10cSrcweir     {
526*cdf0e10cSrcweir         if ( nPos == LISTBOX_APPEND )
527*cdf0e10cSrcweir             nPos = mxListBox->getItemCount();
528*cdf0e10cSrcweir         mxListBox->addItem( rtl::OUString( rStr ), nPos );
529*cdf0e10cSrcweir         return nPos;
530*cdf0e10cSrcweir     }
531*cdf0e10cSrcweir 
532*cdf0e10cSrcweir     void RemoveEntry( sal_uInt16 nPos )
533*cdf0e10cSrcweir     {
534*cdf0e10cSrcweir         mxListBox->removeItems( nPos, 1 );
535*cdf0e10cSrcweir     }
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir     sal_uInt16 RemoveEntry( String const& rStr, sal_uInt16 nPos)
538*cdf0e10cSrcweir     {
539*cdf0e10cSrcweir         if ( nPos == LISTBOX_APPEND )
540*cdf0e10cSrcweir             nPos = mxListBox->getItemCount();
541*cdf0e10cSrcweir         mxListBox->addItem( rtl::OUString( rStr ), nPos );
542*cdf0e10cSrcweir         return nPos;
543*cdf0e10cSrcweir     }
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir     sal_uInt16 GetEntryPos( String const& rStr ) const
546*cdf0e10cSrcweir     {
547*cdf0e10cSrcweir         uno::Sequence< rtl::OUString> aItems( mxListBox->getItems() );
548*cdf0e10cSrcweir         rtl::OUString rKey( rStr );
549*cdf0e10cSrcweir         sal_uInt16 n = sal::static_int_cast< sal_uInt16 >(aItems.getLength());
550*cdf0e10cSrcweir         for (sal_uInt16 i = 0; i < n; i++)
551*cdf0e10cSrcweir         {
552*cdf0e10cSrcweir             if ( aItems[ i ] == rKey )
553*cdf0e10cSrcweir                 return i;
554*cdf0e10cSrcweir         }
555*cdf0e10cSrcweir         return LISTBOX_ENTRY_NOTFOUND;
556*cdf0e10cSrcweir     }
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir     OUString GetEntry( sal_uInt16 nPos ) const
559*cdf0e10cSrcweir     {
560*cdf0e10cSrcweir         return mxListBox->getItem( nPos );
561*cdf0e10cSrcweir     }
562*cdf0e10cSrcweir 
563*cdf0e10cSrcweir     sal_uInt16 GetEntryCount() const
564*cdf0e10cSrcweir     {
565*cdf0e10cSrcweir         return mxListBox->getItemCount();
566*cdf0e10cSrcweir     }
567*cdf0e10cSrcweir 
568*cdf0e10cSrcweir     void SelectEntryPos( sal_uInt16 nPos, bool bSelect )
569*cdf0e10cSrcweir     {
570*cdf0e10cSrcweir         mxListBox->selectItemPos( nPos, bSelect );
571*cdf0e10cSrcweir     }
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir     sal_uInt16 GetSelectEntryCount() const
574*cdf0e10cSrcweir     {
575*cdf0e10cSrcweir         return sal::static_int_cast< sal_uInt16 >( mxListBox->getSelectedItems().getLength() );
576*cdf0e10cSrcweir     }
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir     sal_uInt16 GetSelectEntryPos( sal_uInt16 nSelIndex ) const
579*cdf0e10cSrcweir     {
580*cdf0e10cSrcweir         sal_uInt16 nSelected = 0;
581*cdf0e10cSrcweir         if ( mxListBox->isMutipleMode() )
582*cdf0e10cSrcweir         {
583*cdf0e10cSrcweir             uno::Sequence< short > aItems( mxListBox->getSelectedItemsPos() );
584*cdf0e10cSrcweir             if ( nSelIndex < aItems.getLength() )
585*cdf0e10cSrcweir                 nSelected = aItems[ nSelIndex ];
586*cdf0e10cSrcweir         }
587*cdf0e10cSrcweir         else
588*cdf0e10cSrcweir             nSelected = mxListBox->getSelectedItemPos();
589*cdf0e10cSrcweir         return nSelected;
590*cdf0e10cSrcweir     }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir     virtual void SAL_CALL disposing( lang::EventObject const& e )
593*cdf0e10cSrcweir         throw (uno::RuntimeException)
594*cdf0e10cSrcweir     {
595*cdf0e10cSrcweir         ControlImpl::disposing (e);
596*cdf0e10cSrcweir         mxListBox.clear ();
597*cdf0e10cSrcweir     }
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir     Link& GetClickHdl ()
600*cdf0e10cSrcweir     {
601*cdf0e10cSrcweir         return maClickHdl;
602*cdf0e10cSrcweir     }
603*cdf0e10cSrcweir 
604*cdf0e10cSrcweir     void SetClickHdl( Link const& link )
605*cdf0e10cSrcweir     {
606*cdf0e10cSrcweir         if (!link && !!maClickHdl)
607*cdf0e10cSrcweir             mxListBox->removeActionListener( this );
608*cdf0e10cSrcweir         else if (!!link && !maClickHdl)
609*cdf0e10cSrcweir             mxListBox->addActionListener( this );
610*cdf0e10cSrcweir         maClickHdl = link;
611*cdf0e10cSrcweir     }
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir     void SAL_CALL actionPerformed( const awt::ActionEvent& /* rEvent */ )
614*cdf0e10cSrcweir         throw (uno::RuntimeException)
615*cdf0e10cSrcweir     {
616*cdf0e10cSrcweir         maClickHdl.Call( mpWindow );
617*cdf0e10cSrcweir     }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir     Link& GetSelectHdl ()
620*cdf0e10cSrcweir     {
621*cdf0e10cSrcweir         return maSelectHdl;
622*cdf0e10cSrcweir     }
623*cdf0e10cSrcweir 
624*cdf0e10cSrcweir     void SetSelectHdl( Link const& link )
625*cdf0e10cSrcweir     {
626*cdf0e10cSrcweir         if (!link && !!maSelectHdl)
627*cdf0e10cSrcweir             mxListBox->removeItemListener( this );
628*cdf0e10cSrcweir         else if (!!link && !maSelectHdl)
629*cdf0e10cSrcweir             mxListBox->addItemListener( this );
630*cdf0e10cSrcweir         maSelectHdl = link;
631*cdf0e10cSrcweir     }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir     void SAL_CALL itemStateChanged (awt::ItemEvent const&)
634*cdf0e10cSrcweir         throw (uno::RuntimeException)
635*cdf0e10cSrcweir     {
636*cdf0e10cSrcweir         maSelectHdl.Call (static_cast <ListBox*> (mpWindow));
637*cdf0e10cSrcweir     }
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir     Link& GetDoubleClickHdl ()
640*cdf0e10cSrcweir     {
641*cdf0e10cSrcweir         return maDoubleClickHdl;
642*cdf0e10cSrcweir     }
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir     void SetDoubleClickHdl (Link const& link)
645*cdf0e10cSrcweir     {
646*cdf0e10cSrcweir         if (!link && !!maDoubleClickHdl)
647*cdf0e10cSrcweir             mxWindow->removeMouseListener (this);
648*cdf0e10cSrcweir         else if (!!link && !maSelectHdl)
649*cdf0e10cSrcweir             mxWindow->addMouseListener (this);
650*cdf0e10cSrcweir         maDoubleClickHdl = link;
651*cdf0e10cSrcweir     }
652*cdf0e10cSrcweir 
653*cdf0e10cSrcweir     void SAL_CALL mousePressed (awt::MouseEvent const&) throw (uno::RuntimeException)
654*cdf0e10cSrcweir     {
655*cdf0e10cSrcweir     }
656*cdf0e10cSrcweir     void SAL_CALL mouseReleased (awt::MouseEvent const& e) throw (uno::RuntimeException)
657*cdf0e10cSrcweir     {
658*cdf0e10cSrcweir         if (e.ClickCount == 2)
659*cdf0e10cSrcweir             maDoubleClickHdl.Call (mpWindow);
660*cdf0e10cSrcweir     }
661*cdf0e10cSrcweir     void SAL_CALL mouseEntered (awt::MouseEvent const&) throw (uno::RuntimeException)
662*cdf0e10cSrcweir     {
663*cdf0e10cSrcweir     }
664*cdf0e10cSrcweir     void SAL_CALL mouseExited (awt::MouseEvent const&) throw (uno::RuntimeException)
665*cdf0e10cSrcweir     {
666*cdf0e10cSrcweir     }
667*cdf0e10cSrcweir };
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir ListBox::~ListBox ()
670*cdf0e10cSrcweir {
671*cdf0e10cSrcweir }
672*cdf0e10cSrcweir 
673*cdf0e10cSrcweir sal_uInt16 ListBox::InsertEntry (String const& rStr, sal_uInt16 nPos)
674*cdf0e10cSrcweir {
675*cdf0e10cSrcweir     return getImpl().InsertEntry(rStr, nPos);
676*cdf0e10cSrcweir }
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir void ListBox::RemoveEntry( sal_uInt16 nPos )
679*cdf0e10cSrcweir {
680*cdf0e10cSrcweir     return getImpl().RemoveEntry( nPos );
681*cdf0e10cSrcweir }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir void ListBox::RemoveEntry( String const& rStr )
684*cdf0e10cSrcweir {
685*cdf0e10cSrcweir     return getImpl().RemoveEntry( GetEntryPos( rStr ) );
686*cdf0e10cSrcweir }
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir void ListBox::Clear()
689*cdf0e10cSrcweir {
690*cdf0e10cSrcweir     uno::Sequence< rtl::OUString> aNoItems;
691*cdf0e10cSrcweir     getImpl().setProperty( "StringItemList", uno::Any( aNoItems ) );
692*cdf0e10cSrcweir }
693*cdf0e10cSrcweir 
694*cdf0e10cSrcweir sal_uInt16 ListBox::GetEntryPos( String const& rStr ) const
695*cdf0e10cSrcweir {
696*cdf0e10cSrcweir     return getImpl().GetEntryPos( rStr );
697*cdf0e10cSrcweir }
698*cdf0e10cSrcweir 
699*cdf0e10cSrcweir String ListBox::GetEntry( sal_uInt16 nPos ) const
700*cdf0e10cSrcweir {
701*cdf0e10cSrcweir     return getImpl().GetEntry( nPos );
702*cdf0e10cSrcweir }
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir sal_uInt16 ListBox::GetEntryCount() const
705*cdf0e10cSrcweir {
706*cdf0e10cSrcweir     return getImpl().GetEntryCount();
707*cdf0e10cSrcweir }
708*cdf0e10cSrcweir 
709*cdf0e10cSrcweir void ListBox::SelectEntryPos( sal_uInt16 nPos, bool bSelect )
710*cdf0e10cSrcweir {
711*cdf0e10cSrcweir #if LAYOUT_API_CALLS_HANDLER
712*cdf0e10cSrcweir     getImpl().SelectEntryPos( nPos, bSelect );
713*cdf0e10cSrcweir #else /* !LAYOUT_API_CALLS_HANDLER */
714*cdf0e10cSrcweir     GetListBox ()->SelectEntryPos (nPos, bSelect);
715*cdf0e10cSrcweir #endif /* !LAYOUT_API_CALLS_HANDLER */
716*cdf0e10cSrcweir }
717*cdf0e10cSrcweir 
718*cdf0e10cSrcweir void ListBox::SelectEntry( String const& rStr, bool bSelect )
719*cdf0e10cSrcweir {
720*cdf0e10cSrcweir     SelectEntryPos( GetEntryPos( rStr ), bSelect );
721*cdf0e10cSrcweir }
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir sal_uInt16 ListBox::GetSelectEntryCount() const
724*cdf0e10cSrcweir {
725*cdf0e10cSrcweir     return getImpl().GetSelectEntryCount();
726*cdf0e10cSrcweir }
727*cdf0e10cSrcweir 
728*cdf0e10cSrcweir sal_uInt16 ListBox::GetSelectEntryPos( sal_uInt16 nSelIndex ) const
729*cdf0e10cSrcweir {
730*cdf0e10cSrcweir     return getImpl().GetSelectEntryPos( nSelIndex );
731*cdf0e10cSrcweir }
732*cdf0e10cSrcweir 
733*cdf0e10cSrcweir String ListBox::GetSelectEntry( sal_uInt16 nSelIndex ) const
734*cdf0e10cSrcweir {
735*cdf0e10cSrcweir     return GetEntry( GetSelectEntryPos( nSelIndex ) );
736*cdf0e10cSrcweir }
737*cdf0e10cSrcweir 
738*cdf0e10cSrcweir Link& ListBox::GetSelectHdl ()
739*cdf0e10cSrcweir {
740*cdf0e10cSrcweir     return getImpl ().GetSelectHdl ();
741*cdf0e10cSrcweir }
742*cdf0e10cSrcweir 
743*cdf0e10cSrcweir void ListBox::SetSelectHdl( Link const& link )
744*cdf0e10cSrcweir {
745*cdf0e10cSrcweir     getImpl().SetSelectHdl( link );
746*cdf0e10cSrcweir }
747*cdf0e10cSrcweir 
748*cdf0e10cSrcweir Link& ListBox::GetClickHdl ()
749*cdf0e10cSrcweir {
750*cdf0e10cSrcweir     return getImpl ().GetSelectHdl ();
751*cdf0e10cSrcweir }
752*cdf0e10cSrcweir 
753*cdf0e10cSrcweir void ListBox::SetClickHdl( Link const& link )
754*cdf0e10cSrcweir {
755*cdf0e10cSrcweir     if (&getImpl () && getImpl().mxListBox.is ())
756*cdf0e10cSrcweir         getImpl().SetClickHdl( link );
757*cdf0e10cSrcweir }
758*cdf0e10cSrcweir 
759*cdf0e10cSrcweir Link& ListBox::GetDoubleClickHdl ()
760*cdf0e10cSrcweir {
761*cdf0e10cSrcweir     return getImpl ().GetSelectHdl ();
762*cdf0e10cSrcweir }
763*cdf0e10cSrcweir 
764*cdf0e10cSrcweir void ListBox::SetDoubleClickHdl( Link const& link )
765*cdf0e10cSrcweir {
766*cdf0e10cSrcweir     getImpl().SetDoubleClickHdl( link );
767*cdf0e10cSrcweir }
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir void ListBox::SetEntryData( sal_uInt16 pos, void* data)
770*cdf0e10cSrcweir {
771*cdf0e10cSrcweir     GetListBox ()->SetEntryData (pos, data);
772*cdf0e10cSrcweir }
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir void* ListBox::GetEntryData( sal_uInt16 pos) const
775*cdf0e10cSrcweir {
776*cdf0e10cSrcweir     return GetListBox ()->GetEntryData (pos);
777*cdf0e10cSrcweir }
778*cdf0e10cSrcweir 
779*cdf0e10cSrcweir void ListBox::SetNoSelection ()
780*cdf0e10cSrcweir {
781*cdf0e10cSrcweir     GetListBox ()->SetNoSelection ();
782*cdf0e10cSrcweir }
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir IMPL_CONSTRUCTORS (ListBox, Control, "listbox");
785*cdf0e10cSrcweir IMPL_GET_IMPL (ListBox);
786*cdf0e10cSrcweir IMPL_GET_WINDOW (ListBox);
787*cdf0e10cSrcweir 
788*cdf0e10cSrcweir IMPL_IMPL (MultiListBox, ListBox)
789*cdf0e10cSrcweir IMPL_CONSTRUCTORS_BODY( MultiListBox, ListBox, "multilistbox", GetMultiListBox()->EnableMultiSelection( true ); );
790*cdf0e10cSrcweir IMPL_GET_IMPL( MultiListBox );
791*cdf0e10cSrcweir IMPL_GET_WINDOW( MultiListBox );
792*cdf0e10cSrcweir } // namespace layout
793