*** empty log message ***
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2963 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
59
include/wx/html/forcelink.h
Normal file
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
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
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
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
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
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
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
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
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
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
BIN
include/wx/html/msw/back.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 202 B |
BIN
include/wx/html/msw/book.ico
Normal file
BIN
include/wx/html/msw/book.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/folder.ico
Normal file
BIN
include/wx/html/msw/folder.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/forward.bmp
Normal file
BIN
include/wx/html/msw/forward.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 202 B |
BIN
include/wx/html/msw/page.ico
Normal file
BIN
include/wx/html/msw/page.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 318 B |
BIN
include/wx/html/msw/panel.bmp
Normal file
BIN
include/wx/html/msw/panel.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 710 B |
16
include/wx/html/msw/wxhtml.rc
Normal file
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
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)
|
||||
|
Reference in New Issue
Block a user