]> git.saurik.com Git - wxWidgets.git/blame - src/msw/helpwin.cpp
OnEnter/OnDragOver API update (compiles, links, somewhat runs under wxGTK)
[wxWidgets.git] / src / msw / helpwin.cpp
CommitLineData
2bda0e17
KB
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
47d67540 29#if wxUSE_HELP
2bda0e17
KB
30#include <time.h>
31
2049ba38 32#ifdef __WXMSW__
2bda0e17
KB
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
45IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
46#endif
47
48wxWinHelpController::wxWinHelpController(void)
49{
50 m_helpFile = "";
51}
52
53wxWinHelpController::~wxWinHelpController(void)
54{
55}
56
38009d39 57bool wxWinHelpController::Initialize(const wxString& filename)
2bda0e17
KB
58{
59 m_helpFile = filename;
60 return TRUE;
61}
62
63bool wxWinHelpController::LoadFile(const wxString& file)
64{
65 m_helpFile = file;
66 return TRUE;
67}
68
69bool wxWinHelpController::DisplayContents(void)
70{
223d09f6 71 if (m_helpFile == wxT("")) return FALSE;
2bda0e17 72
33b64e6f
JS
73 wxString str = m_helpFile;
74 size_t len = str.Length();
223d09f6
KB
75 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('.')))
76 str += wxT(".hlp");
33b64e6f 77
2bda0e17
KB
78 if (wxTheApp->GetTopWindow())
79 {
80#if defined(__WIN95__)
837e5743 81 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_FINDER, 0L);
2bda0e17 82#else
837e5743 83 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTENTS, 0L);
2bda0e17
KB
84#endif
85 return TRUE;
86 }
87 return FALSE;
88}
89
90bool wxWinHelpController::DisplaySection(int section)
91{
33b64e6f 92 // Use context number
223d09f6 93 if (m_helpFile == wxT("")) return FALSE;
33b64e6f
JS
94
95 wxString str = m_helpFile;
96 size_t len = str.Length();
223d09f6
KB
97 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('.')))
98 str += wxT(".hlp");
33b64e6f
JS
99
100 if (wxTheApp->GetTopWindow())
101 {
837e5743 102 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXT, (DWORD)section);
33b64e6f
JS
103 return TRUE;
104 }
105 return FALSE;
2bda0e17
KB
106}
107
108bool wxWinHelpController::DisplayBlock(long block)
109{
110 // Use context number -- a very rough equivalent to block id!
223d09f6 111 if (m_helpFile == wxT("")) return FALSE;
2bda0e17 112
33b64e6f
JS
113 wxString str = m_helpFile;
114 size_t len = str.Length();
115 if (!(str[(size_t)(len-1)] == 'p' && str[(size_t)(len-2)] == 'l' && str[(size_t)(len-3)] == 'h' && str[(size_t)(len-4)] == '.'))
223d09f6 116 str += wxT(".hlp");
33b64e6f 117
2bda0e17
KB
118 if (wxTheApp->GetTopWindow())
119 {
837e5743 120 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_CONTEXT, (DWORD)block);
2bda0e17
KB
121 return TRUE;
122 }
123 return FALSE;
124}
125
126bool wxWinHelpController::KeywordSearch(const wxString& k)
127{
223d09f6 128 if (m_helpFile == wxT("")) return FALSE;
2bda0e17 129
33b64e6f
JS
130 wxString str = m_helpFile;
131 size_t len = str.Length();
223d09f6
KB
132 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('.')))
133 str += wxT(".hlp");
33b64e6f 134
2bda0e17
KB
135 if (wxTheApp->GetTopWindow())
136 {
837e5743 137 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k);
2bda0e17
KB
138 return TRUE;
139 }
140 return FALSE;
141}
142
143// Can't close the help window explicitly in WinHelp
144bool wxWinHelpController::Quit(void)
145{
e5fb7191
JS
146 if (wxTheApp->GetTopWindow())
147 {
148 WinHelp((HWND) wxTheApp->GetTopWindow()->GetHWND(), 0, HELP_QUIT, 0L);
149 return TRUE;
150 }
151 else
152 return FALSE;
2bda0e17
KB
153}
154
155// Don't get notified of WinHelp quitting
156void wxWinHelpController::OnQuit(void)
157{
158}
159
47d67540 160#endif // wxUSE_HELP