]> git.saurik.com Git - wxWidgets.git/blame - src/msw/helpwin.cpp
[ 1936700 ] wxCAL_SHOW_WEEK_NUMBERS, slightly modified
[wxWidgets.git] / src / msw / helpwin.cpp
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
a71d815b 2// Name: src/msw/helpwin.cpp
2bda0e17
KB
3// Purpose: Help system: WinHelp implementation
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6c9a19aa 8// Copyright: (c) Julian Smart
59af881e 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
2bda0e17
KB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
7520f3da 16 #pragma hdrstop
2bda0e17
KB
17#endif
18
7520f3da
WS
19#if wxUSE_HELP
20
2bda0e17 21#ifndef WX_PRECOMP
2bda0e17
KB
22#endif
23
f6bcfd97 24#include "wx/filefn.h"
2bda0e17
KB
25#include "wx/msw/helpwin.h"
26
2bda0e17
KB
27#include <time.h>
28
2049ba38 29#ifdef __WXMSW__
3096bd2f 30#include "wx/msw/private.h"
2bda0e17
KB
31#endif
32
33#include <string.h>
34
3db52265 35static HWND GetSuitableHWND(wxWinHelpController* controller)
2bda0e17 36{
3db52265
JS
37 if (controller->GetParentWindow())
38 return (HWND) controller->GetParentWindow()->GetHWND();
39 else if (wxTheApp->GetTopWindow())
f6bcfd97
BP
40 return (HWND) wxTheApp->GetTopWindow()->GetHWND();
41 else
42 return GetDesktopWindow();
2bda0e17
KB
43}
44
f6bcfd97 45IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
2bda0e17 46
38009d39 47bool wxWinHelpController::Initialize(const wxString& filename)
2bda0e17 48{
f6bcfd97 49 m_helpFile = filename;
59af881e 50 return true;
2bda0e17
KB
51}
52
53bool wxWinHelpController::LoadFile(const wxString& file)
54{
7520f3da 55 if (!file.empty())
f6bcfd97 56 m_helpFile = file;
59af881e 57 return true;
2bda0e17
KB
58}
59
60bool wxWinHelpController::DisplayContents(void)
61{
7520f3da 62 if (m_helpFile.empty()) return false;
59af881e 63
f6bcfd97 64 wxString str = GetValidFilename(m_helpFile);
59af881e 65
e0a050e3 66 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_FINDER, 0L) != 0);
2bda0e17
KB
67}
68
69bool wxWinHelpController::DisplaySection(int section)
70{
33b64e6f 71 // Use context number
7520f3da 72 if (m_helpFile.empty()) return false;
59af881e 73
f6bcfd97 74 wxString str = GetValidFilename(m_helpFile);
33b64e6f 75
e0a050e3 76 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXT, (DWORD)section) != 0);
5100cabf
JS
77}
78
79bool wxWinHelpController::DisplayContextPopup(int contextId)
80{
7520f3da 81 if (m_helpFile.empty()) return false;
59af881e 82
5100cabf
JS
83 wxString str = GetValidFilename(m_helpFile);
84
e0a050e3 85 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXTPOPUP, (DWORD) contextId) != 0);
2bda0e17
KB
86}
87
88bool wxWinHelpController::DisplayBlock(long block)
89{
f6bcfd97 90 DisplaySection(block);
59af881e 91 return true;
2bda0e17
KB
92}
93
69b5cec2
VS
94bool wxWinHelpController::KeywordSearch(const wxString& k,
95 wxHelpSearchMode WXUNUSED(mode))
2bda0e17 96{
7520f3da 97 if (m_helpFile.empty()) return false;
59af881e 98
f6bcfd97 99 wxString str = GetValidFilename(m_helpFile);
59af881e 100
dca0f651
VZ
101 return WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_PARTIALKEY,
102 (ULONG_PTR)k.wx_str()) != 0;
2bda0e17
KB
103}
104
105// Can't close the help window explicitly in WinHelp
106bool wxWinHelpController::Quit(void)
107{
dca0f651 108 return WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0) != 0;
2bda0e17
KB
109}
110
f6bcfd97
BP
111// Append extension if necessary.
112wxString wxWinHelpController::GetValidFilename(const wxString& file) const
2bda0e17 113{
f6bcfd97
BP
114 wxString path, name, ext;
115 wxSplitPath(file, & path, & name, & ext);
116
117 wxString fullName;
7520f3da 118 if (path.empty())
f6bcfd97
BP
119 fullName = name + wxT(".hlp");
120 else if (path.Last() == wxT('\\'))
121 fullName = path + name + wxT(".hlp");
122 else
123 fullName = path + wxT("\\") + name + wxT(".hlp");
124 return fullName;
2bda0e17
KB
125}
126
47d67540 127#endif // wxUSE_HELP