]> git.saurik.com Git - wxWidgets.git/blob - src/msw/helpwin.cpp
all delete functions now send delete notification event
[wxWidgets.git] / src / msw / helpwin.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "helpwin.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #include "wx/msw/helpwin.h"
28
29 #if wxUSE_HELP
30 #include <time.h>
31
32 #ifdef __WXMSW__
33 #include <wx/msw/private.h>
34 #endif
35
36 #include <string.h>
37
38 // MAX path length
39 #define _MAXPATHLEN 500
40
41 // MAX length of Help descriptor
42 #define _MAX_HELP_LEN 500
43
44 #if !USE_SHARED_LIBRARY
45 IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
46 #endif
47
48 wxWinHelpController::wxWinHelpController(void)
49 {
50 m_helpFile = "";
51 }
52
53 wxWinHelpController::~wxWinHelpController(void)
54 {
55 }
56
57 bool wxWinHelpController::Initialize(const wxString& filename)
58 {
59 m_helpFile = filename;
60 return TRUE;
61 }
62
63 bool wxWinHelpController::LoadFile(const wxString& file)
64 {
65 m_helpFile = file;
66 return TRUE;
67 }
68
69 bool wxWinHelpController::DisplayContents(void)
70 {
71 if (m_helpFile == "") return FALSE;
72
73 char buf[_MAXPATHLEN];
74 strcpy(buf, (const char*) m_helpFile);
75 size_t len = strlen(buf);
76 if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
77 strcat(buf, ".hlp");
78 if (wxTheApp->GetTopWindow())
79 {
80 #if defined(__WIN95__)
81 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_FINDER, 0L);
82 #else
83 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_CONTENTS, 0L);
84 #endif
85 return TRUE;
86 }
87 return FALSE;
88 }
89
90 bool wxWinHelpController::DisplaySection(int section)
91 {
92 // No WinHelp equivalent for this
93 return FALSE;
94 }
95
96 bool wxWinHelpController::DisplayBlock(long block)
97 {
98 // Use context number -- a very rough equivalent to block id!
99 if (!m_helpFile) return FALSE;
100
101 char buf[_MAXPATHLEN];
102 strcpy(buf, m_helpFile);
103 size_t len = strlen(buf);
104 if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
105 strcat(buf, ".hlp");
106 if (wxTheApp->GetTopWindow())
107 {
108 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_CONTEXT, (DWORD)block);
109 return TRUE;
110 }
111 return FALSE;
112 }
113
114 bool wxWinHelpController::KeywordSearch(const wxString& k)
115 {
116 if (m_helpFile == "") return FALSE;
117
118 char buf[_MAXPATHLEN];
119 strcpy(buf, m_helpFile);
120 size_t len = strlen(buf);
121 if (!(buf[len-1] == 'p' && buf[len-2] == 'l' && buf[len-3] == 'h' && buf[len-4] == '.'))
122 strcat(buf, ".hlp");
123 if (wxTheApp->GetTopWindow())
124 {
125 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), buf, HELP_PARTIALKEY, (DWORD)(const char*) k);
126 return TRUE;
127 }
128 return FALSE;
129 }
130
131 // Can't close the help window explicitly in WinHelp
132 bool wxWinHelpController::Quit(void)
133 {
134 if (wxTheApp->GetTopWindow())
135 {
136 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), 0, HELP_QUIT, 0L);
137 return TRUE;
138 }
139 else
140 return FALSE;
141 }
142
143 // Don't get notified of WinHelp quitting
144 void wxWinHelpController::OnQuit(void)
145 {
146 }
147
148 #endif // wxUSE_HELP