X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e929d5fd62fe0db58a7a9ffa030e5ff13002d66..0ded6bb695f82a0b98d0862ec6870fc5c6cb8b97:/src/common/helpbase.cpp?ds=inline diff --git a/src/common/helpbase.cpp b/src/common/helpbase.cpp index 1468954b39..e8f7722899 100644 --- a/src/common/helpbase.cpp +++ b/src/common/helpbase.cpp @@ -24,199 +24,10 @@ #include "wx/defs.h" #endif -#include "wx/helpbase.h" -#include "wx/app.h" - -#ifdef __WXMSW__ -#include "wx/msw/private.h" -#endif - #if wxUSE_HELP -IMPLEMENT_CLASS(wxHelpControllerBase, wxObject) - -/* - * Invokes context-sensitive help - */ - -IMPLEMENT_DYNAMIC_CLASS(wxContextHelp, wxObject) - -wxContextHelp::wxContextHelp(wxWindow* win, bool beginHelp) -{ - m_inHelp = FALSE; - - if (beginHelp) - BeginContextHelp(win); -} - -wxContextHelp::~wxContextHelp() -{ - if (m_inHelp) - EndContextHelp(); -} - -bool wxContextHelp::BeginContextHelp(wxWindow* win) -{ - if (!win) - win = wxTheApp->GetTopWindow(); - if (!win) - return FALSE; - - wxCursor cursor(wxCURSOR_QUESTION_ARROW); - wxSetCursor(cursor); - - win->CaptureMouse(); - - EventLoop(cursor, win); - - win->ReleaseMouse(); - - return TRUE; -} - -bool wxContextHelp::EndContextHelp() -{ - m_inHelp = FALSE; - - return TRUE; -} - -bool wxContextHelp::EventLoop(const wxCursor& cursor, wxWindow* win) -{ -#ifdef __WXMSW__ - m_inHelp = TRUE; - while ( m_inHelp ) - { - MSG msg; - if (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (!ProcessHelpMessage((WXMSG*) & msg, cursor, win)) - { - m_inHelp = FALSE; - } - } - else - { - wxTheApp->ProcessIdle(); - } - } - return TRUE; -#else - return FALSE; -#endif -} - -#ifdef __WXMSW__ -bool wxContextHelp::ProcessHelpMessage(WXMSG* wxmsg, const wxCursor& cursor, wxWindow* winInQuestion) -{ - MSG& msg = * (MSG*) wxmsg; - - if (msg.message == WM_KEYDOWN || msg.wParam == VK_ESCAPE) - { - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - return FALSE; - } - - if (msg.message == WM_CAPTURECHANGED) - { - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - return FALSE; - } - - if (msg.message == WM_ACTIVATE) - { - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - return FALSE; - } - - if ((msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST)) -// || (msg.message >= WM_NCMOUSEFIRST && msg.message <= WM_NCMOUSELAST)) - { - wxSetCursor(cursor); - - HWND hWndHit = ::WindowFromPoint(msg.pt); - - wxWindow* win = wxFindWinFromHandle((WXHWND) hWndHit) ; - HWND hWnd = hWndHit; - - // Try to find a window with a wxWindow associated with it - while (!win && (hWnd != 0)) - { - hWnd = ::GetParent(hWnd); - win = wxFindWinFromHandle((WXHWND) hWnd) ; - } - - if (win) - { - // It's a wxWindows window - if (msg.message != WM_LBUTTONDOWN) - { - // Hit one of our owned windows -- eat the message. - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - return TRUE; - } - int iHit = (int)::SendMessage(hWndHit, WM_NCHITTEST, 0, - MAKELONG(msg.pt.x, msg.pt.y)); - if (iHit == HTMENU || iHit == HTSYSMENU) - { - // Eat this message, send the event and return - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - DispatchEvent(win, wxPoint(msg.pt.x, msg.pt.y)); - return FALSE; - } - else if (iHit == HTCLIENT) - { - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - DispatchEvent(win, wxPoint(msg.pt.x, msg.pt.y)); - return FALSE; - } - else - { - PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE); - return FALSE; - } - } - else - { - // Someone else's message - if (PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - return TRUE; - } - } - else - { - // allow all other messages to go through (capture still set) - if (PeekMessage(&msg, NULL, msg.message, msg.message, PM_REMOVE)) - DispatchMessage(&msg); - return TRUE; - - } - return TRUE; -} -#endif - -// Dispatch the help event to the relevant window -bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt) -{ - wxWindow* subjectOfHelp = win; - bool eventProcessed = FALSE; - while (subjectOfHelp && !eventProcessed) - { - wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), pt) ; - helpEvent.SetEventObject(this); - eventProcessed = win->GetEventHandler()->ProcessEvent(helpEvent); - - // Go up the window hierarchy until the event is handled (or not). - // I.e. keep submitting ancestor windows until one is recognised - // by the app code that processes the ids and displays help. - subjectOfHelp = subjectOfHelp->GetParent(); - } - return eventProcessed; -} +#include "wx/helpbase.h" +IMPLEMENT_CLASS(wxHelpControllerBase, wxObject) #endif // wxUSE_HELP