]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/helpwin.cpp
add a simple benchmark for wx and iconv converters benchmarking
[wxWidgets.git] / src / msw / helpwin.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/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
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16 #pragma hdrstop
17#endif
18
19#if wxUSE_HELP
20
21#ifndef WX_PRECOMP
22#endif
23
24#include "wx/filefn.h"
25#include "wx/msw/helpwin.h"
26
27#include <time.h>
28
29#ifdef __WXMSW__
30#include "wx/msw/private.h"
31#endif
32
33#include <string.h>
34
35static HWND GetSuitableHWND(wxWinHelpController* controller)
36{
37 if (controller->GetParentWindow())
38 return (HWND) controller->GetParentWindow()->GetHWND();
39 else if (wxTheApp->GetTopWindow())
40 return (HWND) wxTheApp->GetTopWindow()->GetHWND();
41 else
42 return GetDesktopWindow();
43}
44
45IMPLEMENT_DYNAMIC_CLASS(wxWinHelpController, wxHelpControllerBase)
46
47bool wxWinHelpController::Initialize(const wxString& filename)
48{
49 m_helpFile = filename;
50 return true;
51}
52
53bool wxWinHelpController::LoadFile(const wxString& file)
54{
55 if (!file.empty())
56 m_helpFile = file;
57 return true;
58}
59
60bool wxWinHelpController::DisplayContents(void)
61{
62 if (m_helpFile.empty()) return false;
63
64 wxString str = GetValidFilename(m_helpFile);
65
66 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_FINDER, 0L) != 0);
67}
68
69bool wxWinHelpController::DisplaySection(int section)
70{
71 // Use context number
72 if (m_helpFile.empty()) return false;
73
74 wxString str = GetValidFilename(m_helpFile);
75
76 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXT, (DWORD)section) != 0);
77}
78
79bool wxWinHelpController::DisplayContextPopup(int contextId)
80{
81 if (m_helpFile.empty()) return false;
82
83 wxString str = GetValidFilename(m_helpFile);
84
85 return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXTPOPUP, (DWORD) contextId) != 0);
86}
87
88bool wxWinHelpController::DisplayBlock(long block)
89{
90 DisplaySection(block);
91 return true;
92}
93
94bool wxWinHelpController::KeywordSearch(const wxString& k,
95 wxHelpSearchMode WXUNUSED(mode))
96{
97 if (m_helpFile.empty()) return false;
98
99 wxString str = GetValidFilename(m_helpFile);
100
101 return WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_PARTIALKEY,
102 (ULONG_PTR)k.wx_str()) != 0;
103}
104
105// Can't close the help window explicitly in WinHelp
106bool wxWinHelpController::Quit(void)
107{
108 return WinHelp(GetSuitableHWND(this), 0, HELP_QUIT, 0) != 0;
109}
110
111// Append extension if necessary.
112wxString wxWinHelpController::GetValidFilename(const wxString& file) const
113{
114 wxString path, name, ext;
115 wxSplitPath(file, & path, & name, & ext);
116
117 wxString fullName;
118 if (path.empty())
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;
125}
126
127#endif // wxUSE_HELP