diff --git a/Contrib/NSIS Menu/Info.txt b/Contrib/NSIS Menu/Info.txt new file mode 100644 index 00000000..a31dc39f --- /dev/null +++ b/Contrib/NSIS Menu/Info.txt @@ -0,0 +1,10 @@ +NSIS Menu - by Joost Verburg + +Based on wxWindows 2.4.0 / wxHtml + +Compile using the wxWindows framework: http://www.wxwindows.org/ + +Modified wxWindows / wxHtml sources included. +Copy the data from this folder to the wxWindows folder. + +The NSIS Menu binary is compressed using UPX: http://upx.sourceforge.net/ \ No newline at end of file diff --git a/Contrib/NSIS Menu/include/wx/msw/setup.h b/Contrib/NSIS Menu/include/wx/msw/setup.h new file mode 100644 index 00000000..1d0d509c --- /dev/null +++ b/Contrib/NSIS Menu/include/wx/msw/setup.h @@ -0,0 +1,1236 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/msw/setup.h +// Purpose: Configuration for the library +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id: setup0.h,v 1.123.2.5 2002/12/02 11:42:23 JS Exp $ +// Copyright: (c) Julian Smart +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_SETUP_H_ +#define _WX_SETUP_H_ + +// ---------------------------------------------------------------------------- +// global settings +// ---------------------------------------------------------------------------- + +// define this to 0 when building wxBase library - this can also be done from +// makefile/project file overriding the value here +#ifndef wxUSE_GUI + #define wxUSE_GUI 1 +#endif // wxUSE_GUI + +// ---------------------------------------------------------------------------- +// compatibility settings +// ---------------------------------------------------------------------------- + +// This setting determines the compatibility with 1.68 API: +// Level 0: no backward compatibility, all new features +// Level 1: some extra methods are defined for compatibility. +// +// Default is 0. +// +// Recommended setting: 0 (in fact the compatibility code is now very minimal +// so there is little advantage to setting it to 1. +#define WXWIN_COMPATIBILITY 0 + +// This setting determines the compatibility with 2.0 API: set it to 1 to +// enable it +// +// Default is 0. +// +// Recommended setting: 0 (please update your code instead!) +#define WXWIN_COMPATIBILITY_2 0 + +// This setting determines the compatibility with 2.2 API: set it to 0 to +// flag all cases of using deprecated functions. +// +// Default is 1 but please try building your code with 0. +// +// Recommended setting: 0 (please update your code) +#define WXWIN_COMPATIBILITY_2_2 0 + +// in wxMSW version 2.1.11 and earlier, wxIcon always derives from wxBitmap, +// but this is very dangerous because you can mistakenly pass an icon instead +// of a bitmap to a function taking "const wxBitmap&" - which will *not* work +// because an icon is not a valid bitmap +// +// Starting from 2.1.12, you have the choice under this backwards compatible +// behaviour (your code will still compile, but probably won't behave as +// expected!) and not deriving wxIcon class from wxBitmap, but providing a +// conversion ctor wxBitmap(const wxIcon&) instead. +// +// Recommended setting: 0 +#define wxICON_IS_BITMAP 0 + +// Define as 1 for font size to be backward compatible to 1.63 and earlier. +// 1.64 and later define point sizes to be compatible with Windows. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxFONT_SIZE_COMPATIBILITY 0 + +// Set to 0 for accurate dialog units, else 1 to be as per 2.1.16 and before. +// If migrating between versions, your dialogs may seem to shrink. +// +// Default is 1 +// +// Recommended setting: 0 (the new calculations are more correct!) +#define wxDIALOG_UNIT_COMPATIBILITY 0 + +// ---------------------------------------------------------------------------- +// debugging settings +// ---------------------------------------------------------------------------- + +// Generic comment about debugging settings: they are very useful if you don't +// use any other memory leak detection tools such as Purify/BoundsChecker, but +// are probably redundant otherwise. Also, Visual C++ CRT has the same features +// as wxWindows memory debugging subsystem built in since version 5.0 and you +// may prefer to use it instead of built in memory debugging code because it is +// faster and more fool proof. +// +// Using VC++ CRT memory debugging is enabled by default in debug mode +// (__WXDEBUG__) if wxUSE_GLOBAL_MEMORY_OPERATORS is *not* enabled (i.e. is 0) +// and if __NO_VC_CRTDBG__ is not defined. + +// If 1, enables wxDebugContext, for writing error messages to file, etc. If +// __WXDEBUG__ is not defined, will still use the normal memory operators. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_DEBUG_CONTEXT 0 + +// If 1, enables debugging versions of wxObject::new and wxObject::delete *IF* +// __WXDEBUG__ is also defined. +// +// WARNING: this code may not work with all architectures, especially if +// alignment is an issue. This switch is currently ignored for mingw / cygwin +// +// Default is 0 +// +// Recommended setting: 1 if you are not using a memory debugging tool, else 0 +#define wxUSE_MEMORY_TRACING 0 + +// In debug mode, cause new and delete to be redefined globally. +// If this causes problems (e.g. link errors which is a common problem +// especially if you use another library which also redefines the global new +// and delete), set this to 0. +// This switch is currently ignored for mingw / cygwin +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_GLOBAL_MEMORY_OPERATORS 0 + +// In debug mode, causes new to be defined to be WXDEBUG_NEW (see object.h). If +// this causes problems (e.g. link errors), set this to 0. You may need to set +// this to 0 if using templates (at least for VC++). This switch is currently +// ignored for mingw / cygwin / CodeWarrior +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_DEBUG_NEW_ALWAYS 0 + +// wxHandleFatalExceptions() may be used to catch the program faults at run +// time and, instead of terminating the program with a usual GPF message box, +// call the user-defined wxApp::OnFatalException() function. If you set +// wxUSE_ON_FATAL_EXCEPTION to 0, wxHandleFatalExceptions() will not work. +// +// This setting is for Win32 only and can only be enabled if your compiler +// supports Win32 structured exception handling (currently only VC++ does) +// +// Default is 1 +// +// Recommended setting: 1 if your compiler supports it. +#ifdef _MSC_VER + #define wxUSE_ON_FATAL_EXCEPTION 1 +#else + #define wxUSE_ON_FATAL_EXCEPTION 0 +#endif + +// ---------------------------------------------------------------------------- +// Unicode support +// ---------------------------------------------------------------------------- + +// Set wxUSE_UNICODE to 1 to compile wxWindows in Unicode mode: wxChar will be +// defined as wchar_t, wxString will use Unicode internally. If you set this +// to 1, you must use wxT() macro for all literal strings in the program. +// +// Unicode is currently only fully supported under Windows NT/2000/XP (Windows 9x +// doesn't support it and the programs compiled in Unicode mode will not run +// under 9x). +// +// Default is 0 +// +// Recommended setting: 0 (unless you only plan to use Windows NT/2000/XP) +#define wxUSE_UNICODE 0 + +// Set wxUSE_UNICODE_MSLU to 1 if you want to compile wxWindows in Unicode mode +// and be able to run compiled apps under Windows 9x as well as NT/2000/XP. This +// setting enables use of unicows.dll from MSLU (MS Layer for Unicode, see +// http://www.microsoft.com/globaldev/Articles/mslu_announce.asp). Note that you +// will have to modify the makefiles to include unicows.lib import library as the first +// library (if you use MSVC, you can run the makefile with "nmake MSLU=1 UNICODE=1" +// command). +// +// If your compiler doesn't have unicows.lib, you can get a version of it at +// http://libunicows.sourceforge.net +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_UNICODE_MSLU 0 + +// Setting wxUSE_WCHAR_T to 1 gives you some degree of Unicode support without +// compiling the program in Unicode mode. More precisely, it will be possible +// to construct wxString from a wide (Unicode) string and convert any wxString +// to Unicode. +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_WCHAR_T 1 + +// ---------------------------------------------------------------------------- +// global features +// ---------------------------------------------------------------------------- + +// Support for message/error logging. This includes wxLogXXX() functions and +// wxLog and derived classes. Don't set this to 0 unless you really know what +// you are doing. +// +// Default is 1 +// +// Recommended setting: 1 (always) +#define wxUSE_LOG 1 + +// Recommended setting: 1 +#define wxUSE_LOGWINDOW 0 + +// Recommended setting: 1 +#define wxUSE_LOGGUI 0 + +// Recommended setting: 1 +#define wxUSE_LOG_DIALOG 0 + +// Support for command line parsing using wxCmdLineParser class. +// +// Default is 1 +// +// Recommended setting: 1 (can be set to 0 if you don't use the cmd line) +#define wxUSE_CMDLINE_PARSER 0 + +// Support for multithreaded applications: if 1, compile in thread classes +// (thread.h) and make the library a bit more thread safe. Although thread +// support is quite stable by now, you may still consider recompiling the +// library without it if you have no use for it - this will result in a +// somewhat smaller and faster operation. +// +// This is ignored under Win16, threads are only supported under Win32. +// +// Default is 1 +// +// Recommended setting: 0 unless you do plan to develop MT applications +#define wxUSE_THREADS 1 + +// If enabled (1), compiles wxWindows streams classes +#define wxUSE_STREAMS 1 + +// Use standard C++ streams if 1. If 0, use wxWin streams implementation. +#define wxUSE_STD_IOSTREAM 0 + +// ---------------------------------------------------------------------------- +// non GUI features selection +// ---------------------------------------------------------------------------- + +// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit +// integer which is implemented in terms of native 64 bit integers if any or +// uses emulation otherwise. +// +// This class is required by wxDateTime and so you should enable it if you want +// to use wxDateTime. For most modern platforms, it will use the native 64 bit +// integers in which case (almost) all of its functions are inline and it +// almost does not take any space, so there should be no reason to switch it +// off. +// +// Recommended setting: 1 +#define wxUSE_LONGLONG 1 + +// Set wxUSE_(F)FILE to 1 to compile wx(F)File classes. wxFile uses low level +// POSIX functions for file access, wxFFile uses ANSI C stdio.h functions. +// +// Default is 1 +// +// Recommended setting: 1 (wxFile is highly recommended as it is required by +// i18n code, wxFileConfig and others) +#define wxUSE_FILE 1 +#define wxUSE_FFILE 1 + +// Use wxFSVolume class providing access to the configured/active mount points +// +// Default is 1 +// +// Recommended setting: 1 (but may be safely disabled if you don't use it) +#define wxUSE_FSVOLUME 0 + +// use wxTextBuffer class: required by wxTextFile +#define wxUSE_TEXTBUFFER 1 + +// use wxTextFile class: requires wxFile and wxTextBuffer, required by +// wxFileConfig +#define wxUSE_TEXTFILE 1 + +// i18n support: _() macro, wxLocale class. Requires wxTextFile. +#define wxUSE_INTL 0 + +// Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which +// allow to manipulate dates, times and time intervals. wxDateTime replaces the +// old wxTime and wxDate classes which are still provided for backwards +// compatibility (and implemented in terms of wxDateTime). +// +// Note that this class is relatively new and is still officially in alpha +// stage because some features are not yet (fully) implemented. It is already +// quite useful though and should only be disabled if you are aiming at +// absolutely minimal version of the library. +// +// Requires: wxUSE_LONGLONG +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_DATETIME 1 + +// wxUSE_TIMEDATE enables compilation of the old wxDate and wxTime classes (not +// the same as wxDateTime!). These classes are obsolete and shouldn't be used +// in new code +// +// Default is 0 +// +// Recommended setting: 0 unless you have legacy code which uses these classes +#define wxUSE_TIMEDATE 0 + +// Set wxUSE_TIMER to 1 to compile wxTimer class +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_TIMER 1 + +// Use wxStopWatch clas. +// +// Default is 1 +// +// Recommended setting: 1 (needed by wxSocket) +#define wxUSE_STOPWATCH 1 + +// Setting wxUSE_CONFIG to 1 enables the use of wxConfig and related classes +// which allow the application to store its settings in the persistent +// storage. Setting this to 1 will also enable on-demand creation of the +// global config object in wxApp. +// +// See also wxUSE_CONFIG_NATIVE below. +// +// Recommended setting: 1 +#define wxUSE_CONFIG 1 + +// If wxUSE_CONFIG is 1, you may choose to use either the native config +// classes under Windows (using .INI files under Win16 and the registry under +// Win32) or the portable text file format used by the config classes under +// Unix. +// +// Default is 1 to use native classes. Note that you may still use +// wxFileConfig even if you set this to 1 - just the config object created by +// default for the applications needs will be a wxRegConfig or wxIniConfig and +// not wxFileConfig. +// +// Recommended setting: 1 +#define wxUSE_CONFIG_NATIVE 1 + +// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows +// to connect/disconnect from the network and be notified whenever the dial-up +// network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_DIALUP_MANAGER 0 + +// Compile in classes for run-time DLL loading and function calling. +// Required by wxUSE_DIALUP_MANAGER. +// +// This setting is for Win32 only +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_DYNLIB_CLASS 0 + +// experimental, don't use for now +#define wxUSE_DYNAMIC_LOADER 1 + +// Set to 1 to use socket classes +#define wxUSE_SOCKETS 0 + +// Set to 1 to enable virtual file systems (required by wxHTML) +#define wxUSE_FILESYSTEM 1 + +// Set to 1 to enable virtual ZIP filesystem (requires wxUSE_FILESYSTEM) +#define wxUSE_FS_ZIP 0 + +// Set to 1 to enable virtual Internet filesystem (requires wxUSE_FILESYSTEM) +#define wxUSE_FS_INET 0 + +// Set to 1 to compile wxZipInput/OutputStream classes. +#define wxUSE_ZIPSTREAM 0 + +// Set to 1 to compile wxZlibInput/OutputStream classes. Also required by +// wxUSE_LIBPNG. +#define wxUSE_ZLIB 0 + +// If enabled, the code written by Apple will be used to write, in a portable +// way, float on the disk. See extended.c for the license which is different +// from wxWindows one. +// +// Default is 1. +// +// Recommended setting: 1 unless you don't like the license terms (unlikely) +#define wxUSE_APPLE_IEEE 0 + +// Joystick support class +#define wxUSE_JOYSTICK 0 + +// wxFontMapper class +#define wxUSE_FONTMAP 1 + +// wxMimeTypesManager class +#define wxUSE_MIMETYPE 0 + +// wxProtocol and related classes: if you want to use either of wxFTP, wxHTTP +// or wxURL you need to set this to 1. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_PROTOCOL 0 + +// The settings for the individual URL schemes +#define wxUSE_PROTOCOL_FILE 0 +#define wxUSE_PROTOCOL_FTP 0 +#define wxUSE_PROTOCOL_HTTP 0 + +// Define this to use wxURL class. +#define wxUSE_URL 0 + +// Support for regular expression matching via wxRegEx class: enable this to +// use POSIX regular expressions in your code. You need to compile regex +// library from src/regex to use it under Windows. +// +// Default is 0 +// +// Recommended setting: 1 if your compiler supports it, if it doesn't please +// contribute us a makefile for src/regex for it +#define wxUSE_REGEX 0 + +// wxSystemOptions class +#define wxUSE_SYSTEM_OPTIONS 0 + +// wxWave class +#define wxUSE_WAVE 0 + +// ---------------------------------------------------------------------------- +// Individual GUI controls +// ---------------------------------------------------------------------------- + +// You must set wxUSE_CONTROLS to 1 if you are using any controls at all +// (without it, wxControl class is not compiled) +// +// Default is 1 +// +// Recommended setting: 1 (don't change except for very special programs) +#define wxUSE_CONTROLS 1 + +// wxPopupWindow class is a top level transient window. It is currently used +// to implement wxTipWindow +// +// Default is 1 +// +// Recommended setting: 1 (may be set to 0 if you don't wxUSE_TIPWINDOW) +#define wxUSE_POPUPWIN 1 + +// wxTipWindow allows to implement the custom tooltips, it is used by the +// context help classes. Requires wxUSE_POPUPWIN. +// +// Default is 1 +// +// Recommended setting: 1 (may be set to 0) +#define wxUSE_TIPWINDOW 1 + +// Each of the settings below corresponds to one wxWindows control. They are +// all switched on by default but may be disabled if you are sure that your +// program (including any standard dialogs it can show!) doesn't need them and +// if you desperately want to save some space. If you use any of these you must +// set wxUSE_CONTROLS as well. +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 0 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 0 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_GAUGE 0 // wxGauge +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 0 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 0 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 0 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl + +// Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR +// below either wxStatusBar95 or a generic wxStatusBar will be used. +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_STATUSBAR 1 + +// Two status bar implementations are available under Win32: the generic one +// or the wrapper around native control. For native look and feel the native +// version should be used. +// +// Default is 1. +// +// Recommended setting: 1 (there is no advantage in using the generic one) +#define wxUSE_NATIVE_STATUSBAR 1 + +// wxToolBar related settings: if wxUSE_TOOLBAR is 0, don't compile any toolbar +// classes at all. Otherwise, use the native toolbar class unless +// wxUSE_TOOLBAR_NATIVE is 0. Additionally, the generic toolbar class which +// supports some features which might not be supported by the native wxToolBar +// class may be compiled in if wxUSE_TOOLBAR_SIMPLE is 1. +// +// Default is 1 for all settings. +// +// Recommended setting: 1 for wxUSE_TOOLBAR and wxUSE_TOOLBAR_NATIVE and 0 for +// wxUSE_TOOLBAR_SIMPLE (the default is 1 mainly for backwards compatibility). +#define wxUSE_TOOLBAR 0 +#define wxUSE_TOOLBAR_NATIVE 0 +#define wxUSE_TOOLBAR_SIMPLE 0 + +// this setting is obsolete, value is ignored +#define wxUSE_BUTTONBAR 0 + +// wxNotebook is a control with several "tabs" located on one of its sides. It +// may be used ot logically organise the data presented to the user instead of +// putting everything in one huge dialog. It replaces wxTabControl and related +// classes of wxWin 1.6x. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_NOTEBOOK 0 + +// wxTabDialog is a generic version of wxNotebook but it is incompatible with +// the new class. It shouldn't be used in new code. +// +// Default is 0. +// +// Recommended setting: 0 (use wxNotebook) +#define wxUSE_TAB_DIALOG 0 + +// wxGrid class comes in two flavours: the original (pre wxWin 2.2) one and +// the new, much imporved and enhanced version. The new version is backwards +// compatible with the old one and should be used whenever possible, i.e. if +// you set wxUSE_GRID to 1, set wxUSE_NEW_GRID to 1 too. +// +// Default is 1 for both options. +// +// Recommended setting: 1 for wxUSE_NEW_GRID, 0 if you have an old code using +// wxGrid and 100% backwards compatibality (with all old wxGrid quirks) is +// essential. +// +// WIN16/BC++ resets wxUSE_NEW_GRID to 0 because it exceeds the data limit. +#define wxUSE_GRID 0 +#define wxUSE_NEW_GRID 0 + +// wxProperty[Value/Form/List] classes, used by Dialog Editor +#define wxUSE_PROPSHEET 0 + +// ---------------------------------------------------------------------------- +// Miscellaneous GUI stuff +// ---------------------------------------------------------------------------- + +// wxAcceleratorTable/Entry classes and support for them in wxMenu(Bar) +#define wxUSE_ACCEL 1 + +// Use wxCaret: a class implementing a "cursor" in a text control (called caret +// under Windows). +// +// Default is 1. +// +// Recommended setting: 1 (can be safely set to 0, not used by the library) +#define wxUSE_CARET 1 + +// Miscellaneous geometry code: needed for Canvas library +#define wxUSE_GEOMETRY 0 + +// Use wxImageList. This class is needed by wxNotebook, wxTreeCtrl and +// wxListCtrl. +// +// Default is 1. +// +// Recommended setting: 1 (set it to 0 if you don't use any of the controls +// enumerated above, then this class is mostly useless too) +#define wxUSE_IMAGLIST 1 + +// Use wxMenu, wxMenuBar, wxMenuItem. +// +// Default is 1. +// +// Recommended setting: 1 (can't be disabled under MSW) +#define wxUSE_MENUS 1 + +// Use wxSashWindow class. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_SASH 0 + +// Use wxSplitterWindow class. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_SPLITTER 0 + +// Use wxToolTip and wxWindow::Set/GetToolTip() methods. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_TOOLTIPS 0 + +// wxValidator class and related methods +#define wxUSE_VALIDATORS 0 + +// wxDC cacheing implementation +#define wxUSE_DC_CACHEING 0 + +// ---------------------------------------------------------------------------- +// common dialogs +// ---------------------------------------------------------------------------- + +// Define 1 to use generic dialogs in Windows, even though they duplicate +// native common dialog (e.g. wxColourDialog). This is mainly useful for +// testing. +// +// Default is 0 +// +// Recommended setting: 0 +#define wxUSE_GENERIC_DIALOGS_IN_MSW 0 + +// On rare occasions (e.g. using DJGPP) may want to omit common dialogs (e.g. +// file selector, printer dialog). Switching this off also switches off the +// printing architecture and interactive wxPrinterDC. +// +// Default is 1 +// +// Recommended setting: 1 (unless it really doesn't work) +#define wxUSE_COMMON_DIALOGS 1 + +// wxBusyInfo displays window with message when app is busy. Works in same way +// as wxBusyCursor +#define wxUSE_BUSYINFO 0 + +// Use single/multiple choice dialogs. +// +// Default is 1 +// +// Recommended setting: 1 (used in the library itself) +#define wxUSE_CHOICEDLG 1 + +// Use colour picker dialog +// +// Default is 1 +// +// Recommended setting: 1 +#define wxUSE_COLOURDLG 1 + +// wxDirDlg class for getting a directory name from user +#define wxUSE_DIRDLG 0 + +// TODO: setting to choose the generic or native one + +// Use file open/save dialogs. +// +// Default is 1 +// +// Recommended setting: 1 (used in many places in the library itself) +#define wxUSE_FILEDLG 1 + +// Use find/replace dialogs. +// +// Default is 1 +// +// Recommended setting: 1 (but may be safely set to 0) +#define wxUSE_FINDREPLDLG 0 + +// Use font picker dialog +// +// Default is 1 +// +// Recommended setting: 1 (used in the library itself) +#define wxUSE_FONTDLG 0 + +// Use wxMessageDialog and wxMessageBox. +// +// Default is 1 +// +// Recommended setting: 1 (used in the library itself) +#define wxUSE_MSGDLG 1 + +// progress dialog class for lengthy operations +#define wxUSE_PROGRESSDLG 0 + +// support for startup tips (wxShowTip &c) +#define wxUSE_STARTUP_TIPS 0 + +// text entry dialog and wxGetTextFromUser function +#define wxUSE_TEXTDLG 0 + +// number entry dialog +#define wxUSE_NUMBERDLG 0 + +// splash screen class +#define wxUSE_SPLASH 0 + +// wizards +#define wxUSE_WIZARDDLG 0 + +// ---------------------------------------------------------------------------- +// Metafiles support +// ---------------------------------------------------------------------------- + +// Windows supports the graphics format known as metafile which is, though not +// portable, is widely used under Windows and so is supported by wxWin (under +// Windows only, of course). Win16 (Win3.1) used the so-called "Window +// MetaFiles" or WMFs which were replaced with "Enhanced MetaFiles" or EMFs in +// Win32 (Win9x, NT, 2000). Both of these are supported in wxWin and, by +// default, WMFs will be used under Win16 and EMFs under Win32. This may be +// changed by setting wxUSE_WIN_METAFILES_ALWAYS to 1 and/or setting +// wxUSE_ENH_METAFILE to 0. You may also set wxUSE_METAFILE to 0 to not compile +// in any metafile related classes at all. +// +// Default is 1 for wxUSE_ENH_METAFILE and 0 for wxUSE_WIN_METAFILES_ALWAYS. +// +// Recommended setting: default or 0 for everything for portable programs. +#define wxUSE_METAFILE 0 +#define wxUSE_ENH_METAFILE 0 +#define wxUSE_WIN_METAFILES_ALWAYS 0 + +// ---------------------------------------------------------------------------- +// Big GUI components +// ---------------------------------------------------------------------------- + +// Set to 0 to disable document/view architecture +#define wxUSE_DOC_VIEW_ARCHITECTURE 1 + +// Set to 0 to disable MDI document/view architecture +#define wxUSE_MDI_ARCHITECTURE 0 + +// Set to 0 to disable print/preview architecture code +#define wxUSE_PRINTING_ARCHITECTURE 0 + +// wxHTML sublibrary allows to display HTML in wxWindow programs and much, +// much more. +// +// Default is 1. +// +// Recommended setting: 1 (wxHTML is great!), set to 0 if you want compile a +// smaller library. +#define wxUSE_HTML 1 + +// Setting wxUSE_GLCANVAS to 1 enables OpenGL support. You need to have OpenGL +// headers and libraries to be able to compile the library with wxUSE_GLCANVAS +// set to 1. Note that for some compilers (notably Microsoft Visual C++) you +// will need to manually add opengl32.lib and glu32.lib to the list of +// libraries linked with your program if you use OpenGL. +// +// Default is 0. +// +// Recommended setting: 1 if you intend to use OpenGL, 0 otherwise +#define wxUSE_GLCANVAS 0 + +// wxTreeLayout class +#define wxUSE_TREELAYOUT 0 + +// ---------------------------------------------------------------------------- +// Data transfer +// ---------------------------------------------------------------------------- + +// Use wxClipboard class for clipboard copy/paste. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_CLIPBOARD 0 + +// Use wxDataObject and related classes. Needed for clipboard and OLE drag and +// drop +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_DATAOBJ 0 + +// Use wxDropTarget and wxDropSource classes for drag and drop (this is +// different from "built in" drag and drop in wxTreeCtrl which is always +// available). Requires wxUSE_DATAOBJ. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_DRAG_AND_DROP 0 + +// ---------------------------------------------------------------------------- +// miscellaneous settings +// ---------------------------------------------------------------------------- + +// wxSingleInstanceChecker class allows to verify at startup if another program +// instance is running (it is only available under Win32) +// +// Default is 1 +// +// Recommended setting: 1 (the class is tiny, disabling it won't save much +// space) +#define wxUSE_SNGLINST_CHECKER 1 + +#define wxUSE_DRAGIMAGE 1 + +#define wxUSE_IPC 1 + // 0 for no interprocess comms +#define wxUSE_HELP 1 + // 0 for no help facility +#define wxUSE_MS_HTML_HELP 0 + // 0 for no MS HTML Help + +// Use wxHTML-based help controller? +#define wxUSE_WXHTML_HELP 0 + +#define wxUSE_RESOURCES 1 + // 0 for no wxGetResource/wxWriteResource +#define wxUSE_CONSTRAINTS 1 + // 0 for no window layout constraint system + +#define wxUSE_SPLINES 1 + // 0 for no splines + +#define wxUSE_XPM_IN_MSW 1 + // 0 for no XPM support in wxBitmap. + // Default is 1, as XPM is now fully + // supported this makes easier the issue + // of portable icons and bitmaps. + +#define wxUSE_IMAGE_LOADING_IN_MSW 1 + // Use dynamic DIB loading/saving code in utils/dib under MSW. +#define wxUSE_RESOURCE_LOADING_IN_MSW 1 + // Use dynamic icon/cursor loading/saving code + // under MSW. + +// use wxExpr (a.k.a. PrologIO) +#define wxUSE_PROLOGIO 0 + +// Use .wxr resource mechanism (requires PrologIO library) +#define wxUSE_WX_RESOURCES 0 + +#define wxUSE_MOUSEWHEEL 1 + // Include mouse wheel support + +// ---------------------------------------------------------------------------- +// postscript support settings +// ---------------------------------------------------------------------------- + +// Set to 1 for PostScript device context. +#define wxUSE_POSTSCRIPT 0 + +// Set to 1 to use font metric files in GetTextExtent +#define wxUSE_AFM_FOR_POSTSCRIPT 0 + +// Set to 0 to disable PostScript print/preview architecture code under Windows +// (just use Windows printing). +#define wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW 1 + +// ---------------------------------------------------------------------------- +// database classes +// ---------------------------------------------------------------------------- + +// Define 1 to use ODBC classes +#define wxUSE_ODBC 0 + +// For backward compatibility reasons, this parameter now only controls the +// default scrolling method used by cursors. This default behavior can be +// overriden by setting the second param of wxDB::wxDbGetConnection() or +// wxDb() constructor to indicate whether the connection (and any wxDbTable()s +// that use the connection) should support forward only scrolling of cursors, +// or both forward and backward support for backward scrolling cursors is +// dependent on the data source as well as the ODBC driver being used. +#define wxODBC_FWD_ONLY_CURSORS 1 + +// Default is 0. Set to 1 to use the deprecated classes, enum types, function, +// member variables. With a setting of 1, full backward compatability with the +// 2.0.x release is possible. It is STRONGLY recommended that this be set to 0, +// as future development will be done only on the non-deprecated +// functions/classes/member variables/etc. +#define wxODBC_BACKWARD_COMPATABILITY 0 + +// ---------------------------------------------------------------------------- +// other compiler (mis)features +// ---------------------------------------------------------------------------- + +// Set this to 0 if your compiler can't cope with omission of prototype +// parameters. +// +// Default is 1. +// +// Recommended setting: 1 (should never need to set this to 0) +#define REMOVE_UNUSED_ARG 1 + +// VC++ 4.2 and above allows and but you can't mix +// them. Set to 1 for , 0 for +// +// Default is 1. +// +// Recommended setting: whatever your compiler likes more +#define wxUSE_IOSTREAMH 1 + +// ---------------------------------------------------------------------------- +// image format support +// ---------------------------------------------------------------------------- + +// wxImage supports many different image formats which can be configured at +// compile-time. BMP is always supported, others are optional and can be safely +// disabled if you don't plan to use images in such format sometimes saving +// substantial amount of code in the final library. +// +// Some formats require an extra library which is included in wxWin sources +// which is mentioned if it is the case. + +// Set to 1 for wxImage support (recommended). +#define wxUSE_IMAGE 1 + +// Set to 1 for PNG format support (requires libpng). Also requires wxUSE_ZLIB. +#define wxUSE_LIBPNG 0 + +// Set to 1 for JPEG format support (requires libjpeg) +#define wxUSE_LIBJPEG 0 + +// Set to 1 for TIFF format support (requires libtiff) +#define wxUSE_LIBTIFF 0 + +// Set to 1 for GIF format support +#define wxUSE_GIF 1 + +// Set to 1 for PNM format support +#define wxUSE_PNM 0 + +// Set to 1 for PCX format support +#define wxUSE_PCX 0 + +// Set to 1 for IFF format support (Amiga format) +#define wxUSE_IFF 0 + +// Set to 1 for XPM format support +#define wxUSE_XPM 0 + +// Set to 1 for MS Icons and Cursors format support +#define wxUSE_ICO_CUR 1 + +// Set to 1 to compile in wxPalette class +#define wxUSE_PALETTE 1 + +// ---------------------------------------------------------------------------- +// Windows-only settings +// ---------------------------------------------------------------------------- + +// Set this to 1 if you want to use wxWindows and MFC in the same program. This +// will override some other settings (see below) +// +// Default is 0. +// +// Recommended setting: 0 unless you really have to use MFC +#define wxUSE_MFC 0 + +// Set this to 1 for generic OLE support: this is required for drag-and-drop, +// clipboard, OLE Automation. Only set it to 0 if your compiler is very old and +// can't compile/doesn't have the OLE headers. +// +// Default is 1. +// +// Recommended setting: 1 +#define wxUSE_OLE 1 + +// Set this to 1 to use Microsoft CTL3D library for "3D-look" under Win16 or NT +// 3.x. This setting is ignored under Win9x and NT 4.0+. +// +// Default is 0 for (most) Win32 (systems), 1 for Win16 +// +// Recommended setting: same as default +#if defined(__WIN95__) +#define wxUSE_CTL3D 0 +#else +#define wxUSE_CTL3D 1 +#endif + +// Define as 1 to use Microsoft's ItsyBitsy small title bar library, for +// wxMiniFrame. This setting is only used for Win3.1; Win9x and NT use native +// miniframes support instead. +// +// Default is 0 for (most) Win32 (systems), 1 for Win16 +// +// Recommended setting: same as default +#if defined(__WIN95__) +#define wxUSE_ITSY_BITSY 0 +#else +#define wxUSE_ITSY_BITSY 1 +#endif + +// Set this to 1 to use RICHEDIT controls for wxTextCtrl with style wxTE_RICH +// which allows to put more than ~32Kb of text in it even under Win9x (NT +// doesn't have such limitation). +// +// Default is 1 for compilers which support it +// +// Recommended setting: 1, only set it to 0 if your compiler doesn't have +// or can't compile +#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__GNUWIN32_OLD__) +#define wxUSE_RICHEDIT 1 + +// TODO: This should be ifdef'ed for any compilers that don't support +// RichEdit 2.0 but do have RichEdit 1.0... +#define wxUSE_RICHEDIT2 1 + +#else +#define wxUSE_RICHEDIT 0 +#define wxUSE_RICHEDIT2 0 +#endif + +// Set this to 1 to enable support for the owner-drawn menu and listboxes. This +// is required by wxUSE_CHECKLISTBOX. +// +// Default is 1. +// +// Recommended setting: 1, set to 0 for a small library size reduction +#define wxUSE_OWNER_DRAWN 0 + +// ---------------------------------------------------------------------------- +// obsolete settings +// ---------------------------------------------------------------------------- + +// NB: all settings in this section are obsolete and should not be used/changed +// at all, they will disappear + +// Set to 1 to use PenWindows +#define wxUSE_PENWINDOWS 0 + +// Define 1 to use bitmap messages. +#define wxUSE_BITMAP_MESSAGE 1 + +// If 1, enables provision of run-time type information. +// NOW MANDATORY: don't change. +#define wxUSE_DYNAMIC_CLASSES 1 + +// ---------------------------------------------------------------------------- +// disable the settings which don't work for some compilers +// ---------------------------------------------------------------------------- + +#ifndef wxUSE_NORLANDER_HEADERS +#if (defined(__MINGW32__) || defined(__CYGWIN__)) && ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95))) +# define wxUSE_NORLANDER_HEADERS 1 +#else +# define wxUSE_NORLANDER_HEADERS 0 +#endif +#endif + +// wxUSE_DEBUG_NEW_ALWAYS doesn't work with CodeWarrior +#if defined(__MWERKS__) + #undef wxUSE_DEBUG_NEW_ALWAYS + #define wxUSE_DEBUG_NEW_ALWAYS 0 +#endif + +#if defined(__GNUWIN32__) +// These don't work as expected for mingw32 and cygwin32 +#undef wxUSE_MEMORY_TRACING +#define wxUSE_MEMORY_TRACING 0 + +#undef wxUSE_GLOBAL_MEMORY_OPERATORS +#define wxUSE_GLOBAL_MEMORY_OPERATORS 0 + +#undef wxUSE_DEBUG_NEW_ALWAYS +#define wxUSE_DEBUG_NEW_ALWAYS 0 + +// Cygwin betas don't have wcslen +#if defined(__CYGWIN__) || defined(__CYGWIN32__) +# if ! ((__GNUC__>2) ||((__GNUC__==2) && (__GNUC_MINOR__>=95))) +# undef wxUSE_WCHAR_T +# define wxUSE_WCHAR_T 0 +# endif +#endif + +#endif // __GNUWIN32__ + +// MFC duplicates these operators +#if wxUSE_MFC +#undef wxUSE_GLOBAL_MEMORY_OPERATORS +#define wxUSE_GLOBAL_MEMORY_OPERATORS 0 + +#undef wxUSE_DEBUG_NEW_ALWAYS +#define wxUSE_DEBUG_NEW_ALWAYS 0 +#endif // wxUSE_MFC + +#if (!defined(WIN32) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !wxUSE_NORLANDER_HEADERS) +// Can't use OLE drag and drop in Windows 3.1 because we don't know how +// to implement UUIDs +// GnuWin32 doesn't have appropriate headers for e.g. IUnknown. +#undef wxUSE_DRAG_AND_DROP +#define wxUSE_DRAG_AND_DROP 0 +#endif + +// Only WIN32 supports wxStatusBar95 +#if !defined(__WIN32__) && wxUSE_NATIVE_STATUSBAR +#undef wxUSE_NATIVE_STATUSBAR +#define wxUSE_NATIVE_STATUSBAR 0 +#endif + +#if !wxUSE_OWNER_DRAWN +#undef wxUSE_CHECKLISTBOX +#define wxUSE_CHECKLISTBOX 0 +#endif + +// Salford C++ doesn't like some of the memory operator definitions +#ifdef __SALFORDC__ +#undef wxUSE_MEMORY_TRACING +#define wxUSE_MEMORY_TRACING 0 + +#undef wxUSE_GLOBAL_MEMORY_OPERATORS +#define wxUSE_GLOBAL_MEMORY_OPERATORS 0 + +#undef wxUSE_DEBUG_NEW_ALWAYS +#define wxUSE_DEBUG_NEW_ALWAYS 0 + +#undef wxUSE_THREADS +#define wxUSE_THREADS 0 + +#undef wxUSE_OWNER_DRAWN +#define wxUSE_OWNER_DRAWN 0 +#endif // __SALFORDC__ + +#ifdef __TWIN32__ + +#undef wxUSE_THREADS +#define wxUSE_THREADS 0 + +#undef wxUSE_ODBC +#define wxUSE_ODBC 0 + +#endif // __TWIN32__ + +// BC++/Win16 can't cope with the amount of data in resource.cpp +#if defined(__WIN16__) && defined(__BORLANDC__) +#undef wxUSE_WX_RESOURCES +#define wxUSE_WX_RESOURCES 0 + +#undef wxUSE_ODBC +#define wxUSE_ODBC 0 + +#undef wxUSE_NEW_GRID +#define wxUSE_NEW_GRID 0 +#endif + +#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +// BC++ 4.0 can't compile JPEG library +#undef wxUSE_LIBJPEG +#define wxUSE_LIBJPEG 0 +#endif + +// wxUSE_DEBUG_NEW_ALWAYS = 1 not compatible with BC++ in DLL mode +#if defined(__BORLANDC__) && (defined(WXMAKINGDLL) || defined(WXUSINGDLL)) +#undef wxUSE_DEBUG_NEW_ALWAYS +#define wxUSE_DEBUG_NEW_ALWAYS 0 +#endif + +#if defined(__WXMSW__) && defined(__WATCOMC__) +/* +#undef wxUSE_GLCANVAS +#define wxUSE_GLCANVAS 0 +*/ + +#undef wxUSE_WCHAR_T +#define wxUSE_WCHAR_T 0 +#endif + +#if defined(__WXMSW__) && !defined(__WIN32__) + +#undef wxUSE_SOCKETS +#define wxUSE_SOCKETS 0 + +#undef wxUSE_THREADS +#define wxUSE_THREADS 0 + +#undef wxUSE_TOOLTIPS +#define wxUSE_TOOLTIPS 0 + +#undef wxUSE_SPINCTRL +#define wxUSE_SPINCTRL 0 + +#undef wxUSE_SPINBTN +#define wxUSE_SPINBTN 0 + +#undef wxUSE_LIBPNG +#define wxUSE_LIBPNG 0 + +#undef wxUSE_LIBJPEG +#define wxUSE_LIBJPEG 0 + +#undef wxUSE_LIBTIFF +#define wxUSE_LIBTIFF 0 + +#undef wxUSE_GIF +#define wxUSE_GIF 0 + +#undef wxUSE_PNM +#define wxUSE_PNM 0 + +#undef wxUSE_PCX +#define wxUSE_PCX 0 + +#undef wxUSE_GLCANVAS +#define wxUSE_GLCANVAS 0 + +#undef wxUSE_MS_HTML_HELP +#define wxUSE_MS_HTML_HELP 0 + +#undef wxUSE_WCHAR_T +#define wxUSE_WCHAR_T 0 + +#endif // Win16 + +#endif + // _WX_SETUP_H_ diff --git a/Contrib/NSIS Menu/nsismenu/nsisicon.ico b/Contrib/NSIS Menu/nsismenu/nsisicon.ico new file mode 100644 index 00000000..49194a59 Binary files /dev/null and b/Contrib/NSIS Menu/nsismenu/nsisicon.ico differ diff --git a/Contrib/NSIS Menu/nsismenu/nsismenu.cpp b/Contrib/NSIS Menu/nsismenu/nsismenu.cpp new file mode 100644 index 00000000..f82f1f97 --- /dev/null +++ b/Contrib/NSIS Menu/nsismenu/nsismenu.cpp @@ -0,0 +1,139 @@ +///////////////////////////////////////////////////////////////////////////// +// NSIS MENU +///////////////////////////////////////////////////////////////////////////// + +#if defined(__GNUG__) && !defined(__APPLE__) + #pragma implementation "test.cpp" + #pragma interface "test.cpp" +#endif + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWindows headers +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/image.h" +#include "wx/html/htmlwin.h" +#include "wx/html/htmlproc.h" + +// ---------------------------------------------------------------------------- +// private classes +// ---------------------------------------------------------------------------- + +// Define a new application type, each program should derive a class from wxApp +class MyApp : public wxApp +{ +public: + // override base class virtuals + // ---------------------------- + + // this one is called on application startup and is a good place for the app + // initialization (doing it here and not in the ctor allows to have an error + // return: if OnInit() returns false, the application terminates) + virtual bool OnInit(); +}; + +// Define a new frame type: this is going to be our main frame +class MyFrame : public wxFrame +{ +public: + // ctor(s) + MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); + +private: + wxHtmlWindow *m_Html; + + // any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// IDs for the controls and the menu commands + enum + { + // controls start here (the numbers are, of course, arbitrary) + Minimal_Text = 1000 + }; + +// ---------------------------------------------------------------------------- +// event tables and other macros for wxWindows +// ---------------------------------------------------------------------------- + +// the event tables connect the wxWindows events with the functions (event +// handlers) which process them. It can be also done at run-time, but for the +// simple menu events like this the static method is much simpler. + BEGIN_EVENT_TABLE(MyFrame, wxFrame) + END_EVENT_TABLE() + + // Create a new application object: this macro will allow wxWindows to create + // the application object during program execution (it's better than using a + // static object for many reasons) and also declares the accessor function + // wxGetApp() which will return the reference of the right type (i.e. MyApp and + // not wxApp) + IMPLEMENT_APP(MyApp) + + // ============================================================================ + // implementation + // ============================================================================ + + // ---------------------------------------------------------------------------- + // the application class + // ---------------------------------------------------------------------------- + // `Main program' equivalent: the program execution "starts" here + bool MyApp::OnInit() + { + wxInitAllImageHandlers(); + + // Create the main application window + MyFrame *frame = new MyFrame(_("NSIS Menu"), + wxPoint(50, 50), wxSize(612 + (GetSystemMetrics(SM_CXEDGE) * 2), 353 + GetSystemMetrics(SM_CYSIZE) + (GetSystemMetrics(SM_CXEDGE) * 2))); + + // Show it and tell the application that it's our main window + + frame->Show(TRUE); + SetTopWindow(frame); + + // success: wxApp::OnRun() will be called which will enter the main message + // loop and the application will run. If we returned FALSE here, the + // application would exit immediately. + return TRUE; + } + +// ---------------------------------------------------------------------------- +// main frame +// ---------------------------------------------------------------------------- + + +// frame constructor + MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) + : wxFrame((wxFrame *)NULL, -1, title, pos, size, wxMINIMIZE_BOX | wxSYSTEM_MENU | wxCAPTION, + wxT("nsis_menu")) + { + m_Html = new wxHtmlWindow(this); + m_Html->SetRelatedFrame(this, _("NSIS Menu")); + m_Html->SetBorders(0); + + // Set font size + wxWindow UnitConvert; + wxSize DialogSize(1000, 1000); + DialogSize = UnitConvert.ConvertDialogToPixels(DialogSize); + int fonts[7] = {0, 0, 20000 / (DialogSize.GetWidth()), 25000 / (DialogSize.GetWidth()), 0, 0, 0}; + m_Html->SetFonts("", "", fonts); + + m_Html->LoadPage(wxT("Menu/index.html")); + + this->Centre(wxBOTH); + this->SetIcon(wxICON(nsisicon)); + + } \ No newline at end of file diff --git a/Contrib/NSIS Menu/nsismenu/nsismenu.rc b/Contrib/NSIS Menu/nsismenu/nsismenu.rc new file mode 100644 index 00000000..84931ff0 --- /dev/null +++ b/Contrib/NSIS Menu/nsismenu/nsismenu.rc @@ -0,0 +1,2 @@ +nsisicon ICON "nsisicon.ico" +WXCURSOR_HAND CURSOR DISCARDABLE "wx/msw/hand.cur" \ No newline at end of file diff --git a/Contrib/NSIS Menu/nsismenu/nsismenu.sln b/Contrib/NSIS Menu/nsismenu/nsismenu.sln new file mode 100644 index 00000000..74d3f38d --- /dev/null +++ b/Contrib/NSIS Menu/nsismenu/nsismenu.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nsismenu", "nsismenu.vcproj", "{598BB726-F3FC-43A4-9E39-A1F9AD153F05}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Debug.ActiveCfg = Debug|Win32 + {598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Debug.Build.0 = Debug|Win32 + {598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Release.ActiveCfg = Release|Win32 + {598BB726-F3FC-43A4-9E39-A1F9AD153F05}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Contrib/NSIS Menu/nsismenu/nsismenu.vcproj b/Contrib/NSIS Menu/nsismenu/nsismenu.vcproj new file mode 100644 index 00000000..9e13354c --- /dev/null +++ b/Contrib/NSIS Menu/nsismenu/nsismenu.vcproj @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Contrib/NSIS Menu/nsismenu/resource.h b/Contrib/NSIS Menu/nsismenu/resource.h new file mode 100644 index 00000000..3d5cb9c4 --- /dev/null +++ b/Contrib/NSIS Menu/nsismenu/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by test.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/Contrib/NSIS Menu/src/html/helpctrl.cpp b/Contrib/NSIS Menu/src/html/helpctrl.cpp new file mode 100644 index 00000000..5c56052d --- /dev/null +++ b/Contrib/NSIS Menu/src/html/helpctrl.cpp @@ -0,0 +1,331 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: helpctrl.cpp +// Purpose: wxHtmlHelpController +// Notes: Based on htmlhelp.cpp, implementing a monolithic +// HTML Help controller class, by Vaclav Slavik +// Author: Harm van der Heijden and Vaclav Slavik +// RCS-ID: $Id: helpctrl.cpp,v 1.26.2.3 2002/12/29 05:52:26 RL Exp $ +// Copyright: (c) Harm van der Heijden and Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "helpctrl.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#if wxUSE_WXHTML_HELP + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/intl.h" +#endif // WX_PRECOMP + +#include "wx/html/helpctrl.h" +#include "wx/busyinfo.h" + +#ifdef __WXGTK__ + // for the hack in AddGrabIfNeeded() + #include "wx/dialog.h" +#endif // __WXGTK__ + +#if wxUSE_HELP + #include "wx/tipwin.h" +#endif + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxHelpControllerBase) + +wxHtmlHelpController::wxHtmlHelpController(int style) +{ + m_helpFrame = NULL; + m_Config = NULL; + m_ConfigRoot = wxEmptyString; + m_titleFormat = _("Help: %s"); + m_FrameStyle = style; +} + +wxHtmlHelpController::~wxHtmlHelpController() +{ + if (m_Config) + WriteCustomization(m_Config, m_ConfigRoot); + if (m_helpFrame) + DestroyHelpWindow(); +} + + +void wxHtmlHelpController::DestroyHelpWindow() +{ + //if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); + if (m_helpFrame) + m_helpFrame->Destroy(); +} + +void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt) +{ + evt.Skip(); + + OnQuit(); + + m_helpFrame->SetController((wxHelpControllerBase*) NULL); + m_helpFrame = NULL; +} + +void wxHtmlHelpController::SetTitleFormat(const wxString& title) +{ + m_titleFormat = title; + if (m_helpFrame) + m_helpFrame->SetTitleFormat(title); +} + + +bool wxHtmlHelpController::AddBook(const wxFileName& book_file, bool show_wait_msg) +{ + return AddBook(wxFileSystem::FileNameToURL(book_file), show_wait_msg); +} + +bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg) +{ + wxBusyCursor cur; +#if wxUSE_BUSYINFO + wxBusyInfo* busy = NULL; + wxString info; + if (show_wait_msg) + { + info.Printf(_("Adding book %s"), book.c_str()); + busy = new wxBusyInfo(info); + } +#endif + bool retval = m_helpData.AddBook(book); +#if wxUSE_BUSYINFO + if (show_wait_msg) + delete busy; +#endif + if (m_helpFrame) + m_helpFrame->RefreshLists(); + return retval; +} + + + +wxHtmlHelpFrame *wxHtmlHelpController::CreateHelpFrame(wxHtmlHelpData *data) +{ + return new wxHtmlHelpFrame(data); +} + + +void wxHtmlHelpController::CreateHelpWindow() +{ + if (m_helpFrame) + { + m_helpFrame->Raise(); + return ; + } + + if (m_Config == NULL) + { + m_Config = wxConfigBase::Get(FALSE); + if (m_Config != NULL) + m_ConfigRoot = _T("wxWindows/wxHtmlHelpController"); + } + + m_helpFrame = CreateHelpFrame(&m_helpData); + m_helpFrame->SetController(this); + + if (m_Config) + m_helpFrame->UseConfig(m_Config, m_ConfigRoot); + + m_helpFrame->Create(NULL, wxID_HTML_HELPFRAME, wxEmptyString, m_FrameStyle); + m_helpFrame->SetTitleFormat(m_titleFormat); + m_helpFrame->Show(TRUE); +} + +void wxHtmlHelpController::ReadCustomization(wxConfigBase* cfg, const wxString& path) +{ + /* should not be called by the user; call UseConfig, and the controller + * will do the rest */ + if (m_helpFrame && cfg) + m_helpFrame->ReadCustomization(cfg, path); +} + +void wxHtmlHelpController::WriteCustomization(wxConfigBase* cfg, const wxString& path) +{ + /* typically called by the controllers OnCloseFrame handler */ + if (m_helpFrame && cfg) + m_helpFrame->WriteCustomization(cfg, path); +} + +void wxHtmlHelpController::UseConfig(wxConfigBase *config, const wxString& rootpath) +{ + m_Config = config; + m_ConfigRoot = rootpath; + if (m_helpFrame) m_helpFrame->UseConfig(config, rootpath); + ReadCustomization(config, rootpath); +} + +//// Backward compatibility with wxHelpController API + +bool wxHtmlHelpController::Initialize(const wxString& file) +{ + wxString dir, filename, ext; + wxSplitPath(file, & dir, & filename, & ext); + + if (!dir.IsEmpty()) + dir = dir + wxFILE_SEP_PATH; + + // Try to find a suitable file + wxString actualFilename = dir + filename + wxString(wxT(".zip")); + if (!wxFileExists(actualFilename)) + { + actualFilename = dir + filename + wxString(wxT(".htb")); + if (!wxFileExists(actualFilename)) + { + actualFilename = dir + filename + wxString(wxT(".hhp")); + if (!wxFileExists(actualFilename)) + return FALSE; + } + } + + return AddBook(wxFileName(actualFilename)); +} + +bool wxHtmlHelpController::LoadFile(const wxString& WXUNUSED(file)) +{ + // Don't reload the file or we'll have it appear again, presumably. + return TRUE; +} + +bool wxHtmlHelpController::DisplaySection(int sectionNo) +{ + return Display(sectionNo); +} + +bool wxHtmlHelpController::DisplayTextPopup(const wxString& text, const wxPoint& WXUNUSED(pos)) +{ +#if wxUSE_TIPWINDOW + static wxTipWindow* s_tipWindow = NULL; + + if (s_tipWindow) + { + // Prevent s_tipWindow being nulled in OnIdle, + // thereby removing the chance for the window to be closed by ShowHelp + s_tipWindow->SetTipWindowPtr(NULL); + s_tipWindow->Close(); + } + s_tipWindow = NULL; + + if ( !text.empty() ) + { + s_tipWindow = new wxTipWindow(wxTheApp->GetTopWindow(), text, 100, & s_tipWindow); + + return TRUE; + } +#endif // wxUSE_TIPWINDOW + + return FALSE; +} + +void wxHtmlHelpController::SetFrameParameters(const wxString& title, + const wxSize& size, + const wxPoint& pos, + bool WXUNUSED(newFrameEachTime)) +{ + SetTitleFormat(title); + if (m_helpFrame) + { + m_helpFrame->SetSize(pos.x, pos.y, size.x, size.y); + } +} + +wxFrame* wxHtmlHelpController::GetFrameParameters(wxSize *size, + wxPoint *pos, + bool *newFrameEachTime) +{ + if (newFrameEachTime) + (* newFrameEachTime) = FALSE; + if (size && m_helpFrame) + (* size) = m_helpFrame->GetSize(); + if (pos && m_helpFrame) + (* pos) = m_helpFrame->GetPosition(); + return m_helpFrame; +} + +bool wxHtmlHelpController::Quit() +{ + DestroyHelpWindow(); + return TRUE; +} + +// Make the help controller's frame 'modal' if +// needed +void wxHtmlHelpController::AddGrabIfNeeded() +{ + // So far, wxGTK only +#ifdef __WXGTK__ + bool needGrab = FALSE; + + // Check if there are any modal windows present, + // in which case we need to add a grab. + for ( wxWindowList::Node * node = wxTopLevelWindows.GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow *win = node->GetData(); + wxDialog *dialog = wxDynamicCast(win, wxDialog); + + if (dialog && dialog->IsModal()) + needGrab = TRUE; + } + + if (needGrab && m_helpFrame) + m_helpFrame->AddGrab(); +#endif // __WXGTK__ +} + +bool wxHtmlHelpController::Display(const wxString& x) +{ + CreateHelpWindow(); + bool success = m_helpFrame->Display(x); + AddGrabIfNeeded(); + return success; +} + +bool wxHtmlHelpController::Display(int id) +{ + CreateHelpWindow(); + bool success = m_helpFrame->Display(id); + AddGrabIfNeeded(); + return success; +} + +bool wxHtmlHelpController::DisplayContents() +{ + CreateHelpWindow(); + bool success = m_helpFrame->DisplayContents(); + AddGrabIfNeeded(); + return success; +} + +bool wxHtmlHelpController::DisplayIndex() +{ + CreateHelpWindow(); + bool success = m_helpFrame->DisplayIndex(); + AddGrabIfNeeded(); + return success; +} + +bool wxHtmlHelpController::KeywordSearch(const wxString& keyword) +{ + CreateHelpWindow(); + bool success = m_helpFrame->KeywordSearch(keyword); + AddGrabIfNeeded(); + return success; +} + +#endif // wxUSE_WXHTML_HELP + diff --git a/Contrib/NSIS Menu/src/html/helpdata.cpp b/Contrib/NSIS Menu/src/html/helpdata.cpp new file mode 100644 index 00000000..f393a994 --- /dev/null +++ b/Contrib/NSIS Menu/src/html/helpdata.cpp @@ -0,0 +1,866 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: helpdata.cpp +// Purpose: wxHtmlHelpData +// Notes: Based on htmlhelp.cpp, implementing a monolithic +// HTML Help controller class, by Vaclav Slavik +// Author: Harm van der Heijden and Vaclav Slavik +// RCS-ID: $Id: helpdata.cpp,v 1.59.2.5 2002/12/16 10:23:20 JS Exp $ +// Copyright: (c) Harm van der Heijden and Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "helpdata.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#include "wx/defs.h" + +#if wxUSE_HTML && wxUSE_STREAMS + +#ifndef WXPRECOMP + #include "wx/intl.h" + #include "wx/log.h" +#endif + +#include + +#include "wx/html/helpdata.h" +#include "wx/tokenzr.h" +#include "wx/wfstream.h" +#include "wx/busyinfo.h" +#include "wx/encconv.h" +#include "wx/fontmap.h" +#include "wx/log.h" +#include "wx/html/htmlpars.h" +#include "wx/html/htmldefs.h" +#include "wx/html/htmlfilt.h" +#include "wx/filename.h" + +#include "wx/arrimpl.cpp" +WX_DEFINE_OBJARRAY(wxHtmlBookRecArray) + +//----------------------------------------------------------------------------- +// static helper functions +//----------------------------------------------------------------------------- + +// Reads one line, stores it into buf and returns pointer to new line or NULL. +static const wxChar* ReadLine(const wxChar *line, wxChar *buf, size_t bufsize) +{ + wxChar *writeptr = buf; + wxChar *endptr = buf + bufsize - 1; + const wxChar *readptr = line; + + while (*readptr != 0 && *readptr != _T('\r') && *readptr != _T('\n') && + writeptr != endptr) + *(writeptr++) = *(readptr++); + *writeptr = 0; + while (*readptr == _T('\r') || *readptr == _T('\n')) + readptr++; + if (*readptr == 0) + return NULL; + else + return readptr; +} + + + +extern "C" int LINKAGEMODE +wxHtmlHelpIndexCompareFunc(const void *a, const void *b) +{ + return wxStricmp(((wxHtmlContentsItem*)a)->m_Name, ((wxHtmlContentsItem*)b)->m_Name); +} + + +//----------------------------------------------------------------------------- +// HP_Parser +//----------------------------------------------------------------------------- + +class HP_Parser : public wxHtmlParser +{ +public: + wxObject* GetProduct() { return NULL; } +protected: + virtual void AddText(const wxChar* WXUNUSED(txt)) {} +}; + + +//----------------------------------------------------------------------------- +// HP_TagHandler +//----------------------------------------------------------------------------- + +class HP_TagHandler : public wxHtmlTagHandler +{ + private: + wxString m_Name, m_Page; + int m_Level; + int m_ID; + int m_Index; + wxHtmlContentsItem *m_Items; + int m_ItemsCnt; + wxHtmlBookRecord *m_Book; + + public: + HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() + { m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; + m_Level = 0; m_ID = -1; } + wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); } + bool HandleTag(const wxHtmlTag& tag); + void WriteOut(wxHtmlContentsItem*& array, int& size); + void ReadIn(wxHtmlContentsItem* array, int size); +}; + + +bool HP_TagHandler::HandleTag(const wxHtmlTag& tag) +{ + if (tag.GetName() == wxT("UL")) + { + m_Level++; + ParseInner(tag); + m_Level--; + return TRUE; + } + else if (tag.GetName() == wxT("OBJECT")) + { + m_Name = m_Page = wxEmptyString; + ParseInner(tag); + +#if 0 + if (!m_Page.IsEmpty()) + /* Valid HHW's file may contain only two object tags: + + + + + + or + + + + + + + We're interested in the latter. !m_Page.IsEmpty() is valid + condition because text/site properties does not contain Local param + */ +#endif + if (tag.GetParam(wxT("TYPE")) == wxT("text/sitemap")) + { + if (m_ItemsCnt % wxHTML_REALLOC_STEP == 0) + m_Items = (wxHtmlContentsItem*) realloc(m_Items, + (m_ItemsCnt + wxHTML_REALLOC_STEP) * + sizeof(wxHtmlContentsItem)); + + m_Items[m_ItemsCnt].m_Level = m_Level; + m_Items[m_ItemsCnt].m_ID = m_ID; + m_Items[m_ItemsCnt].m_Page = new wxChar[m_Page.Length() + 1]; + wxStrcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str()); + m_Items[m_ItemsCnt].m_Name = new wxChar [m_Name.Length() + 1]; + wxStrcpy(m_Items[m_ItemsCnt].m_Name, m_Name.c_str()); + m_Items[m_ItemsCnt].m_Book = m_Book; + m_ItemsCnt++; + } + + return TRUE; + } + else + { // "PARAM" + if (m_Name == wxEmptyString && tag.GetParam(wxT("NAME")) == wxT("Name")) + m_Name = tag.GetParam(wxT("VALUE")); + if (tag.GetParam(wxT("NAME")) == wxT("Local")) + m_Page = tag.GetParam(wxT("VALUE")); + if (tag.GetParam(wxT("NAME")) == wxT("ID")) + tag.GetParamAsInt(wxT("VALUE"), &m_ID); + return FALSE; + } +} + + + +void HP_TagHandler::WriteOut(wxHtmlContentsItem*& array, int& size) +{ + array = m_Items; + size = m_ItemsCnt; + m_Items = NULL; + m_ItemsCnt = 0; +} + +void HP_TagHandler::ReadIn(wxHtmlContentsItem* array, int size) +{ + m_Items = array; + m_ItemsCnt = size; +} + + + + +//----------------------------------------------------------------------------- +// wxHtmlHelpData +//----------------------------------------------------------------------------- + +wxString wxHtmlBookRecord::GetFullPath(const wxString &page) const +{ + if (wxIsAbsolutePath(page)) + return page; + else + return m_BasePath + page; +} + + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpData, wxObject) + +wxHtmlHelpData::wxHtmlHelpData() +{ + m_TempPath = wxEmptyString; + + m_Contents = NULL; + m_ContentsCnt = 0; + m_Index = NULL; + m_IndexCnt = 0; +} + +wxHtmlHelpData::~wxHtmlHelpData() +{ + int i; + + m_BookRecords.Empty(); + if (m_Contents) + { + for (i = 0; i < m_ContentsCnt; i++) + { + delete[] m_Contents[i].m_Page; + delete[] m_Contents[i].m_Name; + } + free(m_Contents); + } + if (m_Index) + { + for (i = 0; i < m_IndexCnt; i++) + { + delete[] m_Index[i].m_Page; + delete[] m_Index[i].m_Name; + } + free(m_Index); + } +} + +bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, const wxString& indexfile, const wxString& contentsfile) +{ + wxFSFile *f; + wxHtmlFilterHTML filter; + wxString buf; + wxString string; + + HP_Parser parser; + HP_TagHandler *handler = new HP_TagHandler(book); + parser.AddTagHandler(handler); + + f = ( contentsfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(contentsfile) ); + if (f) + { + buf.clear(); + buf = filter.ReadFile(*f); + delete f; + handler->ReadIn(m_Contents, m_ContentsCnt); + parser.Parse(buf); + handler->WriteOut(m_Contents, m_ContentsCnt); + } + else + { + wxLogError(_("Cannot open contents file: %s"), contentsfile.c_str()); + } + + f = ( indexfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(indexfile) ); + if (f) + { + buf.clear(); + buf = filter.ReadFile(*f); + delete f; + handler->ReadIn(m_Index, m_IndexCnt); + parser.Parse(buf); + handler->WriteOut(m_Index, m_IndexCnt); + } + else if (!indexfile.IsEmpty()) + { + wxLogError(_("Cannot open index file: %s"), indexfile.c_str()); + } + return TRUE; +} + + + +inline static void CacheWriteInt32(wxOutputStream *f, wxInt32 value) +{ + wxInt32 x = wxINT32_SWAP_ON_BE(value); + f->Write(&x, sizeof(x)); +} + +inline static wxInt32 CacheReadInt32(wxInputStream *f) +{ + wxInt32 x; + f->Read(&x, sizeof(x)); + return wxINT32_SWAP_ON_BE(x); +} + +inline static void CacheWriteString(wxOutputStream *f, const wxChar *str) +{ +#if wxUSE_UNICODE + wxWX2MBbuf mbstr(wxConvUTF8.cWX2MB(str)); +#else + const wxChar *mbstr = str; +#endif + size_t len = strlen(mbstr)+1; + CacheWriteInt32(f, len); + f->Write(mbstr, len); +} + +inline static wxChar* CacheReadString(wxInputStream *f) +{ + char *str; + size_t len = (size_t)CacheReadInt32(f); + str = new char[len]; + f->Read(str, len); +#if !wxUSE_UNICODE + return str; +#else + wxMB2WXbuf wxstr(wxConvUTF8.cMB2WX(str)); + wxChar *outstr = new wxChar[wxStrlen(wxstr)+1]; + wxStrcpy(outstr, wxstr); + return outstr; +#endif +} + +#define CURRENT_CACHED_BOOK_VERSION 3 + +bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f) +{ + int i, st; + wxInt32 version; + + /* load header - version info : */ + version = CacheReadInt32(f); + + if (version != CURRENT_CACHED_BOOK_VERSION) + { + // NB: We can just silently return FALSE here and don't worry about + // it anymore, because AddBookParam will load the MS project in + // absence of (properly versioned) .cached file and automatically + // create new .cached file immediately afterward. + return FALSE; + } + + /* load contents : */ + st = m_ContentsCnt; + m_ContentsCnt += CacheReadInt32(f); + m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, + (m_ContentsCnt / wxHTML_REALLOC_STEP + 1) * + wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem)); + for (i = st; i < m_ContentsCnt; i++) + { + m_Contents[i].m_Level = CacheReadInt32(f); + m_Contents[i].m_ID = CacheReadInt32(f); + m_Contents[i].m_Name = CacheReadString(f); + m_Contents[i].m_Page = CacheReadString(f); + m_Contents[i].m_Book = book; + } + + /* load index : */ + st = m_IndexCnt; + m_IndexCnt += CacheReadInt32(f); + m_Index = (wxHtmlContentsItem*) realloc(m_Index, (m_IndexCnt / wxHTML_REALLOC_STEP + 1) * + wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem)); + for (i = st; i < m_IndexCnt; i++) + { + m_Index[i].m_Name = CacheReadString(f); + m_Index[i].m_Page = CacheReadString(f); + m_Index[i].m_Book = book; + } + return TRUE; +} + + +bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f) +{ + int i; + wxInt32 cnt; + + /* save header - version info : */ + CacheWriteInt32(f, CURRENT_CACHED_BOOK_VERSION); + + /* save contents : */ + for (cnt = 0, i = 0; i < m_ContentsCnt; i++) + if (m_Contents[i].m_Book == book && m_Contents[i].m_Level > 0) + cnt++; + CacheWriteInt32(f, cnt); + + for (i = 0; i < m_ContentsCnt; i++) + { + if (m_Contents[i].m_Book != book || m_Contents[i].m_Level == 0) + continue; + CacheWriteInt32(f, m_Contents[i].m_Level); + CacheWriteInt32(f, m_Contents[i].m_ID); + CacheWriteString(f, m_Contents[i].m_Name); + CacheWriteString(f, m_Contents[i].m_Page); + } + + /* save index : */ + for (cnt = 0, i = 0; i < m_IndexCnt; i++) + if (m_Index[i].m_Book == book && m_Index[i].m_Level > 0) + cnt++; + CacheWriteInt32(f, cnt); + + for (i = 0; i < m_IndexCnt; i++) + { + if (m_Index[i].m_Book != book || m_Index[i].m_Level == 0) + continue; + CacheWriteString(f, m_Index[i].m_Name); + CacheWriteString(f, m_Index[i].m_Page); + } + return TRUE; +} + + +void wxHtmlHelpData::SetTempDir(const wxString& path) +{ + if (path == wxEmptyString) m_TempPath = path; + else + { + if (wxIsAbsolutePath(path)) m_TempPath = path; + else m_TempPath = wxGetCwd() + _T("/") + path; + + if (m_TempPath[m_TempPath.Length() - 1] != _T('/')) + m_TempPath << _T('/'); + } +} + + + +static wxString SafeFileName(const wxString& s) +{ + wxString res(s); + res.Replace(wxT("#"), wxT("_")); + res.Replace(wxT(":"), wxT("_")); + res.Replace(wxT("\\"), wxT("_")); + res.Replace(wxT("/"), wxT("_")); + return res; +} + +bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, + wxFontEncoding encoding, + const wxString& title, const wxString& contfile, + const wxString& indexfile, const wxString& deftopic, + const wxString& path) +{ + wxFileSystem fsys; + wxFSFile *fi; + wxHtmlBookRecord *bookr; + + int IndexOld = m_IndexCnt, + ContentsOld = m_ContentsCnt; + + if (!path.IsEmpty()) + fsys.ChangePathTo(path, TRUE); + + size_t booksCnt = m_BookRecords.GetCount(); + for (size_t i = 0; i < booksCnt; i++) + { + if ( m_BookRecords[i].GetBookFile() == bookfile.GetLocation() ) + return TRUE; // book is (was) loaded + } + + bookr = new wxHtmlBookRecord(bookfile.GetLocation(), fsys.GetPath(), title, deftopic); + + if (m_ContentsCnt % wxHTML_REALLOC_STEP == 0) + m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + wxHTML_REALLOC_STEP) * sizeof(wxHtmlContentsItem)); + m_Contents[m_ContentsCnt].m_Level = 0; + m_Contents[m_ContentsCnt].m_ID = 0; + m_Contents[m_ContentsCnt].m_Page = new wxChar[deftopic.Length() + 1]; + wxStrcpy(m_Contents[m_ContentsCnt].m_Page, deftopic.c_str()); + m_Contents[m_ContentsCnt].m_Name = new wxChar [title.Length() + 1]; + wxStrcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str()); + m_Contents[m_ContentsCnt].m_Book = bookr; + + // store the contents index for later + int cont_start = m_ContentsCnt++; + + // Try to find cached binary versions: + // 1. save file as book, but with .hhp.cached extension + // 2. same as 1. but in temp path + // 3. otherwise or if cache load failed, load it from MS. + + fi = fsys.OpenFile(bookfile.GetLocation() + wxT(".cached")); + + if (fi == NULL || + fi->GetModificationTime() < bookfile.GetModificationTime() || + !LoadCachedBook(bookr, fi->GetStream())) + { + if (fi != NULL) delete fi; + fi = fsys.OpenFile(m_TempPath + wxFileNameFromPath(bookfile.GetLocation()) + wxT(".cached")); + if (m_TempPath == wxEmptyString || fi == NULL || + fi->GetModificationTime() < bookfile.GetModificationTime() || + !LoadCachedBook(bookr, fi->GetStream())) + { + LoadMSProject(bookr, fsys, indexfile, contfile); + if (m_TempPath != wxEmptyString) + { + wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + + SafeFileName(wxFileNameFromPath(bookfile.GetLocation())) + wxT(".cached")); + SaveCachedBook(bookr, outs); + delete outs; + } + } + } + + if (fi != NULL) delete fi; + + // Now store the contents range + bookr->SetContentsRange(cont_start, m_ContentsCnt); + + // Convert encoding, if neccessary: + if (encoding != wxFONTENCODING_SYSTEM) + { + wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(encoding); + if (a.GetCount() != 0 && a[0] != encoding) + { + int i; + wxEncodingConverter conv; + conv.Init(encoding, a[0]); + + for (i = IndexOld; i < m_IndexCnt; i++) + conv.Convert(m_Index[i].m_Name); + for (i = ContentsOld; i < m_ContentsCnt; i++) + conv.Convert(m_Contents[i].m_Name); + } + } + + m_BookRecords.Add(bookr); + if (m_IndexCnt > 0) + qsort(m_Index, m_IndexCnt, sizeof(wxHtmlContentsItem), wxHtmlHelpIndexCompareFunc); + + return TRUE; +} + + +bool wxHtmlHelpData::AddBook(const wxString& book) +{ + if (book.Right(4).Lower() == wxT(".zip") || + book.Right(4).Lower() == wxT(".htb") /*html book*/) + { + wxFileSystem fsys; + wxString s; + bool rt = FALSE; + + s = fsys.FindFirst(book + wxT("#zip:") + wxT("*.hhp"), wxFILE); + while (!s.IsEmpty()) + { + if (AddBook(s)) rt = TRUE; + s = fsys.FindNext(); + } + + return rt; + } + else + { + wxFSFile *fi; + wxFileSystem fsys; + + wxString title = _("noname"), + safetitle, + start = wxEmptyString, + contents = wxEmptyString, + index = wxEmptyString, + charset = wxEmptyString; + + fi = fsys.OpenFile(book); + if (fi == NULL) + { + wxLogError(_("Cannot open HTML help book: %s"), book.c_str()); + return FALSE; + } + fsys.ChangePathTo(book); + + const wxChar *lineptr; + wxChar linebuf[300]; + wxString tmp; + wxHtmlFilterPlainText filter; + tmp = filter.ReadFile(*fi); + lineptr = tmp.c_str(); + + do + { + lineptr = ReadLine(lineptr, linebuf, 300); + + for (wxChar *ch = linebuf; *ch != wxT('\0') && *ch != wxT('='); ch++) + *ch = tolower(*ch); + + if (wxStrstr(linebuf, _T("title=")) == linebuf) + title = linebuf + wxStrlen(_T("title=")); + if (wxStrstr(linebuf, _T("default topic=")) == linebuf) + start = linebuf + wxStrlen(_T("default topic=")); + if (wxStrstr(linebuf, _T("index file=")) == linebuf) + index = linebuf + wxStrlen(_T("index file=")); + if (wxStrstr(linebuf, _T("contents file=")) == linebuf) + contents = linebuf + wxStrlen(_T("contents file=")); + if (wxStrstr(linebuf, _T("charset=")) == linebuf) + charset = linebuf + wxStrlen(_T("charset=")); + } while (lineptr != NULL); + + wxFontEncoding enc; + if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM; + else enc = wxFontMapper::Get()->CharsetToEncoding(charset); + bool rtval = AddBookParam(*fi, enc, + title, contents, index, start, fsys.GetPath()); + delete fi; + return rtval; + } +} + +wxString wxHtmlHelpData::FindPageByName(const wxString& x) +{ + int cnt; + int i; + wxFileSystem fsys; + wxFSFile *f; + wxString url(wxEmptyString); + + /* 1. try to open given file: */ + + cnt = m_BookRecords.GetCount(); + for (i = 0; i < cnt; i++) + { + f = fsys.OpenFile(m_BookRecords[i].GetFullPath(x)); + if (f) + { + url = m_BookRecords[i].GetFullPath(x); + delete f; + return url; + } + } + + + /* 2. try to find a book: */ + + for (i = 0; i < cnt; i++) + { + if (m_BookRecords[i].GetTitle() == x) + { + url = m_BookRecords[i].GetFullPath(m_BookRecords[i].GetStart()); + return url; + } + } + + /* 3. try to find in contents: */ + + cnt = m_ContentsCnt; + for (i = 0; i < cnt; i++) + { + if (wxStrcmp(m_Contents[i].m_Name, x) == 0) + { + url = m_Contents[i].GetFullPath(); + return url; + } + } + + + /* 4. try to find in index: */ + + cnt = m_IndexCnt; + for (i = 0; i < cnt; i++) + { + if (wxStrcmp(m_Index[i].m_Name, x) == 0) + { + url = m_Index[i].GetFullPath(); + return url; + } + } + + return url; +} + +wxString wxHtmlHelpData::FindPageById(int id) +{ + int i; + wxString url(wxEmptyString); + + for (i = 0; i < m_ContentsCnt; i++) + { + if (m_Contents[i].m_ID == id) + { + url = m_Contents[i].GetFullPath(); + return url; + } + } + + return url; +} + +//---------------------------------------------------------------------------------- +// wxHtmlSearchStatus functions +//---------------------------------------------------------------------------------- + +wxHtmlSearchStatus::wxHtmlSearchStatus(wxHtmlHelpData* data, const wxString& keyword, + bool case_sensitive, bool whole_words_only, + const wxString& book) +{ + m_Data = data; + m_Keyword = keyword; + wxHtmlBookRecord* bookr = NULL; + if (book != wxEmptyString) + { + // we have to search in a specific book. Find it first + int i, cnt = data->m_BookRecords.GetCount(); + for (i = 0; i < cnt; i++) + if (data->m_BookRecords[i].GetTitle() == book) + { + bookr = &(data->m_BookRecords[i]); + m_CurIndex = bookr->GetContentsStart(); + m_MaxIndex = bookr->GetContentsEnd(); + break; + } + // check; we won't crash if the book doesn't exist, but it's Bad Anyway. + wxASSERT(bookr); + } + if (! bookr) + { + // no book specified; search all books + m_CurIndex = 0; + m_MaxIndex = m_Data->m_ContentsCnt; + } + m_Engine.LookFor(keyword, case_sensitive, whole_words_only); + m_Active = (m_CurIndex < m_MaxIndex); + m_LastPage = NULL; +} + +bool wxHtmlSearchStatus::Search() +{ + wxFSFile *file; + int i = m_CurIndex; // shortcut + bool found = FALSE; + wxChar *thepage; + + if (!m_Active) + { + // sanity check. Illegal use, but we'll try to prevent a crash anyway + wxASSERT(m_Active); + return FALSE; + } + + m_Name = wxEmptyString; + m_ContentsItem = NULL; + thepage = m_Data->m_Contents[i].m_Page; + + m_Active = (++m_CurIndex < m_MaxIndex); + // check if it is same page with different anchor: + if (m_LastPage != NULL) + { + wxChar *p1, *p2; + for (p1 = thepage, p2 = m_LastPage; + *p1 != 0 && *p1 != _T('#') && *p1 == *p2; p1++, p2++) {} + + m_LastPage = thepage; + + if (*p1 == 0 || *p1 == _T('#')) + return FALSE; + } + else m_LastPage = thepage; + + wxFileSystem fsys; + file = fsys.OpenFile(m_Data->m_Contents[i].m_Book->GetFullPath(thepage)); + if (file) + { + if (m_Engine.Scan(*file)) + { + m_Name = m_Data->m_Contents[i].m_Name; + m_ContentsItem = m_Data->m_Contents + i; + found = TRUE; + } + delete file; + } + return found; +} + + + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlSearchEngine +//-------------------------------------------------------------------------------- + +void wxHtmlSearchEngine::LookFor(const wxString& keyword, bool case_sensitive, bool whole_words_only) +{ + m_CaseSensitive = case_sensitive; + m_WholeWords = whole_words_only; + if (m_Keyword) delete[] m_Keyword; + m_Keyword = new wxChar[keyword.Length() + 1]; + wxStrcpy(m_Keyword, keyword.c_str()); + + if (!m_CaseSensitive) + { + for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--) + { + if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z'))) + m_Keyword[i] += wxT('a') - wxT('A'); + } + } +} + + +static inline bool WHITESPACE(wxChar c) +{ + return c == _T(' ') || c == _T('\n') || c == _T('\r') || c == _T('\t'); +} + +bool wxHtmlSearchEngine::Scan(const wxFSFile& file) +{ + wxASSERT_MSG(m_Keyword != NULL, wxT("wxHtmlSearchEngine::LookFor must be called before scanning!")); + + int i, j; + int wrd = wxStrlen(m_Keyword); + bool found = FALSE; + wxHtmlFilterHTML filter; + wxString tmp = filter.ReadFile(file); + int lng = tmp.length(); + const wxChar *buf = tmp.c_str(); + + if (!m_CaseSensitive) + for (i = 0; i < lng; i++) + tmp[(size_t)i] = (wxChar)wxTolower(tmp[(size_t)i]); + + if (m_WholeWords) + { + for (i = 0; i < lng - wrd; i++) + { + if (WHITESPACE(buf[i])) continue; + j = 0; + while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++; + if (j == wrd && WHITESPACE(buf[i + j])) { found = TRUE; break; } + } + } + + else + { + for (i = 0; i < lng - wrd; i++) + { + j = 0; + while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++; + if (j == wrd) { found = TRUE; break; } + } + } + + return found; +} + + + +#endif diff --git a/Contrib/NSIS Menu/src/html/helpfrm.cpp b/Contrib/NSIS Menu/src/html/helpfrm.cpp new file mode 100644 index 00000000..26a4c91d --- /dev/null +++ b/Contrib/NSIS Menu/src/html/helpfrm.cpp @@ -0,0 +1,1515 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: helpfrm.cpp +// Purpose: wxHtmlHelpFrame +// Notes: Based on htmlhelp.cpp, implementing a monolithic +// HTML Help controller class, by Vaclav Slavik +// Author: Harm van der Heijden and Vaclav Slavik +// RCS-ID: $Id: helpfrm.cpp,v 1.72.2.3 2002/12/16 10:23:20 JS Exp $ +// Copyright: (c) Harm van der Heijden and Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "helpfrm.h" +#endif + +// For compilers that support precompilation, includes "wx.h" + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#if wxUSE_WXHTML_HELP + +#ifndef WXPRECOMP + #include "wx/intl.h" + #include "wx/log.h" + + #include "wx/object.h" + #include "wx/sizer.h" + + #include "wx/bmpbuttn.h" + #include "wx/statbox.h" + #include "wx/radiobox.h" +#endif // WXPRECOMP + +#include "wx/html/helpfrm.h" +#include "wx/html/helpctrl.h" +#include "wx/textctrl.h" +#include "wx/notebook.h" +#include "wx/imaglist.h" +#include "wx/treectrl.h" +#include "wx/tokenzr.h" +#include "wx/wfstream.h" +#include "wx/html/htmlwin.h" +#include "wx/busyinfo.h" +#include "wx/progdlg.h" +#include "wx/toolbar.h" +#include "wx/fontenum.h" +#include "wx/stream.h" +#include "wx/filedlg.h" +#include "wx/artprov.h" +#include "wx/spinctrl.h" + +// what is considered "small index"? +#define INDEX_IS_SMALL 100 + +/* Motif defines this as a macro */ +#ifdef Below +#undef Below +#endif + +//-------------------------------------------------------------------------- +// wxHtmlHelpTreeItemData (private) +//-------------------------------------------------------------------------- + +class wxHtmlHelpTreeItemData : public wxTreeItemData +{ + public: +#if defined(__VISAGECPP__) +// VA needs a default ctor for some reason.... + wxHtmlHelpTreeItemData() : wxTreeItemData() + { m_Id = 0; } +#endif + wxHtmlHelpTreeItemData(int id) : wxTreeItemData() + { m_Id = id;} + + int m_Id; +}; + + +//-------------------------------------------------------------------------- +// wxHtmlHelpHashData (private) +//-------------------------------------------------------------------------- + +class wxHtmlHelpHashData : public wxObject +{ + public: + wxHtmlHelpHashData(int index, wxTreeItemId id) : wxObject() + { m_Index = index; m_Id = id;} + ~wxHtmlHelpHashData() {} + + int m_Index; + wxTreeItemId m_Id; +}; + + +//-------------------------------------------------------------------------- +// wxHtmlHelpHtmlWindow (private) +//-------------------------------------------------------------------------- + +class wxHtmlHelpHtmlWindow : public wxHtmlWindow +{ + public: + wxHtmlHelpHtmlWindow(wxHtmlHelpFrame *fr, wxWindow *parent) : wxHtmlWindow(parent), m_Frame(fr) {} + + virtual void OnLinkClicked(const wxHtmlLinkInfo& link) + { + wxHtmlWindow::OnLinkClicked(link); + m_Frame->NotifyPageChanged(); + } + + private: + wxHtmlHelpFrame *m_Frame; +}; + + + +//--------------------------------------------------------------------------- +// wxHtmlHelpFrame +//--------------------------------------------------------------------------- + +// Command IDs : +enum +{ + //wxID_HTML_HELPFRAME = wxID_HIGHEST + 1, + wxID_HTML_PANEL = wxID_HIGHEST + 2, + wxID_HTML_BACK, + wxID_HTML_FORWARD, + wxID_HTML_UPNODE, + wxID_HTML_UP, + wxID_HTML_DOWN, + wxID_HTML_PRINT, + wxID_HTML_OPENFILE, + wxID_HTML_OPTIONS, + wxID_HTML_BOOKMARKSLIST, + wxID_HTML_BOOKMARKSADD, + wxID_HTML_BOOKMARKSREMOVE, + wxID_HTML_TREECTRL, + wxID_HTML_INDEXPAGE, + wxID_HTML_INDEXLIST, + wxID_HTML_INDEXTEXT, + wxID_HTML_INDEXBUTTON, + wxID_HTML_INDEXBUTTONALL, + wxID_HTML_NOTEBOOK, + wxID_HTML_SEARCHPAGE, + wxID_HTML_SEARCHTEXT, + wxID_HTML_SEARCHLIST, + wxID_HTML_SEARCHBUTTON, + wxID_HTML_SEARCHCHOICE, + wxID_HTML_COUNTINFO +}; + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpFrame, wxFrame) + +wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow* parent, wxWindowID id, const wxString& title, + int style, wxHtmlHelpData* data) +{ + Init(data); + Create(parent, id, title, style); +} + +void wxHtmlHelpFrame::Init(wxHtmlHelpData* data) +{ + if (data) + { + m_Data = data; + m_DataCreated = FALSE; + } else + { + m_Data = new wxHtmlHelpData(); + m_DataCreated = TRUE; + } + + m_ContentsBox = NULL; + m_IndexList = NULL; + m_IndexButton = NULL; + m_IndexButtonAll = NULL; + m_IndexText = NULL; + m_SearchList = NULL; + m_SearchButton = NULL; + m_SearchText = NULL; + m_SearchChoice = NULL; + m_IndexCountInfo = NULL; + m_Splitter = NULL; + m_NavigPan = NULL; + m_NavigNotebook = NULL; + m_HtmlWin = NULL; + m_Bookmarks = NULL; + m_SearchCaseSensitive = NULL; + m_SearchWholeWords = NULL; + + m_Config = NULL; + m_ConfigRoot = wxEmptyString; + + m_Cfg.x = m_Cfg.y = 0; + m_Cfg.w = 700; + m_Cfg.h = 480; + m_Cfg.sashpos = 240; + m_Cfg.navig_on = TRUE; + + m_NormalFonts = m_FixedFonts = NULL; + m_NormalFace = m_FixedFace = wxEmptyString; +#ifdef __WXMSW__ + m_FontSize = 10; +#else + m_FontSize = 14; +#endif + +#if wxUSE_PRINTING_ARCHITECTURE + m_Printer = NULL; +#endif + + m_PagesHash = NULL; + m_UpdateContents = TRUE; + m_helpController = (wxHelpControllerBase*) NULL; +} + +// Create: builds the GUI components. +// with the style flag it's possible to toggle the toolbar, contents, index and search +// controls. +// m_HtmlWin will *always* be created, but it's important to realize that +// m_ContentsBox, m_IndexList, m_SearchList, m_SearchButton, m_SearchText and +// m_SearchButton may be NULL. +// moreover, if no contents, index or searchpage is needed, m_Splitter and +// m_NavigPan will be NULL too (with m_HtmlWin directly connected to the frame) + +bool wxHtmlHelpFrame::Create(wxWindow* parent, wxWindowID id, + const wxString& WXUNUSED(title), int style) +{ + m_hfStyle = style; + + wxImageList *ContentsImageList = new wxImageList(16, 16); + ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_BOOK, wxART_HELP_BROWSER)); + ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_FOLDER, wxART_HELP_BROWSER)); + ContentsImageList->Add(wxArtProvider::GetIcon(wxART_HELP_PAGE, wxART_HELP_BROWSER)); + + // Do the config in two steps. We read the HtmlWindow customization after we + // create the window. + if (m_Config) + ReadCustomization(m_Config, m_ConfigRoot); + + wxFrame::Create(parent, id, _("Help"), + wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h), + wxDEFAULT_FRAME_STYLE, wxT("wxHtmlHelp")); + + GetPosition(&m_Cfg.x, &m_Cfg.y); + + SetIcon(wxArtProvider::GetIcon(wxART_HELP, wxART_HELP_BROWSER)); + + int notebook_page = 0; + + CreateStatusBar(); + + // toolbar? + if (style & (wxHF_TOOLBAR | wxHF_FLAT_TOOLBAR)) + { + wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | + wxTB_DOCKABLE | + (style & wxHF_FLAT_TOOLBAR ? wxTB_FLAT : 0)); + toolBar->SetMargins( 2, 2 ); + AddToolbarButtons(toolBar, style); + toolBar->Realize(); + } + + wxSizer *navigSizer = NULL; + + if (style & (wxHF_CONTENTS | wxHF_INDEX | wxHF_SEARCH)) + { + // traditional help controller; splitter window with html page on the + // right and a notebook containing various pages on the left + m_Splitter = new wxSplitterWindow(this); + + m_HtmlWin = new wxHtmlHelpHtmlWindow(this, m_Splitter); + m_NavigPan = new wxPanel(m_Splitter, -1); + m_NavigNotebook = new wxNotebook(m_NavigPan, wxID_HTML_NOTEBOOK, + wxDefaultPosition, wxDefaultSize); + wxNotebookSizer *nbs = new wxNotebookSizer(m_NavigNotebook); + + navigSizer = new wxBoxSizer(wxVERTICAL); + navigSizer->Add(nbs, 1, wxEXPAND); + + m_NavigPan->SetAutoLayout(TRUE); + m_NavigPan->SetSizer(navigSizer); + } + else + { // only html window, no notebook with index,contents etc + m_HtmlWin = new wxHtmlWindow(this); + } + + m_HtmlWin->SetRelatedFrame(this, m_TitleFormat); + m_HtmlWin->SetRelatedStatusBar(0); + if ( m_Config ) + m_HtmlWin->ReadCustomization(m_Config, m_ConfigRoot); + + // contents tree panel? + if ( style & wxHF_CONTENTS ) + { + wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); + wxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + + topsizer->Add(0, 10); + + dummy->SetAutoLayout(TRUE); + dummy->SetSizer(topsizer); + + if ( style & wxHF_BOOKMARKS ) + { + m_Bookmarks = new wxComboBox(dummy, wxID_HTML_BOOKMARKSLIST, + wxEmptyString, + wxDefaultPosition, wxDefaultSize, + 0, NULL, wxCB_READONLY | wxCB_SORT); + m_Bookmarks->Append(_("(bookmarks)")); + for (unsigned i = 0; i < m_BookmarksNames.GetCount(); i++) + m_Bookmarks->Append(m_BookmarksNames[i]); + m_Bookmarks->SetSelection(0); + + wxBitmapButton *bmpbt1, *bmpbt2; + bmpbt1 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSADD, + wxArtProvider::GetBitmap(wxART_ADD_BOOKMARK, + wxART_HELP_BROWSER)); + bmpbt2 = new wxBitmapButton(dummy, wxID_HTML_BOOKMARKSREMOVE, + wxArtProvider::GetBitmap(wxART_DEL_BOOKMARK, + wxART_HELP_BROWSER)); +#if wxUSE_TOOLTIPS + bmpbt1->SetToolTip(_("Add current page to bookmarks")); + bmpbt2->SetToolTip(_("Remove current page from bookmarks")); +#endif // wxUSE_TOOLTIPS + + wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL); + + sizer->Add(m_Bookmarks, 1, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 5); + sizer->Add(bmpbt1, 0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 2); + sizer->Add(bmpbt2, 0, wxALIGN_CENTRE_VERTICAL, 0); + + topsizer->Add(sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 10); + } + + m_ContentsBox = new wxTreeCtrl(dummy, wxID_HTML_TREECTRL, + wxDefaultPosition, wxDefaultSize, + wxSUNKEN_BORDER | + wxTR_HAS_BUTTONS | wxTR_HIDE_ROOT | + wxTR_LINES_AT_ROOT); + + m_ContentsBox->AssignImageList(ContentsImageList); + + topsizer->Add(m_ContentsBox, 1, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 2); + + m_NavigNotebook->AddPage(dummy, _("Contents")); + m_ContentsPage = notebook_page++; + } + + // index listbox panel? + if ( style & wxHF_INDEX ) + { + wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); + wxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + + dummy->SetAutoLayout(TRUE); + dummy->SetSizer(topsizer); + + m_IndexText = new wxTextCtrl(dummy, wxID_HTML_INDEXTEXT, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER); + m_IndexButton = new wxButton(dummy, wxID_HTML_INDEXBUTTON, _("Find")); + m_IndexButtonAll = new wxButton(dummy, wxID_HTML_INDEXBUTTONALL, + _("Show all")); + m_IndexCountInfo = new wxStaticText(dummy, wxID_HTML_COUNTINFO, + wxEmptyString, wxDefaultPosition, + wxDefaultSize, + wxALIGN_RIGHT | wxST_NO_AUTORESIZE); + m_IndexList = new wxListBox(dummy, wxID_HTML_INDEXLIST, + wxDefaultPosition, wxDefaultSize, + 0, NULL, wxLB_SINGLE); + +#if wxUSE_TOOLTIPS + m_IndexButton->SetToolTip(_("Display all index items that contain given substring. Search is case insensitive.")); + m_IndexButtonAll->SetToolTip(_("Show all items in index")); +#endif //wxUSE_TOOLTIPS + + topsizer->Add(m_IndexText, 0, wxEXPAND | wxALL, 10); + wxSizer *btsizer = new wxBoxSizer(wxHORIZONTAL); + btsizer->Add(m_IndexButton, 0, wxRIGHT, 2); + btsizer->Add(m_IndexButtonAll); + topsizer->Add(btsizer, 0, + wxALIGN_RIGHT | wxLEFT | wxRIGHT | wxBOTTOM, 10); + topsizer->Add(m_IndexCountInfo, 0, wxEXPAND | wxLEFT | wxRIGHT, 2); + topsizer->Add(m_IndexList, 1, wxEXPAND | wxALL, 2); + + m_NavigNotebook->AddPage(dummy, _("Index")); + m_IndexPage = notebook_page++; + } + + // search list panel? + if ( style & wxHF_SEARCH ) + { + wxWindow *dummy = new wxPanel(m_NavigNotebook, wxID_HTML_INDEXPAGE); + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + dummy->SetAutoLayout(TRUE); + dummy->SetSizer(sizer); + + m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT, + wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER); + m_SearchChoice = new wxChoice(dummy, wxID_HTML_SEARCHCHOICE, + wxDefaultPosition, wxDefaultSize); + m_SearchCaseSensitive = new wxCheckBox(dummy, -1, _("Case sensitive")); + m_SearchWholeWords = new wxCheckBox(dummy, -1, _("Whole words only")); + m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search")); +#if wxUSE_TOOLTIPS + m_SearchButton->SetToolTip(_("Search contents of help book(s) for all occurences of the text you typed above")); +#endif //wxUSE_TOOLTIPS + m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, + wxDefaultPosition, wxDefaultSize, + 0, NULL, wxLB_SINGLE); + + sizer->Add(m_SearchText, 0, wxEXPAND | wxALL, 10); + sizer->Add(m_SearchChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10); + sizer->Add(m_SearchCaseSensitive, 0, wxLEFT | wxRIGHT, 10); + sizer->Add(m_SearchWholeWords, 0, wxLEFT | wxRIGHT, 10); + sizer->Add(m_SearchButton, 0, wxALL | wxALIGN_RIGHT, 8); + sizer->Add(m_SearchList, 1, wxALL | wxEXPAND, 2); + + m_NavigNotebook->AddPage(dummy, _("Search")); + m_SearchPage = notebook_page++; + } + + m_HtmlWin->Show(TRUE); + + RefreshLists(); + + if ( navigSizer ) + { + navigSizer->SetSizeHints(m_NavigPan); + m_NavigPan->Layout(); + } + + // showtime + if ( m_NavigPan && m_Splitter ) + { + m_Splitter->SetMinimumPaneSize(20); + if ( m_Cfg.navig_on ) + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + + if ( m_Cfg.navig_on ) + { + m_NavigPan->Show(TRUE); + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + else + { + m_NavigPan->Show(FALSE); + m_Splitter->Initialize(m_HtmlWin); + } + } + + return TRUE; +} + +wxHtmlHelpFrame::~wxHtmlHelpFrame() +{ + // PopEventHandler(); // wxhtmlhelpcontroller (not any more!) + if (m_DataCreated) + delete m_Data; + if (m_NormalFonts) delete m_NormalFonts; + if (m_FixedFonts) delete m_FixedFonts; + if (m_PagesHash) delete m_PagesHash; +} + + +void wxHtmlHelpFrame::AddToolbarButtons(wxToolBar *toolBar, int style) +{ + wxBitmap wpanelBitmap = + wxArtProvider::GetBitmap(wxART_HELP_SIDE_PANEL, wxART_HELP_BROWSER); + wxBitmap wbackBitmap = + wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_HELP_BROWSER); + wxBitmap wforwardBitmap = + wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_HELP_BROWSER); + wxBitmap wupnodeBitmap = + wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_HELP_BROWSER); + wxBitmap wupBitmap = + wxArtProvider::GetBitmap(wxART_GO_UP, wxART_HELP_BROWSER); + wxBitmap wdownBitmap = + wxArtProvider::GetBitmap(wxART_GO_DOWN, wxART_HELP_BROWSER); + wxBitmap wopenBitmap = + wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_HELP_BROWSER); + wxBitmap wprintBitmap = + wxArtProvider::GetBitmap(wxART_PRINT, wxART_HELP_BROWSER); + wxBitmap woptionsBitmap = + wxArtProvider::GetBitmap(wxART_HELP_SETTINGS, wxART_HELP_BROWSER); + + wxASSERT_MSG( (wpanelBitmap.Ok() && wbackBitmap.Ok() && + wforwardBitmap.Ok() && wupnodeBitmap.Ok() && + wupBitmap.Ok() && wdownBitmap.Ok() && + wopenBitmap.Ok() && wprintBitmap.Ok() && + woptionsBitmap.Ok()), + wxT("One or more HTML help frame toolbar bitmap could not be loaded.")) ; + + + toolBar->AddTool(wxID_HTML_PANEL, wpanelBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Show/hide navigation panel")); + + toolBar->AddSeparator(); + toolBar->AddTool(wxID_HTML_BACK, wbackBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Go back")); + toolBar->AddTool(wxID_HTML_FORWARD, wforwardBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Go forward")); + toolBar->AddSeparator(); + + toolBar->AddTool(wxID_HTML_UPNODE, wupnodeBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Go one level up in document hierarchy")); + toolBar->AddTool(wxID_HTML_UP, wupBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Previous page")); + toolBar->AddTool(wxID_HTML_DOWN, wdownBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Next page")); + + if ((style & wxHF_PRINT) || (style & wxHF_OPEN_FILES)) + toolBar->AddSeparator(); + + if (style & wxHF_OPEN_FILES) + toolBar->AddTool(wxID_HTML_OPENFILE, wopenBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Open HTML document")); + +#if wxUSE_PRINTING_ARCHITECTURE + if (style & wxHF_PRINT) + toolBar->AddTool(wxID_HTML_PRINT, wprintBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Print this page")); +#endif + + toolBar->AddSeparator(); + toolBar->AddTool(wxID_HTML_OPTIONS, woptionsBitmap, wxNullBitmap, + FALSE, -1, -1, (wxObject *) NULL, + _("Display options dialog")); +} + + +void wxHtmlHelpFrame::SetTitleFormat(const wxString& format) +{ + if (m_HtmlWin) + m_HtmlWin->SetRelatedFrame(this, format); + m_TitleFormat = format; +} + + +bool wxHtmlHelpFrame::Display(const wxString& x) +{ + wxString url = m_Data->FindPageByName(x); + if (!url.IsEmpty()) + { + m_HtmlWin->LoadPage(url); + NotifyPageChanged(); + return TRUE; + } + return FALSE; +} + +bool wxHtmlHelpFrame::Display(const int id) +{ + wxString url = m_Data->FindPageById(id); + if (!url.IsEmpty()) + { + m_HtmlWin->LoadPage(url); + NotifyPageChanged(); + return TRUE; + } + return FALSE; +} + + + +bool wxHtmlHelpFrame::DisplayContents() +{ + if (! m_ContentsBox) + return FALSE; + if (!m_Splitter->IsSplit()) + { + m_NavigPan->Show(TRUE); + m_HtmlWin->Show(TRUE); + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + m_Cfg.navig_on = TRUE; + } + m_NavigNotebook->SetSelection(0); + if (m_Data->GetBookRecArray().GetCount() > 0) + { + wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; + if (!book.GetStart().IsEmpty()) + m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); + } + return TRUE; +} + + + +bool wxHtmlHelpFrame::DisplayIndex() +{ + if (! m_IndexList) + return FALSE; + if (!m_Splitter->IsSplit()) + { + m_NavigPan->Show(TRUE); + m_HtmlWin->Show(TRUE); + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + m_NavigNotebook->SetSelection(1); + if (m_Data->GetBookRecArray().GetCount() > 0) + { + wxHtmlBookRecord& book = m_Data->GetBookRecArray()[0]; + if (!book.GetStart().IsEmpty()) + m_HtmlWin->LoadPage(book.GetFullPath(book.GetStart())); + } + return TRUE; +} + + + +bool wxHtmlHelpFrame::KeywordSearch(const wxString& keyword) +{ + if (! (m_SearchList && m_SearchButton && m_SearchText && m_SearchChoice)) + return FALSE; + + int foundcnt = 0, curi; + wxString foundstr; + wxString book = wxEmptyString; + + if (!m_Splitter->IsSplit()) + { + m_NavigPan->Show(TRUE); + m_HtmlWin->Show(TRUE); + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + } + m_NavigNotebook->SetSelection(m_SearchPage); + m_SearchList->Clear(); + m_SearchText->SetValue(keyword); + m_SearchButton->Enable(FALSE); + + if (m_SearchChoice->GetSelection() != 0) + book = m_SearchChoice->GetStringSelection(); + + wxHtmlSearchStatus status(m_Data, keyword, + m_SearchCaseSensitive->GetValue(), m_SearchWholeWords->GetValue(), + book); + + wxProgressDialog progress(_("Searching..."), _("No matching page found yet"), + status.GetMaxIndex(), this, + wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE); + + while (status.IsActive()) + { + curi = status.GetCurIndex(); + if (curi % 32 == 0 && progress.Update(curi) == FALSE) + break; + if (status.Search()) + { + foundstr.Printf(_("Found %i matches"), ++foundcnt); + progress.Update(status.GetCurIndex(), foundstr); + m_SearchList->Append(status.GetName(), status.GetContentsItem()); + } + } + + m_SearchButton->Enable(TRUE); + m_SearchText->SetSelection(0, keyword.Length()); + m_SearchText->SetFocus(); + if (foundcnt) + { + wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(0); + if (it) + { + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); + } + } + return (foundcnt > 0); +} + +void wxHtmlHelpFrame::CreateContents() +{ + if (! m_ContentsBox) + return ; + + m_ContentsBox->Clear(); + + if (m_PagesHash) delete m_PagesHash; + m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * m_Data->GetContentsCnt()); + m_PagesHash->DeleteContents(TRUE); + + int cnt = m_Data->GetContentsCnt(); + int i; + + wxHtmlContentsItem *it; + + const int MAX_ROOTS = 64; + wxTreeItemId roots[MAX_ROOTS]; + // VS: this array holds information about whether we've set item icon at + // given level. This is neccessary because m_Data has flat structure + // and there's no way of recognizing if some item has subitems or not. + // We set the icon later: when we find an item with level=n, we know + // that the last item with level=n-1 was folder with subitems, so we + // set its icon accordingly + bool imaged[MAX_ROOTS]; + m_ContentsBox->DeleteAllItems(); + + roots[0] = m_ContentsBox->AddRoot(_("(Help)")); + imaged[0] = TRUE; + + for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) + { + // Handle books: + if (it->m_Level == 0) + { + if (m_hfStyle & wxHF_MERGE_BOOKS) + // VS: we don't want book nodes, books' content should + // appear under tree's root. This line will create "fake" + // record about book node so that the rest of this look + // will believe there really _is_ book node and will + // behave correctly. + roots[1] = roots[0]; + else + { + roots[1] = m_ContentsBox->AppendItem(roots[0], + it->m_Name, IMG_Book, -1, + new wxHtmlHelpTreeItemData(i)); + m_ContentsBox->SetItemBold(roots[1], TRUE); + } + imaged[1] = TRUE; + } + // ...and their contents: + else + { + roots[it->m_Level + 1] = m_ContentsBox->AppendItem( + roots[it->m_Level], it->m_Name, IMG_Page, + -1, new wxHtmlHelpTreeItemData(i)); + imaged[it->m_Level + 1] = FALSE; + } + + m_PagesHash->Put(it->GetFullPath(), + new wxHtmlHelpHashData(i, roots[it->m_Level + 1])); + + // Set the icon for the node one level up in the hiearachy, + // unless already done (see comment above imaged[] declaration) + if (!imaged[it->m_Level]) + { + int image = IMG_Folder; + if (m_hfStyle & wxHF_ICONS_BOOK) + image = IMG_Book; + else if (m_hfStyle & wxHF_ICONS_BOOK_CHAPTER) + image = (it->m_Level == 1) ? IMG_Book : IMG_Folder; + m_ContentsBox->SetItemImage(roots[it->m_Level], image); + m_ContentsBox->SetItemSelectedImage(roots[it->m_Level], image); + imaged[it->m_Level] = TRUE; + } + } +} + + +void wxHtmlHelpFrame::CreateIndex() +{ + if (! m_IndexList) + return ; + + m_IndexList->Clear(); + + int cnt = m_Data->GetIndexCnt(); + + wxString cnttext; + if (cnt > INDEX_IS_SMALL) cnttext.Printf(_("%i of %i"), 0, cnt); + else cnttext.Printf(_("%i of %i"), cnt, cnt); + m_IndexCountInfo->SetLabel(cnttext); + if (cnt > INDEX_IS_SMALL) return; + + wxHtmlContentsItem* index = m_Data->GetIndex(); + + for (int i = 0; i < cnt; i++) + m_IndexList->Append(index[i].m_Name, (char*)(index + i)); +} + +void wxHtmlHelpFrame::CreateSearch() +{ + if (! (m_SearchList && m_SearchChoice)) + return ; + m_SearchList->Clear(); + m_SearchChoice->Clear(); + m_SearchChoice->Append(_("Search in all books")); + const wxHtmlBookRecArray& bookrec = m_Data->GetBookRecArray(); + int i, cnt = bookrec.GetCount(); + for (i = 0; i < cnt; i++) + m_SearchChoice->Append(bookrec[i].GetTitle()); + m_SearchChoice->SetSelection(0); +} + + +void wxHtmlHelpFrame::RefreshLists() +{ + CreateContents(); + CreateIndex(); + CreateSearch(); +} + +void wxHtmlHelpFrame::ReadCustomization(wxConfigBase *cfg, const wxString& path) +{ + wxString oldpath; + wxString tmp; + + if (path != wxEmptyString) + { + oldpath = cfg->GetPath(); + cfg->SetPath(_T("/") + path); + } + + m_Cfg.navig_on = cfg->Read(wxT("hcNavigPanel"), m_Cfg.navig_on) != 0; + m_Cfg.sashpos = cfg->Read(wxT("hcSashPos"), m_Cfg.sashpos); + m_Cfg.x = cfg->Read(wxT("hcX"), m_Cfg.x); + m_Cfg.y = cfg->Read(wxT("hcY"), m_Cfg.y); + m_Cfg.w = cfg->Read(wxT("hcW"), m_Cfg.w); + m_Cfg.h = cfg->Read(wxT("hcH"), m_Cfg.h); + + m_FixedFace = cfg->Read(wxT("hcFixedFace"), m_FixedFace); + m_NormalFace = cfg->Read(wxT("hcNormalFace"), m_NormalFace); + m_FontSize = cfg->Read(wxT("hcBaseFontSize"), m_FontSize); + + { + int i; + int cnt; + wxString val, s; + + cnt = cfg->Read(wxT("hcBookmarksCnt"), 0L); + if (cnt != 0) + { + m_BookmarksNames.Clear(); + m_BookmarksPages.Clear(); + if (m_Bookmarks) + { + m_Bookmarks->Clear(); + m_Bookmarks->Append(_("(bookmarks)")); + } + + for (i = 0; i < cnt; i++) + { + val.Printf(wxT("hcBookmark_%i"), i); + s = cfg->Read(val); + m_BookmarksNames.Add(s); + if (m_Bookmarks) m_Bookmarks->Append(s); + val.Printf(wxT("hcBookmark_%i_url"), i); + s = cfg->Read(val); + m_BookmarksPages.Add(s); + } + } + } + + if (m_HtmlWin) + m_HtmlWin->ReadCustomization(cfg); + + if (path != wxEmptyString) + cfg->SetPath(oldpath); +} + +void wxHtmlHelpFrame::WriteCustomization(wxConfigBase *cfg, const wxString& path) +{ + wxString oldpath; + wxString tmp; + + if (path != wxEmptyString) + { + oldpath = cfg->GetPath(); + cfg->SetPath(_T("/") + path); + } + + cfg->Write(wxT("hcNavigPanel"), m_Cfg.navig_on); + cfg->Write(wxT("hcSashPos"), (long)m_Cfg.sashpos); + if ( !IsIconized() ) + { + // Don't write if iconized as this would make the window + // disappear next time it is shown! + cfg->Write(wxT("hcX"), (long)m_Cfg.x); + cfg->Write(wxT("hcY"), (long)m_Cfg.y); + cfg->Write(wxT("hcW"), (long)m_Cfg.w); + cfg->Write(wxT("hcH"), (long)m_Cfg.h); + } + cfg->Write(wxT("hcFixedFace"), m_FixedFace); + cfg->Write(wxT("hcNormalFace"), m_NormalFace); + cfg->Write(wxT("hcBaseFontSize"), (long)m_FontSize); + + if (m_Bookmarks) + { + int i; + int cnt = m_BookmarksNames.GetCount(); + wxString val; + + cfg->Write(wxT("hcBookmarksCnt"), (long)cnt); + for (i = 0; i < cnt; i++) + { + val.Printf(wxT("hcBookmark_%i"), i); + cfg->Write(val, m_BookmarksNames[i]); + val.Printf(wxT("hcBookmark_%i_url"), i); + cfg->Write(val, m_BookmarksPages[i]); + } + } + + if (m_HtmlWin) + m_HtmlWin->WriteCustomization(cfg); + + if (path != wxEmptyString) + cfg->SetPath(oldpath); +} + + + + + +static void SetFontsToHtmlWin(wxHtmlWindow *win, wxString scalf, wxString fixf, int size) +{ + int f_sizes[7]; + f_sizes[0] = int(size * 0.6); + f_sizes[1] = int(size * 0.8); + f_sizes[2] = size; + f_sizes[3] = int(size * 1.2); + f_sizes[4] = int(size * 1.4); + f_sizes[5] = int(size * 1.6); + f_sizes[6] = int(size * 1.8); + + win->SetFonts(scalf, fixf, f_sizes); +} + + +class wxHtmlHelpFrameOptionsDialog : public wxDialog +{ +public: + wxComboBox *NormalFont, *FixedFont; + wxSpinCtrl *FontSize; + wxHtmlWindow *TestWin; + + wxHtmlHelpFrameOptionsDialog(wxWindow *parent) + : wxDialog(parent, -1, wxString(_("Help Browser Options"))) + { + wxBoxSizer *topsizer = new wxBoxSizer(wxVERTICAL); + wxFlexGridSizer *sizer = new wxFlexGridSizer(2, 3, 2, 5); + + sizer->Add(new wxStaticText(this, -1, _("Normal font:"))); + sizer->Add(new wxStaticText(this, -1, _("Fixed font:"))); + sizer->Add(new wxStaticText(this, -1, _("Font size:"))); + + sizer->Add(NormalFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, + wxSize(200, 200), + 0, NULL, wxCB_DROPDOWN | wxCB_READONLY)); + + sizer->Add(FixedFont = new wxComboBox(this, -1, wxEmptyString, wxDefaultPosition, + wxSize(200, 200), + 0, NULL, wxCB_DROPDOWN | wxCB_READONLY)); + + sizer->Add(FontSize = new wxSpinCtrl(this, -1)); + FontSize->SetRange(2, 100); + + topsizer->Add(sizer, 0, wxLEFT|wxRIGHT|wxTOP, 10); + + topsizer->Add(new wxStaticText(this, -1, _("Preview:")), + 0, wxLEFT | wxTOP, 10); + topsizer->Add(TestWin = new wxHtmlWindow(this, -1, wxDefaultPosition, wxSize(20, 150), + wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER), + 1, wxEXPAND | wxLEFT|wxTOP|wxRIGHT, 10); + + wxBoxSizer *sizer2 = new wxBoxSizer(wxHORIZONTAL); + wxButton *ok; + sizer2->Add(ok = new wxButton(this, wxID_OK, _("OK")), 0, wxALL, 10); + ok->SetDefault(); + sizer2->Add(new wxButton(this, wxID_CANCEL, _("Cancel")), 0, wxALL, 10); + topsizer->Add(sizer2, 0, wxALIGN_RIGHT); + + SetAutoLayout(TRUE); + SetSizer(topsizer); + topsizer->Fit(this); + Centre(wxBOTH); + } + + + void UpdateTestWin() + { + wxBusyCursor bcur; + SetFontsToHtmlWin(TestWin, + NormalFont->GetStringSelection(), + FixedFont->GetStringSelection(), + FontSize->GetValue()); + TestWin->SetPage(_( +"\ +
\ +Normal face
(and underlined. Italic face. \ +Bold face. Bold italic face.
\ +font size -2
\ +font size -1
\ +font size +0
\ +font size +1
\ +font size +2
\ +font size +3
\ +font size +4
\ +
\ +

Fixed size face.
bold italic \ +bold italic underlined
\ +font size -2
\ +font size -1
\ +font size +0
\ +font size +1
\ +font size +2
\ +font size +3
\ +font size +4
\ +

" + )); + } + + void OnUpdate(wxCommandEvent& WXUNUSED(event)) + { + UpdateTestWin(); + } + void OnUpdateSpin(wxSpinEvent& WXUNUSED(event)) + { + UpdateTestWin(); + } + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(wxHtmlHelpFrameOptionsDialog, wxDialog) + EVT_COMBOBOX(-1, wxHtmlHelpFrameOptionsDialog::OnUpdate) + EVT_SPINCTRL(-1, wxHtmlHelpFrameOptionsDialog::OnUpdateSpin) +END_EVENT_TABLE() + + +void wxHtmlHelpFrame::OptionsDialog() +{ + wxHtmlHelpFrameOptionsDialog dlg(this); + unsigned i; + + if (m_NormalFonts == NULL) + { + wxFontEnumerator enu; + enu.EnumerateFacenames(); + m_NormalFonts = new wxArrayString; + *m_NormalFonts = *enu.GetFacenames(); + m_NormalFonts->Sort(); + } + if (m_FixedFonts == NULL) + { + wxFontEnumerator enu; + enu.EnumerateFacenames(wxFONTENCODING_SYSTEM, TRUE); + m_FixedFonts = new wxArrayString; + *m_FixedFonts = *enu.GetFacenames(); + m_FixedFonts->Sort(); + } + + // VS: We want to show the font that is actually used by wxHtmlWindow. + // If customization dialog wasn't used yet, facenames are empty and + // wxHtmlWindow uses default fonts -- let's find out what they + // are so that we can pass them to the dialog: + if (m_NormalFace.empty()) + { + wxFont fnt(m_FontSize, wxSWISS, wxNORMAL, wxNORMAL, FALSE); + m_NormalFace = fnt.GetFaceName(); + } + if (m_FixedFace.empty()) + { + wxFont fnt(m_FontSize, wxMODERN, wxNORMAL, wxNORMAL, FALSE); + m_FixedFace = fnt.GetFaceName(); + } + + for (i = 0; i < m_NormalFonts->GetCount(); i++) + dlg.NormalFont->Append((*m_NormalFonts)[i]); + for (i = 0; i < m_FixedFonts->GetCount(); i++) + dlg.FixedFont->Append((*m_FixedFonts)[i]); + if (!m_NormalFace.empty()) + dlg.NormalFont->SetStringSelection(m_NormalFace); + else + dlg.NormalFont->SetSelection(0); + if (!m_FixedFace.empty()) + dlg.FixedFont->SetStringSelection(m_FixedFace); + else + dlg.FixedFont->SetSelection(0); + dlg.FontSize->SetValue(m_FontSize); + dlg.UpdateTestWin(); + + if (dlg.ShowModal() == wxID_OK) + { + m_NormalFace = dlg.NormalFont->GetStringSelection(); + m_FixedFace = dlg.FixedFont->GetStringSelection(); + m_FontSize = dlg.FontSize->GetValue(); + SetFontsToHtmlWin(m_HtmlWin, m_NormalFace, m_FixedFace, m_FontSize); + } +} + + + +void wxHtmlHelpFrame::NotifyPageChanged() +{ + if (m_UpdateContents && m_PagesHash) + { + wxString an = m_HtmlWin->GetOpenedAnchor(); + wxHtmlHelpHashData *ha; + if (an.IsEmpty()) + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); + else + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); + if (ha) + { + bool olduc = m_UpdateContents; + m_UpdateContents = FALSE; + m_ContentsBox->SelectItem(ha->m_Id); + m_ContentsBox->EnsureVisible(ha->m_Id); + m_UpdateContents = olduc; + } + } +} + + + +/* +EVENT HANDLING : +*/ + + +void wxHtmlHelpFrame::OnActivate(wxActivateEvent& event) +{ + // This saves one mouse click when using the + // wxHTML for context sensitive help systems +#ifndef __WXGTK__ + // NB: wxActivateEvent is a bit broken in wxGTK + // and is sometimes sent when it should not be + if (event.GetActive() && m_HtmlWin) + m_HtmlWin->SetFocus(); +#endif + + event.Skip(); +} + +void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case wxID_HTML_BACK : + m_HtmlWin->HistoryBack(); + NotifyPageChanged(); + break; + + case wxID_HTML_FORWARD : + m_HtmlWin->HistoryForward(); + NotifyPageChanged(); + break; + + case wxID_HTML_UP : + if (m_PagesHash) + { + wxString an = m_HtmlWin->GetOpenedAnchor(); + wxHtmlHelpHashData *ha; + if (an.IsEmpty()) + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); + else + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); + if (ha && ha->m_Index > 0) + { + wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index - 1); + if (it->m_Page[0] != 0) + { + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); + } + } + } + break; + + case wxID_HTML_UPNODE : + if (m_PagesHash) + { + wxString an = m_HtmlWin->GetOpenedAnchor(); + wxHtmlHelpHashData *ha; + if (an.IsEmpty()) + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage()); + else + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(m_HtmlWin->GetOpenedPage() + wxT("#") + an); + if (ha && ha->m_Index > 0) + { + int level = m_Data->GetContents()[ha->m_Index].m_Level - 1; + wxHtmlContentsItem *it; + int ind = ha->m_Index - 1; + + it = m_Data->GetContents() + ind; + while (ind >= 0 && it->m_Level != level) ind--, it--; + if (ind >= 0) + { + if (it->m_Page[0] != 0) + { + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); + } + } + } + } + break; + + case wxID_HTML_DOWN : + if (m_PagesHash) + { + wxString an = m_HtmlWin->GetOpenedAnchor(); + wxString adr; + wxHtmlHelpHashData *ha; + + if (an.IsEmpty()) adr = m_HtmlWin->GetOpenedPage(); + else adr = m_HtmlWin->GetOpenedPage() + wxT("#") + an; + + ha = (wxHtmlHelpHashData*) m_PagesHash->Get(adr); + + if (ha && ha->m_Index < m_Data->GetContentsCnt() - 1) + { + wxHtmlContentsItem *it = m_Data->GetContents() + (ha->m_Index + 1); + + while (it->GetFullPath() == adr) it++; + + if (it->m_Page[0] != 0) + { + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); + } + } + } + break; + + case wxID_HTML_PANEL : + { + if (! (m_Splitter && m_NavigPan)) + return ; + if (m_Splitter->IsSplit()) + { + m_Cfg.sashpos = m_Splitter->GetSashPosition(); + m_Splitter->Unsplit(m_NavigPan); + m_Cfg.navig_on = FALSE; + } + else + { + m_NavigPan->Show(TRUE); + m_HtmlWin->Show(TRUE); + m_Splitter->SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos); + m_Cfg.navig_on = TRUE; + } + } + break; + + case wxID_HTML_OPTIONS : + OptionsDialog(); + break; + + case wxID_HTML_BOOKMARKSADD : + { + wxString item; + wxString url; + + item = m_HtmlWin->GetOpenedPageTitle(); + url = m_HtmlWin->GetOpenedPage(); + if (item == wxEmptyString) + item = url.AfterLast(wxT('/')); + if (m_BookmarksPages.Index(url) == wxNOT_FOUND) + { + m_Bookmarks->Append(item); + m_BookmarksNames.Add(item); + m_BookmarksPages.Add(url); + } + } + break; + + case wxID_HTML_BOOKMARKSREMOVE : + { + wxString item; + int pos; + + item = m_Bookmarks->GetStringSelection(); + pos = m_BookmarksNames.Index(item); + if (pos != wxNOT_FOUND) + { + m_BookmarksNames.Remove(pos); + m_BookmarksPages.Remove(pos); + m_Bookmarks->Delete(m_Bookmarks->GetSelection()); + } + } + break; + +#if wxUSE_PRINTING_ARCHITECTURE + case wxID_HTML_PRINT : + { + if (m_Printer == NULL) + m_Printer = new wxHtmlEasyPrinting(_("Help Printing"), this); + if (!m_HtmlWin->GetOpenedPage()) + wxLogWarning(_("Cannot print empty page.")); + else + m_Printer->PrintFile(m_HtmlWin->GetOpenedPage()); + } + break; +#endif + + case wxID_HTML_OPENFILE : + { + wxString s = wxFileSelector(_("Open HTML document"), + wxEmptyString, + wxEmptyString, + wxEmptyString, + _( +"HTML files (*.htm)|*.htm|HTML files (*.html)|*.html|\ +Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|\ +HTML Help Project (*.hhp)|*.hhp|\ +All files (*.*)|*" + ), + wxOPEN | wxFILE_MUST_EXIST, + this); + if (!s.IsEmpty()) + { + wxString ext = s.Right(4).Lower(); + if (ext == _T(".zip") || ext == _T(".htb") || ext == _T(".hhp")) + { + wxBusyCursor bcur; + m_Data->AddBook(s); + RefreshLists(); + } + else + m_HtmlWin->LoadPage(s); + } + } + break; + } +} + + + +void wxHtmlHelpFrame::OnContentsSel(wxTreeEvent& event) +{ + wxHtmlHelpTreeItemData *pg; + wxHtmlContentsItem *it; + + pg = (wxHtmlHelpTreeItemData*) m_ContentsBox->GetItemData(event.GetItem()); + + if (pg && m_UpdateContents) + { + it = m_Data->GetContents() + (pg->m_Id); + m_UpdateContents = FALSE; + if (it->m_Page[0] != 0) + m_HtmlWin->LoadPage(it->GetFullPath()); + m_UpdateContents = TRUE; + } +} + + + +void wxHtmlHelpFrame::OnIndexSel(wxCommandEvent& WXUNUSED(event)) +{ + wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_IndexList->GetClientData(m_IndexList->GetSelection()); + if (it->m_Page[0] != 0) + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); +} + + +void wxHtmlHelpFrame::OnIndexFind(wxCommandEvent& event) +{ + wxString sr = m_IndexText->GetLineText(0); + sr.MakeLower(); + if (sr == wxEmptyString) + { + OnIndexAll(event); + } + else + { + wxBusyCursor bcur; + const wxChar *cstr = sr.c_str(); + wxChar mybuff[512]; + wxChar *ptr; + bool first = TRUE; + + m_IndexList->Clear(); + int cnt = m_Data->GetIndexCnt(); + wxHtmlContentsItem* index = m_Data->GetIndex(); + + int displ = 0; + for (int i = 0; i < cnt; i++) + { + wxStrncpy(mybuff, index[i].m_Name, 512); + mybuff[511] = _T('\0'); + for (ptr = mybuff; *ptr != 0; ptr++) + if (*ptr >= _T('A') && *ptr <= _T('Z')) + *ptr -= (wxChar)(_T('A') - _T('a')); + if (wxStrstr(mybuff, cstr) != NULL) + { + m_IndexList->Append(index[i].m_Name, (char*)(index + i)); + displ++; + if (first) + { + if (index[i].m_Page[0] != 0) + m_HtmlWin->LoadPage(index[i].GetFullPath()); + NotifyPageChanged(); + first = FALSE; + } + } + } + + wxString cnttext; + cnttext.Printf(_("%i of %i"), displ, cnt); + m_IndexCountInfo->SetLabel(cnttext); + + m_IndexText->SetSelection(0, sr.Length()); + m_IndexText->SetFocus(); + } +} + +void wxHtmlHelpFrame::OnIndexAll(wxCommandEvent& WXUNUSED(event)) +{ + wxBusyCursor bcur; + + m_IndexList->Clear(); + int cnt = m_Data->GetIndexCnt(); + bool first = TRUE; + wxHtmlContentsItem* index = m_Data->GetIndex(); + + for (int i = 0; i < cnt; i++) + { + m_IndexList->Append(index[i].m_Name, (char*)(index + i)); + if (first) + { + if (index[i].m_Page[0] != 0) + m_HtmlWin->LoadPage(index[i].GetFullPath()); + NotifyPageChanged(); + first = FALSE; + } + } + + wxString cnttext; + cnttext.Printf(_("%i of %i"), cnt, cnt); + m_IndexCountInfo->SetLabel(cnttext); +} + + +void wxHtmlHelpFrame::OnSearchSel(wxCommandEvent& WXUNUSED(event)) +{ + wxHtmlContentsItem *it = (wxHtmlContentsItem*) m_SearchList->GetClientData(m_SearchList->GetSelection()); + if (it) + { + if (it->m_Page[0] != 0) + m_HtmlWin->LoadPage(it->GetFullPath()); + NotifyPageChanged(); + } +} + +void wxHtmlHelpFrame::OnSearch(wxCommandEvent& WXUNUSED(event)) +{ + wxString sr = m_SearchText->GetLineText(0); + + if (sr != wxEmptyString) KeywordSearch(sr); +} + +void wxHtmlHelpFrame::OnBookmarksSel(wxCommandEvent& WXUNUSED(event)) +{ + wxString sr = m_Bookmarks->GetStringSelection(); + + if (sr != wxEmptyString && sr != _("(bookmarks)")) + { + m_HtmlWin->LoadPage(m_BookmarksPages[m_BookmarksNames.Index(sr)]); + NotifyPageChanged(); + } +} + +void wxHtmlHelpFrame::OnCloseWindow(wxCloseEvent& evt) +{ + GetSize(&m_Cfg.w, &m_Cfg.h); + GetPosition(&m_Cfg.x, &m_Cfg.y); + +#ifdef __WXGTK__ + if (IsGrabbed()) + { + RemoveGrab(); + } +#endif + + if (m_Splitter && m_Cfg.navig_on) m_Cfg.sashpos = m_Splitter->GetSashPosition(); + + if (m_Config) + WriteCustomization(m_Config, m_ConfigRoot); + + if (m_helpController && m_helpController->IsKindOf(CLASSINFO(wxHtmlHelpController))) + { + ((wxHtmlHelpController*) m_helpController)->OnCloseFrame(evt); + } + + evt.Skip(); +} + +BEGIN_EVENT_TABLE(wxHtmlHelpFrame, wxFrame) + EVT_ACTIVATE(wxHtmlHelpFrame::OnActivate) + EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_OPTIONS, wxHtmlHelpFrame::OnToolbar) + EVT_BUTTON(wxID_HTML_BOOKMARKSREMOVE, wxHtmlHelpFrame::OnToolbar) + EVT_BUTTON(wxID_HTML_BOOKMARKSADD, wxHtmlHelpFrame::OnToolbar) + EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpFrame::OnContentsSel) + EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpFrame::OnIndexSel) + EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpFrame::OnSearchSel) + EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpFrame::OnSearch) + EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpFrame::OnSearch) + EVT_BUTTON(wxID_HTML_INDEXBUTTON, wxHtmlHelpFrame::OnIndexFind) + EVT_TEXT_ENTER(wxID_HTML_INDEXTEXT, wxHtmlHelpFrame::OnIndexFind) + EVT_BUTTON(wxID_HTML_INDEXBUTTONALL, wxHtmlHelpFrame::OnIndexAll) + EVT_COMBOBOX(wxID_HTML_BOOKMARKSLIST, wxHtmlHelpFrame::OnBookmarksSel) + EVT_CLOSE(wxHtmlHelpFrame::OnCloseWindow) +END_EVENT_TABLE() + +#endif // wxUSE_WXHTML_HELP + diff --git a/Contrib/NSIS Menu/src/html/htmlcell.cpp b/Contrib/NSIS Menu/src/html/htmlcell.cpp new file mode 100644 index 00000000..018445ff --- /dev/null +++ b/Contrib/NSIS Menu/src/html/htmlcell.cpp @@ -0,0 +1,728 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlcell.cpp +// Purpose: wxHtmlCell - basic element of HTML output +// Author: Vaclav Slavik +// RCS-ID: $Id: htmlcell.cpp,v 1.50.2.10 2002/12/19 22:15:45 VS Exp $ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "htmlcell.h" +#endif + +#include "wx/wxprec.h" + +#include "wx/defs.h" + +#if wxUSE_HTML && wxUSE_STREAMS + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP + #include "wx/brush.h" + #include "wx/colour.h" + #include "wx/dc.h" +#endif + +#include "wx/html/htmlcell.h" +#include "wx/html/htmlwin.h" +#include + + +//----------------------------------------------------------------------------- +// wxHtmlCell +//----------------------------------------------------------------------------- + +wxHtmlCell::wxHtmlCell() : wxObject() +{ + m_Next = NULL; + m_Parent = NULL; + m_Width = m_Height = m_Descent = 0; + m_CanLiveOnPagebreak = TRUE; + m_Link = NULL; +} + +wxHtmlCell::~wxHtmlCell() +{ + delete m_Link; +} + + +void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, + const wxMouseEvent& event) +{ + wxHtmlLinkInfo *lnk = GetLink(x, y); + if (lnk != NULL) + { + wxHtmlLinkInfo lnk2(*lnk); + lnk2.SetEvent(&event); + lnk2.SetHtmlCell(this); + + // note : this cast is legal because parent is *always* wxHtmlWindow + wxStaticCast(parent, wxHtmlWindow)->OnLinkClicked(lnk2); + } +} + + + +bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const +{ + if ((!m_CanLiveOnPagebreak) && + m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) + { + *pagebreak = m_PosY; + return TRUE; + } + + return FALSE; +} + + + +void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) +{ + if (m_Link) delete m_Link; + m_Link = NULL; + if (link.GetHref() != wxEmptyString) + m_Link = new wxHtmlLinkInfo(link); +} + + + +void wxHtmlCell::Layout(int WXUNUSED(w)) +{ + SetPos(0, 0); +} + + + +void wxHtmlCell::GetHorizontalConstraints(int *left, int *right) const +{ + if (left) + *left = m_PosX; + if (right) + *right = m_PosX + m_Width; +} + + + +const wxHtmlCell* wxHtmlCell::Find(int WXUNUSED(condition), const void* WXUNUSED(param)) const +{ + return NULL; +} + + +wxHtmlCell *wxHtmlCell::FindCellByPos(wxCoord x, wxCoord y) const +{ + if ( x >= 0 && x < m_Width && y >= 0 && y < m_Height ) + return wxConstCast(this, wxHtmlCell); + + return NULL; +} + + +//----------------------------------------------------------------------------- +// wxHtmlWordCell +//----------------------------------------------------------------------------- + +wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() +{ + m_Word = word; + dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); + SetCanLiveOnPagebreak(FALSE); +} + + + +void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, int WXUNUSED(view_y1), int WXUNUSED(view_y2)) +{ + dc.DrawText(m_Word, x + m_PosX, y + m_PosY); +} + + + +//----------------------------------------------------------------------------- +// wxHtmlContainerCell +//----------------------------------------------------------------------------- + + +wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell() +{ + m_Cells = m_LastCell = NULL; + m_Parent = parent; + if (m_Parent) m_Parent->InsertCell(this); + m_AlignHor = wxHTML_ALIGN_LEFT; + m_AlignVer = wxHTML_ALIGN_BOTTOM; + m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0; + m_WidthFloat = 100; m_WidthFloatUnits = wxHTML_UNITS_PERCENT; + m_UseBkColour = FALSE; + m_UseBorder = FALSE; + m_MinHeight = 0; + m_MinHeightAlign = wxHTML_ALIGN_TOP; + m_LastLayout = -1; +} + +wxHtmlContainerCell::~wxHtmlContainerCell() +{ + wxHtmlCell *cell = m_Cells; + while ( cell ) + { + wxHtmlCell *cellNext = cell->GetNext(); + delete cell; + cell = cellNext; + } +} + + + +void wxHtmlContainerCell::SetIndent(int i, int what, int units) +{ + int val = (units == wxHTML_UNITS_PIXELS) ? i : -i; + if (what & wxHTML_INDENT_LEFT) m_IndentLeft = val; + if (what & wxHTML_INDENT_RIGHT) m_IndentRight = val; + if (what & wxHTML_INDENT_TOP) m_IndentTop = val; + if (what & wxHTML_INDENT_BOTTOM) m_IndentBottom = val; + m_LastLayout = -1; +} + + + +int wxHtmlContainerCell::GetIndent(int ind) const +{ + if (ind & wxHTML_INDENT_LEFT) return m_IndentLeft; + else if (ind & wxHTML_INDENT_RIGHT) return m_IndentRight; + else if (ind & wxHTML_INDENT_TOP) return m_IndentTop; + else if (ind & wxHTML_INDENT_BOTTOM) return m_IndentBottom; + else return -1; /* BUG! Should not be called... */ +} + + + + +int wxHtmlContainerCell::GetIndentUnits(int ind) const +{ + bool p = FALSE; + if (ind & wxHTML_INDENT_LEFT) p = m_IndentLeft < 0; + else if (ind & wxHTML_INDENT_RIGHT) p = m_IndentRight < 0; + else if (ind & wxHTML_INDENT_TOP) p = m_IndentTop < 0; + else if (ind & wxHTML_INDENT_BOTTOM) p = m_IndentBottom < 0; + if (p) return wxHTML_UNITS_PERCENT; + else return wxHTML_UNITS_PIXELS; +} + + + +bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const +{ + if (!m_CanLiveOnPagebreak) + return wxHtmlCell::AdjustPagebreak(pagebreak); + + else + { + wxHtmlCell *c = GetFirstCell(); + bool rt = FALSE; + int pbrk = *pagebreak - m_PosY; + + while (c) + { + if (c->AdjustPagebreak(&pbrk)) + rt = TRUE; + c = c->GetNext(); + } + if (rt) + *pagebreak = pbrk + m_PosY; + return rt; + } +} + + + +void wxHtmlContainerCell::Layout(int w) +{ + wxHtmlCell::Layout(w); + + if (m_LastLayout == w) return; + + // VS: Any attempt to layout with negative or zero width leads to hell, + // but we can't ignore such attempts completely, since it sometimes + // happen (e.g. when trying how small a table can be). The best thing we + // can do is to set the width of child cells to zero + if (w < 1) + { + m_Width = 0; + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + cell->Layout(0); + // this does two things: it recursively calls this code on all + // child contrainers and resets children's position to (0,0) + return; + } + + wxHtmlCell *cell = m_Cells, *line = m_Cells; + long xpos = 0, ypos = m_IndentTop; + int xdelta = 0, ybasicpos = 0, ydiff; + int s_width, s_indent; + int ysizeup = 0, ysizedown = 0; + int MaxLineWidth = 0; + int xcnt = 0; + + + /* + + WIDTH ADJUSTING : + + */ + + if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) + { + if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; + else m_Width = m_WidthFloat * w / 100; + } + else + { + if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; + else m_Width = m_WidthFloat; + } + + if (m_Cells) + { + int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; + int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + cell->Layout(m_Width - (l + r)); + } + + /* + + LAYOUTING : + + */ + + // adjust indentation: + s_indent = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; + s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); + + // my own layouting: + while (cell != NULL) + { + switch (m_AlignVer) + { + case wxHTML_ALIGN_TOP : ybasicpos = 0; break; + case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell->GetHeight(); break; + case wxHTML_ALIGN_CENTER : ybasicpos = - cell->GetHeight() / 2; break; + } + ydiff = cell->GetHeight() + ybasicpos; + + if (cell->GetDescent() + ydiff > ysizedown) ysizedown = cell->GetDescent() + ydiff; + if (ybasicpos + cell->GetDescent() < -ysizeup) ysizeup = - (ybasicpos + cell->GetDescent()); + + cell->SetPos(xpos, ybasicpos + cell->GetDescent()); + xpos += cell->GetWidth(); + cell = cell->GetNext(); + xcnt++; + + // force new line if occured: + if ((cell == NULL) || (xpos + cell->GetWidth() > s_width)) + { + if (xpos > MaxLineWidth) MaxLineWidth = xpos; + if (ysizeup < 0) ysizeup = 0; + if (ysizedown < 0) ysizedown = 0; + switch (m_AlignHor) { + case wxHTML_ALIGN_LEFT : + case wxHTML_ALIGN_JUSTIFY : + xdelta = 0; + break; + case wxHTML_ALIGN_RIGHT : + xdelta = 0 + (s_width - xpos); + break; + case wxHTML_ALIGN_CENTER : + xdelta = 0 + (s_width - xpos) / 2; + break; + } + if (xdelta < 0) xdelta = 0; + xdelta += s_indent; + + ypos += ysizeup; + + if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL) + while (line != cell) + { + line->SetPos(line->GetPosX() + xdelta, + ypos + line->GetPosY()); + line = line->GetNext(); + } + else + { + int counter = 0; + int step = (s_width - xpos); + if (step < 0) step = 0; + xcnt--; + if (xcnt > 0) while (line != cell) + { + line->SetPos(line->GetPosX() + s_indent + + (counter++ * step / xcnt), + ypos + line->GetPosY()); + line = line->GetNext(); + } + xcnt++; + } + + ypos += ysizedown; + xpos = xcnt = 0; + ysizeup = ysizedown = 0; + line = cell; + } + } + + // setup height & width, depending on container layout: + m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom; + + if (m_Height < m_MinHeight) + { + if (m_MinHeightAlign != wxHTML_ALIGN_TOP) + { + int diff = m_MinHeight - m_Height; + if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2; + cell = m_Cells; + while (cell) + { + cell->SetPos(cell->GetPosX(), cell->GetPosY() + diff); + cell = cell->GetNext(); + } + } + m_Height = m_MinHeight; + } + + MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); + if (m_Width < MaxLineWidth) m_Width = MaxLineWidth; + + m_LastLayout = w; +} + + +#define mMin(a, b) (((a) < (b)) ? (a) : (b)) +#define mMax(a, b) (((a) < (b)) ? (b) : (a)) + +void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) +{ + // container visible, draw it: + if ((y + m_PosY <= view_y2) && (y + m_PosY + m_Height > view_y1)) + { + if (m_UseBkColour) + { + wxBrush myb = wxBrush(m_BkColour, wxSOLID); + + int real_y1 = mMax(y + m_PosY, view_y1); + int real_y2 = mMin(y + m_PosY + m_Height - 1, view_y2); + + dc.SetBrush(myb); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1); + } + + if (m_UseBorder) + { + wxPen mypen1(m_BorderColour1, 1, wxSOLID); + wxPen mypen2(m_BorderColour2, 1, wxSOLID); + + dc.SetPen(mypen1); + dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX, y + m_PosY + m_Height - 1); + dc.DrawLine(x + m_PosX, y + m_PosY, x + m_PosX + m_Width, y + m_PosY); + dc.SetPen(mypen2); + dc.DrawLine(x + m_PosX + m_Width - 1, y + m_PosY, x + m_PosX + m_Width - 1, y + m_PosY + m_Height - 1); + dc.DrawLine(x + m_PosX, y + m_PosY + m_Height - 1, x + m_PosX + m_Width, y + m_PosY + m_Height - 1); + } + + if (m_Cells) + { + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + cell->Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2); + } + } + // container invisible, just proceed font+color changing: + else + { + if (m_Cells) + { + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + cell->DrawInvisible(dc, x + m_PosX, y + m_PosY); + } + } +} + + + +void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y) +{ + if (m_Cells) + { + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + cell->DrawInvisible(dc, x + m_PosX, y + m_PosY); + } +} + + +wxColour wxHtmlContainerCell::GetBackgroundColour() +{ + if (m_UseBkColour) + return m_BkColour; + else + return wxNullColour; +} + + + +wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const +{ + wxHtmlCell *cell = FindCellByPos(x, y); + + // VZ: I don't know if we should pass absolute or relative coords to + // wxHtmlCell::GetLink()? As the base class version just ignores them + // anyhow, it hardly matters right now but should still be clarified + return cell ? cell->GetLink(x, y) : NULL; +} + + + +void wxHtmlContainerCell::InsertCell(wxHtmlCell *f) +{ + if (!m_Cells) m_Cells = m_LastCell = f; + else + { + m_LastCell->SetNext(f); + m_LastCell = f; + if (m_LastCell) while (m_LastCell->GetNext()) m_LastCell = m_LastCell->GetNext(); + } + f->SetParent(this); + m_LastLayout = -1; +} + + + +void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag) +{ + if (tag.HasParam(wxT("ALIGN"))) + { + wxString alg = tag.GetParam(wxT("ALIGN")); + alg.MakeUpper(); + if (alg == wxT("CENTER")) + SetAlignHor(wxHTML_ALIGN_CENTER); + else if (alg == wxT("LEFT")) + SetAlignHor(wxHTML_ALIGN_LEFT); + else if (alg == wxT("JUSTIFY")) + SetAlignHor(wxHTML_ALIGN_JUSTIFY); + else if (alg == wxT("RIGHT")) + SetAlignHor(wxHTML_ALIGN_RIGHT); + m_LastLayout = -1; + } +} + + + +void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale) +{ + if (tag.HasParam(wxT("WIDTH"))) + { + int wdi; + wxString wd = tag.GetParam(wxT("WIDTH")); + + if (wd[wd.Length()-1] == wxT('%')) + { + wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); + SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); + } + else + { + wxSscanf(wd.c_str(), wxT("%i"), &wdi); + SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS); + } + m_LastLayout = -1; + } +} + + + +const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const +{ + if (m_Cells) + { + const wxHtmlCell *r = NULL; + + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + { + r = cell->Find(condition, param); + if (r) return r; + } + } + return NULL; +} + + +wxHtmlCell *wxHtmlContainerCell::FindCellByPos(wxCoord x, wxCoord y) const +{ + for ( const wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext() ) + { + int cx = cell->GetPosX(), + cy = cell->GetPosY(); + + if ( (cx <= x) && (cx + cell->GetWidth() > x) && + (cy <= y) && (cy + cell->GetHeight() > y) ) + { + return cell->FindCellByPos(x - cx, y - cy); + } + } + + return NULL; +} + + +void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) +{ + wxHtmlCell *cell = FindCellByPos(x, y); + if ( cell ) + cell->OnMouseClick(parent, x, y, event); +} + + + +void wxHtmlContainerCell::GetHorizontalConstraints(int *left, int *right) const +{ + int cleft = m_PosX + m_Width, cright = m_PosX; // worst case + int l, r; + + for (wxHtmlCell *cell = m_Cells; cell; cell = cell->GetNext()) + { + cell->GetHorizontalConstraints(&l, &r); + if (l < cleft) + cleft = l; + if (r > cright) + cright = r; + } + + cleft -= (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; + cright += (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; + + if (left) + *left = cleft; + if (right) + *right = cright; +} + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlColourCell +//-------------------------------------------------------------------------------- + +void wxHtmlColourCell::Draw(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(view_y1), int WXUNUSED(view_y2)) +{ + if (m_Flags & wxHTML_CLR_FOREGROUND) + dc.SetTextForeground(m_Colour); + if (m_Flags & wxHTML_CLR_BACKGROUND) + { + dc.SetBackground(wxBrush(m_Colour, wxSOLID)); + dc.SetTextBackground(m_Colour); + } +} + +void wxHtmlColourCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y)) +{ + if (m_Flags & wxHTML_CLR_FOREGROUND) + dc.SetTextForeground(m_Colour); + if (m_Flags & wxHTML_CLR_BACKGROUND) + { + dc.SetBackground(wxBrush(m_Colour, wxSOLID)); + dc.SetTextBackground(m_Colour); + } +} + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFontCell +//-------------------------------------------------------------------------------- + +void wxHtmlFontCell::Draw(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(view_y1), int WXUNUSED(view_y2)) +{ + dc.SetFont(m_Font); +} + +void wxHtmlFontCell::DrawInvisible(wxDC& dc, int WXUNUSED(x), int WXUNUSED(y)) +{ + dc.SetFont(m_Font); +} + + + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlWidgetCell +//-------------------------------------------------------------------------------- + +wxHtmlWidgetCell::wxHtmlWidgetCell(wxWindow *wnd, int w) +{ + int sx, sy; + m_Wnd = wnd; + m_Wnd->GetSize(&sx, &sy); + m_Width = sx, m_Height = sy; + m_WidthFloat = w; +} + + +void wxHtmlWidgetCell::Draw(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(view_y1), int WXUNUSED(view_y2)) +{ + int absx = 0, absy = 0, stx, sty; + wxHtmlCell *c = this; + + while (c) + { + absx += c->GetPosX(); + absy += c->GetPosY(); + c = c->GetParent(); + } + + ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); + m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); +} + + + +void wxHtmlWidgetCell::DrawInvisible(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y)) +{ + int absx = 0, absy = 0, stx, sty; + wxHtmlCell *c = this; + + while (c) + { + absx += c->GetPosX(); + absy += c->GetPosY(); + c = c->GetParent(); + } + + ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); + m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); +} + + + +void wxHtmlWidgetCell::Layout(int w) +{ + if (m_WidthFloat != 0) + { + m_Width = (w * m_WidthFloat) / 100; + m_Wnd->SetSize(m_Width, m_Height); + } + + wxHtmlCell::Layout(w); +} + +#endif diff --git a/Contrib/NSIS Menu/src/html/htmlfilt.cpp b/Contrib/NSIS Menu/src/html/htmlfilt.cpp new file mode 100644 index 00000000..017f2e6e --- /dev/null +++ b/Contrib/NSIS Menu/src/html/htmlfilt.cpp @@ -0,0 +1,229 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlfilt.cpp +// Purpose: wxHtmlFilter - input filter for translating into HTML format +// Author: Vaclav Slavik +// RCS-ID: $Id: htmlfilt.cpp,v 1.16.2.4 2002/11/11 00:15:57 VS Exp $ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation "htmlfilt.h" +#endif + +#include "wx/wxprec.h" + +#include "wx/defs.h" +#if wxUSE_HTML && wxUSE_STREAMS + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP + #include "wx/log.h" + #include "wx/intl.h" +#endif + +#include "wx/strconv.h" +#include "wx/html/htmlfilt.h" +#include "wx/html/htmlwin.h" + +// utility function: read a wxString from a wxInputStream +static void ReadString(wxString& str, wxInputStream* s, wxMBConv& conv) +{ + size_t streamSize = s->GetSize(); + + if (streamSize == ~(size_t)0) + { + const size_t bufSize = 4095; + char buffer[bufSize+1]; + size_t lastRead; + + do + { + s->Read(buffer, bufSize); + lastRead = s->LastRead(); + buffer[lastRead] = 0; + str.Append(wxString(buffer, conv)); + } + while (lastRead == bufSize); + } + else + { + char* src = new char[streamSize+1]; + s->Read(src, streamSize); + src[streamSize] = 0; + str = wxString(src, conv); + delete[] src; + } +} + +/* + +There is code for several default filters: + +*/ + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlFilter, wxObject) + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// filter for text/plain or uknown +//-------------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterPlainText, wxHtmlFilter) + +bool wxHtmlFilterPlainText::CanRead(const wxFSFile& WXUNUSED(file)) const +{ + return TRUE; +} + + + +wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + wxString doc, doc2; + + if (s == NULL) return wxEmptyString; + ReadString(doc, s, wxConvISO8859_1); + + doc.Replace(wxT("&"), wxT("&"), TRUE); + doc.Replace(wxT("<"), wxT("<"), TRUE); + doc.Replace(wxT(">"), wxT(">"), TRUE); + doc2 = wxT("
\n") + doc + wxT("\n
"); + return doc2; +} + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterImage +// filter for image/* +//-------------------------------------------------------------------------------- + +class wxHtmlFilterImage : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterImage) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter) + + + +bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const +{ + return (file.GetMimeType().Left(6) == wxT("image/")); +} + + + +wxString wxHtmlFilterImage::ReadFile(const wxFSFile& file) const +{ + wxString res = wxT(""); + return res; +} + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterHTML +// filter for text/html +//-------------------------------------------------------------------------------- + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterHTML, wxHtmlFilter) + +bool wxHtmlFilterHTML::CanRead(const wxFSFile& file) const +{ +// return (file.GetMimeType() == "text/html"); +// This is true in most case but some page can return: +// "text/html; char-encoding=...." +// So we use Find instead + return (file.GetMimeType().Find(wxT("text/html")) == 0); +} + + + +wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + wxString doc; + + if (s == NULL) + { + wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().c_str()); + return wxEmptyString; + } + + // NB: We convert input file to wchar_t here in Unicode mode, based on + // either Content-Type header or tags. In ANSI mode, we don't + // do it as it is done by wxHtmlParser (for this reason, we add + // tag if we used Content-Type header). +#if wxUSE_UNICODE + int charsetPos; + if ((charsetPos = file.GetMimeType().Find(_T("; charset="))) != wxNOT_FOUND) + { + wxString charset = file.GetMimeType().Mid(charsetPos + 10); + wxCSConv conv(charset); + ReadString(doc, s, conv); + } + else + { + wxString tmpdoc; + ReadString(tmpdoc, s, wxConvISO8859_1); + wxString charset = wxHtmlParser::ExtractCharsetInformation(tmpdoc); + if (charset.empty()) + doc = tmpdoc; + else + { + wxCSConv conv(charset); + doc = wxString(tmpdoc.mb_str(wxConvISO8859_1), conv); + } + } +#else // !wxUSE_UNICODE + ReadString(doc, s, wxConvLibc); + // add meta tag if we obtained this through http: + if (!file.GetMimeType().empty()) + { + wxString hdr; + wxString mime = file.GetMimeType(); + hdr.Printf(_T(""), mime.c_str()); + return hdr+doc; + } +#endif + + return doc; +} + + + + +///// Module: + +class wxHtmlFilterModule : public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterModule) + + public: + virtual bool OnInit() + { + wxHtmlWindow::AddFilter(new wxHtmlFilterHTML); + wxHtmlWindow::AddFilter(new wxHtmlFilterImage); + return TRUE; + } + virtual void OnExit() {} +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterModule, wxModule) + +#endif diff --git a/Contrib/NSIS Menu/src/html/htmlpars.cpp b/Contrib/NSIS Menu/src/html/htmlpars.cpp new file mode 100644 index 00000000..2d6ee511 --- /dev/null +++ b/Contrib/NSIS Menu/src/html/htmlpars.cpp @@ -0,0 +1,888 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlpars.cpp +// Purpose: wxHtmlParser class (generic parser) +// Author: Vaclav Slavik +// RCS-ID: $Id: htmlpars.cpp,v 1.28.2.5 2002/11/10 00:05:39 VS Exp $ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation "htmlpars.h" +#endif + +#include "wx/wxprec.h" + +#include "wx/defs.h" +#if wxUSE_HTML && wxUSE_STREAMS + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP + #include "wx/log.h" + #include "wx/intl.h" +#endif + +#include "wx/tokenzr.h" +#include "wx/wfstream.h" +#include "wx/url.h" +#include "wx/fontmap.h" +#include "wx/html/htmldefs.h" +#include "wx/html/htmlpars.h" +#include "wx/dynarray.h" +#include "wx/arrimpl.cpp" + +//----------------------------------------------------------------------------- +// wxHtmlParser helpers +//----------------------------------------------------------------------------- + +class wxHtmlTextPiece +{ +public: + wxHtmlTextPiece(int pos, int lng) : m_pos(pos), m_lng(lng) {} + int m_pos, m_lng; +}; + +WX_DECLARE_OBJARRAY(wxHtmlTextPiece, wxHtmlTextPieces); +WX_DEFINE_OBJARRAY(wxHtmlTextPieces); + +class wxHtmlParserState +{ +public: + wxHtmlTag *m_curTag; + wxHtmlTag *m_tags; + wxHtmlTextPieces *m_textPieces; + int m_curTextPiece; + wxString m_source; + wxHtmlParserState *m_nextState; +}; + +//----------------------------------------------------------------------------- +// wxHtmlParser +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject) + +wxHtmlParser::wxHtmlParser() + : wxObject(), m_HandlersHash(wxKEY_STRING), + m_FS(NULL), m_HandlersStack(NULL) +{ + m_entitiesParser = new wxHtmlEntitiesParser; + m_Tags = NULL; + m_CurTag = NULL; + m_TextPieces = NULL; + m_CurTextPiece = 0; + m_SavedStates = NULL; +} + +wxHtmlParser::~wxHtmlParser() +{ + while (RestoreState()) {} + DestroyDOMTree(); + + delete m_HandlersStack; + m_HandlersHash.Clear(); + m_HandlersList.DeleteContents(TRUE); + m_HandlersList.Clear(); + delete m_entitiesParser; +} + +wxObject* wxHtmlParser::Parse(const wxString& source) +{ + InitParser(source); + DoParsing(); + wxObject *result = GetProduct(); + DoneParser(); + return result; +} + +void wxHtmlParser::InitParser(const wxString& source) +{ + SetSource(source); + m_stopParsing = FALSE; +} + +void wxHtmlParser::DoneParser() +{ + DestroyDOMTree(); +} + +void wxHtmlParser::SetSource(const wxString& src) +{ + DestroyDOMTree(); + m_Source = src; + CreateDOMTree(); + m_CurTag = NULL; + m_CurTextPiece = 0; +} + +void wxHtmlParser::CreateDOMTree() +{ + wxHtmlTagsCache cache(m_Source); + m_TextPieces = new wxHtmlTextPieces; + CreateDOMSubTree(NULL, 0, m_Source.Length(), &cache); + m_CurTextPiece = 0; +} + +void wxHtmlParser::CreateDOMSubTree(wxHtmlTag *cur, + int begin_pos, int end_pos, + wxHtmlTagsCache *cache) +{ + if (end_pos <= begin_pos) return; + + wxChar c; + int i = begin_pos; + int textBeginning = begin_pos; + + while (i < end_pos) + { + c = m_Source.GetChar(i); + + if (c == wxT('<')) + { + // add text to m_TextPieces: + if (i - textBeginning > 0) + m_TextPieces->Add( + wxHtmlTextPiece(textBeginning, i - textBeginning)); + + // if it is a comment, skip it: + if (i < end_pos-6 && m_Source.GetChar(i+1) == wxT('!') && + m_Source.GetChar(i+2) == wxT('-') && + m_Source.GetChar(i+3) == wxT('-')) + { + // Comments begin with "