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