applied Otto Wyss' patch to extend wxHelpController::KeywordSearch with mode argument...
[wxWidgets.git] / src / os2 / helpwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: helpwin.cpp
3 // Purpose: Help system: native implementation
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/09/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef WX_PRECOMP
13 #include "wx/defs.h"
14 #endif
15
16 #include "wx/os2/helpwin.h"
17
18 #if wxUSE_HELP
19 #include <time.h>
20
21 #include <wx/os2/private.h>
22
23 #include <string.h>
24
25 // MAX path length
26 #define _MAXPATHLEN 500
27
28 // MAX length of Help descriptor
29 #define _MAX_HELP_LEN 500
30
31 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
32
33 wxWinHelpController::wxWinHelpController()
34 {
35 m_helpFile = "";
36 }
37
38 wxWinHelpController::~wxWinHelpController()
39 {
40 }
41
42 bool wxWinHelpController::Initialize(const wxString& filename)
43 {
44 m_helpFile = filename;
45 // TODO any other inits
46 return TRUE;
47 }
48
49 bool wxWinHelpController::LoadFile(const wxString& file)
50 {
51 m_helpFile = file;
52 // TODO
53 return TRUE;
54 }
55
56 bool wxWinHelpController::DisplayContents()
57 {
58 if (m_helpFile == wxT("")) return FALSE;
59
60 wxString str = m_helpFile;
61 size_t len = str.Length();
62 if (!(str[(size_t)(len-1)] == wxT('p') && str[(size_t)(len-2)] == wxT('l') && str[(size_t)(len-3)] == wxT('h') && str[(size_t)(len-4)] == wxT('.')))
63 str += wxT(".hlp");
64
65 if (wxTheApp->GetTopWindow())
66 {
67 // TODO : display the help
68 return TRUE;
69 }
70 return FALSE;
71 }
72
73 bool wxWinHelpController::DisplaySection(int section)
74 {
75 // Use context number
76 if (m_helpFile == wxT("")) return FALSE;
77
78 wxString str = m_helpFile;
79 size_t len = str.Length();
80 if (!(str[(size_t)(len-1)] == wxT('p') && str[(size_t)(len-2)] == wxT('l') && str[(size_t)(len-3)] == wxT('h') && str[(size_t)(len-4)] == wxT('.')))
81 str += wxT(".hlp");
82
83 if (wxTheApp->GetTopWindow())
84 {
85 // TODO ::
86 // WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXT, (DWORD)section);
87 return TRUE;
88 }
89 return FALSE;
90 }
91
92 bool wxWinHelpController::DisplayBlock(long block)
93 {
94 // Use context number -- a very rough equivalent to block id!
95 if (m_helpFile == wxT("")) return FALSE;
96
97 wxString str = m_helpFile;
98 size_t len = str.Length();
99 if (!(str[(size_t)(len-1)] == 'p' && str[(size_t)(len-2)] == 'l' && str[(size_t)(len-3)] == 'h' && str[(size_t)(len-4)] == '.'))
100 str += wxT(".hlp");
101
102 if (wxTheApp->GetTopWindow())
103 {
104 // TODO:
105 // WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXT, (DWORD)block);
106 return TRUE;
107 }
108 return FALSE;
109 }
110
111 bool wxWinHelpController::KeywordSearch(const wxString& k,
112 wxHelpSearchMode WXUNUSED(mode))
113 {
114 if (m_helpFile == "") return FALSE;
115
116 wxString str = m_helpFile;
117 size_t len = str.Length();
118 if (!(str[(size_t)(len-1)] == wxT('p') && str[(size_t)(len-2)] == wxT('l') && str[(size_t)(len-3)] == wxT('h') && str[(size_t)(len-4)] == wxT('.')))
119 str += wxT(".hlp");
120
121 if (wxTheApp->GetTopWindow())
122 {
123 // TODO:
124 // WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k);
125 return TRUE;
126 }
127 return FALSE;
128 }
129
130 // Can't close the help window explicitly in WinHelp
131 bool wxWinHelpController::Quit()
132 {
133 if (wxTheApp->GetTopWindow())
134 {
135 // TODO:
136 // WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), 0, HELP_QUIT, 0L);
137 return TRUE;
138 }
139 else
140 return FALSE;
141 }
142
143 void wxWinHelpController::OnQuit()
144 {
145 }
146 #endif // wxUSE_HELP
147