+#endif
+
+
+#if wxUSE_POPUPWIN && wxSTC_USE_POPUP
+#include <wx/popupwin.h>
+#define wxSTCCallTipBase wxPopupWindow
+#define param2 wxBORDER_NONE // popup's 2nd param is flags
+#else
+#define wxSTCCallTipBase wxWindow
+#define param2 -1 // wxWindow's 2nd param is ID
+#endif
+
+#include <wx/dcbuffer.h>
+
+class wxSTCCallTip : public wxSTCCallTipBase {
+public:
+ wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx)
+ : wxSTCCallTipBase(parent, param2),
+ m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord)
+ {
+ }
+
+ ~wxSTCCallTip() {
+#if wxUSE_POPUPWIN && wxSTC_USE_POPUP && defined(__WXGTK__)
+ wxRect rect = GetRect();
+ rect.x = m_cx;
+ rect.y = m_cy;
+ GetParent()->Refresh(false, &rect);
+#endif
+ }
+
+ bool AcceptsFocus() const { return false; }
+
+ void OnPaint(wxPaintEvent& WXUNUSED(evt)) {
+ wxBufferedPaintDC dc(this);
+ Surface* surfaceWindow = Surface::Allocate();
+ surfaceWindow->Init(&dc, m_ct->wDraw.GetID());
+ m_ct->PaintCT(surfaceWindow);
+ surfaceWindow->Release();
+ delete surfaceWindow;
+ }
+
+ void OnFocus(wxFocusEvent& event) {
+ GetParent()->SetFocus();
+ event.Skip();
+ }
+
+ 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) {
+ if (x != wxDefaultCoord) {
+ m_cx = x;
+ GetParent()->ClientToScreen(&x, NULL);
+ }
+ if (y != wxDefaultCoord) {
+ m_cy = y;
+ GetParent()->ClientToScreen(NULL, &y);
+ }
+ wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags);
+ }
+#endif
+
+ wxPoint GetMyPosition() {
+ return wxPoint(m_cx, m_cy);
+ }
+
+private:
+ CallTip* m_ct;
+ ScintillaWX* m_swx;
+ int m_cx, m_cy;
+ DECLARE_EVENT_TABLE()
+};