]>
git.saurik.com Git - wxWidgets.git/blob - utils/helpview/src/helpview.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: HelpView application
4 // A standalone viewer for wxHTML Help (.htb) files
5 // Author: Vaclav Slavik, Julian Smart
9 // Copyright: (c) 2002 Vaclav Slavik, Julian Smart and others
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation "help.cpp"
17 // For compilers that support precompilation, includes "wx/wx.h".
18 #include "wx/wxprec.h"
24 // for all others, include the necessary headers (this file is usually all you
25 // need because it includes almost all "standard" wxWindows headers
31 #include "wx/wxhtml.h"
32 #include "wx/fs_zip.h"
34 #include "wx/artprov.h"
35 #include "wx/filedlg.h"
39 class AlternateArtProvider
: public wxArtProvider
42 virtual wxBitmap
CreateBitmap(const wxArtID
& id
, const wxArtClient
& client
,
46 // ----------------------------------------------------------------------------
48 // ----------------------------------------------------------------------------
57 delete wxLog::SetActiveTarget(new wxLogStderr
); // So dialog boxes aren't used
60 wxArtProvider::PushProvider(new AlternateArtProvider
);
62 wxInitAllImageHandlers();
63 wxFileSystem::AddHandler(new wxZipFSHandler
);
65 SetVendorName("wxWindows");
66 SetAppName("wxHTMLHelp");
67 wxConfig::Get(); // create an instance
69 help
= new wxHtmlHelpController(
70 wxHF_DEFAULT_STYLE
|wxHF_FLAT_TOOLBAR
|wxHF_OPEN_FILES
73 help
->SetTitleFormat(wxT("%s"));
79 for (int i
= 1; i
< argc
; i
++)
80 help
-> AddBook(argv
[i
]);
83 delete wxLog::SetActiveTarget(new wxLogGui
);
86 help
-> DisplayContents();
95 delete wxConfig::Set(NULL
);
100 bool hvApp::OpenBook(wxHtmlHelpController
* controller
)
102 wxString s
= wxFileSelector(_("Open help file"),
107 "Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\
108 HTML Help Project (*.hhp)|*.hhp"),
109 wxOPEN
| wxFILE_MUST_EXIST
,
114 wxString ext
= s
.Right(4).Lower();
115 if (ext
== _T(".zip") || ext
== _T(".htb") || ext
== _T(".hhp"))
118 controller
->AddBook(s
);
129 // ---------------------------------------------------------------------
131 // ---------------------------------------------------------------------
133 // Standard macro for getting a resource from XPM file:
134 #define ART(artId, xpmRc) \
135 if ( id == artId ) return wxBitmap(xpmRc##_xpm);
137 // Compatibility hack to use wxApp::GetStdIcon of overriden by the user
138 #if WXWIN_COMPATIBILITY_2_2
139 #define GET_STD_ICON_FROM_APP(iconId) \
140 if ( client == wxART_MESSAGE_BOX ) \
142 wxIcon icon = wxTheApp->GetStdIcon(iconId); \
146 bmp.CopyFromIcon(icon); \
151 #define GET_STD_ICON_FROM_APP(iconId)
154 // There are two ways of getting the standard icon: either via XPMs or via
155 // wxIcon ctor. This depends on the platform:
156 #if defined(__WXUNIVERSAL__)
157 #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap;
158 #elif defined(__WXGTK__) || defined(__WXMOTIF__)
159 #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm);
161 #define CREATE_STD_ICON(iconId, xpmRc) \
163 wxIcon icon(_T(iconId)); \
165 bmp.CopyFromIcon(icon); \
170 // Macro used in CreateBitmap to get wxICON_FOO icons:
171 #define ART_MSGBOX(artId, iconId, xpmRc) \
174 GET_STD_ICON_FROM_APP(iconId) \
175 CREATE_STD_ICON(#iconId, xpmRc) \
178 // ---------------------------------------------------------------------
180 // ---------------------------------------------------------------------
182 // XPM hack: make the arrays const
183 //#define static static const
185 #include "bitmaps/helpback.xpm"
186 #include "bitmaps/helpbook.xpm"
187 #include "bitmaps/helpdown.xpm"
188 #include "bitmaps/helpforward.xpm"
189 #include "bitmaps/helpoptions.xpm"
190 #include "bitmaps/helppage.xpm"
191 #include "bitmaps/helpsidepanel.xpm"
192 #include "bitmaps/helpup.xpm"
193 #include "bitmaps/helpuplevel.xpm"
194 #include "bitmaps/helpicon.xpm"
195 #include "bitmaps/helpopen.xpm"
199 // ---------------------------------------------------------------------
200 // CreateBitmap routine
201 // ---------------------------------------------------------------------
203 wxBitmap
AlternateArtProvider::CreateBitmap(const wxArtID
& id
,
204 const wxArtClient
& client
,
205 const wxSize
& WXUNUSED(size
))
207 ART(wxART_HELP_SIDE_PANEL
, helpsidepanel
)
208 ART(wxART_HELP_SETTINGS
, helpoptions
)
209 ART(wxART_HELP_BOOK
, helpbook
)
210 ART(wxART_HELP_FOLDER
, helpbook
)
211 ART(wxART_HELP_PAGE
, helppage
)
212 //ART(wxART_ADD_BOOKMARK, addbookm)
213 //ART(wxART_DEL_BOOKMARK, delbookm)
214 ART(wxART_GO_BACK
, helpback
)
215 ART(wxART_GO_FORWARD
, helpforward
)
216 ART(wxART_GO_UP
, helpup
)
217 ART(wxART_GO_DOWN
, helpdown
)
218 ART(wxART_GO_TO_PARENT
, helpuplevel
)
219 ART(wxART_FILE_OPEN
, helpopen
)
220 if (client
== wxART_HELP_BROWSER
)
222 ART(wxART_FRAME_ICON
, helpicon
)
225 //ART(wxART_GO_HOME, home)
227 // Any wxWindows icons not implemented here
228 // will be provided by the default art provider.