cleanup and reformatting to match indentation style of the rest of wx

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9931 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-04-29 17:57:59 +00:00
parent dad9554b4c
commit 9749497156
10 changed files with 893 additions and 902 deletions

View File

@@ -15,7 +15,7 @@
#include "wx/defs.h"
#ifdef __GNUG__
#pragma interface
#pragma interface "helpctrl.h"
#endif
#if wxUSE_HTML
@@ -27,7 +27,7 @@ class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHan
{
DECLARE_DYNAMIC_CLASS(wxHtmlHelpController)
public:
public:
wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
virtual ~wxHtmlHelpController();
@@ -91,7 +91,8 @@ class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHan
virtual void OnQuit() {};
void OnCloseFrame(wxCloseEvent& evt);
protected:
protected:
virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data);
virtual void CreateHelpWindow();

View File

@@ -13,7 +13,7 @@
#define _WX_HELPDATA_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "helpdata.h"
#endif
#include "wx/defs.h"
@@ -26,13 +26,15 @@
#include "wx/dynarray.h"
#include "wx/font.h"
class WXDLLEXPORT wxHtmlHelpData;
//--------------------------------------------------------------------------------
// helper classes & structs
//--------------------------------------------------------------------------------
class WXDLLEXPORT wxHtmlBookRecord : public wxObject
{
public:
public:
wxHtmlBookRecord(const wxString& basepath, const wxString& title,
const wxString& start)
{
@@ -58,7 +60,7 @@ class WXDLLEXPORT wxHtmlBookRecord : public wxObject
void SetBasePath(const wxString& path) { m_BasePath = path; }
void SetStart(const wxString& start) { m_Start = start; }
protected:
protected:
wxString m_BasePath;
wxString m_Title;
wxString m_Start;
@@ -70,41 +72,40 @@ class WXDLLEXPORT wxHtmlBookRecord : public wxObject
WX_DECLARE_EXPORTED_OBJARRAY(wxHtmlBookRecord, wxHtmlBookRecArray);
typedef struct
struct wxHtmlContentsItem
{
short int m_Level;
int m_ID;
wxChar* m_Name;
wxChar* m_Page;
wxHtmlBookRecord *m_Book;
}
wxHtmlContentsItem;
};
//------------------------------------------------------------------------------
// wxSearchEngine
// This class takes input streams and scans them for occurence
// of keyword(s)
//------------------------------------------------------------------------------
class WXDLLEXPORT wxSearchEngine : public wxObject
{
public:
public:
wxSearchEngine() : wxObject() {m_Keyword = NULL; }
~wxSearchEngine() {if (m_Keyword) delete[] m_Keyword; }
virtual void LookFor(const wxString& keyword, bool case_sensitive, bool whole_words_only);
// Sets the keyword we will be searching for
virtual void LookFor(const wxString& keyword, bool case_sensitive, bool whole_words_only);
virtual bool Scan(wxInputStream *stream);
// Scans the stream for the keyword.
// Returns TRUE if the stream contains keyword, fALSE otherwise
virtual bool Scan(wxInputStream *stream);
private:
private:
wxChar *m_Keyword;
bool m_CaseSensitive;
bool m_WholeWords;
};
class wxHtmlHelpData;
// State information of a search action. I'd have prefered to make this a nested
// class inside wxHtmlHelpData, but that's against coding standards :-(
@@ -112,10 +113,9 @@ class wxHtmlHelpData;
// wxHtmlHelpData::PrepareKeywordSearch(const wxString& key)
class WXDLLEXPORT wxHtmlSearchStatus
{
public:
public:
// constructor; supply wxHtmlHelpData ptr, the keyword and (optionally) the
// title of the book to search. By default, all books are searched.
wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword,
bool case_sensitive, bool whole_words_only,
const wxString& book = wxEmptyString);
@@ -126,7 +126,7 @@ class WXDLLEXPORT wxHtmlSearchStatus
const wxString& GetName() { return m_Name; }
wxHtmlContentsItem* GetContentsItem() { return m_ContentsItem; }
private:
private:
wxHtmlHelpData* m_Data;
wxSearchEngine m_Engine;
wxString m_Keyword, m_Name;
@@ -141,22 +141,21 @@ class WXDLLEXPORT wxHtmlSearchStatus
class WXDLLEXPORT wxHtmlHelpData : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxHtmlHelpData)
friend class wxHtmlSearchStatus;
public:
public:
wxHtmlHelpData();
~wxHtmlHelpData();
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.
void SetTempDir(const wxString& path);
bool AddBook(const wxString& book);
// Adds new book. 'book' is location of .htb file (stands for "html book").
// See documentation for details on its format.
// Returns success.
bool AddBook(const wxString& book);
bool AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
@@ -164,11 +163,12 @@ class WXDLLEXPORT wxHtmlHelpData : public wxObject
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString);
// Some accessing stuff
wxString FindPageByName(const wxString& page);
// Some accessing stuff:
// returns URL of page on basis of (file)name
wxString FindPageById(int id);
wxString FindPageByName(const wxString& page);
// returns URL of page on basis of MS id
wxString FindPageById(int id);
const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; }
wxHtmlContentsItem* GetContents() { return m_Contents; }
@@ -176,26 +176,24 @@ class WXDLLEXPORT wxHtmlHelpData : public wxObject
wxHtmlContentsItem* GetIndex() { return m_Index; }
int GetIndexCnt() { return m_IndexCnt; }
protected:
protected:
wxString m_TempPath;
wxHtmlBookRecArray m_BookRecords;
// each book has one record in this array
// each book has one record in this array:
wxHtmlContentsItem* m_Contents;
int m_ContentsCnt;
// list of all available books and pages.
wxHtmlContentsItem* m_Index;
int m_IndexCnt;
// list of index items
wxHtmlContentsItem* m_Index; // list of all available books and pages.
int m_IndexCnt; // list of index items
protected:
protected:
// Imports .hhp files (MS HTML Help Workshop)
bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
const wxString& indexfile, const wxString& contentsfile);
// Imports .hhp files (MS HTML Help Workshop)
bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f);
// Reads binary book
bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f);
bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f);
// Writes binary book
bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f);
};
// Utility function

View File

@@ -13,7 +13,7 @@
#define _WX_HELPFRM_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "helpfrm.h"
#endif
#include "wx/defs.h"
@@ -77,17 +77,15 @@ enum
wxID_HTML_SEARCHCHOICE,
wxID_HTML_COUNTINFO,
wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
}
;
};
typedef struct
struct wxHtmlHelpFrameCfg
{
int x, y, w, h;
long sashpos;
bool navig_on;
}
wxHtmlHelpFrameCfg;
};
class WXDLLEXPORT wxHelpControllerBase;
@@ -96,7 +94,7 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
{
DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
public:
public:
wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
const wxString& title = wxEmptyString,
@@ -109,11 +107,10 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
wxHelpControllerBase* GetController() const { return m_helpController; }
void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
void SetTitleFormat(const wxString& format);
// Sets format of title of the frame. Must contain exactly one "%s"
// (for title of displayed HTML page)
void SetTitleFormat(const wxString& format);
bool 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:
@@ -121,17 +118,18 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
// 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 ...")
bool Display(const int id);
bool Display(const wxString& x);
// Alternative version that works with numeric ID.
// (uses extension to MS format, <param name="ID" value=id>, see docs)
bool Display(const int id);
bool DisplayContents();
// Displays help window and focuses contents.
bool DisplayContents();
bool DisplayIndex();
// Displays help window and focuses index.
bool DisplayIndex();
bool KeywordSearch(const wxString& keyword);
// Searches for keyword. Returns TRUE and display page if found, return
// FALSE otherwise
// Syntax of keyword is Altavista-like:
@@ -140,6 +138,7 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
// * 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
bool KeywordSearch(const wxString& keyword);
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
{
@@ -148,36 +147,35 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
ReadCustomization(config, rootpath);
}
void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
// saves custom settings into cfg config. it will use the path 'path'
// 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 ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
// ...
void NotifyPageChanged();
// call this to let wxHtmlHelpFrame know page changed
void NotifyPageChanged();
protected:
protected:
void Init(wxHtmlHelpData* data = NULL);
void RefreshLists();
// Refreshes Contents and Index tabs
void RefreshLists();
void CreateContents();
// Adds items to m_Contents tree control
void CreateContents();
void CreateIndex();
// Adds items to m_IndexList
void CreateIndex();
void CreateSearch();
// Add books to search choice panel
void CreateSearch();
virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
// Add custom buttons to toolbar
virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
virtual void OptionsDialog();
// Displays options dialog (fonts etc.)
virtual void OptionsDialog();
void OnToolbar(wxCommandEvent& event);
void OnContentsSel(wxTreeEvent& event);
@@ -197,7 +195,7 @@ class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
IMG_RootFolder
};
protected:
protected:
wxHtmlHelpData* m_Data;
bool m_DataCreated; // m_Data created by frame, or supplied?
wxString m_TitleFormat; // title of the help frame

View File

@@ -13,7 +13,7 @@
#define _WX_HTMLCELL_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "htmlcell.h"
#endif
#include "wx/defs.h"
@@ -39,7 +39,7 @@ class WXDLLEXPORT wxHtmlContainerCell;
class WXDLLEXPORT wxHtmlCell : public wxObject
{
public:
public:
wxHtmlCell();
virtual ~wxHtmlCell();
@@ -51,33 +51,33 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
int GetWidth() const {return m_Width;}
int GetHeight() const {return m_Height;}
int GetDescent() const {return m_Descent;}
virtual wxHtmlLinkInfo* GetLink(int WXUNUSED(x) = 0,
int WXUNUSED(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 wxHtmlLinkInfo* GetLink(int WXUNUSED(x) = 0, int WXUNUSED(y) = 0) const
{ return m_Link; }
// members access methods
wxHtmlCell *GetNext() const {return m_Next;}
// members writin methods
virtual void SetPos(int x, int y) {m_PosX = x, m_PosY = y;}
void SetLink(const wxHtmlLinkInfo& link);
void SetNext(wxHtmlCell *cell) {m_Next = cell;}
// members writin methods
virtual void Layout(int 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 Layout(int w);
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
// renders the cell
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
virtual void DrawInvisible(wxDC& dc, int x, int 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 void DrawInvisible(wxDC& dc, int x, int y);
virtual const wxHtmlCell* Find(int condition, const void* param) const;
// This method returns pointer to the FIRST cell for that
// the condition
// is true. It first checks if the condition is true for this
@@ -88,16 +88,16 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
// and param is optional parameter
// Example : m_Cell->Find(wxHTML_COND_ISANCHOR, "news");
// returns pointer to anchor news
virtual const wxHtmlCell* Find(int condition, const void* param) const;
virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event);
// 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
virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event);
virtual bool AdjustPagebreak(int *pagebreak) const;
// This method used to adjust pagebreak position. The parameter is
// variable that contains y-coordinate of page break (= horizontal line that
// should not be crossed by words, images etc.). If this cell cannot be divided
@@ -106,13 +106,14 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
//
// Returned value : true if pagebreak was modified, false otherwise
// Usage : while (container->AdjustPagebreak(&p)) {}
virtual bool AdjustPagebreak(int *pagebreak) const;
void SetCanLiveOnPagebreak(bool can) {m_CanLiveOnPagebreak = can;}
// Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default
// is true - the cell can be split on two pages
void SetCanLiveOnPagebreak(bool can) {m_CanLiveOnPagebreak = can;}
protected:
protected:
wxHtmlCell *m_Next;
// pointer to the next cell
wxHtmlContainerCell *m_Parent;
@@ -126,7 +127,6 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
// destination address if this fragment is hypertext link, "" otherwise
bool m_CanLiveOnPagebreak;
// true if this cell can be placed on pagebreak, false otherwise
};
@@ -144,11 +144,11 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell
{
public:
public:
wxHtmlWordCell(const wxString& word, wxDC& dc);
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
protected:
protected:
wxString m_Word;
};
@@ -163,7 +163,7 @@ class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
{
public:
public:
wxHtmlContainerCell(wxHtmlContainerCell *parent);
~wxHtmlContainerCell();
@@ -172,39 +172,43 @@ class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
virtual void DrawInvisible(wxDC& dc, int x, int y);
virtual bool AdjustPagebreak(int *pagebreak) const;
void InsertCell(wxHtmlCell *cell);
// insert cell at the end of m_Cells list
void InsertCell(wxHtmlCell *cell);
// sets horizontal/vertical alignment
void SetAlignHor(int al) {m_AlignHor = al; m_LastLayout = -1;}
int GetAlignHor() const {return m_AlignHor;}
void SetAlignVer(int al) {m_AlignVer = al; m_LastLayout = -1;}
// sets horizontal/vertical alignment
int GetAlignVer() const {return m_AlignVer;}
void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
// sets left-border indentation. units is one of wxHTML_UNITS_* constants
// what is combination of wxHTML_INDENT_*
int GetIndent(int ind) const;
void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
// returns the indentation. ind is one of wxHTML_INDENT_* constants
int GetIndentUnits(int ind) const;
int GetIndent(int ind) const;
// returns type of value returned by GetIndent(ind)
void SetAlign(const wxHtmlTag& tag);
int GetIndentUnits(int ind) const;
// sets alignment info based on given tag's params
void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units; m_LastLayout = -1;}
void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0);
void SetAlign(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 = wxHTML_ALIGN_TOP) {m_MinHeight = h; m_MinHeightAlign = align; m_LastLayout = -1;}
void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units; m_LastLayout = -1;}
void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0);
// sets minimal height of this container.
void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP) {m_MinHeight = h; m_MinHeightAlign = align; m_LastLayout = -1;}
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 wxHtmlLinkInfo* 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, const wxMouseEvent& event);
wxHtmlCell* GetFirstCell() const {return m_Cells;}
// returns pointer to the first cell in container or NULL
wxHtmlCell* GetFirstCell() const {return m_Cells;}
protected:
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
@@ -240,12 +244,12 @@ class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlColourCell : public wxHtmlCell
{
public:
public:
wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_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);
protected:
protected:
wxColour m_Colour;
unsigned m_Flags;
};
@@ -260,12 +264,12 @@ class WXDLLEXPORT wxHtmlColourCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell
{
public:
public:
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);
protected:
protected:
wxFont m_Font;
};
@@ -283,18 +287,18 @@ class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell
{
public:
wxHtmlWidgetCell(wxWindow *wnd, int w = 0);
public:
// !!! 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)
wxHtmlWidgetCell(wxWindow *wnd, int w = 0);
~wxHtmlWidgetCell() { m_Wnd->Destroy(); }
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);
protected:
protected:
wxWindow* m_Wnd;
int m_WidthFloat;
// width float is used in adjustWidth (it is in percents)
@@ -309,15 +313,17 @@ class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlLinkInfo : public wxObject
{
public:
public:
wxHtmlLinkInfo() : wxObject()
{ m_Href = m_Target = wxEmptyString; m_Event = NULL, m_Cell = NULL; }
wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString) : wxObject()
{ m_Href = href; m_Target = target; m_Event = NULL, m_Cell = NULL; }
wxHtmlLinkInfo(const wxHtmlLinkInfo& l) : wxObject()
{ m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event, m_Cell = l.m_Cell; }
{ m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event;
m_Cell = l.m_Cell; }
wxHtmlLinkInfo& operator=(const wxHtmlLinkInfo& l)
{ m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event, m_Cell = l.m_Cell; return *this; }
{ m_Href = l.m_Href, m_Target = l.m_Target, m_Event = l.m_Event;
m_Cell = l.m_Cell; return *this; }
void SetEvent(const wxMouseEvent *e) { m_Event = e; }
void SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; }
@@ -327,7 +333,7 @@ class WXDLLEXPORT wxHtmlLinkInfo : public wxObject
const wxMouseEvent* GetEvent() const { return m_Event; }
const wxHtmlCell* GetHtmlCell() const { return m_Cell; }
private:
private:
wxString m_Href, m_Target;
const wxMouseEvent *m_Event;
const wxHtmlCell *m_Cell;

View File

@@ -12,7 +12,7 @@
#define _WX_HTMLPARS_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "htmlpars.h"
#endif
#include "wx/defs.h"

View File

@@ -12,56 +12,38 @@
#define _WX_HTMLTAG_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "htmltag.h"
#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 </...>
wxChar *Name;
// name of this tag
} sCacheItem;
// - internal wxHTML class, do not use!
//-----------------------------------------------------------------------------
struct wxHtmlCacheItem;
class wxHtmlTagsCache : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
private:
sCacheItem *m_Cache;
private:
wxHtmlCacheItem *m_Cache;
int m_CacheSize;
int m_CachePos;
public:
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
void QueryTag(int at, int* end1, int* end2);
};
//--------------------------------------------------------------------------------
// wxHtmlTag
// This represents single tag. It is used as internal structure
@@ -72,28 +54,27 @@ class WXDLLEXPORT wxHtmlTag : public wxObject
{
DECLARE_CLASS(wxHtmlTag)
public:
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
public:
// 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)
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
inline wxString GetName() const {return m_Name;}
// Returns tag's name in uppercase.
inline wxString GetName() const {return m_Name;}
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
bool HasParam(const wxString& par) const;
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)
wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
int ScanParam(const wxString& par, wxChar *format, void *param) const;
// Scans param like scanf() functions family do.
// Example : ScanParam("COLOR", "\"#%X\"", &clr);
// This is always with with_commas=FALSE
@@ -101,34 +82,34 @@ class WXDLLEXPORT wxHtmlTag : public wxObject
// (like sscanf() does)
// NOTE: unlike scanf family, this function only accepts
// *one* parameter !
int ScanParam(const wxString& par, wxChar *format, void *param) const;
inline const wxString& GetAllParams() const {return m_Params;}
// Returns string containing all params.
inline const wxString& GetAllParams() const {return m_Params;}
// return TRUE if this is ending tag (</something>) or FALSE
// if it isn't (<something>)
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;}
inline int GetBeginPos() const {return m_Begin;}
// 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;}
inline int GetEndPos1() const {return m_End1;}
// returns end position 2 :
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
inline int GetEndPos2() const {return m_End2;}
private:
private:
wxString m_Name, m_Params;
int m_Begin, m_End1, m_End2;
bool m_Ending;
};

View File

@@ -12,7 +12,7 @@
#define _WX_HTMLWIN_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "htmlwin.h"
#endif
#include "wx/defs.h"
@@ -43,14 +43,14 @@
// item of history list
class WXDLLEXPORT HtmlHistoryItem : public wxObject
{
public:
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;}
private:
private:
wxString m_Page;
wxString m_Anchor;
int m_Pos;
@@ -64,24 +64,23 @@ class wxHtmlWinModule;
class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
{
DECLARE_DYNAMIC_CLASS(wxHtmlWindow)
friend class wxHtmlWinModule;
public:
public:
wxHtmlWindow() : wxScrolledWindow() {};
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHW_SCROLLBAR_AUTO,
const wxString& name = "htmlWindow");
~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 SetPage(const wxString& source);
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
@@ -91,88 +90,88 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
// 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
bool LoadPage(const wxString& location);
wxString GetOpenedPage() const {return m_OpenedPage;}
// Returns full location of opened page
wxString GetOpenedAnchor() const {return m_OpenedAnchor;}
wxString GetOpenedPage() const {return m_OpenedPage;}
// Returns anchor within opened page
wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;}
wxString GetOpenedAnchor() const {return m_OpenedAnchor;}
// Returns <TITLE> of opened page or empty string otherwise
wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;}
void SetRelatedFrame(wxFrame* frame, const wxString& format);
// sets frame in which page title will be displayed. Format is format of
// 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
void SetRelatedFrame(wxFrame* frame, const wxString& format);
wxFrame* GetRelatedFrame() const {return m_RelatedFrame;}
void SetRelatedStatusBar(int bar);
// after(!) calling SetRelatedFrame, this sets statusbar slot where messages
// After(!) calling SetRelatedFrame, this sets statusbar slot where messages
// will be displayed. Default is -1 = no messages.
void SetRelatedStatusBar(int bar);
// Sets fonts to be used when displaying HTML page.
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
// sets fonts to be used when displaying HTML page.
virtual void OnSetTitle(const wxString& title);
// Sets the title of the window
// (depending on the information passed to SetRelatedFrame() method)
virtual void OnSetTitle(const wxString& title);
void SetBorders(int b) {m_Borders = b;}
// Sets space between text and window borders.
void SetBorders(int b) {m_Borders = b;}
virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
// saves custom settings into cfg config. it will use the path 'path'
// 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);
virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
// ...
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
bool HistoryBack();
bool HistoryForward();
bool HistoryCanBack();
bool HistoryCanForward();
void HistoryClear();
// Resets history
void HistoryClear();
wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;}
// Returns pointer to conteiners/cells structure.
// It should be used ONLY when printing
wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;}
static void AddFilter(wxHtmlFilter *filter);
// Adds input filter
static void AddFilter(wxHtmlFilter *filter);
virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
// called when users clicked on hypertext link. Default behavior is to
// Called when users clicked on hypertext link. Default behavior is to
// call LoadPage(loc)
virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
// Returns a pointer to the parser.
wxHtmlWinParser *GetParser() const { return m_Parser; }
// return a pointer to the parser.
protected:
bool ScrollToAnchor(const wxString& anchor);
protected:
// 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
bool ScrollToAnchor(const wxString& anchor);
// Prepares layout (= fill m_PosX, m_PosY for fragments) based on
// actual size of window. This method also setup scrollbars
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);
// Returns new filter (will be stored into m_DefaultFilter variable)
virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;}
// returns new filter (will be stored into m_DefaultFilter variable)
static void CleanUpStatics();
// cleans static variables
protected:
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)
@@ -201,7 +200,7 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
int m_Style;
private:
private:
bool m_tmpMouseMoved;
// a flag indicated if mouse moved
// (if TRUE we will try to change cursor in last call to OnIdle)

View File

@@ -12,7 +12,7 @@
#define _WX_HTMPRINT_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "htmprint.h"
#endif
#include <wx/defs.h>
@@ -33,25 +33,26 @@
class WXDLLEXPORT wxHtmlDCRenderer : public wxObject
{
public:
public:
wxHtmlDCRenderer();
~wxHtmlDCRenderer();
// Following 3 methods *must* be called before any call to Render:
// Asign DC to this render
void SetDC(wxDC *dc, double pixel_scale = 1.0);
// asign DC to this render
void SetSize(int width, int height);
// sets size of output rectangle, in pixels. Note that you *can't* change
// Sets size of output rectangle, in pixels. Note that you *can't* change
// width of the rectangle between calls to Render! (You can freely change height.)
void SetHtmlText(const wxString& html, const wxString& basepath = wxEmptyString, bool isdir = TRUE);
// sets the text to be displayed
//
// basepath is base directory (html string would be stored there if it was in
void SetSize(int width, int height);
// Sets the text to be displayed.
// Basepath is base directory (html string would be stored there if it was in
// file). It is used to determine path for loading images, for example.
// isdir is FALSE if basepath is filename, TRUE if it is directory name
// (see wxFileSystem for detailed explanation)
void SetHtmlText(const wxString& html, const wxString& basepath = wxEmptyString, bool isdir = TRUE);
int Render(int x, int y, int from = 0, int dont_render = FALSE);
// [x,y] is position of upper-left corner of printing rectangle (see SetSize)
// from is y-coordinate of the very first visible cell
// Returned value is y coordinate of first cell than didn't fit onto page.
@@ -61,13 +62,13 @@ class WXDLLEXPORT wxHtmlDCRenderer : public wxObject
// pixels and return y coord of the next page
//
// CAUTION! Render() changes DC's user scale and does NOT restore it!
int Render(int x, int y, int from = 0, int dont_render = FALSE);
int GetTotalHeight();
// returns total height of the html document
// (compare Render's return value with this)
int GetTotalHeight();
private:
private:
wxDC *m_DC;
wxHtmlWinParser *m_Parser;
wxFileSystem *m_FS;

View File

@@ -27,7 +27,7 @@ I STRONGLY recommend reading and understanding these macros!!
#ifdef __GNUG__
#pragma interface
#pragma interface "m_templ.h"
#pragma implementation
#endif

View File

@@ -12,7 +12,7 @@
#define _WX_WINPARS_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "winpars.h"
#endif
#include "wx/defs.h"
@@ -24,9 +24,9 @@
#include "wx/html/htmlcell.h"
#include "wx/encconv.h"
class wxHtmlWinParser;
class wxHtmlWinTagHandler;
class wxHtmlTagsModule;
class WXDLLEXPORT wxHtmlWinParser;
class WXDLLEXPORT wxHtmlWinTagHandler;
class WXDLLEXPORT wxHtmlTagsModule;
//--------------------------------------------------------------------------------
// wxHtmlWinParser
@@ -39,7 +39,7 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
{
friend class wxHtmlWindow;
public:
public:
wxHtmlWinParser(wxWindow *wnd = NULL);
~wxHtmlWinParser();
@@ -47,41 +47,50 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
virtual void DoneParser();
virtual wxObject* GetProduct();
virtual void SetDC(wxDC *dc, double pixel_scale = 1.0) {m_DC = dc; m_PixelScale = pixel_scale;}
// Set's the DC used for parsing. If SetDC() is not called,
// parsing won't proceed
virtual void SetDC(wxDC *dc, double pixel_scale = 1.0)
{ m_DC = dc; m_PixelScale = pixel_scale; }
wxDC *GetDC() {return m_DC;}
double GetPixelScale() {return m_PixelScale;}
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
wxWindow *GetWindow() {return m_Window;}
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
// sets fonts to be used when displaying HTML page.
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
static void AddModule(wxHtmlTagsModule *module);
// Adds tags module. see wxHtmlTagsModule for details.
static void AddModule(wxHtmlTagsModule *module);
static void RemoveModule(wxHtmlTagsModule *module);
// 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();
wxHtmlContainerCell *GetContainer() const {return m_Container;}
// opens new container. This container is sub-container of opened
// container. Sets GetContainer to newly created container
// and returns it.
wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
wxHtmlContainerCell *OpenContainer();
// 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();
wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
// closes the container and sets actual Container to upper-level
// container
wxHtmlContainerCell *CloseContainer();
int GetFontSize() const {return m_FontSize;}
void SetFontSize(int s);
@@ -110,13 +119,13 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; }
wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; }
virtual wxFont* CreateCurrentFont();
// creates font depending on m_Font* members.
virtual wxFont* CreateCurrentFont();
protected:
protected:
virtual void AddText(const char *txt);
private:
private:
bool m_tmpLastWasSpace;
// temporary variable used by AddText
wxWindow *m_Window;
@@ -179,14 +188,13 @@ class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler
{
DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler)
public:
public:
wxHtmlWinTagHandler() : wxHtmlTagHandler() {};
virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;};
protected:
wxHtmlWinParser *m_WParser;
// same as m_Parser, but overcasted
protected:
wxHtmlWinParser *m_WParser; // same as m_Parser, but overcasted
};
@@ -206,17 +214,16 @@ class WXDLLEXPORT wxHtmlTagsModule : public wxModule
{
DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule)
public:
public:
wxHtmlTagsModule() : wxModule() {};
virtual bool OnInit();
virtual void OnExit();
virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { }
// This is called by wxHtmlWinParser.
// The method must simply call parser->AddTagHandler(new <handler_class_name>);
// for each handler
virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { }
};