wxVListBoxComboPopup Class Reference

#include <odcombo.h>

Inheritance diagram for wxVListBoxComboPopup:

wxComboPopup wxCamVListBoxComboPopup wxCamBitmapDropdownPopup List of all members.

Public Member Functions

 wxVListBoxComboPopup ()
virtual ~wxVListBoxComboPopup ()
virtual void Init ()
virtual bool Create (wxWindow *parent)
virtual wxWindow * GetControl ()
virtual void SetStringValue (const wxString &value)
virtual wxString GetStringValue () const
virtual void OnPopup ()
virtual wxSize GetAdjustedSize (int minWidth, int prefHeight, int maxHeight)
virtual void PaintComboControl (wxDC &dc, const wxRect &rect)
virtual void OnComboKeyEvent (wxKeyEvent &event)
virtual void OnComboDoubleClick ()
virtual bool LazyCreate ()
void SetSelection (int item)
void Insert (const wxString &item, int pos)
int Append (const wxString &item)
void Clear ()
void Delete (unsigned int item)
void SetItemClientData (unsigned int n, void *clientData, wxClientDataType clientDataItemsType)
void * GetItemClientData (unsigned int n) const
void SetString (int item, const wxString &str)
wxString GetString (int item) const
unsigned int GetCount () const
int FindString (const wxString &s, bool bCase=false) const
int GetSelection () const
void Populate (const wxArrayString &choices)
void ClearClientDatas ()
int GetItemAtPosition (const wxPoint &pos)
wxCoord GetTotalHeight () const
wxCoord GetLineHeight (int line) const

Protected Member Functions

bool HandleKey (int keycode, bool saturate, wxChar unicode=0)
void SendComboBoxEvent (int selection)
void DismissWithEvent ()
void ItemWidthChanged (unsigned int item)
virtual void OnDrawItem (wxDC &dc, const wxRect &rect, int item, int flags) const
virtual wxCoord OnMeasureItem (size_t item) const
virtual wxCoord OnMeasureItemWidth (size_t item) const
virtual void OnDrawBg (wxDC &dc, const wxRect &rect, int item, int flags) const
virtual void OnDrawItem (wxDC &dc, const wxRect &rect, size_t n) const
void OnDrawBackground (wxDC &dc, const wxRect &rect, size_t n) const
void OnMouseMove (wxMouseEvent &event)
void OnMouseWheel (wxMouseEvent &event)
void OnKey (wxKeyEvent &event)
void OnLeftClick (wxMouseEvent &event)
int GetWidestItemWidth ()
int GetWidestItem ()
void StopPartialCompletion ()

Protected Attributes

wxArrayString m_strings
wxArrayPtrVoid m_clientDatas
wxFont m_useFont
int m_value
int m_itemHover
int m_itemHeight
wxClientDataType m_clientDataItemsType

Private Member Functions

void CalcWidths ()

Private Attributes

wxArrayInt m_widths
int m_widestWidth
int m_widestItem
bool m_widthsDirty
bool m_findWidest
bool m_clicked
wxString m_partialCompletionString

Friends

class wxOwnerDrawnComboBox

Detailed Description

Definition at line 71 of file odcombo.h.


Constructor & Destructor Documentation

wxVListBoxComboPopup::wxVListBoxComboPopup  )  [inline]
 

Definition at line 78 of file odcombo.h.

00078 : wxVListBox(), wxComboPopup() { }

wxVListBoxComboPopup::~wxVListBoxComboPopup  )  [virtual]
 

Definition at line 85 of file odcombo.cpp.

00086 {
00087     Clear();
00088 }


Member Function Documentation

int wxVListBoxComboPopup::Append const wxString &  item  ) 
 

Definition at line 451 of file odcombo.cpp.

00452 {
00453     int pos = (int)m_strings.GetCount();
00454 
00455     if ( m_combo->GetWindowStyle() & wxCB_SORT )
00456     {
00457         // Find position
00458         // TODO: Could be optimized with binary search
00459         wxArrayString strings = m_strings;
00460         unsigned int i;
00461 
00462         for ( i=0; i<strings.GetCount(); i++ )
00463         {
00464             if ( item.Cmp(strings.Item(i)) < 0 )
00465             {
00466                 pos = (int)i;
00467                 break;
00468             }
00469         }
00470     }
00471 
00472     Insert(item,pos);
00473 
00474     return pos;
00475 }

void wxVListBoxComboPopup::CalcWidths  )  [private]
 

Definition at line 603 of file odcombo.cpp.

00604 {
00605     bool doFindWidest = m_findWidest;
00606 
00607     // Measure items with dirty width.
00608     if ( m_widthsDirty )
00609     {
00610         unsigned int i;
00611         unsigned int n = m_widths.GetCount();
00612         int dirtyHandled = 0;
00613         wxArrayInt& widths = m_widths;
00614 
00615         // I think using wxDC::GetTextExtent is faster than
00616         // wxWindow::GetTextExtent (assuming same dc is used
00617         // for all calls, as we do here).
00618         wxClientDC dc(m_combo);
00619         dc.SetFont(m_useFont);
00620 
00621         for ( i=0; i<n; i++ )
00622         {
00623             if ( widths[i] < 0 )
00624             {
00625                 wxCoord x = OnMeasureItemWidth(i);
00626 
00627                 if ( x < 0 )
00628                 {
00629                     const wxString& text = m_strings[i];
00630 
00631                     // To make sure performance won't suck in extreme scenarios,
00632                     // we'll estimate length after some arbitrary number of items
00633                     // have been checked precily.
00634                     if ( dirtyHandled < 1024 )
00635                     {
00636                         wxCoord y;
00637                         dc.GetTextExtent(text, &x, &y, 0, 0);
00638                         x += 4;
00639                     }
00640                     else
00641                     {
00642                         x = text.length() * (dc.GetCharWidth()+1);
00643                     }
00644                 }
00645 
00646                 widths[i] = x;
00647 
00648                 if ( x >= m_widestWidth )
00649                 {
00650                     m_widestWidth = x;
00651                     m_widestItem = (int)i;
00652                 }
00653                 else if ( (int)i == m_widestItem )
00654                 {
00655                     // Width of previously widest item has been decreased, so
00656                     // we'll have to check all to find current widest item.
00657                     doFindWidest = true;
00658                 }
00659 
00660                 dirtyHandled++;
00661             }
00662         }
00663 
00664         m_widthsDirty = false;
00665     }
00666 
00667     if ( doFindWidest )
00668     {
00669         unsigned int i;
00670         unsigned int n = m_widths.GetCount();
00671 
00672         int bestWidth = -1;
00673         int bestIndex = -1;
00674 
00675         for ( i=0; i<n; i++ )
00676         {
00677             int w = m_widths[i];
00678             if ( w > bestWidth )
00679             {
00680                 bestIndex = (int)i;
00681                 bestWidth = w;
00682             }
00683         }
00684 
00685         m_widestWidth = bestWidth;
00686         m_widestItem = bestIndex;
00687 
00688         m_findWidest = false;
00689     }
00690 }

void wxVListBoxComboPopup::Clear  ) 
 

Definition at line 477 of file odcombo.cpp.

00478 {
00479     wxASSERT(m_combo);
00480 
00481     m_strings.Empty();
00482     m_widths.Empty();
00483 
00484     m_widestWidth = 0;
00485     m_widestItem = -1;
00486 
00487     ClearClientDatas();
00488 
00489     m_value = wxNOT_FOUND;
00490 
00491     if ( IsCreated() )
00492         wxVListBox::SetItemCount(0);
00493 }

void wxVListBoxComboPopup::ClearClientDatas  ) 
 

Definition at line 495 of file odcombo.cpp.

00496 {
00497     if ( m_clientDataItemsType == wxClientData_Object )
00498     {
00499         size_t i;
00500         for ( i=0; i<m_clientDatas.GetCount(); i++ )
00501             delete (wxClientData*) m_clientDatas[i];
00502     }
00503 
00504     m_clientDatas.Empty();
00505 }

bool wxVListBoxComboPopup::Create wxWindow *  parent  )  [virtual]
 

Implements wxComboPopup.

Definition at line 66 of file odcombo.cpp.

00067 {
00068     if ( !wxVListBox::Create(parent,
00069                              wxID_ANY,
00070                              wxDefaultPosition,
00071                              wxDefaultSize,
00072                              wxBORDER_SIMPLE | wxLB_INT_HEIGHT | wxWANTS_CHARS) )
00073         return false;
00074 
00075     m_useFont = m_combo->GetFont();
00076 
00077     wxVListBox::SetItemCount(m_strings.GetCount());
00078 
00079     // TODO: Move this to SetFont
00080     m_itemHeight = GetCharHeight() + 0;
00081 
00082     return true;
00083 }

void wxVListBoxComboPopup::Delete unsigned int  item  ) 
 

Definition at line 528 of file odcombo.cpp.

00529 {
00530     // Remove client data, if set
00531     if ( m_clientDatas.GetCount() )
00532     {
00533         if ( m_clientDataItemsType == wxClientData_Object )
00534             delete (wxClientData*) m_clientDatas[item];
00535 
00536         m_clientDatas.RemoveAt(item);
00537     }
00538 
00539     m_strings.RemoveAt(item);
00540     m_widths.RemoveAt(item);
00541 
00542     if ( (int)item == m_widestItem )
00543         m_findWidest = true;
00544 
00545     if ( IsCreated() )
00546         wxVListBox::SetItemCount( wxVListBox::GetItemCount()-1 );
00547 }

void wxVListBoxComboPopup::DismissWithEvent  )  [protected]
 

Definition at line 180 of file odcombo.cpp.

00181 {
00182     StopPartialCompletion();
00183 
00184     int selection = wxVListBox::GetSelection();
00185 
00186     Dismiss();
00187 
00188     wxString valStr;
00189     if ( selection != wxNOT_FOUND )
00190         valStr = m_strings[selection];
00191     else
00192         valStr = wxEmptyString;
00193 
00194     m_value = selection;
00195 
00196     if ( valStr != m_combo->GetValue() )
00197         m_combo->SetValue(valStr);
00198 
00199     SendComboBoxEvent(selection);
00200 }

int wxVListBoxComboPopup::FindString const wxString &  s,
bool  bCase = false
const
 

Definition at line 549 of file odcombo.cpp.

00550 {
00551     return m_strings.Index(s, bCase);
00552 }

wxSize wxVListBoxComboPopup::GetAdjustedSize int  minWidth,
int  prefHeight,
int  maxHeight
[virtual]
 

Reimplemented from wxComboPopup.

Definition at line 692 of file odcombo.cpp.

00693 {
00694     int height = 250;
00695 
00696     if ( m_strings.GetCount() )
00697     {
00698         if ( prefHeight > 0 )
00699             height = prefHeight;
00700 
00701         if ( height > maxHeight )
00702             height = maxHeight;
00703 
00704         int totalHeight = GetTotalHeight(); // + 3;
00705         if ( height >= totalHeight )
00706         {
00707             height = totalHeight;
00708         }
00709         else
00710         {
00711             // Adjust height to a multiple of the height of the first item
00712             // NB: Calculations that take variable height into account
00713             //     are unnecessary.
00714             int fih = GetLineHeight(0);
00715             int shown = height/fih;
00716             height = shown * fih;
00717         }
00718     }
00719     else
00720         height = 50;
00721 
00722     CalcWidths();
00723 
00724     // Take scrollbar into account in width calculations
00725     int widestWidth = m_widestWidth + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
00726     return wxSize(minWidth > widestWidth ? minWidth : widestWidth,
00727                   height+2);
00728 }

virtual wxWindow* wxVListBoxComboPopup::GetControl  )  [inline, virtual]
 

Implements wxComboPopup.

Definition at line 84 of file odcombo.h.

00084 { return this; }

unsigned int wxVListBoxComboPopup::GetCount  )  const
 

Definition at line 554 of file odcombo.cpp.

00555 {
00556     return m_strings.GetCount();
00557 }

int wxVListBoxComboPopup::GetItemAtPosition const wxPoint &  pos  )  [inline]
 

Definition at line 115 of file odcombo.h.

00115 { return HitTest(pos); }

void * wxVListBoxComboPopup::GetItemClientData unsigned int  n  )  const
 

Definition at line 520 of file odcombo.cpp.

00521 {
00522     if ( m_clientDatas.GetCount() > n )
00523         return m_clientDatas[n];
00524 
00525     return NULL;
00526 }

wxCoord wxVListBoxComboPopup::GetLineHeight int  line  )  const [inline]
 

Definition at line 117 of file odcombo.h.

00117 { return OnGetLineHeight(line); }

int wxVListBoxComboPopup::GetSelection  )  const
 

Definition at line 588 of file odcombo.cpp.

00589 {
00590     return m_value;
00591 }

wxString wxVListBoxComboPopup::GetString int  item  )  const
 

Definition at line 559 of file odcombo.cpp.

00560 {
00561     return m_strings[item];
00562 }

wxString wxVListBoxComboPopup::GetStringValue  )  const [virtual]
 

Implements wxComboPopup.

Definition at line 570 of file odcombo.cpp.

00571 {
00572     if ( m_value >= 0 )
00573         return m_strings[m_value];
00574     return wxEmptyString;
00575 }

wxCoord wxVListBoxComboPopup::GetTotalHeight  )  const [inline]
 

Definition at line 116 of file odcombo.h.

00116 { return EstimateTotalHeight(); }

int wxVListBoxComboPopup::GetWidestItem  )  [inline, protected]
 

Definition at line 173 of file odcombo.h.

00173 { CalcWidths(); return m_widestItem; }

int wxVListBoxComboPopup::GetWidestItemWidth  )  [inline, protected]
 

Definition at line 170 of file odcombo.h.

00170 { CalcWidths(); return m_widestWidth; }

bool wxVListBoxComboPopup::HandleKey int  keycode,
bool  saturate,
wxChar  unicode = 0
[protected]
 

Definition at line 224 of file odcombo.cpp.

00225 {
00226     int value = m_value;
00227     int itemCount = GetCount();
00228     int comboStyle = m_combo->GetWindowStyle();
00229 
00230     // this is the character equivalent of the code
00231     wxChar keychar=0;
00232     if ((keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
00233     {
00234         keychar = (wxChar)keycode;
00235     }
00236     else if (unicode>0)
00237     {
00238         keychar = unicode; 
00239     }
00240 
00241     if ( keycode == WXK_DOWN || keycode == WXK_RIGHT )
00242     {
00243         value++;
00244         StopPartialCompletion();
00245     }
00246     else if ( keycode == WXK_UP || keycode == WXK_LEFT )
00247     {
00248         value--;
00249         StopPartialCompletion();
00250     }
00251     else if ( keycode == WXK_PAGEDOWN )
00252     {
00253         value+=10;
00254         StopPartialCompletion();
00255     }
00256     else if ( keycode == WXK_PAGEUP )
00257     {
00258         value-=10;
00259         StopPartialCompletion();
00260     }
00261     else if ( comboStyle & wxCB_READONLY )
00262     {
00263         // Try partial completion
00264 
00265         // find the new partial completion string
00266 #if wxUSE_TIMER
00267         if (m_partialCompletionTimer.IsRunning())
00268             m_partialCompletionString+=wxString(keychar);
00269         else
00270 #endif // wxUSE_TIMER
00271             m_partialCompletionString=wxString(keychar);
00272 
00273         // now search through the values to see if this is found
00274         int found = -1;
00275         unsigned int length=m_partialCompletionString.Length();
00276         int i;
00277         for (i=0; i<itemCount; i++)
00278         {
00279             wxString item=GetString(i);
00280             if (( item.Length() >=length) && (!  m_partialCompletionString.CmpNoCase(item.Left(length))))
00281             {
00282                 found=i;
00283                 break;
00284             }
00285         }
00286 
00287         if (found<0)
00288         {
00289             StopPartialCompletion();
00290             ::wxBell();
00291             return true; // to stop the first value being set
00292         }
00293         else
00294         {
00295             value=i;
00296 #if wxUSE_TIMER
00297             m_partialCompletionTimer.Start(wxODCB_PARTIAL_COMPLETION_TIME, true);
00298 #endif // wxUSE_TIMER
00299         }
00300     }
00301     else
00302         return false;
00303 
00304     if ( saturate )
00305     {
00306         if ( value >= itemCount )
00307             value = itemCount - 1;
00308         else if ( value < 0 )
00309             value = 0;
00310     }
00311     else
00312     {
00313         if ( value >= itemCount )
00314             value -= itemCount;
00315         else if ( value < 0 )
00316             value += itemCount;
00317     }
00318 
00319     if ( value == m_value )
00320         // Even if value was same, don't skip the event
00321         // (good for consistency)
00322         return true;
00323 
00324     m_value = value;
00325 
00326     if ( value >= 0 )
00327         m_combo->SetValue(m_strings[value]);
00328 
00329     SendComboBoxEvent(m_value);
00330 
00331     return true;
00332 }

void wxVListBoxComboPopup::Init  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 53 of file odcombo.cpp.

00054 {
00055     m_widestWidth = 0;
00056     m_widestItem = -1;
00057     m_widthsDirty = false;
00058     m_findWidest = false;
00059     m_itemHeight = 0;
00060     m_value = -1;
00061     m_itemHover = -1;
00062     m_clientDataItemsType = wxClientData_None;
00063     m_partialCompletionString = wxEmptyString;
00064 }

void wxVListBoxComboPopup::Insert const wxString &  item,
int  pos
 

Definition at line 433 of file odcombo.cpp.

00434 {
00435     // Need to change selection?
00436     wxString strValue;
00437     if ( !(m_combo->GetWindowStyle() & wxCB_READONLY) &&
00438          m_combo->GetValue() == item )
00439     {
00440         m_value = pos;
00441     }
00442 
00443     m_strings.Insert(item,pos);
00444     m_widths.Insert(-1,pos);
00445     m_widthsDirty = true;
00446 
00447     if ( IsCreated() )
00448         wxVListBox::SetItemCount( wxVListBox::GetItemCount()+1 );
00449 }

void wxVListBoxComboPopup::ItemWidthChanged unsigned int  item  )  [inline, protected]
 

Definition at line 131 of file odcombo.h.

00132     {
00133         m_widths[item] = -1;
00134         m_widthsDirty = true;
00135     }

bool wxVListBoxComboPopup::LazyCreate  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 90 of file odcombo.cpp.

00091 {
00092     // NB: There is a bug with wxVListBox that can be avoided by creating
00093     //     it later (bug causes empty space to be shown if initial selection
00094     //     is at the end of a list longer than the control can show at once).
00095     return true;
00096 }

void wxVListBoxComboPopup::OnComboDoubleClick  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 343 of file odcombo.cpp.

00344 {
00345     // Cycle on dclick (disable saturation to allow true cycling).
00346     if ( !::wxGetKeyState(WXK_SHIFT) )
00347         HandleKey(WXK_DOWN,false);
00348     else
00349         HandleKey(WXK_UP,false);
00350 }

void wxVListBoxComboPopup::OnComboKeyEvent wxKeyEvent &  event  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 352 of file odcombo.cpp.

00353 {
00354     // Saturated key movement on
00355     if ( !HandleKey(event.GetKeyCode(),true,
00356 #if wxUSE_UNICODE
00357         event.GetUnicodeKey()
00358 #else
00359         0
00360 #endif
00361         ) )
00362         event.Skip();
00363 }

void wxVListBoxComboPopup::OnDrawBackground wxDC &  dc,
const wxRect &  rect,
size_t  n
const [protected]
 

Definition at line 164 of file odcombo.cpp.

00165 {
00166     OnDrawBg(dc,rect,(int)n,0);
00167 }

void wxVListBoxComboPopup::OnDrawBg wxDC &  dc,
const wxRect &  rect,
int  item,
int  flags
const [protected, virtual]
 

Definition at line 151 of file odcombo.cpp.

00155 {
00156     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
00157 
00158     wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
00159                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
00160 
00161     combo->OnDrawBackground(dc,rect,item,flags);
00162 }

void wxVListBoxComboPopup::OnDrawItem wxDC &  dc,
const wxRect &  rect,
size_t  n
const [protected, virtual]
 

Definition at line 114 of file odcombo.cpp.

00115 {
00116     // TODO: Maybe this code could be moved to wxVListBox::OnPaint?
00117     dc.SetFont(m_useFont);
00118 
00119     // Set correct text colour for selected items
00120     if ( wxVListBox::GetSelection() == (int) n )
00121         dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT) );
00122     else
00123         dc.SetTextForeground( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
00124 
00125     OnDrawItem(dc,rect,(int)n,0);
00126 }

void wxVListBoxComboPopup::OnDrawItem wxDC &  dc,
const wxRect &  rect,
int  item,
int  flags
const [protected, virtual]
 

Reimplemented in wxCamVListBoxComboPopup.

Definition at line 170 of file odcombo.cpp.

00171 {
00172     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
00173 
00174     wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
00175                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
00176 
00177     combo->OnDrawItem(dc,rect,item,flags);
00178 }

void wxVListBoxComboPopup::OnKey wxKeyEvent &  event  )  [protected]
 

Definition at line 404 of file odcombo.cpp.

00405 {
00406     // Select item if ENTER is pressed
00407     if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER )
00408     {
00409         DismissWithEvent();
00410     }
00411     // Hide popup if ESC is pressed
00412     else if ( event.GetKeyCode() == WXK_ESCAPE )
00413     {
00414         StopPartialCompletion();
00415         Dismiss();
00416     }
00417     else
00418     {
00419         int comboStyle = m_combo->GetWindowStyle();
00420         int keycode = event.GetKeyCode();
00421         // Process partial completion key codes here, but not the arrow keys as the base class will do that for us
00422         if ((comboStyle & wxCB_READONLY) &&
00423             (keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
00424         {
00425             OnComboKeyEvent(event);
00426             SetSelection(m_value); // ensure the highlight bar moves
00427         }
00428         else
00429             event.Skip();
00430     }
00431 }

void wxVListBoxComboPopup::OnLeftClick wxMouseEvent &  event  )  [protected]
 

wxCoord wxVListBoxComboPopup::OnMeasureItem size_t  item  )  const [protected, virtual]
 

Reimplemented in wxCamVListBoxComboPopup.

Definition at line 128 of file odcombo.cpp.

00129 {
00130     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
00131 
00132     wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
00133                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
00134 
00135     wxCoord h = combo->OnMeasureItem(n);
00136     if ( h < 0 )
00137         h = m_itemHeight;
00138     return h;
00139 }

wxCoord wxVListBoxComboPopup::OnMeasureItemWidth size_t  item  )  const [protected, virtual]
 

Reimplemented in wxCamVListBoxComboPopup.

Definition at line 141 of file odcombo.cpp.

00142 {
00143     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
00144 
00145     wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
00146                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
00147 
00148     return combo->OnMeasureItemWidth(n);
00149 }

void wxVListBoxComboPopup::OnMouseMove wxMouseEvent &  event  )  [protected]
 

Definition at line 371 of file odcombo.cpp.

00372 {
00373     event.Skip();
00374 
00375     // Move selection to cursor if it is inside the popup
00376 
00377     int y = event.GetPosition().y;
00378     int fromBottom = GetClientSize().y - y;
00379 
00380     // Since in any case we need to find out if the last item is only
00381     // partially visible, we might just as well replicate the HitTest
00382     // loop here.
00383     const size_t lineMax = GetVisibleEnd();
00384     for ( size_t line = GetVisibleBegin(); line < lineMax; line++ )
00385     {
00386         y -= OnGetLineHeight(line);
00387         if ( y < 0 )
00388         {
00389             // Only change selection if item is fully visible
00390             if ( (y + fromBottom) >= 0 )
00391             {
00392                 wxVListBox::SetSelection((int)line);
00393                 return;
00394             }
00395         }
00396     }
00397 }

void wxVListBoxComboPopup::OnMouseWheel wxMouseEvent &  event  )  [protected]
 

void wxVListBoxComboPopup::OnPopup  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 365 of file odcombo.cpp.

00366 {
00367     // *must* set value after size is set (this is because of a vlbox bug)
00368     wxVListBox::SetSelection(m_value);
00369 }

void wxVListBoxComboPopup::PaintComboControl wxDC &  dc,
const wxRect &  rect
[virtual]
 

Reimplemented from wxComboPopup.

Reimplemented in wxCamBitmapDropdownPopup.

Definition at line 99 of file odcombo.cpp.

00100 {
00101     if ( !(m_combo->GetWindowStyle() & wxODCB_STD_CONTROL_PAINT) )
00102     {
00103         OnDrawBg(dc,rect,m_value,wxODCB_PAINTING_CONTROL);
00104         if ( m_value >= 0 )
00105         {
00106             OnDrawItem(dc,rect,m_value,wxODCB_PAINTING_CONTROL);
00107             return;
00108         }
00109     }
00110 
00111     wxComboPopup::PaintComboControl(dc,rect);
00112 }

void wxVListBoxComboPopup::Populate const wxArrayString &  choices  ) 
 

Definition at line 731 of file odcombo.cpp.

00732 {
00733     int i;
00734 
00735     int n = choices.GetCount();
00736 
00737     for ( i=0; i<n; i++ )
00738     {
00739         const wxString& item = choices.Item(i);
00740         m_strings.Add(item);
00741     }
00742 
00743     m_widths.SetCount(n,-1);
00744     m_widthsDirty = true;
00745 
00746     if ( IsCreated() )
00747         wxVListBox::SetItemCount(n);
00748 
00749     // Sort the initial choices
00750     if ( m_combo->GetWindowStyle() & wxCB_SORT )
00751         m_strings.Sort();
00752 
00753     // Find initial selection
00754     wxString strValue = m_combo->GetValue();
00755     if ( strValue.length() )
00756         m_value = m_strings.Index(strValue);
00757 }

void wxVListBoxComboPopup::SendComboBoxEvent int  selection  )  [protected]
 

Definition at line 202 of file odcombo.cpp.

00203 {
00204     wxCommandEvent evt(wxEVT_COMMAND_COMBOBOX_SELECTED,m_combo->GetId());
00205 
00206     evt.SetEventObject(m_combo);
00207 
00208     evt.SetInt(selection);
00209 
00210     // Set client data, if any
00211     if ( selection >= 0 && (int)m_clientDatas.GetCount() > selection )
00212     {
00213         void* clientData = m_clientDatas[selection];
00214         if ( m_clientDataItemsType == wxClientData_Object )
00215             evt.SetClientObject((wxClientData*)clientData);
00216         else
00217             evt.SetClientData(clientData);
00218     }
00219 
00220     m_combo->GetEventHandler()->AddPendingEvent(evt);
00221 }

void wxVListBoxComboPopup::SetItemClientData unsigned int  n,
void *  clientData,
wxClientDataType  clientDataItemsType
 

Definition at line 507 of file odcombo.cpp.

00510 {
00511     // It should be sufficient to update this variable only here
00512     m_clientDataItemsType = clientDataItemsType;
00513 
00514     m_clientDatas.SetCount(n+1,NULL);
00515     m_clientDatas[n] = clientData;
00516 
00517     ItemWidthChanged(n);
00518 }

void wxVListBoxComboPopup::SetSelection int  item  ) 
 

Definition at line 577 of file odcombo.cpp.

00578 {
00579     wxCHECK_RET( item == wxNOT_FOUND || ((unsigned int)item < GetCount()),
00580                  wxT("invalid index in wxVListBoxComboPopup::SetSelection") );
00581 
00582     m_value = item;
00583 
00584     if ( IsCreated() )
00585         wxVListBox::SetSelection(item);
00586 }

void wxVListBoxComboPopup::SetString int  item,
const wxString &  str
 

Definition at line 564 of file odcombo.cpp.

00565 {
00566     m_strings[item] = str;
00567     ItemWidthChanged(item);
00568 }

void wxVListBoxComboPopup::SetStringValue const wxString &  value  )  [virtual]
 

Reimplemented from wxComboPopup.

Definition at line 593 of file odcombo.cpp.

00594 {
00595     int index = m_strings.Index(value);
00596 
00597     m_value = index;
00598 
00599     if ( index >= -1 && index < (int)wxVListBox::GetItemCount() )
00600         wxVListBox::SetSelection(index);
00601 }

void wxVListBoxComboPopup::StopPartialCompletion  )  [protected]
 

Definition at line 335 of file odcombo.cpp.

00336 {
00337     m_partialCompletionString = wxEmptyString;
00338 #if wxUSE_TIMER
00339     m_partialCompletionTimer.Stop();
00340 #endif // wxUSE_TIMER
00341 }


Friends And Related Function Documentation

friend class wxOwnerDrawnComboBox [friend]
 

Definition at line 74 of file odcombo.h.


Member Data Documentation

bool wxVListBoxComboPopup::m_clicked [private]
 

Definition at line 208 of file odcombo.h.

wxClientDataType wxVListBoxComboPopup::m_clientDataItemsType [protected]
 

Definition at line 188 of file odcombo.h.

wxArrayPtrVoid wxVListBoxComboPopup::m_clientDatas [protected]
 

Definition at line 179 of file odcombo.h.

bool wxVListBoxComboPopup::m_findWidest [private]
 

Definition at line 205 of file odcombo.h.

int wxVListBoxComboPopup::m_itemHeight [protected]
 

Definition at line 186 of file odcombo.h.

int wxVListBoxComboPopup::m_itemHover [protected]
 

Definition at line 185 of file odcombo.h.

wxString wxVListBoxComboPopup::m_partialCompletionString [private]
 

Definition at line 214 of file odcombo.h.

wxArrayString wxVListBoxComboPopup::m_strings [protected]
 

Definition at line 178 of file odcombo.h.

wxFont wxVListBoxComboPopup::m_useFont [protected]
 

Definition at line 181 of file odcombo.h.

int wxVListBoxComboPopup::m_value [protected]
 

Definition at line 184 of file odcombo.h.

int wxVListBoxComboPopup::m_widestItem [private]
 

Definition at line 199 of file odcombo.h.

int wxVListBoxComboPopup::m_widestWidth [private]
 

Definition at line 196 of file odcombo.h.

wxArrayInt wxVListBoxComboPopup::m_widths [private]
 

Definition at line 193 of file odcombo.h.

bool wxVListBoxComboPopup::m_widthsDirty [private]
 

Definition at line 202 of file odcombo.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:03:20 2007 for Camelot by  doxygen 1.4.4