From 7414c52cd0f25ebd2ac4951966b5d0bb8bbbfca0 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 7 Jul 2002 21:48:30 +0000 Subject: [PATCH] Added USE_ALTERNATE_UI symbol to helpview.cpp. Set to 1 to: - provide different icons. - add an open file icon for the toolbar. - use a flat toolbar style. - show a file selector if no file was given on the command line. - remove 'Help:' from the title bar. Set to 0 to revert to previous behaviour. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/html/helpview/bitmaps/helpback.xpm | 21 ++ samples/html/helpview/bitmaps/helpbook.xpm | 25 +++ samples/html/helpview/bitmaps/helpdown.xpm | 21 ++ samples/html/helpview/bitmaps/helpforward.xpm | 21 ++ samples/html/helpview/bitmaps/helpicon.xpm | 41 ++++ samples/html/helpview/bitmaps/helpopen.xpm | 22 +++ samples/html/helpview/bitmaps/helpoptions.xpm | 21 ++ samples/html/helpview/bitmaps/helppage.xpm | 23 +++ .../html/helpview/bitmaps/helpsidepanel.xpm | 35 ++++ samples/html/helpview/bitmaps/helpup.xpm | 21 ++ samples/html/helpview/bitmaps/helpuplevel.xpm | 21 ++ samples/html/helpview/helpview.cpp | 179 +++++++++++++++++- samples/html/helpview/helpview.ico | Bin 0 -> 1078 bytes samples/html/helpview/helpview.rc | 3 +- 14 files changed, 452 insertions(+), 2 deletions(-) create mode 100644 samples/html/helpview/bitmaps/helpback.xpm create mode 100644 samples/html/helpview/bitmaps/helpbook.xpm create mode 100644 samples/html/helpview/bitmaps/helpdown.xpm create mode 100644 samples/html/helpview/bitmaps/helpforward.xpm create mode 100644 samples/html/helpview/bitmaps/helpicon.xpm create mode 100644 samples/html/helpview/bitmaps/helpopen.xpm create mode 100644 samples/html/helpview/bitmaps/helpoptions.xpm create mode 100644 samples/html/helpview/bitmaps/helppage.xpm create mode 100644 samples/html/helpview/bitmaps/helpsidepanel.xpm create mode 100644 samples/html/helpview/bitmaps/helpup.xpm create mode 100644 samples/html/helpview/bitmaps/helpuplevel.xpm create mode 100644 samples/html/helpview/helpview.ico diff --git a/samples/html/helpview/bitmaps/helpback.xpm b/samples/html/helpview/bitmaps/helpback.xpm new file mode 100644 index 0000000000..c7b09913eb --- /dev/null +++ b/samples/html/helpview/bitmaps/helpback.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpback_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +" ", +" ", +" . ", +" .. ", +" .X. ", +" .XX........ ", +" .XXXXXXXXXX. ", +" .XXXXXXXXXXX. ", +" .XXXXXXXXXXX. ", +" .XXXXXXXXXX. ", +" .XX........ ", +" .X. ", +" .. ", +" . ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpbook.xpm b/samples/html/helpview/bitmaps/helpbook.xpm new file mode 100644 index 0000000000..4f56093e1f --- /dev/null +++ b/samples/html/helpview/bitmaps/helpbook.xpm @@ -0,0 +1,25 @@ +/* XPM */ +static char * helpbook_xpm[] = { +"16 16 6 1", +" c None", +". c Black", +"X c #000080", +"o c #c0c0c0", +"O c #808080", +"+ c Gray100", +" ", +" .. ", +" ..XX. ", +" ..XXXXX. ", +" ..XXXXXXXX. ", +".oXXXXXXXXXX. ", +".XoXXXXXXXXXX. ", +".XXoXXXXXXXXXX. ", +".XXXoXXXXXXXXX..", +".XXXXoXXXXXX..O ", +" .XXXXoXXX..O+O ", +" .XXXXo..O++o..", +" .XXX.O+++o.. ", +" .XX.o+o.. ", +" .X.o.. ", +" ... "}; diff --git a/samples/html/helpview/bitmaps/helpdown.xpm b/samples/html/helpview/bitmaps/helpdown.xpm new file mode 100644 index 0000000000..30da826980 --- /dev/null +++ b/samples/html/helpview/bitmaps/helpdown.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpdown_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +" ", +" ...... ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" ....XXXX.... ", +" .XXXXXXXX. ", +" .XXXXXX. ", +" .XXXX. ", +" .XX. ", +" .. ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpforward.xpm b/samples/html/helpview/bitmaps/helpforward.xpm new file mode 100644 index 0000000000..3d0b8e5858 --- /dev/null +++ b/samples/html/helpview/bitmaps/helpforward.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpforward_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +" ", +" ", +" . ", +" .. ", +" .X. ", +" ........XX. ", +" .XXXXXXXXXX. ", +" .XXXXXXXXXXX. ", +" .XXXXXXXXXXX. ", +" .XXXXXXXXXX. ", +" ........XX. ", +" .X. ", +" .. ", +" . ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpicon.xpm b/samples/html/helpview/bitmaps/helpicon.xpm new file mode 100644 index 0000000000..b6f57a1a06 --- /dev/null +++ b/samples/html/helpview/bitmaps/helpicon.xpm @@ -0,0 +1,41 @@ +/* XPM */ +static char * helpicon_xpm[] = { +"32 32 6 1", +" c None", +". c #808080", +"X c Black", +"o c #c0c0c0", +"O c Gray100", +"+ c #000080", +" ", +" ", +" ", +" ", +" ", +" ", +" .......X ", +" ...ooooooo.X ", +" o.....XoooOoOOOOoX ", +" .oOoOoO.ooOoOoOOOO.X ", +" o.o.oOoOoOoO.ooOoOoOOOOX ", +" +oOoOoOoOOOOXoooOoOOOOOoX ", +" +oOoOoOoOOOO.oooOoOOOOOX ", +" +OoOoOoOOOOOXooOoOoOOOOoX ", +" o+OoOoOoOOOOO.ooOoOoOOOO.X ", +" o+oOoOoOoOOOOXoooOoOOOOOOX ", +" o+oOoOoOoOOOO.oooOooOOOooX ", +" o+OoOoOoOOOOOXooOo...oooX+ ", +" o+OoOoOoOOoooXooXXXXXXX++ ", +" o+OoOoOo.o.oXXX++++++++. ", +" o+oOoOo.oXXX+++...... ", +" o+oOoXXX+++.+ ", +" o+OXX+++... ", +" o+++... ", +" o+.. ", +" o. ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpopen.xpm b/samples/html/helpview/bitmaps/helpopen.xpm new file mode 100644 index 0000000000..13e355027d --- /dev/null +++ b/samples/html/helpview/bitmaps/helpopen.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * helpopen_xpm[] = { +"16 15 4 1", +" c None", +". c Black", +"X c Gray100", +"o c #848484", +" ", +" ", +" ", +" ... ", +" .XXX....... ", +" .XXXXXXXXX. ", +" .XXXXXXXXX. ", +" .XXXX..........", +" .XXX.ooooooooo.", +" .XX.ooooooooo. ", +" .X.ooooooooo. ", +" ..ooooooooo. ", +" ........... ", +" ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpoptions.xpm b/samples/html/helpview/bitmaps/helpoptions.xpm new file mode 100644 index 0000000000..df7f054d3e --- /dev/null +++ b/samples/html/helpview/bitmaps/helpoptions.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpoptions_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" .. ", +" ... ", +" .... ", +" . ... ", +" .. ... ", +" . .. ", +" .. ... ", +" . .. ", +" ......... ", +" .. ... ", +" . ... ", +" .. ... ", +" .... ....... ", +" ", +" "}; diff --git a/samples/html/helpview/bitmaps/helppage.xpm b/samples/html/helpview/bitmaps/helppage.xpm new file mode 100644 index 0000000000..3524b0176f --- /dev/null +++ b/samples/html/helpview/bitmaps/helppage.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static char * helppage_xpm[] = { +"16 16 4 1", +" c None", +". c #808080", +"X c Gray100", +"o c Black", +" ", +" .......... ", +" .XXXXXXXX.. ", +" .XXXXXXXXooo ", +" .X......XXXo ", +" .XXXXXXXXXXo ", +" .X........Xo ", +" .XXXXXXXXXXo ", +" .X........Xo ", +" .XXXXXXXXXXo ", +" .X........Xo ", +" .XXXXXXXXXXo ", +" .X........Xo ", +" .XXXXXXXXXXo ", +" .XXXXXXXXXXo ", +" oooooooooooo "}; diff --git a/samples/html/helpview/bitmaps/helpsidepanel.xpm b/samples/html/helpview/bitmaps/helpsidepanel.xpm new file mode 100644 index 0000000000..ffac7c4228 --- /dev/null +++ b/samples/html/helpview/bitmaps/helpsidepanel.xpm @@ -0,0 +1,35 @@ +/* XPM */ +static char * helpsidepanel_xpm[] = { +"16 15 17 1", +" c None", +". c #000000", +"+ c #800000", +"@ c #008000", +"# c #808000", +"$ c #000080", +"% c #800080", +"& c #008080", +"* c #C0C0C0", +"= c #808080", +"- c #FF0000", +"; c #00FF00", +"> c #FFFF00", +", c #0000FF", +"' c #FF00FF", +") c #00FFFF", +"! c #FFFFFF", +"****************", +"*..............*", +"*.************.*", +"*..............*", +"*.****.!!!!!!!.*", +"*.****.!====*!.*", +"*.****.!!!!!!!.*", +"*.****.!===*!!.*", +"*.****.!!!!!!!.*", +"*.****.!====*!.*", +"*.****.!!!!!!!.*", +"*.****.!===*!!.*", +"*.****.!!!!!!!.*", +"*..............*", +"****************"}; diff --git a/samples/html/helpview/bitmaps/helpup.xpm b/samples/html/helpview/bitmaps/helpup.xpm new file mode 100644 index 0000000000..66694d3458 --- /dev/null +++ b/samples/html/helpview/bitmaps/helpup.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpup_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +" ", +" .. ", +" .XX. ", +" .XXXX. ", +" .XXXXXX. ", +" .XXXXXXXX. ", +" ....XXXX.... ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" .XXXX. ", +" ...... ", +" "}; diff --git a/samples/html/helpview/bitmaps/helpuplevel.xpm b/samples/html/helpview/bitmaps/helpuplevel.xpm new file mode 100644 index 0000000000..e6f41a446c --- /dev/null +++ b/samples/html/helpview/bitmaps/helpuplevel.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * helpuplevel_xpm[] = { +"16 15 3 1", +" c None", +". c Black", +"X c Gray100", +" ", +" .. ", +" .XX. ", +" .XXXX. ", +" .XXXXXX. ", +" .XXXXXXXX. ", +" ....XXXX.... ", +" .XXXX. ", +" .XXXX..... ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" .XXXXXXXX. ", +" .......... ", +" "}; diff --git a/samples/html/helpview/helpview.cpp b/samples/html/helpview/helpview.cpp index 27adb78a3e..2b2a275859 100644 --- a/samples/html/helpview/helpview.cpp +++ b/samples/html/helpview/helpview.cpp @@ -26,6 +26,29 @@ #include "wx/wxhtml.h" #include "wx/fs_zip.h" #include "wx/log.h" +#include "wx/artprov.h" +#include "wx/filedlg.h" + +// Set to 1 to: +// +// - provide different icons. +// - add an open file icon for the toolbar. +// - use a flat toolbar style. +// - show a file selector if no file was given on the command line. +// - remove 'Help:' from the title bar. +// +// Set to 0 to revert to previous behaviour. + +#define USE_ALTERNATE_UI 0 + +#if USE_ALTERNATE_UI +class AlternateArtProvider : public wxArtProvider +{ +protected: + virtual wxBitmap CreateBitmap(const wxArtID& id, const wxArtClient& client, + const wxSize& size); +}; +#endif // ---------------------------------------------------------------------------- // private classes @@ -46,6 +69,9 @@ class MyApp : public wxApp virtual bool OnInit(); virtual int OnExit(); + // Prompt the user for a book to open + bool OpenBook(wxHtmlHelpController* controller); + private: wxHtmlHelpController *help; }; @@ -60,6 +86,10 @@ bool MyApp::OnInit() delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used #endif +#if USE_ALTERNATE_UI + wxArtProvider::PushProvider(new AlternateArtProvider); +#endif + wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); @@ -67,13 +97,25 @@ bool MyApp::OnInit() SetAppName("wxHTMLHelp"); wxConfig::Get(); // create an instance - help = new wxHtmlHelpController; + help = new wxHtmlHelpController( +#if USE_ALTERNATE_UI + wxHF_DEFAULT_STYLE|wxHF_FLAT_TOOLBAR|wxHF_OPEN_FILES +#endif + ); +#if USE_ALTERNATE_UI + help->SetTitleFormat(wxT("%s")); + if (argc < 2) { + if (!OpenBook(help)) + return FALSE; + } +#else if (argc < 2) { wxLogError(wxT("Usage : helpview []")); wxLogError(wxT(" helpfile may be .hhp, .zip or .htb")); return FALSE; } +#endif for (int i = 1; i < argc; i++) help -> AddBook(argv[i]); @@ -96,3 +138,138 @@ int MyApp::OnExit() return 0; } +bool MyApp::OpenBook(wxHtmlHelpController* controller) +{ + wxString s = wxFileSelector(_("Open help file"), + wxGetCwd(), + wxEmptyString, + wxEmptyString, + _( +"Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\ +HTML Help Project (*.hhp)|*.hhp"), + wxOPEN | wxFILE_MUST_EXIST, + NULL); + + if (!s.IsEmpty()) + { + wxString ext = s.Right(4).Lower(); + if (ext == _T(".zip") || ext == _T(".htb") || ext == _T(".hhp")) + { + wxBusyCursor bcur; + controller->AddBook(s); + return TRUE; + } + } + return FALSE; +} + +#if USE_ALTERNATE_UI + +/* + * Art provider class + */ + +// --------------------------------------------------------------------- +// helper macros +// --------------------------------------------------------------------- + +// Standard macro for getting a resource from XPM file: +#define ART(artId, xpmRc) \ + if ( id == artId ) return wxBitmap(xpmRc##_xpm); + +// Compatibility hack to use wxApp::GetStdIcon of overriden by the user +#if WXWIN_COMPATIBILITY_2_2 + #define GET_STD_ICON_FROM_APP(iconId) \ + if ( client == wxART_MESSAGE_BOX ) \ + { \ + wxIcon icon = wxTheApp->GetStdIcon(iconId); \ + if ( icon.Ok() ) \ + { \ + wxBitmap bmp; \ + bmp.CopyFromIcon(icon); \ + return bmp; \ + } \ + } +#else + #define GET_STD_ICON_FROM_APP(iconId) +#endif + +// There are two ways of getting the standard icon: either via XPMs or via +// wxIcon ctor. This depends on the platform: +#if defined(__WXUNIVERSAL__) + #define CREATE_STD_ICON(iconId, xpmRc) return wxNullBitmap; +#elif defined(__WXGTK__) || defined(__WXMOTIF__) + #define CREATE_STD_ICON(iconId, xpmRc) return wxBitmap(xpmRc##_xpm); +#else + #define CREATE_STD_ICON(iconId, xpmRc) \ + { \ + wxIcon icon(_T(iconId)); \ + wxBitmap bmp; \ + bmp.CopyFromIcon(icon); \ + return bmp; \ + } +#endif + +// Macro used in CreateBitmap to get wxICON_FOO icons: +#define ART_MSGBOX(artId, iconId, xpmRc) \ + if ( id == artId ) \ + { \ + GET_STD_ICON_FROM_APP(iconId) \ + CREATE_STD_ICON(#iconId, xpmRc) \ + } + +// --------------------------------------------------------------------- +// XPMs with the art +// --------------------------------------------------------------------- + +// XPM hack: make the arrays const +//#define static static const + +#include "bitmaps/helpback.xpm" +#include "bitmaps/helpbook.xpm" +#include "bitmaps/helpdown.xpm" +#include "bitmaps/helpforward.xpm" +#include "bitmaps/helpoptions.xpm" +#include "bitmaps/helppage.xpm" +#include "bitmaps/helpsidepanel.xpm" +#include "bitmaps/helpup.xpm" +#include "bitmaps/helpuplevel.xpm" +#include "bitmaps/helpicon.xpm" +#include "bitmaps/helpopen.xpm" + +//#undef static + +// --------------------------------------------------------------------- +// CreateBitmap routine +// --------------------------------------------------------------------- + +wxBitmap AlternateArtProvider::CreateBitmap(const wxArtID& id, + const wxArtClient& client, + const wxSize& WXUNUSED(size)) +{ + ART(wxART_HELP_SIDE_PANEL, helpsidepanel) + ART(wxART_HELP_SETTINGS, helpoptions) + ART(wxART_HELP_BOOK, helpbook) + ART(wxART_HELP_FOLDER, helpbook) + ART(wxART_HELP_PAGE, helppage) + //ART(wxART_ADD_BOOKMARK, addbookm) + //ART(wxART_DEL_BOOKMARK, delbookm) + ART(wxART_GO_BACK, helpback) + ART(wxART_GO_FORWARD, helpforward) + ART(wxART_GO_UP, helpup) + ART(wxART_GO_DOWN, helpdown) + ART(wxART_GO_TO_PARENT, helpuplevel) + ART(wxART_FILE_OPEN, helpopen) + if (client == wxART_HELP_BROWSER) + { + ART(wxART_FRAME_ICON, helpicon) + } + + //ART(wxART_GO_HOME, home) + + // Any wxWindows icons not implemented here + // will be provided by the default art provider. + return wxNullBitmap; +} + +#endif \ No newline at end of file diff --git a/samples/html/helpview/helpview.ico b/samples/html/helpview/helpview.ico new file mode 100644 index 0000000000000000000000000000000000000000..cbf22233727e5bffd15eb565c73a90d29bb3e9de GIT binary patch literal 1078 zcmcgrIc~!+5FFbCm@4uQtSay?tb%~u`7162P#swWkUBjfU(r)srgTRYhM8H?3Y5U< zlB_h`UCt~eUcdrNl;xUU;e83b09dbczFh#%D`3mMlBfvLiFs-tn zLd5hUMu`YM(k0D5nD$>kQg`2S)6Et72y>W8^gckD*Uy^Tx#lF2dsQ7mXj@8*IZ&jJ z&beUqiLoJsj`3nc*IFexX%|Q9Yz)+Jbm6sSBg>J>V{DU%xthw!%aCd+cX{<@<$*Ms zMg*z+B0128Fk1PBPboBi-0~NaJa;{H*4ie=x$UOe%{%`f=A<9n8@mf)5#tRzqKH>u zL##%Eb4xgL#qKERH$%pby4?-nLKAY_ey}Zg_KA|1&iTOjv3Y>+FP-yBwv!uLxfGbH zmkm~CkDgm&Ol{EjOnI(AU(*{XNyVqMg3hVb8B?Y4$R<-M&2hSKR|kw6;G%&u@A*K^ V-}&U&2i|><_XRc7jyvGSx(^uT2onGR literal 0 HcmV?d00001 diff --git a/samples/html/helpview/helpview.rc b/samples/html/helpview/helpview.rc index ff5d223942..d43931e596 100644 --- a/samples/html/helpview/helpview.rc +++ b/samples/html/helpview/helpview.rc @@ -1,4 +1,5 @@ /* We need this to get the right default icon. */ -aaaaaa ICON "mondrian.ico" +aaaaaa ICON "helpview.ico" +helpview ICON "helpview.ico" #include "wx/msw/wx.rc" -- 2.45.2