*** empty log message ***
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2963 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
@@ -533,6 +533,11 @@
|
|||||||
*/
|
*/
|
||||||
#define wxUSE_MINIFRAME 0
|
#define wxUSE_MINIFRAME 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wxHTML
|
||||||
|
*/
|
||||||
|
#define wxUSE_HTML 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable this if your compiler can't cope
|
* Disable this if your compiler can't cope
|
||||||
* with omission of prototype parameters.
|
* with omission of prototype parameters.
|
||||||
|
16
configure.in
@@ -292,6 +292,7 @@ if test $DEBUG_CONFIGURE = 1; then
|
|||||||
DEFAULT_wxUSE_STARTUP_TIPS=no
|
DEFAULT_wxUSE_STARTUP_TIPS=no
|
||||||
DEFAULT_wxUSE_PROGRESSDLG=no
|
DEFAULT_wxUSE_PROGRESSDLG=no
|
||||||
DEFAULT_wxUSE_MINIFRAME=no
|
DEFAULT_wxUSE_MINIFRAME=no
|
||||||
|
DEFAULT_wxUSE_HTML=no
|
||||||
DEFAULT_wxUSE_VALIDATORS=yes
|
DEFAULT_wxUSE_VALIDATORS=yes
|
||||||
|
|
||||||
DEFAULT_wxUSE_ACCEL=no
|
DEFAULT_wxUSE_ACCEL=no
|
||||||
@@ -391,6 +392,7 @@ else
|
|||||||
DEFAULT_wxUSE_STARTUP_TIPS=yes
|
DEFAULT_wxUSE_STARTUP_TIPS=yes
|
||||||
DEFAULT_wxUSE_PROGRESSDLG=yes
|
DEFAULT_wxUSE_PROGRESSDLG=yes
|
||||||
DEFAULT_wxUSE_MINIFRAME=yes
|
DEFAULT_wxUSE_MINIFRAME=yes
|
||||||
|
DEFAULT_wxUSE_HTML=no
|
||||||
DEFAULT_wxUSE_VALIDATORS=yes
|
DEFAULT_wxUSE_VALIDATORS=yes
|
||||||
|
|
||||||
DEFAULT_wxUSE_ACCEL=yes
|
DEFAULT_wxUSE_ACCEL=yes
|
||||||
@@ -675,6 +677,7 @@ WX_ARG_ENABLE(textdlg, [ --enable-textdlg use wxTextDialog], wxUSE_T
|
|||||||
WX_ARG_ENABLE(tipdlg, [ --enable-tipdlg use startup tips], wxUSE_STARTUP_TIPS)
|
WX_ARG_ENABLE(tipdlg, [ --enable-tipdlg use startup tips], wxUSE_STARTUP_TIPS)
|
||||||
WX_ARG_ENABLE(progressdlg, [ --enable-progressdlg use wxProgressDialog], wxUSE_PROGRESSDLG)
|
WX_ARG_ENABLE(progressdlg, [ --enable-progressdlg use wxProgressDialog], wxUSE_PROGRESSDLG)
|
||||||
WX_ARG_ENABLE(miniframe, [ --enable-miniframe use wxMiniFrame class], wxUSE_MINIFRAME)
|
WX_ARG_ENABLE(miniframe, [ --enable-miniframe use wxMiniFrame class], wxUSE_MINIFRAME)
|
||||||
|
WX_ARG_ENABLE(html, [ --enable-html use wxHTML sub-library], wxUSE_HTML)
|
||||||
WX_ARG_ENABLE(tooltips, [ --enable-tooltips use wxToolTip class], wxUSE_TOOLTIPS)
|
WX_ARG_ENABLE(tooltips, [ --enable-tooltips use wxToolTip class], wxUSE_TOOLTIPS)
|
||||||
WX_ARG_ENABLE(splines, [ --enable-splines use spline drawing code], wxUSE_SPLINES)
|
WX_ARG_ENABLE(splines, [ --enable-splines use spline drawing code], wxUSE_SPLINES)
|
||||||
WX_ARG_ENABLE(validators, [ --enable-validators use wxValidator and derived classes], wxUSE_VALIDATORS)
|
WX_ARG_ENABLE(validators, [ --enable-validators use wxValidator and derived classes], wxUSE_VALIDATORS)
|
||||||
@@ -1993,6 +1996,11 @@ if test "$wxUSE_MINIFRAME" = "yes"; then
|
|||||||
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS minifram"
|
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS minifram"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test "$wxUSE_HTML" = "yes"; then
|
||||||
|
AC_DEFINE(wxUSE_HTML)
|
||||||
|
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS html"
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$wxUSE_VALIDATORS" = "yes"; then
|
if test "$wxUSE_VALIDATORS" = "yes"; then
|
||||||
AC_DEFINE(wxUSE_VALIDATORS)
|
AC_DEFINE(wxUSE_VALIDATORS)
|
||||||
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
|
SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS validate"
|
||||||
@@ -2178,6 +2186,14 @@ dnl samples/Makefile samples/minimal/Makefile
|
|||||||
samples/validate/Makefile
|
samples/validate/Makefile
|
||||||
samples/wxpoem/Makefile
|
samples/wxpoem/Makefile
|
||||||
samples/wxsocket/Makefile
|
samples/wxsocket/Makefile
|
||||||
|
samples/html/Makefile
|
||||||
|
samples/html/about/Makefile
|
||||||
|
samples/html/help/Makefile
|
||||||
|
samples/html/test/Makefile
|
||||||
|
samples/html/printing/Makefile
|
||||||
|
samples/html/widget/Makefile
|
||||||
|
samples/html/virtual/Makefile
|
||||||
|
samples/html/zip/Makefile
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
chmod +x wx-config
|
chmod +x wx-config
|
||||||
|
58
include/wx/busyinfo.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: busyinfo.h
|
||||||
|
// Purpose: Information window (when app is busy)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __INFOWIN_H__
|
||||||
|
#define __INFOWIN_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxInfoFrame : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxInfoFrame(wxWindow *parent, const wxString& message);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxBusyInfo
|
||||||
|
// Displays progress information
|
||||||
|
// Can be used in exactly same way as wxBusyCursor
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxBusyInfo : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxBusyInfo(const wxString& message);
|
||||||
|
~wxBusyInfo();
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxInfoFrame *m_InfoFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
194
include/wx/filesys.h
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: filesys.h
|
||||||
|
// Purpose: class for opening files - virtual file system
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __FILESYS_H__
|
||||||
|
#define __FILESYS_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/stream.h>
|
||||||
|
#include <wx/mimetype.h>
|
||||||
|
#include <wx/url.h>
|
||||||
|
|
||||||
|
|
||||||
|
class wxFSFile;
|
||||||
|
class wxFileSystemHandler;
|
||||||
|
class wxFileSystem;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxFSFile
|
||||||
|
// This class is a file opened using wxFileSystem. It consists of
|
||||||
|
// input stream, location, mime type & optional anchor
|
||||||
|
// (in 'index.htm#chapter2', 'chapter2' is anchor)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFSFile : public wxObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxInputStream *m_Stream;
|
||||||
|
wxString m_Location;
|
||||||
|
wxString m_MimeType;
|
||||||
|
wxString m_Anchor;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxFSFile(wxInputStream *stream, const wxString& loc, const wxString& mimetype, const wxString& anchor)
|
||||||
|
{
|
||||||
|
m_Stream = stream;
|
||||||
|
m_Location = loc;
|
||||||
|
m_MimeType = mimetype; m_MimeType.MakeLower();
|
||||||
|
m_Anchor = anchor;
|
||||||
|
}
|
||||||
|
virtual ~wxFSFile()
|
||||||
|
{
|
||||||
|
if (m_Stream) delete m_Stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxInputStream *GetStream() const {return m_Stream;}
|
||||||
|
// returns stream. This doesn't _create_ stream, it only returns
|
||||||
|
// pointer to it!!
|
||||||
|
|
||||||
|
const wxString& GetMimeType() const {return m_MimeType;}
|
||||||
|
// returns file's mime type
|
||||||
|
|
||||||
|
const wxString& GetLocation() const {return m_Location;}
|
||||||
|
// returns the original location (aka filename) of the file
|
||||||
|
|
||||||
|
const wxString& GetAnchor() const {return m_Anchor;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxFileSystemHandler
|
||||||
|
// This class is FS handler for wxFileSystem. It provides
|
||||||
|
// interface to access certain
|
||||||
|
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFileSystemHandler : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxFileSystemHandler)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxFileSystemHandler() : wxObject() {}
|
||||||
|
|
||||||
|
virtual bool CanOpen(const wxString& location) = 0;
|
||||||
|
// returns TRUE if this handler is able to open given location
|
||||||
|
|
||||||
|
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location) = 0;
|
||||||
|
// opens given file and returns pointer to input stream.
|
||||||
|
// Returns NULL if opening failed.
|
||||||
|
// The location is always absolute path.
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString GetProtocol(const wxString& location) const;
|
||||||
|
// returns protocol ("file", "http", "tar" etc.) The last (most right)
|
||||||
|
// protocol is used:
|
||||||
|
// {it returns "tar" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||||
|
|
||||||
|
wxString GetLeftLocation(const wxString& location) const;
|
||||||
|
// returns left part of address:
|
||||||
|
// {it returns "file:subdir/archive.tar.gz" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||||
|
|
||||||
|
wxString GetAnchor(const wxString& location) const;
|
||||||
|
// returns anchor part of address:
|
||||||
|
// {it returns "anchor" for "file:subdir/archive.tar.gz#tar:/README.txt#anchor"}
|
||||||
|
// NOTE: anchor is NOT a part of GetLeftLocation()'s return value
|
||||||
|
|
||||||
|
wxString GetRightLocation(const wxString& location) const;
|
||||||
|
// returns right part of address:
|
||||||
|
// {it returns "/README.txt" for "file:subdir/archive.tar.gz#tar:/README.txt"}
|
||||||
|
|
||||||
|
wxString GetMimeTypeFromExt(const wxString& location);
|
||||||
|
// Returns MIME type of the file - w/o need to open it
|
||||||
|
// (default behaviour is that it returns type based on extension)
|
||||||
|
|
||||||
|
private:
|
||||||
|
static wxMimeTypesManager m_MimeMng;
|
||||||
|
// MIME manager
|
||||||
|
// (it's static and thus shared by all instances and derived classes)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxFileSystem
|
||||||
|
// This class provides simple interface for opening various
|
||||||
|
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxFileSystem : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxFileSystem)
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_Path;
|
||||||
|
// the path (location) we are currently in
|
||||||
|
// this is path, not file!
|
||||||
|
// (so if you opened test/demo.htm, it is
|
||||||
|
// "test/", not "test/demo.htm")
|
||||||
|
wxString m_LastName;
|
||||||
|
// name of last opened file (full path)
|
||||||
|
static wxList m_Handlers;
|
||||||
|
// list of FS handlers
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxFileSystem() : wxObject() {m_Path = m_LastName = wxEmptyString; m_Handlers.DeleteContents(TRUE);}
|
||||||
|
|
||||||
|
void ChangePathTo(const wxString& location, bool is_dir = FALSE);
|
||||||
|
// sets the current location. Every call to OpenFile is
|
||||||
|
// relative to this location.
|
||||||
|
// NOTE !!
|
||||||
|
// unless is_dir = TRUE 'location' is *not* the directory but
|
||||||
|
// file contained in this directory
|
||||||
|
// (so ChangePathTo("dir/subdir/xh.htm") sets m_Path to "dir/subdir/")
|
||||||
|
|
||||||
|
wxString GetPath() const {return m_Path;}
|
||||||
|
|
||||||
|
wxFSFile* OpenFile(const wxString& location);
|
||||||
|
// opens given file and returns pointer to input stream.
|
||||||
|
// Returns NULL if opening failed.
|
||||||
|
// It first tries to open the file in relative scope
|
||||||
|
// (based on ChangePathTo()'s value) and then as an absolute
|
||||||
|
// path.
|
||||||
|
|
||||||
|
static void AddHandler(wxFileSystemHandler *handler);
|
||||||
|
// Adds FS handler.
|
||||||
|
// In fact, this class is only front-end to the FS hanlers :-)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
'location' syntax:
|
||||||
|
|
||||||
|
To determine FS type, we're using standard KDE notation:
|
||||||
|
file:/absolute/path/file.htm
|
||||||
|
file:relative_path/xxxxx.html
|
||||||
|
/some/path/x.file ('file:' is default)
|
||||||
|
http://www.gnome.org
|
||||||
|
file:subdir/archive.tar.gz#tar:/README.txt
|
||||||
|
|
||||||
|
special characters :
|
||||||
|
':' - FS identificator is before this char
|
||||||
|
'#' - separator. It can be either HTML anchor ("index.html#news")
|
||||||
|
(in case there is no ':' in the string to the right from it)
|
||||||
|
or FS separator
|
||||||
|
(example : http://www.wxhtml.org/wxhtml-0.1.tar.gz#tar:/include/wxhtml/filesys.h"
|
||||||
|
this would access tgz archive stored on web)
|
||||||
|
'/' - directory (path) separator. It is used to determine upper-level path.
|
||||||
|
HEY! Don't use \ even if you're on Windows!
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif // __FILESYS_H__
|
55
include/wx/fs_inet.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: fs_inet.h
|
||||||
|
// Purpose: HTTP and FTP file system
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
REMARKS :
|
||||||
|
|
||||||
|
This FS creates local cache (in /tmp directory). The cache is freed
|
||||||
|
on program exit.
|
||||||
|
|
||||||
|
Size of cache is limited to cca 1000 items (due to GetTempFileName
|
||||||
|
limitation)
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxInternetFSHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxInternetFSHandler : public wxFileSystemHandler
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxHashTable m_Cache;
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool CanOpen(const wxString& location);
|
||||||
|
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||||
|
~wxInternetFSHandler();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
41
include/wx/fs_zip.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: fs_zip.h
|
||||||
|
// Purpose: ZIP file system
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxZipFSHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxZipFSHandler : public wxFileSystemHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool CanOpen(const wxString& location);
|
||||||
|
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||||
|
~wxZipFSHandler();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
59
include/wx/html/forcelink.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: forcelink.h
|
||||||
|
// Purpose: see bellow
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
DESCRPITON:
|
||||||
|
|
||||||
|
mod_*.cpp files contain handlers for tags. These files are modules - they contain
|
||||||
|
one wxTagModule class and it's OnInit() method is called from wxApp's init method.
|
||||||
|
The module is called even if you only link it into the executable, so everything
|
||||||
|
seems wonderful.
|
||||||
|
|
||||||
|
The problem is that we have these modules in LIBRARY and mod_*.cpp files contain
|
||||||
|
no method nor class which is known out of the module. So the linker won't
|
||||||
|
link these .o/.obj files into executable because it detected that it is not used
|
||||||
|
by the program.
|
||||||
|
|
||||||
|
To workaround this I introduced set of macros FORCE_LINK_ME and FORCE_LINK. These
|
||||||
|
macros are generic and are not limited to mod_*.cpp files. You may find them quite
|
||||||
|
useful somewhere else...
|
||||||
|
|
||||||
|
How to use them:
|
||||||
|
let's suppose you want to always link file foo.cpp and that you have module
|
||||||
|
always.cpp that is certainly always linked (e.g. the one with main() function
|
||||||
|
or htmlwin.cpp in wxHtml library).
|
||||||
|
|
||||||
|
Place FORCE_LINK_ME(foo) somewhere in foo.cpp and FORCE_LINK(foo) somewhere
|
||||||
|
in always.cpp
|
||||||
|
See mod_*.cpp and htmlwin.cpp for example :-)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __FORCELINK_H__
|
||||||
|
#define __FORCELINK_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// This must be part of the module you want to force:
|
||||||
|
#define FORCE_LINK_ME(module_name) \
|
||||||
|
int _link_dummy_func_##module_name () \
|
||||||
|
{ \
|
||||||
|
return 1; \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// And this must be somewhere where it certainly will be linked:
|
||||||
|
#define FORCE_LINK(module_name) \
|
||||||
|
extern int _link_dummy_func_##module_name (); \
|
||||||
|
static int _link_dummy_var_##module_name = \
|
||||||
|
_link_dummy_func_##module_name ();
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __FORCELINK_H__
|
292
include/wx/html/htmlcell.h
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlcell.h
|
||||||
|
// Purpose: wxHtmlCell class is used by wxHtmlWindow/wxHtmlWinParser
|
||||||
|
// as a basic visual element of HTML page
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLCELL_H__
|
||||||
|
#define __HTMLCELL_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/html/htmltag.h>
|
||||||
|
#include <wx/html/htmldefs.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class wxHtmlCell;
|
||||||
|
class wxHtmlContainerCell;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlCell
|
||||||
|
// Internal data structure. It represents fragments of parsed HTML
|
||||||
|
// page - a word, picture, table, horizontal line and so on.
|
||||||
|
// It is used by wxHtmlWindow to represent HTML page in memory.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlCell : public wxObject
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
wxHtmlCell *m_Next;
|
||||||
|
// pointer to the next cell
|
||||||
|
wxHtmlContainerCell *m_Parent;
|
||||||
|
// pointer to parent cell
|
||||||
|
long m_Width, m_Height, m_Descent;
|
||||||
|
// dimensions of fragment
|
||||||
|
// m_Descent is used to position text&images..
|
||||||
|
long m_PosX, m_PosY;
|
||||||
|
// position where the fragment is drawn
|
||||||
|
wxString m_Link;
|
||||||
|
// destination address if this fragment is hypertext link, "" otherwise
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlCell() : wxObject() {m_Next = NULL; m_Parent = NULL; m_Width = m_Height = m_Descent = 0;};
|
||||||
|
virtual ~wxHtmlCell() {if (m_Next) delete m_Next;};
|
||||||
|
|
||||||
|
void SetParent(wxHtmlContainerCell *p) {m_Parent = p;}
|
||||||
|
wxHtmlContainerCell *GetParent() const {return m_Parent;}
|
||||||
|
|
||||||
|
int GetPosX() const {return m_PosX;}
|
||||||
|
int GetPosY() const {return m_PosY;}
|
||||||
|
int GetWidth() const {return m_Width;}
|
||||||
|
int GetHeight() const {return m_Height;}
|
||||||
|
int GetDescent() const {return m_Descent;}
|
||||||
|
virtual wxString GetLink(int x = 0, int y = 0) const {return m_Link;}
|
||||||
|
// returns the link associated with this cell. The position is position within
|
||||||
|
// the cell so it varies from 0 to m_Width, from 0 to m_Height
|
||||||
|
wxHtmlCell *GetNext() const {return m_Next;}
|
||||||
|
// members access methods
|
||||||
|
|
||||||
|
virtual void SetPos(int x, int y) {m_PosX = x, m_PosY = y;}
|
||||||
|
void SetLink(const wxString& link) {m_Link = link;}
|
||||||
|
void SetNext(wxHtmlCell *cell) {m_Next = cell;}
|
||||||
|
// members writin methods
|
||||||
|
|
||||||
|
virtual void Layout(int w) {SetPos(0, 0); if (m_Next) m_Next -> Layout(w);};
|
||||||
|
// 1. adjust cell's width according to the fact that maximal possible width is w.
|
||||||
|
// (this has sense when working with horizontal lines, tables etc.)
|
||||||
|
// 2. prepare layout (=fill-in m_PosX, m_PosY (and sometime m_Height) members)
|
||||||
|
// = place items to fit window, according to the width w
|
||||||
|
|
||||||
|
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) {if (m_Next) m_Next -> Draw(dc, x, y, view_y1, view_y2);}
|
||||||
|
// renders the cell
|
||||||
|
|
||||||
|
virtual void DrawInvisible(wxDC& dc, int x, int y) {if (m_Next) m_Next -> DrawInvisible(dc, x, y);};
|
||||||
|
// proceed drawing actions in case the cell is not visible (scrolled out of screen).
|
||||||
|
// This is needed to change fonts, colors and so on
|
||||||
|
|
||||||
|
virtual const wxHtmlCell* Find(int condition, const void* param) const {if (m_Next) return m_Next -> Find(condition, param); else return NULL;}
|
||||||
|
// This method returns pointer to the FIRST cell for that
|
||||||
|
// the condition
|
||||||
|
// is true. It first checks if the condition is true for this
|
||||||
|
// cell and then calls m_Next -> Find(). (Note: it checks
|
||||||
|
// all subcells if the cell is container)
|
||||||
|
// Condition is unique condition identifier (see htmldefs.h)
|
||||||
|
// (user-defined condition IDs should start from 10000)
|
||||||
|
// and param is optional parameter
|
||||||
|
// Example : m_Cell -> Find(HTML_COND_ISANCHOR, "news");
|
||||||
|
// returns pointer to anchor news
|
||||||
|
|
||||||
|
virtual void OnMouseClick(wxWindow *parent, int x, int y, bool left, bool middle, bool right);
|
||||||
|
// This function is called when mouse button is clicked over the cell.
|
||||||
|
// left, middle, right are flags indicating whether the button was or wasn't
|
||||||
|
// pressed.
|
||||||
|
// Parent is pointer to wxHtmlWindow that generated the event
|
||||||
|
// HINT: if this handling is not enough for you you should use
|
||||||
|
// wxHtmlBinderCell
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// Inherited cells:
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlWordCell
|
||||||
|
// Single word in input stream.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
wxString m_Word;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlWordCell(const wxString& word, wxDC& dc);
|
||||||
|
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlContainerCell
|
||||||
|
// Container - it contains other cells. Basic of layout algorithm.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
int m_IndentLeft, m_IndentRight, m_IndentTop, m_IndentBottom;
|
||||||
|
// indentation of subcells. There is always m_Indent pixels
|
||||||
|
// big space between given border of the container and the subcells
|
||||||
|
// it m_Indent < 0 it is in PERCENTS, otherwise it is in pixels
|
||||||
|
int m_MinHeight, m_MinHeightAlign;
|
||||||
|
// minimal height.
|
||||||
|
int m_MaxLineWidth;
|
||||||
|
// maximal widht of line. Filled during Layout()
|
||||||
|
wxHtmlCell *m_Cells, *m_LastCell;
|
||||||
|
// internal cells, m_Cells points to the first of them, m_LastCell to the last one.
|
||||||
|
// (LastCell is needed only to speed-up InsertCell)
|
||||||
|
int m_AlignHor, m_AlignVer;
|
||||||
|
// alignment horizontal and vertical (left, center, right)
|
||||||
|
int m_WidthFloat, m_WidthFloatUnits;
|
||||||
|
// width float is used in adjustWidth
|
||||||
|
bool m_UseBkColour;
|
||||||
|
wxColour m_BkColour;
|
||||||
|
// background color of this container
|
||||||
|
bool m_UseBorder;
|
||||||
|
wxColour m_BorderColour1, m_BorderColour2;
|
||||||
|
// borders color of this container
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlContainerCell(wxHtmlContainerCell *parent);
|
||||||
|
~wxHtmlContainerCell() {if (m_Cells) delete m_Cells;}
|
||||||
|
|
||||||
|
virtual void Layout(int w);
|
||||||
|
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
virtual void DrawInvisible(wxDC& dc, int x, int y);
|
||||||
|
|
||||||
|
void InsertCell(wxHtmlCell *cell);
|
||||||
|
// insert cell at the end of m_Cells list
|
||||||
|
void SetAlignHor(int al) {m_AlignHor = al;}
|
||||||
|
int GetAlignHor() const {return m_AlignHor;}
|
||||||
|
void SetAlignVer(int al) {m_AlignVer = al;}
|
||||||
|
// sets horizontal/vertical alignment
|
||||||
|
int GetAlignVer() const {return m_AlignVer;}
|
||||||
|
void SetIndent(int i, int what, int units = HTML_UNITS_PIXELS);
|
||||||
|
// sets left-border indentation. units is one of HTML_UNITS_* constants
|
||||||
|
// what is combination of HTML_INDENT_*
|
||||||
|
int GetIndent(int ind) const;
|
||||||
|
// returns the indentation. ind is one of HTML_INDENT_* constants
|
||||||
|
int GetIndentUnits(int ind) const;
|
||||||
|
// returns type of value returned by GetIndent(ind)
|
||||||
|
void SetAlign(const wxHtmlTag& tag);
|
||||||
|
// sets alignment info based on given tag's params
|
||||||
|
void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units;}
|
||||||
|
void SetWidthFloat(const wxHtmlTag& tag);
|
||||||
|
// sets floating width adjustment
|
||||||
|
// (examples : 32 percent of parent container,
|
||||||
|
// -15 pixels percent (this means 100 % - 15 pixels)
|
||||||
|
void SetMinHeight(int h, int align = HTML_ALIGN_TOP) {m_MinHeight = h; m_MinHeightAlign = align;}
|
||||||
|
// sets minimal height of this container.
|
||||||
|
int GetMaxLineWidth() const {return m_MaxLineWidth;}
|
||||||
|
// returns maximal line width in this container.
|
||||||
|
// Call to this method is valid only after calling
|
||||||
|
// Layout()
|
||||||
|
void SetBackgroundColour(const wxColour& clr) {m_UseBkColour = TRUE; m_BkColour = clr;}
|
||||||
|
void SetBorder(const wxColour& clr1, const wxColour& clr2) {m_UseBorder = TRUE; m_BorderColour1 = clr1, m_BorderColour2 = clr2;}
|
||||||
|
virtual wxString GetLink(int x = 0, int y = 0) const;
|
||||||
|
virtual const wxHtmlCell* Find(int condition, const void* param) const;
|
||||||
|
virtual void OnMouseClick(wxWindow *parent, int x, int y, bool left, bool middle, bool right);
|
||||||
|
|
||||||
|
wxHtmlCell* GetFirstCell() {return m_Cells;}
|
||||||
|
// returns pointer to the first cell in container or NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlColourCell
|
||||||
|
// Color changer.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlColourCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxColour m_Colour;
|
||||||
|
unsigned m_Flags;
|
||||||
|
|
||||||
|
wxHtmlColourCell(wxColour clr, int flags = HTML_CLR_FOREGROUND) : wxHtmlCell() {m_Colour = clr; m_Flags = flags;}
|
||||||
|
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
virtual void DrawInvisible(wxDC& dc, int x, int y);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFontCell
|
||||||
|
// Sets actual font used for text rendering
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxFont *m_Font;
|
||||||
|
|
||||||
|
wxHtmlFontCell(wxFont *font) : wxHtmlCell() {m_Font = font;};
|
||||||
|
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
virtual void DrawInvisible(wxDC& dc, int x, int y);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlwidgetCell
|
||||||
|
// This cell is connected with wxWindow object
|
||||||
|
// You can use it to insert windows into HTML page
|
||||||
|
// (buttons, input boxes etc.)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
wxWindow* m_Wnd;
|
||||||
|
int m_WidthFloat;
|
||||||
|
// width float is used in adjustWidth (it is in percents)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlWidgetCell(wxWindow *wnd, int w = 0);
|
||||||
|
// !!! wnd must have correct parent!
|
||||||
|
// if w != 0 then the m_Wnd has 'floating' width - it adjust
|
||||||
|
// it's width according to parent container's width
|
||||||
|
// (w is percent of parent's width)
|
||||||
|
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
virtual void DrawInvisible(wxDC& dc, int x, int y);
|
||||||
|
virtual void Layout(int w);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLCELL_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
94
include/wx/html/htmldefs.h
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmldefs.h
|
||||||
|
// Purpose: constants for wxhtml library
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLDEFS_H__
|
||||||
|
#define __HTMLDEFS_H__
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// ALIGNMENTS
|
||||||
|
// Describes alignment of text etc. in containers
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_ALIGN_LEFT 0x0000
|
||||||
|
#define HTML_ALIGN_RIGHT 0x0002
|
||||||
|
|
||||||
|
#define HTML_ALIGN_TOP 0x0004
|
||||||
|
#define HTML_ALIGN_BOTTOM 0x0008
|
||||||
|
|
||||||
|
#define HTML_ALIGN_CENTER 0x0001
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// COLOR MODES
|
||||||
|
// Used by wxHtmlColourCell to determine clr of what is changing
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_CLR_FOREGROUND 0x0001
|
||||||
|
#define HTML_CLR_BACKGROUND 0x0002
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// UNITS
|
||||||
|
// Used to specify units
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_UNITS_PIXELS 0x0001
|
||||||
|
#define HTML_UNITS_PERCENT 0x0002
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// INDENTS
|
||||||
|
// Used to specify indetation relatives
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_INDENT_LEFT 0x0010
|
||||||
|
#define HTML_INDENT_RIGHT 0x0020
|
||||||
|
#define HTML_INDENT_TOP 0x0040
|
||||||
|
#define HTML_INDENT_BOTTOM 0x0080
|
||||||
|
|
||||||
|
#define HTML_INDENT_HORIZONTAL HTML_INDENT_LEFT | HTML_INDENT_RIGHT
|
||||||
|
#define HTML_INDENT_VERTICAL HTML_INDENT_TOP | HTML_INDENT_BOTTOM
|
||||||
|
#define HTML_INDENT_ALL HTML_INDENT_VERTICAL | HTML_INDENT_HORIZONTAL
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// FIND CONDITIONS
|
||||||
|
// Identifiers of wxHtmlCell's Find() conditions
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_COND_ISANCHOR 1
|
||||||
|
// Finds the anchor of 'param' name (pointer to wxString).
|
||||||
|
|
||||||
|
#define HTML_COND_USER 10000
|
||||||
|
// User-defined conditions should start from this number
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// INTERNALS
|
||||||
|
// wxHTML internal constants
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define HTML_SCROLL_STEP 16
|
||||||
|
/* size of one scroll step of wxHtmlWindow in pixels */
|
||||||
|
#define HTML_BUFLEN 1024
|
||||||
|
/* size of temporary buffer used during parsing */
|
||||||
|
#define HTML_REALLOC_STEP 32
|
||||||
|
/* steps of array reallocation */
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
70
include/wx/html/htmlfilter.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlfilter.h
|
||||||
|
// Purpose: filters
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLFILTER_H__
|
||||||
|
#define __HTMLFILTER_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFilter
|
||||||
|
// This class is input filter. It can "translate" files
|
||||||
|
// in non-HTML format to HTML format
|
||||||
|
// interface to access certain
|
||||||
|
// kinds of files (HTPP, FTP, local, tar.gz etc..)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlFilter : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxHtmlFilter)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlFilter() : wxObject() {}
|
||||||
|
|
||||||
|
virtual bool CanRead(const wxFSFile& file) = 0;
|
||||||
|
// returns TRUE if this filter is able to open&read given file
|
||||||
|
|
||||||
|
virtual wxString ReadFile(const wxFSFile& file) = 0;
|
||||||
|
// reads given file and returns HTML document.
|
||||||
|
// Returns empty string if opening failed
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFilterPlainText
|
||||||
|
// This filter is used as default filter if no other can
|
||||||
|
// be used (= uknown type of file). It is used by
|
||||||
|
// wxHtmlWindow itself.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlFilterPlainText : public wxHtmlFilter
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlFilterPlainText)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool CanRead(const wxFSFile& file);
|
||||||
|
virtual wxString ReadFile(const wxFSFile& file);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLFILTER_H__
|
||||||
|
|
||||||
|
#endif
|
223
include/wx/html/htmlhelp.h
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlhelp.h
|
||||||
|
// Purpose: Help controller
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLHELP_H__
|
||||||
|
#define __HTMLHELP_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/window.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
#include <wx/splitter.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// helper classes & structs - please ignore 'em
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT HtmlBookRecord : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxString m_BasePath;
|
||||||
|
wxString m_Title;
|
||||||
|
wxString m_Start;
|
||||||
|
|
||||||
|
HtmlBookRecord(const wxString& basepath, const wxString& title, const wxString& start) {m_BasePath = basepath; m_Title = title; m_Start = start;}
|
||||||
|
wxString GetTitle() const {return m_Title;}
|
||||||
|
wxString GetStart() const {return m_Start;}
|
||||||
|
wxString GetBasePath() const {return m_BasePath;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#undef WXDLLEXPORTLOCAL
|
||||||
|
#define WXDLLEXPORTLOCAL WXDLLEXPORT
|
||||||
|
// ?? Don't know why - but Allen Van Sickel reported it to fix problems with DLL
|
||||||
|
WX_DECLARE_OBJARRAY(HtmlBookRecord, HtmlBookRecArray);
|
||||||
|
|
||||||
|
#undef WXDLLEXPORTLOCAL
|
||||||
|
#define WXDLLEXPORTLOCAL
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
short int m_Level;
|
||||||
|
int m_ID;
|
||||||
|
char* m_Name;
|
||||||
|
char* m_Page;
|
||||||
|
HtmlBookRecord *m_Book;
|
||||||
|
} HtmlContentsItem;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlHelpController
|
||||||
|
// This class ensures dislaying help.
|
||||||
|
// See documentation for details on its philosophy.
|
||||||
|
//
|
||||||
|
// WARNING!!
|
||||||
|
// This class is not derived from wxHelpController and is not
|
||||||
|
// compatible with it!
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlHelpController : public wxEvtHandler
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlHelpController)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxConfigBase *m_Config;
|
||||||
|
wxString m_ConfigRoot;
|
||||||
|
// configuration file/registry used to store custom settings
|
||||||
|
wxString m_TitleFormat;
|
||||||
|
// title of the help frame
|
||||||
|
wxString m_TempPath;
|
||||||
|
|
||||||
|
wxFrame *m_Frame;
|
||||||
|
wxHtmlWindow *m_HtmlWin;
|
||||||
|
wxSplitterWindow *m_Splitter;
|
||||||
|
wxNotebook *m_NavigPan;
|
||||||
|
wxTreeCtrl *m_ContentsBox;
|
||||||
|
wxImageList *m_ContentsImageList;
|
||||||
|
wxListBox *m_IndexBox;
|
||||||
|
wxTextCtrl *m_SearchText;
|
||||||
|
wxButton *m_SearchButton;
|
||||||
|
wxListBox *m_SearchList;
|
||||||
|
// ...pointers to parts of help window
|
||||||
|
|
||||||
|
struct {
|
||||||
|
long x, y, w, h;
|
||||||
|
long sashpos;
|
||||||
|
bool navig_on;
|
||||||
|
} m_Cfg;
|
||||||
|
// settings (window size, position, sash pos etc..)
|
||||||
|
|
||||||
|
HtmlBookRecArray m_BookRecords;
|
||||||
|
// each book has one record in this array
|
||||||
|
HtmlContentsItem* m_Contents;
|
||||||
|
int m_ContentsCnt;
|
||||||
|
// list of all available books and pages.
|
||||||
|
HtmlContentsItem* m_Index;
|
||||||
|
int m_IndexCnt;
|
||||||
|
// list of index items
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlHelpController();
|
||||||
|
~wxHtmlHelpController();
|
||||||
|
|
||||||
|
void SetTitleFormat(const wxString& format) {m_TitleFormat = format;}
|
||||||
|
// Sets format of title of the frame. Must contain exactly one "%s"
|
||||||
|
// (for title of displayed HTML page)
|
||||||
|
|
||||||
|
void SetTempDir(const wxString& path);
|
||||||
|
// Sets directory where temporary files are stored.
|
||||||
|
// These temp files are index & contents file in binary (much faster to read)
|
||||||
|
// form. These files are NOT deleted on program's exit.
|
||||||
|
|
||||||
|
bool AddBook(const wxString& book, bool show_wait_msg = FALSE);
|
||||||
|
// Adds new book. 'book' is location of .htb file (stands for "html book").
|
||||||
|
// See documentation for details on its format.
|
||||||
|
// Returns success.
|
||||||
|
// If show_wait_msg == true then message window with "loading book..." is displayed
|
||||||
|
|
||||||
|
void Display(const wxString& x);
|
||||||
|
// Displays page x. If not found it will offect the user a choice of searching
|
||||||
|
// books.
|
||||||
|
// Looking for the page runs in these steps:
|
||||||
|
// 1. try to locate file named x (if x is for example "doc/howto.htm")
|
||||||
|
// 2. try to open starting page of book x
|
||||||
|
// 3. try to find x in contents (if x is for example "How To ...")
|
||||||
|
// 4. try to find x in index (if x is for example "How To ...")
|
||||||
|
// 5. offer searching and if the user agree, run KeywordSearch
|
||||||
|
void Display(const int id);
|
||||||
|
// Alternative version that works with numeric ID.
|
||||||
|
// (uses extension to MS format, <param name="ID" value=id>, see docs)
|
||||||
|
|
||||||
|
void DisplayContents();
|
||||||
|
// Displays help window and focuses contents.
|
||||||
|
|
||||||
|
void DisplayIndex();
|
||||||
|
// Displays help window and focuses index.
|
||||||
|
|
||||||
|
bool KeywordSearch(const wxString& keyword);
|
||||||
|
// Searches for keyword. Returns TRUE and display page if found, return
|
||||||
|
// FALSE otherwise
|
||||||
|
// Syntax of keyword is Altavista-like:
|
||||||
|
// * words are separated by spaces
|
||||||
|
// (but "\"hello world\"" is only one world "hello world")
|
||||||
|
// * word may be pretended by + or -
|
||||||
|
// (+ : page must contain the word ; - : page can't contain the word)
|
||||||
|
// * if there is no + or - before the word, + is default
|
||||||
|
|
||||||
|
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) {m_Config = config; m_ConfigRoot = rootpath;}
|
||||||
|
// Assigns config object to the controller. This config is then
|
||||||
|
// used in subsequent calls to Read/WriteCustomization of both help
|
||||||
|
// controller and it's wxHtmlWindow
|
||||||
|
|
||||||
|
void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// saves custom settings into cfg config. it will use the path 'path'
|
||||||
|
// if given, otherwise it will save info into currently selected path.
|
||||||
|
// saved values : things set by SetFonts, SetBorders.
|
||||||
|
void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// ...
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void CreateHelpWindow();
|
||||||
|
// Creates frame & html window and sets m_Frame and other variables;
|
||||||
|
// Do nothing if the window already exists
|
||||||
|
void RefreshLists();
|
||||||
|
// Refreshes Contents and Index tabs
|
||||||
|
void CreateContents();
|
||||||
|
// Adds items to m_Contents tree control
|
||||||
|
void CreateIndex();
|
||||||
|
// Adds items to m_IndexList
|
||||||
|
|
||||||
|
void LoadMSProject(HtmlBookRecord *book, wxFileSystem& fsys, const wxString& indexfile, const wxString& contentsfile, bool show_wait_msg);
|
||||||
|
// Imports .hhp files (MS HTML Help Workshop)
|
||||||
|
void LoadCachedBook(HtmlBookRecord *book, wxInputStream *f);
|
||||||
|
// Reads binary book
|
||||||
|
void SaveCachedBook(HtmlBookRecord *book, wxOutputStream *f);
|
||||||
|
// Writes binary book
|
||||||
|
|
||||||
|
void OnToolbar(wxCommandEvent& event);
|
||||||
|
void OnContentsSel(wxTreeEvent& event);
|
||||||
|
void OnIndexSel(wxCommandEvent& event);
|
||||||
|
void OnSearchSel(wxCommandEvent& event);
|
||||||
|
void OnSearch(wxCommandEvent& event);
|
||||||
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLHELP_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
176
include/wx/html/htmlparser.h
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlparser.h
|
||||||
|
// Purpose: wxHtmlParser class (generic parser)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLPARSER_H__
|
||||||
|
#define __HTMLPARSER_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/html/htmltag.h>
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
|
||||||
|
class wxHtmlParser;
|
||||||
|
class wxHtmlTagHandler;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlParser
|
||||||
|
// This class handles generic parsing of HTML document : it scans
|
||||||
|
// the document and divide it into blocks of tags (where one block
|
||||||
|
// consists of starting and ending tag and of text between these
|
||||||
|
// 2 tags.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlParser : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxHtmlParser)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString m_Source;
|
||||||
|
// source being parsed
|
||||||
|
wxHtmlTagsCache *m_Cache;
|
||||||
|
// tags cache, used during parsing.
|
||||||
|
wxHashTable m_HandlersHash;
|
||||||
|
wxList m_HandlersList;
|
||||||
|
// handlers that handle particular tags. The table is accessed by
|
||||||
|
// key = tag's name.
|
||||||
|
// This attribute MUST be filled by derived class otherwise it would
|
||||||
|
// be empty and no tags would be recognized
|
||||||
|
// (see wxHtmlWinParser for details about filling it)
|
||||||
|
// m_HandlersHash is for random access based on knowledge of tag name (BR, P, etc.)
|
||||||
|
// it may (and often does) contain more references to one object
|
||||||
|
// m_HandlersList is list of all handlers and it is guaranteed to contain
|
||||||
|
// only one reference to each handler instance.
|
||||||
|
wxFileSystem *m_FS;
|
||||||
|
// class for opening files (file system)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlParser() : wxObject(), m_HandlersHash(wxKEY_STRING) {m_FS = NULL; m_Cache = NULL;}
|
||||||
|
virtual ~wxHtmlParser();
|
||||||
|
|
||||||
|
void SetFS(wxFileSystem *fs) {m_FS = fs;}
|
||||||
|
// Sets the class which will be used for opening files
|
||||||
|
wxFileSystem* GetFS() const {return m_FS;}
|
||||||
|
|
||||||
|
wxObject* Parse(const wxString& source);
|
||||||
|
// You can simply call this method when you need parsed output.
|
||||||
|
// This method does these things:
|
||||||
|
// 1. call InitParser(source);
|
||||||
|
// 2. call DoParsing();
|
||||||
|
// 3. call GetProduct(); (it's return value is then returned)
|
||||||
|
// 4. call DoneParser();
|
||||||
|
|
||||||
|
virtual void InitParser(const wxString& source);
|
||||||
|
// Sets the source. This must be called before running Parse() method.
|
||||||
|
virtual void DoneParser();
|
||||||
|
// This must be called after Parse().
|
||||||
|
|
||||||
|
void DoParsing(int begin_pos, int end_pos);
|
||||||
|
inline void DoParsing() {DoParsing(0, m_Source.Length());};
|
||||||
|
// Parses the m_Source from begin_pos to end_pos-1.
|
||||||
|
// (in noparams version it parses whole m_Source)
|
||||||
|
|
||||||
|
virtual wxObject* GetProduct() = 0;
|
||||||
|
// Returns product of parsing
|
||||||
|
// Returned value is result of parsing of the part. The type of this result
|
||||||
|
// depends on internal representation in derived parser
|
||||||
|
// (see wxHtmlWinParser for details).
|
||||||
|
|
||||||
|
virtual void AddTagHandler(wxHtmlTagHandler *handler);
|
||||||
|
// adds handler to the list & hash table of handlers.
|
||||||
|
|
||||||
|
wxString* GetSource() {return &m_Source;}
|
||||||
|
|
||||||
|
virtual wxList* GetTempData() {return NULL;}
|
||||||
|
// this method returns list of wxObjects that represents
|
||||||
|
// all data allocated by the parser. These can't be freeded
|
||||||
|
// by destructor because they must be valid as long as
|
||||||
|
// GetProduct's return value is valid - the caller must
|
||||||
|
// explicitly call delete MyParser -> GetTempData() to free
|
||||||
|
// the memory
|
||||||
|
// (this method always sets the list to delete its contents)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void AddText(const char* txt) = 0;
|
||||||
|
// Adds text to the output.
|
||||||
|
// This is called from Parse() and must be overriden in derived classes.
|
||||||
|
// txt is not guaranteed to be only one word. It is largest continuous part of text
|
||||||
|
// (= not broken by tags)
|
||||||
|
// NOTE : using char* because of speed improvements
|
||||||
|
|
||||||
|
virtual void AddTag(const wxHtmlTag& tag);
|
||||||
|
// Adds tag and proceeds it. Parse() may (and usually is) called from this method.
|
||||||
|
// This is called from Parse() and may be overriden.
|
||||||
|
// Default behavior is that it looks for proper handler in m_Handlers. The tag is
|
||||||
|
// ignored if no hander is found.
|
||||||
|
// Derived class is *responsible* for filling in m_Handlers table.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagHandler
|
||||||
|
// This class (and derived classes) cooperates with wxHtmlParser.
|
||||||
|
// Each recognized tag is passed to handler which is capable
|
||||||
|
// of handling it. Each tag is handled in 3 steps:
|
||||||
|
// 1. Handler will modifies state of parser
|
||||||
|
// (using it's public methods)
|
||||||
|
// 2. Parser parses source between starting and ending tag
|
||||||
|
// 3. Handler restores original state of the parser
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlTagHandler : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxHtmlTagHandler)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxHtmlParser *m_Parser;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlTagHandler() : wxObject () {m_Parser = NULL;};
|
||||||
|
|
||||||
|
virtual void SetParser(wxHtmlParser *parser) {m_Parser = parser;}
|
||||||
|
// Sets the parser.
|
||||||
|
// NOTE : each _instance_ of handler is guaranteed to be called
|
||||||
|
// only by one parser. This means you don't have to care about
|
||||||
|
// reentrancy.
|
||||||
|
|
||||||
|
virtual wxString GetSupportedTags() = 0;
|
||||||
|
// Returns list of supported tags. The list is in uppercase and
|
||||||
|
// tags are delimited by ','.
|
||||||
|
// Example : "I,B,FONT,P"
|
||||||
|
// is capable of handling italic, bold, font and paragraph tags
|
||||||
|
|
||||||
|
virtual bool HandleTag(const wxHtmlTag& tag) = 0;
|
||||||
|
// This is hadling core method. It does all the Steps 1-3.
|
||||||
|
// To process step 2, you can call ParseInner()
|
||||||
|
// returned value : TRUE if it called ParseInner(),
|
||||||
|
// FALSE etherwise
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void ParseInner(const wxHtmlTag& tag) {m_Parser -> DoParsing(tag.GetBeginPos(), tag.GetEndPos1());}
|
||||||
|
// parses input between beginning and ending tag.
|
||||||
|
// m_Parser must be set.
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLPARSER_H__
|
||||||
|
|
||||||
|
#endif
|
135
include/wx/html/htmltag.h
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmltag.h
|
||||||
|
// Purpose: wxHtmlTag class (represents single tag)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLTAG_H__
|
||||||
|
#define __HTMLTAG_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagsCache
|
||||||
|
// !! INTERNAL STRUCTURE !! Do not use in your program!
|
||||||
|
// This structure contains information on positions of tags
|
||||||
|
// in the string being parsed
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int Key;
|
||||||
|
// this is "pos" value passed to wxHtmlTag's constructor.
|
||||||
|
// it is position of '<' character of the tag
|
||||||
|
int End1, End2;
|
||||||
|
// end positions for the tag:
|
||||||
|
// end1 is '<' of ending tag,
|
||||||
|
// end2 is '>' or both are
|
||||||
|
// -1 if there is no ending tag for this one...
|
||||||
|
// or -2 if this is ending tag </...>
|
||||||
|
char *Name;
|
||||||
|
// name of this tag
|
||||||
|
} sCacheItem;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class wxHtmlTagsCache : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
|
||||||
|
|
||||||
|
private:
|
||||||
|
sCacheItem *m_Cache;
|
||||||
|
int m_CacheSize;
|
||||||
|
int m_CachePos;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
|
||||||
|
wxHtmlTagsCache(const wxString& source);
|
||||||
|
~wxHtmlTagsCache() {free(m_Cache);}
|
||||||
|
|
||||||
|
void QueryTag(int at, int* end1, int* end2);
|
||||||
|
// Finds parameters for tag starting at at and fills the variables
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlTag
|
||||||
|
// This represents single tag. It is used as internal structure
|
||||||
|
// by wxHtmlParser.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlTag : public wxObject
|
||||||
|
{
|
||||||
|
DECLARE_CLASS(wxHtmlTag)
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_Name, m_Params;
|
||||||
|
int m_Begin, m_End1, m_End2;
|
||||||
|
bool m_Ending;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
|
||||||
|
// constructs wxHtmlTag object based on HTML tag.
|
||||||
|
// The tag begins (with '<' character) at position pos in source
|
||||||
|
// end_pos is position where parsing ends (usually end of document)
|
||||||
|
|
||||||
|
inline wxString GetName() const {return m_Name;};
|
||||||
|
// Returns tag's name in uppercase.
|
||||||
|
|
||||||
|
bool HasParam(const wxString& par) const;
|
||||||
|
// Returns TRUE if the tag has given parameter. Parameter
|
||||||
|
// should always be in uppercase.
|
||||||
|
// Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
|
||||||
|
|
||||||
|
wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
|
||||||
|
// Returns value of the param. Value is in uppercase unless it is
|
||||||
|
// enclosed with "
|
||||||
|
// Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
|
||||||
|
// <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
|
||||||
|
// (or ("WhaT.jpg") if with_commas == TRUE)
|
||||||
|
|
||||||
|
void ScanParam(const wxString& par, char *format, ...) const;
|
||||||
|
// Scans param like scanf() functions family do.
|
||||||
|
// Example : ScanParam("COLOR", "\"#%X\"", &clr);
|
||||||
|
// This is always with with_commas=FALSE
|
||||||
|
|
||||||
|
inline const wxString& GetAllParams() const {return m_Params;};
|
||||||
|
// Returns string containing all params.
|
||||||
|
|
||||||
|
inline bool IsEnding() const {return m_Ending;};
|
||||||
|
// return TRUE if this is ending tag (</something>) or FALSE
|
||||||
|
// if it isn't (<something>)
|
||||||
|
|
||||||
|
inline bool HasEnding() const {return m_End1 >= 0;};
|
||||||
|
// return TRUE if this is ending tag (</something>) or FALSE
|
||||||
|
// if it isn't (<something>)
|
||||||
|
|
||||||
|
inline int GetBeginPos() const {return m_Begin;};
|
||||||
|
// returns beginning position of _internal_ block of text
|
||||||
|
// See explanation (returned value is marked with *):
|
||||||
|
// bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
|
||||||
|
inline int GetEndPos1() const {return m_End1;};
|
||||||
|
// returns ending position of _internal_ block of text.
|
||||||
|
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
|
||||||
|
inline int GetEndPos2() const {return m_End2;};
|
||||||
|
// returns end position 2 :
|
||||||
|
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLTAG_H__
|
||||||
|
|
||||||
|
#endif
|
220
include/wx/html/htmlwin.h
Normal file
@@ -0,0 +1,220 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlwin.h
|
||||||
|
// Purpose: wxHtmlWindow class for parsing & displaying HTML
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLWIN_H__
|
||||||
|
#define __HTMLWIN_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/window.h>
|
||||||
|
#include <wx/config.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/html/htmlwinparser.h>
|
||||||
|
#include <wx/html/htmlcell.h>
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
#include <wx/html/htmlfilter.h>
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlWindow
|
||||||
|
// (This is probably the only class you will directly use.)
|
||||||
|
// Purpose of this class is to display HTML page (either local
|
||||||
|
// file or downloaded via HTTP protocol) in a window. Width
|
||||||
|
// of window is constant - given in constructor - virtual height
|
||||||
|
// is changed dynamicly depending on page size.
|
||||||
|
// Once the window is created you can set it's content by calling
|
||||||
|
// SetPage(text) or LoadPage(filename).
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// item of history list
|
||||||
|
class WXDLLEXPORT HtmlHistoryItem : public wxObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxString m_Page;
|
||||||
|
wxString m_Anchor;
|
||||||
|
int m_Pos;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;}
|
||||||
|
int GetPos() const {return m_Pos;}
|
||||||
|
void SetPos(int p) {m_Pos = p;}
|
||||||
|
const wxString& GetPage() const {return m_Page;}
|
||||||
|
const wxString& GetAnchor() const {return m_Anchor;}
|
||||||
|
};
|
||||||
|
|
||||||
|
#undef WXDLLEXPORTLOCAL
|
||||||
|
#define WXDLLEXPORTLOCAL WXDLLEXPORT
|
||||||
|
// ?? Don't know why - but Allen Van Sickel reported it to fix problems with DLL
|
||||||
|
|
||||||
|
WX_DECLARE_OBJARRAY(HtmlHistoryItem, HtmlHistoryArray);
|
||||||
|
|
||||||
|
#undef WXDLLEXPORTLOCAL
|
||||||
|
#define WXDLLEXPORTLOCAL
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlWindow)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxHtmlContainerCell *m_Cell;
|
||||||
|
// This is pointer to the first cell in parsed data.
|
||||||
|
// (Note: the first cell is usually top one = all other cells are sub-cells of this one)
|
||||||
|
wxHtmlWinParser *m_Parser;
|
||||||
|
// parser which is used to parse HTML input.
|
||||||
|
// Each wxHtmlWindow has it's own parser because sharing one global
|
||||||
|
// parser would be problematic (because of reentrancy)
|
||||||
|
wxString m_OpenedPage;
|
||||||
|
// contains name of actualy opened page or empty string if no page opened
|
||||||
|
wxString m_OpenedAnchor;
|
||||||
|
// contains name of current anchor within m_OpenedPage
|
||||||
|
wxFileSystem* m_FS;
|
||||||
|
// class for opening files (file system)
|
||||||
|
|
||||||
|
wxFrame *m_RelatedFrame;
|
||||||
|
wxString m_TitleFormat;
|
||||||
|
int m_RelatedStatusBar;
|
||||||
|
// frame in which page title should be displayed & number of it's statusbar
|
||||||
|
// reserved for usage with this html window
|
||||||
|
|
||||||
|
int m_Borders;
|
||||||
|
// borders (free space between text and window borders)
|
||||||
|
// defaults to 10 pixels.
|
||||||
|
|
||||||
|
bool m_Scrollable;
|
||||||
|
// TRUE if you can scroll the window.
|
||||||
|
// If it is FALSE you can't scroll the window even if it's contents is larger
|
||||||
|
// than window.
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_tmpMouseMoved;
|
||||||
|
// a flag indicated if mouse moved
|
||||||
|
// (if TRUE we will try to change cursor in last call to OnIdle)
|
||||||
|
bool m_tmpCanDraw;
|
||||||
|
// if FALSE contents of the window is not redrawn
|
||||||
|
// (in order to avoid ugly bliking)
|
||||||
|
|
||||||
|
static wxList m_Filters;
|
||||||
|
// list of HTML filters
|
||||||
|
static wxHtmlFilterPlainText m_DefaultFilter;
|
||||||
|
// this filter is used when no filter is able to read some file
|
||||||
|
|
||||||
|
HtmlHistoryArray m_History;
|
||||||
|
int m_HistoryPos;
|
||||||
|
// browser history
|
||||||
|
bool m_HistoryOn;
|
||||||
|
// if this FLAG is false, items are not added to history
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlWindow() : wxScrolledWindow() {};
|
||||||
|
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
|
||||||
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
|
const wxString& name = "htmlWindow", bool scrollable = TRUE);
|
||||||
|
~wxHtmlWindow();
|
||||||
|
|
||||||
|
bool SetPage(const wxString& source);
|
||||||
|
// Set HTML page and display it. !! source is HTML document itself,
|
||||||
|
// it is NOT address/filename of HTML document. If you want to
|
||||||
|
// specify document location, use LoadPage() istead
|
||||||
|
// Return value : FALSE if an error occured, TRUE otherwise
|
||||||
|
|
||||||
|
bool LoadPage(const wxString& location);
|
||||||
|
// Load HTML page from given location. Location can be either
|
||||||
|
// a) /usr/wxGTK2/docs/html/wx.htm
|
||||||
|
// b) http://www.somewhere.uk/document.htm
|
||||||
|
// c) ftp://ftp.somesite.cz/pub/something.htm
|
||||||
|
// In case there is no prefix (http:,ftp:), the method
|
||||||
|
// will try to find it itself (1. local file, then http or ftp)
|
||||||
|
// After the page is loaded, the method calls SetPage() to display it.
|
||||||
|
// Note : you can also use path relative to previously loaded page
|
||||||
|
// Return value : same as SetPage
|
||||||
|
|
||||||
|
wxString GetOpenedPage() const {return m_OpenedPage;}
|
||||||
|
// Returns full location of opened page
|
||||||
|
|
||||||
|
void SetRelatedFrame(wxFrame* frame, const wxString& format);
|
||||||
|
// sets frame in which page title will be displayed. Format is format of
|
||||||
|
// frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s
|
||||||
|
wxFrame* GetRelatedFrame() const {return m_RelatedFrame;}
|
||||||
|
|
||||||
|
void SetRelatedStatusBar(int bar);
|
||||||
|
// after(!) calling SetRelatedFrame, this sets statusbar slot where messages
|
||||||
|
// will be displayed. Default is -1 = no messages.
|
||||||
|
|
||||||
|
void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes);
|
||||||
|
// sets fonts to be used when displaying HTML page.
|
||||||
|
// *_italic_mode can be either wxSLANT or wxITALIC
|
||||||
|
|
||||||
|
void SetTitle(const wxString& title);
|
||||||
|
// Sets the title of the window
|
||||||
|
// (depending on the information passed to SetRelatedFrame() method)
|
||||||
|
|
||||||
|
void SetBorders(int b) {m_Borders = b;}
|
||||||
|
// Sets space between text and window borders.
|
||||||
|
|
||||||
|
virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// saves custom settings into cfg config. it will use the path 'path'
|
||||||
|
// if given, otherwise it will save info into currently selected path.
|
||||||
|
// saved values : things set by SetFonts, SetBorders.
|
||||||
|
virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
|
||||||
|
// ...
|
||||||
|
|
||||||
|
bool HistoryBack();
|
||||||
|
bool HistoryForward();
|
||||||
|
// Goes to previous/next page (in browsing history)
|
||||||
|
// Returns TRUE if successful, FALSE otherwise
|
||||||
|
void HistoryClear();
|
||||||
|
// Resets history
|
||||||
|
|
||||||
|
wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;}
|
||||||
|
// Returns pointer to conteiners/cells structure.
|
||||||
|
// It should be used ONLY when printing
|
||||||
|
|
||||||
|
static void AddFilter(wxHtmlFilter *filter);
|
||||||
|
// Adds input filter
|
||||||
|
|
||||||
|
virtual void OnLinkClicked(const wxString& link);
|
||||||
|
// called when users clicked on hypertext link. Default behavior is to
|
||||||
|
// call LoadPage(loc)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool ScrollToAnchor(const wxString& anchor);
|
||||||
|
// Scrolls to anchor of this name. (Anchor is #news
|
||||||
|
// or #features etc. it is part of address sometimes:
|
||||||
|
// http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html#news)
|
||||||
|
// Return value : TRUE if anchor exists, FALSE otherwise
|
||||||
|
|
||||||
|
void CreateLayout();
|
||||||
|
// prepare layout (= fill m_PosX, m_PosY for fragments) based on actual size of
|
||||||
|
// window. This method also setup scrollbars
|
||||||
|
|
||||||
|
void OnDraw(wxDC& dc);
|
||||||
|
void OnSize(wxSizeEvent& event);
|
||||||
|
void OnMouseEvent(wxMouseEvent& event);
|
||||||
|
void OnIdle(wxIdleEvent& event);
|
||||||
|
void OnKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLWIN_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
219
include/wx/html/htmlwinparser.h
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlwinparser.h
|
||||||
|
// Purpose: wxHtmlWinParser class (parser to be used with wxHtmlWindow)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __HTMLWINPARSER_H__
|
||||||
|
#define __HTMLWINPARSER_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/module.h>
|
||||||
|
#include <wx/html/htmlparser.h>
|
||||||
|
#include <wx/html/htmlcell.h>
|
||||||
|
|
||||||
|
class wxHtmlWinParser;
|
||||||
|
class wxHtmlWinTagHandler;
|
||||||
|
class wxHtmlTagsModule;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlWinParser
|
||||||
|
// This class is derived from wxHtmlParser and its mail goal
|
||||||
|
// is to parse HTML input so that it can be displayed in
|
||||||
|
// wxHtmlWindow. It uses special wxHtmlWinTagHandler.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlWinParser)
|
||||||
|
|
||||||
|
friend class wxHtmlWindow;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow *m_Window;
|
||||||
|
// window we're parsing for
|
||||||
|
wxDC *m_DC;
|
||||||
|
// Device Context we're parsing for
|
||||||
|
static wxList m_Modules;
|
||||||
|
// list of tags modules (see wxHtmlTagsModule for details)
|
||||||
|
// This list is used to initialize m_Handlers member.
|
||||||
|
|
||||||
|
wxHtmlContainerCell *m_Container;
|
||||||
|
// actual container. See Open/CloseContainer for details.
|
||||||
|
|
||||||
|
int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not TRUE,FALSE but 1,0, we need it for indexing
|
||||||
|
int m_FontSize; /* -2 to +4, 0 is default */
|
||||||
|
wxColour m_LinkColor;
|
||||||
|
wxColour m_ActualColor;
|
||||||
|
// basic font parameters.
|
||||||
|
wxString m_Link;
|
||||||
|
// actual hypertext link or empty string
|
||||||
|
bool m_UseLink;
|
||||||
|
// TRUE if m_Link is not empty
|
||||||
|
long m_CharHeight, m_CharWidth;
|
||||||
|
// average height of normal-sized text
|
||||||
|
int m_Align;
|
||||||
|
// actual alignment
|
||||||
|
|
||||||
|
wxFont *m_FontsTable[2][2][2][2][7];
|
||||||
|
// table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off
|
||||||
|
// state of these flags (from left to right):
|
||||||
|
// [bold][italic][underlined][fixed_size]
|
||||||
|
// last index is font size : from 0 to 7 (remapped from html sizes -2 to +4)
|
||||||
|
// Note : this table covers all possible combinations of fonts, but not
|
||||||
|
// all of them are used, so many items in table are usually NULL.
|
||||||
|
int m_FontsSizes[7];
|
||||||
|
wxString m_FontFaceFixed, m_FontFaceNormal;
|
||||||
|
int m_ItalicModeFixed, m_ItalicModeNormal;
|
||||||
|
// html font sizes and faces of fixed and proportional fonts
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlWinParser() : wxHtmlParser() {wxHtmlWinParser(NULL);}
|
||||||
|
wxHtmlWinParser(wxWindow *wnd);
|
||||||
|
|
||||||
|
virtual void InitParser(const wxString& source);
|
||||||
|
virtual void DoneParser();
|
||||||
|
virtual wxObject* GetProduct();
|
||||||
|
|
||||||
|
virtual void SetDC(wxDC *dc) {m_DC = dc;}
|
||||||
|
// Set's the DC used for parsing. If SetDC() is not called,
|
||||||
|
// parsing won't proceed
|
||||||
|
wxDC *GetDC() {return m_DC;}
|
||||||
|
int GetCharHeight() const {return m_CharHeight;}
|
||||||
|
int GetCharWidth() const {return m_CharWidth;}
|
||||||
|
// NOTE : these functions do _not_ return _actual_
|
||||||
|
// height/width. They return h/w of default font
|
||||||
|
// for this DC. If you want actual values, call
|
||||||
|
// GetDC() -> GetChar...()
|
||||||
|
wxWindow *GetWindow() {return m_Window;}
|
||||||
|
// returns associated wxWindow
|
||||||
|
|
||||||
|
void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes);
|
||||||
|
// sets fonts to be used when displaying HTML page.
|
||||||
|
// *_italic_mode can be either wxSLANT or wxITALIC
|
||||||
|
|
||||||
|
virtual wxList* GetTempData();
|
||||||
|
|
||||||
|
static void AddModule(wxHtmlTagsModule *module);
|
||||||
|
// Adds tags module. see wxHtmlTagsModule for details.
|
||||||
|
|
||||||
|
// parsing-related methods. These methods are called by tag handlers:
|
||||||
|
wxHtmlContainerCell *GetContainer() const {return m_Container;}
|
||||||
|
// Returns pointer to actual container. Common use in tag handler is :
|
||||||
|
// m_WParser -> GetContainer() -> InsertCell(new ...);
|
||||||
|
wxHtmlContainerCell *OpenContainer();
|
||||||
|
// opens new container. This container is sub-container of opened
|
||||||
|
// container. Sets GetContainer to newly created container
|
||||||
|
// and returns it.
|
||||||
|
wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
|
||||||
|
// works like OpenContainer except that new container is not created
|
||||||
|
// but c is used. You can use this to directly set actual container
|
||||||
|
wxHtmlContainerCell *CloseContainer();
|
||||||
|
// closes the container and sets actual Container to upper-level
|
||||||
|
// container
|
||||||
|
|
||||||
|
int GetFontSize() const {return m_FontSize;}
|
||||||
|
void SetFontSize(int s) {m_FontSize = s;}
|
||||||
|
int GetFontBold() const {return m_FontBold;}
|
||||||
|
void SetFontBold(int x) {m_FontBold = x;}
|
||||||
|
int GetFontItalic() const {return m_FontItalic;}
|
||||||
|
void SetFontItalic(int x) {m_FontItalic = x;}
|
||||||
|
int GetFontUnderlined() const {return m_FontUnderlined;}
|
||||||
|
void SetFontUnderlined(int x) {m_FontUnderlined = x;}
|
||||||
|
int GetFontFixed() const {return m_FontFixed;}
|
||||||
|
void SetFontFixed(int x) {m_FontFixed = x;}
|
||||||
|
|
||||||
|
int GetAlign() const {return m_Align;}
|
||||||
|
void SetAlign(int a) {m_Align = a;}
|
||||||
|
const wxColour& GetLinkColor() const {return m_LinkColor;}
|
||||||
|
void SetLinkColor(const wxColour& clr) {m_LinkColor = clr;}
|
||||||
|
const wxColour& GetActualColor() const {return m_ActualColor;}
|
||||||
|
void SetActualColor(const wxColour& clr) {m_ActualColor = clr;}
|
||||||
|
const wxString& GetLink() const {return m_Link;}
|
||||||
|
void SetLink(const wxString& link) {m_Link = link; m_UseLink = link.Length() > 0;}
|
||||||
|
|
||||||
|
virtual wxFont* CreateCurrentFont();
|
||||||
|
// creates font depending on m_Font* members.
|
||||||
|
// (note : it calls wxHtmlWindow's CreateCurrentFont...)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void AddText(const char *txt);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_tmpLastWasSpace;
|
||||||
|
// temporary variable used by AddText
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlWinTagHandler
|
||||||
|
// This is basicly wxHtmlTagHandler except
|
||||||
|
// it is extended with protected member m_Parser pointing to
|
||||||
|
// the wxHtmlWinParser object
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler
|
||||||
|
{
|
||||||
|
DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler)
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxHtmlWinParser *m_WParser;
|
||||||
|
// same as m_Parser, but overcasted
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlWinTagHandler() : wxHtmlTagHandler() {};
|
||||||
|
|
||||||
|
virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagsModule
|
||||||
|
// This is basic of dynamic tag handlers binding.
|
||||||
|
// The class provides methods for filling parser's handlers
|
||||||
|
// hash table.
|
||||||
|
// (See documentation for details)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxHtmlTagsModule : public wxModule
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxHtmlTagsModule() : wxModule() {};
|
||||||
|
|
||||||
|
virtual bool OnInit();
|
||||||
|
virtual void OnExit();
|
||||||
|
|
||||||
|
virtual void FillHandlersTable(wxHtmlWinParser *parser) {}
|
||||||
|
// This is called by wxHtmlWinParser.
|
||||||
|
// The method must simply call parser->AddTagHandler(new <handler_class_name>);
|
||||||
|
// for each handler
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __HTMLWINPARSER_H__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
102
include/wx/html/mod_templ.h
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mod_templ.h
|
||||||
|
// Purpose: wxHtml tags module generic "template"
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
This is set of macros for easier writing of tag handlers. How to use it?
|
||||||
|
See mod_fonts.cpp for example...
|
||||||
|
|
||||||
|
Attention! This is quite strange C++ bastard. Before using it,
|
||||||
|
I STRONGLY recommend reading and understanding these macros!!
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MOD_TEMPL_H__
|
||||||
|
#define __MOD_TEMPL_H__
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/html/htmlwinparser.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define TAG_HANDLER_BEGIN(name,tags) \
|
||||||
|
class HTML_Handler_##name : public wxHtmlWinTagHandler \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
wxString GetSupportedTags() {return tags;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TAG_HANDLER_VARS \
|
||||||
|
private:
|
||||||
|
|
||||||
|
#define TAG_HANDLER_CONSTR(name) \
|
||||||
|
public: \
|
||||||
|
HTML_Handler_##name () : wxHtmlWinTagHandler()
|
||||||
|
|
||||||
|
|
||||||
|
#define TAG_HANDLER_PROC(varib) \
|
||||||
|
public: \
|
||||||
|
bool HandleTag(const wxHtmlTag& varib)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TAG_HANDLER_END(name) \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TAGS_MODULE_BEGIN(name) \
|
||||||
|
class HTML_Module##name : public wxHtmlTagsModule \
|
||||||
|
{ \
|
||||||
|
DECLARE_DYNAMIC_CLASS(HTML_Module##name ) \
|
||||||
|
public: \
|
||||||
|
void FillHandlersTable(wxHtmlWinParser *parser) \
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TAGS_MODULE_ADD(handler) \
|
||||||
|
parser -> AddTagHandler(new HTML_Handler_##handler);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define TAGS_MODULE_END(name) \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(HTML_Module##name , wxHtmlTagsModule)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
BIN
include/wx/html/msw/back.bmp
Normal file
After Width: | Height: | Size: 202 B |
BIN
include/wx/html/msw/book.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/folder.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/forward.bmp
Normal file
After Width: | Height: | Size: 202 B |
BIN
include/wx/html/msw/page.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/panel.bmp
Normal file
After Width: | Height: | Size: 710 B |
16
include/wx/html/msw/wxhtml.rc
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// This file contains bitmaps used
|
||||||
|
// by wxHtmlHelpController
|
||||||
|
// Include it in your .rc file if you're using wxHTML help system
|
||||||
|
// (#include "wx/html/msw/wxhtml.rc")
|
||||||
|
//
|
||||||
|
|
||||||
|
back BITMAP "wx/html/msw/back.bmp"
|
||||||
|
forward BITMAP "wx/html/msw/forward.bmp"
|
||||||
|
panel BITMAP "wx/html/msw/panel.bmp"
|
||||||
|
|
||||||
|
book ICON "wx/html/msw/book.ico"
|
||||||
|
folder ICON "wx/html/msw/folder.ico"
|
||||||
|
page ICON "wx/html/msw/page.ico"
|
||||||
|
|
7
include/wx/html/version.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
#define wxHTML_VERSION_MAJOR 0
|
||||||
|
#define wxHTML_VERSION_MINOR 2
|
||||||
|
#define wxHTML_VERSION_REL 3
|
||||||
|
|
||||||
|
#define wxHTML_VERSION (wxHTML_VERSION_MAJOR * 1000 + wxHTML_VERSION_MINOR * 100 + wxHTML_VERSION_REL)
|
||||||
|
|
@@ -198,6 +198,8 @@
|
|||||||
// wxWindow::SetToolTip() method
|
// wxWindow::SetToolTip() method
|
||||||
#define wxUSE_SOCKETS 0
|
#define wxUSE_SOCKETS 0
|
||||||
// Set to 1 to use socket classes
|
// Set to 1 to use socket classes
|
||||||
|
#define wxUSE_HTML 0
|
||||||
|
// Set to 1 to use wxHTML sub-library
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finer detail
|
* Finer detail
|
||||||
|
27
include/wx/wxhtml.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wxhtml.h
|
||||||
|
// Purpose: wxHTML library for wxWindows
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __WXHTML_H__
|
||||||
|
#define __WXHTML_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/html/version.h>
|
||||||
|
#include <wx/html/htmldefs.h>
|
||||||
|
#include <wx/html/htmltag.h>
|
||||||
|
#include <wx/html/htmlcell.h>
|
||||||
|
#include <wx/html/htmlparser.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
#include <wx/html/htmlwinparser.h>
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
#include <wx/html/htmlhelp.h>
|
||||||
|
|
||||||
|
#endif // __WXHTML_H__
|
70
include/wx/zipstream.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: zipstream.h
|
||||||
|
// Purpose: wxZipInputStream for reading files from ZIP archive
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __ZIPSTREAM_H__
|
||||||
|
#define __ZIPSTREAM_H__
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_ZLIB && wxUSE_STREAMS
|
||||||
|
|
||||||
|
#include <wx/stream.h>
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxZipInputStream
|
||||||
|
// This class is input stream from ZIP archive. The archive
|
||||||
|
// must be local file (accessible via FILE*)
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxZipInputStream : public wxInputStream
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
size_t m_Size;
|
||||||
|
off_t m_Pos;
|
||||||
|
void *m_Archive;
|
||||||
|
// this void* is handle of archive .
|
||||||
|
// I'm sorry it is void and not proper type but I don't want
|
||||||
|
// to make unzip.h header public.
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxZipInputStream(const wxString& archive, const wxString& file);
|
||||||
|
// archive is name of .zip archive, file is name of file to be extracted.
|
||||||
|
// Remember that archive must be local file accesible via fopen, fread functions!
|
||||||
|
~wxZipInputStream();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual size_t StreamSize() const {return m_Size;}
|
||||||
|
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
||||||
|
virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||||
|
virtual off_t OnSysTell() const {return m_Pos;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // if use_zlib && use_streams
|
||||||
|
|
||||||
|
#endif // __ZIPSTREAM_H__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
8
samples/html/Makefile.am
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
## Purpose: The automake makefile for wxHTML samples
|
||||||
|
## Author: VS
|
||||||
|
## Version: $Id$
|
||||||
|
##
|
||||||
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
|
SUBDIRS = about help printing test virtual widget zip
|
||||||
|
|
9
samples/html/about/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = about
|
||||||
|
|
||||||
|
about_SOURCES = about.cpp
|
174
samples/html/about/about.cpp
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: test.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#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/wxhtml.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);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
|
wxPoint(50, 50), wxSize(150, 50));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_About, "&About");
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
wxDialog dlg(this, -1, "About", wxDefaultPosition, wxSize(400, 230), wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE);
|
||||||
|
|
||||||
|
html = new wxHtmlWindow(&dlg, -1, wxPoint(10, 10), wxSize(380, 160), "htmlWindow", FALSE);
|
||||||
|
html -> SetBorders(0);
|
||||||
|
html -> LoadPage("data/about.htm");
|
||||||
|
wxButton *bu1 = new wxButton(&dlg, wxID_OK, "OK", wxPoint(250, 185), wxSize(100, 30));
|
||||||
|
bu1 -> SetDefault();
|
||||||
|
dlg.ShowModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
samples/html/about/about.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
17
samples/html/about/data/about.htm
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"><table cellspacing=3 cellpadding=4 width="100%">
|
||||||
|
<tr><td bgcolor="#101010">
|
||||||
|
<center><font size=+2 color="#FFFFFF"><b>
|
||||||
|
<br>wxHTML Library Sample 0.2.0<br>
|
||||||
|
</b></font></center>
|
||||||
|
<tr><td bgcolor="#73A183">
|
||||||
|
<b><font size=+1>Copyright (C) 1999 Vaclav Slavik</font></b><p>
|
||||||
|
<font size=-1>
|
||||||
|
<table cellpadding=0 cellspacing=0 width="100%">
|
||||||
|
<tr><td width="65%">
|
||||||
|
Vaclav Slavik (slavik2@czn.cz)<br>Someone Else (selse@hell.org)<p>
|
||||||
|
<td valign=top><img src="logo.png">
|
||||||
|
</table>
|
||||||
|
<font size=-2>
|
||||||
|
The wxHTML library is available at <font color="#0000FF">http://www.ms.mff.cuni.cz/~vsla8348/wxhtml</font><br>
|
||||||
|
The library is licenced under wxWindows Library Licence, Version 3.
|
||||||
|
</font></font></table></body></html>
|
BIN
samples/html/about/data/logo.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
9
samples/html/help/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = help
|
||||||
|
|
||||||
|
help_SOURCES = help.cpp
|
85
samples/html/help/help.cpp
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: test.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#pragma interface
|
||||||
|
#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/wxhtml.h>
|
||||||
|
#if (( wxVERSION_NUMBER < 2100 ) || (( wxVERSION_NUMBER == 2100 ) && (wxBETA_NUMBER <= 4)))
|
||||||
|
#include <wx/imaggif.h>
|
||||||
|
#endif
|
||||||
|
#include <wx/config.h>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
|
class MyApp : public wxApp
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxHtmlHelpController help;
|
||||||
|
wxConfig* config;
|
||||||
|
|
||||||
|
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)
|
||||||
|
bool OnInit();
|
||||||
|
int OnExit();
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
config = new wxConfig("wxHTMLhelp");
|
||||||
|
#if wxUSE_LIBPNG
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
#endif
|
||||||
|
#if wxUSE_LIBJPEG
|
||||||
|
wxImage::AddHandler(new wxJPEGHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
help.UseConfig(config);
|
||||||
|
help.SetTempDir("tmp");
|
||||||
|
help.AddBook("helpfiles/testing.hhp");
|
||||||
|
help.Display("Main page");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyApp::OnExit()
|
||||||
|
{
|
||||||
|
delete config;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
samples/html/help/help.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
#include "wx/html/msw/wxhtml.rc"
|
24
samples/html/help/helpfiles/Index.hhk
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
||||||
|
<!-- Sitemap 1.0 -->
|
||||||
|
</HEAD><BODY>
|
||||||
|
<UL>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="1">
|
||||||
|
<param name="Name" value="Book 1">
|
||||||
|
<param name="Local" value="book1.htm">
|
||||||
|
</OBJECT>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="main">
|
||||||
|
<param name="Name" value="Untitled: d:\HELPS\testing\main.htm">
|
||||||
|
<param name="Local" value="main.htm">
|
||||||
|
</OBJECT>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="2">
|
||||||
|
<param name="Name" value="Book 1">
|
||||||
|
<param name="Local" value="book2.htm">
|
||||||
|
</OBJECT>
|
||||||
|
</UL>
|
||||||
|
</BODY></HTML>
|
4
samples/html/help/helpfiles/book1.htm
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<html><title>Book 1</title><body>
|
||||||
|
<h2>Book 1.</h2>
|
||||||
|
How do you enjoy <i> book one</i>??
|
||||||
|
</body></html>
|
5
samples/html/help/helpfiles/book2.htm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<html><title>Book 1</title><body>
|
||||||
|
<h2>Book 2.</h2>
|
||||||
|
How do you enjoy <i> book two</i>??
|
||||||
|
<p>Please click <a href="page2-b.htm">HERE</a>
|
||||||
|
</body></html>
|
33
samples/html/help/helpfiles/contents.hhc
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<meta name="GENERATOR" content="Microsoft® HTML Help Workshop 4.1">
|
||||||
|
<!-- Sitemap 1.0 -->
|
||||||
|
</HEAD><BODY>
|
||||||
|
<OBJECT type="text/site properties">
|
||||||
|
<param name="ImageType" value="Folder">
|
||||||
|
</OBJECT>
|
||||||
|
<UL>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="Main page">
|
||||||
|
<param name="Local" value="main.htm">
|
||||||
|
</OBJECT>
|
||||||
|
<UL>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="Book 1">
|
||||||
|
<param name="Local" value="book1.htm">
|
||||||
|
</OBJECT>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="Book 2">
|
||||||
|
<param name="ID" value=34>
|
||||||
|
<param name="Local" value="book2.htm">
|
||||||
|
</OBJECT>
|
||||||
|
<UL>
|
||||||
|
<LI> <OBJECT type="text/sitemap">
|
||||||
|
<param name="Name" value="sub book">
|
||||||
|
<param name="Local" value="page2-b.htm">
|
||||||
|
</OBJECT>
|
||||||
|
</UL>
|
||||||
|
</UL>
|
||||||
|
</UL>
|
||||||
|
</BODY></HTML>
|
5
samples/html/help/helpfiles/main.htm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<html><body>
|
||||||
|
<h2>This is main page.</h2>
|
||||||
|
<a href="book1.htm">Book 1</a><br>
|
||||||
|
<a href="book2.htm">Book 2</a><br>
|
||||||
|
</body></html>
|
5
samples/html/help/helpfiles/page2-b.htm
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<html><body>
|
||||||
|
<font color="#FF0000" size=+4 face="Tahoma">
|
||||||
|
Hello, you're on sub page of page 2 !!!
|
||||||
|
</font>
|
||||||
|
</body></html>
|
15
samples/html/help/helpfiles/testing.hhp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[OPTIONS]
|
||||||
|
Compatibility=1.1
|
||||||
|
Compiled file=testing.chm
|
||||||
|
Contents file=contents.hhc
|
||||||
|
Display compile progress=No
|
||||||
|
Index file=Index.hhk
|
||||||
|
Language=0x405 <20>esky
|
||||||
|
Title=Testing HELPFILE :-)
|
||||||
|
Default topic=main.htm
|
||||||
|
|
||||||
|
[FILES]
|
||||||
|
main.htm
|
||||||
|
book1.htm
|
||||||
|
book2.htm
|
||||||
|
page2-b.htm
|
9
samples/html/printing/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = printing
|
||||||
|
|
||||||
|
printing_SOURCES = printing.cpp
|
BIN
samples/html/printing/mondrian.ico
Normal file
After Width: | Height: | Size: 766 B |
44
samples/html/printing/mondrian.xpm
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char *mondrian_xpm[] = {
|
||||||
|
/* columns rows colors chars-per-pixel */
|
||||||
|
"32 32 6 1",
|
||||||
|
" c Black",
|
||||||
|
". c Blue",
|
||||||
|
"X c #00bf00",
|
||||||
|
"o c Red",
|
||||||
|
"O c Yellow",
|
||||||
|
"+ c Gray100",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" oooooo +++++++++++++++++++++++ ",
|
||||||
|
" ",
|
||||||
|
" ++++++ ++++++++++++++++++ .... ",
|
||||||
|
" ++++++ ++++++++++++++++++ .... ",
|
||||||
|
" ++++++ ++++++++++++++++++ .... ",
|
||||||
|
" ++++++ ++++++++++++++++++ .... ",
|
||||||
|
" ++++++ ++++++++++++++++++ .... ",
|
||||||
|
" ++++++ ++++++++++++++++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++++++++++++++++ ++++ ",
|
||||||
|
" ++++++ ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
||||||
|
" "
|
||||||
|
};
|
BIN
samples/html/printing/pic.png
Normal file
After Width: | Height: | Size: 31 KiB |
312
samples/html/printing/printing.cpp
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
/*
|
||||||
|
* File: printing.cc
|
||||||
|
* Purpose: Printing demo for wxWindows class library
|
||||||
|
* Author: Julian Smart
|
||||||
|
* modified by Vaclav Slavik (wxHTML stuffs)
|
||||||
|
* Created: 1995
|
||||||
|
* Updated:
|
||||||
|
* Copyright: (c) 1995, AIAI, University of Edinburgh
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* static const char sccsid[] = "%W% %G%"; */
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !wxUSE_PRINTING_ARCHITECTURE
|
||||||
|
#error You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h to compile this demo.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set this to 1 if you want to test PostScript printing under MSW.
|
||||||
|
// However, you'll also need to edit src/msw/makefile.nt.
|
||||||
|
|
||||||
|
//!!! DON'T DO THAT! This is wxHTML sample now
|
||||||
|
#define wxTEST_POSTSCRIPT_IN_MSW 0
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include "wx/metafile.h"
|
||||||
|
#include "wx/print.h"
|
||||||
|
#include "wx/printdlg.h"
|
||||||
|
|
||||||
|
#include "wx/accel.h"
|
||||||
|
|
||||||
|
#if wxTEST_POSTSCRIPT_IN_MSW
|
||||||
|
#include "wx/generic/printps.h"
|
||||||
|
#include "wx/generic/prntdlgg.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxhtml.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include "printing.h"
|
||||||
|
|
||||||
|
#ifndef __WXMSW__
|
||||||
|
#include "mondrian.xpm"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Global print data, to remember settings during the session
|
||||||
|
wxPrintData *g_printData = (wxPrintData*) NULL ;
|
||||||
|
|
||||||
|
// Global page setup data
|
||||||
|
wxPageSetupData* g_pageSetupData = (wxPageSetupData*) NULL;
|
||||||
|
|
||||||
|
|
||||||
|
// Declare a frame
|
||||||
|
MyFrame *frame = (MyFrame *) NULL;
|
||||||
|
wxHtmlWindow *html = NULL;
|
||||||
|
int orientation = wxPORTRAIT;
|
||||||
|
|
||||||
|
// Main proc
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
|
||||||
|
MyApp::MyApp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// The `main program' equivalent, creating the windows and returning the
|
||||||
|
// main frame
|
||||||
|
bool MyApp::OnInit(void)
|
||||||
|
{
|
||||||
|
g_printData = new wxPrintData;
|
||||||
|
g_pageSetupData = new wxPageSetupDialogData;
|
||||||
|
|
||||||
|
// Create the main frame window
|
||||||
|
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(600, 400));
|
||||||
|
|
||||||
|
// Give it a status line
|
||||||
|
frame->CreateStatusBar(2);
|
||||||
|
|
||||||
|
// Load icon and bitmap
|
||||||
|
frame->SetIcon( wxICON( mondrian) );
|
||||||
|
|
||||||
|
// Make a menubar
|
||||||
|
wxMenu *file_menu = new wxMenu;
|
||||||
|
|
||||||
|
file_menu->Append(WXPRINT_PRINT, "&Print...", "Print");
|
||||||
|
file_menu->Append(WXPRINT_PRINT_SETUP, "Print &Setup...", "Setup printer properties");
|
||||||
|
file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup");
|
||||||
|
file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview");
|
||||||
|
|
||||||
|
// Accelerators
|
||||||
|
wxAcceleratorEntry entries[1];
|
||||||
|
entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
|
||||||
|
wxAcceleratorTable accel(1, entries);
|
||||||
|
frame->SetAcceleratorTable(accel);
|
||||||
|
|
||||||
|
file_menu->AppendSeparator();
|
||||||
|
file_menu->Append(WXPRINT_QUIT, "E&xit", "Exit program");
|
||||||
|
|
||||||
|
wxMenu *help_menu = new wxMenu;
|
||||||
|
help_menu->Append(WXPRINT_ABOUT, "&About", "About this demo");
|
||||||
|
|
||||||
|
wxMenuBar *menu_bar = new wxMenuBar;
|
||||||
|
|
||||||
|
menu_bar->Append(file_menu, "&File");
|
||||||
|
menu_bar->Append(help_menu, "&Help");
|
||||||
|
|
||||||
|
// Associate the menu bar with the frame
|
||||||
|
frame->SetMenuBar(menu_bar);
|
||||||
|
|
||||||
|
frame->Centre(wxBOTH);
|
||||||
|
frame->Show(TRUE);
|
||||||
|
|
||||||
|
frame->SetStatusText("Printing demo");
|
||||||
|
|
||||||
|
SetTopWindow(frame);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyApp::OnExit()
|
||||||
|
{
|
||||||
|
delete g_printData;
|
||||||
|
delete g_pageSetupData;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
|
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
|
||||||
|
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
|
||||||
|
EVT_MENU(WXPRINT_PREVIEW, MyFrame::OnPrintPreview)
|
||||||
|
EVT_MENU(WXPRINT_PRINT_SETUP, MyFrame::OnPrintSetup)
|
||||||
|
EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
|
||||||
|
EVT_MENU(WXPRINT_ABOUT, MyFrame::OnPrintAbout)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Define my frame constructor
|
||||||
|
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
|
||||||
|
wxFrame(frame, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
html = new wxHtmlWindow(this);
|
||||||
|
html -> LoadPage("test.htm");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxPrinter printer;
|
||||||
|
MyPrintout printout("My printout");
|
||||||
|
if (!printer.Print(this, &printout, TRUE))
|
||||||
|
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxPrintData printData;
|
||||||
|
printData.SetOrientation(orientation);
|
||||||
|
|
||||||
|
// Pass two printout objects: for preview, and possible printing.
|
||||||
|
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printData);
|
||||||
|
if (!preview->Ok())
|
||||||
|
{
|
||||||
|
delete preview;
|
||||||
|
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
|
||||||
|
frame->Centre(wxBOTH);
|
||||||
|
frame->Initialize();
|
||||||
|
frame->Show(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxPrintDialogData printDialogData(* g_printData);
|
||||||
|
wxPrintDialog printerDialog(this, & printDialogData);
|
||||||
|
|
||||||
|
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
||||||
|
printerDialog.ShowModal();
|
||||||
|
|
||||||
|
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
(*g_pageSetupData) = * g_printData;
|
||||||
|
|
||||||
|
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
|
||||||
|
pageSetupDialog.ShowModal();
|
||||||
|
|
||||||
|
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
||||||
|
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
(void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\n\nModified by Vaclav Slavik to show wxHtml features",
|
||||||
|
"About wxWindows printing demo", wxOK|wxCENTRE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MyPrintout::OnPrintPage(int page)
|
||||||
|
{
|
||||||
|
wxDC *dc = GetDC();
|
||||||
|
if (dc)
|
||||||
|
{
|
||||||
|
if (page == 1)
|
||||||
|
DrawPageOne(dc);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyPrintout::OnBeginDocument(int startPage, int endPage)
|
||||||
|
{
|
||||||
|
if (!wxPrintout::OnBeginDocument(startPage, endPage))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
|
||||||
|
{
|
||||||
|
*minPage = 1;
|
||||||
|
*maxPage = 1;
|
||||||
|
*selPageFrom = 1;
|
||||||
|
*selPageTo = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MyPrintout::HasPage(int pageNum)
|
||||||
|
{
|
||||||
|
return (pageNum == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyPrintout::DrawPageOne(wxDC *dc)
|
||||||
|
{
|
||||||
|
int leftMargin = 20;
|
||||||
|
int topMargin = 40;
|
||||||
|
|
||||||
|
/* You might use THIS code to set the printer DC to ROUGHLY reflect
|
||||||
|
* the screen text size. This page also draws lines of actual length 5cm
|
||||||
|
* on the page.
|
||||||
|
*/
|
||||||
|
// Get the logical pixels per inch of screen and printer
|
||||||
|
int ppiScreenX, ppiScreenY;
|
||||||
|
GetPPIScreen(&ppiScreenX, &ppiScreenY);
|
||||||
|
int ppiPrinterX, ppiPrinterY;
|
||||||
|
GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
|
||||||
|
|
||||||
|
// Here we obtain internal cell representation of HTML document:
|
||||||
|
wxHtmlContainerCell *cell = html -> GetInternalRepresentation();
|
||||||
|
|
||||||
|
// Now we have to check in case our real page size is reduced
|
||||||
|
// (e.g. because we're drawing to a print preview memory DC)
|
||||||
|
int pageWidth, pageHeight;
|
||||||
|
int w, h;
|
||||||
|
dc->GetSize(&w, &h);
|
||||||
|
GetPageSizePixels(&pageWidth, &pageHeight);
|
||||||
|
|
||||||
|
// Now we must scale it somehow. The best would be to suppose that html window
|
||||||
|
// width is equal to page width:
|
||||||
|
|
||||||
|
float scale = (float)((float)(pageWidth - 0 * leftMargin)/((float)cell -> GetMaxLineWidth() + 2 * leftMargin));
|
||||||
|
|
||||||
|
// If printer pageWidth == current DC width, then this doesn't
|
||||||
|
// change. But w might be the preview bitmap width, so scale down.
|
||||||
|
float overallScale = scale * (float)(w/(float)pageWidth);
|
||||||
|
dc->SetUserScale(overallScale, overallScale);
|
||||||
|
|
||||||
|
// Calculate conversion factor for converting millimetres into
|
||||||
|
// logical units.
|
||||||
|
// There are approx. 25.1 mm to the inch. There are ppi
|
||||||
|
// device units to the inch. Therefore 1 mm corresponds to
|
||||||
|
// ppi/25.1 device units. We also divide by the
|
||||||
|
// screen-to-printer scaling factor, because we need to
|
||||||
|
// unscale to pass logical units to DrawLine.
|
||||||
|
|
||||||
|
dc->SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
|
// TESTING
|
||||||
|
|
||||||
|
int pageWidthMM, pageHeightMM;
|
||||||
|
GetPageSizeMM(&pageWidthMM, &pageHeightMM);
|
||||||
|
|
||||||
|
|
||||||
|
// This is all the printing :
|
||||||
|
cell -> Draw(*dc, leftMargin, topMargin, 0, cell -> GetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
76
samples/html/printing/printing.h
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* File: printing.h
|
||||||
|
* Purpose: Printing demo for wxWindows class library
|
||||||
|
* Author: Julian Smart
|
||||||
|
* Created: 1995
|
||||||
|
* Updated:
|
||||||
|
* Copyright: (c) 1995, AIAI, University of Edinburgh
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* sccsid[] = "%W% %G%" */
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Define a new application
|
||||||
|
class MyApp: public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyApp() ;
|
||||||
|
bool OnInit();
|
||||||
|
int OnExit();
|
||||||
|
};
|
||||||
|
|
||||||
|
DECLARE_APP(MyApp)
|
||||||
|
|
||||||
|
class MyCanvas;
|
||||||
|
|
||||||
|
// Define a new canvas and frame
|
||||||
|
class MyFrame: public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
|
void OnPrint(wxCommandEvent& event);
|
||||||
|
void OnPrintPreview(wxCommandEvent& event);
|
||||||
|
void OnPrintSetup(wxCommandEvent& event);
|
||||||
|
void OnPageSetup(wxCommandEvent& event);
|
||||||
|
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
|
||||||
|
void OnPrintPS(wxCommandEvent& event);
|
||||||
|
void OnPrintPreviewPS(wxCommandEvent& event);
|
||||||
|
void OnPrintSetupPS(wxCommandEvent& event);
|
||||||
|
void OnPageSetupPS(wxCommandEvent& event);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void OnExit(wxCommandEvent& event);
|
||||||
|
void OnPrintAbout(wxCommandEvent& event);
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MyPrintout: public wxPrintout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyPrintout(char *title = "My printout"):wxPrintout(title) {}
|
||||||
|
bool OnPrintPage(int page);
|
||||||
|
bool HasPage(int page);
|
||||||
|
bool OnBeginDocument(int startPage, int endPage);
|
||||||
|
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
||||||
|
|
||||||
|
void DrawPageOne(wxDC *dc);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define WXPRINT_QUIT 100
|
||||||
|
#define WXPRINT_PRINT 101
|
||||||
|
#define WXPRINT_PRINT_SETUP 102
|
||||||
|
#define WXPRINT_PAGE_SETUP 103
|
||||||
|
#define WXPRINT_PREVIEW 104
|
||||||
|
|
||||||
|
#define WXPRINT_PRINT_PS 105
|
||||||
|
#define WXPRINT_PRINT_SETUP_PS 106
|
||||||
|
#define WXPRINT_PAGE_SETUP_PS 107
|
||||||
|
#define WXPRINT_PREVIEW_PS 108
|
||||||
|
|
||||||
|
#define WXPRINT_ABOUT 109
|
||||||
|
|
3
samples/html/printing/printing.rc
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
mondrian ICON "mondrian.ico"
|
||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
126
samples/html/printing/test.htm
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||||
|
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
|
||||||
|
</HEAD>
|
||||||
|
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
|
||||||
|
This is - - default text, now switching to
|
||||||
|
<CENTER>
|
||||||
|
<P>center, now still ctr, now exiting</CENTER>
|
||||||
|
|
||||||
|
<P>exited!.<A HREF="#downtown">[link to down]</A>
|
||||||
|
<P>Hello, this *is* default charset (helvetica, probably) and it is displayed
|
||||||
|
with one <FONT COLOR="#FF0000">COLOR CHANGE</FONT>. Of course we
|
||||||
|
can have as many color changes as we can, what about this <FONT COLOR="#FF0000">M</FONT><FONT COLOR="#FFFF00">A</FONT><FONT COLOR="#33FF33">D</FONT><B><FONT COLOR="#FFFFFF"><FONT SIZE=+1>N</FONT></FONT></B>E<FONT COLOR="#999999">S</FONT><FONT COLOR="#CC33CC">S?</FONT>
|
||||||
|
<P><FONT COLOR="#000000">There was a space above.</FONT>
|
||||||
|
<BR>
|
||||||
|
<HR WIDTH="100%">This was a line. <TT>(BTW we are in <B>fixed</B> font
|
||||||
|
/ <I><U>typewriter</U> font</I> right now :-)</TT>
|
||||||
|
<BR>This is in <B>BOLD</B> face. This is <I>ITALIC.</I> This is <B><I><U>E
|
||||||
|
V E R Y T H I N G</U></I></B>.
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<CENTER>
|
||||||
|
<P>Right now, <FONT COLOR="#0000FF"><FONT SIZE=+4>centered REALLY Big Text</FONT></FONT>,
|
||||||
|
how do you like (space) it?</CENTER>
|
||||||
|
|
||||||
|
<DIV ALIGN=right>RIGHT: <FONT SIZE=-2>text-2, </FONT><FONT SIZE=-1>text-1,
|
||||||
|
</FONT>text+0,
|
||||||
|
<FONT SIZE=+1>text+1,
|
||||||
|
</FONT><FONT COLOR="#FF0000"><FONT SIZE=+2>text+2,
|
||||||
|
</FONT></FONT><FONT SIZE=+3>text+3,
|
||||||
|
</FONT><FONT SIZE=+4>text+4</FONT>
|
||||||
|
<BR><U><FONT SIZE=+1>we are right now</FONT></U></DIV>
|
||||||
|
|
||||||
|
<CENTER><U><FONT SIZE=+1>we are center now</FONT></U></CENTER>
|
||||||
|
<U><FONT SIZE=+1>we are left now.</FONT></U>
|
||||||
|
<P><I><FONT COLOR="#3366FF">Blue italic text is displayed there....</FONT></I>
|
||||||
|
<H1>
|
||||||
|
|
||||||
|
<HR ALIGN=LEFT SIZE=10 WIDTH="50%">This is heading one.</H1>
|
||||||
|
this is normal
|
||||||
|
<CENTER>
|
||||||
|
<H1>
|
||||||
|
This is <FONT COLOR="#33FF33">CENTERED</FONT> heading one</H1></CENTER>
|
||||||
|
<IMG SRC="pic.png" ALT="Testing image image" >and this is text......
|
||||||
|
<BR>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
item 1</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item 2</LI>
|
||||||
|
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
nested item</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
nested item 2</LI>
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item 3</LI>
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
<OL>
|
||||||
|
<LI>
|
||||||
|
item one</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item two</LI>
|
||||||
|
|
||||||
|
<OL>
|
||||||
|
<LI>
|
||||||
|
nsted item</LI>
|
||||||
|
</OL>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
last numbered item</LI>
|
||||||
|
</OL>
|
||||||
|
|
||||||
|
<H1>
|
||||||
|
Heading 1</H1>
|
||||||
|
<I>Italic text now...</I>
|
||||||
|
<H2>
|
||||||
|
<I>Heading 2</I></H2>
|
||||||
|
<I>and now?</I>
|
||||||
|
<H3>
|
||||||
|
Heading 3</H3>
|
||||||
|
|
||||||
|
<H4>
|
||||||
|
Heading 4</H4>
|
||||||
|
|
||||||
|
<H5>
|
||||||
|
Heading 5</H5>
|
||||||
|
|
||||||
|
<H6>
|
||||||
|
Heading 6</H6>
|
||||||
|
And this is normal text, once again :-)
|
||||||
|
<P>And yes, we're in <FONT SIZE=+4>HTML DOCUMENT, </FONT><FONT SIZE=+1>so
|
||||||
|
what about some nice <A HREF="fft.html">hypertext link</A>??</FONT>
|
||||||
|
<P>hello?
|
||||||
|
<CENTER>
|
||||||
|
<P>This is <A NAME="downtown"></A>centered paragraph</CENTER>
|
||||||
|
|
||||||
|
<P>Now, you will see some PRE text:
|
||||||
|
<PRE>// This is sample C++ code:
|
||||||
|
|
||||||
|
void main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
printf("Go away, man!\n");
|
||||||
|
i = 666;
|
||||||
|
printf("\n\n\nCRASH\n DOWN NOW. . . \n");
|
||||||
|
}</PRE>
|
||||||
|
|
||||||
|
<H3>
|
||||||
|
WWW</H3>
|
||||||
|
<A HREF="http://www.kde.org">This is WWW link to KDE site!</A>
|
||||||
|
<BR><A HREF="http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html">(one
|
||||||
|
folder up)</A>
|
||||||
|
</BODY>
|
||||||
|
</HTML>
|
9
samples/html/test/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = test
|
||||||
|
|
||||||
|
test_SOURCES = test.cpp
|
2474
samples/html/test/f.html
Normal file
144
samples/html/test/fft.html
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<head>
|
||||||
|
<META >
|
||||||
|
<META NAME="Author" CONTENT="Vaclav Slavik">
|
||||||
|
<META NAME="Keywords" CONTENT="wxWindows,HTML widget,HTML,free,Unix,Linux,Windows,cross-platform,wxHTML,LGPL">
|
||||||
|
<TITLE>wxHTML : wxWindows HTML library</TITLE>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body TEXT="#000000" BGCOLOR="#8D99BC" LINK="#51188E" VLINK="#51188E" ALINK="#FF0000">
|
||||||
|
|
||||||
|
<!-- TITLE BAR -->
|
||||||
|
|
||||||
|
<center>
|
||||||
|
<img src="pic/logo.png">
|
||||||
|
<p>
|
||||||
|
[ Intro & News ]
|
||||||
|
<a href="features.html.iso-8859-1">[ Features ]</a>
|
||||||
|
<a href="downloads.html.iso-8859-1">[ Download ]</a>
|
||||||
|
<a href="licence.html.iso-8859-1">[ Licence ]</a>
|
||||||
|
<a href="screenshots.html.iso-8859-1">[ Screenshots ]</a>
|
||||||
|
<a href="links.html.iso-8859-1">[ Links & Apps ]</a>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- PAGE -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- HEADLINE -->
|
||||||
|
|
||||||
|
<p align=center><b><font color="#9B3030">
|
||||||
|
|
||||||
|
<center><table bgcolor="#00000" width="60%" cellpadding=1>
|
||||||
|
<tr><td>
|
||||||
|
<table width="100%" cellspacing=1 cellpadding=0><tr><td bgcolor="#7783A2" valign=center><font color="#FFFFFF" size=+2><center>
|
||||||
|
|
||||||
|
Latest release 0.2.3
|
||||||
|
|
||||||
|
</center></font>
|
||||||
|
</table>
|
||||||
|
</table></center>
|
||||||
|
|
||||||
|
</font></b></p>
|
||||||
|
|
||||||
|
<center></center>
|
||||||
|
<div align=right><font size=-1>
|
||||||
|
<!-- begin include -->
|
||||||
|
2811<!-- end --> visitors since January 99
|
||||||
|
|
||||||
|
|
||||||
|
<br>Last updated on : June 13, 1999
|
||||||
|
|
||||||
|
|
||||||
|
</font></div>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
<table width="100%" cellspacing=0 cellpadding=6 border><tr><td width="30%" bgcolor="#7783A2" valign=top>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- NEWS -->
|
||||||
|
|
||||||
|
<h2><u>News</u></h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b><font color="#9B3030">13/06/1999</font> - CVS available! </b><br>
|
||||||
|
Thanks to Russell Smith, development version of wxHTML is available through CVS.
|
||||||
|
See Download page for details!
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b><font color="#9B3030">13/06/1999</font> - 0.2.3 release </b><br>
|
||||||
|
Only minor changes and bugfixes.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b><font color="#9B3030">16/05/1999</font> - New release </b><br>
|
||||||
|
Well, 0.2.1 is out. It contains some bug fixes (mainly related to Visual C++)
|
||||||
|
and new help controller that works with MS HTML Help Workshop projects as
|
||||||
|
it's native format. Patch from previous version is only 30kB so don't hesitate
|
||||||
|
to download it!
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><b><font color="#9B3030">02/05/1999</font> - Beta release 0.2 is out!</b><br>
|
||||||
|
Ok, it's here, download it! Help controller is included (and broken under
|
||||||
|
MSW/Mingw32 - I'll fix it asap. If anyone can help with it, please do so...)
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- INTRO -->
|
||||||
|
|
||||||
|
<td valign=top>
|
||||||
|
<h2><u>Intro</u></h2>
|
||||||
|
|
||||||
|
I started work on this library in January, 1999.
|
||||||
|
<br>The main goal was to provide light-weight HTML viewer for
|
||||||
|
<a href="http://web.ukonline.co.uk/julian.smart/wxwin">wxWindows 2</a> toolkit.
|
||||||
|
This viewer was expected to be used as help/documentation browser rather than full-featured web browser.
|
||||||
|
|
||||||
|
<p>This library is released under <b><font color="#330000"><a href="licence.html.iso-8859-1">
|
||||||
|
wxWindows Library Licence, Version 3</a></font>.</b> It is basically
|
||||||
|
GNU Library General Public Licence except that it makes using
|
||||||
|
wxHTML in commercial products much easier.
|
||||||
|
|
||||||
|
<p>The library should work on all platforms supported by wxWindows - it
|
||||||
|
is written as poor wxWindows-only code, without line of platform-specific
|
||||||
|
code (as I hope :-). It is known to compile under these enviromnets:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>EGCS under Linux
|
||||||
|
<li>Cygwin b20 or Mingw32 under Windows 95
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- AUTHOR -->
|
||||||
|
|
||||||
|
<h2><u>Author(s)</u></h2>
|
||||||
|
<i>wxHTML (and this page) is copyrighted by Vaclav Slavik. Parts of wxHTML are copyrighted by other
|
||||||
|
autors - all of them are listed in <a href="#contrib">contributors</a> section.
|
||||||
|
</i>
|
||||||
|
<p>
|
||||||
|
Feel free to send your suggestions, comments, bug reports to me. My
|
||||||
|
e-mail address is
|
||||||
|
|
||||||
|
<br><A HREF="mailto:slavik2@czn.cz">slavik2@czn.cz</A>
|
||||||
|
<br>or
|
||||||
|
<br><A HREF="mailto:vsla8348@ss1000.ms.mff.cuni.cz">vsla8348@ss1000.ms.mff.cuni.cz</A>
|
||||||
|
<p align=right>Vaclav Slavik
|
||||||
|
|
||||||
|
|
||||||
|
<a name="contrib"><h2><u>Contributors</u></h2></a>
|
||||||
|
<ul>
|
||||||
|
<li><b><u>Guillermo Rodriguez Garcia</u></b> (<a href="mailto:guille@iies.es">guille@iies.es</a>)
|
||||||
|
<br>contributed GIF reading routines
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
samples/html/test/pic.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
samples/html/test/pic2.bmp
Normal file
After Width: | Height: | Size: 23 KiB |
116
samples/html/test/tables.htm
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||||
|
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
|
||||||
|
</HEAD>
|
||||||
|
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
|
||||||
|
|
||||||
|
<H3>
|
||||||
|
This is TABLES
|
||||||
|
tests page...</H3>
|
||||||
|
|
||||||
|
|
||||||
|
(yes, really, see bellow:)
|
||||||
|
<BR>Click <a href="test.htm">here</a> to go to original testing page...
|
||||||
|
<BR>Click <a href="../../docs/html/man.htm">here</a> to go to manuals...
|
||||||
|
<BR>
|
||||||
|
<CENTER><TABLE CELLSPACING=5 BORDER COLS=2 WIDTH="40%" NOSAVE >
|
||||||
|
<TR ALIGN=CENTER NOSAVE>
|
||||||
|
<TD WIDTH="40%" NOSAVE>Top left
|
||||||
|
<BR>(two lines expression)
|
||||||
|
<P>paragraph done</TD>
|
||||||
|
|
||||||
|
<TD NOSAVE>Top right</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR>
|
||||||
|
<TD>Bottom left</TD>
|
||||||
|
|
||||||
|
<TD>Bottom right</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE></CENTER>
|
||||||
|
|
||||||
|
<P>Subsampling is shown there:
|
||||||
|
<BR>
|
||||||
|
<TABLE BORDER COLS=2 WIDTH="100%" NOSAVE >
|
||||||
|
<TR NOSAVE>
|
||||||
|
<TD VALIGN=BOTTOM NOSAVE>
|
||||||
|
<TABLE BORDER COLS=2 WIDTH="50%" NOSAVE >
|
||||||
|
<TR ALIGN=CENTER BGCOLOR="#3366FF" NOSAVE>
|
||||||
|
<TD>a</TD>
|
||||||
|
|
||||||
|
<TD WIDTH="10%" NOSAVE>b</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR NOSAVE>
|
||||||
|
<TD>c</TD>
|
||||||
|
|
||||||
|
<TD NOSAVE>d</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
</TABLE>
|
||||||
|
</TD>
|
||||||
|
|
||||||
|
<TD VALIGN=BOTTOM NOSAVE>2</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR NOSAVE>
|
||||||
|
<TD>3 dflkj lkjfl dkjldkfjl flk jflkf lkjflkj ljlf ajlfj alff h khg hgj
|
||||||
|
gjg jg gjhfg fg gjh gjf jgf jgj f gjfgj kfajg </TD>
|
||||||
|
|
||||||
|
<TD ALIGN=CENTER VALIGN=BOTTOM BGCOLOR="#FFFF99" NOSAVE>4
|
||||||
|
<BR>gh
|
||||||
|
<BR>gfh
|
||||||
|
<BR>gh
|
||||||
|
<BR>hg
|
||||||
|
<BR>5</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
|
||||||
|
<P>This is "default" table - with no sizes givev:
|
||||||
|
<BR>
|
||||||
|
<TABLE BORDER COLS=4 WIDTH="100%" NOSAVE >
|
||||||
|
<TR NOSAVE>
|
||||||
|
<TD>Hello</TD>
|
||||||
|
|
||||||
|
<TD NOSAVE>lkfdsjlk fj dlfj lkfj lkjflk jlfk lk fjlk elwkf lkejflek f jlekjflkj
|
||||||
|
ljlk lk jlkf lefjl j flkj ljl lf lfj lfjl lj lwe lekf;eh kfejh lkh kjh
|
||||||
|
kjhkj hkj hkj lkh kjh kjlh kj</TD>
|
||||||
|
|
||||||
|
<TD>shortebn formo lr lk</TD>
|
||||||
|
|
||||||
|
<TD>djsf lkjlf poer oi pjr po kpk </TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR>
|
||||||
|
<TD>a</TD>
|
||||||
|
|
||||||
|
<TD>b</TD>
|
||||||
|
|
||||||
|
<TD>c</TD>
|
||||||
|
|
||||||
|
<TD>d</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR NOSAVE>
|
||||||
|
<TD>1</TD>
|
||||||
|
|
||||||
|
<TD>2</TD>
|
||||||
|
|
||||||
|
<TD COLSPAN="2" ROWSPAN="2" NOSAVE>3</TD>
|
||||||
|
</TR>
|
||||||
|
|
||||||
|
<TR>
|
||||||
|
<TD>A</TD>
|
||||||
|
|
||||||
|
<TD>B</Td>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
203
samples/html/test/test.cpp
Normal file
@@ -0,0 +1,203 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: test.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#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>
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnBack(wxCommandEvent& event);
|
||||||
|
void OnForward(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
wxLogDebug("[starting testing app]");
|
||||||
|
#if wxUSE_LIBPNG
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
#endif
|
||||||
|
#if wxUSE_LIBJPEG
|
||||||
|
wxImage::AddHandler(new wxJPEGHandler);
|
||||||
|
#endif
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
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
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_About, "&Load wxWindows manual page");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
menuNav->Append(Minimal_Back, "Go &BACK");
|
||||||
|
menuNav->Append(Minimal_Forward, "Go &FORWARD");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuNav, "&Navigate");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
CreateStatusBar(1);
|
||||||
|
|
||||||
|
{
|
||||||
|
wxConfig *cfg = new wxConfig("wxHtmlTest");
|
||||||
|
html = new wxHtmlWindow(this);
|
||||||
|
html -> SetRelatedFrame(this, "HTML : %s");
|
||||||
|
html -> SetRelatedStatusBar(0);
|
||||||
|
html -> ReadCustomization(cfg);
|
||||||
|
delete cfg;
|
||||||
|
html -> LoadPage("test.htm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
wxLogDebug("about to save config...");
|
||||||
|
wxConfig *cfg = new wxConfig("wxHtmlTest");
|
||||||
|
html -> WriteCustomization(cfg);
|
||||||
|
delete cfg;
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
html -> LoadPage("fft.html");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnBack(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryBack()) wxMessageBox("You reached prehistory era!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnForward(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryForward()) wxMessageBox("No more items in history!");
|
||||||
|
}
|
266
samples/html/test/test.htm
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<HTML>
|
||||||
|
<HEAD>
|
||||||
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
||||||
|
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
|
||||||
|
</HEAD>
|
||||||
|
<BODY TEXT="#000000" BGCOLOR="#006600" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
|
||||||
|
|
||||||
|
<b><a href="tables.htm">click here to go to tables test page!</a></b>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This is - - default text, now switching to
|
||||||
|
<CENTER>
|
||||||
|
<P>center, now still ctr, now exiting</CENTER>
|
||||||
|
exited!.<A HREF="#downtown">[link to down]</A>
|
||||||
|
<P>Hello, this *is* default charset (helvetica, probably) and it is displayed
|
||||||
|
with one <FONT COLOR="#FF0000">COLOR CHANGE</FONT>. Of course we
|
||||||
|
can have as many color changes as we can, what about this <FONT COLOR="#FF0000">M</FONT><FONT COLOR="#FFFF00">A</FONT><FONT COLOR="#33FF33">D</FONT><B><FONT COLOR="#FFFFFF"><FONT SIZE=+1>N</FONT></FONT></B>E<FONT COLOR="#999999">S</FONT><FONT COLOR="#CC33CC">S?</FONT>
|
||||||
|
<P><FONT COLOR="#000000">There was a space above.</FONT>
|
||||||
|
<BR>
|
||||||
|
<HR WIDTH="100%">This was a line. <TT>(BTW we are in <B>fixed</B> font
|
||||||
|
/ <I><U>typewriter</U> font</I> right now :-)</TT>
|
||||||
|
<BR>This is in <B>BOLD</B> face. This is <I>ITALIC.</I> This is <B><I><U>E
|
||||||
|
V E R Y T H I N G</U></I></B>.
|
||||||
|
<BR>
|
||||||
|
<P><BR>
|
||||||
|
<CENTER>
|
||||||
|
<P>Right now, <FONT COLOR="#0000FF"><FONT SIZE=+4>centered REALLY Big Text</FONT></FONT>,
|
||||||
|
how do you like (space) it?</CENTER>
|
||||||
|
|
||||||
|
<DIV ALIGN=right>RIGHT: <FONT SIZE=-2>text-2, </FONT><FONT SIZE=-1>text-1,
|
||||||
|
</FONT>text+0,
|
||||||
|
<FONT SIZE=+1>text+1,
|
||||||
|
</FONT><FONT COLOR="#FF0000"><FONT SIZE=+2>text+2,
|
||||||
|
</FONT></FONT><FONT SIZE=+3>text+3,
|
||||||
|
</FONT><FONT SIZE=+4>text+4</FONT>
|
||||||
|
<BR><U><FONT SIZE=+1>we are right now</FONT></U></DIV>
|
||||||
|
|
||||||
|
<CENTER><U><FONT SIZE=+1>we are center now</FONT></U></CENTER>
|
||||||
|
<U><FONT SIZE=+1>we are left now.</FONT></U>
|
||||||
|
<P><I><FONT COLOR="#3366FF">Blue italic text is displayed there....</FONT></I>
|
||||||
|
<H1>
|
||||||
|
|
||||||
|
<HR ALIGN=LEFT SIZE=10 WIDTH="50%">This is heading one.</H1>
|
||||||
|
this is normal
|
||||||
|
<CENTER>
|
||||||
|
<H1>
|
||||||
|
This is <FONT COLOR="#33FF33">CENTERED</FONT> heading one</H1></CENTER>
|
||||||
|
<FONT COLOR="#FFFF00">Yes, hmmmmmmmmm........, right now, <TT>we should
|
||||||
|
display some tiny nice image</TT>, he?</FONT>
|
||||||
|
<BR><IMG SRC="pic.png" ALT="Testing image image" ><IMG SRC="pic2.bmp">and this is text......
|
||||||
|
<P><IMG SRC="pic.png" ALT="Testing image image" HEIGHT=200 WIDTH=327 ALIGN=CENTER>and
|
||||||
|
this is text......
|
||||||
|
<BR><A HREF="pic.png"><IMG SRC="pic.png" ALT="Testing image image" HEIGHT=160 WIDTH=100 ALIGN=TEXTTOP></A> (try clicking on the image :-) and
|
||||||
|
this is text......
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
item 1</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item 2</LI>
|
||||||
|
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
nested item</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
nested item 2</LI>
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item 3</LI>
|
||||||
|
</UL>
|
||||||
|
|
||||||
|
<OL>
|
||||||
|
<LI>
|
||||||
|
item one</LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
item two</LI>
|
||||||
|
|
||||||
|
<OL>
|
||||||
|
<LI>
|
||||||
|
nsted item</LI>
|
||||||
|
</OL>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
last numbered item</LI>
|
||||||
|
</OL>
|
||||||
|
|
||||||
|
<H1>
|
||||||
|
Heading 1</H1>
|
||||||
|
<I>Italic text now...</I>
|
||||||
|
<H2>
|
||||||
|
<I>Heading 2</I></H2>
|
||||||
|
<I>and now?</I>
|
||||||
|
<H3>
|
||||||
|
Heading 3</H3>
|
||||||
|
|
||||||
|
<H4>
|
||||||
|
Heading 4</H4>
|
||||||
|
|
||||||
|
<H5>
|
||||||
|
Heading 5</H5>
|
||||||
|
|
||||||
|
<H6>
|
||||||
|
Heading 6</H6>
|
||||||
|
And this is normal text, once again :-)
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<BR>
|
||||||
|
<P>And yes, we're in <FONT SIZE=+4>HTML DOCUMENT, </FONT><FONT SIZE=+1>so
|
||||||
|
what about some nice <A HREF="fft.html">hypertext link</A>??</FONT>
|
||||||
|
<P>hello?
|
||||||
|
<BR>
|
||||||
|
<P><BR>
|
||||||
|
<CENTER>
|
||||||
|
<P>This is <A NAME="downtown"></a>centered paragraph</CENTER>
|
||||||
|
|
||||||
|
<P>This is new par?
|
||||||
|
<P><B>We switched to BOLD</B>
|
||||||
|
<P><B>This is new paragraph</B> Bold is off now.
|
||||||
|
<P>new par
|
||||||
|
<P> -----------
|
||||||
|
<P><FONT SIZE=-2>Hello</FONT>
|
||||||
|
<OL><FONT SIZE=-2>this is standalone :-)</FONT>
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf
|
||||||
|
jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl
|
||||||
|
fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga
|
||||||
|
kjegiquw iuqdb qiud iquwd hurray googoo.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO two two two two two two twotwo TWO two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO</FONT></LI>
|
||||||
|
|
||||||
|
<BLOCKQUOTE><FONT SIZE=+0><B>(blockquote)</B>two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO</FONT>
|
||||||
|
<BLOCKQUOTE><FONT SIZE=+0>two two two two two two twotwo TWO two two two</FONT></BLOCKQUOTE>
|
||||||
|
<FONT SIZE=+0>two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO</FONT></BLOCKQUOTE>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO</FONT>
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item nyumber 3.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf
|
||||||
|
jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl
|
||||||
|
fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga
|
||||||
|
kjegiquw iuqdb qiud iquwd hurray googoo.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO two two two two two two twotwo TWO two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO two two two two two two twotwo TWO two
|
||||||
|
two two two two two twotwo TWO two two two two two two twotwo TWO two two
|
||||||
|
two two two two twotwo TWO two two two two two two twotwo TWO two two two
|
||||||
|
two two two twotwo TWO two two two two two two twotwo TWO two two two two
|
||||||
|
two two twotwo TWO two two two two two two twotwo TWO</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item nyumber 3.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf
|
||||||
|
jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl
|
||||||
|
fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga
|
||||||
|
kjegiquw iuqdb qiud iquwd hurray googoo.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO two two two two two two twotwo TWO two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO two two two two two two twotwo TWO two
|
||||||
|
two two two two two twotwo TWO two two two two two two twotwo TWO two two
|
||||||
|
two two two two twotwo TWO two two two two two two twotwo TWO two two two
|
||||||
|
two two two twotwo TWO two two two two two two twotwo TWO two two two two
|
||||||
|
two two twotwo TWO two two two two two two twotwo TWO</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item nyumber 3.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf
|
||||||
|
jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl
|
||||||
|
fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga
|
||||||
|
kjegiquw iuqdb qiud iquwd hurray googoo.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO two two two two two two twotwo TWO two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO two two two two two two twotwo TWO two
|
||||||
|
two two two two two twotwo TWO two two two two two two twotwo TWO two two
|
||||||
|
two two two two twotwo TWO two two two two two two twotwo TWO two two two
|
||||||
|
two two two twotwo TWO two two two two two two twotwo TWO two two two two
|
||||||
|
two two twotwo TWO two two two two two two twotwo TWO</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item nyumber 3.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item number one. iti lkdjfdl kjd lk jlkjdl kjlk jlf
|
||||||
|
jflkj d lfkjlkf jl jflkj flkwe lkhelf ;fk;fl kw;lfke ;ffj lkjflk wj lfjl
|
||||||
|
fkw ;k;ekf;lkfe ;kf;lk; ;j ;lrj;wfj;f ;eljfw; lfj;ewlfj dagdja gdj chga
|
||||||
|
kjegiquw iuqdb qiud iquwd hurray googoo.</FONT></LI>
|
||||||
|
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO two two two two two two twotwo TWO two two two two two two twotwo
|
||||||
|
TWO two two two two two two twotwo TWO two two two two two two twotwo TWO
|
||||||
|
two two two two two two twotwo TWO two two two two two two twotwo TWO</FONT></LI>
|
||||||
|
|
||||||
|
<P><BR><FONT SIZE=-2>two two two two two two twotwo TWO two two two two
|
||||||
|
two two twotwo TWO two two two two two two twotwo TWO two two two two two
|
||||||
|
two twotwo TWO</FONT>
|
||||||
|
<P><FONT SIZE=-2>two two two two two two twotwo TWO two two two two two
|
||||||
|
two twotwo TWO two two two two two two twotwo TWO two two two two two two
|
||||||
|
twotwo TWO</FONT>
|
||||||
|
<LI>
|
||||||
|
<FONT SIZE=-2>This is item nyumber 3.</FONT></LI>
|
||||||
|
</OL>
|
||||||
|
Now, you will see some PRE text:<p>
|
||||||
|
<PRE>// This is sample C++ code:
|
||||||
|
|
||||||
|
void main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
printf("Go away, man!\n");
|
||||||
|
i = 666;
|
||||||
|
printf("\n\n\nCRASH\n DOWN NOW. . . \n");
|
||||||
|
}</PRE>
|
||||||
|
|
||||||
|
<H3>WWW</H3>
|
||||||
|
<A HREF="http://www.kde.org">This is WWW link to KDE site!</A>
|
||||||
|
<BR>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<A HREF="http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html">(one folder up)</A>
|
||||||
|
<BR>
|
||||||
|
|
||||||
|
...
|
||||||
|
<BR>
|
||||||
|
...
|
||||||
|
<BR>
|
||||||
|
Link to normal text file : <a href="test.cpp">test.cpp</a>
|
||||||
|
<BR>
|
||||||
|
And link to BINARY : <a href="test">Unix</a> or <a href="test.exe">Windows</a>
|
||||||
|
<BR>
|
||||||
|
<a href="http://www.tue.nl">ANOTHER LINK(www.tue.nl)</a>
|
||||||
|
|
||||||
|
|
||||||
|
</BODY>
|
||||||
|
</HTML>
|
2
samples/html/test/test.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
9
samples/html/virtual/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = virtual
|
||||||
|
|
||||||
|
virtual_SOURCES = virtual.cpp
|
12
samples/html/virtual/start.htm
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>VFS Demo</title></head>
|
||||||
|
<body>
|
||||||
|
<h3>Virtual File Systems demonstration</h3>
|
||||||
|
|
||||||
|
Hello. This sample demonstrates VFS. Try the link (and have a look
|
||||||
|
at status bar before clicking on them)
|
||||||
|
<p>
|
||||||
|
<a href="myVFS:node"><b>Enter top level Node...</b></a>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
231
samples/html/virtual/virtual.cpp
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: virtua;.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
// demonstrates virtual file systems feature
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#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/html/htmlwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
// new handler class:
|
||||||
|
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include <wx/mstream.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MyVFS : public wxFileSystemHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyVFS() : wxFileSystemHandler() {}
|
||||||
|
|
||||||
|
wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||||
|
bool CanOpen(const wxString& location);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool MyVFS::CanOpen(const wxString& location)
|
||||||
|
{
|
||||||
|
return (GetProtocol(location) == "myVFS");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFSFile* MyVFS::OpenFile(wxFileSystem& fs, const wxString& location)
|
||||||
|
{
|
||||||
|
wxFSFile *f;
|
||||||
|
wxInputStream *str;
|
||||||
|
char *buf = (char*)malloc(1024);
|
||||||
|
|
||||||
|
sprintf(buf, "<html><body><h2><i>You're in Node <u>%s</u></i></h2><p>"
|
||||||
|
"Where do you want to go?<br><blockquote>"
|
||||||
|
"<a href=\"%s-1\">sub-1</a><br>"
|
||||||
|
"<a href=\"%s-2\">sub-2</a><br>"
|
||||||
|
"<a href=\"%s-3\">sub-3</a><br>"
|
||||||
|
"</blockquote></body></html>",
|
||||||
|
location.GetData(), location.GetData(), location.GetData(), location.GetData());
|
||||||
|
str = new wxMemoryInputStream(buf, strlen(buf));
|
||||||
|
f = new wxFSFile(str, location, "text/html", wxEmptyString);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnBack(wxCommandEvent& event);
|
||||||
|
void OnForward(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
frame->Show(TRUE);
|
||||||
|
SetTopWindow(frame);
|
||||||
|
wxFileSystem::AddHandler(new MyVFS);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
menuNav->Append(Minimal_Back, "Go &BACK");
|
||||||
|
menuNav->Append(Minimal_Forward, "Go &FORWARD");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuNav, "&Navigate");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
CreateStatusBar(1);
|
||||||
|
|
||||||
|
html = new wxHtmlWindow(this);
|
||||||
|
html -> SetRelatedFrame(this, "VFS Demo: '%s'");
|
||||||
|
html -> SetRelatedStatusBar(1);
|
||||||
|
html -> LoadPage("start.htm");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnBack(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryBack()) wxMessageBox("You reached prehistory era!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnForward(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryForward()) wxMessageBox("No more items in history!");
|
||||||
|
}
|
2
samples/html/virtual/virtual.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
9
samples/html/widget/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = widget
|
||||||
|
|
||||||
|
widget_SOURCES = widget.cpp
|
20
samples/html/widget/start.htm
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<html>
|
||||||
|
<head><title>Binder demo</title></head>
|
||||||
|
<body>
|
||||||
|
<h3>wxHtmlBinderCell demonstration</h3>
|
||||||
|
|
||||||
|
There is binded window somewhere around. Enjoy it.
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<center>
|
||||||
|
<mybind name="experimental binded window :-)" x=300 y=500>
|
||||||
|
</center>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<mybind name="(small one)" x=150 y=30>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<mybind name="a widget with floating width, hurray :-)" float=y x="50" y=50>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
244
samples/html/widget/widget.cpp
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: virtua;.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
// demonstrates virtual file systems feature
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#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/html/htmlwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
TAG HANDER FOR 'MYBIND' TAG
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/html/mod_templ.h>
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(MYBIND, "MYBIND")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
wxWindow *wnd;
|
||||||
|
int ax, ay;
|
||||||
|
int fl = 0;
|
||||||
|
|
||||||
|
tag.ScanParam("X", "%i", &ax);
|
||||||
|
tag.ScanParam("Y", "%i", &ay);
|
||||||
|
if (tag.HasParam("FLOAT")) fl = ax;
|
||||||
|
|
||||||
|
wnd = new wxTextCtrl( m_WParser -> GetWindow(), -1, tag.GetParam("NAME"),
|
||||||
|
wxPoint(0,0), wxSize(ax, ay), wxTE_MULTILINE );
|
||||||
|
wnd -> Show(TRUE);
|
||||||
|
|
||||||
|
m_WParser -> OpenContainer() -> InsertCell(new wxHtmlWidgetCell(wnd, fl));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(MYBIND)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(MyBind)
|
||||||
|
|
||||||
|
TAGS_MODULE_ADD(MYBIND)
|
||||||
|
|
||||||
|
TAGS_MODULE_END(MyBind)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnBack(wxCommandEvent& event);
|
||||||
|
void OnForward(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
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
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
menuNav->Append(Minimal_Back, "Go &BACK");
|
||||||
|
menuNav->Append(Minimal_Forward, "Go &FORWARD");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuNav, "&Navigate");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
CreateStatusBar(1);
|
||||||
|
|
||||||
|
html = new wxHtmlWindow(this);
|
||||||
|
html -> SetRelatedFrame(this, "VFS Demo: '%s'");
|
||||||
|
html -> SetRelatedStatusBar(1);
|
||||||
|
html -> LoadPage("start.htm");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnBack(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryBack()) wxMessageBox("You reached prehistory era!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnForward(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryForward()) wxMessageBox("No more items in history!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
samples/html/widget/widget.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
9
samples/html/zip/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
AUTOMAKE_OPTIONS = 1.3 no-dependencies
|
||||||
|
|
||||||
|
SUFFIXES = .cpp
|
||||||
|
|
||||||
|
DEFS = @DEFS@ $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
|
|
||||||
|
noinst_PROGRAMS = zip
|
||||||
|
|
||||||
|
zip_SOURCES = zip.cpp
|
BIN
samples/html/zip/pages.zip
Normal file
9
samples/html/zip/start.htm
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<html><body>
|
||||||
|
<h1>ZIP archive</h1>
|
||||||
|
<h3>feature demo</h3>
|
||||||
|
<p>
|
||||||
|
Click on this <a href="pages.zip#zip:test.htm">link</a> to load page stored in ZIP
|
||||||
|
archive (<a href="pages.zip">pages.zip</a>). Enjoy it!
|
||||||
|
|
||||||
|
|
||||||
|
</body></html>
|
195
samples/html/zip/zip.cpp
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: test.cpp
|
||||||
|
// Purpose: wxHtml testing example
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#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/fs_zip.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);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnBack(wxCommandEvent& event);
|
||||||
|
void OnForward(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Back,
|
||||||
|
Minimal_Forward,
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Back, MyFrame::OnBack)
|
||||||
|
EVT_MENU(Minimal_Forward, MyFrame::OnForward)
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
#if wxUSE_LIBPNG
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
#endif
|
||||||
|
#if wxUSE_LIBJPEG
|
||||||
|
wxImage::AddHandler(new wxJPEGHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxFileSystem::AddHandler(new wxZipFSHandler);
|
||||||
|
|
||||||
|
// Create the main application window
|
||||||
|
MyFrame *frame = new MyFrame("wxHtmlWindow testing application",
|
||||||
|
wxPoint(50, 50), wxSize(640, 480));
|
||||||
|
|
||||||
|
// Show it and tell the application that it's our main window
|
||||||
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
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
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlWindow *html;
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
|
{
|
||||||
|
// create a menu bar
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_Quit, "E&xit");
|
||||||
|
menuNav->Append(Minimal_Back, "Go &BACK");
|
||||||
|
menuNav->Append(Minimal_Forward, "Go &FORWARD");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuNav, "&Navigate");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
CreateStatusBar(1);
|
||||||
|
|
||||||
|
{
|
||||||
|
html = new wxHtmlWindow(this);
|
||||||
|
html -> SetRelatedFrame(this, "HTML : %s");
|
||||||
|
html -> SetRelatedStatusBar(0);
|
||||||
|
html -> LoadPage("start.htm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// event handlers
|
||||||
|
|
||||||
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
// TRUE is to force the frame to close
|
||||||
|
Close(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnBack(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryBack()) wxMessageBox("You reached prehistory era!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnForward(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
if (!html -> HistoryForward()) wxMessageBox("No more items in history!");
|
||||||
|
}
|
2
samples/html/zip/zip.rc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "wx/msw/wx.rc"
|
||||||
|
|
294
src/common/filesys.cpp
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: filesys.cpp
|
||||||
|
// Purpose: wxFileSystem class - interface for opening files
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include <wx/url.h>
|
||||||
|
#include <wx/module.h>
|
||||||
|
#include <wx/filesys.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxFileSystemHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxFileSystemHandler, wxObject)
|
||||||
|
|
||||||
|
wxMimeTypesManager wxFileSystemHandler::m_MimeMng;
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxFileSystemHandler::GetMimeTypeFromExt(const wxString& location)
|
||||||
|
{
|
||||||
|
wxString ext = wxEmptyString, mime = wxEmptyString;
|
||||||
|
wxString loc = GetRightLocation(location);
|
||||||
|
char c;
|
||||||
|
int l = loc.Length(), l2;
|
||||||
|
wxFileType *ft;
|
||||||
|
|
||||||
|
l2 = l;
|
||||||
|
for (int i = l-1; i >= 0; i--) {
|
||||||
|
c = loc[i];
|
||||||
|
if (c == '#') l2 = i + 1;
|
||||||
|
if (c == '.') {ext = loc.Right(l2-i-1); break;}
|
||||||
|
if ((c == '/') || (c == '\\') || (c == ':')) {return wxEmptyString;}
|
||||||
|
}
|
||||||
|
ft = m_MimeMng.GetFileTypeFromExtension(ext);
|
||||||
|
if (ft && (ft -> GetMimeType(&mime))) return mime;
|
||||||
|
else return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxFileSystemHandler::GetProtocol(const wxString& location) const
|
||||||
|
{
|
||||||
|
wxString s = wxEmptyString;
|
||||||
|
int i, l = location.Length();
|
||||||
|
bool fnd;
|
||||||
|
|
||||||
|
fnd = FALSE;
|
||||||
|
for (i = l-1; (i >= 0) && ((location[i] != '#') || (!fnd)); i--) {
|
||||||
|
if ((location[i] == ':') && (i != 1 /*win: C:\path*/)) fnd = TRUE;
|
||||||
|
}
|
||||||
|
if (!fnd) return "file";
|
||||||
|
for (++i; (i < l) && (location[i] != ':'); i++) s << location[i];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxFileSystemHandler::GetLeftLocation(const wxString& location) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
bool fnd;
|
||||||
|
|
||||||
|
fnd = FALSE;
|
||||||
|
for (i = location.Length()-1; i >= 0; i--) {
|
||||||
|
if ((location[i] == ':') && (i != 1 /*win: C:\path*/)) fnd = TRUE;
|
||||||
|
else if (fnd && (location[i] == '#')) return location.Left(i);
|
||||||
|
}
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxFileSystemHandler::GetRightLocation(const wxString& location) const
|
||||||
|
{
|
||||||
|
int i, l = location.Length();
|
||||||
|
int l2 = l + 1;
|
||||||
|
for (i = l-1; (i >= 0) && ((location[i] != ':') || (i == 1) || (location[i-2] == ':')); i--) {if (location[i] == '#') l2 = i + 1;}
|
||||||
|
if (i == 0) return wxEmptyString;
|
||||||
|
else return location.Mid(i + 1, l2 - i - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxFileSystemHandler::GetAnchor(const wxString& location) const
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
int l = location.Length();
|
||||||
|
|
||||||
|
for (int i = l-1; i >= 0; i--) {
|
||||||
|
c = location[i];
|
||||||
|
if (c == '#') return location.Right(l-i-1);
|
||||||
|
else if ((c == '.') || (c == '/') || (c == '\\') || (c == ':')) return wxEmptyString;
|
||||||
|
}
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxLocalFSHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxLocalFSHandler : public wxFileSystemHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool CanOpen(const wxString& location);
|
||||||
|
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxLocalFSHandler::CanOpen(const wxString& location)
|
||||||
|
{
|
||||||
|
return GetProtocol(location) == "file";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFSFile* wxLocalFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
|
||||||
|
{
|
||||||
|
wxString right = GetRightLocation(location);
|
||||||
|
if (wxFileExists(right))
|
||||||
|
return new wxFSFile(new wxFileInputStream(right),
|
||||||
|
right,
|
||||||
|
GetMimeTypeFromExt(location),
|
||||||
|
GetAnchor(location));
|
||||||
|
else return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxFileSystem
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxFileSystem, wxObject)
|
||||||
|
|
||||||
|
|
||||||
|
wxList wxFileSystem::m_Handlers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxFileSystem::ChangePathTo(const wxString& location, bool is_dir)
|
||||||
|
{
|
||||||
|
int i, pathpos = -1;
|
||||||
|
m_Path = location;
|
||||||
|
|
||||||
|
for (i = m_Path.Length()-1; i >= 0; i--)
|
||||||
|
if (m_Path[i] == '\\') m_Path.GetWritableChar(i) = '/'; // wanna be windows-safe
|
||||||
|
|
||||||
|
if (is_dir == FALSE) {
|
||||||
|
for (i = m_Path.Length()-1; i >= 0; i--) {
|
||||||
|
if (m_Path[i] == '/') {
|
||||||
|
if ((i > 1) && (m_Path[i-1] == '/') && (m_Path[i-2] == ':')) {
|
||||||
|
i -= 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pathpos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_Path[i] == ':') {
|
||||||
|
pathpos = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pathpos == -1) {
|
||||||
|
for (i = 0; i < (int) m_Path.Length(); i++) {
|
||||||
|
if (m_Path[i] == ':') {
|
||||||
|
//m_Path << '/';
|
||||||
|
m_Path.Remove(i+1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == (int) m_Path.Length()) m_Path = wxEmptyString;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (m_Path[m_Path.Length()-1] != '/') m_Path << '/';
|
||||||
|
m_Path.Remove(pathpos+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFSFile* wxFileSystem::OpenFile(const wxString& location)
|
||||||
|
{
|
||||||
|
wxString loc = location;
|
||||||
|
int i, ln;
|
||||||
|
char meta;
|
||||||
|
wxFSFile *s = NULL;
|
||||||
|
wxNode *node;
|
||||||
|
|
||||||
|
ln = loc.Length();
|
||||||
|
meta = 0;
|
||||||
|
for (i = 0; i < ln; i++) {
|
||||||
|
if (loc[i] == '\\') loc.GetWritableChar(i) = '/'; // wanna be windows-safe
|
||||||
|
if (!meta) switch (loc[i]) {
|
||||||
|
case '/' : case ':' : case '#' : meta = loc[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_LastName = wxEmptyString;
|
||||||
|
|
||||||
|
// try relative paths first :
|
||||||
|
if (meta != ':') {
|
||||||
|
node = m_Handlers.GetFirst();
|
||||||
|
while (node){
|
||||||
|
wxFileSystemHandler *h = (wxFileSystemHandler*) node -> GetData();
|
||||||
|
if (h -> CanOpen(m_Path + location)) {
|
||||||
|
s = h -> OpenFile(*this, m_Path + location);
|
||||||
|
if (s) {m_LastName = m_Path + location; break;}
|
||||||
|
}
|
||||||
|
node = node -> GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if failed, try absolute paths :
|
||||||
|
if (s == NULL) {
|
||||||
|
node = m_Handlers.GetFirst();
|
||||||
|
while (node){
|
||||||
|
wxFileSystemHandler *h = (wxFileSystemHandler*) node -> GetData();
|
||||||
|
if (h -> CanOpen(location)) {
|
||||||
|
s = h -> OpenFile(*this, location);
|
||||||
|
if (s) {m_LastName = location; break; }
|
||||||
|
}
|
||||||
|
node = node -> GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxFileSystem::AddHandler(wxFileSystemHandler *handler)
|
||||||
|
{
|
||||||
|
m_Handlers.Append(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///// Module:
|
||||||
|
|
||||||
|
class wxFileSystemModule : public wxModule
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxFileSystemModule)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool OnInit()
|
||||||
|
{
|
||||||
|
wxFileSystem::AddHandler(new wxLocalFSHandler);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
virtual void OnExit() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxFileSystemModule, wxModule)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
130
src/common/fs_inet.cpp
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: fs_inet.cpp
|
||||||
|
// Purpose: HTTP and FTP file system
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
REMARKS :
|
||||||
|
|
||||||
|
This FS creates local cache (in /tmp directory). The cache is freed
|
||||||
|
on program exit.
|
||||||
|
|
||||||
|
Size of cache is limited to cca 1000 items (due to GetTempFileName
|
||||||
|
limitation)
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/wfstream.h"
|
||||||
|
#include "wx/url.h"
|
||||||
|
#include "wx/filesys.h"
|
||||||
|
#include "wx/fs_inet.h"
|
||||||
|
|
||||||
|
class wxInetCacheNode : public wxObject
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxString m_Temp;
|
||||||
|
wxString m_Mime;
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxInetCacheNode(const wxString& l, const wxString& m) : wxObject() {m_Temp = l; m_Mime = m;}
|
||||||
|
const wxString& GetTemp() const {return m_Temp;}
|
||||||
|
const wxString& GetMime() const {return m_Mime;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxInternetFSHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
bool wxInternetFSHandler::CanOpen(const wxString& location)
|
||||||
|
{
|
||||||
|
wxString p = GetProtocol(location);
|
||||||
|
return (p == "http") || (p == "ftp");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
|
||||||
|
{
|
||||||
|
wxString right = GetProtocol(location) + ":" + GetRightLocation(location);
|
||||||
|
wxInputStream *s;
|
||||||
|
wxString content;
|
||||||
|
wxInetCacheNode *info;
|
||||||
|
|
||||||
|
info = (wxInetCacheNode*) m_Cache.Get(right);
|
||||||
|
|
||||||
|
// Add item into cache:
|
||||||
|
if (info == NULL) {
|
||||||
|
wxURL url(right);
|
||||||
|
s = url.GetInputStream();
|
||||||
|
content = url.GetProtocol().GetContentType();
|
||||||
|
if (content == wxEmptyString) content = GetMimeTypeFromExt(location);
|
||||||
|
if (s) {
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
wxGetTempFileName("wxhtml", buf);
|
||||||
|
info = new wxInetCacheNode(buf, content);
|
||||||
|
m_Cache.Put(right, info);
|
||||||
|
|
||||||
|
{ // ok, now copy it:
|
||||||
|
wxFileOutputStream sout(buf);
|
||||||
|
s -> Read(sout); // copy the stream
|
||||||
|
}
|
||||||
|
delete s;
|
||||||
|
}
|
||||||
|
else return NULL; //we can't open the URL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load item from cache:
|
||||||
|
s = new wxFileInputStream(info -> GetTemp());
|
||||||
|
if (s) {
|
||||||
|
return new wxFSFile(s,
|
||||||
|
right,
|
||||||
|
info -> GetMime(),
|
||||||
|
GetAnchor(location));
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxInternetFSHandler::~wxInternetFSHandler()
|
||||||
|
{
|
||||||
|
wxNode *n;
|
||||||
|
wxInetCacheNode *n2;
|
||||||
|
|
||||||
|
m_Cache.BeginFind();
|
||||||
|
while ((n = m_Cache.Next()) != NULL) {
|
||||||
|
n2 = (wxInetCacheNode*) n -> GetData();
|
||||||
|
wxRemoveFile(n2 -> GetTemp());
|
||||||
|
delete n2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
75
src/common/fs_zip.cpp
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: fs_zip.cpp
|
||||||
|
// Purpose: ZIP file system
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/filesys.h"
|
||||||
|
#include "wx/zipstream.h"
|
||||||
|
#include "wx/fs_zip.h"
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxZipFSHandler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxZipFSHandler::CanOpen(const wxString& location)
|
||||||
|
{
|
||||||
|
wxString p = GetProtocol(location);
|
||||||
|
return (p == "zip");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFSFile* wxZipFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxString& location)
|
||||||
|
{
|
||||||
|
wxString right = GetRightLocation(location);
|
||||||
|
wxString left = GetLeftLocation(location);
|
||||||
|
wxInputStream *s;
|
||||||
|
|
||||||
|
if (GetProtocol(left) != "file") {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = new wxZipInputStream(left, right);
|
||||||
|
if (s && (s -> LastError() == wxStream_NOERROR)) {
|
||||||
|
return new wxFSFile(s,
|
||||||
|
left + "#zip:" + right,
|
||||||
|
GetMimeTypeFromExt(location),
|
||||||
|
GetAnchor(location));
|
||||||
|
}
|
||||||
|
else return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxZipFSHandler::~wxZipFSHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1294
src/common/unzip.c
Normal file
275
src/common/unzip.h
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||||
|
Version 0.15 beta, Mar 19th, 1998,
|
||||||
|
|
||||||
|
Copyright (C) 1998 Gilles Vollant
|
||||||
|
|
||||||
|
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||||
|
WinZip, InfoZip tools and compatible.
|
||||||
|
Encryption and multi volume ZipFile (span) are not supported.
|
||||||
|
Old compressions used by old PKZip 1.x are not supported
|
||||||
|
|
||||||
|
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
|
||||||
|
CAN CHANGE IN FUTURE VERSION !!
|
||||||
|
I WAIT FEEDBACK at mail info@winimage.com
|
||||||
|
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
|
||||||
|
|
||||||
|
Condition of use and distribution are the same than zlib :
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
/* for more info about .ZIP format, see
|
||||||
|
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
|
||||||
|
PkWare has also a specification at :
|
||||||
|
ftp://ftp.pkware.com/probdesc.zip */
|
||||||
|
|
||||||
|
#ifndef _unz_H
|
||||||
|
#define _unz_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _ZLIB_H
|
||||||
|
#include "zlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
|
||||||
|
/* like the STRICT of WIN32, we define a pointer that cannot be converted
|
||||||
|
from (void*) without cast */
|
||||||
|
typedef struct TagunzFile__ { int unused; } unzFile__;
|
||||||
|
typedef unzFile__ *unzFile;
|
||||||
|
#else
|
||||||
|
typedef voidp unzFile;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define UNZ_OK (0)
|
||||||
|
#define UNZ_END_OF_LIST_OF_FILE (-100)
|
||||||
|
#define UNZ_ERRNO (Z_ERRNO)
|
||||||
|
#define UNZ_EOF (0)
|
||||||
|
#define UNZ_PARAMERROR (-102)
|
||||||
|
#define UNZ_BADZIPFILE (-103)
|
||||||
|
#define UNZ_INTERNALERROR (-104)
|
||||||
|
#define UNZ_CRCERROR (-105)
|
||||||
|
|
||||||
|
/* tm_unz contain date/time info */
|
||||||
|
typedef struct tm_unz_s
|
||||||
|
{
|
||||||
|
uInt tm_sec; /* seconds after the minute - [0,59] */
|
||||||
|
uInt tm_min; /* minutes after the hour - [0,59] */
|
||||||
|
uInt tm_hour; /* hours since midnight - [0,23] */
|
||||||
|
uInt tm_mday; /* day of the month - [1,31] */
|
||||||
|
uInt tm_mon; /* months since January - [0,11] */
|
||||||
|
uInt tm_year; /* years - [1980..2044] */
|
||||||
|
} tm_unz;
|
||||||
|
|
||||||
|
/* unz_global_info structure contain global data about the ZIPfile
|
||||||
|
These data comes from the end of central dir */
|
||||||
|
typedef struct unz_global_info_s
|
||||||
|
{
|
||||||
|
uLong number_entry; /* total number of entries in
|
||||||
|
the central dir on this disk */
|
||||||
|
uLong size_comment; /* size of the global comment of the zipfile */
|
||||||
|
} unz_global_info;
|
||||||
|
|
||||||
|
|
||||||
|
/* unz_file_info contain information about a file in the zipfile */
|
||||||
|
typedef struct unz_file_info_s
|
||||||
|
{
|
||||||
|
uLong version; /* version made by 2 bytes */
|
||||||
|
uLong version_needed; /* version needed to extract 2 bytes */
|
||||||
|
uLong flag; /* general purpose bit flag 2 bytes */
|
||||||
|
uLong compression_method; /* compression method 2 bytes */
|
||||||
|
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
|
||||||
|
uLong crc; /* crc-32 4 bytes */
|
||||||
|
uLong compressed_size; /* compressed size 4 bytes */
|
||||||
|
uLong uncompressed_size; /* uncompressed size 4 bytes */
|
||||||
|
uLong size_filename; /* filename length 2 bytes */
|
||||||
|
uLong size_file_extra; /* extra field length 2 bytes */
|
||||||
|
uLong size_file_comment; /* file comment length 2 bytes */
|
||||||
|
|
||||||
|
uLong disk_num_start; /* disk number start 2 bytes */
|
||||||
|
uLong internal_fa; /* internal file attributes 2 bytes */
|
||||||
|
uLong external_fa; /* external file attributes 4 bytes */
|
||||||
|
|
||||||
|
tm_unz tmu_date;
|
||||||
|
} unz_file_info;
|
||||||
|
|
||||||
|
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
|
||||||
|
const char* fileName2,
|
||||||
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Compare two filename (fileName1,fileName2).
|
||||||
|
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
|
||||||
|
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
|
||||||
|
or strcasecmp)
|
||||||
|
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
|
||||||
|
(like 1 on Unix, 2 on Windows)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern unzFile ZEXPORT unzOpen OF((const char *path));
|
||||||
|
/*
|
||||||
|
Open a Zip file. path contain the full pathname (by example,
|
||||||
|
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
|
||||||
|
"zlib/zlib111.zip".
|
||||||
|
If the zipfile cannot be opened (file don't exist or in not valid), the
|
||||||
|
return value is NULL.
|
||||||
|
Else, the return value is a unzFile Handle, usable with other function
|
||||||
|
of this unzip package.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzClose OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close a ZipFile opened with unzipOpen.
|
||||||
|
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
|
||||||
|
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
|
||||||
|
unz_global_info *pglobal_info));
|
||||||
|
/*
|
||||||
|
Write info about the ZipFile in the *pglobal_info structure.
|
||||||
|
No preparation of the structure is needed
|
||||||
|
return UNZ_OK if there is no problem. */
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
|
||||||
|
char *szComment,
|
||||||
|
uLong uSizeBuf));
|
||||||
|
/*
|
||||||
|
Get the global comment string of the ZipFile, in the szComment buffer.
|
||||||
|
uSizeBuf is the size of the szComment buffer.
|
||||||
|
return the number of byte copied or an error code <0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/* Unzip package allow you browse the directory of the zipfile */
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Set the current file of the zipfile to the first file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Set the current file of the zipfile to the next file.
|
||||||
|
return UNZ_OK if there is no problem
|
||||||
|
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzLocateFile OF((unzFile file,
|
||||||
|
const char *szFileName,
|
||||||
|
int iCaseSensitivity));
|
||||||
|
/*
|
||||||
|
Try locate the file szFileName in the zipfile.
|
||||||
|
For the iCaseSensitivity signification, see unzStringFileNameCompare
|
||||||
|
|
||||||
|
return value :
|
||||||
|
UNZ_OK if the file is found. It becomes the current file.
|
||||||
|
UNZ_END_OF_LIST_OF_FILE if the file is not found
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
|
||||||
|
unz_file_info *pfile_info,
|
||||||
|
char *szFileName,
|
||||||
|
uLong fileNameBufferSize,
|
||||||
|
void *extraField,
|
||||||
|
uLong extraFieldBufferSize,
|
||||||
|
char *szComment,
|
||||||
|
uLong commentBufferSize));
|
||||||
|
/*
|
||||||
|
Get Info about the current file
|
||||||
|
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
|
||||||
|
the current file
|
||||||
|
if szFileName!=NULL, the filemane string will be copied in szFileName
|
||||||
|
(fileNameBufferSize is the size of the buffer)
|
||||||
|
if extraField!=NULL, the extra field information will be copied in extraField
|
||||||
|
(extraFieldBufferSize is the size of the buffer).
|
||||||
|
This is the Central-header version of the extra field
|
||||||
|
if szComment!=NULL, the comment string of the file will be copied in szComment
|
||||||
|
(commentBufferSize is the size of the buffer)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
/* for reading the content of the current zipfile, you can open it, read data
|
||||||
|
from it, and close it (you can close it before reading all the file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Open for reading data the current file in the zipfile.
|
||||||
|
If there is no error, the return value is UNZ_OK.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Close the file in zip opened with unzOpenCurrentFile
|
||||||
|
Return UNZ_CRCERROR if all the file was read but the CRC is not good
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read bytes from the current file (opened by unzOpenCurrentFile)
|
||||||
|
buf contain buffer where data must be copied
|
||||||
|
len the size of buf.
|
||||||
|
|
||||||
|
return the number of byte copied if somes bytes are copied
|
||||||
|
return 0 if the end of file was reached
|
||||||
|
return <0 with error code if there is an error
|
||||||
|
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern z_off_t ZEXPORT unztell OF((unzFile file));
|
||||||
|
/*
|
||||||
|
Give the current position in uncompressed data
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzeof OF((unzFile file));
|
||||||
|
/*
|
||||||
|
return 1 if the end of file was reached, 0 elsewhere
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
||||||
|
voidp buf,
|
||||||
|
unsigned len));
|
||||||
|
/*
|
||||||
|
Read extra field from the current file (opened by unzOpenCurrentFile)
|
||||||
|
This is the local-header version of the extra field (sometimes, there is
|
||||||
|
more info in the local-header version than in the central-header)
|
||||||
|
|
||||||
|
if buf==NULL, it return the size of the local extra field
|
||||||
|
|
||||||
|
if buf!=NULL, len is the size of the buffer, the extra header is copied in
|
||||||
|
buf.
|
||||||
|
the return value is the number of bytes copied in buf, or (if <0)
|
||||||
|
the error code
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _unz_H */
|
110
src/common/zipstream.cpp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: zipstream.cpp
|
||||||
|
// Purpose: input stream for ZIP archive access
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/stream.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include <wx/zipstream.h>
|
||||||
|
#include "unzip.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxZipInputStream::wxZipInputStream(const wxString& archive, const wxString& file) : wxInputStream()
|
||||||
|
{
|
||||||
|
unz_file_info zinfo;
|
||||||
|
|
||||||
|
m_Pos = 0;
|
||||||
|
m_Size = 0;
|
||||||
|
m_Archive = (void*) unzOpen(archive);
|
||||||
|
if (m_Archive == NULL) {
|
||||||
|
m_lasterror = wxStream_READ_ERR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (unzLocateFile((unzFile)m_Archive, file, 0) != UNZ_OK) {
|
||||||
|
m_lasterror = wxStream_READ_ERR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
unzGetCurrentFileInfo((unzFile)m_Archive, &zinfo, NULL, 0, NULL, 0, NULL, 0);
|
||||||
|
|
||||||
|
if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK) {
|
||||||
|
m_lasterror = wxStream_READ_ERR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_Size = zinfo.uncompressed_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxZipInputStream::~wxZipInputStream()
|
||||||
|
{
|
||||||
|
if (m_Archive) {
|
||||||
|
if (m_Size != 0)
|
||||||
|
unzCloseCurrentFile((unzFile)m_Archive);
|
||||||
|
unzClose((unzFile)m_Archive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
size_t wxZipInputStream::OnSysRead(void *buffer, size_t bufsize)
|
||||||
|
{
|
||||||
|
if (m_Pos + bufsize > m_Size) bufsize = m_Size - m_Pos;
|
||||||
|
unzReadCurrentFile((unzFile)m_Archive, buffer, bufsize);
|
||||||
|
m_Pos += bufsize;
|
||||||
|
return bufsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
off_t wxZipInputStream::OnSysSeek(off_t seek, wxSeekMode mode)
|
||||||
|
{
|
||||||
|
off_t nextpos;
|
||||||
|
void *buf;
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case wxFromCurrent : nextpos = seek + m_Pos; break;
|
||||||
|
case wxFromStart : nextpos = seek; break;
|
||||||
|
case wxFromEnd : nextpos = m_Size - 1 + seek; break;
|
||||||
|
default : nextpos = m_Pos; break; /* just to fool compiler, never happens */
|
||||||
|
}
|
||||||
|
|
||||||
|
// cheated seeking :
|
||||||
|
if (nextpos > m_Pos) {
|
||||||
|
buf = malloc(nextpos - m_Pos);
|
||||||
|
unzReadCurrentFile((unzFile)m_Archive, buf, nextpos - m_Pos);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
else if (nextpos < m_Pos) {
|
||||||
|
unzCloseCurrentFile((unzFile)m_Archive);
|
||||||
|
if (unzOpenCurrentFile((unzFile)m_Archive) != UNZ_OK) {
|
||||||
|
m_lasterror = wxStream_READ_ERR;
|
||||||
|
return m_Pos;
|
||||||
|
}
|
||||||
|
buf = malloc(nextpos);
|
||||||
|
unzReadCurrentFile((unzFile)m_Archive, buf, nextpos);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Pos = nextpos;
|
||||||
|
return m_Pos;
|
||||||
|
}
|
||||||
|
|
69
src/generic/busyinfo.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: busyinfo.cpp
|
||||||
|
// Purpose: Information window when app is busy
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/busyinfo.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxInfoFrame::wxInfoFrame(wxWindow *parent, const wxString& message)
|
||||||
|
: wxFrame(parent, -1, "", wxPoint(0, 0), wxSize(400, 80), wxTHICK_FRAME | wxSIMPLE_BORDER | wxFRAME_TOOL_WINDOW)
|
||||||
|
{
|
||||||
|
wxPanel *p = new wxPanel(this);
|
||||||
|
wxStaticText *s = new wxStaticText(p, -1, message, wxPoint(20, 20), wxSize(360, 40), wxALIGN_CENTER);
|
||||||
|
Centre(wxBOTH);
|
||||||
|
p -> SetCursor(*wxHOURGLASS_CURSOR);
|
||||||
|
s -> SetCursor(*wxHOURGLASS_CURSOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxBusyInfo::wxBusyInfo(const wxString& message) : wxObject()
|
||||||
|
{
|
||||||
|
m_InfoFrame = new wxInfoFrame(NULL, message);
|
||||||
|
m_InfoFrame -> Show(TRUE);
|
||||||
|
wxYield();
|
||||||
|
m_InfoFrame -> Refresh();
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxBusyInfo::~wxBusyInfo()
|
||||||
|
{
|
||||||
|
m_InfoFrame -> Show(FALSE);
|
||||||
|
m_InfoFrame -> Close();
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -12,7 +12,7 @@ SUFFIXES = .cpp .c
|
|||||||
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
LIBS = $(GUILIBS)
|
LIBS = $(GUILIBS)
|
||||||
|
|
||||||
VPATH = .:${srcdir}:${srcdir}/../common:${srcdir}/../generic:${EXTRA_VPATH}
|
VPATH = .:${srcdir}:${srcdir}/../common:${srcdir}/../generic:${srcdir}/../html:${EXTRA_VPATH}
|
||||||
|
|
||||||
lib_LTLIBRARIES = @WX_LIBRARY_NAME@
|
lib_LTLIBRARIES = @WX_LIBRARY_NAME@
|
||||||
EXTRA_LTLIBRARIES = libwx_gtk.la libwx_motif.la libwx_msw.la
|
EXTRA_LTLIBRARIES = libwx_gtk.la libwx_motif.la libwx_msw.la
|
||||||
@@ -44,7 +44,10 @@ libwx_gtk_la_SOURCES = \
|
|||||||
file.cpp \
|
file.cpp \
|
||||||
fileconf.cpp \
|
fileconf.cpp \
|
||||||
filefn.cpp \
|
filefn.cpp \
|
||||||
|
filesys.cpp \
|
||||||
framecmn.cpp \
|
framecmn.cpp \
|
||||||
|
fs_inet.cpp \
|
||||||
|
fs_zip.cpp \
|
||||||
ftp.cpp \
|
ftp.cpp \
|
||||||
gdicmn.cpp \
|
gdicmn.cpp \
|
||||||
hash.cpp \
|
hash.cpp \
|
||||||
@@ -90,6 +93,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
time.cpp \
|
time.cpp \
|
||||||
timercmn.cpp \
|
timercmn.cpp \
|
||||||
tokenzr.cpp \
|
tokenzr.cpp \
|
||||||
|
unzip.c \
|
||||||
url.cpp \
|
url.cpp \
|
||||||
utilscmn.cpp \
|
utilscmn.cpp \
|
||||||
valgen.cpp \
|
valgen.cpp \
|
||||||
@@ -101,10 +105,12 @@ libwx_gtk_la_SOURCES = \
|
|||||||
wxchar.cpp \
|
wxchar.cpp \
|
||||||
wxexpr.cpp \
|
wxexpr.cpp \
|
||||||
zstream.cpp \
|
zstream.cpp \
|
||||||
|
zipstream.cpp \
|
||||||
\
|
\
|
||||||
db.cpp \
|
db.cpp \
|
||||||
dbtable.cpp \
|
dbtable.cpp \
|
||||||
\
|
\
|
||||||
|
busyinfo.cpp \
|
||||||
caret.cpp \
|
caret.cpp \
|
||||||
colrdlgg.cpp \
|
colrdlgg.cpp \
|
||||||
dcpsg.cpp \
|
dcpsg.cpp \
|
||||||
@@ -192,7 +198,26 @@ libwx_gtk_la_SOURCES = \
|
|||||||
utilsgtk.cpp \
|
utilsgtk.cpp \
|
||||||
utilsres.cpp \
|
utilsres.cpp \
|
||||||
wave.cpp \
|
wave.cpp \
|
||||||
window.cpp
|
window.cpp \
|
||||||
|
\
|
||||||
|
htmlcell.cpp \
|
||||||
|
htmlfilter.cpp \
|
||||||
|
htmlhelp.cpp \
|
||||||
|
htmlhelp_io.cpp \
|
||||||
|
htmlparser.cpp \
|
||||||
|
htmltag.cpp \
|
||||||
|
htmlwin.cpp \
|
||||||
|
htmlwinparser.cpp \
|
||||||
|
mod_fonts.cpp \
|
||||||
|
mod_hline.cpp \
|
||||||
|
mod_image.cpp \
|
||||||
|
mod_layout.cpp \
|
||||||
|
mod_links.cpp \
|
||||||
|
mod_list.cpp \
|
||||||
|
mod_pre.cpp \
|
||||||
|
mod_tables.cpp \
|
||||||
|
search.cpp
|
||||||
|
|
||||||
|
|
||||||
# these are the sources which we build by our own rules
|
# these are the sources which we build by our own rules
|
||||||
#
|
#
|
||||||
|
@@ -12,7 +12,7 @@ SUFFIXES = .cpp .c
|
|||||||
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
LIBS = $(GUILIBS)
|
LIBS = $(GUILIBS)
|
||||||
|
|
||||||
VPATH = .:${srcdir}:${srcdir}/../common:${srcdir}/../generic:${EXTRA_VPATH}
|
VPATH = .:${srcdir}:${srcdir}/../common:${srcdir}/../generic:${srcdir}/../html:${EXTRA_VPATH}
|
||||||
|
|
||||||
lib_LTLIBRARIES = @WX_LIBRARY_NAME@
|
lib_LTLIBRARIES = @WX_LIBRARY_NAME@
|
||||||
EXTRA_LTLIBRARIES = libwx_gtk.la libwx_motif.la libwx_msw.la
|
EXTRA_LTLIBRARIES = libwx_gtk.la libwx_motif.la libwx_msw.la
|
||||||
@@ -44,7 +44,10 @@ libwx_gtk_la_SOURCES = \
|
|||||||
file.cpp \
|
file.cpp \
|
||||||
fileconf.cpp \
|
fileconf.cpp \
|
||||||
filefn.cpp \
|
filefn.cpp \
|
||||||
|
filesys.cpp \
|
||||||
framecmn.cpp \
|
framecmn.cpp \
|
||||||
|
fs_inet.cpp \
|
||||||
|
fs_zip.cpp \
|
||||||
ftp.cpp \
|
ftp.cpp \
|
||||||
gdicmn.cpp \
|
gdicmn.cpp \
|
||||||
hash.cpp \
|
hash.cpp \
|
||||||
@@ -90,6 +93,7 @@ libwx_gtk_la_SOURCES = \
|
|||||||
time.cpp \
|
time.cpp \
|
||||||
timercmn.cpp \
|
timercmn.cpp \
|
||||||
tokenzr.cpp \
|
tokenzr.cpp \
|
||||||
|
unzip.c \
|
||||||
url.cpp \
|
url.cpp \
|
||||||
utilscmn.cpp \
|
utilscmn.cpp \
|
||||||
valgen.cpp \
|
valgen.cpp \
|
||||||
@@ -101,10 +105,12 @@ libwx_gtk_la_SOURCES = \
|
|||||||
wxchar.cpp \
|
wxchar.cpp \
|
||||||
wxexpr.cpp \
|
wxexpr.cpp \
|
||||||
zstream.cpp \
|
zstream.cpp \
|
||||||
|
zipstream.cpp \
|
||||||
\
|
\
|
||||||
db.cpp \
|
db.cpp \
|
||||||
dbtable.cpp \
|
dbtable.cpp \
|
||||||
\
|
\
|
||||||
|
busyinfo.cpp \
|
||||||
caret.cpp \
|
caret.cpp \
|
||||||
colrdlgg.cpp \
|
colrdlgg.cpp \
|
||||||
dcpsg.cpp \
|
dcpsg.cpp \
|
||||||
@@ -192,7 +198,26 @@ libwx_gtk_la_SOURCES = \
|
|||||||
utilsgtk.cpp \
|
utilsgtk.cpp \
|
||||||
utilsres.cpp \
|
utilsres.cpp \
|
||||||
wave.cpp \
|
wave.cpp \
|
||||||
window.cpp
|
window.cpp \
|
||||||
|
\
|
||||||
|
htmlcell.cpp \
|
||||||
|
htmlfilter.cpp \
|
||||||
|
htmlhelp.cpp \
|
||||||
|
htmlhelp_io.cpp \
|
||||||
|
htmlparser.cpp \
|
||||||
|
htmltag.cpp \
|
||||||
|
htmlwin.cpp \
|
||||||
|
htmlwinparser.cpp \
|
||||||
|
mod_fonts.cpp \
|
||||||
|
mod_hline.cpp \
|
||||||
|
mod_image.cpp \
|
||||||
|
mod_layout.cpp \
|
||||||
|
mod_links.cpp \
|
||||||
|
mod_list.cpp \
|
||||||
|
mod_pre.cpp \
|
||||||
|
mod_tables.cpp \
|
||||||
|
search.cpp
|
||||||
|
|
||||||
|
|
||||||
# these are the sources which we build by our own rules
|
# these are the sources which we build by our own rules
|
||||||
#
|
#
|
||||||
|
24
src/html/bitmaps/back.xpm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * back_xpm[] = {
|
||||||
|
"16 16 5 1",
|
||||||
|
" c None",
|
||||||
|
". c #000000",
|
||||||
|
"+ c #C0E4CB",
|
||||||
|
"@ c #77C490",
|
||||||
|
"# c #808080",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" . ",
|
||||||
|
" .. ",
|
||||||
|
" .+. ",
|
||||||
|
" .++........ ",
|
||||||
|
" .++@+++++++. ",
|
||||||
|
" .++@@@@@@@@@. ",
|
||||||
|
" .+@@@@@@@@@. ",
|
||||||
|
" #.+@........ ",
|
||||||
|
" #.+.####### ",
|
||||||
|
" #..# ",
|
||||||
|
" #.# ",
|
||||||
|
" ## ",
|
||||||
|
" # ",
|
||||||
|
" "};
|
40
src/html/bitmaps/book.xpm
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * book_xpm[] = {
|
||||||
|
"16 16 21 1",
|
||||||
|
" c None",
|
||||||
|
". c #007F7F",
|
||||||
|
"+ c #660000",
|
||||||
|
"@ c #CC0000",
|
||||||
|
"# c #E50000",
|
||||||
|
"$ c #FF0000",
|
||||||
|
"% c #F20000",
|
||||||
|
"& c #D80000",
|
||||||
|
"* c #720000",
|
||||||
|
"= c #7F0000",
|
||||||
|
"- c #BFBFBF",
|
||||||
|
"; c #E57F7F",
|
||||||
|
"> c #7F7F7F",
|
||||||
|
", c #FFFFFF",
|
||||||
|
"' c #F2BFBF",
|
||||||
|
") c #723F3F",
|
||||||
|
"! c #A5A5A5",
|
||||||
|
"~ c #E5E5E5",
|
||||||
|
"{ c #B2B2B2",
|
||||||
|
"] c #003F3F",
|
||||||
|
"^ c #000000",
|
||||||
|
" ",
|
||||||
|
" ......... ",
|
||||||
|
" +@#$$$$$%&+ ",
|
||||||
|
" +##$$$$$$$* ",
|
||||||
|
" +##$$$$$$$=- ",
|
||||||
|
" +##$$$$$$$=;> ",
|
||||||
|
" +##$$$$$$$=;,. ",
|
||||||
|
" +##$$$$$$$=;,. ",
|
||||||
|
" +##$$$$$$$=''. ",
|
||||||
|
" +##$$$$$$$=,;. ",
|
||||||
|
" +##$$$$$$%+,;. ",
|
||||||
|
" +&++++++++),;. ",
|
||||||
|
" ++!~~~~~~~~~,. ",
|
||||||
|
" ++!~~~~~~~~~{. ",
|
||||||
|
" ]^^^^^^^^^^^ ",
|
||||||
|
" "};
|
50
src/html/bitmaps/folder.xpm
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * folder_xpm[] = {
|
||||||
|
"16 16 31 1",
|
||||||
|
" c None",
|
||||||
|
". c #000000",
|
||||||
|
"+ c #7F6E54",
|
||||||
|
"@ c #555555",
|
||||||
|
"# c #7F6140",
|
||||||
|
"$ c #FFCF94",
|
||||||
|
"% c #FFFFFF",
|
||||||
|
"& c #D5D5D5",
|
||||||
|
"* c #4B4336",
|
||||||
|
"= c #FFDCA8",
|
||||||
|
"- c #BFA57E",
|
||||||
|
"; c #EFEFEF",
|
||||||
|
"> c #DFDFDF",
|
||||||
|
", c #B8B8B9",
|
||||||
|
"' c #6E6E6F",
|
||||||
|
") c #BF7E42",
|
||||||
|
"! c #FFA858",
|
||||||
|
"~ c #FFC280",
|
||||||
|
"{ c #CFCFCF",
|
||||||
|
"] c #55402C",
|
||||||
|
"^ c #3C2C2C",
|
||||||
|
"/ c #7F542C",
|
||||||
|
"( c #C0C0C0",
|
||||||
|
"_ c #B0B0B2",
|
||||||
|
": c #969698",
|
||||||
|
"< c #A8A8AB",
|
||||||
|
"[ c #A0A0A4",
|
||||||
|
"} c #2C2C2C",
|
||||||
|
"| c #7C7C7E",
|
||||||
|
"1 c #161616",
|
||||||
|
"2 c #3F2A16",
|
||||||
|
" .+. ",
|
||||||
|
".@#$+. ",
|
||||||
|
".%&@#$+.+* ",
|
||||||
|
".%%%&@#$==-. ",
|
||||||
|
".%%;>,')!~$+ ",
|
||||||
|
".%;>{{,']^/~. ",
|
||||||
|
".;>{{((,,_:]/ ",
|
||||||
|
".>{{((,,_<[}/ ",
|
||||||
|
".{{((,,_<[[^/ ",
|
||||||
|
"._((,,_<[[[}/ ",
|
||||||
|
" }|_,_<[[[[}/ ",
|
||||||
|
" .}|<[[[[[}/ ",
|
||||||
|
" .}|[[[[}/ ",
|
||||||
|
" .}|[[}/.. ",
|
||||||
|
" .}|}/.. ",
|
||||||
|
" .12. "};
|
24
src/html/bitmaps/forward.xpm
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * forward_xpm[] = {
|
||||||
|
"16 16 5 1",
|
||||||
|
" c None",
|
||||||
|
". c #000000",
|
||||||
|
"+ c #C0E4CB",
|
||||||
|
"@ c #77C490",
|
||||||
|
"# c #808080",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" . ",
|
||||||
|
" .. ",
|
||||||
|
" .+. ",
|
||||||
|
" ........++. ",
|
||||||
|
" .+++++++@++. ",
|
||||||
|
" .@@@@@@@@@++. ",
|
||||||
|
" .@@@@@@@@@+. ",
|
||||||
|
" ........@+.# ",
|
||||||
|
" #######.+.# ",
|
||||||
|
" #..# ",
|
||||||
|
" #.# ",
|
||||||
|
" ## ",
|
||||||
|
" # ",
|
||||||
|
" "};
|
25
src/html/bitmaps/page.xpm
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * page_xpm[] = {
|
||||||
|
/* width height ncolors chars_per_pixel */
|
||||||
|
"16 16 3 1",
|
||||||
|
/* colors */
|
||||||
|
" s None c None",
|
||||||
|
". c #000000",
|
||||||
|
"+ c #ffffff",
|
||||||
|
/* pixels */
|
||||||
|
" ",
|
||||||
|
" ........ ",
|
||||||
|
" .++++++.. ",
|
||||||
|
" .+.+.++.+. ",
|
||||||
|
" .++++++.... ",
|
||||||
|
" .+.+.+++++. ",
|
||||||
|
" .+++++++++. ",
|
||||||
|
" .+.+.+.+.+. ",
|
||||||
|
" .+++++++++. ",
|
||||||
|
" .+.+.+.+.+. ",
|
||||||
|
" .+++++++++. ",
|
||||||
|
" .+.+.+.+.+. ",
|
||||||
|
" .+++++++++. ",
|
||||||
|
" ........... ",
|
||||||
|
" ",
|
||||||
|
" "};
|
122
src/html/bitmaps/panel.xpm
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
/* XPM */
|
||||||
|
static char * panel_xpm[] = {
|
||||||
|
"16 15 104 2",
|
||||||
|
" c None",
|
||||||
|
". c #7F7C7C",
|
||||||
|
"+ c #8A8E8E",
|
||||||
|
"@ c #D03232",
|
||||||
|
"# c #BA7E7E",
|
||||||
|
"$ c #555858",
|
||||||
|
"% c #5F5F5F",
|
||||||
|
"& c #656565",
|
||||||
|
"* c #5D5D5D",
|
||||||
|
"= c #939696",
|
||||||
|
"- c #FFFFFF",
|
||||||
|
"; c #F4C8C8",
|
||||||
|
"> c #DCDCF4",
|
||||||
|
", c #D3D3D3",
|
||||||
|
"' c #4E5151",
|
||||||
|
") c #7E7E7E",
|
||||||
|
"! c #9E9E9E",
|
||||||
|
"~ c #A7A7A7",
|
||||||
|
"{ c #5C5C5C",
|
||||||
|
"] c #9B9E9E",
|
||||||
|
"^ c #A3A3FF",
|
||||||
|
"/ c #BBBBFF",
|
||||||
|
"( c #DBDBDB",
|
||||||
|
"_ c #808B8B",
|
||||||
|
": c #5E5E5E",
|
||||||
|
"< c #858571",
|
||||||
|
"[ c #AEAE4B",
|
||||||
|
"} c #90902D",
|
||||||
|
"| c #8B8B8B",
|
||||||
|
"1 c #000027",
|
||||||
|
"2 c #D7D7FF",
|
||||||
|
"3 c #C3C3FF",
|
||||||
|
"4 c #A7A7FF",
|
||||||
|
"5 c #9B9BFF",
|
||||||
|
"6 c #D7D7D7",
|
||||||
|
"7 c #717474",
|
||||||
|
"8 c #727D7D",
|
||||||
|
"9 c #575721",
|
||||||
|
"0 c #BFBF7F",
|
||||||
|
"a c #DFDF8F",
|
||||||
|
"b c #DFDF60",
|
||||||
|
"c c #7F7F3B",
|
||||||
|
"d c #2F2F7F",
|
||||||
|
"e c #AFAFF3",
|
||||||
|
"f c #E7E7E7",
|
||||||
|
"g c #9797E7",
|
||||||
|
"h c #8787F3",
|
||||||
|
"i c #AFAFC3",
|
||||||
|
"j c #4F4F37",
|
||||||
|
"k c #8E9898",
|
||||||
|
"l c #484824",
|
||||||
|
"m c #4D4D0B",
|
||||||
|
"n c #8C8C8C",
|
||||||
|
"o c #7D7D36",
|
||||||
|
"p c #74742D",
|
||||||
|
"q c #535353",
|
||||||
|
"r c #636363",
|
||||||
|
"s c #5C5C4C",
|
||||||
|
"t c #818149",
|
||||||
|
"u c #78784C",
|
||||||
|
"v c #787840",
|
||||||
|
"w c #7E7E40",
|
||||||
|
"x c #787E46",
|
||||||
|
"y c #757F7F",
|
||||||
|
"z c #616121",
|
||||||
|
"A c #87874B",
|
||||||
|
"B c #C8C88C",
|
||||||
|
"C c #F6F6B6",
|
||||||
|
"D c #D4D498",
|
||||||
|
"E c #6C6C30",
|
||||||
|
"F c #424242",
|
||||||
|
"G c #9D9D23",
|
||||||
|
"H c #FDFD7B",
|
||||||
|
"I c #FFFF7F",
|
||||||
|
"J c #7F7F3F",
|
||||||
|
"K c #737C7C",
|
||||||
|
"L c #808038",
|
||||||
|
"M c #6B6B5F",
|
||||||
|
"N c #797935",
|
||||||
|
"O c #6E6E62",
|
||||||
|
"P c #8B8B43",
|
||||||
|
"Q c #8D8D8D",
|
||||||
|
"R c #1C4B4B",
|
||||||
|
"S c #959523",
|
||||||
|
"T c #F9F973",
|
||||||
|
"U c #7F7F43",
|
||||||
|
"V c #737D7D",
|
||||||
|
"W c #939343",
|
||||||
|
"X c #4FD3D3",
|
||||||
|
"Y c #185353",
|
||||||
|
"Z c #8D8D27",
|
||||||
|
"` c #F5F56B",
|
||||||
|
" . c #9B9B43",
|
||||||
|
".. c #57CFCF",
|
||||||
|
"+. c #145B5B",
|
||||||
|
"@. c #85851E",
|
||||||
|
"#. c #A3A343",
|
||||||
|
"$. c #3BA7A7",
|
||||||
|
"%. c #636300",
|
||||||
|
"&. c #CFCF67",
|
||||||
|
"*. c #F3F367",
|
||||||
|
"=. c #909A9A",
|
||||||
|
"-. c #4B4B07",
|
||||||
|
";. c #434325",
|
||||||
|
" . ",
|
||||||
|
" + @ # ",
|
||||||
|
" $ % & * = - ; > , ",
|
||||||
|
" ' ) ! ~ ~ { ] - - ^ / - ( ",
|
||||||
|
"_ : < [ [ } | 1 2 - 3 / 4 5 6 7 ",
|
||||||
|
"8 9 0 a b c 3 d e f f g h i j ",
|
||||||
|
"k l m n o p q r s t t t u v w x ",
|
||||||
|
"y z A B C D E F G H I I I I I J ",
|
||||||
|
"K I L M N O P Q R S T I I I I U ",
|
||||||
|
"V I I I I I I W X Y Z ` I I I U ",
|
||||||
|
"8 I I I I I I I ...+.@.I I I U ",
|
||||||
|
"K I I I I I I I I #.$.%.I I I U ",
|
||||||
|
"8 I I I I I I I I I &.*.I I I U ",
|
||||||
|
"V I I I I I I I I I I I I I I U ",
|
||||||
|
"=.-.-.-.-.-.-.-.-.-.-.-.-.-.-.;."};
|
507
src/html/htmlcell.cpp
Normal file
@@ -0,0 +1,507 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlcell.cpp
|
||||||
|
// Purpose: wxHtmlCell - basic element of HTML output
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/html/htmlcell.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlCell
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, bool left, bool middle, bool right)
|
||||||
|
{
|
||||||
|
if (GetLink() != wxEmptyString)
|
||||||
|
((wxHtmlWindow*)parent) -> OnLinkClicked(GetLink());
|
||||||
|
// note : this overcasting is legal because parent is *always* wxHtmlWindow
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlWordCell
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
|
||||||
|
{
|
||||||
|
m_Word = word;
|
||||||
|
m_Word.Replace(" ", " ", TRUE);
|
||||||
|
m_Word.Replace(""", "\"", TRUE);
|
||||||
|
m_Word.Replace("<", "<", TRUE);
|
||||||
|
m_Word.Replace(">", ">", TRUE);
|
||||||
|
m_Word.Replace("&", "&", TRUE);
|
||||||
|
dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWordCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
|
||||||
|
{
|
||||||
|
dc.DrawText(m_Word, x + m_PosX, y + m_PosY);
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlContainerCell
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCell()
|
||||||
|
{
|
||||||
|
m_Cells = m_LastCell = NULL;
|
||||||
|
m_Parent = parent;
|
||||||
|
if (m_Parent) m_Parent -> InsertCell(this);
|
||||||
|
m_AlignHor = HTML_ALIGN_LEFT;
|
||||||
|
m_AlignVer = HTML_ALIGN_BOTTOM;
|
||||||
|
m_IndentLeft = m_IndentRight = m_IndentTop = m_IndentBottom = 0;
|
||||||
|
m_WidthFloat = 100; m_WidthFloatUnits = HTML_UNITS_PERCENT;
|
||||||
|
m_UseBkColour = FALSE;
|
||||||
|
m_UseBorder = FALSE;
|
||||||
|
m_MinHeight = m_MaxLineWidth = 0;
|
||||||
|
m_MinHeightAlign = HTML_ALIGN_TOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::SetIndent(int i, int what, int units)
|
||||||
|
{
|
||||||
|
int val = (units == HTML_UNITS_PIXELS) ? i : -i;
|
||||||
|
if (what & HTML_INDENT_LEFT) m_IndentLeft = val;
|
||||||
|
if (what & HTML_INDENT_RIGHT) m_IndentRight = val;
|
||||||
|
if (what & HTML_INDENT_TOP) m_IndentTop = val;
|
||||||
|
if (what & HTML_INDENT_BOTTOM) m_IndentBottom = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int wxHtmlContainerCell::GetIndent(int ind) const
|
||||||
|
{
|
||||||
|
if (ind & HTML_INDENT_LEFT) return m_IndentLeft;
|
||||||
|
else if (ind & HTML_INDENT_RIGHT) return m_IndentRight;
|
||||||
|
else if (ind & HTML_INDENT_TOP) return m_IndentTop;
|
||||||
|
else if (ind & HTML_INDENT_BOTTOM) return m_IndentBottom;
|
||||||
|
else return -1; /* BUG! Should not be called... */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int wxHtmlContainerCell::GetIndentUnits(int ind) const
|
||||||
|
{
|
||||||
|
bool p = FALSE;
|
||||||
|
if (ind & HTML_INDENT_LEFT) p = m_IndentLeft < 0;
|
||||||
|
else if (ind & HTML_INDENT_RIGHT) p = m_IndentRight < 0;
|
||||||
|
else if (ind & HTML_INDENT_TOP) p = m_IndentTop < 0;
|
||||||
|
else if (ind & HTML_INDENT_BOTTOM) p = m_IndentBottom < 0;
|
||||||
|
if (p) return HTML_UNITS_PERCENT;
|
||||||
|
else return HTML_UNITS_PIXELS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::Layout(int w)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
WIDTH ADJUSTING :
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (m_WidthFloatUnits == HTML_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;
|
||||||
|
m_Cells -> 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);
|
||||||
|
|
||||||
|
m_MaxLineWidth = 0;
|
||||||
|
|
||||||
|
// my own layouting:
|
||||||
|
while (cell != NULL) {
|
||||||
|
switch (m_AlignVer) {
|
||||||
|
case HTML_ALIGN_TOP : ybasicpos = 0; break;
|
||||||
|
case HTML_ALIGN_BOTTOM : ybasicpos = - cell -> GetHeight(); break;
|
||||||
|
case HTML_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();
|
||||||
|
|
||||||
|
// force new line if occured:
|
||||||
|
if ((cell == NULL) || (xpos + cell -> GetWidth() > s_width)) {
|
||||||
|
if (xpos > m_MaxLineWidth) m_MaxLineWidth = xpos;
|
||||||
|
if (ysizeup < 0) ysizeup = 0;
|
||||||
|
if (ysizedown < 0) ysizedown = 0;
|
||||||
|
switch (m_AlignHor) {
|
||||||
|
case HTML_ALIGN_LEFT : xdelta = 0; break;
|
||||||
|
case HTML_ALIGN_RIGHT : xdelta = 0 + (s_width - xpos); break;
|
||||||
|
case HTML_ALIGN_CENTER : xdelta = 0 + (s_width - xpos) / 2; break;
|
||||||
|
}
|
||||||
|
if (xdelta < 0) xdelta = 0;
|
||||||
|
xdelta += s_indent;
|
||||||
|
|
||||||
|
ypos += ysizeup;
|
||||||
|
while (line != cell) {
|
||||||
|
line -> SetPos(line -> GetPosX() + xdelta, ypos + line -> GetPosY());
|
||||||
|
line = line -> GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
ypos += ysizedown;
|
||||||
|
xpos = 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 != HTML_ALIGN_TOP) {
|
||||||
|
int diff = m_MinHeight - m_Height;
|
||||||
|
if (m_MinHeightAlign == HTML_ALIGN_CENTER) diff /= 2;
|
||||||
|
cell = m_Cells;
|
||||||
|
while (cell) {
|
||||||
|
cell -> SetPos(cell -> GetPosX(), cell -> GetPosY() + diff);
|
||||||
|
cell = cell -> GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Height = m_MinHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_MaxLineWidth += s_indent + ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
|
||||||
|
if (m_Width < m_MaxLineWidth) m_Width = m_MaxLineWidth;
|
||||||
|
|
||||||
|
wxHtmlCell::Layout(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 - 1, 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 - 1, y + m_PosY + m_Height - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Cells) m_Cells -> Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
// container invisible, just proceed font+color changing:
|
||||||
|
else {
|
||||||
|
if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::DrawInvisible(wxDC& dc, int x, int y)
|
||||||
|
{
|
||||||
|
if (m_Cells) m_Cells -> DrawInvisible(dc, x + m_PosX, y + m_PosY);
|
||||||
|
wxHtmlCell::DrawInvisible(dc, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlContainerCell::GetLink(int x, int y) const
|
||||||
|
{
|
||||||
|
wxHtmlCell *c = m_Cells;
|
||||||
|
int cx, cy, cw, ch;
|
||||||
|
|
||||||
|
while (c) {
|
||||||
|
cx = c -> GetPosX(), cy = c -> GetPosY();
|
||||||
|
cw = c -> GetWidth(), ch = c -> GetHeight();
|
||||||
|
if ((x >= cx) && (x < cx + cw) && (y >= cy) && (y < cy + ch))
|
||||||
|
return c -> GetLink(x - cx, y - cy);
|
||||||
|
c = c -> GetNext();
|
||||||
|
}
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
|
||||||
|
{
|
||||||
|
if (tag.HasParam("ALIGN")) {
|
||||||
|
wxString alg = tag.GetParam("ALIGN");
|
||||||
|
alg.MakeUpper();
|
||||||
|
if (alg == "CENTER")
|
||||||
|
SetAlignHor(HTML_ALIGN_CENTER);
|
||||||
|
else if (alg == "LEFT")
|
||||||
|
SetAlignHor(HTML_ALIGN_LEFT);
|
||||||
|
else if (alg == "RIGHT")
|
||||||
|
SetAlignHor(HTML_ALIGN_RIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag)
|
||||||
|
{
|
||||||
|
if (tag.HasParam("WIDTH")) {
|
||||||
|
int wdi;
|
||||||
|
wxString wd = tag.GetParam("WIDTH");
|
||||||
|
|
||||||
|
if (wd[wd.Length()-1] == '%') {
|
||||||
|
sscanf(wd.c_str(), "%i%%", &wdi);
|
||||||
|
SetWidthFloat(wdi, HTML_UNITS_PERCENT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sscanf(wd.c_str(), "%i", &wdi);
|
||||||
|
SetWidthFloat(wdi, HTML_UNITS_PIXELS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) const
|
||||||
|
{
|
||||||
|
const wxHtmlCell *r = NULL;
|
||||||
|
|
||||||
|
if (m_Cells) {
|
||||||
|
r = m_Cells -> Find(condition, param);
|
||||||
|
if (r) return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxHtmlCell::Find(condition, param);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, bool left, bool middle, bool right)
|
||||||
|
{
|
||||||
|
if (m_Cells) {
|
||||||
|
wxHtmlCell *c = m_Cells;
|
||||||
|
while (c) {
|
||||||
|
if ( (c -> GetPosX() <= x) &&
|
||||||
|
(c -> GetPosY() <= y) &&
|
||||||
|
(c -> GetPosX() + c -> GetWidth() > x) &&
|
||||||
|
(c -> GetPosY() + c -> GetHeight() > y)) {
|
||||||
|
c -> OnMouseClick(parent, x - c -> GetPosX(), y - c -> GetPosY(), left, middle, right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
c = c -> GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlColourCell
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxHtmlColourCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
|
||||||
|
{
|
||||||
|
if (m_Flags & HTML_CLR_FOREGROUND)
|
||||||
|
dc.SetTextForeground(m_Colour);
|
||||||
|
if (m_Flags & HTML_CLR_BACKGROUND) {
|
||||||
|
dc.SetBackground(wxBrush(m_Colour, wxSOLID));
|
||||||
|
dc.SetTextBackground(m_Colour);
|
||||||
|
}
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlColourCell::DrawInvisible(wxDC& dc, int x, int y)
|
||||||
|
{
|
||||||
|
if (m_Flags & HTML_CLR_FOREGROUND)
|
||||||
|
dc.SetTextForeground(m_Colour);
|
||||||
|
if (m_Flags & HTML_CLR_BACKGROUND) {
|
||||||
|
dc.SetBackground(wxBrush(m_Colour, wxSOLID));
|
||||||
|
dc.SetTextBackground(m_Colour);
|
||||||
|
}
|
||||||
|
wxHtmlCell::DrawInvisible(dc, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFontCell
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxHtmlFontCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
|
||||||
|
{
|
||||||
|
dc.SetFont(*m_Font);
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxHtmlFontCell::DrawInvisible(wxDC& dc, int x, int y)
|
||||||
|
{
|
||||||
|
dc.SetFont(*m_Font);
|
||||||
|
wxHtmlCell::DrawInvisible(dc, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// 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& dc, int x, int y, int view_y1, int 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())) -> ViewStart(&stx, &sty);
|
||||||
|
|
||||||
|
m_Wnd -> SetSize(absx - HTML_SCROLL_STEP * stx, absy - HTML_SCROLL_STEP * sty, m_Width, m_Height);
|
||||||
|
// m_Wnd -> Refresh();
|
||||||
|
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int 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())) -> ViewStart(&stx, &sty);
|
||||||
|
|
||||||
|
m_Wnd -> SetSize(absx - HTML_SCROLL_STEP * stx, absy - HTML_SCROLL_STEP * sty, m_Width, m_Height);
|
||||||
|
wxHtmlCell::DrawInvisible(dc, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
170
src/html/htmlfilter.cpp
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: filter.cpp
|
||||||
|
// Purpose: wxHtmlFilter - input filter for translating into HTML format
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/html/htmlfilter.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
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& file)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file)
|
||||||
|
{
|
||||||
|
wxInputStream *s = file.GetStream();
|
||||||
|
char *src;
|
||||||
|
wxString doc, doc2;
|
||||||
|
|
||||||
|
if (s == NULL) return wxEmptyString;
|
||||||
|
src = (char*) malloc(s -> StreamSize());
|
||||||
|
src[s -> StreamSize()] = 0;
|
||||||
|
s -> Read(src, s -> StreamSize());
|
||||||
|
doc = src;
|
||||||
|
free(src);
|
||||||
|
|
||||||
|
doc.Replace("<", "<", TRUE);
|
||||||
|
doc.Replace(">", ">", TRUE);
|
||||||
|
doc2 = "<HTML><BODY><PRE>\n" + doc + "\n</PRE></BODY></HTML>";
|
||||||
|
return doc2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFilterImage
|
||||||
|
// filter for image/*
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHtmlFilterImage : public wxHtmlFilter
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlFilterImage)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool CanRead(const wxFSFile& file);
|
||||||
|
virtual wxString ReadFile(const wxFSFile& file);
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlFilterImage::CanRead(const wxFSFile& file)
|
||||||
|
{
|
||||||
|
return (file.GetMimeType().Left(6) == "image/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlFilterImage::ReadFile(const wxFSFile& file)
|
||||||
|
{
|
||||||
|
return ("<HTML><BODY><IMG SRC=\"" + file.GetLocation() + "\"></BODY></HTML>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlFilterPlainText
|
||||||
|
// filter for text/plain or uknown
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHtmlFilterHTML : public wxHtmlFilter
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxHtmlFilterHTML)
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual bool CanRead(const wxFSFile& file);
|
||||||
|
virtual wxString ReadFile(const wxFSFile& file);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterHTML, wxHtmlFilter)
|
||||||
|
|
||||||
|
bool wxHtmlFilterHTML::CanRead(const wxFSFile& file)
|
||||||
|
{
|
||||||
|
return (file.GetMimeType() == "text/html");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file)
|
||||||
|
{
|
||||||
|
wxInputStream *s = file.GetStream();
|
||||||
|
char *src;
|
||||||
|
wxString doc;
|
||||||
|
|
||||||
|
if (s == NULL) return wxEmptyString;
|
||||||
|
src = (char*) malloc(s -> StreamSize() + 1);
|
||||||
|
src[s -> StreamSize()] = 0;
|
||||||
|
s -> Read(src, s -> StreamSize());
|
||||||
|
doc = src;
|
||||||
|
free(src);
|
||||||
|
|
||||||
|
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
|
864
src/html/htmlhelp.cpp
Normal file
@@ -0,0 +1,864 @@
|
|||||||
|
// Name: htmlhelp.cpp
|
||||||
|
// Purpose: Help controller
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#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/html/htmlhelp.h>
|
||||||
|
#include <wx/busyinfo.h>
|
||||||
|
|
||||||
|
#if !((wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7)))
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Bitmaps:
|
||||||
|
|
||||||
|
#ifndef __WXMSW__
|
||||||
|
#include "bitmaps/panel.xpm"
|
||||||
|
#include "bitmaps/back.xpm"
|
||||||
|
#include "bitmaps/forward.xpm"
|
||||||
|
#include "bitmaps/book.xpm"
|
||||||
|
#include "bitmaps/folder.xpm"
|
||||||
|
#include "bitmaps/page.xpm"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "search.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Helper constants
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// Command IDs :
|
||||||
|
|
||||||
|
enum {
|
||||||
|
wxID_HTML_PANEL = wxID_HIGHEST + 1,
|
||||||
|
wxID_HTML_BACK,
|
||||||
|
wxID_HTML_FORWARD,
|
||||||
|
wxID_HTML_TREECTRL,
|
||||||
|
wxID_HTML_INDEXPAGE,
|
||||||
|
wxID_HTML_INDEXLIST,
|
||||||
|
wxID_HTML_NOTEBOOK,
|
||||||
|
wxID_HTML_SEARCHPAGE,
|
||||||
|
wxID_HTML_SEARCHTEXT,
|
||||||
|
wxID_HTML_SEARCHLIST,
|
||||||
|
wxID_HTML_SEARCHBUTTON
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Images:
|
||||||
|
|
||||||
|
enum {
|
||||||
|
IMG_Book = 0,
|
||||||
|
IMG_Folder,
|
||||||
|
IMG_Page
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class HtmlHelpTreeItemData : public wxTreeItemData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxString m_Page;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HtmlHelpTreeItemData(HtmlContentsItem *it) : wxTreeItemData() {m_Page = it -> m_Book -> GetBasePath() + it -> m_Page;}
|
||||||
|
const wxString& GetPage() {return m_Page;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/arrimpl.cpp>
|
||||||
|
WX_DEFINE_OBJARRAY(HtmlBookRecArray)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlHelpController
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlHelpController, wxEvtHandler)
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlHelpController::wxHtmlHelpController() : wxEvtHandler()
|
||||||
|
{
|
||||||
|
m_Frame = NULL;
|
||||||
|
m_Config = NULL;
|
||||||
|
m_ConfigRoot = wxEmptyString;
|
||||||
|
m_TitleFormat = _("Help : %s");
|
||||||
|
m_TempPath = 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_ContentsImageList = new wxImageList(12, 12);
|
||||||
|
m_ContentsImageList -> Add(wxICON(book));
|
||||||
|
m_ContentsImageList -> Add(wxICON(folder));
|
||||||
|
m_ContentsImageList -> Add(wxICON(page));
|
||||||
|
|
||||||
|
m_Contents = NULL;
|
||||||
|
m_ContentsCnt = 0;
|
||||||
|
m_Index = NULL;
|
||||||
|
m_IndexCnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlHelpController::~wxHtmlHelpController()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
m_BookRecords.Empty();
|
||||||
|
delete m_ContentsImageList;
|
||||||
|
if (m_Contents) {
|
||||||
|
for (i = 0; i < m_ContentsCnt; i++) {
|
||||||
|
free(m_Contents[i].m_Page);
|
||||||
|
free(m_Contents[i].m_Name);
|
||||||
|
}
|
||||||
|
free(m_Contents);
|
||||||
|
}
|
||||||
|
if (m_Index) {
|
||||||
|
for (i = 0; i < m_IndexCnt; i++) {
|
||||||
|
free(m_Index[i].m_Page);
|
||||||
|
free(m_Index[i].m_Name);
|
||||||
|
}
|
||||||
|
free(m_Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::SetTempDir(const wxString& path)
|
||||||
|
{
|
||||||
|
if (path == wxEmptyString) m_TempPath = path;
|
||||||
|
else {
|
||||||
|
if (wxIsAbsolutePath(path)) m_TempPath = path;
|
||||||
|
else m_TempPath = wxGetCwd() + "/" + path;
|
||||||
|
|
||||||
|
if (m_TempPath[m_TempPath.Length() - 1] != '/')
|
||||||
|
m_TempPath << "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Reads one line, stores it into buf and returns pointer to new line or NULL.
|
||||||
|
static char* ReadLine(char *line, char *buf)
|
||||||
|
{
|
||||||
|
char *writeptr = buf, *readptr = line;
|
||||||
|
|
||||||
|
while (*readptr != 0 && *readptr != '\r' && *readptr != '\n') *(writeptr++) = *(readptr++);
|
||||||
|
*writeptr = 0;
|
||||||
|
while (*readptr == '\r' || *readptr == '\n') readptr++;
|
||||||
|
if (*readptr == 0) return NULL;
|
||||||
|
else return readptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static wxString SafeFileName(const wxString& s)
|
||||||
|
{
|
||||||
|
wxString res = s;
|
||||||
|
res.Replace(":", "_", TRUE);
|
||||||
|
res.Replace(" ", "_", TRUE);
|
||||||
|
res.Replace("/", "_", TRUE);
|
||||||
|
res.Replace("\\", "_", TRUE);
|
||||||
|
res.Replace("#", "_", TRUE);
|
||||||
|
res.Replace(".", "_", TRUE);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int IndexCompareFunc(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return strcmp(((HtmlContentsItem*)a) -> m_Name, ((HtmlContentsItem*)b) -> m_Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg = FALSE)
|
||||||
|
{
|
||||||
|
wxFSFile *fi;
|
||||||
|
wxFileSystem fsys;
|
||||||
|
wxInputStream *s;
|
||||||
|
HtmlBookRecord *bookr;
|
||||||
|
wxString bookFull;
|
||||||
|
|
||||||
|
int sz;
|
||||||
|
char *buff, *lineptr;
|
||||||
|
char linebuf[300];
|
||||||
|
|
||||||
|
wxString title = _("noname"),
|
||||||
|
safetitle,
|
||||||
|
start = wxEmptyString,
|
||||||
|
contents = wxEmptyString, index = wxEmptyString;
|
||||||
|
|
||||||
|
if (wxIsAbsolutePath(book)) bookFull = book;
|
||||||
|
else bookFull = wxGetCwd() + "/" + book;
|
||||||
|
|
||||||
|
fi = fsys.OpenFile(bookFull);
|
||||||
|
if (fi == NULL) return FALSE;
|
||||||
|
fsys.ChangePathTo(bookFull);
|
||||||
|
s = fi -> GetStream();
|
||||||
|
sz = s -> StreamSize();
|
||||||
|
buff = (char*) malloc(sz+1);
|
||||||
|
buff[sz] = 0;
|
||||||
|
s -> Read(buff, sz);
|
||||||
|
lineptr = buff;
|
||||||
|
delete fi;
|
||||||
|
|
||||||
|
while ((lineptr = ReadLine(lineptr, linebuf)) != NULL) {
|
||||||
|
if (strstr(linebuf, "Title=") == linebuf)
|
||||||
|
title = linebuf + strlen("Title=");
|
||||||
|
if (strstr(linebuf, "Default topic=") == linebuf)
|
||||||
|
start = linebuf + strlen("Default topic=");
|
||||||
|
if (strstr(linebuf, "Index file=") == linebuf)
|
||||||
|
index = linebuf + strlen("Index file=");
|
||||||
|
if (strstr(linebuf, "Contents file=") == linebuf)
|
||||||
|
contents = linebuf + strlen("Contents file=");
|
||||||
|
}
|
||||||
|
free(buff);
|
||||||
|
|
||||||
|
bookr = new HtmlBookRecord(fsys.GetPath(), title, start);
|
||||||
|
|
||||||
|
if (m_ContentsCnt % HTML_REALLOC_STEP == 0)
|
||||||
|
m_Contents = (HtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem));
|
||||||
|
m_Contents[m_ContentsCnt].m_Level = 0;
|
||||||
|
m_Contents[m_ContentsCnt].m_ID = 0;
|
||||||
|
m_Contents[m_ContentsCnt].m_Page = (char*) malloc(start.Length() + 1);
|
||||||
|
strcpy(m_Contents[m_ContentsCnt].m_Page, start.c_str());
|
||||||
|
m_Contents[m_ContentsCnt].m_Name = (char*) malloc(title.Length() + 1);
|
||||||
|
strcpy(m_Contents[m_ContentsCnt].m_Name, title.c_str());
|
||||||
|
m_Contents[m_ContentsCnt].m_Book = bookr;
|
||||||
|
m_ContentsCnt++;
|
||||||
|
|
||||||
|
// Try to find cached binary versions:
|
||||||
|
safetitle = SafeFileName(title);
|
||||||
|
fi = fsys.OpenFile(safetitle + ".cached");
|
||||||
|
if (fi == NULL) fi = fsys.OpenFile(m_TempPath + safetitle + ".cached");
|
||||||
|
if ((fi == NULL) || (m_TempPath == wxEmptyString)) {
|
||||||
|
LoadMSProject(bookr, fsys, index, contents, show_wait_msg);
|
||||||
|
if (m_TempPath != wxEmptyString) {
|
||||||
|
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + safetitle + ".cached");
|
||||||
|
SaveCachedBook(bookr, outs);
|
||||||
|
delete outs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LoadCachedBook(bookr, fi -> GetStream());
|
||||||
|
delete fi;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_BookRecords.Add(bookr);
|
||||||
|
if (m_IndexCnt > 0)
|
||||||
|
qsort(m_Index, m_IndexCnt, sizeof(HtmlContentsItem), IndexCompareFunc);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::Display(const wxString& x)
|
||||||
|
{
|
||||||
|
int cnt;
|
||||||
|
int i;
|
||||||
|
wxFileSystem fsys;
|
||||||
|
wxFSFile *f;
|
||||||
|
|
||||||
|
CreateHelpWindow();
|
||||||
|
|
||||||
|
/* 1. try to open given file: */
|
||||||
|
|
||||||
|
cnt = m_BookRecords.GetCount();
|
||||||
|
for (i = 0; i < cnt; i++) {
|
||||||
|
f = fsys.OpenFile(m_BookRecords[i].GetBasePath() + x);
|
||||||
|
if (f) {
|
||||||
|
m_HtmlWin -> LoadPage(m_BookRecords[i].GetBasePath() + x);
|
||||||
|
delete f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 2. try to find a book: */
|
||||||
|
|
||||||
|
for (i = 0; i < cnt; i++) {
|
||||||
|
if (m_BookRecords[i].GetTitle() == x) {
|
||||||
|
m_HtmlWin -> LoadPage(m_BookRecords[i].GetBasePath() + m_BookRecords[i].GetStart());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3. try to find in contents: */
|
||||||
|
|
||||||
|
cnt = m_ContentsCnt;
|
||||||
|
for (i = 0; i < cnt; i++) {
|
||||||
|
if (strcmp(m_Contents[i].m_Name, x) == 0) {
|
||||||
|
m_HtmlWin -> LoadPage(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 4. try to find in index: */
|
||||||
|
|
||||||
|
cnt = m_IndexCnt;
|
||||||
|
for (i = 0; i < cnt; i++) {
|
||||||
|
if (strcmp(m_Index[i].m_Name, x) == 0) {
|
||||||
|
m_HtmlWin -> LoadPage(m_Index[i].m_Book -> GetBasePath() + m_Index[i].m_Page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 5. if everything failed, search the documents: */
|
||||||
|
|
||||||
|
KeywordSearch(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::Display(const int id)
|
||||||
|
{
|
||||||
|
CreateHelpWindow();
|
||||||
|
|
||||||
|
for (int i = 0; i < m_ContentsCnt; i++) {
|
||||||
|
if (m_Contents[i].m_ID == id) {
|
||||||
|
m_HtmlWin -> LoadPage(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::DisplayContents()
|
||||||
|
{
|
||||||
|
CreateHelpWindow();
|
||||||
|
m_Frame -> Raise();
|
||||||
|
if (!m_Splitter -> IsSplit()) {
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
}
|
||||||
|
m_NavigPan -> SetSelection(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::DisplayIndex()
|
||||||
|
{
|
||||||
|
CreateHelpWindow();
|
||||||
|
m_Frame -> Raise();
|
||||||
|
if (!m_Splitter -> IsSplit()) {
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
}
|
||||||
|
m_NavigPan -> SetSelection(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
|
||||||
|
|
||||||
|
class MyProgressDlg : public wxDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool m_Canceled;
|
||||||
|
|
||||||
|
MyProgressDlg(wxWindow *parent) : wxDialog(parent, -1,
|
||||||
|
_("Searching..."),
|
||||||
|
wxPoint(0, 0),
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
wxSize(300, 110))
|
||||||
|
#else
|
||||||
|
wxSize(300, 130))
|
||||||
|
#endif
|
||||||
|
{m_Canceled = FALSE;}
|
||||||
|
void OnCancel(wxCommandEvent& event) {m_Canceled = TRUE;}
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
BEGIN_EVENT_TABLE(MyProgressDlg, wxDialog)
|
||||||
|
EVT_BUTTON(wxID_CANCEL, MyProgressDlg::OnCancel)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlHelpController::KeywordSearch(const wxString& keyword)
|
||||||
|
{
|
||||||
|
int foundcnt = 0;
|
||||||
|
|
||||||
|
CreateHelpWindow();
|
||||||
|
m_Frame -> Raise();
|
||||||
|
if (!m_Splitter -> IsSplit()) {
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
}
|
||||||
|
m_NavigPan -> SetSelection(2);
|
||||||
|
m_SearchList -> Clear();
|
||||||
|
m_SearchText -> SetValue(keyword);
|
||||||
|
m_SearchButton -> Enable(FALSE);
|
||||||
|
|
||||||
|
{
|
||||||
|
int cnt = m_ContentsCnt;
|
||||||
|
wxSearchEngine engine;
|
||||||
|
wxFileSystem fsys;
|
||||||
|
wxFSFile *file;
|
||||||
|
wxString lastpage = wxEmptyString;
|
||||||
|
wxString foundstr;
|
||||||
|
|
||||||
|
#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
|
||||||
|
MyProgressDlg progress(m_Frame);
|
||||||
|
|
||||||
|
wxStaticText *prompt = new wxStaticText(&progress, -1, "", wxPoint(20, 50), wxSize(260, 25), wxALIGN_CENTER);
|
||||||
|
wxGauge *gauge = new wxGauge(&progress, -1, cnt, wxPoint(20, 20), wxSize(260, 25));
|
||||||
|
wxButton *btn = new wxButton(&progress, wxID_CANCEL, _("Cancel"), wxPoint(110, 70), wxSize(80, 25));
|
||||||
|
btn = btn; /* fool compiler :-) */
|
||||||
|
prompt -> SetLabel(_("No matching page found yet"));
|
||||||
|
|
||||||
|
progress.Centre(wxBOTH);
|
||||||
|
progress.Show(TRUE);
|
||||||
|
#else
|
||||||
|
wxProgressDialog progress(_("Searching..."), _("No matching page found yet"), cnt, m_Frame, wxPD_APP_MODAL | wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
engine.LookFor(keyword);
|
||||||
|
|
||||||
|
for (int i = 0; i < cnt; i++) {
|
||||||
|
#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
|
||||||
|
gauge -> SetValue(i);
|
||||||
|
if (progress.m_Canceled) break;
|
||||||
|
#else
|
||||||
|
if (progress.Update(i) == FALSE) break;
|
||||||
|
#endif
|
||||||
|
wxYield();
|
||||||
|
|
||||||
|
file = fsys.OpenFile(m_Contents[i].m_Book -> GetBasePath() + m_Contents[i].m_Page);
|
||||||
|
if (file) {
|
||||||
|
if (lastpage != file -> GetLocation()) {
|
||||||
|
lastpage = file -> GetLocation();
|
||||||
|
if (engine.Scan(file -> GetStream())) {
|
||||||
|
foundstr.Printf(_("Found %i matches"), ++foundcnt);
|
||||||
|
#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
|
||||||
|
prompt -> SetLabel(foundstr);
|
||||||
|
#else
|
||||||
|
progress.Update(i, foundstr);
|
||||||
|
#endif
|
||||||
|
wxYield();
|
||||||
|
m_SearchList -> Append(m_Contents[i].m_Name, (char*)(m_Contents + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (wxVERSION_NUMBER < 2100) || ((wxVERSION_NUMBER == 2100) && (wxBETA_NUMBER < 7))
|
||||||
|
progress.Close(TRUE);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
m_SearchButton -> Enable(TRUE);
|
||||||
|
m_SearchText -> SetSelection(0, keyword.Length());
|
||||||
|
m_SearchText -> SetFocus();
|
||||||
|
if (foundcnt) {
|
||||||
|
HtmlContentsItem *it = (HtmlContentsItem*) m_SearchList -> GetClientData(0);
|
||||||
|
if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
|
||||||
|
}
|
||||||
|
return (foundcnt > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::CreateHelpWindow()
|
||||||
|
{
|
||||||
|
wxBusyCursor cur;
|
||||||
|
wxString oldpath;
|
||||||
|
wxStatusBar *sbar;
|
||||||
|
|
||||||
|
if (m_Frame) {
|
||||||
|
m_Frame -> Raise();
|
||||||
|
m_Frame -> Show(TRUE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBusyInfo busyinfo(_("Preparing help window..."));
|
||||||
|
|
||||||
|
if (m_Config) ReadCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
|
m_Frame = new wxFrame(NULL, -1, "", wxPoint(m_Cfg.x, m_Cfg.y), wxSize(m_Cfg.w, m_Cfg.h));
|
||||||
|
m_Frame -> PushEventHandler(this);
|
||||||
|
sbar = m_Frame -> CreateStatusBar();
|
||||||
|
|
||||||
|
{
|
||||||
|
wxToolBar *toolBar;
|
||||||
|
toolBar = m_Frame -> CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE);
|
||||||
|
toolBar -> SetMargins(2, 2);
|
||||||
|
wxBitmap* toolBarBitmaps[3];
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
toolBarBitmaps[0] = new wxBitmap("panel");
|
||||||
|
toolBarBitmaps[1] = new wxBitmap("back");
|
||||||
|
toolBarBitmaps[2] = new wxBitmap("forward");
|
||||||
|
int width = 24;
|
||||||
|
#else
|
||||||
|
toolBarBitmaps[0] = new wxBitmap(panel_xpm);
|
||||||
|
toolBarBitmaps[1] = new wxBitmap(back_xpm);
|
||||||
|
toolBarBitmaps[2] = new wxBitmap(forward_xpm);
|
||||||
|
int width = 16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int currentX = 5;
|
||||||
|
|
||||||
|
toolBar -> AddTool(wxID_HTML_PANEL, *(toolBarBitmaps[0]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Show/hide navigation panel"));
|
||||||
|
currentX += width + 5;
|
||||||
|
toolBar -> AddSeparator();
|
||||||
|
toolBar -> AddTool(wxID_HTML_BACK, *(toolBarBitmaps[1]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go back to the previous HTML page"));
|
||||||
|
currentX += width + 5;
|
||||||
|
toolBar -> AddTool(wxID_HTML_FORWARD, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, _("Go forward to the next HTML page"));
|
||||||
|
currentX += width + 5;
|
||||||
|
|
||||||
|
toolBar -> Realize();
|
||||||
|
|
||||||
|
// Can delete the bitmaps since they're reference counted
|
||||||
|
for (int i = 0; i < 3; i++) delete toolBarBitmaps[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
m_Splitter = new wxSplitterWindow(m_Frame);
|
||||||
|
|
||||||
|
m_HtmlWin = new wxHtmlWindow(m_Splitter);
|
||||||
|
m_HtmlWin -> SetRelatedFrame(m_Frame, m_TitleFormat);
|
||||||
|
m_HtmlWin -> SetRelatedStatusBar(0);
|
||||||
|
if (m_Config) m_HtmlWin -> ReadCustomization(m_Config, m_ConfigRoot);
|
||||||
|
|
||||||
|
m_NavigPan = new wxNotebook(m_Splitter, wxID_HTML_NOTEBOOK, wxDefaultPosition, wxDefaultSize);
|
||||||
|
{
|
||||||
|
m_ContentsBox = new wxTreeCtrl(m_NavigPan, wxID_HTML_TREECTRL, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxSUNKEN_BORDER);
|
||||||
|
m_ContentsBox -> SetImageList(m_ContentsImageList);
|
||||||
|
m_NavigPan -> AddPage(m_ContentsBox, _("Contents"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_INDEXPAGE);
|
||||||
|
wxLayoutConstraints *b1 = new wxLayoutConstraints;
|
||||||
|
b1 -> top.SameAs (dummy, wxTop, 0);
|
||||||
|
b1 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b1 -> width.PercentOf (dummy, wxWidth, 100);
|
||||||
|
b1 -> bottom.SameAs (dummy, wxBottom, 0);
|
||||||
|
m_IndexBox = new wxListBox(dummy, wxID_HTML_INDEXLIST, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_IndexBox -> SetConstraints(b1);
|
||||||
|
dummy -> SetAutoLayout(TRUE);
|
||||||
|
m_NavigPan -> AddPage(dummy, _("Index"));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
wxWindow *dummy = new wxPanel(m_NavigPan, wxID_HTML_SEARCHPAGE);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b1 = new wxLayoutConstraints;
|
||||||
|
m_SearchText = new wxTextCtrl(dummy, wxID_HTML_SEARCHTEXT);
|
||||||
|
b1 -> top.SameAs (dummy, wxTop, 0);
|
||||||
|
b1 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b1 -> right.SameAs (dummy, wxRight, 0);
|
||||||
|
b1 -> height.AsIs();
|
||||||
|
m_SearchText -> SetConstraints(b1);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b2 = new wxLayoutConstraints;
|
||||||
|
m_SearchButton = new wxButton(dummy, wxID_HTML_SEARCHBUTTON, _("Search!"));
|
||||||
|
b2 -> top.Below (m_SearchText, 10);
|
||||||
|
b2 -> right.SameAs (dummy, wxRight, 10);
|
||||||
|
b2 -> width.AsIs();
|
||||||
|
b2 -> height.AsIs();
|
||||||
|
m_SearchButton -> SetConstraints(b2);
|
||||||
|
|
||||||
|
wxLayoutConstraints *b3 = new wxLayoutConstraints;
|
||||||
|
m_SearchList = new wxListBox(dummy, wxID_HTML_SEARCHLIST, wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
b3 -> top.Below (m_SearchButton, 10);
|
||||||
|
b3 -> left.SameAs (dummy, wxLeft, 0);
|
||||||
|
b3 -> right.SameAs (dummy, wxRight, 0);
|
||||||
|
b3 -> bottom.SameAs (dummy, wxBottom, 0);
|
||||||
|
m_SearchList -> SetConstraints(b3);
|
||||||
|
|
||||||
|
dummy -> SetAutoLayout(TRUE);
|
||||||
|
dummy -> Layout();
|
||||||
|
m_NavigPan -> AddPage(dummy, _("Search"));
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshLists();
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SetMinimumPaneSize(20);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
if (!m_Cfg.navig_on) m_Splitter -> Unsplit(m_NavigPan);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Frame -> Show(TRUE);
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_ROOTS 64
|
||||||
|
|
||||||
|
void wxHtmlHelpController::CreateContents()
|
||||||
|
{
|
||||||
|
HtmlContentsItem *it;
|
||||||
|
wxTreeItemId roots[MAX_ROOTS];
|
||||||
|
bool imaged[MAX_ROOTS];
|
||||||
|
int count = m_ContentsCnt;
|
||||||
|
|
||||||
|
m_ContentsBox -> DeleteAllItems();
|
||||||
|
roots[0] = m_ContentsBox -> AddRoot(_("(Help)"));
|
||||||
|
imaged[0] = TRUE;
|
||||||
|
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
it = m_Contents + i;
|
||||||
|
roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(roots[it -> m_Level], it -> m_Name, IMG_Page, -1, new HtmlHelpTreeItemData(it));
|
||||||
|
if (it -> m_Level == 0) {
|
||||||
|
m_ContentsBox -> SetItemBold(roots[1], TRUE);
|
||||||
|
m_ContentsBox -> SetItemImage(roots[1], IMG_Book);
|
||||||
|
m_ContentsBox -> SetItemSelectedImage(roots[1], IMG_Book);
|
||||||
|
imaged[1] = TRUE;
|
||||||
|
}
|
||||||
|
else imaged[it -> m_Level + 1] = FALSE;
|
||||||
|
|
||||||
|
if (!imaged[it -> m_Level]) {
|
||||||
|
m_ContentsBox -> SetItemImage(roots[it -> m_Level], IMG_Folder);
|
||||||
|
m_ContentsBox -> SetItemSelectedImage(roots[it -> m_Level], IMG_Folder);
|
||||||
|
imaged[it -> m_Level] = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ContentsBox -> Expand(roots[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::CreateIndex()
|
||||||
|
{
|
||||||
|
m_IndexBox -> Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < m_IndexCnt; i++)
|
||||||
|
m_IndexBox -> Append(m_Index[i].m_Name, (char*)(m_Index + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::RefreshLists()
|
||||||
|
{
|
||||||
|
if (m_Frame) {
|
||||||
|
CreateContents();
|
||||||
|
CreateIndex();
|
||||||
|
m_SearchList -> Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::ReadCustomization(wxConfigBase *cfg, wxString path)
|
||||||
|
{
|
||||||
|
wxString oldpath;
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
|
if (path != wxEmptyString) {
|
||||||
|
oldpath = cfg -> GetPath();
|
||||||
|
cfg -> SetPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Cfg.navig_on = (bool) cfg -> Read("hcNavigPanel", m_Cfg.navig_on);
|
||||||
|
m_Cfg.sashpos = cfg -> Read("hcSashPos", m_Cfg.sashpos);
|
||||||
|
m_Cfg.x = cfg -> Read("hcX", m_Cfg.x);
|
||||||
|
m_Cfg.y = cfg -> Read("hcY", m_Cfg.y);
|
||||||
|
m_Cfg.w = cfg -> Read("hcW", m_Cfg.w);
|
||||||
|
m_Cfg.h = cfg -> Read("hcH", m_Cfg.h);
|
||||||
|
|
||||||
|
if (path != wxEmptyString)
|
||||||
|
cfg -> SetPath(oldpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::WriteCustomization(wxConfigBase *cfg, wxString path)
|
||||||
|
{
|
||||||
|
wxString oldpath;
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
|
if (path != wxEmptyString) {
|
||||||
|
oldpath = cfg -> GetPath();
|
||||||
|
cfg -> SetPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg -> Write("hcNavigPanel", m_Cfg.navig_on);
|
||||||
|
cfg -> Write("hcSashPos", (long)m_Cfg.sashpos);
|
||||||
|
cfg -> Write("hcX", (long)m_Cfg.x);
|
||||||
|
cfg -> Write("hcY", (long)m_Cfg.y);
|
||||||
|
cfg -> Write("hcW", (long)m_Cfg.w);
|
||||||
|
cfg -> Write("hcH", (long)m_Cfg.h);
|
||||||
|
|
||||||
|
if (path != wxEmptyString)
|
||||||
|
cfg -> SetPath(oldpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
EVENT HANDLING :
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnToolbar(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
switch (event.GetId()) {
|
||||||
|
case wxID_HTML_BACK :
|
||||||
|
m_HtmlWin -> HistoryBack();
|
||||||
|
break;
|
||||||
|
case wxID_HTML_FORWARD :
|
||||||
|
m_HtmlWin -> HistoryForward();
|
||||||
|
break;
|
||||||
|
case wxID_HTML_PANEL :
|
||||||
|
if (m_Splitter -> IsSplit()) {
|
||||||
|
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
|
m_Splitter -> Unsplit(m_NavigPan);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_NavigPan -> Show(TRUE);
|
||||||
|
m_HtmlWin -> Show(TRUE);
|
||||||
|
m_Splitter -> SplitVertically(m_NavigPan, m_HtmlWin, m_Cfg.sashpos);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnContentsSel(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
HtmlHelpTreeItemData *pg;
|
||||||
|
|
||||||
|
pg = (HtmlHelpTreeItemData*) m_ContentsBox -> GetItemData(event.GetItem());
|
||||||
|
if (pg) m_HtmlWin -> LoadPage(pg -> GetPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnIndexSel(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
HtmlContentsItem *it = (HtmlContentsItem*) m_IndexBox -> GetClientData(m_IndexBox -> GetSelection());
|
||||||
|
if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnSearchSel(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
HtmlContentsItem *it = (HtmlContentsItem*) m_SearchList -> GetClientData(m_SearchList -> GetSelection());
|
||||||
|
if (it) m_HtmlWin -> LoadPage(it -> m_Book -> GetBasePath() + it -> m_Page);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnCloseWindow(wxCloseEvent& event)
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
|
||||||
|
m_Cfg.navig_on = m_Splitter -> IsSplit();
|
||||||
|
if (m_Cfg.navig_on)
|
||||||
|
m_Cfg.sashpos = m_Splitter -> GetSashPosition();
|
||||||
|
m_Frame -> GetPosition(&a, &b);
|
||||||
|
m_Cfg.x = a, m_Cfg.y = b;
|
||||||
|
m_Frame -> GetSize(&a, &b);
|
||||||
|
m_Cfg.w = a, m_Cfg.h = b;
|
||||||
|
|
||||||
|
if (m_Config) {
|
||||||
|
WriteCustomization(m_Config, m_ConfigRoot);
|
||||||
|
m_HtmlWin -> WriteCustomization(m_Config, m_ConfigRoot);
|
||||||
|
}
|
||||||
|
m_Frame = NULL;
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::OnSearch(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxString sr = m_SearchText -> GetLineText(0);
|
||||||
|
|
||||||
|
if (sr != wxEmptyString) KeywordSearch(sr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxHtmlHelpController, wxEvtHandler)
|
||||||
|
EVT_TOOL_RANGE(wxID_HTML_PANEL, wxID_HTML_FORWARD, wxHtmlHelpController::OnToolbar)
|
||||||
|
EVT_TREE_SEL_CHANGED(wxID_HTML_TREECTRL, wxHtmlHelpController::OnContentsSel)
|
||||||
|
EVT_LISTBOX(wxID_HTML_INDEXLIST, wxHtmlHelpController::OnIndexSel)
|
||||||
|
EVT_LISTBOX(wxID_HTML_SEARCHLIST, wxHtmlHelpController::OnSearchSel)
|
||||||
|
EVT_CLOSE(wxHtmlHelpController::OnCloseWindow)
|
||||||
|
EVT_BUTTON(wxID_HTML_SEARCHBUTTON, wxHtmlHelpController::OnSearch)
|
||||||
|
EVT_TEXT_ENTER(wxID_HTML_SEARCHTEXT, wxHtmlHelpController::OnSearch)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
250
src/html/htmlhelp_io.cpp
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlhelp.cpp
|
||||||
|
// Purpose: Help controller
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
//#ifdef __GNUG__
|
||||||
|
//#pragma implementation "htmlhelp.h"
|
||||||
|
//#endif
|
||||||
|
// --- already in htmlhelp.cpp
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/wxhtml.h>
|
||||||
|
#include <wx/busyinfo.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class HP_Parser : public wxHtmlParser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void AddText(const char* text) {}
|
||||||
|
wxObject* GetProduct() {return NULL;}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class HP_TagHandler : public wxHtmlTagHandler
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxString m_Name, m_Page;
|
||||||
|
int m_Level;
|
||||||
|
int m_ID;
|
||||||
|
int m_Index;
|
||||||
|
HtmlContentsItem *m_Items;
|
||||||
|
int m_ItemsCnt;
|
||||||
|
HtmlBookRecord *m_Book;
|
||||||
|
|
||||||
|
public:
|
||||||
|
HP_TagHandler(HtmlBookRecord *b) : wxHtmlTagHandler() {m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; m_Level = 0;}
|
||||||
|
wxString GetSupportedTags() {return "UL,OBJECT,PARAM";}
|
||||||
|
bool HandleTag(const wxHtmlTag& tag);
|
||||||
|
void WriteOut(HtmlContentsItem*& array, int& size);
|
||||||
|
void ReadIn(HtmlContentsItem* array, int size);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
|
||||||
|
{
|
||||||
|
if (tag.GetName() == "UL") {
|
||||||
|
m_Level++;
|
||||||
|
ParseInner(tag);
|
||||||
|
m_Level--;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (tag.GetName() == "OBJECT") {
|
||||||
|
m_Name = m_Page = wxEmptyString;
|
||||||
|
ParseInner(tag);
|
||||||
|
if (m_Page != wxEmptyString) {
|
||||||
|
if (m_ItemsCnt % HTML_REALLOC_STEP == 0)
|
||||||
|
m_Items = (HtmlContentsItem*) realloc(m_Items, (m_ItemsCnt + HTML_REALLOC_STEP) * sizeof(HtmlContentsItem));
|
||||||
|
m_Items[m_ItemsCnt].m_Level = m_Level;
|
||||||
|
m_Items[m_ItemsCnt].m_ID = m_ID;
|
||||||
|
m_Items[m_ItemsCnt].m_Page = (char*) malloc(m_Page.Length() + 1);
|
||||||
|
strcpy(m_Items[m_ItemsCnt].m_Page, m_Page.c_str());
|
||||||
|
m_Items[m_ItemsCnt].m_Name = (char*) malloc(m_Name.Length() + 1);
|
||||||
|
strcpy(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("NAME") == "Name") m_Name = tag.GetParam("VALUE");
|
||||||
|
if (tag.GetParam("NAME") == "Local") m_Page = tag.GetParam("VALUE");
|
||||||
|
if (tag.GetParam("NAME") == "ID") tag.ScanParam("VALUE", "%i", &m_ID);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void HP_TagHandler::WriteOut(HtmlContentsItem*& array, int& size)
|
||||||
|
{
|
||||||
|
array = m_Items;
|
||||||
|
size = m_ItemsCnt;
|
||||||
|
m_Items = NULL;
|
||||||
|
m_ItemsCnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HP_TagHandler::ReadIn(HtmlContentsItem* array, int size)
|
||||||
|
{
|
||||||
|
m_Items = array;
|
||||||
|
m_ItemsCnt = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::LoadMSProject(HtmlBookRecord *book, wxFileSystem& fsys, const wxString& indexfile, const wxString& contentsfile, bool show_wait_msg)
|
||||||
|
{
|
||||||
|
wxFSFile *f;
|
||||||
|
char *buf;
|
||||||
|
int sz;
|
||||||
|
wxString string;
|
||||||
|
wxBusyInfo *busyinfo = (show_wait_msg) ? new wxBusyInfo(_("Importing help file : \n") + book -> m_Title) : NULL;
|
||||||
|
|
||||||
|
HP_Parser parser;
|
||||||
|
HP_TagHandler *handler = new HP_TagHandler(book);
|
||||||
|
parser.AddTagHandler(handler);
|
||||||
|
|
||||||
|
f = fsys.OpenFile(contentsfile);
|
||||||
|
if (f) {
|
||||||
|
sz = f -> GetStream() -> StreamSize();
|
||||||
|
buf = (char*) malloc(sz+1);
|
||||||
|
buf[sz] = 0;
|
||||||
|
f -> GetStream() -> Read(buf, sz);
|
||||||
|
delete f;
|
||||||
|
handler -> ReadIn(m_Contents, m_ContentsCnt);
|
||||||
|
parser.Parse(buf);
|
||||||
|
handler -> WriteOut(m_Contents, m_ContentsCnt);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
f = fsys.OpenFile(indexfile);
|
||||||
|
if (f) {
|
||||||
|
sz = f -> GetStream() -> StreamSize();
|
||||||
|
buf = (char*) malloc(sz+1);
|
||||||
|
buf[sz] = 0;
|
||||||
|
f -> GetStream() -> Read(buf, sz);
|
||||||
|
delete f;
|
||||||
|
handler -> ReadIn(m_Index, m_IndexCnt);
|
||||||
|
parser.Parse(buf);
|
||||||
|
handler -> WriteOut(m_Index, m_IndexCnt);
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
if (show_wait_msg) delete busyinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::LoadCachedBook(HtmlBookRecord *book, wxInputStream *f)
|
||||||
|
{
|
||||||
|
int i, st;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
/* load contents : */
|
||||||
|
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
st = m_ContentsCnt;
|
||||||
|
m_ContentsCnt += x;
|
||||||
|
m_Contents = (HtmlContentsItem*) realloc(m_Contents, (m_ContentsCnt / HTML_REALLOC_STEP + 1) * HTML_REALLOC_STEP * sizeof(HtmlContentsItem));
|
||||||
|
for (i = st; i < m_ContentsCnt; i++) {
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Contents[i].m_Level = x;
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Contents[i].m_ID = x;
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Contents[i].m_Name = (char*) malloc(x);
|
||||||
|
f -> Read(m_Contents[i].m_Name, x);
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Contents[i].m_Page = (char*) malloc(x);
|
||||||
|
f -> Read(m_Contents[i].m_Page, x);
|
||||||
|
m_Contents[i].m_Book = book;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* load index : */
|
||||||
|
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
st = m_IndexCnt;
|
||||||
|
m_IndexCnt += x;
|
||||||
|
m_Index = (HtmlContentsItem*) realloc(m_Index, (m_IndexCnt / HTML_REALLOC_STEP + 1) * HTML_REALLOC_STEP * sizeof(HtmlContentsItem));
|
||||||
|
for (i = st; i < m_IndexCnt; i++) {
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Index[i].m_Name = (char*) malloc(x);
|
||||||
|
f -> Read(m_Index[i].m_Name, x);
|
||||||
|
f -> Read(&x, sizeof(x));
|
||||||
|
m_Index[i].m_Page = (char*) malloc(x);
|
||||||
|
f -> Read(m_Index[i].m_Page, x);
|
||||||
|
m_Index[i].m_Book = book;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlHelpController::SaveCachedBook(HtmlBookRecord *book, wxOutputStream *f)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
/* save contents : */
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
for (i = 0; i < m_ContentsCnt; i++) if (m_Contents[i].m_Book == book && m_Contents[i].m_Level > 0) x++;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
for (i = 0; i < m_ContentsCnt; i++) {
|
||||||
|
if (m_Contents[i].m_Book != book || m_Contents[i].m_Level == 0) continue;
|
||||||
|
x = m_Contents[i].m_Level;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
x = m_Contents[i].m_ID;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
x = strlen(m_Contents[i].m_Name) + 1;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
f -> Write(m_Contents[i].m_Name, x);
|
||||||
|
x = strlen(m_Contents[i].m_Page) + 1;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
f -> Write(m_Contents[i].m_Page, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save index : */
|
||||||
|
|
||||||
|
x = 0;
|
||||||
|
for (i = 0; i < m_IndexCnt; i++) if (m_Index[i].m_Book == book && m_Index[i].m_Level > 0) x++;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
for (i = 0; i < m_IndexCnt; i++) {
|
||||||
|
if (m_Index[i].m_Book != book || m_Index[i].m_Level == 0) continue;
|
||||||
|
x = strlen(m_Index[i].m_Name) + 1;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
f -> Write(m_Index[i].m_Name, x);
|
||||||
|
x = strlen(m_Index[i].m_Page) + 1;
|
||||||
|
f -> Write(&x, sizeof(x));
|
||||||
|
f -> Write(m_Index[i].m_Page, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
169
src/html/htmlparser.cpp
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlparser.cpp
|
||||||
|
// Purpose: wxHtmlParser class (generic parser)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/tokenzr.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
#include <wx/url.h>
|
||||||
|
#include <wx/html/htmldefs.h>
|
||||||
|
#include <wx/html/htmlparser.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlParser
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject)
|
||||||
|
|
||||||
|
|
||||||
|
wxObject* wxHtmlParser::Parse(const wxString& source)
|
||||||
|
{
|
||||||
|
wxObject *result;
|
||||||
|
|
||||||
|
InitParser(source);
|
||||||
|
DoParsing();
|
||||||
|
result = GetProduct();
|
||||||
|
DoneParser();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlParser::InitParser(const wxString& source)
|
||||||
|
{
|
||||||
|
m_Source = source;
|
||||||
|
m_Cache = new wxHtmlTagsCache(m_Source);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlParser::DoneParser()
|
||||||
|
{
|
||||||
|
delete m_Cache;
|
||||||
|
m_Cache = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define HTML_MAX_BUFLEN 1024
|
||||||
|
|
||||||
|
void wxHtmlParser::DoParsing(int begin_pos, int end_pos)
|
||||||
|
{
|
||||||
|
char temp[HTML_BUFLEN], c;
|
||||||
|
int i;
|
||||||
|
int templen;
|
||||||
|
|
||||||
|
templen = 0;
|
||||||
|
i = begin_pos;
|
||||||
|
|
||||||
|
while (i < end_pos) {
|
||||||
|
c = m_Source[i];
|
||||||
|
|
||||||
|
// continue building word:
|
||||||
|
if (c != '<') {
|
||||||
|
temp[templen++] = c;
|
||||||
|
if (templen == HTML_BUFLEN-1) {
|
||||||
|
temp[templen] = 0;
|
||||||
|
AddText(temp);
|
||||||
|
templen = 0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (c == '<') {
|
||||||
|
wxHtmlTag tag(m_Source, i, end_pos, m_Cache);
|
||||||
|
|
||||||
|
if (templen) {
|
||||||
|
temp[templen] = 0;
|
||||||
|
AddText(temp);
|
||||||
|
templen = 0;
|
||||||
|
}
|
||||||
|
AddTag(tag);
|
||||||
|
if (tag.HasEnding()) i = tag.GetEndPos2();
|
||||||
|
else i = tag.GetBeginPos();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (templen) { // last word of block :-(
|
||||||
|
temp[templen] = 0;
|
||||||
|
AddText(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlParser::AddTag(const wxHtmlTag& tag)
|
||||||
|
{
|
||||||
|
wxHtmlTagHandler *h;
|
||||||
|
bool inner = FALSE;
|
||||||
|
|
||||||
|
h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName());
|
||||||
|
if (h)
|
||||||
|
inner = h -> HandleTag(tag);
|
||||||
|
if (!inner) {
|
||||||
|
if (tag.HasEnding())
|
||||||
|
DoParsing(tag.GetBeginPos(), tag.GetEndPos1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlParser::AddTagHandler(wxHtmlTagHandler *handler)
|
||||||
|
{
|
||||||
|
wxString s(handler -> GetSupportedTags());
|
||||||
|
wxStringTokenizer tokenizer(s, ", ");
|
||||||
|
|
||||||
|
#if (wxVERSION_NUMBER < 2100)
|
||||||
|
while (tokenizer.HasMoreToken())
|
||||||
|
#else
|
||||||
|
while (tokenizer.HasMoreTokens())
|
||||||
|
#endif
|
||||||
|
m_HandlersHash.Put(tokenizer.NextToken(), handler);
|
||||||
|
|
||||||
|
if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND)
|
||||||
|
m_HandlersList.Append(handler);
|
||||||
|
|
||||||
|
handler -> SetParser(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlParser::~wxHtmlParser()
|
||||||
|
{
|
||||||
|
m_HandlersHash.Clear();
|
||||||
|
m_HandlersList.DeleteContents(TRUE);
|
||||||
|
m_HandlersList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagHandler
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxHtmlTagHandler,wxObject)
|
||||||
|
|
||||||
|
#endif
|
248
src/html/htmltag.cpp
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmltag.cpp
|
||||||
|
// Purpose: wxHtmlTag class (represents single tag)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/html/htmltag.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagsCache
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_CLASS(wxHtmlTagsCache,wxObject)
|
||||||
|
|
||||||
|
#define CACHE_INCREMENT 64
|
||||||
|
|
||||||
|
wxHtmlTagsCache::wxHtmlTagsCache(const wxString& source)
|
||||||
|
{
|
||||||
|
const char *src = source.c_str();
|
||||||
|
int i, tg, pos, stpos;
|
||||||
|
int lng = source.Length();
|
||||||
|
char dummy[256];
|
||||||
|
|
||||||
|
m_Cache = NULL;
|
||||||
|
m_CacheSize = 0;
|
||||||
|
m_CachePos = 0;
|
||||||
|
|
||||||
|
pos = 0;
|
||||||
|
while (pos < lng) {
|
||||||
|
if (src[pos] == '<') { // tag found:
|
||||||
|
if (m_CacheSize % CACHE_INCREMENT == 0)
|
||||||
|
m_Cache = (sCacheItem*) realloc(m_Cache, (m_CacheSize + CACHE_INCREMENT) * sizeof(sCacheItem));
|
||||||
|
tg = m_CacheSize++;
|
||||||
|
m_Cache[tg].Key = stpos = pos++;
|
||||||
|
dummy[0] = 0; i = 0;
|
||||||
|
while ((src[pos] != '>') && (src[pos] != ' ')) {
|
||||||
|
dummy[i] = src[pos++];
|
||||||
|
if ((dummy[i] >= 'a') && (dummy[i] <= 'z')) dummy[i] -= ('a' - 'A');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
dummy[i] = 0;
|
||||||
|
m_Cache[tg].Name = (char*) malloc(i+1);
|
||||||
|
memcpy(m_Cache[tg].Name, dummy, i+1);
|
||||||
|
|
||||||
|
while (src[pos] != '>') pos++;
|
||||||
|
|
||||||
|
if (src[stpos+1] == '/') { // ending tag:
|
||||||
|
m_Cache[tg].End1 = m_Cache[tg].End2 = -2;
|
||||||
|
// find matching begin tag:
|
||||||
|
for (i = tg; i >= 0; i--)
|
||||||
|
if ((m_Cache[i].End1 == -1) && (strcmp(m_Cache[i].Name, dummy+1) == 0)) {
|
||||||
|
m_Cache[i].End1 = stpos;
|
||||||
|
m_Cache[i].End2 = pos + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_Cache[tg].End1 = m_Cache[tg].End2 = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ok, we're done, now we'll free .Name members of cache - we don't need it anymore:
|
||||||
|
for (i = 0; i < m_CacheSize; i++) {
|
||||||
|
free(m_Cache[i].Name);
|
||||||
|
m_Cache[i].Name = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlTagsCache::QueryTag(int at, int* end1, int* end2)
|
||||||
|
{
|
||||||
|
if (m_Cache == NULL) return;
|
||||||
|
if (m_Cache[m_CachePos].Key != at) {
|
||||||
|
int delta = (at < m_Cache[m_CachePos].Key) ? -1 : 1;
|
||||||
|
do {m_CachePos += delta;} while (m_Cache[m_CachePos].Key != at);
|
||||||
|
}
|
||||||
|
*end1 = m_Cache[m_CachePos].End1;
|
||||||
|
*end2 = m_Cache[m_CachePos].End2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlTag
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_CLASS(wxHtmlTag,wxObject)
|
||||||
|
|
||||||
|
wxHtmlTag::wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache) : wxObject()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
// fill-in name, params and begin pos:
|
||||||
|
m_Name = m_Params = wxEmptyString;
|
||||||
|
i = pos+1;
|
||||||
|
if (source[i] == '/') {m_Ending = TRUE; i++;}
|
||||||
|
else m_Ending = FALSE;
|
||||||
|
|
||||||
|
while ((i < end_pos) && ((c = source[i++]) != ' ') && (c != '>')) {
|
||||||
|
if ((c >= 'a') && (c <= 'z')) c -= ('a' - 'A');
|
||||||
|
m_Name += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source[i-1] != '>')
|
||||||
|
while ((i < end_pos) && ((c = source[i++]) != '>')) {
|
||||||
|
if ((c >= 'a') && (c <= 'z')) c -= ('a' - 'A');
|
||||||
|
m_Params += c;
|
||||||
|
if (c == '"') {
|
||||||
|
while ((i < end_pos) && ((c = source[i++]) != '"')) m_Params += c;
|
||||||
|
m_Params += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_Begin = i;
|
||||||
|
|
||||||
|
cache -> QueryTag(pos, &m_End1, &m_End2);
|
||||||
|
if (m_End1 > end_pos) m_End1 = end_pos;
|
||||||
|
if (m_End2 > end_pos) m_End2 = end_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlTag::HasParam(const wxString& par) const
|
||||||
|
{
|
||||||
|
const char *st = m_Params, *p = par;
|
||||||
|
const char *st2, *p2;
|
||||||
|
|
||||||
|
if (*st == 0) return FALSE;
|
||||||
|
if (*p == 0) return FALSE;
|
||||||
|
for (st2 = st, p2 = p; ; st2++) {
|
||||||
|
if (*p2 == 0) return TRUE;
|
||||||
|
if (*st2 == 0) return FALSE;
|
||||||
|
if (*p2 != *st2) p2 = p;
|
||||||
|
if (*p2 == *st2) p2++;
|
||||||
|
if (*st2 == ' ') p2 = p;
|
||||||
|
else if (*st2 == '=') {
|
||||||
|
p2 = p;
|
||||||
|
while (*st2 != ' ') {
|
||||||
|
if (*st2 == '"') {
|
||||||
|
st2++;
|
||||||
|
while (*st2 != '"') st2++;
|
||||||
|
}
|
||||||
|
st2++;
|
||||||
|
if (*st2 == 0) return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const
|
||||||
|
{
|
||||||
|
const char *st = m_Params, *p = par;
|
||||||
|
const char *st2, *p2;
|
||||||
|
bool comma;
|
||||||
|
|
||||||
|
if (*st == 0) return "";
|
||||||
|
if (*p == 0) return "";
|
||||||
|
for (st2 = st, p2 = p; ; st2++) {
|
||||||
|
if (*p2 == 0) { // found
|
||||||
|
wxString fnd = "";
|
||||||
|
st2++; // '=' character
|
||||||
|
comma = FALSE;
|
||||||
|
if (!with_commas && (*(st2) == '"')) {st2++; comma = TRUE;}
|
||||||
|
while (*st2 != 0) {
|
||||||
|
if (*st2 == '"') comma = !comma;
|
||||||
|
else if ((*st2 == ' ') && (!comma)) break;
|
||||||
|
fnd += (*(st2++));
|
||||||
|
}
|
||||||
|
if (!with_commas && (*(st2-1) == '"')) fnd.RemoveLast();
|
||||||
|
return fnd;
|
||||||
|
}
|
||||||
|
if (*st2 == 0) return "";
|
||||||
|
if (*p2 != *st2) p2 = p;
|
||||||
|
if (*p2 == *st2) p2++;
|
||||||
|
if (*st2 == ' ') p2 = p;
|
||||||
|
else if (*st2 == '=') {
|
||||||
|
p2 = p;
|
||||||
|
while (*st2 != ' ') {
|
||||||
|
if (*st2 == '"') {
|
||||||
|
st2++;
|
||||||
|
while (*st2 != '"') st2++;
|
||||||
|
}
|
||||||
|
st2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlTag::ScanParam(const wxString& par, char *format, ...) const
|
||||||
|
{
|
||||||
|
va_list argptr;
|
||||||
|
wxString parval = GetParam(par);
|
||||||
|
|
||||||
|
va_start(argptr, format);
|
||||||
|
|
||||||
|
#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__VISUALC__)
|
||||||
|
sscanf((const char*)parval, format, va_arg(argptr, void *));
|
||||||
|
#else
|
||||||
|
vsscanf((const char*)parval, format, argptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
--- vsscanf is not defined under Cygwin or Mingw32 or M$ Visual C++ environment
|
||||||
|
if this module doesn't compile with your compiler,
|
||||||
|
modify the def statement and let me know. Thanks...
|
||||||
|
|
||||||
|
So far wxHtml functions are scanning only _one_ value
|
||||||
|
so I workarounded this by supposing that there is only
|
||||||
|
one ...-parameter
|
||||||
|
*/
|
||||||
|
|
||||||
|
va_end(argptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
542
src/html/htmlwin.cpp
Normal file
@@ -0,0 +1,542 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlwin.cpp
|
||||||
|
// Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
|
||||||
|
#include <wx/html/forcelink.h>
|
||||||
|
|
||||||
|
///// This is my own wxBusyCursor. It works only with one window.
|
||||||
|
|
||||||
|
#if (defined __WXGTK__) && (wxVERSION_NUMBER < 2100)
|
||||||
|
class wxLocalBusyCursor
|
||||||
|
#else
|
||||||
|
class wxLocalBusyCursor : public wxBusyCursor
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
wxWindow *m_Wnd;
|
||||||
|
public:
|
||||||
|
#if (defined __WXGTK__) && (wxVERSION_NUMBER < 2100)
|
||||||
|
wxLocalBusyCursor(wxWindow *w) {m_Wnd = w; m_Wnd -> SetCursor(*wxHOURGLASS_CURSOR);}
|
||||||
|
~wxLocalBusyCursor() {m_Wnd -> SetCursor(*wxSTANDARD_CURSOR);}
|
||||||
|
#else
|
||||||
|
wxLocalBusyCursor(wxWindow *w) : wxBusyCursor() {}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlWindow
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/arrimpl.cpp>
|
||||||
|
WX_DEFINE_OBJARRAY(HtmlHistoryArray)
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlWindow::wxHtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
|
const wxString& name, bool scrollable) : wxScrolledWindow(parent, id, pos, size, wxVSCROLL, name)
|
||||||
|
{
|
||||||
|
m_tmpMouseMoved = FALSE;
|
||||||
|
m_tmpCanDraw = TRUE;
|
||||||
|
m_FS = new wxFileSystem();
|
||||||
|
m_RelatedStatusBar = -1;
|
||||||
|
m_RelatedFrame = NULL;
|
||||||
|
m_TitleFormat = "%s";
|
||||||
|
m_OpenedPage = m_OpenedAnchor = wxEmptyString;
|
||||||
|
m_Cell = NULL;
|
||||||
|
m_Parser = new wxHtmlWinParser(this);
|
||||||
|
m_Parser -> SetFS(m_FS);
|
||||||
|
SetBorders(10);
|
||||||
|
m_HistoryPos = -1;
|
||||||
|
m_HistoryOn = TRUE;
|
||||||
|
m_Scrollable = scrollable;
|
||||||
|
SetPage("<html><body></body></html>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlWindow::~wxHtmlWindow()
|
||||||
|
{
|
||||||
|
HistoryClear();
|
||||||
|
|
||||||
|
if (m_Cell) delete m_Cell;
|
||||||
|
|
||||||
|
wxList *parser_data = m_Parser -> GetTempData();
|
||||||
|
if (parser_data) delete parser_data;
|
||||||
|
|
||||||
|
delete m_Parser;
|
||||||
|
delete m_FS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::SetRelatedFrame(wxFrame* frame, const wxString& format)
|
||||||
|
{
|
||||||
|
m_RelatedFrame = frame;
|
||||||
|
m_TitleFormat = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::SetRelatedStatusBar(int bar)
|
||||||
|
{
|
||||||
|
m_RelatedStatusBar = bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes)
|
||||||
|
{
|
||||||
|
m_Parser -> SetFonts(normal_face, normal_italic_mode, fixed_face, fixed_italic_mode, sizes);
|
||||||
|
if (!m_OpenedPage.IsEmpty()) LoadPage(m_OpenedPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlWindow::SetPage(const wxString& source)
|
||||||
|
{
|
||||||
|
wxClientDC *dc = new wxClientDC(this);
|
||||||
|
|
||||||
|
dc -> SetMapMode(wxMM_TEXT);
|
||||||
|
SetBackgroundColour(wxColour(0xFF, 0xFF, 0xFF));
|
||||||
|
m_OpenedPage = m_OpenedAnchor = wxEmptyString;
|
||||||
|
m_Parser -> SetDC(dc);
|
||||||
|
if (m_Cell) delete m_Cell;
|
||||||
|
m_Cell = (wxHtmlContainerCell*) m_Parser -> Parse(source);
|
||||||
|
delete dc;
|
||||||
|
m_Cell -> SetIndent(m_Borders, HTML_INDENT_ALL, HTML_UNITS_PIXELS);
|
||||||
|
m_Cell -> SetAlignHor(HTML_ALIGN_CENTER);
|
||||||
|
CreateLayout();
|
||||||
|
Refresh();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlWindow::LoadPage(const wxString& location)
|
||||||
|
{
|
||||||
|
wxFSFile *f;
|
||||||
|
bool rt_val;
|
||||||
|
wxLocalBusyCursor b(this);
|
||||||
|
|
||||||
|
m_tmpCanDraw = FALSE;
|
||||||
|
if (m_HistoryOn && (m_HistoryPos != -1)) { // store scroll position into history item
|
||||||
|
int x, y;
|
||||||
|
ViewStart(&x, &y);
|
||||||
|
m_History[m_HistoryPos].SetPos(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (location[0] == '#') { // local anchor
|
||||||
|
wxString anch = location.Mid(1) /*1 to end*/;
|
||||||
|
m_tmpCanDraw = TRUE;
|
||||||
|
rt_val = ScrollToAnchor(anch);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
// load&display it:
|
||||||
|
if (m_RelatedStatusBar != -1) {
|
||||||
|
m_RelatedFrame -> SetStatusText(_("Connecting..."), m_RelatedStatusBar);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
f = m_FS -> OpenFile(location);
|
||||||
|
if (f == NULL) {
|
||||||
|
wxString err;
|
||||||
|
|
||||||
|
err.Printf(_("The browser is unable to open requested location :\n\n%s"), WXSTRINGCAST location);
|
||||||
|
wxMessageBox(err, "Error");
|
||||||
|
m_tmpCanDraw = TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
wxNode *node;
|
||||||
|
wxString src = wxEmptyString;
|
||||||
|
|
||||||
|
if (m_RelatedStatusBar != -1) {
|
||||||
|
wxString msg = _("Loading : ") + location;
|
||||||
|
m_RelatedFrame -> SetStatusText(msg, m_RelatedStatusBar);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
node = m_Filters.GetFirst();
|
||||||
|
while (node){
|
||||||
|
wxHtmlFilter *h = (wxHtmlFilter*) node -> GetData();
|
||||||
|
if (h -> CanRead(*f)) {
|
||||||
|
src = h -> ReadFile(*f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
node = node -> GetNext();
|
||||||
|
}
|
||||||
|
if (src == wxEmptyString) src = m_DefaultFilter.ReadFile(*f);
|
||||||
|
|
||||||
|
m_FS -> ChangePathTo(f -> GetLocation());
|
||||||
|
rt_val = SetPage(src);
|
||||||
|
m_OpenedPage = f -> GetLocation();
|
||||||
|
if (f -> GetAnchor() != wxEmptyString) {
|
||||||
|
m_tmpCanDraw = TRUE;
|
||||||
|
ScrollToAnchor(f -> GetAnchor());
|
||||||
|
m_tmpCanDraw = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete f;
|
||||||
|
|
||||||
|
if (m_RelatedStatusBar != -1) m_RelatedFrame -> SetStatusText(_("Done"), m_RelatedStatusBar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_HistoryOn) { // add this page to history there:
|
||||||
|
int c = m_History.GetCount() - (m_HistoryPos + 1);
|
||||||
|
|
||||||
|
m_HistoryPos++;
|
||||||
|
for (int i = 0; i < c; i++)
|
||||||
|
m_History.Remove(m_HistoryPos);
|
||||||
|
m_History.Add(new HtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_tmpCanDraw = TRUE;
|
||||||
|
Refresh();
|
||||||
|
return rt_val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlWindow::ScrollToAnchor(const wxString& anchor)
|
||||||
|
{
|
||||||
|
const wxHtmlCell *c = m_Cell -> Find(HTML_COND_ISANCHOR, &anchor);
|
||||||
|
if (!c) return FALSE;
|
||||||
|
else {
|
||||||
|
int y;
|
||||||
|
|
||||||
|
for (y = 0; c != NULL; c = c -> GetParent()) y += c -> GetPosY();
|
||||||
|
Scroll(-1, y / HTML_SCROLL_STEP);
|
||||||
|
m_OpenedAnchor = anchor;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::SetTitle(const wxString& title)
|
||||||
|
{
|
||||||
|
if (m_RelatedFrame) {
|
||||||
|
wxString tit;
|
||||||
|
tit.Printf(m_TitleFormat, title.c_str());
|
||||||
|
m_RelatedFrame -> SetTitle(tit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::CreateLayout()
|
||||||
|
{
|
||||||
|
int ClientWidth, ClientHeight;
|
||||||
|
|
||||||
|
if (!m_Cell) return;
|
||||||
|
GetClientSize(&ClientWidth, &ClientHeight);
|
||||||
|
m_Cell -> Layout(ClientWidth);
|
||||||
|
if (m_Scrollable)
|
||||||
|
SetScrollbars(HTML_SCROLL_STEP, HTML_SCROLL_STEP,
|
||||||
|
m_Cell -> GetWidth() / HTML_SCROLL_STEP,
|
||||||
|
m_Cell -> GetHeight() / HTML_SCROLL_STEP
|
||||||
|
/*cheat: top-level frag is always container*/ );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::ReadCustomization(wxConfigBase *cfg, wxString path)
|
||||||
|
{
|
||||||
|
wxString oldpath;
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
|
if (path != wxEmptyString) {
|
||||||
|
oldpath = cfg -> GetPath();
|
||||||
|
cfg -> SetPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Borders = cfg -> Read("wxHtmlWindow/Borders", m_Borders);
|
||||||
|
m_Parser -> m_FontFaceFixed = cfg -> Read("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed);
|
||||||
|
m_Parser -> m_FontFaceNormal = cfg -> Read("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal);
|
||||||
|
m_Parser -> m_ItalicModeFixed = cfg -> Read("wxHtmlWindow/ItalicModeFixed", m_Parser -> m_ItalicModeFixed);
|
||||||
|
m_Parser -> m_ItalicModeNormal = cfg -> Read("wxHtmlWindow/ItalicModeNormal", m_Parser -> m_ItalicModeNormal);
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
tmp.Printf("wxHtmlWindow/FontsSize%i", i);
|
||||||
|
m_Parser -> m_FontsSizes[i] = cfg -> Read(tmp, m_Parser -> m_FontsSizes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path != wxEmptyString)
|
||||||
|
cfg -> SetPath(oldpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::WriteCustomization(wxConfigBase *cfg, wxString path)
|
||||||
|
{
|
||||||
|
wxString oldpath;
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
|
if (path != wxEmptyString) {
|
||||||
|
oldpath = cfg -> GetPath();
|
||||||
|
cfg -> SetPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg -> Write("wxHtmlWindow/Borders", (long) m_Borders);
|
||||||
|
cfg -> Write("wxHtmlWindow/FontFaceFixed", m_Parser -> m_FontFaceFixed);
|
||||||
|
cfg -> Write("wxHtmlWindow/FontFaceNormal", m_Parser -> m_FontFaceNormal);
|
||||||
|
cfg -> Write("wxHtmlWindow/ItalicModeFixed", (long) m_Parser -> m_ItalicModeFixed);
|
||||||
|
cfg -> Write("wxHtmlWindow/ItalicModeNormal", (long) m_Parser -> m_ItalicModeNormal);
|
||||||
|
for (int i = 0; i < 7; i++) {
|
||||||
|
tmp.Printf("wxHtmlWindow/FontsSize%i", i);
|
||||||
|
cfg -> Write(tmp, (long) m_Parser -> m_FontsSizes[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (path != wxEmptyString)
|
||||||
|
cfg -> SetPath(oldpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlWindow::HistoryBack()
|
||||||
|
{
|
||||||
|
wxString a, l;
|
||||||
|
|
||||||
|
if (m_HistoryPos < 1) return FALSE;
|
||||||
|
|
||||||
|
m_HistoryPos--;
|
||||||
|
|
||||||
|
l = m_History[m_HistoryPos].GetPage();
|
||||||
|
a = m_History[m_HistoryPos].GetAnchor();
|
||||||
|
m_HistoryOn = FALSE;
|
||||||
|
if (a == wxEmptyString) LoadPage(l);
|
||||||
|
else LoadPage(l + "#" + a);
|
||||||
|
m_HistoryOn = TRUE;
|
||||||
|
Scroll(0, m_History[m_HistoryPos].GetPos());
|
||||||
|
Refresh();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlWindow::HistoryForward()
|
||||||
|
{
|
||||||
|
wxString a, l;
|
||||||
|
|
||||||
|
if (m_HistoryPos == -1) return FALSE;
|
||||||
|
if (m_HistoryPos >= (int)m_History.GetCount() - 1)return FALSE;
|
||||||
|
|
||||||
|
m_OpenedPage = wxEmptyString; // this will disable adding new entry into history in LoadPage()
|
||||||
|
|
||||||
|
m_HistoryPos++;
|
||||||
|
l = m_History[m_HistoryPos].GetPage();
|
||||||
|
a = m_History[m_HistoryPos].GetAnchor();
|
||||||
|
m_HistoryOn = FALSE;
|
||||||
|
if (a == wxEmptyString) LoadPage(l);
|
||||||
|
else LoadPage(l + "#" + a);
|
||||||
|
m_HistoryOn = TRUE;
|
||||||
|
Scroll(0, m_History[m_HistoryPos].GetPos());
|
||||||
|
Refresh();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::HistoryClear()
|
||||||
|
{
|
||||||
|
m_History.Empty();
|
||||||
|
m_HistoryPos = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxList wxHtmlWindow::m_Filters;
|
||||||
|
wxHtmlFilterPlainText wxHtmlWindow::m_DefaultFilter;
|
||||||
|
|
||||||
|
void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
|
||||||
|
{
|
||||||
|
m_Filters.DeleteContents(TRUE);
|
||||||
|
m_Filters.Append(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnLinkClicked(const wxString& link)
|
||||||
|
{
|
||||||
|
LoadPage(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnDraw(wxDC& dc)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
wxRegionIterator upd(GetUpdateRegion()); // get the update rect list
|
||||||
|
int v_y, v_h;
|
||||||
|
|
||||||
|
if (!m_tmpCanDraw) return;
|
||||||
|
dc.SetMapMode(wxMM_TEXT);
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER == 1200)
|
||||||
|
::SetMapMode((HDC)dc.GetHDC(), MM_TEXT);
|
||||||
|
#endif
|
||||||
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
ViewStart(&x, &y);
|
||||||
|
|
||||||
|
while (upd) {
|
||||||
|
v_y = upd.GetY();
|
||||||
|
v_h = upd.GetH();
|
||||||
|
if (m_Cell) m_Cell -> Draw(dc, 0, 0, y * HTML_SCROLL_STEP + v_y, y * HTML_SCROLL_STEP + v_h + v_y);
|
||||||
|
upd++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnSize(wxSizeEvent& event)
|
||||||
|
{
|
||||||
|
wxScrolledWindow::OnSize(event);
|
||||||
|
CreateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnKeyDown(wxKeyEvent& event)
|
||||||
|
{
|
||||||
|
int dummy;
|
||||||
|
int sty, szy, cliy;
|
||||||
|
|
||||||
|
ViewStart(&dummy, &sty);
|
||||||
|
GetClientSize(&dummy, &cliy); cliy /= HTML_SCROLL_STEP;
|
||||||
|
GetVirtualSize(&dummy, &szy); szy /= HTML_SCROLL_STEP;
|
||||||
|
|
||||||
|
switch (event.KeyCode()) {
|
||||||
|
case WXK_PAGEUP :
|
||||||
|
case WXK_PRIOR :
|
||||||
|
Scroll(-1, sty - cliy);
|
||||||
|
break;
|
||||||
|
case WXK_PAGEDOWN :
|
||||||
|
case WXK_NEXT :
|
||||||
|
Scroll(-1, sty + cliy);
|
||||||
|
break;
|
||||||
|
case WXK_HOME :
|
||||||
|
Scroll(-1, 0);
|
||||||
|
break;
|
||||||
|
case WXK_END :
|
||||||
|
Scroll(-1, szy - cliy);
|
||||||
|
break;
|
||||||
|
case WXK_UP :
|
||||||
|
Scroll(-1, sty - 1);
|
||||||
|
break;
|
||||||
|
case WXK_DOWN :
|
||||||
|
Scroll(-1, sty + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event)
|
||||||
|
{
|
||||||
|
m_tmpMouseMoved = TRUE;
|
||||||
|
|
||||||
|
if (event.ButtonDown()) {
|
||||||
|
int sx, sy;
|
||||||
|
wxPoint pos;
|
||||||
|
wxString lnk;
|
||||||
|
|
||||||
|
ViewStart(&sx, &sy); sx *= HTML_SCROLL_STEP; sy *= HTML_SCROLL_STEP;
|
||||||
|
pos = event.GetPosition();
|
||||||
|
|
||||||
|
if (m_Cell)
|
||||||
|
m_Cell -> OnMouseClick(this, sx + pos.x, sy + pos.y, event.ButtonDown(1), event.ButtonDown(2), event.ButtonDown(3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWindow::OnIdle(wxIdleEvent& event)
|
||||||
|
{
|
||||||
|
static wxCursor cur_hand(wxCURSOR_HAND), cur_arrow(wxCURSOR_ARROW);
|
||||||
|
|
||||||
|
if (m_tmpMouseMoved && (m_Cell != NULL)) {
|
||||||
|
int sx, sy;
|
||||||
|
int x, y;
|
||||||
|
wxString lnk;
|
||||||
|
|
||||||
|
ViewStart(&sx, &sy); sx *= HTML_SCROLL_STEP; sy *= HTML_SCROLL_STEP;
|
||||||
|
wxGetMousePosition(&x, &y);
|
||||||
|
ScreenToClient(&x, &y);
|
||||||
|
lnk = m_Cell -> GetLink(sx + x, sy + y);
|
||||||
|
|
||||||
|
if (lnk == wxEmptyString) {
|
||||||
|
SetCursor(cur_arrow);
|
||||||
|
if (m_RelatedStatusBar != -1) m_RelatedFrame -> SetStatusText(wxEmptyString, m_RelatedStatusBar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetCursor(cur_hand);
|
||||||
|
if (m_RelatedStatusBar != -1) m_RelatedFrame -> SetStatusText(lnk, m_RelatedStatusBar);
|
||||||
|
}
|
||||||
|
m_tmpMouseMoved = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
|
||||||
|
EVT_SIZE(wxHtmlWindow::OnSize)
|
||||||
|
EVT_LEFT_DOWN(wxHtmlWindow::OnMouseEvent)
|
||||||
|
EVT_MOTION(wxHtmlWindow::OnMouseEvent)
|
||||||
|
EVT_IDLE(wxHtmlWindow::OnIdle)
|
||||||
|
EVT_KEY_DOWN(wxHtmlWindow::OnKeyDown)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///// default mod handlers are forced there:
|
||||||
|
|
||||||
|
FORCE_LINK(mod_layout)
|
||||||
|
FORCE_LINK(mod_fonts)
|
||||||
|
FORCE_LINK(mod_image)
|
||||||
|
FORCE_LINK(mod_list)
|
||||||
|
FORCE_LINK(mod_pre)
|
||||||
|
FORCE_LINK(mod_hline)
|
||||||
|
FORCE_LINK(mod_links)
|
||||||
|
FORCE_LINK(mod_tables)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
288
src/html/htmlwinparser.cpp
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmlwinparser.cpp
|
||||||
|
// Purpose: wxHtmlParser class (generic parser)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#ifdef __BORDLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WXPRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/html/htmldefs.h>
|
||||||
|
#include <wx/html/htmlwinparser.h>
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlWinParser
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinParser,wxHtmlParser)
|
||||||
|
|
||||||
|
wxList wxHtmlWinParser::m_Modules;
|
||||||
|
|
||||||
|
wxHtmlWinParser::wxHtmlWinParser(wxWindow *wnd) : wxHtmlParser()
|
||||||
|
{
|
||||||
|
m_Window = wnd;
|
||||||
|
m_Container = NULL;
|
||||||
|
m_DC = NULL;
|
||||||
|
m_CharHeight = m_CharWidth = 0;
|
||||||
|
m_UseLink = FALSE;
|
||||||
|
|
||||||
|
{
|
||||||
|
int i, j, k, l, m;
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
for (j = 0; j < 2; j++)
|
||||||
|
for (k = 0; k < 2; k++)
|
||||||
|
for (l = 0; l < 2; l++)
|
||||||
|
for (m = 0; m < 7; m++)
|
||||||
|
m_FontsTable[i][j][k][l][m] = NULL;
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
int default_sizes[7] = {7, 8, 10, 12, 16, 22, 30};
|
||||||
|
#else
|
||||||
|
int default_sizes[7] = {10, 12, 14, 16, 19, 24, 32};
|
||||||
|
#endif
|
||||||
|
SetFonts("", wxSLANT, "", wxSLANT, default_sizes);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fill in wxHtmlParser's tables:
|
||||||
|
wxNode *node = m_Modules.GetFirst();
|
||||||
|
while (node){
|
||||||
|
wxHtmlTagsModule *mod = (wxHtmlTagsModule*) node -> GetData();
|
||||||
|
mod -> FillHandlersTable(this);
|
||||||
|
node = node -> GetNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWinParser::AddModule(wxHtmlTagsModule *module)
|
||||||
|
{
|
||||||
|
m_Modules.Append(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWinParser::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 7; i++) m_FontsSizes[i] = sizes[i];
|
||||||
|
m_FontFaceFixed = fixed_face;
|
||||||
|
m_FontFaceNormal = normal_face;
|
||||||
|
m_ItalicModeFixed = fixed_italic_mode;
|
||||||
|
m_ItalicModeNormal = normal_italic_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWinParser::InitParser(const wxString& source)
|
||||||
|
{
|
||||||
|
wxHtmlParser::InitParser(source);
|
||||||
|
wxASSERT_MSG(m_DC != NULL, _("no DC assigned to wxHtmlWinParser!!"));
|
||||||
|
|
||||||
|
m_FontBold = m_FontItalic = m_FontUnderlined = m_FontFixed = FALSE;
|
||||||
|
m_FontSize = 0;
|
||||||
|
CreateCurrentFont(); // we're selecting default font into
|
||||||
|
m_DC -> GetTextExtent("H", &m_CharWidth, &m_CharHeight);
|
||||||
|
/* NOTE : we're not using GetCharWidth/Height() because
|
||||||
|
of differences under X and win
|
||||||
|
*/
|
||||||
|
|
||||||
|
m_Link = "";
|
||||||
|
m_LinkColor.Set(0, 0, 0xFF);
|
||||||
|
m_ActualColor.Set(0, 0, 0);
|
||||||
|
m_Align = HTML_ALIGN_LEFT;
|
||||||
|
m_tmpLastWasSpace = FALSE;
|
||||||
|
|
||||||
|
OpenContainer();
|
||||||
|
|
||||||
|
OpenContainer();
|
||||||
|
m_Container -> InsertCell(new wxHtmlColourCell(m_ActualColor));
|
||||||
|
m_Container -> InsertCell(new wxHtmlFontCell(CreateCurrentFont()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWinParser::DoneParser()
|
||||||
|
{
|
||||||
|
m_Container = NULL;
|
||||||
|
wxHtmlParser::DoneParser();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxObject* wxHtmlWinParser::GetProduct()
|
||||||
|
{
|
||||||
|
wxHtmlContainerCell *top;
|
||||||
|
|
||||||
|
CloseContainer();
|
||||||
|
OpenContainer();
|
||||||
|
GetContainer() -> SetIndent(m_CharHeight, HTML_INDENT_TOP);
|
||||||
|
top = m_Container;
|
||||||
|
while (top -> GetParent()) top = top -> GetParent();
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxList* wxHtmlWinParser::GetTempData()
|
||||||
|
{
|
||||||
|
int i, j, k, l, m;
|
||||||
|
wxFont *f;
|
||||||
|
wxList *lst = wxHtmlParser::GetTempData();
|
||||||
|
|
||||||
|
if (lst == NULL) lst = new wxList;
|
||||||
|
lst -> DeleteContents(TRUE);
|
||||||
|
|
||||||
|
for (i = 0; i < 2; i++)
|
||||||
|
for (j = 0; j < 2; j++)
|
||||||
|
for (k = 0; k < 2; k++)
|
||||||
|
for (l = 0; l < 2; l++)
|
||||||
|
for (m = 0; m < 7; m++) {
|
||||||
|
f = m_FontsTable[i][j][k][l][m];
|
||||||
|
if (f) lst -> Append(f);
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlWinParser::AddText(const char* txt)
|
||||||
|
{
|
||||||
|
wxHtmlCell *c;
|
||||||
|
int i = 0, x, lng = strlen(txt);
|
||||||
|
char temp[HTML_BUFLEN];
|
||||||
|
register char d;
|
||||||
|
int templen = 0;
|
||||||
|
|
||||||
|
if (m_tmpLastWasSpace) {
|
||||||
|
while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (i < lng) {
|
||||||
|
x = 0;
|
||||||
|
d = temp[templen++] = txt[i];
|
||||||
|
if ((d == '\n') || (d == '\r') || (d == ' ') || (d == '\t')) {
|
||||||
|
i++, x++;
|
||||||
|
while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++, x++;
|
||||||
|
}
|
||||||
|
else i++;
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
temp[templen-1] = ' ';
|
||||||
|
temp[templen] = 0;
|
||||||
|
templen = 0;
|
||||||
|
c = new wxHtmlWordCell(temp, *(GetDC()));
|
||||||
|
if (m_UseLink) c -> SetLink(m_Link);
|
||||||
|
m_Container -> InsertCell(c);
|
||||||
|
m_tmpLastWasSpace = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (templen) {
|
||||||
|
temp[templen] = 0;
|
||||||
|
c = new wxHtmlWordCell(temp, *(GetDC()));
|
||||||
|
if (m_UseLink) c -> SetLink(m_Link);
|
||||||
|
m_Container -> InsertCell(c);
|
||||||
|
m_tmpLastWasSpace = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlContainerCell* wxHtmlWinParser::OpenContainer()
|
||||||
|
{
|
||||||
|
m_Container = new wxHtmlContainerCell(m_Container);
|
||||||
|
m_Container -> SetAlignHor(m_Align);
|
||||||
|
m_tmpLastWasSpace = TRUE;
|
||||||
|
/* to avoid space being first character in paragraph */
|
||||||
|
return m_Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlContainerCell* wxHtmlWinParser::SetContainer(wxHtmlContainerCell *c)
|
||||||
|
{
|
||||||
|
m_tmpLastWasSpace = TRUE;
|
||||||
|
/* to avoid space being first character in paragraph */
|
||||||
|
return m_Container = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlContainerCell* wxHtmlWinParser::CloseContainer()
|
||||||
|
{
|
||||||
|
m_Container = m_Container -> GetParent();
|
||||||
|
return m_Container;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxFont* wxHtmlWinParser::CreateCurrentFont()
|
||||||
|
{
|
||||||
|
int fb = GetFontBold(),
|
||||||
|
fi = GetFontItalic(),
|
||||||
|
fu = GetFontUnderlined(),
|
||||||
|
ff = GetFontFixed(),
|
||||||
|
fs = GetFontSize() + 2 /*remap from <-2;4> to <0;7>*/ ;
|
||||||
|
|
||||||
|
if (m_FontsTable[fb][fi][fu][ff][fs] == NULL) {
|
||||||
|
m_FontsTable[fb][fi][fu][ff][fs] =
|
||||||
|
//wxTheFontList -> FindOrCreateFont(
|
||||||
|
new wxFont(
|
||||||
|
m_FontsSizes[fs],
|
||||||
|
ff ? wxMODERN : wxSWISS,
|
||||||
|
fi ? (ff ? m_ItalicModeFixed : m_ItalicModeNormal) : wxNORMAL,
|
||||||
|
fb ? wxBOLD : wxNORMAL,
|
||||||
|
fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal);
|
||||||
|
}
|
||||||
|
m_DC -> SetFont(*(m_FontsTable[fb][fi][fu][ff][fs]));
|
||||||
|
return (m_FontsTable[fb][fi][fu][ff][fs]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlWinTagHandler
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_ABSTRACT_CLASS(wxHtmlWinTagHandler, wxHtmlTagHandler)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlTagsModule
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxHtmlTagsModule, wxModule)
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlTagsModule::OnInit()
|
||||||
|
{
|
||||||
|
wxHtmlWinParser::AddModule(this);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlTagsModule::OnExit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
175
src/html/mod_fonts.cpp
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mod_fonts.cpp
|
||||||
|
// Purpose: wxHtml module for fonts & colors of fonts
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/html/forcelink.h>
|
||||||
|
#include <wx/html/mod_templ.h>
|
||||||
|
|
||||||
|
FORCE_LINK_ME(mod_fonts)
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(FONT, "FONT")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
unsigned long tmp;
|
||||||
|
wxColour oldclr = m_WParser -> GetActualColor();
|
||||||
|
int oldsize = m_WParser -> GetFontSize();
|
||||||
|
|
||||||
|
if (tag.HasParam("COLOR")) {
|
||||||
|
wxColour clr;
|
||||||
|
tag.ScanParam("COLOR", "#%lX", &tmp);
|
||||||
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
|
m_WParser -> SetActualColor(clr);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.HasParam("SIZE")) {
|
||||||
|
tag.ScanParam("SIZE", "%li", &tmp);
|
||||||
|
m_WParser -> SetFontSize(tmp);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
if (oldclr != m_WParser -> GetActualColor()) {
|
||||||
|
m_WParser -> SetActualColor(oldclr);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr));
|
||||||
|
}
|
||||||
|
if (oldsize != m_WParser -> GetFontSize()) {
|
||||||
|
m_WParser -> SetFontSize(oldsize);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(FONT)
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(FACES, "U,I,B,TT")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
int fixed = m_WParser -> GetFontFixed(),
|
||||||
|
italic = m_WParser -> GetFontItalic(),
|
||||||
|
underlined = m_WParser -> GetFontUnderlined(),
|
||||||
|
bold = m_WParser -> GetFontBold();
|
||||||
|
|
||||||
|
if (tag.GetName() == "U")
|
||||||
|
m_WParser -> SetFontUnderlined(TRUE);
|
||||||
|
else if (tag.GetName() == "B")
|
||||||
|
m_WParser -> SetFontBold(TRUE);
|
||||||
|
else if (tag.GetName() == "I")
|
||||||
|
m_WParser -> SetFontItalic(TRUE);
|
||||||
|
else
|
||||||
|
m_WParser -> SetFontFixed(TRUE);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
m_WParser -> SetFontUnderlined(underlined);
|
||||||
|
m_WParser -> SetFontBold(bold);
|
||||||
|
m_WParser -> SetFontItalic(italic);
|
||||||
|
m_WParser -> SetFontFixed(fixed);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(FACES)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
int old_size, old_b, old_i, old_u, old_f, old_al;
|
||||||
|
wxHtmlContainerCell *c;
|
||||||
|
|
||||||
|
old_size = m_WParser -> GetFontSize();
|
||||||
|
old_b = m_WParser -> GetFontBold();
|
||||||
|
old_i = m_WParser -> GetFontItalic();
|
||||||
|
old_u = m_WParser -> GetFontUnderlined();
|
||||||
|
old_f = m_WParser -> GetFontFixed();
|
||||||
|
old_al = m_WParser -> GetAlign();
|
||||||
|
|
||||||
|
m_WParser -> SetFontBold(TRUE);
|
||||||
|
m_WParser -> SetFontItalic(FALSE);
|
||||||
|
m_WParser -> SetFontUnderlined(FALSE);
|
||||||
|
m_WParser -> SetFontFixed(FALSE);
|
||||||
|
|
||||||
|
if (tag.GetName() == "H1")
|
||||||
|
m_WParser -> SetFontSize(+4);
|
||||||
|
else if (tag.GetName() == "H2")
|
||||||
|
m_WParser -> SetFontSize(+3);
|
||||||
|
else if (tag.GetName() == "H3")
|
||||||
|
m_WParser -> SetFontSize(+2);
|
||||||
|
else if (tag.GetName() == "H4") {
|
||||||
|
m_WParser -> SetFontSize(+2);
|
||||||
|
m_WParser -> SetFontItalic(TRUE);
|
||||||
|
m_WParser -> SetFontBold(FALSE);
|
||||||
|
}
|
||||||
|
else if (tag.GetName() == "H5")
|
||||||
|
m_WParser -> SetFontSize(+1);
|
||||||
|
else if (tag.GetName() == "H6") {
|
||||||
|
m_WParser -> SetFontSize(+1);
|
||||||
|
m_WParser -> SetFontItalic(TRUE);
|
||||||
|
m_WParser -> SetFontBold(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
c = m_WParser -> GetContainer();
|
||||||
|
if (c -> GetFirstCell()) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
c = m_WParser -> GetContainer();
|
||||||
|
}
|
||||||
|
c = m_WParser -> GetContainer();
|
||||||
|
|
||||||
|
c -> SetAlign(tag);
|
||||||
|
c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
|
||||||
|
m_WParser -> SetAlign(c -> GetAlignHor());
|
||||||
|
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
m_WParser -> SetFontSize(old_size);
|
||||||
|
m_WParser -> SetFontBold(old_b);
|
||||||
|
m_WParser -> SetFontItalic(old_i);
|
||||||
|
m_WParser -> SetFontUnderlined(old_u);
|
||||||
|
m_WParser -> SetFontFixed(old_f);
|
||||||
|
m_WParser -> SetAlign(old_al);
|
||||||
|
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont()));
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
c = m_WParser -> GetContainer();
|
||||||
|
c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(Hx)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(Fonts)
|
||||||
|
|
||||||
|
TAGS_MODULE_ADD(FONT)
|
||||||
|
TAGS_MODULE_ADD(FACES)
|
||||||
|
TAGS_MODULE_ADD(Hx)
|
||||||
|
|
||||||
|
TAGS_MODULE_END(Fonts)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
88
src/html/mod_hline.cpp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mod_hline.cpp
|
||||||
|
// Purpose: wxHtml module for horizontal line (HR tag)
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/html/forcelink.h>
|
||||||
|
#include <wx/html/mod_templ.h>
|
||||||
|
|
||||||
|
#include <wx/html/htmlcell.h>
|
||||||
|
|
||||||
|
FORCE_LINK_ME(mod_hline)
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxHtmlLineCell
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHtmlLineCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxHtmlLineCell(int size) : wxHtmlCell() {m_Height = size;}
|
||||||
|
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
void Layout(int w) {m_Width = w; if (m_Next) m_Next -> Layout(w);}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlLineCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
|
||||||
|
{
|
||||||
|
wxBrush mybrush("BLACK", wxSOLID);
|
||||||
|
wxPen mypen("BLACK", 1, wxSOLID);
|
||||||
|
dc.SetBrush(mybrush);
|
||||||
|
dc.SetPen(mypen);
|
||||||
|
dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height);
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// The list handler:
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(HR, "HR")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
wxHtmlContainerCell *c;
|
||||||
|
int sz;
|
||||||
|
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
c = m_WParser -> OpenContainer();
|
||||||
|
|
||||||
|
c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_VERTICAL);
|
||||||
|
c -> SetAlignHor(HTML_ALIGN_CENTER);
|
||||||
|
c -> SetAlign(tag);
|
||||||
|
c -> SetWidthFloat(tag);
|
||||||
|
if (tag.HasParam("SIZE")) tag.ScanParam("SIZE", "%i", &sz);
|
||||||
|
else sz = 1;
|
||||||
|
c -> InsertCell(new wxHtmlLineCell(sz));
|
||||||
|
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(HR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(HLine)
|
||||||
|
|
||||||
|
TAGS_MODULE_ADD(HR)
|
||||||
|
|
||||||
|
TAGS_MODULE_END(HLine)
|
||||||
|
|
||||||
|
#endif
|
147
src/html/mod_image.cpp
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mod_image.cpp
|
||||||
|
// Purpose: wxHtml module for displaying images
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/html/forcelink.h>
|
||||||
|
#include <wx/html/mod_templ.h>
|
||||||
|
|
||||||
|
#include <wx/wxhtml.h>
|
||||||
|
#include <wx/image.h>
|
||||||
|
|
||||||
|
FORCE_LINK_ME(mod_image)
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlImageCell
|
||||||
|
// Image/bitmap
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHtmlImageCell : public wxHtmlCell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxBitmap *m_Image;
|
||||||
|
|
||||||
|
wxHtmlImageCell(wxFSFile *input, int w = -1, int h = -1, int align = HTML_ALIGN_BOTTOM);
|
||||||
|
~wxHtmlImageCell() {if (m_Image) delete m_Image;}
|
||||||
|
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlImageCell
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align) : wxHtmlCell()
|
||||||
|
{
|
||||||
|
wxImage *img;
|
||||||
|
int ww, hh;
|
||||||
|
wxString m = input -> GetMimeType();
|
||||||
|
wxInputStream *s = input -> GetStream();
|
||||||
|
|
||||||
|
#if wxVERSION_NUMBER < 2100
|
||||||
|
/* NOTE : use this *old* code only if you have old 2.0.1 wxWindows distribution
|
||||||
|
and don't want to upgrade it with stuffs from add-on/wxwin201 */
|
||||||
|
if (wxMimeTypesManager::IsOfType(m, "image/png")) img = new wxImage(*s, wxBITMAP_TYPE_PNG);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/jpeg")) img = new wxImage(*s, wxBITMAP_TYPE_JPEG);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/bmp")) img = new wxImage(*s, wxBITMAP_TYPE_BMP);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/gif")) img = new wxImage(*s, wxBITMAP_TYPE_GIF);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/tiff")) img = new wxImage(*s, wxBITMAP_TYPE_TIF);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/xpm")) img = new wxImage(*s, wxBITMAP_TYPE_XPM);
|
||||||
|
else if (wxMimeTypesManager::IsOfType(m, "image/xbm")) img = new wxImage(*s, wxBITMAP_TYPE_XBM);
|
||||||
|
else img = NULL;
|
||||||
|
#else
|
||||||
|
img = new wxImage(*s, m);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
m_Image = NULL;
|
||||||
|
if (img && (img -> Ok())) {
|
||||||
|
ww = img -> GetWidth();
|
||||||
|
hh = img -> GetHeight();
|
||||||
|
if (w != -1) m_Width = w; else m_Width = ww;
|
||||||
|
if (h != -1) m_Height = h; else m_Height = hh;
|
||||||
|
if ((m_Width != ww) || (m_Height != hh)) {
|
||||||
|
wxImage img2 = img -> Scale(m_Width, m_Height);
|
||||||
|
m_Image = new wxBitmap(img2.ConvertToBitmap());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_Image = new wxBitmap(img -> ConvertToBitmap());
|
||||||
|
delete img;
|
||||||
|
}
|
||||||
|
switch (align) {
|
||||||
|
case HTML_ALIGN_TOP :
|
||||||
|
m_Descent = m_Height; break;
|
||||||
|
case HTML_ALIGN_CENTER :
|
||||||
|
m_Descent = m_Height / 2; break;
|
||||||
|
case HTML_ALIGN_BOTTOM : default :
|
||||||
|
m_Descent = 0; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlImageCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
|
||||||
|
{
|
||||||
|
if (m_Image)
|
||||||
|
dc.DrawBitmap(*m_Image, x + m_PosX, y + m_PosY, TRUE);
|
||||||
|
wxHtmlCell::Draw(dc, x, y, view_y1, view_y2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// tag handler
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(IMG, "IMG")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
if (tag.HasParam("SRC")) {
|
||||||
|
int w = -1, h = -1;
|
||||||
|
int al;
|
||||||
|
wxFSFile *str;
|
||||||
|
wxString tmp = tag.GetParam("SRC");
|
||||||
|
|
||||||
|
str = m_WParser -> GetFS() -> OpenFile(tmp);
|
||||||
|
if (tag.HasParam("WIDTH")) tag.ScanParam("WIDTH", "%i", &w);
|
||||||
|
if (tag.HasParam("HEIGHT")) tag.ScanParam("HEIGHT", "%i", &h);
|
||||||
|
al = HTML_ALIGN_BOTTOM;
|
||||||
|
if (tag.HasParam("ALIGN")) {
|
||||||
|
wxString alstr = tag.GetParam("ALIGN");
|
||||||
|
alstr.MakeUpper(); // for the case alignment was in ".."
|
||||||
|
if (alstr == "TEXTTOP") al = HTML_ALIGN_TOP;
|
||||||
|
else if ((alstr == "CENTER") || (alstr == "ABSCENTER")) al = HTML_ALIGN_CENTER;
|
||||||
|
}
|
||||||
|
if (str) {
|
||||||
|
wxHtmlCell *cel = new wxHtmlImageCell(str, w, h, al);
|
||||||
|
cel -> SetLink(m_WParser -> GetLink());
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(cel);
|
||||||
|
delete str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(IMAGE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(Image)
|
||||||
|
|
||||||
|
TAGS_MODULE_ADD(IMG)
|
||||||
|
|
||||||
|
TAGS_MODULE_END(Image)
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
223
src/html/mod_layout.cpp
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: mod_layout.cpp
|
||||||
|
// Purpose: wxHtml module for basic paragraphs/layout handling
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Copyright: (c) 1999 Vaclav Slavik
|
||||||
|
// Licence: wxWindows Licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/defs.h"
|
||||||
|
#if wxUSE_HTML
|
||||||
|
|
||||||
|
#include <wx/html/forcelink.h>
|
||||||
|
#include <wx/html/mod_templ.h>
|
||||||
|
|
||||||
|
#include <wx/html/htmlwin.h>
|
||||||
|
|
||||||
|
FORCE_LINK_ME(mod_layout)
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(P, "P")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
}
|
||||||
|
m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
|
||||||
|
m_WParser -> GetContainer() -> SetAlign(tag);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(P)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(BR, "BR")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
int al = m_WParser -> GetContainer() -> GetAlignHor();
|
||||||
|
wxHtmlContainerCell *c;
|
||||||
|
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
c = m_WParser -> OpenContainer();
|
||||||
|
c -> SetAlignHor(al);
|
||||||
|
c -> SetAlign(tag);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(BR)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(CENTER, "CENTER")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
int old = m_WParser -> GetAlign();
|
||||||
|
wxHtmlContainerCell *c = m_WParser -> GetContainer();
|
||||||
|
|
||||||
|
m_WParser -> SetAlign(HTML_ALIGN_CENTER);
|
||||||
|
if (c -> GetFirstCell() != NULL) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c -> SetAlignHor(HTML_ALIGN_CENTER);
|
||||||
|
|
||||||
|
if (tag.HasEnding()) {
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
m_WParser -> SetAlign(old);
|
||||||
|
if (c -> GetFirstCell() != NULL) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c -> SetAlignHor(old);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(CENTER)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(DIV, "DIV")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
int old = m_WParser -> GetAlign();
|
||||||
|
wxHtmlContainerCell *c = m_WParser -> GetContainer();
|
||||||
|
if (c -> GetFirstCell() != NULL) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
c = m_WParser -> GetContainer();
|
||||||
|
c -> SetAlign(tag);
|
||||||
|
m_WParser -> SetAlign(c -> GetAlignHor());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c -> SetAlign(tag);
|
||||||
|
m_WParser -> SetAlign(c -> GetAlignHor());
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseInner(tag);
|
||||||
|
|
||||||
|
m_WParser -> SetAlign(old);
|
||||||
|
if (c -> GetFirstCell() != NULL) {
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
c -> SetAlignHor(old);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(DIV)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(TITLE, "TITLE")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
if (m_WParser -> GetWindow()) {
|
||||||
|
wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow());
|
||||||
|
if (wfr) {
|
||||||
|
wxString title = "";
|
||||||
|
wxString *src = m_WParser -> GetSource();
|
||||||
|
|
||||||
|
for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[i];
|
||||||
|
wfr -> SetTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(TITLE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(BODY, "BODY")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
unsigned long tmp;
|
||||||
|
wxColour clr;
|
||||||
|
|
||||||
|
if (tag.HasParam("TEXT")) {
|
||||||
|
tag.ScanParam("TEXT", "#%lX", &tmp);
|
||||||
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
|
m_WParser -> SetActualColor(clr);
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.HasParam("LINK")) {
|
||||||
|
tag.ScanParam("LINK", "#%lX", &tmp);
|
||||||
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
|
m_WParser -> SetLinkColor(clr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.HasParam("BGCOLOR")) {
|
||||||
|
tag.ScanParam("BGCOLOR", "#%lX", &tmp);
|
||||||
|
clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF));
|
||||||
|
m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND));
|
||||||
|
if (m_WParser -> GetWindow() != NULL)
|
||||||
|
m_WParser -> GetWindow() -> SetBackgroundColour(clr);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(BODY)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
|
||||||
|
|
||||||
|
TAG_HANDLER_PROC(tag)
|
||||||
|
{
|
||||||
|
wxHtmlContainerCell *c;
|
||||||
|
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
c = m_WParser -> OpenContainer();
|
||||||
|
if (c -> GetAlignHor() == HTML_ALIGN_RIGHT)
|
||||||
|
c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_RIGHT);
|
||||||
|
else
|
||||||
|
c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT);
|
||||||
|
c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP);
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
ParseInner(tag);
|
||||||
|
c = m_WParser -> CloseContainer();
|
||||||
|
c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_BOTTOM);
|
||||||
|
m_WParser -> CloseContainer();
|
||||||
|
m_WParser -> OpenContainer();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAG_HANDLER_END(BLOCKQUOTE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TAGS_MODULE_BEGIN(Layout)
|
||||||
|
|
||||||
|
TAGS_MODULE_ADD(P)
|
||||||
|
TAGS_MODULE_ADD(BR)
|
||||||
|
TAGS_MODULE_ADD(CENTER)
|
||||||
|
TAGS_MODULE_ADD(DIV)
|
||||||
|
TAGS_MODULE_ADD(TITLE)
|
||||||
|
TAGS_MODULE_ADD(BODY)
|
||||||
|
TAGS_MODULE_ADD(BLOCKQUOTE)
|
||||||
|
|
||||||
|
TAGS_MODULE_END(Layout)
|
||||||
|
|
||||||
|
#endif
|