]> git.saurik.com Git - wxWidgets.git/commitdiff
wxHelpProvider now cleans itself up. wxTipWindow doesn't
authorJulian Smart <julian@anthemion.co.uk>
Mon, 11 Sep 2000 12:37:44 +0000 (12:37 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 11 Sep 2000 12:37:44 +0000 (12:37 +0000)
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
src/common/cshelp.cpp
src/generic/tipwin.cpp
src/wxvc.dsp
src/wxvc_dll.dsp

index feaddc11b6a47125804ee95305e30d6dd612cedb..766f45e7dbdeab420cfd9a35c5fe9a78d2a25553 100644 (file)
@@ -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);
index 6c4975896c30654dc7aa76b265b57f65fb59c604..7917ac2c6fc0e7a187a350f61a7c23243c253985 100644 (file)
@@ -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
index 6dc9d80ac610c406ff4179dc1f9fd25b482e0af0..40b227ae68fde7396d4d18c2989d69a723a60bc9 100644 (file)
@@ -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();
 }
index 9dfb5f6c98a2a8ee88392c6581cec8bb6ddd8dc6..4163c5b268e579f27ff2959775560415b0b46ddf 100644 (file)
@@ -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
index 96387f564d339a50dce0beee3488d2bc122fb0c9..1bf6a263c0267340ed912357616e81b3eb47dbf2 100644 (file)
@@ -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