]> git.saurik.com Git - wxWidgets.git/blame - src/generic/odcombo.cpp
simplify mouse wheel signal handler
[wxWidgets.git] / src / generic / odcombo.cpp
CommitLineData
a340b80d
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: odcombo.cpp
3// Purpose: wxOwnerDrawnComboBox, wxVListBoxComboPopup
4// Author: Jaakko Salli
5// Modified by:
6// Created: Apr-30-2006
7// RCS-ID: $Id$
8// Copyright: (c) 2005 Jaakko Salli
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_OWNERDRAWNCOMBOBOX
27
28#ifndef WX_PRECOMP
29 #include "wx/log.h"
30 #include "wx/combobox.h"
31 #include "wx/dcclient.h"
32 #include "wx/settings.h"
33 #include "wx/dialog.h"
34#endif
35
36#include "wx/combo.h"
37#include "wx/odcombo.h"
38
39
40// ============================================================================
41// implementation
42// ============================================================================
43
44
45// ----------------------------------------------------------------------------
46// wxVListBoxComboPopup is a wxVListBox customized to act as a popup control
47//
48// ----------------------------------------------------------------------------
49
50
51BEGIN_EVENT_TABLE(wxVListBoxComboPopup, wxVListBox)
52 EVT_MOTION(wxVListBoxComboPopup::OnMouseMove)
53 EVT_KEY_DOWN(wxVListBoxComboPopup::OnKey)
54 EVT_LEFT_UP(wxVListBoxComboPopup::OnLeftClick)
55END_EVENT_TABLE()
56
57
6d0ce565
VZ
58void wxVListBoxComboPopup::Init()
59/* : wxVListBox(),
60 wxComboPopup(combo)*/
a340b80d
VZ
61{
62 m_widestWidth = 0;
63 m_avgCharWidth = 0;
64 m_baseImageWidth = 0;
65 m_itemHeight = 0;
66 m_value = -1;
67 m_itemHover = -1;
68 m_clientDataItemsType = wxClientData_None;
69}
70
71bool wxVListBoxComboPopup::Create(wxWindow* parent)
72{
73 if ( !wxVListBox::Create(parent,
74 wxID_ANY,
75 wxDefaultPosition,
76 wxDefaultSize,
77 wxBORDER_SIMPLE | wxLB_INT_HEIGHT | wxWANTS_CHARS) )
78 return false;
79
6d0ce565 80 m_useFont = m_combo->GetFont();
a340b80d
VZ
81
82 wxVListBox::SetItemCount(m_strings.GetCount());
83
84 // TODO: Move this to SetFont
85 m_itemHeight = GetCharHeight() + 0;
86
87 return true;
88}
89
90wxVListBoxComboPopup::~wxVListBoxComboPopup()
91{
92 Clear();
93}
94
95bool wxVListBoxComboPopup::LazyCreate()
96{
97 // NB: There is a bug with wxVListBox that can be avoided by creating
98 // it later (bug causes empty space to be shown if initial selection
99 // is at the end of a list longer than the control can show at once).
100 return true;
101}
102
103// paint the control itself
104void wxVListBoxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect )
105{
106 if ( !(m_combo->GetWindowStyle() & wxODCB_STD_CONTROL_PAINT) )
107 {
108 m_combo->DrawFocusBackground(dc,rect,0);
109 if ( m_value >= 0 )
110 {
6d0ce565
VZ
111 OnDrawItem(dc,rect,m_value,wxCP_PAINTING_CONTROL);
112 return;
a340b80d
VZ
113 }
114 }
115
116 wxComboPopup::PaintComboControl(dc,rect);
117}
118
119void wxVListBoxComboPopup::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
120{
6d0ce565
VZ
121 // TODO: Maybe this code could be moved to wxVListBox::OnPaint?
122 dc.SetFont(m_useFont);
a340b80d
VZ
123
124 // Set correct text colour for selected items
6d0ce565 125 if ( wxVListBox::GetSelection() == (int) n )
a340b80d
VZ
126 dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
127 else
128 dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
129
6d0ce565 130 OnDrawItem(dc,rect,(int)n,0);
a340b80d
VZ
131}
132
6d0ce565 133wxCoord wxVListBoxComboPopup::OnMeasureItem(size_t WXUNUSED(n)) const
a340b80d 134{
6d0ce565 135 /*
a340b80d
VZ
136 int itemHeight = m_combo->OnMeasureListItem(n);
137 if ( itemHeight < 0 )
138 itemHeight = m_itemHeight;
6d0ce565
VZ
139 */
140 return m_itemHeight;
141}
a340b80d 142
6d0ce565
VZ
143wxCoord wxVListBoxComboPopup::OnMeasureItemWidth(size_t WXUNUSED(n)) const
144{
145 //return OnMeasureListItemWidth(n);
146 return -1;
a340b80d
VZ
147}
148
149void wxVListBoxComboPopup::OnDrawBackground(wxDC& dc, const wxRect& rect, size_t n) const
150{
151 // we need to render selected and current items differently
152 if ( IsCurrent(n) )
153 {
154 m_combo->DrawFocusBackground( dc, rect, wxCONTROL_ISSUBMENU|wxCONTROL_SELECTED );
155 }
156 //else: do nothing for the normal items
157}
158
6d0ce565
VZ
159// This is called from wxVListBoxComboPopup::OnDrawItem, with text colour and font prepared
160void wxVListBoxComboPopup::OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const
161{
162 if ( flags & wxCP_PAINTING_CONTROL )
163 {
164 dc.DrawText( m_combo->GetValue(),
165 rect.x + m_combo->GetTextIndent(),
166 (rect.height-dc.GetCharHeight())/2 + rect.y );
167 }
168 else
169 {
170 dc.DrawText( GetString(item), rect.x + 2, rect.y );
171 }
172}
173
174void wxVListBoxComboPopup::DismissWithEvent()
175{
176 int selection = wxVListBox::GetSelection();
177
178 Dismiss();
179
180 wxString valStr;
181 if ( selection != wxNOT_FOUND )
182 valStr = m_strings[selection];
183 else
184 valStr = wxEmptyString;
185
186 m_value = selection;
187
188 if ( valStr != m_combo->GetValue() )
189 m_combo->SetValue(valStr);
190
191 SendComboBoxEvent(selection);
192}
193
194void wxVListBoxComboPopup::SendComboBoxEvent( int selection )
a340b80d
VZ
195{
196 wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId());
a340b80d
VZ
197
198 evt.SetEventObject(m_combo);
6d0ce565 199
a340b80d
VZ
200 evt.SetInt(selection);
201
202 // Set client data, if any
203 if ( selection >= 0 && (int)m_clientDatas.GetCount() > selection )
204 {
205 void* clientData = m_clientDatas[selection];
206 if ( m_clientDataItemsType == wxClientData_Object )
207 evt.SetClientObject((wxClientData*)clientData);
208 else
209 evt.SetClientData(clientData);
210 }
211
212 m_combo->GetEventHandler()->AddPendingEvent(evt);
213}
214
215// returns true if key was consumed
216bool wxVListBoxComboPopup::HandleKey( int keycode, bool saturate )
217{
218 int value = m_value;
219 int itemCount = GetCount();
220
221 if ( keycode == WXK_DOWN || keycode == WXK_RIGHT )
222 {
223 value++;
224 }
225 else if ( keycode == WXK_UP || keycode == WXK_LEFT )
226 {
227 value--;
228 }
229 else if ( keycode == WXK_PAGEDOWN )
230 {
231 value+=10;
232 }
233 else if ( keycode == WXK_PAGEUP )
234 {
235 value-=10;
236 }
237 /*
238 else if ( keycode == WXK_END )
239 {
240 value = itemCount-1;
241 }
242 else if ( keycode == WXK_HOME )
243 {
244 value = 0;
245 }
246 */
247 else
248 return false;
249
250 if ( saturate )
251 {
252 if ( value >= itemCount )
253 value = itemCount - 1;
254 else if ( value < 0 )
255 value = 0;
256 }
257 else
258 {
259 if ( value >= itemCount )
260 value -= itemCount;
261 else if ( value < 0 )
262 value += itemCount;
263 }
264
265 if ( value == m_value )
266 // Even if value was same, don't skip the event
267 // (good for consistency)
268 return true;
269
270 m_value = value;
271
a340b80d
VZ
272 if ( value >= 0 )
273 m_combo->SetValue(m_strings[value]);
274
6d0ce565 275 SendComboBoxEvent(m_value);
a340b80d
VZ
276
277 return true;
278}
279
280void wxVListBoxComboPopup::OnComboDoubleClick()
281{
282 // Cycle on dclick (disable saturation to allow true cycling).
283 if ( !::wxGetKeyState(WXK_SHIFT) )
284 HandleKey(WXK_DOWN,false);
285 else
286 HandleKey(WXK_UP,false);
287}
288
289void wxVListBoxComboPopup::OnComboKeyEvent( wxKeyEvent& event )
290{
291 // Saturated key movement on
292 if ( !HandleKey(event.GetKeyCode(),true) )
293 event.Skip();
294}
295
296void wxVListBoxComboPopup::OnPopup()
297{
298 // *must* set value after size is set (this is because of a vlbox bug)
299 wxVListBox::SetSelection(m_value);
300}
301
302void wxVListBoxComboPopup::OnMouseMove(wxMouseEvent& event)
303{
304 // Move selection to cursor if it is inside the popup
305 int itemHere = GetItemAtPosition(event.GetPosition());
306 if ( itemHere >= 0 )
307 wxVListBox::SetSelection(itemHere);
308
309 event.Skip();
310}
311
312void wxVListBoxComboPopup::OnLeftClick(wxMouseEvent& WXUNUSED(event))
313{
6d0ce565 314 DismissWithEvent();
a340b80d
VZ
315}
316
317void wxVListBoxComboPopup::OnKey(wxKeyEvent& event)
318{
319 // Select item if ENTER is pressed
320 if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER )
321 {
6d0ce565 322 DismissWithEvent();
a340b80d
VZ
323 }
324 // Hide popup if ESC is pressed
325 else if ( event.GetKeyCode() == WXK_ESCAPE )
326 Dismiss();
327 else
328 event.Skip();
329}
330
331void wxVListBoxComboPopup::CheckWidth( int pos )
332{
6d0ce565 333 wxCoord x = OnMeasureItemWidth(pos);
a340b80d
VZ
334
335 if ( x < 0 )
336 {
6d0ce565
VZ
337 if ( !m_useFont.Ok() )
338 m_useFont = m_combo->GetFont();
a340b80d
VZ
339
340 wxCoord y;
6d0ce565 341 m_combo->GetTextExtent(m_strings[pos], &x, &y, 0, 0, &m_useFont);
a340b80d
VZ
342 x += 4;
343 }
344
345 if ( m_widestWidth < x )
346 {
347 m_widestWidth = x;
348 }
349}
350
351void wxVListBoxComboPopup::Insert( const wxString& item, int pos )
352{
353 // Need to change selection?
354 wxString strValue;
355 if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) &&
356 m_combo->GetValue() == item )
6d0ce565 357 {
a340b80d 358 m_value = pos;
6d0ce565 359 }
a340b80d
VZ
360
361 m_strings.Insert(item,pos);
362
363 if ( IsCreated() )
364 wxVListBox::SetItemCount( wxVListBox::GetItemCount()+1 );
365
366 // Calculate width
367 CheckWidth(pos);
368}
369
370int wxVListBoxComboPopup::Append(const wxString& item)
371{
372 int pos = (int)m_strings.GetCount();
373
374 if ( m_combo->GetWindowStyle() & wxCB_SORT )
375 {
376 // Find position
377 // TODO: Could be optimized with binary search
378 wxArrayString strings = m_strings;
379 unsigned int i;
380
381 for ( i=0; i<strings.GetCount(); i++ )
382 {
383 if ( item.Cmp(strings.Item(i)) < 0 )
384 {
385 pos = (int)i;
386 break;
387 }
388 }
389 }
390
391 Insert(item,pos);
392
393 return pos;
394}
395
396void wxVListBoxComboPopup::Clear()
397{
398 wxASSERT(m_combo);
399
400 m_strings.Empty();
401
402 ClearClientDatas();
403
404 if ( IsCreated() )
405 wxVListBox::SetItemCount(0);
406}
407
408void wxVListBoxComboPopup::ClearClientDatas()
409{
410 if ( m_clientDataItemsType == wxClientData_Object )
411 {
412 size_t i;
413 for ( i=0; i<m_clientDatas.GetCount(); i++ )
414 delete (wxClientData*) m_clientDatas[i];
415 }
416
417 m_clientDatas.Empty();
418}
419
420void wxVListBoxComboPopup::SetItemClientData( unsigned int n,
421 void* clientData,
422 wxClientDataType clientDataItemsType )
423{
424 // It should be sufficient to update this variable only here
425 m_clientDataItemsType = clientDataItemsType;
426
427 m_clientDatas.SetCount(n+1,NULL);
428 m_clientDatas[n] = clientData;
429}
430
431void* wxVListBoxComboPopup::GetItemClientData(unsigned int n) const
432{
433 if ( m_clientDatas.GetCount() > n )
434 return m_clientDatas[n];
435
436 return NULL;
437}
438
439void wxVListBoxComboPopup::Delete( unsigned int item )
440{
441 // Remove client data, if set
442 if ( m_clientDatas.GetCount() )
443 {
444 if ( m_clientDataItemsType == wxClientData_Object )
445 delete (wxClientData*) m_clientDatas[item];
446
447 m_clientDatas.RemoveAt(item);
448 }
449
450 m_strings.RemoveAt(item);
451
452 if ( IsCreated() )
453 wxVListBox::SetItemCount( wxVListBox::GetItemCount()-1 );
454}
455
456int wxVListBoxComboPopup::FindString(const wxString& s) const
457{
458 return m_strings.Index(s);
459}
460
461unsigned int wxVListBoxComboPopup::GetCount() const
462{
463 return m_strings.GetCount();
464}
465
466wxString wxVListBoxComboPopup::GetString( int item ) const
467{
468 return m_strings[item];
469}
470
471void wxVListBoxComboPopup::SetString( int item, const wxString& str )
472{
473 m_strings[item] = str;
474}
475
476wxString wxVListBoxComboPopup::GetStringValue() const
477{
478 if ( m_value >= 0 )
479 return m_strings[m_value];
480 return wxEmptyString;
481}
482
483void wxVListBoxComboPopup::SetSelection( int item )
484{
485 // This seems to be necessary (2.5.3 w/ MingW atleast)
486 if ( item < -1 || item >= (int)m_strings.GetCount() )
487 item = -1;
488
489 m_value = item;
490
491 if ( IsCreated() )
492 wxVListBox::SetSelection(item);
493}
494
6d0ce565
VZ
495int wxVListBoxComboPopup::GetSelection() const
496{
497 return m_value;
498}
499
a340b80d
VZ
500void wxVListBoxComboPopup::SetStringValue( const wxString& value )
501{
502 int index = m_strings.Index(value);
503
504 m_value = index;
505
506 if ( index >= -1 && index < (int)wxVListBox::GetItemCount() )
507 wxVListBox::SetSelection(index);
508}
509
510wxSize wxVListBoxComboPopup::GetAdjustedSize( int minWidth, int prefHeight, int maxHeight )
511{
512 int height = 250;
513
514 if ( m_strings.GetCount() )
515 {
516 if ( prefHeight > 0 )
517 height = prefHeight;
518
519 if ( height > maxHeight )
520 height = maxHeight;
521
522 int totalHeight = GetTotalHeight(); // + 3;
523 if ( height >= totalHeight )
524 {
525 height = totalHeight;
526 }
527 else
528 {
529 // Adjust height to a multiple of the height of the first item
530 // NB: Calculations that take variable height into account
531 // are unnecessary.
532 int fih = GetLineHeight(0);
533 int shown = height/fih;
534 height = shown * fih;
535 }
536 }
537 else
538 height = 50;
539
540 // Take scrollbar into account in width calculations
541 int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
542 return wxSize(minWidth > widestWidth ? minWidth : widestWidth,
543 height+2);
544}
545
6d0ce565
VZ
546//void wxVListBoxComboPopup::Populate( int n, const wxString choices[] )
547void wxVListBoxComboPopup::Populate( const wxArrayString& choices )
a340b80d
VZ
548{
549 int i;
550
6d0ce565
VZ
551 int n = choices.GetCount();
552
a340b80d
VZ
553 for ( i=0; i<n; i++ )
554 {
6d0ce565 555 const wxString& item = choices.Item(i);
a340b80d
VZ
556 m_strings.Add(item);
557 CheckWidth(i);
558 }
559
560 if ( IsCreated() )
561 wxVListBox::SetItemCount(n);
562
563 // Sort the initial choices
564 if ( m_combo->GetWindowStyle() & wxCB_SORT )
565 m_strings.Sort();
566
567 // Find initial selection
568 wxString strValue = m_combo->GetValue();
569 if ( strValue.Length() )
570 m_value = m_strings.Index(strValue);
571}
572
573// ----------------------------------------------------------------------------
574// wxOwnerDrawnComboBox
575// ----------------------------------------------------------------------------
576
577
578BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboControl)
579END_EVENT_TABLE()
580
581
582IMPLEMENT_DYNAMIC_CLASS2(wxOwnerDrawnComboBox, wxComboControl, wxControlWithItems)
583
584void wxOwnerDrawnComboBox::Init()
585{
6d0ce565 586 m_popupInterface = NULL;
a340b80d
VZ
587}
588
589bool wxOwnerDrawnComboBox::Create(wxWindow *parent,
590 wxWindowID id,
591 const wxString& value,
592 const wxPoint& pos,
593 const wxSize& size,
594 long style,
595 const wxValidator& validator,
596 const wxString& name)
597{
598 return wxComboControl::Create(parent,id,value,pos,size,style,validator,name);
599}
600
601wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent,
602 wxWindowID id,
603 const wxString& value,
604 const wxPoint& pos,
605 const wxSize& size,
606 const wxArrayString& choices,
607 long style,
608 const wxValidator& validator,
609 const wxString& name)
610 : wxComboControl()
611{
612 Init();
613
614 Create(parent,id,value,pos,size,choices,style, validator, name);
615}
616
617bool wxOwnerDrawnComboBox::Create(wxWindow *parent,
618 wxWindowID id,
619 const wxString& value,
620 const wxPoint& pos,
621 const wxSize& size,
622 const wxArrayString& choices,
623 long style,
624 const wxValidator& validator,
625 const wxString& name)
626{
6d0ce565
VZ
627 m_initChs = choices;
628 //wxCArrayString chs(choices);
a340b80d 629
6d0ce565
VZ
630 //return Create(parent, id, value, pos, size, chs.GetCount(),
631 // chs.GetStrings(), style, validator, name);
632 return Create(parent, id, value, pos, size, 0,
633 NULL, style, validator, name);
a340b80d
VZ
634}
635
636bool wxOwnerDrawnComboBox::Create(wxWindow *parent,
637 wxWindowID id,
638 const wxString& value,
639 const wxPoint& pos,
640 const wxSize& size,
641 int n,
642 const wxString choices[],
643 long style,
644 const wxValidator& validator,
645 const wxString& name)
646{
647
648 if ( !Create(parent, id, value, pos, size, style,
649 validator, name) )
650 {
651 return false;
652 }
653
6d0ce565
VZ
654 int i;
655 for ( i=0; i<n; i++ )
656 m_initChs.Add(choices[i]);
a340b80d
VZ
657
658 return true;
659}
660
661wxOwnerDrawnComboBox::~wxOwnerDrawnComboBox()
662{
663 if ( m_popupInterface )
664 m_popupInterface->ClearClientDatas();
665}
666
6d0ce565
VZ
667void wxOwnerDrawnComboBox::SetPopupControl( wxComboPopup* popup )
668{
669 if ( !popup )
670 {
671 popup = new wxVListBoxComboPopup();
672 }
673
674 wxComboControl::SetPopupControl(popup);
675
676 wxASSERT(popup);
677 m_popupInterface = (wxVListBoxComboPopup*) popup;
678
679 // Add initial choices to the wxVListBox
680 if ( !m_popupInterface->GetCount() )
681 {
682 //m_popupInterface->Populate(m_initChs.GetCount(),m_initChs.GetStrings());
683 m_popupInterface->Populate(m_initChs);
684 m_initChs.Clear();
685 }
686}
687
a340b80d
VZ
688// ----------------------------------------------------------------------------
689// wxOwnerDrawnComboBox item manipulation methods
690// ----------------------------------------------------------------------------
691
692void wxOwnerDrawnComboBox::Clear()
693{
6d0ce565 694 EnsurePopupControl();
a340b80d
VZ
695
696 m_popupInterface->Clear();
697
698 GetTextCtrl()->SetValue(wxEmptyString);
699}
700
701void wxOwnerDrawnComboBox::Delete(unsigned int n)
702{
703 wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxOwnerDrawnComboBox::Delete") );
704
705 if ( GetSelection() == (int) n )
706 SetValue(wxEmptyString);
707
708 m_popupInterface->Delete(n);
709}
710
711unsigned int wxOwnerDrawnComboBox::GetCount() const
712{
6d0ce565 713 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
a340b80d
VZ
714 return m_popupInterface->GetCount();
715}
716
717wxString wxOwnerDrawnComboBox::GetString(unsigned int n) const
718{
719 wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxOwnerDrawnComboBox::GetString") );
720 return m_popupInterface->GetString(n);
721}
722
723void wxOwnerDrawnComboBox::SetString(unsigned int n, const wxString& s)
724{
725 wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxOwnerDrawnComboBox::SetString") );
726 m_popupInterface->SetString(n,s);
727}
728
729int wxOwnerDrawnComboBox::FindString(const wxString& s) const
730{
6d0ce565 731 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
a340b80d
VZ
732 return m_popupInterface->FindString(s);
733}
734
735void wxOwnerDrawnComboBox::Select(int n)
736{
737 wxCHECK_RET( (n >= -1) && (n < (int)GetCount()), _T("invalid index in wxOwnerDrawnComboBox::Select") );
6d0ce565 738 EnsurePopupControl();
a340b80d
VZ
739
740 m_popupInterface->SetSelection(n);
741
742 wxString str;
743 if ( n >= 0 )
744 str = m_popupInterface->GetString(n);
745
746 // Refresh text portion in control
747 if ( m_text )
748 m_text->SetValue( str );
749 else
750 m_valueString = str;
751
752 Refresh();
753}
754
755int wxOwnerDrawnComboBox::GetSelection() const
756{
6d0ce565 757 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
a340b80d
VZ
758 return m_popupInterface->GetSelection();
759}
760
761int wxOwnerDrawnComboBox::DoAppend(const wxString& item)
762{
6d0ce565
VZ
763 EnsurePopupControl();
764 wxASSERT(m_popupInterface);
a340b80d
VZ
765 return m_popupInterface->Append(item);
766}
767
768int wxOwnerDrawnComboBox::DoInsert(const wxString& item, unsigned int pos)
769{
770 wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
771 wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
772
6d0ce565 773 EnsurePopupControl();
a340b80d
VZ
774 m_popupInterface->Insert(item,pos);
775
776 return pos;
777}
778
779void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData)
780{
6d0ce565 781 EnsurePopupControl();
a340b80d
VZ
782 m_popupInterface->SetItemClientData(n,clientData,m_clientDataItemsType);
783}
784
785void* wxOwnerDrawnComboBox::DoGetItemClientData(unsigned int n) const
786{
6d0ce565 787 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
a340b80d
VZ
788 return m_popupInterface->GetItemClientData(n);
789}
790
791void wxOwnerDrawnComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
792{
793 DoSetItemClientData(n, (void*) clientData);
794}
795
796wxClientData* wxOwnerDrawnComboBox::DoGetItemClientObject(unsigned int n) const
797{
798 return (wxClientData*) DoGetItemClientData(n);
799}
800
801#endif // wxUSE_OWNERDRAWNCOMBOBOX