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