From 267484bc4fb1ce9a5da47cb496e9a8db04bfae96 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 13 May 2002 20:33:54 +0000 Subject: [PATCH] The use of wxPopupWindow fo rhte autocomplete and calltip windows is now a little better integrated. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15544 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/src/stc/PlatWX.cpp | 27 ++++++++++++++------------- contrib/src/stc/ScintillaWX.cpp | 6 ++++++ src/stc/PlatWX.cpp | 27 ++++++++++++++------------- src/stc/ScintillaWX.cpp | 6 ++++++ 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 23dd10d5bd..9e477cc58a 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -652,6 +652,11 @@ void Window::SetTitle(const char *s) { //---------------------------------------------------------------------- // Helper classes for ListBox + +// #undef wxSTC_USE_POPUP +// #define wxSTC_USE_POPUP 0 + + // A wxListBox that gives focus back to its parent if it gets it. class wxSTCListBox : public wxListBox { public: @@ -660,9 +665,10 @@ public: 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER) {} - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); + void OnKeyDown(wxKeyEvent& event) { + // Give the key events to the STC. It will then update + // the listbox as needed. + GetGrandParent()->GetEventHandler()->ProcessEvent(event); } private: @@ -670,11 +676,10 @@ private: }; BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox) - EVT_SET_FOCUS(wxSTCListBox::OnFocus) + EVT_KEY_DOWN(wxSTCListBox::OnKeyDown) + EVT_CHAR(wxSTCListBox::OnKeyDown) END_EVENT_TABLE() -#undef wxSTC_USE_POPUP -#define wxSTC_USE_POPUP 0 // Leave it off for this one... // A window to place the listbox upon. If wxPopupWindow is supported then @@ -695,17 +700,14 @@ public: : wxSTCListBoxWinBase(parent, param2) { lb = new wxSTCListBox(this, id); lb->SetCursor(wxCursor(wxCURSOR_ARROW)); + lb->SetFocus(); } void OnSize(wxSizeEvent& event) { lb->SetSize(GetSize()); } - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); - } - wxListBox* GetLB() { return lb; } + wxListBox* GetLB() { return lb; } #if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, @@ -725,8 +727,7 @@ private: }; BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase) - EVT_SIZE (wxSTCListBoxWin::OnSize) - EVT_SET_FOCUS (wxSTCListBoxWin::OnFocus) + EVT_SIZE(wxSTCListBoxWin::OnSize) END_EVENT_TABLE() diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index e45084ca70..8a2c4d27b1 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -88,6 +88,11 @@ public: delete surfaceWindow; } + void OnFocus(wxFocusEvent& event) { + GetParent()->SetFocus(); + event.Skip(); + } + #if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, @@ -122,6 +127,7 @@ private: BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) EVT_PAINT(wxSTCCallTip::OnPaint) + EVT_SET_FOCUS(wxSTCCallTip::OnFocus) #if wxUSE_POPUPWIN && wxSTC_USE_POPUP EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) #endif diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 23dd10d5bd..9e477cc58a 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -652,6 +652,11 @@ void Window::SetTitle(const char *s) { //---------------------------------------------------------------------- // Helper classes for ListBox + +// #undef wxSTC_USE_POPUP +// #define wxSTC_USE_POPUP 0 + + // A wxListBox that gives focus back to its parent if it gets it. class wxSTCListBox : public wxListBox { public: @@ -660,9 +665,10 @@ public: 0, NULL, wxLB_SINGLE | wxSIMPLE_BORDER) {} - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); + void OnKeyDown(wxKeyEvent& event) { + // Give the key events to the STC. It will then update + // the listbox as needed. + GetGrandParent()->GetEventHandler()->ProcessEvent(event); } private: @@ -670,11 +676,10 @@ private: }; BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox) - EVT_SET_FOCUS(wxSTCListBox::OnFocus) + EVT_KEY_DOWN(wxSTCListBox::OnKeyDown) + EVT_CHAR(wxSTCListBox::OnKeyDown) END_EVENT_TABLE() -#undef wxSTC_USE_POPUP -#define wxSTC_USE_POPUP 0 // Leave it off for this one... // A window to place the listbox upon. If wxPopupWindow is supported then @@ -695,17 +700,14 @@ public: : wxSTCListBoxWinBase(parent, param2) { lb = new wxSTCListBox(this, id); lb->SetCursor(wxCursor(wxCURSOR_ARROW)); + lb->SetFocus(); } void OnSize(wxSizeEvent& event) { lb->SetSize(GetSize()); } - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); - } - wxListBox* GetLB() { return lb; } + wxListBox* GetLB() { return lb; } #if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, @@ -725,8 +727,7 @@ private: }; BEGIN_EVENT_TABLE(wxSTCListBoxWin, wxSTCListBoxWinBase) - EVT_SIZE (wxSTCListBoxWin::OnSize) - EVT_SET_FOCUS (wxSTCListBoxWin::OnFocus) + EVT_SIZE(wxSTCListBoxWin::OnSize) END_EVENT_TABLE() diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index e45084ca70..8a2c4d27b1 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -88,6 +88,11 @@ public: delete surfaceWindow; } + void OnFocus(wxFocusEvent& event) { + GetParent()->SetFocus(); + event.Skip(); + } + #if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, @@ -122,6 +127,7 @@ private: BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) EVT_PAINT(wxSTCCallTip::OnPaint) + EVT_SET_FOCUS(wxSTCCallTip::OnFocus) #if wxUSE_POPUPWIN && wxSTC_USE_POPUP EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) #endif -- 2.45.2