From 129caaddf1062e108e2018acc1d2205dc24cfc7e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 11 Sep 2000 12:37:44 +0000 Subject: [PATCH] wxHelpProvider now cleans itself up. wxTipWindow doesn't grab the mouse, but instead deletes itself when it's deactivated or loses the focus. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/tipwin.h | 2 ++ src/common/cshelp.cpp | 36 +++++++++++++++++++++++++++++++++++- src/generic/tipwin.cpp | 24 ++++++++++++++++++++---- src/wxvc.dsp | 4 ++++ src/wxvc_dll.dsp | 4 ++++ 5 files changed, 65 insertions(+), 5 deletions(-) diff --git a/include/wx/tipwin.h b/include/wx/tipwin.h index feaddc11b6..766f45e7db 100644 --- a/include/wx/tipwin.h +++ b/include/wx/tipwin.h @@ -34,6 +34,8 @@ protected: // event handlers void OnPaint(wxPaintEvent& event); void OnMouseClick(wxMouseEvent& event); + void OnActivate(wxActivateEvent& event); + void OnKillFocus(wxFocusEvent& event); // calculate the client rect we need to display the text void Adjust(const wxString& text, wxCoord maxLength); diff --git a/src/common/cshelp.cpp b/src/common/cshelp.cpp index 6c4975896c..7917ac2c6f 100644 --- a/src/common/cshelp.cpp +++ b/src/common/cshelp.cpp @@ -35,7 +35,7 @@ #include "wx/tipwin.h" #include "wx/app.h" - +#include "wx/module.h" #include "wx/cshelp.h" // ---------------------------------------------------------------------------- @@ -312,4 +312,38 @@ bool wxSimpleHelpProvider::ShowHelp(wxWindowBase *window) return FALSE; } +// ---------------------------------------------------------------------------- +// wxHelpProviderModule: module responsible for cleaning up help provider. +// ---------------------------------------------------------------------------- + +class wxHelpProviderModule : public wxModule +{ +public: + bool OnInit(); + void OnExit(); + +private: + DECLARE_DYNAMIC_CLASS(wxHelpProviderModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHelpProviderModule, wxModule) + +bool wxHelpProviderModule::OnInit() +{ + // Probably we don't want to do anything by default, + // since it could pull in extra code + // wxHelpProvider::Set(new wxSimpleHelpProvider); + + return TRUE; +} + +void wxHelpProviderModule::OnExit() +{ + if (wxHelpProvider::Get()) + { + delete wxHelpProvider::Get(); + wxHelpProvider::Set(NULL); + } +} + #endif // wxUSE_HELP diff --git a/src/generic/tipwin.cpp b/src/generic/tipwin.cpp index 6dc9d80ac6..40b227ae68 100644 --- a/src/generic/tipwin.cpp +++ b/src/generic/tipwin.cpp @@ -55,6 +55,8 @@ BEGIN_EVENT_TABLE(wxTipWindow, wxFrame) EVT_LEFT_DOWN(wxTipWindow::OnMouseClick) EVT_RIGHT_DOWN(wxTipWindow::OnMouseClick) EVT_MIDDLE_DOWN(wxTipWindow::OnMouseClick) + EVT_KILL_FOCUS(wxTipWindow::OnKillFocus) + EVT_ACTIVATE(wxTipWindow::OnActivate) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -79,8 +81,7 @@ wxTipWindow::wxTipWindow(wxWindow *parent, Adjust(text, maxLength); - // capture mouse as we want to dismiss the window when it is clicked - CaptureMouse(); + SetFocus(); Show(TRUE); } @@ -158,7 +159,13 @@ void wxTipWindow::OnPaint(wxPaintEvent& event) // first filll the background dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); - dc.SetPen(*wxBLACK_PEN); + + // Under Windows, you apparently get a thin black border whether you like it or not :-( +#ifdef __WXMSW__ + dc.SetPen( * wxTRANSPARENT_PEN ); +#else + dc.SetPen( * wxBLACK_PEND ); +#endif dc.DrawRectangle(rect); // and then draw the text line by line @@ -178,7 +185,16 @@ void wxTipWindow::OnPaint(wxPaintEvent& event) void wxTipWindow::OnMouseClick(wxMouseEvent& event) { - ReleaseMouse(); + Close(); +} + +void wxTipWindow::OnActivate(wxActivateEvent& event) +{ + if (!event.GetActive()) + Close(); +} +void wxTipWindow::OnKillFocus(wxFocusEvent& event) +{ Close(); } diff --git a/src/wxvc.dsp b/src/wxvc.dsp index 9dfb5f6c98..4163c5b268 100644 --- a/src/wxvc.dsp +++ b/src/wxvc.dsp @@ -632,6 +632,10 @@ SOURCE=.\generic\tipdlg.cpp # End Source File # Begin Source File +SOURCE=.\generic\tipwin.cpp +# End Source File +# Begin Source File + SOURCE=.\generic\treectlg.cpp # End Source File # Begin Source File diff --git a/src/wxvc_dll.dsp b/src/wxvc_dll.dsp index 96387f564d..1bf6a263c0 100644 --- a/src/wxvc_dll.dsp +++ b/src/wxvc_dll.dsp @@ -630,6 +630,10 @@ SOURCE=.\generic\tipdlg.cpp # End Source File # Begin Source File +SOURCE=.\generic\tipwin.cpp +# End Source File +# Begin Source File + SOURCE=.\generic\treectlg.cpp # End Source File # Begin Source File -- 2.45.2