+//----------------------------------------------------------------------
+// Helper classes for ListBox
+
+// A wxListBox that gives focus to its parent if it gets it.
+class wxSTCListBox : public wxListBox {
+public:
+ wxSTCListBox(wxWindow* parent, wxWindowID id)
+ : wxListBox(parent, id, wxDefaultPosition, wxDefaultSize,
+ 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER)
+ {}
+
+ void OnFocus(wxFocusEvent& event) {
+ GetParent()->SetFocus();
+ event.Skip();
+ }
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox)
+ EVT_SET_FOCUS(wxSTCListBox::OnFocus)
+END_EVENT_TABLE()
+
+
+
+// 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
+#include <wx/popupwin.h>
+#define wxSTCListBoxWinBase wxPopupWindow
+#define param2 wxBORDER_NONE // popup's 2nd param is flags
+#else
+#define wxSTCListBoxWinBase wxWindow
+#define param2 -1 // wxWindows 2nd param is ID
+#endif
+
+class wxSTCListBoxWin : public wxSTCListBoxWinBase {
+public:
+ wxSTCListBoxWin(wxWindow* parent, wxWindowID id)
+ : wxSTCListBoxWinBase(parent, param2) {
+ lb = new wxSTCListBox(this, id);
+ }
+
+ void OnSize(wxSizeEvent& event) {
+ lb->SetSize(GetSize());
+ }
+ void OnFocus(wxFocusEvent& event) {
+ GetParent()->SetFocus();
+ event.Skip();
+ }
+
+ wxListBox* GetLB() { return lb; }
+
+#if wxUSE_POPUPWIN
+ 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)
+ EVT_SET_FOCUS (wxSTCListBoxWin::OnFocus)
+END_EVENT_TABLE()
+
+
+#define GETLB(win) (((wxSTCListBoxWin*)win)->GetLB())
+
+//----------------------------------------------------------------------