+//----------------------------------------------------------------------
+// Helper classes for ListBox
+
+
+#if defined(__WXMAC__)
+class wxSTCListBoxWin : public wxListBox {
+public:
+ wxSTCListBoxWin(wxWindow* parent, wxWindowID id)
+ : wxListBox(parent, id, wxDefaultPosition, wxSize(0,0),
+ 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER) {
+ SetCursor(wxCursor(wxCURSOR_ARROW));
+ Hide();
+ }
+
+ void OnFocus(wxFocusEvent& event) {
+ GetParent()->SetFocus();
+ event.Skip();
+ }
+
+ wxListBox* GetLB() { return this; }
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+
+BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxListBox)
+ EVT_SET_FOCUS(wxSTCListBoxWin::OnFocus)
+END_EVENT_TABLE()
+
+
+
+#else
+
+
+class wxSTCListBox : public wxListBox {
+public:
+ wxSTCListBox(wxWindow* parent, wxWindowID id)
+ : wxListBox(parent, id, wxDefaultPosition, wxDefaultSize,
+ 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER | wxWANTS_CHARS)
+ {}
+
+ void OnKeyDown(wxKeyEvent& event) {
+ // Give the key events to the STC. It will then update
+ // the listbox as needed.
+ GetGrandParent()->GetEventHandler()->ProcessEvent(event);
+ }
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox)
+ EVT_KEY_DOWN(wxSTCListBox::OnKeyDown)
+ EVT_CHAR(wxSTCListBox::OnKeyDown)
+END_EVENT_TABLE()
+
+
+
+#undef wxSTC_USE_POPUP
+#define wxSTC_USE_POPUP 0 // wxPopupWindow just doesn't work well in this case...
+
+// A window to place the listbox upon. If wxPopupWindow is supported then
+// that will be used so the listbox can extend beyond the client area of the
+// wxSTC if needed.
+#if wxUSE_POPUPWIN && wxSTC_USE_POPUP
+#include <wx/popupwin.h>
+#define wxSTCListBoxWinBase wxPopupWindow
+#define param2 wxBORDER_NONE // popup's 2nd param is flags
+#else
+#define wxSTCListBoxWinBase wxWindow
+#define param2 -1 // wxWindow's 2nd param is ID
+#endif
+
+class wxSTCListBoxWin : public wxSTCListBoxWinBase {
+public:
+ wxSTCListBoxWin(wxWindow* parent, wxWindowID id)
+ : wxSTCListBoxWinBase(parent, param2) {
+ lb = new wxSTCListBox(this, id);
+ lb->SetCursor(wxCursor(wxCURSOR_ARROW));
+ lb->SetFocus();
+ }
+
+ void OnSize(wxSizeEvent& event) {
+ lb->SetSize(GetSize());
+ }
+
+ wxListBox* GetLB() { return lb; }
+
+#if wxUSE_POPUPWIN && wxSTC_USE_POPUP
+ virtual void DoSetSize(int x, int y,
+ int width, int height,
+ int sizeFlags = wxSIZE_AUTO) {
+ if (x != -1)
+ GetParent()->ClientToScreen(&x, NULL);
+ if (y != -1)
+ GetParent()->ClientToScreen(NULL, &y);
+ wxSTCListBoxWinBase::DoSetSize(x, y, width, height, sizeFlags);
+ }
+#endif
+
+private:
+ wxSTCListBox* lb;
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase)
+ EVT_SIZE(wxSTCListBoxWin::OnSize)
+END_EVENT_TABLE()
+#endif
+
+inline wxListBox* GETLB(WindowID win) {
+ return (((wxSTCListBoxWin*)win)->GetLB());
+}
+
+//----------------------------------------------------------------------