xref: /aoo41x/main/vcl/source/control/lstbox.cxx (revision 6485ffd2)
19f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59f62ea84SAndrew Rist  * distributed with this work for additional information
69f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
99f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
109f62ea84SAndrew Rist  *
119f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129f62ea84SAndrew Rist  *
139f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149f62ea84SAndrew Rist  * software distributed under the License is distributed on an
159f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
179f62ea84SAndrew Rist  * specific language governing permissions and limitations
189f62ea84SAndrew Rist  * under the License.
199f62ea84SAndrew Rist  *
209f62ea84SAndrew Rist  *************************************************************/
219f62ea84SAndrew Rist 
229f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "tools/rc.h"
28cdf0e10cSrcweir #include "tools/debug.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "vcl/decoview.hxx"
32cdf0e10cSrcweir #include "vcl/event.hxx"
33cdf0e10cSrcweir #include "vcl/scrbar.hxx"
34cdf0e10cSrcweir #include "vcl/button.hxx"
35cdf0e10cSrcweir #include "vcl/edit.hxx"
36cdf0e10cSrcweir #include "vcl/lstbox.hxx"
37cdf0e10cSrcweir #include "vcl/combobox.hxx"
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include "svdata.hxx"
40cdf0e10cSrcweir #include "controldata.hxx"
41cdf0e10cSrcweir #include "subedit.hxx"
42cdf0e10cSrcweir #include "ilstbox.hxx"
43cdf0e10cSrcweir #include "dndevdis.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // =======================================================================
48cdf0e10cSrcweir 
ListBox(WindowType nType)49cdf0e10cSrcweir ListBox::ListBox( WindowType nType ) : Control( nType )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	ImplInitListBoxData();
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // -----------------------------------------------------------------------
55cdf0e10cSrcweir 
ListBox(Window * pParent,WinBits nStyle)56cdf0e10cSrcweir ListBox::ListBox( Window* pParent, WinBits nStyle ) : Control( WINDOW_LISTBOX )
57cdf0e10cSrcweir {
58cdf0e10cSrcweir 	ImplInitListBoxData();
59cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir // -----------------------------------------------------------------------
63cdf0e10cSrcweir 
ListBox(Window * pParent,const ResId & rResId)64cdf0e10cSrcweir ListBox::ListBox( Window* pParent, const ResId& rResId ) :
65cdf0e10cSrcweir 	Control( WINDOW_LISTBOX )
66cdf0e10cSrcweir {
67cdf0e10cSrcweir 	ImplInitListBoxData();
68cdf0e10cSrcweir 	rResId.SetRT( RSC_LISTBOX );
69cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
70cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
71cdf0e10cSrcweir 	ImplLoadRes( rResId );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE ) )
74cdf0e10cSrcweir 		Show();
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir // -----------------------------------------------------------------------
78cdf0e10cSrcweir 
~ListBox()79cdf0e10cSrcweir ListBox::~ListBox()
80cdf0e10cSrcweir {
81cdf0e10cSrcweir     //#109201#
82cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     delete mpImplLB;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	// Beim zerstoeren des FloatWins macht TH ein GrabFocus auf den Parent,
87cdf0e10cSrcweir 	// also diese ListBox => PreNotify()...
88cdf0e10cSrcweir 	mpImplLB = NULL;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	delete mpFloatWin;
91cdf0e10cSrcweir 	delete mpImplWin;
92cdf0e10cSrcweir 	delete mpBtn;
93cdf0e10cSrcweir }
94cdf0e10cSrcweir 
95cdf0e10cSrcweir // -----------------------------------------------------------------------
96cdf0e10cSrcweir 
ImplInitListBoxData()97cdf0e10cSrcweir void ListBox::ImplInitListBoxData()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	mpFloatWin		= NULL;
100cdf0e10cSrcweir 	mpImplWin		= NULL;
101cdf0e10cSrcweir 	mpBtn			= NULL;
102cdf0e10cSrcweir 	mnDDHeight		= 0;
103cdf0e10cSrcweir 	mnSaveValue 	= LISTBOX_ENTRY_NOTFOUND;
104cdf0e10cSrcweir     mnLineCount     = 0;
105a68b38dfSArmin Le Grand 	mbDDAutoSize	= true;
106a68b38dfSArmin Le Grand     mbEdgeBlending  = false;
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir // -----------------------------------------------------------------------
110cdf0e10cSrcweir 
ImplInit(Window * pParent,WinBits nStyle)111cdf0e10cSrcweir void ListBox::ImplInit( Window* pParent, WinBits nStyle )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 	nStyle = ImplInitStyle( nStyle );
114cdf0e10cSrcweir 	if ( !(nStyle & WB_NOBORDER) && ( nStyle & WB_DROPDOWN ) )
115cdf0e10cSrcweir 		nStyle |= WB_BORDER;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
118cdf0e10cSrcweir 	SetBackground();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTargetListener> xDrop = new DNDEventDispatcher(this);
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	if( nStyle & WB_DROPDOWN )
123cdf0e10cSrcweir 	{
124cdf0e10cSrcweir         sal_Int32 nLeft, nTop, nRight, nBottom;
125cdf0e10cSrcweir         GetBorder( nLeft, nTop, nRight, nBottom );
126cdf0e10cSrcweir         mnDDHeight = (sal_uInt16)(GetTextHeight() + nTop + nBottom + 4);
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         if( IsNativeWidgetEnabled() &&
129cdf0e10cSrcweir             IsNativeControlSupported( CTRL_LISTBOX, PART_ENTIRE_CONTROL ) )
130cdf0e10cSrcweir         {
131cdf0e10cSrcweir                 ImplControlValue aControlValue;
132cdf0e10cSrcweir                 Rectangle aCtrlRegion( Point( 0, 0 ), Size( 20, mnDDHeight ) );
133cdf0e10cSrcweir                 Rectangle aBoundingRgn( aCtrlRegion );
134cdf0e10cSrcweir                 Rectangle aContentRgn( aCtrlRegion );
135cdf0e10cSrcweir                 if( GetNativeControlRegion( CTRL_LISTBOX, PART_ENTIRE_CONTROL, aCtrlRegion,
136cdf0e10cSrcweir                                             CTRL_STATE_ENABLED, aControlValue, rtl::OUString(),
137cdf0e10cSrcweir                                             aBoundingRgn, aContentRgn ) )
138cdf0e10cSrcweir                 {
139cdf0e10cSrcweir                     sal_Int32 nHeight = aBoundingRgn.GetHeight();
140cdf0e10cSrcweir                     if( nHeight > mnDDHeight )
141cdf0e10cSrcweir                         mnDDHeight = static_cast<sal_uInt16>(nHeight);
142cdf0e10cSrcweir                 }
143cdf0e10cSrcweir         }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		mpFloatWin = new ImplListBoxFloatingWindow( this );
146cdf0e10cSrcweir 		mpFloatWin->SetAutoWidth( sal_True );
147cdf0e10cSrcweir 		mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) );
148cdf0e10cSrcweir         mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop);
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 		mpImplWin = new ImplWin( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER );
151cdf0e10cSrcweir 		mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
152cdf0e10cSrcweir 		mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
153cdf0e10cSrcweir 		mpImplWin->Show();
154cdf0e10cSrcweir         mpImplWin->GetDropTarget()->addDropTargetListener(xDrop);
155a68b38dfSArmin Le Grand         mpImplWin->SetEdgeBlending(GetEdgeBlending());
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 		mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
158cdf0e10cSrcweir 		ImplInitDropDownButton( mpBtn );
159cdf0e10cSrcweir 		mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
160cdf0e10cSrcweir 		mpBtn->Show();
161cdf0e10cSrcweir         mpBtn->GetDropTarget()->addDropTargetListener(xDrop);
162cdf0e10cSrcweir 	}
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 	Window* pLBParent = this;
165cdf0e10cSrcweir 	if ( mpFloatWin )
166cdf0e10cSrcweir 		pLBParent = mpFloatWin;
167cdf0e10cSrcweir 	mpImplLB = new ImplListBox( pLBParent, nStyle&(~WB_BORDER) );
168cdf0e10cSrcweir 	mpImplLB->SetSelectHdl( LINK( this, ListBox, ImplSelectHdl ) );
169cdf0e10cSrcweir 	mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) );
170cdf0e10cSrcweir 	mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) );
171cdf0e10cSrcweir 	mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) );
172cdf0e10cSrcweir 	mpImplLB->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
173ad3a95a3SSteve Yin 	mpImplLB->SetFocusHdl( LINK( this, ListBox, ImplFocusHdl ) );
174ad3a95a3SSteve Yin 	mpImplLB->SetListItemSelectHdl( LINK( this, ListBox, ImplListItemSelectHdl ) );
175cdf0e10cSrcweir 	mpImplLB->SetPosPixel( Point() );
176a68b38dfSArmin Le Grand     mpImplLB->SetEdgeBlending(GetEdgeBlending());
177cdf0e10cSrcweir 	mpImplLB->Show();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir     mpImplLB->GetDropTarget()->addDropTargetListener(xDrop);
180cdf0e10cSrcweir     mpImplLB->SetDropTraget(xDrop);
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	if ( mpFloatWin )
183cdf0e10cSrcweir 	{
184cdf0e10cSrcweir 		mpFloatWin->SetImplListBox( mpImplLB );
185cdf0e10cSrcweir 		mpImplLB->SetSelectionChangedHdl( LINK( this, ListBox, ImplSelectionChangedHdl ) );
186cdf0e10cSrcweir 	}
187cdf0e10cSrcweir 	else
188cdf0e10cSrcweir 		mpImplLB->GetMainWindow()->AllowGrabFocus( sal_True );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	SetCompoundControl( sal_True );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir // -----------------------------------------------------------------------
194cdf0e10cSrcweir 
ImplInitStyle(WinBits nStyle)195cdf0e10cSrcweir WinBits ListBox::ImplInitStyle( WinBits nStyle )
196cdf0e10cSrcweir {
197cdf0e10cSrcweir 	if ( !(nStyle & WB_NOTABSTOP) )
198cdf0e10cSrcweir 		nStyle |= WB_TABSTOP;
199cdf0e10cSrcweir 	if ( !(nStyle & WB_NOGROUP) )
200cdf0e10cSrcweir 		nStyle |= WB_GROUP;
201cdf0e10cSrcweir 	return nStyle;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
204cdf0e10cSrcweir // -----------------------------------------------------------------------
205cdf0e10cSrcweir 
ImplLoadRes(const ResId & rResId)206cdf0e10cSrcweir void ListBox::ImplLoadRes( const ResId& rResId )
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	Control::ImplLoadRes( rResId );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 	sal_uInt16 nSelPos = ReadShortRes();
211cdf0e10cSrcweir 	sal_uInt16 nNumber = sal::static_int_cast<sal_uInt16>(ReadLongRes());
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	for( sal_uInt16 i = 0; i < nNumber; i++ )
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 		sal_uInt16 nPos = InsertEntry( ReadStringRes(), LISTBOX_APPEND );
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 		long nId = ReadLongRes();
218cdf0e10cSrcweir 		if( nId )
219cdf0e10cSrcweir 			SetEntryData( nPos, (void *)nId );	// ID als UserData
220cdf0e10cSrcweir 	}
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	if( nSelPos < nNumber )
223cdf0e10cSrcweir 		SelectEntryPos( nSelPos );
224cdf0e10cSrcweir }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir // -----------------------------------------------------------------------
227cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplSelectHdl,void *,EMPTYARG)228cdf0e10cSrcweir IMPL_LINK( ListBox, ImplSelectHdl, void*, EMPTYARG )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	sal_Bool bPopup = IsInDropDown();
231cdf0e10cSrcweir 	if( IsDropDownBox() )
232cdf0e10cSrcweir 	{
233cdf0e10cSrcweir 		if( !mpImplLB->IsTravelSelect() )
234cdf0e10cSrcweir 		{
235cdf0e10cSrcweir 			mpFloatWin->EndPopupMode();
236cdf0e10cSrcweir 			mpImplWin->GrabFocus();
237cdf0e10cSrcweir 		}
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 		mpImplWin->SetItemPos( GetSelectEntryPos() );
240cdf0e10cSrcweir 		mpImplWin->SetString( GetSelectEntry() );
241cdf0e10cSrcweir 		if( mpImplLB->GetEntryList()->HasImages() )
242cdf0e10cSrcweir 		{
243cdf0e10cSrcweir 			Image aImage = mpImplLB->GetEntryList()->GetEntryImage( GetSelectEntryPos() );
244cdf0e10cSrcweir 			mpImplWin->SetImage( aImage );
245cdf0e10cSrcweir 		}
246cdf0e10cSrcweir 		mpImplWin->Invalidate();
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || ( bPopup && !IsMultiSelectionEnabled() ) )
250cdf0e10cSrcweir 		Select();
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	return 1;
253cdf0e10cSrcweir }
IMPL_LINK(ListBox,ImplFocusHdl,void *,nPos)254ad3a95a3SSteve Yin IMPL_LINK( ListBox, ImplFocusHdl, void *, nPos )
255ad3a95a3SSteve Yin {
256ad3a95a3SSteve Yin     ImplCallEventListeners( VCLEVENT_LISTBOX_FOCUS , nPos);
257ad3a95a3SSteve Yin 	return 1;
258ad3a95a3SSteve Yin }
IMPL_LINK(ListBox,ImplListItemSelectHdl,void *,EMPTYARG)259ad3a95a3SSteve Yin IMPL_LINK( ListBox, ImplListItemSelectHdl, void*, EMPTYARG )
260ad3a95a3SSteve Yin {
261*6485ffd2SSteve Yin     ImplCallEventListeners( VCLEVENT_DROPDOWN_SELECT );
262ad3a95a3SSteve Yin 	return 1;
263ad3a95a3SSteve Yin }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir // -----------------------------------------------------------------------
266cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplScrollHdl,void *,EMPTYARG)267cdf0e10cSrcweir IMPL_LINK( ListBox, ImplScrollHdl, void*, EMPTYARG )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_LISTBOX_SCROLLED );
270cdf0e10cSrcweir 	return 1;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir // -----------------------------------------------------------------------
274cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplCancelHdl,void *,EMPTYARG)275cdf0e10cSrcweir IMPL_LINK( ListBox, ImplCancelHdl, void*, EMPTYARG )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir 	if( IsInDropDown() )
278cdf0e10cSrcweir 		mpFloatWin->EndPopupMode();
279cdf0e10cSrcweir 
280cdf0e10cSrcweir 	return 1;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir // -----------------------------------------------------------------------
284cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplSelectionChangedHdl,void *,n)285cdf0e10cSrcweir IMPL_LINK( ListBox, ImplSelectionChangedHdl, void*, n )
286cdf0e10cSrcweir {
287cdf0e10cSrcweir 	if ( !mpImplLB->IsTrackingSelect() )
288cdf0e10cSrcweir 	{
289cdf0e10cSrcweir 		sal_uInt16 nChanged = (sal_uInt16)(sal_uLong)n;
290cdf0e10cSrcweir 		const ImplEntryList* pEntryList = mpImplLB->GetEntryList();
291cdf0e10cSrcweir 		if ( pEntryList->IsEntryPosSelected( nChanged ) )
292cdf0e10cSrcweir 		{
293cdf0e10cSrcweir 			// Sollte mal ein ImplPaintEntry werden...
294cdf0e10cSrcweir 			if ( nChanged < pEntryList->GetMRUCount() )
295cdf0e10cSrcweir 				nChanged = pEntryList->FindEntry( pEntryList->GetEntryText( nChanged ) );
296cdf0e10cSrcweir 			mpImplWin->SetItemPos( nChanged );
297cdf0e10cSrcweir 			mpImplWin->SetString( mpImplLB->GetEntryList()->GetEntryText( nChanged ) );
298cdf0e10cSrcweir 			if( mpImplLB->GetEntryList()->HasImages() )
299cdf0e10cSrcweir 			{
300cdf0e10cSrcweir 				Image aImage = mpImplLB->GetEntryList()->GetEntryImage( nChanged );
301cdf0e10cSrcweir 				mpImplWin->SetImage( aImage );
302cdf0e10cSrcweir 			}
303cdf0e10cSrcweir 		}
304cdf0e10cSrcweir 		else
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
307cdf0e10cSrcweir 			mpImplWin->SetString( ImplGetSVEmptyStr() );
308cdf0e10cSrcweir 			Image aImage;
309cdf0e10cSrcweir 			mpImplWin->SetImage( aImage );
310cdf0e10cSrcweir 		}
311cdf0e10cSrcweir 		mpImplWin->Invalidate();
312cdf0e10cSrcweir 	}
313cdf0e10cSrcweir 	return 1;
314cdf0e10cSrcweir }
315cdf0e10cSrcweir 
316cdf0e10cSrcweir // -----------------------------------------------------------------------
317cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplDoubleClickHdl,void *,EMPTYARG)318cdf0e10cSrcweir IMPL_LINK( ListBox, ImplDoubleClickHdl, void*, EMPTYARG )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir 	DoubleClick();
321cdf0e10cSrcweir 	return 1;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir // -----------------------------------------------------------------------
325cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplClickBtnHdl,void *,EMPTYARG)326cdf0e10cSrcweir IMPL_LINK( ListBox, ImplClickBtnHdl, void*, EMPTYARG )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	if( !mpFloatWin->IsInPopupMode() )
329cdf0e10cSrcweir 	{
330cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN );
331cdf0e10cSrcweir 		mpImplWin->GrabFocus();
332cdf0e10cSrcweir 		mpBtn->SetPressed( sal_True );
333cdf0e10cSrcweir 		mpFloatWin->StartFloat( sal_True );
334cdf0e10cSrcweir         ImplCallEventListeners( VCLEVENT_DROPDOWN_OPEN );
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         ImplClearLayoutData();
337cdf0e10cSrcweir         if( mpImplLB )
338cdf0e10cSrcweir             mpImplLB->GetMainWindow()->ImplClearLayoutData();
339cdf0e10cSrcweir         if( mpImplWin )
340cdf0e10cSrcweir             mpImplWin->ImplClearLayoutData();
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	return 0;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir // -----------------------------------------------------------------------
347cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplPopupModeEndHdl,void *,EMPTYARG)348cdf0e10cSrcweir IMPL_LINK( ListBox, ImplPopupModeEndHdl, void*, EMPTYARG )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir     if( mpFloatWin->IsPopupModeCanceled() )
351cdf0e10cSrcweir     {
352cdf0e10cSrcweir         if ( ( mpFloatWin->GetPopupModeStartSaveSelection() != LISTBOX_ENTRY_NOTFOUND )
353cdf0e10cSrcweir                 && !IsEntryPosSelected( mpFloatWin->GetPopupModeStartSaveSelection() ) )
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             mpImplLB->SelectEntry( mpFloatWin->GetPopupModeStartSaveSelection(), sal_True );
356cdf0e10cSrcweir             sal_Bool bTravelSelect = mpImplLB->IsTravelSelect();
357cdf0e10cSrcweir             mpImplLB->SetTravelSelect( sal_True );
358cdf0e10cSrcweir 
359cdf0e10cSrcweir             ImplDelData aCheckDelete;
360cdf0e10cSrcweir             ImplAddDel( &aCheckDelete );
361cdf0e10cSrcweir             Select();
362cdf0e10cSrcweir             if ( aCheckDelete.IsDelete() )
363cdf0e10cSrcweir                 return 0;
364cdf0e10cSrcweir             ImplRemoveDel( &aCheckDelete );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir             mpImplLB->SetTravelSelect( bTravelSelect );
367cdf0e10cSrcweir         }
368cdf0e10cSrcweir     }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir     ImplClearLayoutData();
371cdf0e10cSrcweir     if( mpImplLB )
372cdf0e10cSrcweir         mpImplLB->GetMainWindow()->ImplClearLayoutData();
373cdf0e10cSrcweir     if( mpImplWin )
374cdf0e10cSrcweir         mpImplWin->ImplClearLayoutData();
375cdf0e10cSrcweir 
376cdf0e10cSrcweir     mpBtn->SetPressed( sal_False );
377cdf0e10cSrcweir     ImplCallEventListeners( VCLEVENT_DROPDOWN_CLOSE );
378cdf0e10cSrcweir 	return 0;
379cdf0e10cSrcweir }
380cdf0e10cSrcweir 
381cdf0e10cSrcweir // -----------------------------------------------------------------------
382cdf0e10cSrcweir 
ToggleDropDown()383cdf0e10cSrcweir void ListBox::ToggleDropDown()
384cdf0e10cSrcweir {
385cdf0e10cSrcweir     if( IsDropDownBox() )
386cdf0e10cSrcweir     {
387cdf0e10cSrcweir         if( mpFloatWin->IsInPopupMode() )
388cdf0e10cSrcweir             mpFloatWin->EndPopupMode();
389cdf0e10cSrcweir         else
390cdf0e10cSrcweir         {
391cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN );
392cdf0e10cSrcweir             mpImplWin->GrabFocus();
393cdf0e10cSrcweir             mpBtn->SetPressed( sal_True );
394cdf0e10cSrcweir             mpFloatWin->StartFloat( sal_True );
395cdf0e10cSrcweir             ImplCallEventListeners( VCLEVENT_DROPDOWN_OPEN );
396cdf0e10cSrcweir         }
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir }
399cdf0e10cSrcweir 
400cdf0e10cSrcweir // -----------------------------------------------------------------------
401cdf0e10cSrcweir 
Draw(OutputDevice * pDev,const Point & rPos,const Size & rSize,sal_uLong nFlags)402cdf0e10cSrcweir void ListBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir 	mpImplLB->GetMainWindow()->ImplInitSettings( sal_True, sal_True, sal_True );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	Point aPos = pDev->LogicToPixel( rPos );
407cdf0e10cSrcweir 	Size aSize = pDev->LogicToPixel( rSize );
408cdf0e10cSrcweir 	Font aFont = mpImplLB->GetMainWindow()->GetDrawPixelFont( pDev );
409cdf0e10cSrcweir 	OutDevType eOutDevType = pDev->GetOutDevType();
410cdf0e10cSrcweir 
411cdf0e10cSrcweir 	pDev->Push();
412cdf0e10cSrcweir 	pDev->SetMapMode();
413cdf0e10cSrcweir 	pDev->SetFont( aFont );
414cdf0e10cSrcweir 	pDev->SetTextFillColor();
415cdf0e10cSrcweir 
416cdf0e10cSrcweir 	// Border/Background
417cdf0e10cSrcweir 	pDev->SetLineColor();
418cdf0e10cSrcweir 	pDev->SetFillColor();
419cdf0e10cSrcweir 	sal_Bool bBorder = !(nFlags & WINDOW_DRAW_NOBORDER ) && (GetStyle() & WB_BORDER);
420cdf0e10cSrcweir 	sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && IsControlBackground();
421cdf0e10cSrcweir 	if ( bBorder || bBackground )
422cdf0e10cSrcweir 	{
423cdf0e10cSrcweir 		Rectangle aRect( aPos, aSize );
424cdf0e10cSrcweir 		if ( bBorder )
425cdf0e10cSrcweir 		{
426cdf0e10cSrcweir             ImplDrawFrame( pDev, aRect );
427cdf0e10cSrcweir 		}
428cdf0e10cSrcweir 		if ( bBackground )
429cdf0e10cSrcweir 		{
430cdf0e10cSrcweir 			pDev->SetFillColor( GetControlBackground() );
431cdf0e10cSrcweir 			pDev->DrawRect( aRect );
432cdf0e10cSrcweir 		}
433cdf0e10cSrcweir 	}
434cdf0e10cSrcweir 
435cdf0e10cSrcweir 	// Inhalt
436cdf0e10cSrcweir 	if ( ( nFlags & WINDOW_DRAW_MONO ) || ( eOutDevType == OUTDEV_PRINTER ) )
437cdf0e10cSrcweir 	{
438cdf0e10cSrcweir 		pDev->SetTextColor( Color( COL_BLACK ) );
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir 	else
441cdf0e10cSrcweir 	{
442cdf0e10cSrcweir 		if ( !(nFlags & WINDOW_DRAW_NODISABLE ) && !IsEnabled() )
443cdf0e10cSrcweir 		{
444cdf0e10cSrcweir 			const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
445cdf0e10cSrcweir 			pDev->SetTextColor( rStyleSettings.GetDisableColor() );
446cdf0e10cSrcweir 		}
447cdf0e10cSrcweir 		else
448cdf0e10cSrcweir 		{
449cdf0e10cSrcweir 			pDev->SetTextColor( GetTextColor() );
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 	}
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 	long        nOnePixel = GetDrawPixel( pDev, 1 );
454cdf0e10cSrcweir     sal_uInt16      nTextStyle = TEXT_DRAW_VCENTER;
455cdf0e10cSrcweir     Rectangle   aTextRect( aPos, aSize );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir     if ( GetStyle() & WB_CENTER )
458cdf0e10cSrcweir         nTextStyle |= TEXT_DRAW_CENTER;
459cdf0e10cSrcweir     else if ( GetStyle() & WB_RIGHT )
460cdf0e10cSrcweir         nTextStyle |= TEXT_DRAW_RIGHT;
461cdf0e10cSrcweir     else
462cdf0e10cSrcweir         nTextStyle |= TEXT_DRAW_LEFT;
463cdf0e10cSrcweir 
464cdf0e10cSrcweir     aTextRect.Left() += 3*nOnePixel;
465cdf0e10cSrcweir     aTextRect.Right() -= 3*nOnePixel;
466cdf0e10cSrcweir 
467cdf0e10cSrcweir     if ( IsDropDownBox() )
468cdf0e10cSrcweir 	{
469cdf0e10cSrcweir 		XubString	aText = GetSelectEntry();
470cdf0e10cSrcweir 		long		nTextHeight = pDev->GetTextHeight();
471cdf0e10cSrcweir 		long		nTextWidth = pDev->GetTextWidth( aText );
472cdf0e10cSrcweir 		long		nOffX = 3*nOnePixel;
473cdf0e10cSrcweir 		long		nOffY = (aSize.Height()-nTextHeight) / 2;
474cdf0e10cSrcweir 
475cdf0e10cSrcweir 		// Clipping?
476cdf0e10cSrcweir 		if ( (nOffY < 0) ||
477cdf0e10cSrcweir 			 ((nOffY+nTextHeight) > aSize.Height()) ||
478cdf0e10cSrcweir 			 ((nOffX+nTextWidth) > aSize.Width()) )
479cdf0e10cSrcweir 		{
480cdf0e10cSrcweir 			Rectangle aClip( aPos, aSize );
481cdf0e10cSrcweir 			if ( nTextHeight > aSize.Height() )
482cdf0e10cSrcweir 				aClip.Bottom() += nTextHeight-aSize.Height()+1;  // Damit HP-Drucker nicht 'weg-optimieren'
483cdf0e10cSrcweir 			pDev->IntersectClipRegion( aClip );
484cdf0e10cSrcweir 		}
485cdf0e10cSrcweir 
486cdf0e10cSrcweir 		pDev->DrawText( aTextRect, aText, nTextStyle );
487cdf0e10cSrcweir 	}
488cdf0e10cSrcweir 	else
489cdf0e10cSrcweir 	{
490cdf0e10cSrcweir 		long		nTextHeight = pDev->GetTextHeight();
491cdf0e10cSrcweir 		sal_uInt16		nLines = (sal_uInt16)(aSize.Height() / nTextHeight);
492cdf0e10cSrcweir 		Rectangle	aClip( aPos, aSize );
493cdf0e10cSrcweir 
494cdf0e10cSrcweir         pDev->IntersectClipRegion( aClip );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir         if ( !nLines )
497cdf0e10cSrcweir 			nLines = 1;
498cdf0e10cSrcweir 
499cdf0e10cSrcweir         for ( sal_uInt16 n = 0; n < nLines; n++ )
500cdf0e10cSrcweir 		{
501cdf0e10cSrcweir 			sal_uInt16 nEntry = n+mpImplLB->GetTopEntry();
502cdf0e10cSrcweir 			sal_Bool bSelected = mpImplLB->GetEntryList()->IsEntryPosSelected( nEntry );
503cdf0e10cSrcweir 			if ( bSelected )
504cdf0e10cSrcweir 			{
505cdf0e10cSrcweir 				pDev->SetFillColor( COL_BLACK );
506cdf0e10cSrcweir 				pDev->DrawRect( Rectangle(	Point( aPos.X(), aPos.Y() + n*nTextHeight ),
507cdf0e10cSrcweir 											Point( aPos.X() + aSize.Width(), aPos.Y() + (n+1)*nTextHeight + 2*nOnePixel ) ) );
508cdf0e10cSrcweir 				pDev->SetFillColor();
509cdf0e10cSrcweir 				pDev->SetTextColor( COL_WHITE );
510cdf0e10cSrcweir 			}
511cdf0e10cSrcweir 
512cdf0e10cSrcweir             aTextRect.Top() = aPos.Y() + n*nTextHeight;
513cdf0e10cSrcweir             aTextRect.Bottom() = aTextRect.Top() + nTextHeight;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir             pDev->DrawText( aTextRect, mpImplLB->GetEntryList()->GetEntryText( nEntry ), nTextStyle );
516cdf0e10cSrcweir 
517cdf0e10cSrcweir             if ( bSelected )
518cdf0e10cSrcweir 				pDev->SetTextColor( COL_BLACK );
519cdf0e10cSrcweir 		}
520cdf0e10cSrcweir 	}
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 	pDev->Pop();
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir // -----------------------------------------------------------------------
526cdf0e10cSrcweir 
GetFocus()527cdf0e10cSrcweir void ListBox::GetFocus()
528cdf0e10cSrcweir {
529cdf0e10cSrcweir 	if ( mpImplLB )
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 		if( IsDropDownBox() )
532cdf0e10cSrcweir 			mpImplWin->GrabFocus();
533cdf0e10cSrcweir 		else
534cdf0e10cSrcweir 			mpImplLB->GrabFocus();
535cdf0e10cSrcweir 	}
536cdf0e10cSrcweir 
537cdf0e10cSrcweir 	Control::GetFocus();
538cdf0e10cSrcweir }
539cdf0e10cSrcweir 
540cdf0e10cSrcweir // -----------------------------------------------------------------------
541cdf0e10cSrcweir 
GetPreferredKeyInputWindow()542cdf0e10cSrcweir Window* ListBox::GetPreferredKeyInputWindow()
543cdf0e10cSrcweir {
544cdf0e10cSrcweir 	if ( mpImplLB )
545cdf0e10cSrcweir 	{
546cdf0e10cSrcweir 		if( IsDropDownBox() )
547cdf0e10cSrcweir 			return mpImplWin->GetPreferredKeyInputWindow();
548cdf0e10cSrcweir 		else
549cdf0e10cSrcweir 			return mpImplLB->GetPreferredKeyInputWindow();
550cdf0e10cSrcweir 	}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 	return Control::GetPreferredKeyInputWindow();
553cdf0e10cSrcweir }
554cdf0e10cSrcweir 
555cdf0e10cSrcweir // -----------------------------------------------------------------------
556cdf0e10cSrcweir 
LoseFocus()557cdf0e10cSrcweir void ListBox::LoseFocus()
558cdf0e10cSrcweir {
559cdf0e10cSrcweir 	if( IsDropDownBox() )
560cdf0e10cSrcweir 		mpImplWin->HideFocus();
561cdf0e10cSrcweir 	else
562cdf0e10cSrcweir 		mpImplLB->HideFocus();
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	Control::LoseFocus();
565cdf0e10cSrcweir }
566cdf0e10cSrcweir 
567cdf0e10cSrcweir // -----------------------------------------------------------------------
568cdf0e10cSrcweir 
DataChanged(const DataChangedEvent & rDCEvt)569cdf0e10cSrcweir void ListBox::DataChanged( const DataChangedEvent& rDCEvt )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
572cdf0e10cSrcweir 
573cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
574cdf0e10cSrcweir 		 (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
575cdf0e10cSrcweir 		 ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
576cdf0e10cSrcweir 		  (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
577cdf0e10cSrcweir 	{
578cdf0e10cSrcweir         SetBackground();    // due to a hack in Window::UpdateSettings the background must be reset
579cdf0e10cSrcweir                             // otherwise it will overpaint NWF drawn listboxes
580cdf0e10cSrcweir 		Resize();
581cdf0e10cSrcweir 		mpImplLB->Resize(); // Wird nicht durch ListBox::Resize() gerufen, wenn sich die ImplLB nicht aendert.
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 		if ( mpImplWin )
584cdf0e10cSrcweir 		{
585cdf0e10cSrcweir 			mpImplWin->SetSettings( GetSettings() );	// Falls noch nicht eingestellt...
586cdf0e10cSrcweir 			ImplInitFieldSettings( mpImplWin, sal_True, sal_True, sal_True );
587cdf0e10cSrcweir 
588cdf0e10cSrcweir 			mpBtn->SetSettings( GetSettings() );
589cdf0e10cSrcweir 			ImplInitDropDownButton( mpBtn );
590cdf0e10cSrcweir 		}
591cdf0e10cSrcweir 
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 		if ( IsDropDownBox() )
594cdf0e10cSrcweir 			Invalidate();
595cdf0e10cSrcweir 	}
596cdf0e10cSrcweir }
597cdf0e10cSrcweir 
598cdf0e10cSrcweir // -----------------------------------------------------------------------
599cdf0e10cSrcweir 
EnableAutoSize(bool bAuto)600a68b38dfSArmin Le Grand void ListBox::EnableAutoSize( bool bAuto )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir 	mbDDAutoSize = bAuto;
603cdf0e10cSrcweir 	if ( mpFloatWin )
604cdf0e10cSrcweir 	{
605cdf0e10cSrcweir 		if ( bAuto && !mpFloatWin->GetDropDownLineCount() )
606a68b38dfSArmin Le Grand         {
607a68b38dfSArmin Le Grand             // use GetListBoxMaximumLineCount here; before, was on fixed number of five
608a68b38dfSArmin Le Grand             AdaptDropDownLineCountToMaximum();
609a68b38dfSArmin Le Grand         }
610cdf0e10cSrcweir 		else if ( !bAuto )
611a68b38dfSArmin Le Grand         {
612cdf0e10cSrcweir 			mpFloatWin->SetDropDownLineCount( 0 );
613a68b38dfSArmin Le Grand         }
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir // -----------------------------------------------------------------------
618cdf0e10cSrcweir 
EnableDDAutoWidth(sal_Bool b)619cdf0e10cSrcweir void ListBox::EnableDDAutoWidth( sal_Bool b )
620cdf0e10cSrcweir {
621cdf0e10cSrcweir     if ( mpFloatWin )
622cdf0e10cSrcweir         mpFloatWin->SetAutoWidth( b );
623cdf0e10cSrcweir }
624cdf0e10cSrcweir 
625cdf0e10cSrcweir // -----------------------------------------------------------------------
626cdf0e10cSrcweir 
IsDDAutoWidthEnabled() const627cdf0e10cSrcweir sal_Bool ListBox::IsDDAutoWidthEnabled() const
628cdf0e10cSrcweir {
629cdf0e10cSrcweir     return mpFloatWin ? mpFloatWin->IsAutoWidth() : sal_False;
630cdf0e10cSrcweir }
631cdf0e10cSrcweir 
632cdf0e10cSrcweir // -----------------------------------------------------------------------
633cdf0e10cSrcweir 
SetDropDownLineCount(sal_uInt16 nLines)634cdf0e10cSrcweir void ListBox::SetDropDownLineCount( sal_uInt16 nLines )
635cdf0e10cSrcweir {
636cdf0e10cSrcweir     mnLineCount = nLines;
637cdf0e10cSrcweir 	if ( mpFloatWin )
638cdf0e10cSrcweir 		mpFloatWin->SetDropDownLineCount( mnLineCount );
639cdf0e10cSrcweir }
640cdf0e10cSrcweir 
641cdf0e10cSrcweir // -----------------------------------------------------------------------
642cdf0e10cSrcweir 
AdaptDropDownLineCountToMaximum()643a68b38dfSArmin Le Grand void ListBox::AdaptDropDownLineCountToMaximum()
644a68b38dfSArmin Le Grand {
645a68b38dfSArmin Le Grand     // adapt to maximum allowed number
646a68b38dfSArmin Le Grand     SetDropDownLineCount(std::min(GetEntryCount(), GetSettings().GetStyleSettings().GetListBoxMaximumLineCount()));
647a68b38dfSArmin Le Grand }
648a68b38dfSArmin Le Grand 
649a68b38dfSArmin Le Grand // -----------------------------------------------------------------------
650a68b38dfSArmin Le Grand 
GetDropDownLineCount() const651cdf0e10cSrcweir sal_uInt16 ListBox::GetDropDownLineCount() const
652cdf0e10cSrcweir {
653cdf0e10cSrcweir     if ( mpFloatWin )
654cdf0e10cSrcweir         return mpFloatWin->GetDropDownLineCount();
655cdf0e10cSrcweir 	return mnLineCount;
656cdf0e10cSrcweir }
657cdf0e10cSrcweir 
658cdf0e10cSrcweir // -----------------------------------------------------------------------
659cdf0e10cSrcweir 
SetPosSizePixel(long nX,long nY,long nWidth,long nHeight,sal_uInt16 nFlags)660cdf0e10cSrcweir void ListBox::SetPosSizePixel( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir 	if( IsDropDownBox() && ( nFlags & WINDOW_POSSIZE_SIZE ) )
663cdf0e10cSrcweir 	{
664cdf0e10cSrcweir 		Size aPrefSz = mpFloatWin->GetPrefSize();
665cdf0e10cSrcweir 		if ( ( nFlags & WINDOW_POSSIZE_HEIGHT ) && ( nHeight >= 2*mnDDHeight ) )
666cdf0e10cSrcweir 			aPrefSz.Height() = nHeight-mnDDHeight;
667cdf0e10cSrcweir 		if ( nFlags & WINDOW_POSSIZE_WIDTH )
668cdf0e10cSrcweir 			aPrefSz.Width() = nWidth;
669cdf0e10cSrcweir 		mpFloatWin->SetPrefSize( aPrefSz );
670cdf0e10cSrcweir 
671cdf0e10cSrcweir 		if ( IsAutoSizeEnabled() && ! (nFlags & WINDOW_POSSIZE_DROPDOWN) )
672cdf0e10cSrcweir 			nHeight = mnDDHeight;
673cdf0e10cSrcweir 	}
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 	Control::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
676cdf0e10cSrcweir }
677cdf0e10cSrcweir 
678cdf0e10cSrcweir // -----------------------------------------------------------------------
679cdf0e10cSrcweir 
Resize()680cdf0e10cSrcweir void ListBox::Resize()
681cdf0e10cSrcweir {
682cdf0e10cSrcweir 	Size aOutSz = GetOutputSizePixel();
683cdf0e10cSrcweir 	if( IsDropDownBox() )
684cdf0e10cSrcweir 	{
685cdf0e10cSrcweir 		// initialize the dropdown button size with the standard scrollbar width
686cdf0e10cSrcweir 		long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
687cdf0e10cSrcweir 		long	nTop = 0;
688cdf0e10cSrcweir 		long	nBottom = aOutSz.Height();
689cdf0e10cSrcweir 
690cdf0e10cSrcweir         // note: in case of no border, pBorder will actually be this
691cdf0e10cSrcweir 		Window *pBorder = GetWindow( WINDOW_BORDER );
692cdf0e10cSrcweir 		ImplControlValue aControlValue;
693cdf0e10cSrcweir 		Point aPoint;
694cdf0e10cSrcweir 		Rectangle aContent, aBound;
695cdf0e10cSrcweir 
696cdf0e10cSrcweir 		// use the full extent of the control
697cdf0e10cSrcweir 		Rectangle aArea( aPoint, pBorder->GetOutputSizePixel() );
698cdf0e10cSrcweir 
699cdf0e10cSrcweir 		if ( GetNativeControlRegion( CTRL_LISTBOX, PART_BUTTON_DOWN,
700cdf0e10cSrcweir 					aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
701cdf0e10cSrcweir 		{
702cdf0e10cSrcweir 			// convert back from border space to local coordinates
703cdf0e10cSrcweir 			aPoint = pBorder->ScreenToOutputPixel( OutputToScreenPixel( aPoint ) );
704cdf0e10cSrcweir 			aContent.Move( -aPoint.X(), -aPoint.Y() );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 			// use the themes drop down size for the button
707cdf0e10cSrcweir 			aOutSz.Width() = aContent.Left();
708cdf0e10cSrcweir 			mpBtn->SetPosSizePixel( aContent.Left(), nTop, aContent.Right(), (nBottom-nTop) );
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 			// adjust the size of the edit field
711cdf0e10cSrcweir 			if ( GetNativeControlRegion( CTRL_LISTBOX, PART_SUB_EDIT,
712cdf0e10cSrcweir 						aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
713cdf0e10cSrcweir 			{
714cdf0e10cSrcweir 				// convert back from border space to local coordinates
715cdf0e10cSrcweir 				aContent.Move( -aPoint.X(), -aPoint.Y() );
716cdf0e10cSrcweir 
717cdf0e10cSrcweir 				// use the themes drop down size
718cdf0e10cSrcweir                 if( ! (GetStyle() & WB_BORDER) && ImplGetSVData()->maNWFData.mbNoFocusRects )
719cdf0e10cSrcweir                 {
720cdf0e10cSrcweir                     // no border but focus ring behavior -> we have a problem; the
721cdf0e10cSrcweir                     // native rect relies on the border to draw the focus
722cdf0e10cSrcweir                     // let's do the best we can and center vertically, so it doesn't look
723cdf0e10cSrcweir                     // completely wrong.
724cdf0e10cSrcweir                     Size aSz( GetOutputSizePixel() );
725cdf0e10cSrcweir                     long nDiff = aContent.Top() - (aSz.Height() - aContent.GetHeight())/2;
726cdf0e10cSrcweir                     aContent.Top() -= nDiff;
727cdf0e10cSrcweir                     aContent.Bottom() -= nDiff;
728cdf0e10cSrcweir                 }
729cdf0e10cSrcweir                 mpImplWin->SetPosSizePixel( aContent.TopLeft(), aContent.GetSize() );
730cdf0e10cSrcweir 			}
731cdf0e10cSrcweir 			else
732cdf0e10cSrcweir 				mpImplWin->SetSizePixel( aOutSz );
733cdf0e10cSrcweir 		}
734cdf0e10cSrcweir 		else
735cdf0e10cSrcweir 		{
736cdf0e10cSrcweir 			nSBWidth = CalcZoom( nSBWidth );
737cdf0e10cSrcweir 			mpImplWin->SetPosSizePixel( 0, 0, aOutSz.Width() - nSBWidth, aOutSz.Height() );
738cdf0e10cSrcweir 			mpBtn->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
739cdf0e10cSrcweir 		}
740cdf0e10cSrcweir 	}
741cdf0e10cSrcweir 	else
742cdf0e10cSrcweir 	{
743cdf0e10cSrcweir 		mpImplLB->SetSizePixel( aOutSz );
744cdf0e10cSrcweir 	}
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 	// FloatingWindow-Groesse auch im unsichtbare Zustand auf Stand halten,
747cdf0e10cSrcweir 	// weil KEY_PGUP/DOWN ausgewertet wird...
748cdf0e10cSrcweir 	if ( mpFloatWin )
749cdf0e10cSrcweir 		mpFloatWin->SetSizePixel( mpFloatWin->CalcFloatSize() );
750cdf0e10cSrcweir 
751cdf0e10cSrcweir     Control::Resize();
752cdf0e10cSrcweir }
753cdf0e10cSrcweir 
754cdf0e10cSrcweir // -----------------------------------------------------------------------
755cdf0e10cSrcweir 
FillLayoutData() const756cdf0e10cSrcweir void ListBox::FillLayoutData() const
757cdf0e10cSrcweir {
758cdf0e10cSrcweir     mpControlData->mpLayoutData = new vcl::ControlLayoutData();
759cdf0e10cSrcweir     const Control* pMainWin = mpImplLB->GetMainWindow();
760cdf0e10cSrcweir     if( mpFloatWin )
761cdf0e10cSrcweir     {
762cdf0e10cSrcweir         // dropdown mode
763cdf0e10cSrcweir         AppendLayoutData( *mpImplWin );
764cdf0e10cSrcweir         mpImplWin->SetLayoutDataParent( this );
765cdf0e10cSrcweir         if( mpFloatWin->IsReallyVisible() )
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             AppendLayoutData( *pMainWin );
768cdf0e10cSrcweir             pMainWin->SetLayoutDataParent( this );
769cdf0e10cSrcweir         }
770cdf0e10cSrcweir     }
771cdf0e10cSrcweir     else
772cdf0e10cSrcweir     {
773cdf0e10cSrcweir         AppendLayoutData( *pMainWin );
774cdf0e10cSrcweir         pMainWin->SetLayoutDataParent( this );
775cdf0e10cSrcweir     }
776cdf0e10cSrcweir }
777cdf0e10cSrcweir 
778cdf0e10cSrcweir // -----------------------------------------------------------------------
779cdf0e10cSrcweir 
GetIndexForPoint(const Point & rPoint,sal_uInt16 & rPos) const780cdf0e10cSrcweir long ListBox::GetIndexForPoint( const Point& rPoint, sal_uInt16& rPos ) const
781cdf0e10cSrcweir {
782cdf0e10cSrcweir     if( !HasLayoutData() )
783cdf0e10cSrcweir         FillLayoutData();
784cdf0e10cSrcweir 
785cdf0e10cSrcweir     // check whether rPoint fits at all
786cdf0e10cSrcweir     long nIndex = Control::GetIndexForPoint( rPoint );
787cdf0e10cSrcweir     if( nIndex != -1 )
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         // point must be either in main list window
790cdf0e10cSrcweir         // or in impl window (dropdown case)
791cdf0e10cSrcweir         ImplListBoxWindow* pMain = mpImplLB->GetMainWindow();
792cdf0e10cSrcweir 
793cdf0e10cSrcweir         // convert coordinates to ImplListBoxWindow pixel coordinate space
794cdf0e10cSrcweir         Point aConvPoint = LogicToPixel( rPoint );
795cdf0e10cSrcweir         aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
796cdf0e10cSrcweir         aConvPoint = pMain->AbsoluteScreenToOutputPixel( aConvPoint );
797cdf0e10cSrcweir         aConvPoint = pMain->PixelToLogic( aConvPoint );
798cdf0e10cSrcweir 
799cdf0e10cSrcweir         // try to find entry
800cdf0e10cSrcweir         sal_uInt16 nEntry = pMain->GetEntryPosForPoint( aConvPoint );
801cdf0e10cSrcweir         if( nEntry == LISTBOX_ENTRY_NOTFOUND )
802cdf0e10cSrcweir         {
803cdf0e10cSrcweir             // not found, maybe dropdown case
804cdf0e10cSrcweir             if( mpImplWin && mpImplWin->IsReallyVisible() )
805cdf0e10cSrcweir             {
806cdf0e10cSrcweir                 // convert to impl window pixel coordinates
807cdf0e10cSrcweir                 aConvPoint = LogicToPixel( rPoint );
808cdf0e10cSrcweir                 aConvPoint = OutputToAbsoluteScreenPixel( aConvPoint );
809cdf0e10cSrcweir                 aConvPoint = mpImplWin->AbsoluteScreenToOutputPixel( aConvPoint );
810cdf0e10cSrcweir 
811cdf0e10cSrcweir                 // check whether converted point is inside impl window
812cdf0e10cSrcweir                 Size aImplWinSize = mpImplWin->GetOutputSizePixel();
813cdf0e10cSrcweir                 if( aConvPoint.X() >= 0 && aConvPoint.Y() >= 0 && aConvPoint.X() < aImplWinSize.Width() && aConvPoint.Y() < aImplWinSize.Height() )
814cdf0e10cSrcweir                 {
815cdf0e10cSrcweir                     // inside the impl window, the position is the current item pos
816cdf0e10cSrcweir                     rPos = mpImplWin->GetItemPos();
817cdf0e10cSrcweir                 }
818cdf0e10cSrcweir                 else
819cdf0e10cSrcweir                     nIndex = -1;
820cdf0e10cSrcweir             }
821cdf0e10cSrcweir             else
822cdf0e10cSrcweir                 nIndex = -1;
823cdf0e10cSrcweir         }
824cdf0e10cSrcweir         else
825cdf0e10cSrcweir             rPos = nEntry;
826cdf0e10cSrcweir 
827cdf0e10cSrcweir         DBG_ASSERT( nIndex != -1, "found index for point, but relative index failed" );
828cdf0e10cSrcweir     }
829cdf0e10cSrcweir 
830cdf0e10cSrcweir     // get line relative index
831cdf0e10cSrcweir     if( nIndex != -1 )
832cdf0e10cSrcweir         nIndex = ToRelativeLineIndex( nIndex );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir     return nIndex;
835cdf0e10cSrcweir }
836cdf0e10cSrcweir 
837cdf0e10cSrcweir // -----------------------------------------------------------------------
838cdf0e10cSrcweir 
StateChanged(StateChangedType nType)839cdf0e10cSrcweir void ListBox::StateChanged( StateChangedType nType )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	if( nType == STATE_CHANGE_READONLY )
842cdf0e10cSrcweir 	{
843cdf0e10cSrcweir 		if( mpImplWin )
844cdf0e10cSrcweir 			mpImplWin->Enable( !IsReadOnly() );
845cdf0e10cSrcweir 		if( mpBtn )
846cdf0e10cSrcweir 			mpBtn->Enable( !IsReadOnly() );
847cdf0e10cSrcweir 	}
848cdf0e10cSrcweir 	else if( nType == STATE_CHANGE_ENABLE )
849cdf0e10cSrcweir 	{
850cdf0e10cSrcweir 		mpImplLB->Enable( IsEnabled() );
851cdf0e10cSrcweir 		if( mpImplWin )
852cdf0e10cSrcweir 		{
853cdf0e10cSrcweir 			mpImplWin->Enable( IsEnabled() );
854cdf0e10cSrcweir 			if ( IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL)
855cdf0e10cSrcweir 					&& ! IsNativeControlSupported(CTRL_LISTBOX, PART_BUTTON_DOWN) )
856cdf0e10cSrcweir 			{
857cdf0e10cSrcweir 				GetWindow( WINDOW_BORDER )->Invalidate( INVALIDATE_NOERASE );
858cdf0e10cSrcweir 			}
859cdf0e10cSrcweir 			else
860cdf0e10cSrcweir 				mpImplWin->Invalidate();
861cdf0e10cSrcweir 		}
862cdf0e10cSrcweir 		if( mpBtn )
863cdf0e10cSrcweir 			mpBtn->Enable( IsEnabled() );
864cdf0e10cSrcweir 	}
865cdf0e10cSrcweir 	else if( nType == STATE_CHANGE_UPDATEMODE )
866cdf0e10cSrcweir 	{
867cdf0e10cSrcweir 		mpImplLB->SetUpdateMode( IsUpdateMode() );
868cdf0e10cSrcweir 	}
869cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_ZOOM )
870cdf0e10cSrcweir 	{
871cdf0e10cSrcweir 		mpImplLB->SetZoom( GetZoom() );
872cdf0e10cSrcweir 		if ( mpImplWin )
873cdf0e10cSrcweir 		{
874cdf0e10cSrcweir 			mpImplWin->SetZoom( GetZoom() );
875cdf0e10cSrcweir 			mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
876cdf0e10cSrcweir 			mpImplWin->Invalidate();
877cdf0e10cSrcweir 		}
878cdf0e10cSrcweir 		Resize();
879cdf0e10cSrcweir 	}
880cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLFONT )
881cdf0e10cSrcweir 	{
882cdf0e10cSrcweir 		mpImplLB->SetControlFont( GetControlFont() );
883cdf0e10cSrcweir 		if ( mpImplWin )
884cdf0e10cSrcweir 		{
885cdf0e10cSrcweir 			mpImplWin->SetControlFont( GetControlFont() );
886cdf0e10cSrcweir 			mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
887cdf0e10cSrcweir 			mpImplWin->Invalidate();
888cdf0e10cSrcweir 		}
889cdf0e10cSrcweir 		Resize();
890cdf0e10cSrcweir 	}
891cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
892cdf0e10cSrcweir 	{
893cdf0e10cSrcweir 		mpImplLB->SetControlForeground( GetControlForeground() );
894cdf0e10cSrcweir 		if ( mpImplWin )
895cdf0e10cSrcweir 		{
896cdf0e10cSrcweir 			mpImplWin->SetControlForeground( GetControlForeground() );
897cdf0e10cSrcweir 			mpImplWin->SetTextColor( GetControlForeground() );
898cdf0e10cSrcweir 			mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
899cdf0e10cSrcweir 			mpImplWin->Invalidate();
900cdf0e10cSrcweir 		}
901cdf0e10cSrcweir 	}
902cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
903cdf0e10cSrcweir 	{
904cdf0e10cSrcweir 		mpImplLB->SetControlBackground( GetControlBackground() );
905cdf0e10cSrcweir 		if ( mpImplWin )
906cdf0e10cSrcweir 		{
907cdf0e10cSrcweir 			if ( mpImplWin->IsNativeControlSupported(CTRL_LISTBOX, PART_ENTIRE_CONTROL) )
908cdf0e10cSrcweir 			{
909cdf0e10cSrcweir 				// Transparent background
910cdf0e10cSrcweir 				mpImplWin->SetBackground();
911cdf0e10cSrcweir 				mpImplWin->SetControlBackground();
912cdf0e10cSrcweir 			}
913cdf0e10cSrcweir 			else
914cdf0e10cSrcweir 			{
915cdf0e10cSrcweir 				mpImplWin->SetBackground( mpImplLB->GetMainWindow()->GetControlBackground() );
916cdf0e10cSrcweir 				mpImplWin->SetControlBackground( mpImplLB->GetMainWindow()->GetControlBackground() );
917cdf0e10cSrcweir 			}
918cdf0e10cSrcweir 			mpImplWin->SetFont( mpImplLB->GetMainWindow()->GetFont() );
919cdf0e10cSrcweir 			mpImplWin->Invalidate();
920cdf0e10cSrcweir 		}
921cdf0e10cSrcweir 	}
922cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
923cdf0e10cSrcweir 	{
924cdf0e10cSrcweir 		SetStyle( ImplInitStyle( GetStyle() ) );
925cdf0e10cSrcweir 		mpImplLB->GetMainWindow()->EnableSort( ( GetStyle() & WB_SORT ) ? sal_True : sal_False );
926cdf0e10cSrcweir 	    sal_Bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) ? sal_True : sal_False;
927cdf0e10cSrcweir 	    mpImplLB->SetMultiSelectionSimpleMode( bSimpleMode );
928cdf0e10cSrcweir 	}
929cdf0e10cSrcweir     else if( nType == STATE_CHANGE_MIRRORING )
930cdf0e10cSrcweir     {
931cdf0e10cSrcweir         if( mpBtn )
932cdf0e10cSrcweir         {
933cdf0e10cSrcweir             mpBtn->EnableRTL( IsRTLEnabled() );
934cdf0e10cSrcweir             ImplInitDropDownButton( mpBtn );
935cdf0e10cSrcweir         }
936cdf0e10cSrcweir         mpImplLB->EnableRTL( IsRTLEnabled() );
937cdf0e10cSrcweir         if( mpImplWin )
938cdf0e10cSrcweir             mpImplWin->EnableRTL( IsRTLEnabled() );
939cdf0e10cSrcweir         Resize();
940cdf0e10cSrcweir     }
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 	Control::StateChanged( nType );
943cdf0e10cSrcweir }
944cdf0e10cSrcweir 
945cdf0e10cSrcweir // -----------------------------------------------------------------------
946cdf0e10cSrcweir 
PreNotify(NotifyEvent & rNEvt)947cdf0e10cSrcweir long ListBox::PreNotify( NotifyEvent& rNEvt )
948cdf0e10cSrcweir {
949cdf0e10cSrcweir 	long nDone = 0;
950cdf0e10cSrcweir 	if ( mpImplLB )
951cdf0e10cSrcweir 	{
952cdf0e10cSrcweir 		if( ( rNEvt.GetType() == EVENT_KEYINPUT ) && ( rNEvt.GetWindow() == mpImplWin ) )
953cdf0e10cSrcweir 		{
954cdf0e10cSrcweir 			KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
955cdf0e10cSrcweir 			switch( aKeyEvt.GetKeyCode().GetCode() )
956cdf0e10cSrcweir 			{
957cdf0e10cSrcweir 				case KEY_DOWN:
958cdf0e10cSrcweir 				{
959cdf0e10cSrcweir 					if( mpFloatWin && !mpFloatWin->IsInPopupMode() &&
960cdf0e10cSrcweir 						aKeyEvt.GetKeyCode().IsMod2() )
961cdf0e10cSrcweir 					{
962cdf0e10cSrcweir                         ImplCallEventListeners( VCLEVENT_DROPDOWN_PRE_OPEN );
963cdf0e10cSrcweir 						mpBtn->SetPressed( sal_True );
964cdf0e10cSrcweir 						mpFloatWin->StartFloat( sal_False );
965cdf0e10cSrcweir                         ImplCallEventListeners( VCLEVENT_DROPDOWN_OPEN );
966cdf0e10cSrcweir 						nDone = 1;
967cdf0e10cSrcweir 					}
968cdf0e10cSrcweir 					else
969cdf0e10cSrcweir 					{
970cdf0e10cSrcweir 						nDone = mpImplLB->ProcessKeyInput( aKeyEvt );
971cdf0e10cSrcweir 					}
972cdf0e10cSrcweir 				}
973cdf0e10cSrcweir 				break;
974cdf0e10cSrcweir 				case KEY_UP:
975cdf0e10cSrcweir 				{
976cdf0e10cSrcweir 					if( mpFloatWin && mpFloatWin->IsInPopupMode() &&
977cdf0e10cSrcweir 						aKeyEvt.GetKeyCode().IsMod2() )
978cdf0e10cSrcweir 					{
979cdf0e10cSrcweir 						mpFloatWin->EndPopupMode();
980cdf0e10cSrcweir 						nDone = 1;
981cdf0e10cSrcweir 					}
982cdf0e10cSrcweir 					else
983cdf0e10cSrcweir 					{
984cdf0e10cSrcweir 						nDone = mpImplLB->ProcessKeyInput( aKeyEvt );
985cdf0e10cSrcweir 					}
986cdf0e10cSrcweir 				}
987cdf0e10cSrcweir 				break;
988cdf0e10cSrcweir 				case KEY_RETURN:
989cdf0e10cSrcweir 				{
990cdf0e10cSrcweir 					if( IsInDropDown() )
991cdf0e10cSrcweir 					{
992cdf0e10cSrcweir 						mpImplLB->ProcessKeyInput( aKeyEvt );
993cdf0e10cSrcweir 						nDone = 1;
994cdf0e10cSrcweir 					}
995cdf0e10cSrcweir 				}
996cdf0e10cSrcweir 				break;
997cdf0e10cSrcweir 
998cdf0e10cSrcweir 				default:
999cdf0e10cSrcweir                 {
1000cdf0e10cSrcweir 					nDone = mpImplLB->ProcessKeyInput( aKeyEvt );
1001cdf0e10cSrcweir                 }
1002cdf0e10cSrcweir 			}
1003cdf0e10cSrcweir 		}
1004cdf0e10cSrcweir 		else if ( rNEvt.GetType() == EVENT_LOSEFOCUS )
1005cdf0e10cSrcweir 		{
1006cdf0e10cSrcweir 			if ( IsInDropDown() && !HasChildPathFocus( sal_True ) )
1007cdf0e10cSrcweir 				mpFloatWin->EndPopupMode();
1008cdf0e10cSrcweir 		}
1009cdf0e10cSrcweir 		else if ( (rNEvt.GetType() == EVENT_COMMAND) &&
1010cdf0e10cSrcweir 				  (rNEvt.GetCommandEvent()->GetCommand() == COMMAND_WHEEL) &&
1011cdf0e10cSrcweir 				  (rNEvt.GetWindow() == mpImplWin) )
1012cdf0e10cSrcweir 		{
1013cdf0e10cSrcweir             sal_uInt16 nWheelBehavior( GetSettings().GetMouseSettings().GetWheelBehavior() );
1014cdf0e10cSrcweir             if  (   ( nWheelBehavior == MOUSE_WHEEL_ALWAYS )
1015cdf0e10cSrcweir                 ||  (   ( nWheelBehavior == MOUSE_WHEEL_FOCUS_ONLY )
1016cdf0e10cSrcweir                     &&  HasChildPathFocus()
1017cdf0e10cSrcweir                     )
1018cdf0e10cSrcweir                 )
1019cdf0e10cSrcweir             {
1020cdf0e10cSrcweir                 nDone = mpImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() );
1021cdf0e10cSrcweir             }
1022cdf0e10cSrcweir             else
1023cdf0e10cSrcweir             {
1024cdf0e10cSrcweir                 nDone = 0;  // don't eat this event, let the default handling happen (i.e. scroll the context)
1025cdf0e10cSrcweir             }
1026cdf0e10cSrcweir 		}
1027cdf0e10cSrcweir 	}
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir 	return nDone ? nDone : Control::PreNotify( rNEvt );
1030cdf0e10cSrcweir }
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir // -----------------------------------------------------------------------
1033cdf0e10cSrcweir 
Select()1034cdf0e10cSrcweir void ListBox::Select()
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir     ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_SELECT, maSelectHdl, this );
1037cdf0e10cSrcweir }
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir // -----------------------------------------------------------------------
1040cdf0e10cSrcweir 
DoubleClick()1041cdf0e10cSrcweir void ListBox::DoubleClick()
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir     ImplCallEventListenersAndHandler( VCLEVENT_LISTBOX_DOUBLECLICK, maDoubleClickHdl, this );
1044cdf0e10cSrcweir }
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir // -----------------------------------------------------------------------
1047cdf0e10cSrcweir 
Clear()1048cdf0e10cSrcweir void ListBox::Clear()
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir 	mpImplLB->Clear();
1051cdf0e10cSrcweir 	if( IsDropDownBox() )
1052cdf0e10cSrcweir 	{
1053cdf0e10cSrcweir 		mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
1054cdf0e10cSrcweir 		mpImplWin->SetString( ImplGetSVEmptyStr() );
1055cdf0e10cSrcweir 		Image aImage;
1056cdf0e10cSrcweir 		mpImplWin->SetImage( aImage );
1057cdf0e10cSrcweir 		mpImplWin->Invalidate();
1058cdf0e10cSrcweir 	}
1059cdf0e10cSrcweir     CallEventListeners( VCLEVENT_LISTBOX_ITEMREMOVED, (void*) sal_IntPtr(-1) );
1060cdf0e10cSrcweir }
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir // -----------------------------------------------------------------------
1063cdf0e10cSrcweir 
SetNoSelection()1064cdf0e10cSrcweir void ListBox::SetNoSelection()
1065cdf0e10cSrcweir {
1066cdf0e10cSrcweir 	mpImplLB->SetNoSelection();
1067cdf0e10cSrcweir 	if( IsDropDownBox() )
1068cdf0e10cSrcweir 	{
1069cdf0e10cSrcweir 		mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
1070cdf0e10cSrcweir 		mpImplWin->SetString( ImplGetSVEmptyStr() );
1071cdf0e10cSrcweir 		Image aImage;
1072cdf0e10cSrcweir 		mpImplWin->SetImage( aImage );
1073cdf0e10cSrcweir 		mpImplWin->Invalidate();
1074cdf0e10cSrcweir 	}
1075ad3a95a3SSteve Yin 	NotifyVCLEvent( VCLEVENT_LISTBOX_STATEUPDATE);
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir // -----------------------------------------------------------------------
1079cdf0e10cSrcweir 
InsertEntry(const XubString & rStr,sal_uInt16 nPos)1080cdf0e10cSrcweir sal_uInt16 ListBox::InsertEntry( const XubString& rStr, sal_uInt16 nPos )
1081cdf0e10cSrcweir {
1082cdf0e10cSrcweir 	sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr );
1083cdf0e10cSrcweir 	nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());
1084cdf0e10cSrcweir     CallEventListeners( VCLEVENT_LISTBOX_ITEMADDED, (void*) sal_IntPtr(nRealPos) );
1085cdf0e10cSrcweir 	return nRealPos;
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir 
1088cdf0e10cSrcweir // -----------------------------------------------------------------------
1089cdf0e10cSrcweir 
InsertEntry(const Image & rImage,sal_uInt16 nPos)1090cdf0e10cSrcweir sal_uInt16 ListBox::InsertEntry( const Image& rImage, sal_uInt16 nPos )
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir 	sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rImage );
1093cdf0e10cSrcweir 	nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());
1094cdf0e10cSrcweir     CallEventListeners( VCLEVENT_LISTBOX_ITEMADDED, (void*) sal_IntPtr(nRealPos) );
1095cdf0e10cSrcweir 	return nRealPos;
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir 
1098cdf0e10cSrcweir // -----------------------------------------------------------------------
1099cdf0e10cSrcweir 
InsertEntry(const XubString & rStr,const Image & rImage,sal_uInt16 nPos)1100cdf0e10cSrcweir sal_uInt16 ListBox::InsertEntry( const XubString& rStr, const Image& rImage, sal_uInt16 nPos )
1101cdf0e10cSrcweir {
1102cdf0e10cSrcweir 	sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr, rImage );
1103cdf0e10cSrcweir 	nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());
1104cdf0e10cSrcweir     CallEventListeners( VCLEVENT_LISTBOX_ITEMADDED, (void*) sal_IntPtr(nRealPos) );
1105cdf0e10cSrcweir 	return nRealPos;
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir 
1108cdf0e10cSrcweir // -----------------------------------------------------------------------
1109cdf0e10cSrcweir 
RemoveEntry(const XubString & rStr)1110cdf0e10cSrcweir void ListBox::RemoveEntry( const XubString& rStr )
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir 	RemoveEntry( GetEntryPos( rStr ) );
1113cdf0e10cSrcweir }
1114cdf0e10cSrcweir 
1115cdf0e10cSrcweir // -----------------------------------------------------------------------
1116cdf0e10cSrcweir 
RemoveEntry(sal_uInt16 nPos)1117cdf0e10cSrcweir void ListBox::RemoveEntry( sal_uInt16 nPos )
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir 	mpImplLB->RemoveEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1120cdf0e10cSrcweir     CallEventListeners( VCLEVENT_LISTBOX_ITEMREMOVED, (void*) sal_IntPtr(nPos) );
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir // -----------------------------------------------------------------------
1124cdf0e10cSrcweir 
GetEntryImage(sal_uInt16 nPos) const1125cdf0e10cSrcweir Image ListBox::GetEntryImage( sal_uInt16 nPos ) const
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir     if ( mpImplLB->GetEntryList()->HasEntryImage( nPos ) )
1128cdf0e10cSrcweir         return mpImplLB->GetEntryList()->GetEntryImage( nPos );
1129cdf0e10cSrcweir     return Image();
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir // -----------------------------------------------------------------------
1133cdf0e10cSrcweir 
GetEntryPos(const XubString & rStr) const1134cdf0e10cSrcweir sal_uInt16 ListBox::GetEntryPos( const XubString& rStr ) const
1135cdf0e10cSrcweir {
1136cdf0e10cSrcweir 	sal_uInt16 nPos = mpImplLB->GetEntryList()->FindEntry( rStr );
1137cdf0e10cSrcweir 	if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1138cdf0e10cSrcweir 		nPos = sal::static_int_cast<sal_uInt16>(nPos - mpImplLB->GetEntryList()->GetMRUCount());
1139cdf0e10cSrcweir 	return nPos;
1140cdf0e10cSrcweir }
1141cdf0e10cSrcweir 
1142cdf0e10cSrcweir // -----------------------------------------------------------------------
1143cdf0e10cSrcweir 
GetEntryPos(const void * pData) const1144cdf0e10cSrcweir sal_uInt16 ListBox::GetEntryPos( const void* pData ) const
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir 	sal_uInt16 nPos = mpImplLB->GetEntryList()->FindEntry( pData );
1147cdf0e10cSrcweir 	if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1148cdf0e10cSrcweir 		nPos = sal::static_int_cast<sal_uInt16>(nPos - mpImplLB->GetEntryList()->GetMRUCount());
1149cdf0e10cSrcweir 	return nPos;
1150cdf0e10cSrcweir }
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir // -----------------------------------------------------------------------
1153cdf0e10cSrcweir 
GetEntry(sal_uInt16 nPos) const1154cdf0e10cSrcweir XubString ListBox::GetEntry( sal_uInt16 nPos ) const
1155cdf0e10cSrcweir {
1156cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->GetEntryText( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir // -----------------------------------------------------------------------
1160cdf0e10cSrcweir 
GetEntryCount() const1161cdf0e10cSrcweir sal_uInt16 ListBox::GetEntryCount() const
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->GetEntryCount() - mpImplLB->GetEntryList()->GetMRUCount();
1164cdf0e10cSrcweir }
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir // -----------------------------------------------------------------------
1167cdf0e10cSrcweir 
GetSelectEntry(sal_uInt16 nIndex) const1168cdf0e10cSrcweir XubString ListBox::GetSelectEntry( sal_uInt16 nIndex ) const
1169cdf0e10cSrcweir {
1170cdf0e10cSrcweir 	return GetEntry( GetSelectEntryPos( nIndex ) );
1171cdf0e10cSrcweir }
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir // -----------------------------------------------------------------------
1174cdf0e10cSrcweir 
GetSelectEntryCount() const1175cdf0e10cSrcweir sal_uInt16 ListBox::GetSelectEntryCount() const
1176cdf0e10cSrcweir {
1177cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->GetSelectEntryCount();
1178cdf0e10cSrcweir }
1179cdf0e10cSrcweir 
1180cdf0e10cSrcweir // -----------------------------------------------------------------------
1181cdf0e10cSrcweir 
GetSelectEntryPos(sal_uInt16 nIndex) const1182cdf0e10cSrcweir sal_uInt16 ListBox::GetSelectEntryPos( sal_uInt16 nIndex ) const
1183cdf0e10cSrcweir {
1184cdf0e10cSrcweir 	sal_uInt16 nPos = mpImplLB->GetEntryList()->GetSelectEntryPos( nIndex );
1185cdf0e10cSrcweir 	if ( nPos != LISTBOX_ENTRY_NOTFOUND )
1186cdf0e10cSrcweir 	{
1187cdf0e10cSrcweir 		if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() )
1188cdf0e10cSrcweir 			nPos = mpImplLB->GetEntryList()->FindEntry( mpImplLB->GetEntryList()->GetEntryText( nPos ) );
1189cdf0e10cSrcweir 		nPos = sal::static_int_cast<sal_uInt16>(nPos - mpImplLB->GetEntryList()->GetMRUCount());
1190cdf0e10cSrcweir 	}
1191cdf0e10cSrcweir 	return nPos;
1192cdf0e10cSrcweir }
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir // -----------------------------------------------------------------------
1195cdf0e10cSrcweir 
IsEntrySelected(const XubString & rStr) const1196cdf0e10cSrcweir sal_Bool ListBox::IsEntrySelected( const XubString& rStr ) const
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir 	return IsEntryPosSelected( GetEntryPos( rStr ) );
1199cdf0e10cSrcweir }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir // -----------------------------------------------------------------------
1202cdf0e10cSrcweir 
IsEntryPosSelected(sal_uInt16 nPos) const1203cdf0e10cSrcweir sal_Bool ListBox::IsEntryPosSelected( sal_uInt16 nPos ) const
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->IsEntryPosSelected( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1206cdf0e10cSrcweir }
1207cdf0e10cSrcweir 
1208cdf0e10cSrcweir // -----------------------------------------------------------------------
1209cdf0e10cSrcweir 
SelectEntry(const XubString & rStr,sal_Bool bSelect)1210cdf0e10cSrcweir void ListBox::SelectEntry( const XubString& rStr, sal_Bool bSelect )
1211cdf0e10cSrcweir {
1212cdf0e10cSrcweir 	SelectEntryPos( GetEntryPos( rStr ), bSelect );
1213cdf0e10cSrcweir }
1214cdf0e10cSrcweir 
1215cdf0e10cSrcweir // -----------------------------------------------------------------------
1216cdf0e10cSrcweir 
SelectEntryPos(sal_uInt16 nPos,sal_Bool bSelect)1217cdf0e10cSrcweir void ListBox::SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect )
1218cdf0e10cSrcweir {
1219cdf0e10cSrcweir 	if ( nPos < mpImplLB->GetEntryList()->GetEntryCount() )
1220ad3a95a3SSteve Yin 	{
1221ad3a95a3SSteve Yin 		sal_uInt16 oldSelectCount = GetSelectEntryCount(), newSelectCount = 0, nCurrentPos = mpImplLB->GetCurrentPos();
1222cdf0e10cSrcweir 		mpImplLB->SelectEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), bSelect );
1223ad3a95a3SSteve Yin 		newSelectCount = GetSelectEntryCount();
1224ad3a95a3SSteve Yin 		if (oldSelectCount == 0 && newSelectCount > 0)
1225ad3a95a3SSteve Yin 			NotifyVCLEvent( VCLEVENT_LISTBOX_STATEUPDATE);
1226ad3a95a3SSteve Yin 		//Only when bSelect == true, send both Selection & Focus events
1227ad3a95a3SSteve Yin 		if (nCurrentPos != nPos && bSelect)
1228ad3a95a3SSteve Yin 		{
1229ad3a95a3SSteve Yin 			ImplCallEventListeners( VCLEVENT_LISTBOX_SELECT, reinterpret_cast<void*>(nPos));
1230ad3a95a3SSteve Yin 			if (HasFocus())
1231ad3a95a3SSteve Yin 				ImplCallEventListeners( VCLEVENT_LISTBOX_FOCUS, reinterpret_cast<void*>(nPos));
1232ad3a95a3SSteve Yin 		}
1233ad3a95a3SSteve Yin 	}
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir // -----------------------------------------------------------------------
1237cdf0e10cSrcweir 
SetEntryData(sal_uInt16 nPos,void * pNewData)1238cdf0e10cSrcweir void ListBox::SetEntryData( sal_uInt16 nPos, void* pNewData )
1239cdf0e10cSrcweir {
1240cdf0e10cSrcweir 	mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData );
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir // -----------------------------------------------------------------------
1244cdf0e10cSrcweir 
GetEntryData(sal_uInt16 nPos) const1245cdf0e10cSrcweir void* ListBox::GetEntryData( sal_uInt16 nPos ) const
1246cdf0e10cSrcweir {
1247cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->GetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1248cdf0e10cSrcweir }
1249cdf0e10cSrcweir 
1250cdf0e10cSrcweir // -----------------------------------------------------------------------
1251cdf0e10cSrcweir 
SetEntryFlags(sal_uInt16 nPos,long nFlags)1252cdf0e10cSrcweir void ListBox::SetEntryFlags( sal_uInt16 nPos, long nFlags )
1253cdf0e10cSrcweir {
1254cdf0e10cSrcweir 	mpImplLB->SetEntryFlags( nPos + mpImplLB->GetEntryList()->GetMRUCount(), nFlags );
1255cdf0e10cSrcweir }
1256cdf0e10cSrcweir 
1257cdf0e10cSrcweir // -----------------------------------------------------------------------
1258cdf0e10cSrcweir 
GetEntryFlags(sal_uInt16 nPos) const1259cdf0e10cSrcweir long ListBox::GetEntryFlags( sal_uInt16 nPos ) const
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir 	return mpImplLB->GetEntryList()->GetEntryFlags( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1262cdf0e10cSrcweir }
1263cdf0e10cSrcweir 
1264cdf0e10cSrcweir // -----------------------------------------------------------------------
1265cdf0e10cSrcweir 
SetTopEntry(sal_uInt16 nPos)1266cdf0e10cSrcweir void ListBox::SetTopEntry( sal_uInt16 nPos )
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir 	mpImplLB->SetTopEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1269cdf0e10cSrcweir }
1270cdf0e10cSrcweir 
1271cdf0e10cSrcweir // -----------------------------------------------------------------------
1272cdf0e10cSrcweir 
ShowProminentEntry(sal_uInt16 nPos)1273cdf0e10cSrcweir void ListBox::ShowProminentEntry( sal_uInt16 nPos )
1274cdf0e10cSrcweir {
1275cdf0e10cSrcweir 	mpImplLB->ShowProminentEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
1276cdf0e10cSrcweir }
1277cdf0e10cSrcweir 
1278cdf0e10cSrcweir // -----------------------------------------------------------------------
1279cdf0e10cSrcweir 
GetTopEntry() const1280cdf0e10cSrcweir sal_uInt16 ListBox::GetTopEntry() const
1281cdf0e10cSrcweir {
1282cdf0e10cSrcweir 	sal_uInt16 nPos = GetEntryCount() ? mpImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND;
1283cdf0e10cSrcweir 	if ( nPos < mpImplLB->GetEntryList()->GetMRUCount() )
1284cdf0e10cSrcweir 		nPos = 0;
1285cdf0e10cSrcweir 	return nPos;
1286cdf0e10cSrcweir }
1287cdf0e10cSrcweir 
1288cdf0e10cSrcweir // -----------------------------------------------------------------------
1289cdf0e10cSrcweir 
SetProminentEntryType(ProminentEntry eType)1290cdf0e10cSrcweir void ListBox::SetProminentEntryType( ProminentEntry eType )
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir     mpImplLB->SetProminentEntryType( eType );
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir // -----------------------------------------------------------------------
1296cdf0e10cSrcweir 
GetProminentEntryType() const1297cdf0e10cSrcweir ProminentEntry ListBox::GetProminentEntryType() const
1298cdf0e10cSrcweir {
1299cdf0e10cSrcweir     return mpImplLB->GetProminentEntryType();
1300cdf0e10cSrcweir }
1301cdf0e10cSrcweir 
1302cdf0e10cSrcweir // -----------------------------------------------------------------------
1303cdf0e10cSrcweir 
IsTravelSelect() const1304cdf0e10cSrcweir sal_Bool ListBox::IsTravelSelect() const
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir 	return mpImplLB->IsTravelSelect();
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir // -----------------------------------------------------------------------
1310cdf0e10cSrcweir 
IsInDropDown() const1311cdf0e10cSrcweir sal_Bool ListBox::IsInDropDown() const
1312cdf0e10cSrcweir {
1313cdf0e10cSrcweir 	return mpFloatWin && mpFloatWin->IsInPopupMode();
1314cdf0e10cSrcweir }
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir // -----------------------------------------------------------------------
1317cdf0e10cSrcweir 
CalcWindowSizePixel(sal_uInt16 nLines) const1318cdf0e10cSrcweir long ListBox::CalcWindowSizePixel( sal_uInt16 nLines ) const
1319cdf0e10cSrcweir {
1320cdf0e10cSrcweir 	return mpImplLB->GetEntryHeight() * nLines;
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir 
GetBoundingRectangle(sal_uInt16 nItem) const1323cdf0e10cSrcweir Rectangle ListBox::GetBoundingRectangle( sal_uInt16 nItem ) const
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir     Rectangle aRect = mpImplLB->GetMainWindow()->GetBoundingRectangle( nItem );
1326cdf0e10cSrcweir     Rectangle aOffset = mpImplLB->GetMainWindow()->GetWindowExtentsRelative( (Window*)this );
1327cdf0e10cSrcweir     aRect.Move( aOffset.TopLeft().X(), aOffset.TopLeft().Y() );
1328cdf0e10cSrcweir     return aRect;
1329cdf0e10cSrcweir }
1330cdf0e10cSrcweir 
1331cdf0e10cSrcweir // -----------------------------------------------------------------------
1332cdf0e10cSrcweir 
EnableMultiSelection(sal_Bool bMulti)1333cdf0e10cSrcweir void ListBox::EnableMultiSelection( sal_Bool bMulti )
1334cdf0e10cSrcweir {
1335cdf0e10cSrcweir 	EnableMultiSelection( bMulti, sal_False );
1336cdf0e10cSrcweir }
1337cdf0e10cSrcweir 
EnableMultiSelection(sal_Bool bMulti,sal_Bool bStackSelection)1338cdf0e10cSrcweir void ListBox::EnableMultiSelection( sal_Bool bMulti, sal_Bool bStackSelection )
1339cdf0e10cSrcweir {
1340cdf0e10cSrcweir 	mpImplLB->EnableMultiSelection( bMulti, bStackSelection );
1341cdf0e10cSrcweir 
1342cdf0e10cSrcweir 	// WB_SIMPLEMODE:
1343cdf0e10cSrcweir 	// Die MultiListBox verh�lt sich wie eine normale ListBox.
1344cdf0e10cSrcweir 	// Die Mehrfachselektion kann nur �ber entsprechende Zusatztasten erfolgen.
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 	sal_Bool bSimpleMode = ( GetStyle() & WB_SIMPLEMODE ) ? sal_True : sal_False;
1347cdf0e10cSrcweir 	mpImplLB->SetMultiSelectionSimpleMode( bSimpleMode );
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir 	// ohne Focus ist das Traveln in einer MultiSelection nicht zu sehen:
1350cdf0e10cSrcweir 	if ( mpFloatWin )
1351cdf0e10cSrcweir 		mpImplLB->GetMainWindow()->AllowGrabFocus( bMulti );
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir 
1354cdf0e10cSrcweir // -----------------------------------------------------------------------
1355cdf0e10cSrcweir 
IsMultiSelectionEnabled() const1356cdf0e10cSrcweir sal_Bool ListBox::IsMultiSelectionEnabled() const
1357cdf0e10cSrcweir {
1358cdf0e10cSrcweir 	return mpImplLB->IsMultiSelectionEnabled();
1359cdf0e10cSrcweir }
1360cdf0e10cSrcweir 
1361cdf0e10cSrcweir // -----------------------------------------------------------------------
1362cdf0e10cSrcweir 
CalcMinimumSize() const1363cdf0e10cSrcweir Size ListBox::CalcMinimumSize() const
1364cdf0e10cSrcweir {
1365cdf0e10cSrcweir 	Size aSz;
1366cdf0e10cSrcweir 	if ( !IsDropDownBox() )
1367cdf0e10cSrcweir         aSz = mpImplLB->CalcSize (mnLineCount ? mnLineCount : mpImplLB->GetEntryList()->GetEntryCount());
1368cdf0e10cSrcweir 	else
1369cdf0e10cSrcweir 	{
1370cdf0e10cSrcweir 		aSz.Height() = mpImplLB->CalcSize( 1 ).Height();
1371cdf0e10cSrcweir 		aSz.Height() += 4; // add a space between entry and border
1372cdf0e10cSrcweir         // size to maxmimum entry width and add a little breathing space
1373cdf0e10cSrcweir 		aSz.Width() = mpImplLB->GetMaxEntryWidth() + 4;
1374cdf0e10cSrcweir         // do not create ultrathin ListBoxes, it doesn't look good
1375cdf0e10cSrcweir         if( aSz.Width() < GetSettings().GetStyleSettings().GetScrollBarSize() )
1376cdf0e10cSrcweir             aSz.Width() = GetSettings().GetStyleSettings().GetScrollBarSize();
1377cdf0e10cSrcweir 
1378cdf0e10cSrcweir         // try native borders; scrollbar size may not be a good indicator
1379cdf0e10cSrcweir         // see how large the edit area inside is to estimate what is needed for the dropdown
1380cdf0e10cSrcweir 		ImplControlValue aControlValue;
1381cdf0e10cSrcweir 		Point aPoint;
1382cdf0e10cSrcweir 		Rectangle aContent, aBound;
1383cdf0e10cSrcweir         Size aTestSize( 100, 20 );
1384cdf0e10cSrcweir 		Rectangle aArea( aPoint, aTestSize );
1385cdf0e10cSrcweir         if( const_cast<ListBox*>(this)->GetNativeControlRegion(
1386cdf0e10cSrcweir                        CTRL_LISTBOX, PART_SUB_EDIT, aArea, 0, aControlValue, rtl::OUString(), aBound, aContent) )
1387cdf0e10cSrcweir         {
1388cdf0e10cSrcweir             // use the themes drop down size
1389cdf0e10cSrcweir             aSz.Width() += aTestSize.Width() - aContent.GetWidth();
1390cdf0e10cSrcweir         }
1391cdf0e10cSrcweir         else
1392cdf0e10cSrcweir             aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize();
1393cdf0e10cSrcweir 	}
1394cdf0e10cSrcweir 
1395cdf0e10cSrcweir 	aSz = CalcWindowSize( aSz );
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir 	if ( IsDropDownBox() ) // check minimum height of dropdown box
1398cdf0e10cSrcweir     {
1399cdf0e10cSrcweir         ImplControlValue aControlValue;
1400cdf0e10cSrcweir         Rectangle aRect( Point( 0, 0 ), aSz );
1401cdf0e10cSrcweir         Rectangle aContent, aBound;
1402cdf0e10cSrcweir         if( const_cast<ListBox*>(this)->GetNativeControlRegion(
1403cdf0e10cSrcweir                        CTRL_LISTBOX, PART_ENTIRE_CONTROL, aRect, 0, aControlValue, rtl::OUString(), aBound, aContent) )
1404cdf0e10cSrcweir         {
1405cdf0e10cSrcweir             if( aBound.GetHeight() > aSz.Height() )
1406cdf0e10cSrcweir                 aSz.Height() = aBound.GetHeight();
1407cdf0e10cSrcweir         }
1408cdf0e10cSrcweir     }
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir 	return aSz;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir 
1413cdf0e10cSrcweir // -----------------------------------------------------------------------
1414cdf0e10cSrcweir 
GetOptimalSize(WindowSizeType eType) const1415cdf0e10cSrcweir Size ListBox::GetOptimalSize(WindowSizeType eType) const
1416cdf0e10cSrcweir {
1417cdf0e10cSrcweir     switch (eType) {
1418cdf0e10cSrcweir     case WINDOWSIZE_MINIMUM:
1419cdf0e10cSrcweir         return CalcMinimumSize();
1420cdf0e10cSrcweir     default:
1421cdf0e10cSrcweir         return Control::GetOptimalSize( eType );
1422cdf0e10cSrcweir     }
1423cdf0e10cSrcweir }
1424cdf0e10cSrcweir 
1425cdf0e10cSrcweir // -----------------------------------------------------------------------
1426cdf0e10cSrcweir 
CalcAdjustedSize(const Size & rPrefSize) const1427cdf0e10cSrcweir Size ListBox::CalcAdjustedSize( const Size& rPrefSize ) const
1428cdf0e10cSrcweir {
1429cdf0e10cSrcweir 	Size aSz = rPrefSize;
1430cdf0e10cSrcweir 	sal_Int32 nLeft, nTop, nRight, nBottom;
1431cdf0e10cSrcweir 	((Window*)this)->GetBorder( nLeft, nTop, nRight, nBottom );
1432cdf0e10cSrcweir 	aSz.Height() -= nTop+nBottom;
1433cdf0e10cSrcweir 	if ( !IsDropDownBox() )
1434cdf0e10cSrcweir 	{
1435cdf0e10cSrcweir 		long nEntryHeight = CalcSize( 1, 1 ).Height();
1436cdf0e10cSrcweir 		long nLines = aSz.Height() / nEntryHeight;
1437cdf0e10cSrcweir 		if ( nLines < 1 )
1438cdf0e10cSrcweir 			nLines = 1;
1439cdf0e10cSrcweir 		aSz.Height() = nLines * nEntryHeight;
1440cdf0e10cSrcweir 	}
1441cdf0e10cSrcweir 	else
1442cdf0e10cSrcweir 	{
1443cdf0e10cSrcweir 		aSz.Height() = mnDDHeight;
1444cdf0e10cSrcweir 	}
1445cdf0e10cSrcweir 	aSz.Height() += nTop+nBottom;
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 	aSz = CalcWindowSize( aSz );
1448cdf0e10cSrcweir 	return aSz;
1449cdf0e10cSrcweir }
1450cdf0e10cSrcweir 
1451cdf0e10cSrcweir // -----------------------------------------------------------------------
1452cdf0e10cSrcweir 
CalcSize(sal_uInt16 nColumns,sal_uInt16 nLines) const1453cdf0e10cSrcweir Size ListBox::CalcSize( sal_uInt16 nColumns, sal_uInt16 nLines ) const
1454cdf0e10cSrcweir {
1455cdf0e10cSrcweir 	// ggf. werden ScrollBars eingeblendet
1456cdf0e10cSrcweir 	Size aMinSz = CalcMinimumSize();
1457cdf0e10cSrcweir //	aMinSz = ImplCalcOutSz( aMinSz );
1458cdf0e10cSrcweir 
1459cdf0e10cSrcweir 	Size aSz;
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir 	// Hoehe
1462cdf0e10cSrcweir 	if ( nLines )
1463cdf0e10cSrcweir 	{
1464cdf0e10cSrcweir 		if ( !IsDropDownBox() )
1465cdf0e10cSrcweir 			aSz.Height() = mpImplLB->CalcSize( nLines ).Height();
1466cdf0e10cSrcweir 		else
1467cdf0e10cSrcweir 			aSz.Height() = mnDDHeight;
1468cdf0e10cSrcweir 	}
1469cdf0e10cSrcweir 	else
1470cdf0e10cSrcweir 		aSz.Height() = aMinSz.Height();
1471cdf0e10cSrcweir 
1472cdf0e10cSrcweir 	// Breite
1473cdf0e10cSrcweir 	if ( nColumns )
1474cdf0e10cSrcweir 		aSz.Width() = nColumns * GetTextWidth( XubString( 'X' ) );
1475cdf0e10cSrcweir 	else
1476cdf0e10cSrcweir 		aSz.Width() = aMinSz.Width();
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir 	if ( IsDropDownBox() )
1479cdf0e10cSrcweir 		aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize();
1480cdf0e10cSrcweir 
1481cdf0e10cSrcweir 	if ( !IsDropDownBox() )
1482cdf0e10cSrcweir 	{
1483cdf0e10cSrcweir 		if ( aSz.Width() < aMinSz.Width() )
1484cdf0e10cSrcweir 			aSz.Height() += GetSettings().GetStyleSettings().GetScrollBarSize();
1485cdf0e10cSrcweir 		if ( aSz.Height() < aMinSz.Height() )
1486cdf0e10cSrcweir 			aSz.Width() += GetSettings().GetStyleSettings().GetScrollBarSize();
1487cdf0e10cSrcweir 	}
1488cdf0e10cSrcweir 
1489cdf0e10cSrcweir 	aSz = CalcWindowSize( aSz );
1490cdf0e10cSrcweir 	return aSz;
1491cdf0e10cSrcweir }
1492cdf0e10cSrcweir 
1493cdf0e10cSrcweir // -----------------------------------------------------------------------
1494cdf0e10cSrcweir 
GetMaxVisColumnsAndLines(sal_uInt16 & rnCols,sal_uInt16 & rnLines) const1495cdf0e10cSrcweir void ListBox::GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const
1496cdf0e10cSrcweir {
1497cdf0e10cSrcweir 	long nCharWidth = GetTextWidth( UniString( 'x' ) );
1498cdf0e10cSrcweir 	if ( !IsDropDownBox() )
1499cdf0e10cSrcweir 	{
1500cdf0e10cSrcweir 		Size aOutSz = mpImplLB->GetMainWindow()->GetOutputSizePixel();
1501cdf0e10cSrcweir 		rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth);
1502cdf0e10cSrcweir 		rnLines = (sal_uInt16) (aOutSz.Height()/mpImplLB->GetEntryHeight());
1503cdf0e10cSrcweir 	}
1504cdf0e10cSrcweir 	else
1505cdf0e10cSrcweir 	{
1506cdf0e10cSrcweir 		Size aOutSz = mpImplWin->GetOutputSizePixel();
1507cdf0e10cSrcweir 		rnCols = (sal_uInt16) (aOutSz.Width()/nCharWidth);
1508cdf0e10cSrcweir 		rnLines = 1;
1509cdf0e10cSrcweir 	}
1510cdf0e10cSrcweir }
1511cdf0e10cSrcweir 
1512cdf0e10cSrcweir // -----------------------------------------------------------------------
1513cdf0e10cSrcweir 
IMPL_LINK(ListBox,ImplUserDrawHdl,UserDrawEvent *,pEvent)1514cdf0e10cSrcweir IMPL_LINK( ListBox, ImplUserDrawHdl, UserDrawEvent*, pEvent )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir 	UserDraw( *pEvent );
1517cdf0e10cSrcweir 	return 1;
1518cdf0e10cSrcweir }
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir // -----------------------------------------------------------------------
1521cdf0e10cSrcweir 
UserDraw(const UserDrawEvent &)1522cdf0e10cSrcweir void ListBox::UserDraw( const UserDrawEvent& )
1523cdf0e10cSrcweir {
1524cdf0e10cSrcweir }
1525cdf0e10cSrcweir 
1526cdf0e10cSrcweir // -----------------------------------------------------------------------
1527cdf0e10cSrcweir 
DrawEntry(const UserDrawEvent & rEvt,sal_Bool bDrawImage,sal_Bool bDrawText,sal_Bool bDrawTextAtImagePos)1528cdf0e10cSrcweir void ListBox::DrawEntry( const UserDrawEvent& rEvt, sal_Bool bDrawImage, sal_Bool bDrawText, sal_Bool bDrawTextAtImagePos )
1529cdf0e10cSrcweir {
1530cdf0e10cSrcweir 	if ( rEvt.GetDevice() == mpImplLB->GetMainWindow() )
1531cdf0e10cSrcweir 		mpImplLB->GetMainWindow()->DrawEntry( rEvt.GetItemId(), bDrawImage, bDrawText, bDrawTextAtImagePos );
1532cdf0e10cSrcweir 	else if ( rEvt.GetDevice() == mpImplWin )
1533cdf0e10cSrcweir 		mpImplWin->DrawEntry( bDrawImage, bDrawText, bDrawTextAtImagePos );
1534cdf0e10cSrcweir }
1535cdf0e10cSrcweir 
1536cdf0e10cSrcweir // -----------------------------------------------------------------------
1537cdf0e10cSrcweir 
SetUserItemSize(const Size & rSz)1538cdf0e10cSrcweir void ListBox::SetUserItemSize( const Size& rSz )
1539cdf0e10cSrcweir {
1540cdf0e10cSrcweir 	mpImplLB->GetMainWindow()->SetUserItemSize( rSz );
1541cdf0e10cSrcweir 	if ( mpImplWin )
1542cdf0e10cSrcweir 		mpImplWin->SetUserItemSize( rSz );
1543cdf0e10cSrcweir }
1544cdf0e10cSrcweir 
1545cdf0e10cSrcweir // -----------------------------------------------------------------------
1546cdf0e10cSrcweir 
GetUserItemSize() const1547cdf0e10cSrcweir const Size& ListBox::GetUserItemSize() const
1548cdf0e10cSrcweir {
1549cdf0e10cSrcweir 	return mpImplLB->GetMainWindow()->GetUserItemSize();
1550cdf0e10cSrcweir }
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir // -----------------------------------------------------------------------
1553cdf0e10cSrcweir 
EnableUserDraw(sal_Bool bUserDraw)1554cdf0e10cSrcweir void ListBox::EnableUserDraw( sal_Bool bUserDraw )
1555cdf0e10cSrcweir {
1556cdf0e10cSrcweir 	mpImplLB->GetMainWindow()->EnableUserDraw( bUserDraw );
1557cdf0e10cSrcweir 	if ( mpImplWin )
1558cdf0e10cSrcweir 		mpImplWin->EnableUserDraw( bUserDraw );
1559cdf0e10cSrcweir }
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir // -----------------------------------------------------------------------
1562cdf0e10cSrcweir 
IsUserDrawEnabled() const1563cdf0e10cSrcweir sal_Bool ListBox::IsUserDrawEnabled() const
1564cdf0e10cSrcweir {
1565cdf0e10cSrcweir 	return mpImplLB->GetMainWindow()->IsUserDrawEnabled();
1566cdf0e10cSrcweir }
1567cdf0e10cSrcweir 
1568cdf0e10cSrcweir // -----------------------------------------------------------------------
1569cdf0e10cSrcweir 
SetReadOnly(sal_Bool bReadOnly)1570cdf0e10cSrcweir void ListBox::SetReadOnly( sal_Bool bReadOnly )
1571cdf0e10cSrcweir {
1572cdf0e10cSrcweir 	if ( mpImplLB->IsReadOnly() != bReadOnly )
1573cdf0e10cSrcweir 	{
1574cdf0e10cSrcweir 		mpImplLB->SetReadOnly( bReadOnly );
1575cdf0e10cSrcweir 		StateChanged( STATE_CHANGE_READONLY );
1576cdf0e10cSrcweir 	}
1577cdf0e10cSrcweir }
1578cdf0e10cSrcweir 
1579cdf0e10cSrcweir // -----------------------------------------------------------------------
1580cdf0e10cSrcweir 
IsReadOnly() const1581cdf0e10cSrcweir sal_Bool ListBox::IsReadOnly() const
1582cdf0e10cSrcweir {
1583cdf0e10cSrcweir 	return mpImplLB->IsReadOnly();
1584cdf0e10cSrcweir }
1585cdf0e10cSrcweir 
1586cdf0e10cSrcweir // -----------------------------------------------------------------------
1587cdf0e10cSrcweir 
SetSeparatorPos(sal_uInt16 n)1588cdf0e10cSrcweir void ListBox::SetSeparatorPos( sal_uInt16 n )
1589cdf0e10cSrcweir {
1590cdf0e10cSrcweir 	mpImplLB->SetSeparatorPos( n );
1591cdf0e10cSrcweir }
1592cdf0e10cSrcweir 
1593cdf0e10cSrcweir // -----------------------------------------------------------------------
1594cdf0e10cSrcweir 
SetSeparatorPos()1595cdf0e10cSrcweir void ListBox::SetSeparatorPos()
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir 	mpImplLB->SetSeparatorPos( LISTBOX_ENTRY_NOTFOUND );
1598cdf0e10cSrcweir }
1599cdf0e10cSrcweir 
1600cdf0e10cSrcweir // -----------------------------------------------------------------------
1601cdf0e10cSrcweir 
GetSeparatorPos() const1602cdf0e10cSrcweir sal_uInt16 ListBox::GetSeparatorPos() const
1603cdf0e10cSrcweir {
1604cdf0e10cSrcweir 	return mpImplLB->GetSeparatorPos();
1605cdf0e10cSrcweir }
1606cdf0e10cSrcweir 
1607cdf0e10cSrcweir // -----------------------------------------------------------------------
1608cdf0e10cSrcweir 
SetMRUEntries(const XubString & rEntries,xub_Unicode cSep)1609cdf0e10cSrcweir void ListBox::SetMRUEntries( const XubString& rEntries, xub_Unicode cSep )
1610cdf0e10cSrcweir {
1611cdf0e10cSrcweir 	mpImplLB->SetMRUEntries( rEntries, cSep );
1612cdf0e10cSrcweir }
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir // -----------------------------------------------------------------------
1615cdf0e10cSrcweir 
GetMRUEntries(xub_Unicode cSep) const1616cdf0e10cSrcweir XubString ListBox::GetMRUEntries( xub_Unicode cSep ) const
1617cdf0e10cSrcweir {
1618cdf0e10cSrcweir 	return mpImplLB->GetMRUEntries( cSep );
1619cdf0e10cSrcweir }
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir // -----------------------------------------------------------------------
1622cdf0e10cSrcweir 
SetMaxMRUCount(sal_uInt16 n)1623cdf0e10cSrcweir void ListBox::SetMaxMRUCount( sal_uInt16 n )
1624cdf0e10cSrcweir {
1625cdf0e10cSrcweir 	mpImplLB->SetMaxMRUCount( n );
1626cdf0e10cSrcweir }
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir // -----------------------------------------------------------------------
1629cdf0e10cSrcweir 
GetMaxMRUCount() const1630cdf0e10cSrcweir sal_uInt16 ListBox::GetMaxMRUCount() const
1631cdf0e10cSrcweir {
1632cdf0e10cSrcweir 	return mpImplLB->GetMaxMRUCount();
1633cdf0e10cSrcweir }
GetMRUCount() const1634ad3a95a3SSteve Yin sal_uInt16 ListBox::GetMRUCount() const
1635ad3a95a3SSteve Yin {
1636ad3a95a3SSteve Yin 	return mpImplLB->GetEntryList()->GetMRUCount();
1637ad3a95a3SSteve Yin }
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir // -----------------------------------------------------------------------
1640cdf0e10cSrcweir 
GetDisplayLineCount() const1641cdf0e10cSrcweir sal_uInt16 ListBox::GetDisplayLineCount() const
1642cdf0e10cSrcweir {
1643cdf0e10cSrcweir     return mpImplLB->GetDisplayLineCount();
1644cdf0e10cSrcweir }
1645cdf0e10cSrcweir 
1646cdf0e10cSrcweir // -----------------------------------------------------------------------
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir // pb: #106948# explicit mirroring for calc
1649cdf0e10cSrcweir 
EnableMirroring()1650cdf0e10cSrcweir void ListBox::EnableMirroring()
1651cdf0e10cSrcweir {
1652cdf0e10cSrcweir     mpImplLB->EnableMirroring();
1653cdf0e10cSrcweir }
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir // -----------------------------------------------------------------------
1656cdf0e10cSrcweir 
GetDropDownPosSizePixel() const1657cdf0e10cSrcweir Rectangle ListBox::GetDropDownPosSizePixel() const
1658cdf0e10cSrcweir {
1659cdf0e10cSrcweir     return mpFloatWin ? mpFloatWin->GetWindowExtentsRelative( const_cast<ListBox*>(this) ) : Rectangle();
1660cdf0e10cSrcweir }
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir // -----------------------------------------------------------------------
1663cdf0e10cSrcweir 
GetDisplayBackground() const1664cdf0e10cSrcweir const Wallpaper& ListBox::GetDisplayBackground() const
1665cdf0e10cSrcweir {
1666cdf0e10cSrcweir     // !!! recursion does not occur because the ImplListBox is default
1667cdf0e10cSrcweir     // initialized to a nontransparent color in Window::ImplInitData
1668cdf0e10cSrcweir     return mpImplLB->GetDisplayBackground();
1669cdf0e10cSrcweir }
1670cdf0e10cSrcweir 
1671a68b38dfSArmin Le Grand // -----------------------------------------------------------------------
1672a68b38dfSArmin Le Grand 
SetEdgeBlending(bool bNew)1673a68b38dfSArmin Le Grand void ListBox::SetEdgeBlending(bool bNew)
1674a68b38dfSArmin Le Grand {
1675a68b38dfSArmin Le Grand     if(mbEdgeBlending != bNew)
1676a68b38dfSArmin Le Grand     {
1677a68b38dfSArmin Le Grand         mbEdgeBlending = bNew;
1678a68b38dfSArmin Le Grand 
1679a68b38dfSArmin Le Grand         if(IsDropDownBox())
1680a68b38dfSArmin Le Grand         {
1681a68b38dfSArmin Le Grand             mpImplWin->Invalidate();
1682a68b38dfSArmin Le Grand         }
1683a68b38dfSArmin Le Grand         else
1684a68b38dfSArmin Le Grand         {
1685a68b38dfSArmin Le Grand             mpImplLB->Invalidate();
1686a68b38dfSArmin Le Grand         }
1687a68b38dfSArmin Le Grand 
1688a68b38dfSArmin Le Grand         if(mpImplWin)
1689a68b38dfSArmin Le Grand         {
1690a68b38dfSArmin Le Grand             mpImplWin->SetEdgeBlending(GetEdgeBlending());
1691a68b38dfSArmin Le Grand         }
1692a68b38dfSArmin Le Grand 
1693a68b38dfSArmin Le Grand         if(mpImplLB)
1694a68b38dfSArmin Le Grand         {
1695a68b38dfSArmin Le Grand             mpImplLB->SetEdgeBlending(GetEdgeBlending());
1696a68b38dfSArmin Le Grand         }
1697a68b38dfSArmin Le Grand 
1698a68b38dfSArmin Le Grand         Invalidate();
1699a68b38dfSArmin Le Grand     }
1700a68b38dfSArmin Le Grand }
1701a68b38dfSArmin Le Grand 
1702cdf0e10cSrcweir // =======================================================================
MultiListBox(Window * pParent,WinBits nStyle)1703cdf0e10cSrcweir MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) :
1704cdf0e10cSrcweir 	ListBox( WINDOW_MULTILISTBOX )
1705cdf0e10cSrcweir {
1706cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
1707cdf0e10cSrcweir 	EnableMultiSelection( sal_True );
1708cdf0e10cSrcweir }
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir // -----------------------------------------------------------------------
1711cdf0e10cSrcweir 
MultiListBox(Window * pParent,const ResId & rResId)1712cdf0e10cSrcweir MultiListBox::MultiListBox( Window* pParent, const ResId& rResId ) :
1713cdf0e10cSrcweir 	ListBox( WINDOW_MULTILISTBOX )
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir 	rResId.SetRT( RSC_MULTILISTBOX );
1716cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
1717cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
1718cdf0e10cSrcweir 	ImplLoadRes( rResId );
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE ) )
1721cdf0e10cSrcweir 		Show();
1722cdf0e10cSrcweir 	EnableMultiSelection( sal_True );
1723cdf0e10cSrcweir }
1724a68b38dfSArmin Le Grand 
1725