fixes and missing files from the first wxComboControl patch (update of patch 1479938)
[wxWidgets.git] / src / generic / odcombo.cpp
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
51 BEGIN_EVENT_TABLE(wxVListBoxComboPopup, wxVListBox)
52 EVT_MOTION(wxVListBoxComboPopup::OnMouseMove)
53 EVT_KEY_DOWN(wxVListBoxComboPopup::OnKey)
54 EVT_LEFT_UP(wxVListBoxComboPopup::OnLeftClick)
55 END_EVENT_TABLE()
56
57
58 void wxVListBoxComboPopup::Init()
59 /* : wxVListBox(),
60 wxComboPopup(combo)*/
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
71 bool 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
80 m_useFont = m_combo->GetFont();
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
90 wxVListBoxComboPopup::~wxVListBoxComboPopup()
91 {
92 Clear();
93 }
94
95 bool 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
104 void 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 {
111 OnDrawItem(dc,rect,m_value,wxCP_PAINTING_CONTROL);
112 return;
113 }
114 }
115
116 wxComboPopup::PaintComboControl(dc,rect);
117 }
118
119 void wxVListBoxComboPopup::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
120 {
121 // TODO: Maybe this code could be moved to wxVListBox::OnPaint?
122 dc.SetFont(m_useFont);
123
124 // Set correct text colour for selected items
125 if ( wxVListBox::GetSelection() == (int) n )
126 dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
127 else
128 dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
129
130 OnDrawItem(dc,rect,(int)n,0);
131 }
132
133 wxCoord wxVListBoxComboPopup::OnMeasureItem(size_t WXUNUSED(n)) const
134 {
135 /*
136 int itemHeight = m_combo->OnMeasureListItem(n);
137 if ( itemHeight < 0 )
138 itemHeight = m_itemHeight;
139 */
140 return m_itemHeight;
141 }
142
143 wxCoord wxVListBoxComboPopup::OnMeasureItemWidth(size_t WXUNUSED(n)) const
144 {
145 //return OnMeasureListItemWidth(n);
146 return -1;
147 }
148
149 void 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
159 // This is called from wxVListBoxComboPopup::OnDrawItem, with text colour and font prepared
160 void 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
174 void 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
194 void wxVListBoxComboPopup::SendComboBoxEvent( int selection )
195 {
196 wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId());
197
198 evt.SetEventObject(m_combo);
199
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
216 bool 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
272 if ( value >= 0 )
273 m_combo->SetValue(m_strings[value]);
274
275 SendComboBoxEvent(m_value);
276
277 return true;
278 }
279
280 void 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
289 void wxVListBoxComboPopup::OnComboKeyEvent( wxKeyEvent& event )
290 {
291 // Saturated key movement on
292 if ( !HandleKey(event.GetKeyCode(),true) )
293 event.Skip();
294 }
295
296 void 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
302 void 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
312 void wxVListBoxComboPopup::OnLeftClick(wxMouseEvent& WXUNUSED(event))
313 {
314 DismissWithEvent();
315 }
316
317 void wxVListBoxComboPopup::OnKey(wxKeyEvent& event)
318 {
319 // Select item if ENTER is pressed
320 if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER )
321 {
322 DismissWithEvent();
323 }
324 // Hide popup if ESC is pressed
325 else if ( event.GetKeyCode() == WXK_ESCAPE )
326 Dismiss();
327 else
328 event.Skip();
329 }
330
331 void wxVListBoxComboPopup::CheckWidth( int pos )
332 {
333 wxCoord x = OnMeasureItemWidth(pos);
334
335 if ( x < 0 )
336 {
337 if ( !m_useFont.Ok() )
338 m_useFont = m_combo->GetFont();
339
340 wxCoord y;
341 m_combo->GetTextExtent(m_strings[pos], &x, &y, 0, 0, &m_useFont);
342 x += 4;
343 }
344
345 if ( m_widestWidth < x )
346 {
347 m_widestWidth = x;
348 }
349 }
350
351 void 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 )
357 {
358 m_value = pos;
359 }
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
370 int 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
396 void 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
408 void 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
420 void 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
431 void* wxVListBoxComboPopup::GetItemClientData(unsigned int n) const
432 {
433 if ( m_clientDatas.GetCount() > n )
434 return m_clientDatas[n];
435
436 return NULL;
437 }
438
439 void 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
456 int wxVListBoxComboPopup::FindString(const wxString& s) const
457 {
458 return m_strings.Index(s);
459 }
460
461 unsigned int wxVListBoxComboPopup::GetCount() const
462 {
463 return m_strings.GetCount();
464 }
465
466 wxString wxVListBoxComboPopup::GetString( int item ) const
467 {
468 return m_strings[item];
469 }
470
471 void wxVListBoxComboPopup::SetString( int item, const wxString& str )
472 {
473 m_strings[item] = str;
474 }
475
476 wxString wxVListBoxComboPopup::GetStringValue() const
477 {
478 if ( m_value >= 0 )
479 return m_strings[m_value];
480 return wxEmptyString;
481 }
482
483 void 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
495 int wxVListBoxComboPopup::GetSelection() const
496 {
497 return m_value;
498 }
499
500 void 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
510 wxSize 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
546 //void wxVListBoxComboPopup::Populate( int n, const wxString choices[] )
547 void wxVListBoxComboPopup::Populate( const wxArrayString& choices )
548 {
549 int i;
550
551 int n = choices.GetCount();
552
553 for ( i=0; i<n; i++ )
554 {
555 const wxString& item = choices.Item(i);
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
578 BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboControl)
579 END_EVENT_TABLE()
580
581
582 IMPLEMENT_DYNAMIC_CLASS2(wxOwnerDrawnComboBox, wxComboControl, wxControlWithItems)
583
584 void wxOwnerDrawnComboBox::Init()
585 {
586 m_popupInterface = NULL;
587 }
588
589 bool 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
601 wxOwnerDrawnComboBox::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
617 bool 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 {
627 m_initChs = choices;
628 //wxCArrayString chs(choices);
629
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);
634 }
635
636 bool 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
654 int i;
655 for ( i=0; i<n; i++ )
656 m_initChs.Add(choices[i]);
657
658 return true;
659 }
660
661 wxOwnerDrawnComboBox::~wxOwnerDrawnComboBox()
662 {
663 if ( m_popupInterface )
664 m_popupInterface->ClearClientDatas();
665 }
666
667 void 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
688 // ----------------------------------------------------------------------------
689 // wxOwnerDrawnComboBox item manipulation methods
690 // ----------------------------------------------------------------------------
691
692 void wxOwnerDrawnComboBox::Clear()
693 {
694 EnsurePopupControl();
695
696 m_popupInterface->Clear();
697
698 GetTextCtrl()->SetValue(wxEmptyString);
699 }
700
701 void 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
711 unsigned int wxOwnerDrawnComboBox::GetCount() const
712 {
713 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
714 return m_popupInterface->GetCount();
715 }
716
717 wxString 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
723 void 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
729 int wxOwnerDrawnComboBox::FindString(const wxString& s) const
730 {
731 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
732 return m_popupInterface->FindString(s);
733 }
734
735 void wxOwnerDrawnComboBox::Select(int n)
736 {
737 wxCHECK_RET( (n >= -1) && (n < (int)GetCount()), _T("invalid index in wxOwnerDrawnComboBox::Select") );
738 EnsurePopupControl();
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
755 int wxOwnerDrawnComboBox::GetSelection() const
756 {
757 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
758 return m_popupInterface->GetSelection();
759 }
760
761 int wxOwnerDrawnComboBox::DoAppend(const wxString& item)
762 {
763 EnsurePopupControl();
764 wxASSERT(m_popupInterface);
765 return m_popupInterface->Append(item);
766 }
767
768 int 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
773 EnsurePopupControl();
774 m_popupInterface->Insert(item,pos);
775
776 return pos;
777 }
778
779 void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData)
780 {
781 EnsurePopupControl();
782 m_popupInterface->SetItemClientData(n,clientData,m_clientDataItemsType);
783 }
784
785 void* wxOwnerDrawnComboBox::DoGetItemClientData(unsigned int n) const
786 {
787 wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
788 return m_popupInterface->GetItemClientData(n);
789 }
790
791 void wxOwnerDrawnComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
792 {
793 DoSetItemClientData(n, (void*) clientData);
794 }
795
796 wxClientData* wxOwnerDrawnComboBox::DoGetItemClientObject(unsigned int n) const
797 {
798 return (wxClientData*) DoGetItemClientData(n);
799 }
800
801 #endif // wxUSE_OWNERDRAWNCOMBOBOX