]> git.saurik.com Git - wxWidgets.git/blob - src/msw/helpwin.cpp
don't generate wxEVT_CONTEXT_MENU messages for right clicks in the list control header
[wxWidgets.git] / src / msw / helpwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/helpwin.cpp
3 // Purpose: Help system: WinHelp implementation
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifdef __BORLANDC__
16 #pragma hdrstop
17 #endif
18
19 #ifndef WX_PRECOMP
20 #include "wx/defs.h"
21 #endif
22
23 #if wxUSE_HELP
24
25 #include "wx/filefn.h"
26 #include "wx/msw/helpwin.h"
27
28 #include <time.h>
29
30 #ifdef __WXMSW__
31 #include "wx/msw/private.h"
32 #endif
33
34 #include <string.h>
35
36 static HWND GetSuitableHWND(wxWinHelpController* controller)
37 {
38 if (controller->GetParentWindow())
39 return (HWND) controller->GetParentWindow()->GetHWND();
40 else if (wxTheApp->GetTopWindow())
41 return (HWND) wxTheApp->GetTopWindow()->GetHWND();
42 else
43 return GetDesktopWindow();
44 }
45
46 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
47
48 bool wxWinHelpController::Initialize(const wxString& filename)
49 {
50 m_helpFile = filename;
51 return true;
52 }
53
54 bool wxWinHelpController::LoadFile(const wxString& file)
55 {
56 if (!file.IsEmpty())
57 m_helpFile = file;
58 return true;
59 }
60
61 bool wxWinHelpController::DisplayContents(void)
62 {
63 if (m_helpFile.IsEmpty()) return false;
64
65 wxString str = GetValidFilename(m_helpFile);
66
67 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_FINDER, 0L) != 0);
68 }
69
70 bool wxWinHelpController::DisplaySection(int section)
71 {
72 // Use context number
73 if (m_helpFile.IsEmpty()) return false;
74
75 wxString str = GetValidFilename(m_helpFile);
76
77 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXT, (DWORD)section) != 0);
78 }
79
80 bool wxWinHelpController::DisplayContextPopup(int contextId)
81 {
82 if (m_helpFile.IsEmpty()) return false;
83
84 wxString str = GetValidFilename(m_helpFile);
85
86 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXTPOPUP, (DWORD) contextId) != 0);
87 }
88
89 bool wxWinHelpController::DisplayBlock(long block)
90 {
91 DisplaySection(block);
92 return true;
93 }
94
95 bool wxWinHelpController::KeywordSearch(const wxString& k,
96 wxHelpSearchMode WXUNUSED(mode))
97 {
98 if (m_helpFile.IsEmpty()) return false;
99
100 wxString str = GetValidFilename(m_helpFile);
101
102 return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0);
103 }
104
105 // Can't close the help window explicitly in WinHelp
106 bool wxWinHelpController::Quit(void)
107 {
108 return (WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0L) != 0);
109 }
110
111 // Append extension if necessary.
112 wxString wxWinHelpController::GetValidFilename(const wxString& file) const
113 {
114 wxString path, name, ext;
115 wxSplitPath(file, & path, & name, & ext);
116
117 wxString fullName;
118 if (path.IsEmpty())
119 fullName = name + wxT(".hlp");
120 else if (path.Last() == wxT('\\'))
121 fullName = path + name + wxT(".hlp");
122 else
123 fullName = path + wxT("\\") + name + wxT(".hlp");
124 return fullName;
125 }
126
127 #endif // wxUSE_HELP