From be62e9322d7ed2f3e5b62444cb3d8447ca14dbf8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sat, 21 Oct 2000 22:09:00 +0000 Subject: [PATCH] Some tweaks to make the AutoComplete list box behave better, and a few other little things git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/PlatWX.cpp | 30 ++++++++++++++++++++++++++++-- contrib/src/stc/stc.cpp | 6 +++++- contrib/src/stc/stc.cpp.in | 6 +++++- src/stc/PlatWX.cpp | 30 ++++++++++++++++++++++++++++-- src/stc/stc.cpp | 6 +++++- src/stc/stc.cpp.in | 6 +++++- 6 files changed, 76 insertions(+), 8 deletions(-) diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 63b363ec0e..7211cb06b8 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -446,6 +446,27 @@ void Window::SetTitle(const char *s) { } +class wxSTCListBox : public wxListBox { +public: + wxSTCListBox(wxWindow* parent, wxWindowID id) + : wxListBox(parent, id, wxDefaultPosition, wxDefaultSize, + 0, NULL, wxLB_SINGLE | wxLB_SORT | 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() + ListBox::ListBox() { } @@ -454,8 +475,9 @@ ListBox::~ListBox() { } void ListBox::Create(Window &parent, int ctrlID) { - id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize, - 0, NULL, wxLB_SINGLE | wxLB_SORT); + id = new wxSTCListBox(parent.id, ctrlID); + //id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize, + // 0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER); } PRectangle ListBox::GetDesiredRect() { @@ -463,6 +485,10 @@ PRectangle ListBox::GetDesiredRect() { PRectangle rc; rc.top = 0; rc.left = 0; + if (sz.x > 150) // TODO: A better way to determine these max sizes + sz.x = 150; + if (sz.y > 100) + sz.y = 100; rc.right = sz.x; rc.bottom = sz.y; diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index 250bfa440c..d8af67cd6b 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -98,7 +98,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, long style, const wxString& name) : wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS, + style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name) { m_swx = new ScintillaWX(this); @@ -119,6 +119,10 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } +#ifdef MAKELONG +#undef MAKELONG +#endif + #define MAKELONG(a, b) ((a) | ((b) << 16)) diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index e38f930f01..b5df70df2a 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -98,7 +98,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, long style, const wxString& name) : wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS, + style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name) { m_swx = new ScintillaWX(this); @@ -119,6 +119,10 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } +#ifdef MAKELONG +#undef MAKELONG +#endif + #define MAKELONG(a, b) ((a) | ((b) << 16)) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 63b363ec0e..7211cb06b8 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -446,6 +446,27 @@ void Window::SetTitle(const char *s) { } +class wxSTCListBox : public wxListBox { +public: + wxSTCListBox(wxWindow* parent, wxWindowID id) + : wxListBox(parent, id, wxDefaultPosition, wxDefaultSize, + 0, NULL, wxLB_SINGLE | wxLB_SORT | 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() + ListBox::ListBox() { } @@ -454,8 +475,9 @@ ListBox::~ListBox() { } void ListBox::Create(Window &parent, int ctrlID) { - id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize, - 0, NULL, wxLB_SINGLE | wxLB_SORT); + id = new wxSTCListBox(parent.id, ctrlID); + //id = new wxListBox(parent.id, ctrlID, wxDefaultPosition, wxDefaultSize, + // 0, NULL, wxLB_SINGLE | wxLB_SORT | wxSIMPLE_BORDER); } PRectangle ListBox::GetDesiredRect() { @@ -463,6 +485,10 @@ PRectangle ListBox::GetDesiredRect() { PRectangle rc; rc.top = 0; rc.left = 0; + if (sz.x > 150) // TODO: A better way to determine these max sizes + sz.x = 150; + if (sz.y > 100) + sz.y = 100; rc.right = sz.x; rc.bottom = sz.y; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 250bfa440c..d8af67cd6b 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -98,7 +98,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, long style, const wxString& name) : wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS, + style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name) { m_swx = new ScintillaWX(this); @@ -119,6 +119,10 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } +#ifdef MAKELONG +#undef MAKELONG +#endif + #define MAKELONG(a, b) ((a) | ((b) << 16)) diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index e38f930f01..b5df70df2a 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -98,7 +98,7 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, long style, const wxString& name) : wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS, + style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, wxDefaultValidator, name) { m_swx = new ScintillaWX(this); @@ -119,6 +119,10 @@ long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { } +#ifdef MAKELONG +#undef MAKELONG +#endif + #define MAKELONG(a, b) ((a) | ((b) << 16))