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