From 9c46ea66472d59fe5fe623c456e540e47d922fcf Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 3 May 2002 23:30:40 +0000 Subject: [PATCH] Make it easier to not use wxPopupWindow in wxSTC, and for now, don't use it at all for the AutoComplete window. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15356 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/stc/stc.h | 7 +++++++ contrib/src/stc/PlatWX.cpp | 16 +++++++++------- contrib/src/stc/ScintillaWX.cpp | 22 ++++++++++++++++++++-- contrib/src/stc/stc.h.in | 7 +++++++ include/wx/stc/stc.h | 7 +++++++ src/stc/PlatWX.cpp | 16 +++++++++------- src/stc/ScintillaWX.cpp | 22 ++++++++++++++++++++-- src/stc/stc.h.in | 7 +++++++ wxPython/contrib/stc/msw/stc_.cpp | 1 + wxPython/contrib/stc/msw/stc_.py | 1 + 10 files changed, 88 insertions(+), 18 deletions(-) diff --git a/contrib/include/wx/stc/stc.h b/contrib/include/wx/stc/stc.h index ab01bf1887..62bc6db594 100644 --- a/contrib/include/wx/stc/stc.h +++ b/contrib/include/wx/stc/stc.h @@ -24,6 +24,13 @@ #include #include +//---------------------------------------------------------------------- + +// Should a wxPopupWindow be used for the call tips and autocomplete windows? +#ifndef wxSTC_USE_POPUP +#define wxSTC_USE_POPUP 1 +#endif + //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated // by gen_iface.py. Do not edit this file. Edit stc.h.in instead diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index c4fcfb5123..23dd10d5bd 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -673,19 +673,20 @@ BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox) EVT_SET_FOCUS(wxSTCListBox::OnFocus) 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 // that will be used so the listbox can extend beyond the client area of the // wxSTC if needed. - -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP #include #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 +#define param2 -1 // wxWindow's 2nd param is ID #endif class wxSTCListBoxWin : public wxSTCListBoxWinBase { @@ -693,6 +694,7 @@ public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id) : wxSTCListBoxWinBase(parent, param2) { lb = new wxSTCListBox(this, id); + lb->SetCursor(wxCursor(wxCURSOR_ARROW)); } void OnSize(wxSizeEvent& event) { @@ -703,9 +705,9 @@ public: event.Skip(); } - wxListBox* GetLB() { return lb; } + wxListBox* GetLB() { return lb; } -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { @@ -755,8 +757,8 @@ PRectangle ListBox::GetDesiredRect() { rc.left = 0; if (sz.x > 400) sz.x = 400; - if (sz.y > 160) // TODO: Use desiredVisibleRows?? - sz.y = 160; + if (sz.y > 140) // TODO: Use desiredVisibleRows?? + sz.y = 140; rc.right = sz.x; rc.bottom = sz.y; return rc; diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index f7336a7196..e45084ca70 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -63,7 +63,7 @@ void wxSTCDropTarget::OnLeave() { #endif -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP #include #define wxSTCCallTipBase wxPopupWindow #define param2 wxBORDER_NONE // popup's 2nd param is flags @@ -88,7 +88,7 @@ public: delete surfaceWindow; } -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { @@ -98,6 +98,21 @@ public: GetParent()->ClientToScreen(NULL, &y); wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); } + + virtual bool Show( bool show = TRUE ) { + bool retval = wxSTCCallTipBase::Show(show); + if (show) { + CaptureMouse(); + } + else { + ReleaseMouse(); + } + return retval; + } + + void OnLeftDown(wxMouseEvent& ) { + Show(FALSE); + } #endif private: @@ -107,6 +122,9 @@ private: BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) EVT_PAINT(wxSTCCallTip::OnPaint) +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP + EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) +#endif END_EVENT_TABLE() diff --git a/contrib/src/stc/stc.h.in b/contrib/src/stc/stc.h.in index f7b01cb837..0e56b08abb 100644 --- a/contrib/src/stc/stc.h.in +++ b/contrib/src/stc/stc.h.in @@ -24,6 +24,13 @@ #include #include +//---------------------------------------------------------------------- + +// Should a wxPopupWindow be used for the call tips and autocomplete windows? +#ifndef wxSTC_USE_POPUP +#define wxSTC_USE_POPUP 1 +#endif + //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated // by gen_iface.py. Do not edit this file. Edit stc.h.in instead diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index ab01bf1887..62bc6db594 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -24,6 +24,13 @@ #include #include +//---------------------------------------------------------------------- + +// Should a wxPopupWindow be used for the call tips and autocomplete windows? +#ifndef wxSTC_USE_POPUP +#define wxSTC_USE_POPUP 1 +#endif + //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated // by gen_iface.py. Do not edit this file. Edit stc.h.in instead diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index c4fcfb5123..23dd10d5bd 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -673,19 +673,20 @@ BEGIN_EVENT_TABLE(wxSTCListBox, wxListBox) EVT_SET_FOCUS(wxSTCListBox::OnFocus) 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 // that will be used so the listbox can extend beyond the client area of the // wxSTC if needed. - -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP #include #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 +#define param2 -1 // wxWindow's 2nd param is ID #endif class wxSTCListBoxWin : public wxSTCListBoxWinBase { @@ -693,6 +694,7 @@ public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id) : wxSTCListBoxWinBase(parent, param2) { lb = new wxSTCListBox(this, id); + lb->SetCursor(wxCursor(wxCURSOR_ARROW)); } void OnSize(wxSizeEvent& event) { @@ -703,9 +705,9 @@ public: event.Skip(); } - wxListBox* GetLB() { return lb; } + wxListBox* GetLB() { return lb; } -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { @@ -755,8 +757,8 @@ PRectangle ListBox::GetDesiredRect() { rc.left = 0; if (sz.x > 400) sz.x = 400; - if (sz.y > 160) // TODO: Use desiredVisibleRows?? - sz.y = 160; + if (sz.y > 140) // TODO: Use desiredVisibleRows?? + sz.y = 140; rc.right = sz.x; rc.bottom = sz.y; return rc; diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index f7336a7196..e45084ca70 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -63,7 +63,7 @@ void wxSTCDropTarget::OnLeave() { #endif -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP #include #define wxSTCCallTipBase wxPopupWindow #define param2 wxBORDER_NONE // popup's 2nd param is flags @@ -88,7 +88,7 @@ public: delete surfaceWindow; } -#if wxUSE_POPUPWIN +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) { @@ -98,6 +98,21 @@ public: GetParent()->ClientToScreen(NULL, &y); wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); } + + virtual bool Show( bool show = TRUE ) { + bool retval = wxSTCCallTipBase::Show(show); + if (show) { + CaptureMouse(); + } + else { + ReleaseMouse(); + } + return retval; + } + + void OnLeftDown(wxMouseEvent& ) { + Show(FALSE); + } #endif private: @@ -107,6 +122,9 @@ private: BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) EVT_PAINT(wxSTCCallTip::OnPaint) +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP + EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) +#endif END_EVENT_TABLE() diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index f7b01cb837..0e56b08abb 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -24,6 +24,13 @@ #include #include +//---------------------------------------------------------------------- + +// Should a wxPopupWindow be used for the call tips and autocomplete windows? +#ifndef wxSTC_USE_POPUP +#define wxSTC_USE_POPUP 1 +#endif + //---------------------------------------------------------------------- // BEGIN generated section. The following code is automatically generated // by gen_iface.py. Do not edit this file. Edit stc.h.in instead diff --git a/wxPython/contrib/stc/msw/stc_.cpp b/wxPython/contrib/stc/msw/stc_.cpp index 97b37af3ca..e08469d4d7 100644 --- a/wxPython/contrib/stc/msw/stc_.cpp +++ b/wxPython/contrib/stc/msw/stc_.cpp @@ -11032,6 +11032,7 @@ SWIGEXPORT(void) initstc_c() { SWIG_globals = SWIG_newvarlink(); m = Py_InitModule("stc_c", stc_cMethods); d = PyModule_GetDict(m); + PyDict_SetItemString(d,"wxSTC_USE_POPUP", PyInt_FromLong((long) 1)); PyDict_SetItemString(d,"wxSTC_INVALID_POSITION", PyInt_FromLong((long) -1)); PyDict_SetItemString(d,"wxSTC_START", PyInt_FromLong((long) 2000)); PyDict_SetItemString(d,"wxSTC_OPTIONAL_START", PyInt_FromLong((long) 3000)); diff --git a/wxPython/contrib/stc/msw/stc_.py b/wxPython/contrib/stc/msw/stc_.py index 4be749e525..3e189c0e64 100644 --- a/wxPython/contrib/stc/msw/stc_.py +++ b/wxPython/contrib/stc/msw/stc_.py @@ -1158,6 +1158,7 @@ class wxStyledTextEvent(wxStyledTextEventPtr): #-------------- VARIABLE WRAPPERS ------------------ +wxSTC_USE_POPUP = stc_c.wxSTC_USE_POPUP wxSTC_INVALID_POSITION = stc_c.wxSTC_INVALID_POSITION wxSTC_START = stc_c.wxSTC_START wxSTC_OPTIONAL_START = stc_c.wxSTC_OPTIONAL_START -- 2.45.2