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
This commit is contained in:
@@ -34,6 +34,8 @@ protected:
|
|||||||
// event handlers
|
// event handlers
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
void OnMouseClick(wxMouseEvent& event);
|
void OnMouseClick(wxMouseEvent& event);
|
||||||
|
void OnActivate(wxActivateEvent& event);
|
||||||
|
void OnKillFocus(wxFocusEvent& event);
|
||||||
|
|
||||||
// calculate the client rect we need to display the text
|
// calculate the client rect we need to display the text
|
||||||
void Adjust(const wxString& text, wxCoord maxLength);
|
void Adjust(const wxString& text, wxCoord maxLength);
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#include "wx/tipwin.h"
|
#include "wx/tipwin.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
|
#include "wx/module.h"
|
||||||
#include "wx/cshelp.h"
|
#include "wx/cshelp.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -312,4 +312,38 @@ bool wxSimpleHelpProvider::ShowHelp(wxWindowBase *window)
|
|||||||
return FALSE;
|
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
|
#endif // wxUSE_HELP
|
||||||
|
@@ -55,6 +55,8 @@ BEGIN_EVENT_TABLE(wxTipWindow, wxFrame)
|
|||||||
EVT_LEFT_DOWN(wxTipWindow::OnMouseClick)
|
EVT_LEFT_DOWN(wxTipWindow::OnMouseClick)
|
||||||
EVT_RIGHT_DOWN(wxTipWindow::OnMouseClick)
|
EVT_RIGHT_DOWN(wxTipWindow::OnMouseClick)
|
||||||
EVT_MIDDLE_DOWN(wxTipWindow::OnMouseClick)
|
EVT_MIDDLE_DOWN(wxTipWindow::OnMouseClick)
|
||||||
|
EVT_KILL_FOCUS(wxTipWindow::OnKillFocus)
|
||||||
|
EVT_ACTIVATE(wxTipWindow::OnActivate)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -79,8 +81,7 @@ wxTipWindow::wxTipWindow(wxWindow *parent,
|
|||||||
|
|
||||||
Adjust(text, maxLength);
|
Adjust(text, maxLength);
|
||||||
|
|
||||||
// capture mouse as we want to dismiss the window when it is clicked
|
SetFocus();
|
||||||
CaptureMouse();
|
|
||||||
|
|
||||||
Show(TRUE);
|
Show(TRUE);
|
||||||
}
|
}
|
||||||
@@ -158,7 +159,13 @@ void wxTipWindow::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
// first filll the background
|
// first filll the background
|
||||||
dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID));
|
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);
|
dc.DrawRectangle(rect);
|
||||||
|
|
||||||
// and then draw the text line by line
|
// and then draw the text line by line
|
||||||
@@ -178,7 +185,16 @@ void wxTipWindow::OnPaint(wxPaintEvent& event)
|
|||||||
|
|
||||||
void wxTipWindow::OnMouseClick(wxMouseEvent& event)
|
void wxTipWindow::OnMouseClick(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
ReleaseMouse();
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTipWindow::OnActivate(wxActivateEvent& event)
|
||||||
|
{
|
||||||
|
if (!event.GetActive())
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTipWindow::OnKillFocus(wxFocusEvent& event)
|
||||||
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@@ -632,6 +632,10 @@ SOURCE=.\generic\tipdlg.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\generic\tipwin.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\generic\treectlg.cpp
|
SOURCE=.\generic\treectlg.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -630,6 +630,10 @@ SOURCE=.\generic\tipdlg.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\generic\tipwin.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\generic\treectlg.cpp
|
SOURCE=.\generic\treectlg.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
Reference in New Issue
Block a user