diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 0e92b30e8a..ab2cb5c06a 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -791,9 +791,10 @@ public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : wxPopupWindow(parent, wxBORDER_NONE) { + SetBackgroundColour(*wxBLACK); // for our simple border - lv = new wxSTCListBox(parent, id, wxDefaultPosition, wxDefaultSize, + lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxBORDER_NONE); lv->SetCursor(wxCursor(wxCURSOR_ARROW)); lv->InsertColumn(0, wxEmptyString); @@ -897,17 +898,27 @@ END_EVENT_TABLE() -#else // wxUSE_POPUPWIN ----------------------------------- +#else // !wxUSE_POPUPWIN ----------------------------------- -// A normal window to place the wxSTCListBox upon. -class wxSTCListBoxWin : public wxWindow { +// A normal window to place the wxSTCListBox upon, but make it behave as much +// like a wxPopupWindow as possible +class wxSTCListBoxWin : public wxFrame { private: wxListView* lv; CallBackAction doubleClickAction; void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : - wxWindow(parent, id, wxPoint(location.x, location.y), wxSize(0,0), wxSIMPLE_BORDER ) + wxFrame(parent, id, wxEmptyString, wxPoint(location.x, location.y), wxSize(0,0), + wxFRAME_NO_TASKBAR + | wxFRAME_FLOAT_ON_PARENT +#ifdef __WXMAC__ + | wxPOPUP_WINDOW + | wxNO_BORDER +#else + | wxSIMPLE_BORDER +#endif + ) { lv = new wxSTCListBox(this, id, wxDefaultPosition, wxDefaultSize, @@ -921,14 +932,15 @@ public: lv->SetFocus(); Hide(); - } + } // On OSX and (possibly others) there can still be pending // messages/events for the list control when Scintilla wants to // close it, so do a pending delete of it instead of destroying // immediately. - bool Destroy() { + bool Destroy() + { #ifdef __WXMAC__ // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... @@ -943,7 +955,8 @@ public: } - int IconWidth() { + int IconWidth() + { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { int w, h; @@ -954,18 +967,22 @@ public: } - void SetDoubleClickAction(CallBackAction action, void *data) { + void SetDoubleClickAction(CallBackAction action, void *data) + { doubleClickAction = action; doubleClickActionData = data; } - void OnFocus(wxFocusEvent& event) { + void OnFocus(wxFocusEvent& event) + { + ActivateParent(); GetParent()->SetFocus(); event.Skip(); } - void OnSize(wxSizeEvent& event) { + void OnSize(wxSizeEvent& event) + { // resize the child wxSize sz = GetClientSize(); lv->SetSize(sz); @@ -976,15 +993,44 @@ public: event.Skip(); } + void ActivateParent() + { + // Although we're a frame, we always want the parent to be active, so + // raise it whenever we get shown, focused, etc. + wxTopLevelWindow *frame = wxDynamicCast( + wxGetTopLevelParent(GetParent()), wxTopLevelWindow); + if (frame) + frame->Raise(); + } + + + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO) + { + // convert coords to screen coords since we're a top-level window + if (x != wxDefaultCoord) { + GetParent()->ClientToScreen(&x, NULL); + } + if (y != wxDefaultCoord) { + GetParent()->ClientToScreen(NULL, &y); + } + wxFrame::DoSetSize(x, y, width, height, sizeFlags); + } + + virtual bool Show(bool show = true) + { + bool rv = wxFrame::Show(show); + if (rv && show) + ActivateParent(); #ifdef __WXMAC__ - virtual bool Show(bool show = true) { - bool rv = wxWindow::Show(show); GetParent()->Refresh(false); +#endif return rv; } -#endif - void OnActivate(wxListEvent& WXUNUSED(event)) { + void OnActivate(wxListEvent& WXUNUSED(event)) + { doubleClickAction(doubleClickActionData); } @@ -1193,7 +1239,7 @@ void ListBoxImpl::Select(int n) { n = 0; select = false; } - GETLB(id)->Focus(n); + GETLB(id)->EnsureVisible(n); GETLB(id)->Select(n, select); } diff --git a/contrib/src/stc/ScintillaWX.cpp b/contrib/src/stc/ScintillaWX.cpp index df2f36e343..000db9a24b 100644 --- a/contrib/src/stc/ScintillaWX.cpp +++ b/contrib/src/stc/ScintillaWX.cpp @@ -87,7 +87,7 @@ void wxSTCDropTarget::OnLeave() { #define wxSTCCallTipBase wxPopupWindow #define param2 wxBORDER_NONE // popup's 2nd param is flags #else -#define wxSTCCallTipBase wxWindow +#define wxSTCCallTipBase wxFrame #define param2 -1 // wxWindow's 2nd param is ID #endif @@ -95,8 +95,19 @@ void wxSTCDropTarget::OnLeave() { class wxSTCCallTip : public wxSTCCallTipBase { public: - wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) - : wxSTCCallTipBase(parent, param2), + wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) : +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP + wxSTCCallTipBase(parent, wxBORDER_NONE), +#else + wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, + wxFRAME_NO_TASKBAR + | wxFRAME_FLOAT_ON_PARENT + | wxBORDER_NONE +#ifdef __WXMAC__ + | wxPOPUP_WINDOW +#endif + ), +#endif m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) { } @@ -112,7 +123,8 @@ public: bool AcceptsFocus() const { return false; } - void OnPaint(wxPaintEvent& WXUNUSED(evt)) { + void OnPaint(wxPaintEvent& WXUNUSED(evt)) + { wxBufferedPaintDC dc(this); Surface* surfaceWindow = Surface::Allocate(); surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); @@ -121,22 +133,25 @@ public: delete surfaceWindow; } - void OnFocus(wxFocusEvent& event) { + void OnFocus(wxFocusEvent& event) + { GetParent()->SetFocus(); event.Skip(); } - void OnLeftDown(wxMouseEvent& event) { + void OnLeftDown(wxMouseEvent& event) + { wxPoint pt = event.GetPosition(); Point p(pt.x, pt.y); m_ct->MouseClick(p); m_swx->CallTipClick(); } -#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, - int sizeFlags = wxSIZE_AUTO) { + int sizeFlags = wxSIZE_AUTO) + { + // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) { m_cx = x; GetParent()->ClientToScreen(&x, NULL); @@ -147,9 +162,27 @@ public: } wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); } -#endif - wxPoint GetMyPosition() { +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP +#else + virtual bool Show( bool show = true ) + { + // Although we're a frame, we always want the parent to be active, so + // raise it whenever we get shown. + bool rv = wxSTCCallTipBase::Show(show); + if (rv && show) + { + wxTopLevelWindow *frame = wxDynamicCast( + wxGetTopLevelParent(GetParent()), wxTopLevelWindow); + if (frame) + frame->Raise(); + } + return rv; + } +#endif + + wxPoint GetMyPosition() + { return wxPoint(m_cx, m_cy); } diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 0e92b30e8a..ab2cb5c06a 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -791,9 +791,10 @@ public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : wxPopupWindow(parent, wxBORDER_NONE) { + SetBackgroundColour(*wxBLACK); // for our simple border - lv = new wxSTCListBox(parent, id, wxDefaultPosition, wxDefaultSize, + lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxBORDER_NONE); lv->SetCursor(wxCursor(wxCURSOR_ARROW)); lv->InsertColumn(0, wxEmptyString); @@ -897,17 +898,27 @@ END_EVENT_TABLE() -#else // wxUSE_POPUPWIN ----------------------------------- +#else // !wxUSE_POPUPWIN ----------------------------------- -// A normal window to place the wxSTCListBox upon. -class wxSTCListBoxWin : public wxWindow { +// A normal window to place the wxSTCListBox upon, but make it behave as much +// like a wxPopupWindow as possible +class wxSTCListBoxWin : public wxFrame { private: wxListView* lv; CallBackAction doubleClickAction; void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : - wxWindow(parent, id, wxPoint(location.x, location.y), wxSize(0,0), wxSIMPLE_BORDER ) + wxFrame(parent, id, wxEmptyString, wxPoint(location.x, location.y), wxSize(0,0), + wxFRAME_NO_TASKBAR + | wxFRAME_FLOAT_ON_PARENT +#ifdef __WXMAC__ + | wxPOPUP_WINDOW + | wxNO_BORDER +#else + | wxSIMPLE_BORDER +#endif + ) { lv = new wxSTCListBox(this, id, wxDefaultPosition, wxDefaultSize, @@ -921,14 +932,15 @@ public: lv->SetFocus(); Hide(); - } + } // On OSX and (possibly others) there can still be pending // messages/events for the list control when Scintilla wants to // close it, so do a pending delete of it instead of destroying // immediately. - bool Destroy() { + bool Destroy() + { #ifdef __WXMAC__ // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... @@ -943,7 +955,8 @@ public: } - int IconWidth() { + int IconWidth() + { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { int w, h; @@ -954,18 +967,22 @@ public: } - void SetDoubleClickAction(CallBackAction action, void *data) { + void SetDoubleClickAction(CallBackAction action, void *data) + { doubleClickAction = action; doubleClickActionData = data; } - void OnFocus(wxFocusEvent& event) { + void OnFocus(wxFocusEvent& event) + { + ActivateParent(); GetParent()->SetFocus(); event.Skip(); } - void OnSize(wxSizeEvent& event) { + void OnSize(wxSizeEvent& event) + { // resize the child wxSize sz = GetClientSize(); lv->SetSize(sz); @@ -976,15 +993,44 @@ public: event.Skip(); } + void ActivateParent() + { + // Although we're a frame, we always want the parent to be active, so + // raise it whenever we get shown, focused, etc. + wxTopLevelWindow *frame = wxDynamicCast( + wxGetTopLevelParent(GetParent()), wxTopLevelWindow); + if (frame) + frame->Raise(); + } + + + virtual void DoSetSize(int x, int y, + int width, int height, + int sizeFlags = wxSIZE_AUTO) + { + // convert coords to screen coords since we're a top-level window + if (x != wxDefaultCoord) { + GetParent()->ClientToScreen(&x, NULL); + } + if (y != wxDefaultCoord) { + GetParent()->ClientToScreen(NULL, &y); + } + wxFrame::DoSetSize(x, y, width, height, sizeFlags); + } + + virtual bool Show(bool show = true) + { + bool rv = wxFrame::Show(show); + if (rv && show) + ActivateParent(); #ifdef __WXMAC__ - virtual bool Show(bool show = true) { - bool rv = wxWindow::Show(show); GetParent()->Refresh(false); +#endif return rv; } -#endif - void OnActivate(wxListEvent& WXUNUSED(event)) { + void OnActivate(wxListEvent& WXUNUSED(event)) + { doubleClickAction(doubleClickActionData); } @@ -1193,7 +1239,7 @@ void ListBoxImpl::Select(int n) { n = 0; select = false; } - GETLB(id)->Focus(n); + GETLB(id)->EnsureVisible(n); GETLB(id)->Select(n, select); } diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index df2f36e343..000db9a24b 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -87,7 +87,7 @@ void wxSTCDropTarget::OnLeave() { #define wxSTCCallTipBase wxPopupWindow #define param2 wxBORDER_NONE // popup's 2nd param is flags #else -#define wxSTCCallTipBase wxWindow +#define wxSTCCallTipBase wxFrame #define param2 -1 // wxWindow's 2nd param is ID #endif @@ -95,8 +95,19 @@ void wxSTCDropTarget::OnLeave() { class wxSTCCallTip : public wxSTCCallTipBase { public: - wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) - : wxSTCCallTipBase(parent, param2), + wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) : +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP + wxSTCCallTipBase(parent, wxBORDER_NONE), +#else + wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, + wxFRAME_NO_TASKBAR + | wxFRAME_FLOAT_ON_PARENT + | wxBORDER_NONE +#ifdef __WXMAC__ + | wxPOPUP_WINDOW +#endif + ), +#endif m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) { } @@ -112,7 +123,8 @@ public: bool AcceptsFocus() const { return false; } - void OnPaint(wxPaintEvent& WXUNUSED(evt)) { + void OnPaint(wxPaintEvent& WXUNUSED(evt)) + { wxBufferedPaintDC dc(this); Surface* surfaceWindow = Surface::Allocate(); surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); @@ -121,22 +133,25 @@ public: delete surfaceWindow; } - void OnFocus(wxFocusEvent& event) { + void OnFocus(wxFocusEvent& event) + { GetParent()->SetFocus(); event.Skip(); } - void OnLeftDown(wxMouseEvent& event) { + void OnLeftDown(wxMouseEvent& event) + { wxPoint pt = event.GetPosition(); Point p(pt.x, pt.y); m_ct->MouseClick(p); m_swx->CallTipClick(); } -#if wxUSE_POPUPWIN && wxSTC_USE_POPUP virtual void DoSetSize(int x, int y, int width, int height, - int sizeFlags = wxSIZE_AUTO) { + int sizeFlags = wxSIZE_AUTO) + { + // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) { m_cx = x; GetParent()->ClientToScreen(&x, NULL); @@ -147,9 +162,27 @@ public: } wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); } -#endif - wxPoint GetMyPosition() { +#if wxUSE_POPUPWIN && wxSTC_USE_POPUP +#else + virtual bool Show( bool show = true ) + { + // Although we're a frame, we always want the parent to be active, so + // raise it whenever we get shown. + bool rv = wxSTCCallTipBase::Show(show); + if (rv && show) + { + wxTopLevelWindow *frame = wxDynamicCast( + wxGetTopLevelParent(GetParent()), wxTopLevelWindow); + if (frame) + frame->Raise(); + } + return rv; + } +#endif + + wxPoint GetMyPosition() + { return wxPoint(m_cx, m_cy); }