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" #include "wx/defs.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "helpctrl.h"
#endif #endif
#if wxUSE_HTML #if wxUSE_HTML
@@ -25,85 +25,86 @@
class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHandler class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHandler
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlHelpController) DECLARE_DYNAMIC_CLASS(wxHtmlHelpController)
public: public:
wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE); wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE);
virtual ~wxHtmlHelpController(); virtual ~wxHtmlHelpController();
void SetTitleFormat(const wxString& format); void SetTitleFormat(const wxString& format);
void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); } void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); }
bool AddBook(const wxString& book, bool show_wait_msg = FALSE); bool AddBook(const wxString& book, bool show_wait_msg = FALSE);
bool Display(const wxString& x) bool Display(const wxString& x)
{ {
CreateHelpWindow(); return m_helpFrame->Display(x); CreateHelpWindow(); return m_helpFrame->Display(x);
} }
bool Display(int id) bool Display(int id)
{ {
CreateHelpWindow(); return m_helpFrame->Display(id); CreateHelpWindow(); return m_helpFrame->Display(id);
} }
bool DisplayContents() bool DisplayContents()
{ {
CreateHelpWindow(); return m_helpFrame->DisplayContents(); CreateHelpWindow(); return m_helpFrame->DisplayContents();
} }
bool DisplayIndex() bool DisplayIndex()
{ {
CreateHelpWindow(); return m_helpFrame->DisplayIndex(); CreateHelpWindow(); return m_helpFrame->DisplayIndex();
} }
bool KeywordSearch(const wxString& keyword) bool KeywordSearch(const wxString& keyword)
{ {
CreateHelpWindow(); return m_helpFrame->KeywordSearch(keyword); CreateHelpWindow(); return m_helpFrame->KeywordSearch(keyword);
} }
wxHtmlHelpFrame* GetFrame() { return m_helpFrame; } wxHtmlHelpFrame* GetFrame() { return m_helpFrame; }
void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString); void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString);
// Assigns config object to the Ctrl. This config is then
// used in subsequent calls to Read/WriteCustomization of both help
// Ctrl and it's wxHtmlWindow
virtual void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
virtual void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
//// Backward compatibility with wxHelpController API // Assigns config object to the Ctrl. This config is then
// used in subsequent calls to Read/WriteCustomization of both help
// Ctrl and it's wxHtmlWindow
virtual void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
virtual void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString);
virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize(file); } //// Backward compatibility with wxHelpController API
virtual bool Initialize(const wxString& file);
virtual void SetViewer(const wxString& WXUNUSED(viewer), long WXUNUSED(flags) = 0) {}
virtual bool LoadFile(const wxString& file = "");
virtual bool DisplaySection(int sectionNo);
virtual bool DisplaySection(const wxString& section) { return Display(section); }
virtual bool DisplayBlock(long blockNo) { return DisplaySection(blockNo); }
virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
virtual void SetFrameParameters(const wxString& title, virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize(file); }
const wxSize& size, virtual bool Initialize(const wxString& file);
const wxPoint& pos = wxDefaultPosition, virtual void SetViewer(const wxString& WXUNUSED(viewer), long WXUNUSED(flags) = 0) {}
bool newFrameEachTime = FALSE); virtual bool LoadFile(const wxString& file = "");
/// Obtains the latest settings used by the help frame and the help virtual bool DisplaySection(int sectionNo);
/// frame. virtual bool DisplaySection(const wxString& section) { return Display(section); }
virtual wxFrame *GetFrameParameters(wxSize *size = NULL, virtual bool DisplayBlock(long blockNo) { return DisplaySection(blockNo); }
wxPoint *pos = NULL, virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos);
bool *newFrameEachTime = NULL);
// Sets the specified book or all books to have the given base path virtual void SetFrameParameters(const wxString& title,
virtual void SetBookBasePath(const wxString& basePath, int which = -1); const wxSize& size,
const wxPoint& pos = wxDefaultPosition,
bool newFrameEachTime = FALSE);
/// Obtains the latest settings used by the help frame and the help
/// frame.
virtual wxFrame *GetFrameParameters(wxSize *size = NULL,
wxPoint *pos = NULL,
bool *newFrameEachTime = NULL);
virtual bool Quit() ; // Sets the specified book or all books to have the given base path
virtual void OnQuit() {}; virtual void SetBookBasePath(const wxString& basePath, int which = -1);
void OnCloseFrame(wxCloseEvent& evt); virtual bool Quit() ;
protected: virtual void OnQuit() {};
virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data);
virtual void CreateHelpWindow();
virtual void DestroyHelpWindow();
wxHtmlHelpData m_helpData; void OnCloseFrame(wxCloseEvent& evt);
wxHtmlHelpFrame* m_helpFrame;
wxConfigBase * m_Config; protected:
wxString m_ConfigRoot; virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data);
wxString m_titleFormat;
int m_FrameStyle; virtual void CreateHelpWindow();
// DECLARE_EVENT_TABLE() virtual void DestroyHelpWindow();
wxHtmlHelpData m_helpData;
wxHtmlHelpFrame* m_helpFrame;
wxConfigBase * m_Config;
wxString m_ConfigRoot;
wxString m_titleFormat;
int m_FrameStyle;
// DECLARE_EVENT_TABLE()
}; };
#endif #endif

View File

@@ -13,7 +13,7 @@
#define _WX_HELPDATA_H_ #define _WX_HELPDATA_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "helpdata.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -26,85 +26,86 @@
#include "wx/dynarray.h" #include "wx/dynarray.h"
#include "wx/font.h" #include "wx/font.h"
class WXDLLEXPORT wxHtmlHelpData;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// helper classes & structs // helper classes & structs
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
class WXDLLEXPORT wxHtmlBookRecord : public wxObject class WXDLLEXPORT wxHtmlBookRecord : public wxObject
{ {
public: public:
wxHtmlBookRecord(const wxString& basepath, const wxString& title, wxHtmlBookRecord(const wxString& basepath, const wxString& title,
const wxString& start) const wxString& start)
{ {
m_BasePath = basepath; m_BasePath = basepath;
m_Title = title; m_Title = title;
m_Start = start; m_Start = start;
// for debugging, give the contents index obvious default values // for debugging, give the contents index obvious default values
m_ContentsStart = m_ContentsEnd = -1; m_ContentsStart = m_ContentsEnd = -1;
} }
wxString GetTitle() const { return m_Title; } wxString GetTitle() const { return m_Title; }
wxString GetStart() const { return m_Start; } wxString GetStart() const { return m_Start; }
wxString GetBasePath() const { return m_BasePath; } wxString GetBasePath() const { return m_BasePath; }
/* SetContentsRange: store in the bookrecord where in the index/contents lists the /* SetContentsRange: store in the bookrecord where in the index/contents lists the
* book's records are stored. This to facilitate searching in a specific book. * book's records are stored. This to facilitate searching in a specific book.
* This code will have to be revised when loading/removing books becomes dynamic. * This code will have to be revised when loading/removing books becomes dynamic.
* (as opposed to appending only) * (as opposed to appending only)
* Note that storing index range is pointless, because the index is alphab. sorted. */ * Note that storing index range is pointless, because the index is alphab. sorted. */
void SetContentsRange(int start, int end) { m_ContentsStart = start; m_ContentsEnd = end; } void SetContentsRange(int start, int end) { m_ContentsStart = start; m_ContentsEnd = end; }
int GetContentsStart() const { return m_ContentsStart; } int GetContentsStart() const { return m_ContentsStart; }
int GetContentsEnd() const { return m_ContentsEnd; } int GetContentsEnd() const { return m_ContentsEnd; }
void SetTitle(const wxString& title) { m_Title = title; } void SetTitle(const wxString& title) { m_Title = title; }
void SetBasePath(const wxString& path) { m_BasePath = path; } void SetBasePath(const wxString& path) { m_BasePath = path; }
void SetStart(const wxString& start) { m_Start = start; } void SetStart(const wxString& start) { m_Start = start; }
protected: protected:
wxString m_BasePath; wxString m_BasePath;
wxString m_Title; wxString m_Title;
wxString m_Start; wxString m_Start;
int m_ContentsStart; int m_ContentsStart;
int m_ContentsEnd; int m_ContentsEnd;
}; };
WX_DECLARE_EXPORTED_OBJARRAY(wxHtmlBookRecord, wxHtmlBookRecArray); WX_DECLARE_EXPORTED_OBJARRAY(wxHtmlBookRecord, wxHtmlBookRecArray);
typedef struct struct wxHtmlContentsItem
{ {
short int m_Level; short int m_Level;
int m_ID; int m_ID;
wxChar* m_Name; wxChar* m_Name;
wxChar* m_Page; wxChar* m_Page;
wxHtmlBookRecord *m_Book; wxHtmlBookRecord *m_Book;
} };
wxHtmlContentsItem;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// wxSearchEngine // wxSearchEngine
// This class takes input streams and scans them for occurence // This class takes input streams and scans them for occurence
// of keyword(s) // of keyword(s)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
class WXDLLEXPORT wxSearchEngine : public wxObject class WXDLLEXPORT wxSearchEngine : public wxObject
{ {
public: public:
wxSearchEngine() : wxObject() {m_Keyword = NULL; } wxSearchEngine() : wxObject() {m_Keyword = NULL; }
~wxSearchEngine() {if (m_Keyword) delete[] m_Keyword; } ~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
// 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.
// Scans the stream for the keyword. // Returns TRUE if the stream contains keyword, fALSE otherwise
// Returns TRUE if the stream contains keyword, fALSE otherwise virtual bool Scan(wxInputStream *stream);
private: private:
wxChar *m_Keyword; wxChar *m_Keyword;
bool m_CaseSensitive; bool m_CaseSensitive;
bool m_WholeWords; bool m_WholeWords;
}; };
class wxHtmlHelpData;
// State information of a search action. I'd have prefered to make this a nested // State information of a search action. I'd have prefered to make this a nested
// class inside wxHtmlHelpData, but that's against coding standards :-( // class inside wxHtmlHelpData, but that's against coding standards :-(
@@ -112,90 +113,87 @@ class wxHtmlHelpData;
// wxHtmlHelpData::PrepareKeywordSearch(const wxString& key) // wxHtmlHelpData::PrepareKeywordSearch(const wxString& key)
class WXDLLEXPORT wxHtmlSearchStatus class WXDLLEXPORT wxHtmlSearchStatus
{ {
public: public:
// constructor; supply wxHtmlHelpData ptr, the keyword and (optionally) the // constructor; supply wxHtmlHelpData ptr, the keyword and (optionally) the
// title of the book to search. By default, all books are searched. // 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);
bool Search(); // do the next iteration
bool IsActive() { return m_Active; }
int GetCurIndex() { return m_CurIndex; }
int GetMaxIndex() { return m_MaxIndex; }
const wxString& GetName() { return m_Name; }
wxHtmlContentsItem* GetContentsItem() { return m_ContentsItem; }
wxHtmlSearchStatus(wxHtmlHelpData* base, const wxString& keyword, private:
bool case_sensitive, bool whole_words_only, wxHtmlHelpData* m_Data;
const wxString& book = wxEmptyString); wxSearchEngine m_Engine;
bool Search(); // do the next iteration wxString m_Keyword, m_Name;
bool IsActive() { return m_Active; } wxChar *m_LastPage;
int GetCurIndex() { return m_CurIndex; } wxHtmlContentsItem* m_ContentsItem;
int GetMaxIndex() { return m_MaxIndex; } bool m_Active; // search is not finished
const wxString& GetName() { return m_Name; } int m_CurIndex; // where we are now
wxHtmlContentsItem* GetContentsItem() { return m_ContentsItem; } int m_MaxIndex; // number of files we search
// For progress bar: 100*curindex/maxindex = % complete
private:
wxHtmlHelpData* m_Data;
wxSearchEngine m_Engine;
wxString m_Keyword, m_Name;
wxChar *m_LastPage;
wxHtmlContentsItem* m_ContentsItem;
bool m_Active; // search is not finished
int m_CurIndex; // where we are now
int m_MaxIndex; // number of files we search
// For progress bar: 100*curindex/maxindex = % complete
}; };
class WXDLLEXPORT wxHtmlHelpData : public wxObject class WXDLLEXPORT wxHtmlHelpData : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlHelpData) DECLARE_DYNAMIC_CLASS(wxHtmlHelpData)
friend class wxHtmlSearchStatus;
friend class wxHtmlSearchStatus; public:
wxHtmlHelpData();
~wxHtmlHelpData();
public: // Sets directory where temporary files are stored.
wxHtmlHelpData(); // These temp files are index & contents file in binary (much faster to read)
~wxHtmlHelpData(); // form. These files are NOT deleted on program's exit.
void SetTempDir(const wxString& path);
void SetTempDir(const wxString& path); // Adds new book. 'book' is location of .htb file (stands for "html book").
// Sets directory where temporary files are stored. // See documentation for details on its format.
// These temp files are index & contents file in binary (much faster to read) // Returns success.
// form. These files are NOT deleted on program's exit. bool AddBook(const wxString& book);
bool AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
const wxString& indexfile = wxEmptyString,
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString);
bool AddBook(const wxString& book); // Some accessing stuff:
// Adds new book. 'book' is location of .htb file (stands for "html book").
// See documentation for details on its format.
// Returns success.
bool AddBookParam(const wxFSFile& bookfile,
wxFontEncoding encoding,
const wxString& title, const wxString& contfile,
const wxString& indexfile = wxEmptyString,
const wxString& deftopic = wxEmptyString,
const wxString& path = wxEmptyString);
// Some accessing stuff // returns URL of page on basis of (file)name
wxString FindPageByName(const wxString& page); wxString FindPageByName(const wxString& page);
// returns URL of page on basis of (file)name // returns URL of page on basis of MS id
wxString FindPageById(int id); wxString FindPageById(int id);
// returns URL of page on basis of MS id
const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; } const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; }
wxHtmlContentsItem* GetContents() { return m_Contents; } wxHtmlContentsItem* GetContents() { return m_Contents; }
int GetContentsCnt() { return m_ContentsCnt; } int GetContentsCnt() { return m_ContentsCnt; }
wxHtmlContentsItem* GetIndex() { return m_Index; } wxHtmlContentsItem* GetIndex() { return m_Index; }
int GetIndexCnt() { return m_IndexCnt; } int GetIndexCnt() { return m_IndexCnt; }
protected: protected:
wxString m_TempPath; wxString m_TempPath;
wxHtmlBookRecArray m_BookRecords; wxHtmlBookRecArray m_BookRecords;
// each book has one record in this array // each book has one record in this array:
wxHtmlContentsItem* m_Contents; wxHtmlContentsItem* m_Contents;
int m_ContentsCnt; int m_ContentsCnt;
// list of all available books and pages. wxHtmlContentsItem* m_Index; // list of all available books and pages.
wxHtmlContentsItem* m_Index; int m_IndexCnt; // list of index items
int m_IndexCnt;
// list of index items
protected: protected:
bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, // Imports .hhp files (MS HTML Help Workshop)
const wxString& indexfile, const wxString& contentsfile); bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys,
// Imports .hhp files (MS HTML Help Workshop) const wxString& indexfile, const wxString& contentsfile);
bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f); // Reads binary book
// Reads binary book bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f);
bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f); // Writes binary book
// Writes binary book bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f);
}; };
// Utility function // Utility function

View File

@@ -13,7 +13,7 @@
#define _WX_HELPFRM_H_ #define _WX_HELPFRM_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "helpfrm.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -77,174 +77,172 @@ enum
wxID_HTML_SEARCHCHOICE, wxID_HTML_SEARCHCHOICE,
wxID_HTML_COUNTINFO, wxID_HTML_COUNTINFO,
wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe wxID_HTML_HELPFRAME // the id of wxHtmlHelpController's helpframe
} };
;
typedef struct struct wxHtmlHelpFrameCfg
{ {
int x, y, w, h; int x, y, w, h;
long sashpos; long sashpos;
bool navig_on; bool navig_on;
} };
wxHtmlHelpFrameCfg;
class WXDLLEXPORT wxHelpControllerBase; class WXDLLEXPORT wxHelpControllerBase;
class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame) DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame)
public: public:
wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); } wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); }
wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID, wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID,
const wxString& title = wxEmptyString, const wxString& title = wxEmptyString,
int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL);
bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString, bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString,
int style = wxHF_DEFAULTSTYLE); int style = wxHF_DEFAULTSTYLE);
~wxHtmlHelpFrame(); ~wxHtmlHelpFrame();
wxHtmlHelpData* GetData() { return m_Data; } wxHtmlHelpData* GetData() { return m_Data; }
wxHelpControllerBase* GetController() const { return m_helpController; } wxHelpControllerBase* GetController() const { return m_helpController; }
void SetController(wxHelpControllerBase* controller) { m_helpController = controller; } void SetController(wxHelpControllerBase* controller) { m_helpController = controller; }
void SetTitleFormat(const wxString& format); // Sets format of title of the frame. Must contain exactly one "%s"
// Sets format of title of the frame. Must contain exactly one "%s" // (for title of displayed HTML page)
// (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
// Displays page x. If not found it will offect the user a choice of // searching books.
// searching books. // Looking for the page runs in these steps:
// Looking for the page runs in these steps: // 1. try to locate file named x (if x is for example "doc/howto.htm")
// 1. try to locate file named x (if x is for example "doc/howto.htm") // 2. try to open starting page of book x
// 2. try to open starting page of book x // 3. try to find x in contents (if x is for example "How To ...")
// 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 ...")
// 4. try to find x in index (if x is for example "How To ...") bool Display(const wxString& x);
bool Display(const int id);
// Alternative version that works with numeric ID.
// (uses extension to MS format, <param name="ID" value=id>, see docs)
bool DisplayContents(); // Alternative version that works with numeric ID.
// Displays help window and focuses contents. // (uses extension to MS format, <param name="ID" value=id>, see docs)
bool Display(const int id);
bool DisplayIndex(); // Displays help window and focuses contents.
// Displays help window and focuses index. bool DisplayContents();
bool KeywordSearch(const wxString& keyword); // Displays help window and focuses index.
// Searches for keyword. Returns TRUE and display page if found, return bool DisplayIndex();
// 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) // Searches for keyword. Returns TRUE and display page if found, return
{ // FALSE otherwise
m_Config = config; // Syntax of keyword is Altavista-like:
m_ConfigRoot = rootpath; // * words are separated by spaces
ReadCustomization(config, rootpath); // (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
bool KeywordSearch(const wxString& keyword);
void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString)
// saves custom settings into cfg config. it will use the path 'path' {
// if given, otherwise it will save info into currently selected path. m_Config = config;
// saved values : things set by SetFonts, SetBorders. m_ConfigRoot = rootpath;
void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); ReadCustomization(config, rootpath);
// ... }
void NotifyPageChanged();
// call this to let wxHtmlHelpFrame know page changed
protected: // Saves custom settings into cfg config. it will use the path 'path'
void Init(wxHtmlHelpData* data = NULL); // 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 RefreshLists(); // call this to let wxHtmlHelpFrame know page changed
// Refreshes Contents and Index tabs void NotifyPageChanged();
void CreateContents(); protected:
// Adds items to m_Contents tree control void Init(wxHtmlHelpData* data = NULL);
void CreateIndex(); // Refreshes Contents and Index tabs
// Adds items to m_IndexList void RefreshLists();
void CreateSearch(); // Adds items to m_Contents tree control
// Add books to search choice panel void CreateContents();
virtual void AddToolbarButtons(wxToolBar *toolBar, int style); // Adds items to m_IndexList
// Add custom buttons to toolbar void CreateIndex();
virtual void OptionsDialog(); // Add books to search choice panel
// Displays options dialog (fonts etc.) void CreateSearch();
void OnToolbar(wxCommandEvent& event); // Add custom buttons to toolbar
void OnContentsSel(wxTreeEvent& event); virtual void AddToolbarButtons(wxToolBar *toolBar, int style);
void OnIndexSel(wxCommandEvent& event);
void OnIndexFind(wxCommandEvent& event);
void OnIndexAll(wxCommandEvent& event);
void OnSearchSel(wxCommandEvent& event);
void OnSearch(wxCommandEvent& event);
void OnBookmarksSel(wxCommandEvent& event);
void OnCloseWindow(wxCloseEvent& event);
// Images: // Displays options dialog (fonts etc.)
enum { virtual void OptionsDialog();
IMG_Book = 0,
IMG_Folder,
IMG_Page,
IMG_RootFolder
};
protected: void OnToolbar(wxCommandEvent& event);
wxHtmlHelpData* m_Data; void OnContentsSel(wxTreeEvent& event);
bool m_DataCreated; // m_Data created by frame, or supplied? void OnIndexSel(wxCommandEvent& event);
wxString m_TitleFormat; // title of the help frame void OnIndexFind(wxCommandEvent& event);
// below are various pointers to GUI components void OnIndexAll(wxCommandEvent& event);
wxHtmlWindow *m_HtmlWin; void OnSearchSel(wxCommandEvent& event);
wxSplitterWindow *m_Splitter; void OnSearch(wxCommandEvent& event);
wxNotebook *m_NavigPan; void OnBookmarksSel(wxCommandEvent& event);
wxTreeCtrl *m_ContentsBox; void OnCloseWindow(wxCloseEvent& event);
wxTextCtrl *m_IndexText;
wxButton *m_IndexButton;
wxButton *m_IndexButtonAll;
wxListBox *m_IndexList;
wxTextCtrl *m_SearchText;
wxButton *m_SearchButton;
wxListBox *m_SearchList;
wxChoice *m_SearchChoice;
wxStaticText *m_IndexCountInfo;
wxCheckBox *m_SearchCaseSensitive;
wxCheckBox *m_SearchWholeWords;
wxComboBox *m_Bookmarks; // Images:
wxArrayString m_BookmarksNames, m_BookmarksPages; enum {
IMG_Book = 0,
IMG_Folder,
IMG_Page,
IMG_RootFolder
};
wxHtmlHelpFrameCfg m_Cfg; protected:
wxHtmlHelpData* m_Data;
bool m_DataCreated; // m_Data created by frame, or supplied?
wxString m_TitleFormat; // title of the help frame
// below are various pointers to GUI components
wxHtmlWindow *m_HtmlWin;
wxSplitterWindow *m_Splitter;
wxNotebook *m_NavigPan;
wxTreeCtrl *m_ContentsBox;
wxTextCtrl *m_IndexText;
wxButton *m_IndexButton;
wxButton *m_IndexButtonAll;
wxListBox *m_IndexList;
wxTextCtrl *m_SearchText;
wxButton *m_SearchButton;
wxListBox *m_SearchList;
wxChoice *m_SearchChoice;
wxStaticText *m_IndexCountInfo;
wxCheckBox *m_SearchCaseSensitive;
wxCheckBox *m_SearchWholeWords;
wxConfigBase *m_Config; wxComboBox *m_Bookmarks;
wxString m_ConfigRoot; wxArrayString m_BookmarksNames, m_BookmarksPages;
// pagenumbers of controls in notebook (usually 0,1,2) wxHtmlHelpFrameCfg m_Cfg;
int m_ContentsPage;
int m_IndexPage; wxConfigBase *m_Config;
int m_SearchPage; wxString m_ConfigRoot;
// lists of available fonts (used in options dialog) // pagenumbers of controls in notebook (usually 0,1,2)
wxArrayString *m_NormalFonts, *m_FixedFonts; int m_ContentsPage;
int m_FontSize; // 0,1,2 = small,medium,big int m_IndexPage;
wxString m_NormalFace, m_FixedFace; int m_SearchPage;
bool m_UpdateContents; // lists of available fonts (used in options dialog)
wxArrayString *m_NormalFonts, *m_FixedFonts;
int m_FontSize; // 0,1,2 = small,medium,big
wxString m_NormalFace, m_FixedFace;
bool m_UpdateContents;
#if wxUSE_PRINTING_ARCHITECTURE #if wxUSE_PRINTING_ARCHITECTURE
wxHtmlEasyPrinting *m_Printer; wxHtmlEasyPrinting *m_Printer;
#endif #endif
wxHashTable *m_PagesHash; wxHashTable *m_PagesHash;
wxHelpControllerBase* m_helpController; wxHelpControllerBase* m_helpController;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#endif // wxUSE_HTML #endif // wxUSE_HTML

View File

@@ -13,7 +13,7 @@
#define _WX_HTMLCELL_H_ #define _WX_HTMLCELL_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "htmlcell.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -39,94 +39,94 @@ class WXDLLEXPORT wxHtmlContainerCell;
class WXDLLEXPORT wxHtmlCell : public wxObject class WXDLLEXPORT wxHtmlCell : public wxObject
{ {
public: public:
wxHtmlCell(); wxHtmlCell();
virtual ~wxHtmlCell(); virtual ~wxHtmlCell();
void SetParent(wxHtmlContainerCell *p) {m_Parent = p;} void SetParent(wxHtmlContainerCell *p) {m_Parent = p;}
wxHtmlContainerCell *GetParent() const {return m_Parent;} wxHtmlContainerCell *GetParent() const {return m_Parent;}
int GetPosX() const {return m_PosX;} int GetPosX() const {return m_PosX;}
int GetPosY() const {return m_PosY;} int GetPosY() const {return m_PosY;}
int GetWidth() const {return m_Width;} int GetWidth() const {return m_Width;}
int GetHeight() const {return m_Height;} int GetHeight() const {return m_Height;}
int GetDescent() const {return m_Descent;} 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 void SetPos(int x, int y) {m_PosX = x, m_PosY = y;} // returns the link associated with this cell. The position is position within
void SetLink(const wxHtmlLinkInfo& link); // the cell so it varies from 0 to m_Width, from 0 to m_Height
void SetNext(wxHtmlCell *cell) {m_Next = cell;} virtual wxHtmlLinkInfo* GetLink(int WXUNUSED(x) = 0, int WXUNUSED(y) = 0) const
// members writin methods { return m_Link; }
virtual void Layout(int w); // members access methods
// 1. adjust cell's width according to the fact that maximal possible width is w. wxHtmlCell *GetNext() const {return m_Next;}
// (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); // members writin methods
// renders the cell 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;}
virtual void DrawInvisible(wxDC& dc, int x, int y); // 1. adjust cell's width according to the fact that maximal possible width is w.
// proceed drawing actions in case the cell is not visible (scrolled out of screen). // (this has sense when working with horizontal lines, tables etc.)
// This is needed to change fonts, colors and so on // 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 const wxHtmlCell* Find(int condition, const void* param) const; // renders the cell
// This method returns pointer to the FIRST cell for that virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
// 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(wxHTML_COND_ISANCHOR, "news");
// returns pointer to anchor news
virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event); // proceed drawing actions in case the cell is not visible (scrolled out of screen).
// This function is called when mouse button is clicked over the cell. // This is needed to change fonts, colors and so on
// left, middle, right are flags indicating whether the button was or wasn't virtual void DrawInvisible(wxDC& dc, int x, int y);
// pressed.
// Parent is pointer to wxHtmlWindow that generated the event
// HINT: if this handling is not enough for you you should use
// wxHtmlBinderCell
virtual bool AdjustPagebreak(int *pagebreak) const; // This method returns pointer to the FIRST cell for that
// This method used to adjust pagebreak position. The parameter is // the condition
// variable that contains y-coordinate of page break (= horizontal line that // is true. It first checks if the condition is true for this
// should not be crossed by words, images etc.). If this cell cannot be divided // cell and then calls m_Next->Find(). (Note: it checks
// into two pieces (each one on another page) then it moves the pagebreak // all subcells if the cell is container)
// few pixels up. // Condition is unique condition identifier (see htmldefs.h)
// // (user-defined condition IDs should start from 10000)
// Returned value : true if pagebreak was modified, false otherwise // and param is optional parameter
// Usage : while (container->AdjustPagebreak(&p)) {} // Example : m_Cell->Find(wxHTML_COND_ISANCHOR, "news");
// returns pointer to anchor news
virtual const wxHtmlCell* Find(int condition, const void* param) const;
void SetCanLiveOnPagebreak(bool can) {m_CanLiveOnPagebreak = can;} // This function is called when mouse button is clicked over the cell.
// Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default // left, middle, right are flags indicating whether the button was or wasn't
// is true - the cell can be split on two pages // 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);
// 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
// into two pieces (each one on another page) then it moves the pagebreak
// few pixels up.
//
// Returned value : true if pagebreak was modified, false otherwise
// Usage : while (container->AdjustPagebreak(&p)) {}
virtual bool AdjustPagebreak(int *pagebreak) const;
// 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; wxHtmlCell *m_Next;
// pointer to the next cell // pointer to the next cell
wxHtmlContainerCell *m_Parent; wxHtmlContainerCell *m_Parent;
// pointer to parent cell // pointer to parent cell
long m_Width, m_Height, m_Descent; long m_Width, m_Height, m_Descent;
// dimensions of fragment // dimensions of fragment
// m_Descent is used to position text&images.. // m_Descent is used to position text&images..
long m_PosX, m_PosY; long m_PosX, m_PosY;
// position where the fragment is drawn // position where the fragment is drawn
wxHtmlLinkInfo *m_Link; wxHtmlLinkInfo *m_Link;
// destination address if this fragment is hypertext link, "" otherwise // destination address if this fragment is hypertext link, "" otherwise
bool m_CanLiveOnPagebreak; bool m_CanLiveOnPagebreak;
// true if this cell can be placed on pagebreak, false otherwise // true if this cell can be placed on pagebreak, false otherwise
}; };
@@ -144,12 +144,12 @@ class WXDLLEXPORT wxHtmlCell : public wxObject
class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell
{ {
public: public:
wxHtmlWordCell(const wxString& word, wxDC& dc); wxHtmlWordCell(const wxString& word, wxDC& dc);
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
protected: protected:
wxString m_Word; wxString m_Word;
}; };
@@ -163,70 +163,74 @@ class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
{ {
public: public:
wxHtmlContainerCell(wxHtmlContainerCell *parent); wxHtmlContainerCell(wxHtmlContainerCell *parent);
~wxHtmlContainerCell(); ~wxHtmlContainerCell();
virtual void Layout(int w); virtual void Layout(int w);
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); 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 DrawInvisible(wxDC& dc, int x, int y);
virtual bool AdjustPagebreak(int *pagebreak) const; virtual bool AdjustPagebreak(int *pagebreak) const;
void InsertCell(wxHtmlCell *cell); // insert cell at the end of m_Cells list
// insert cell at the end of m_Cells list void InsertCell(wxHtmlCell *cell);
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;
// returns the indentation. ind is one of wxHTML_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; m_LastLayout = -1;}
void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0);
// 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;}
// sets minimal height of this container.
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;} // sets horizontal/vertical alignment
// returns pointer to the first cell in container or NULL 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;}
int GetAlignVer() const {return m_AlignVer;}
protected: // sets left-border indentation. units is one of wxHTML_UNITS_* constants
int m_IndentLeft, m_IndentRight, m_IndentTop, m_IndentBottom; // what is combination of wxHTML_INDENT_*
// indentation of subcells. There is always m_Indent pixels void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
// big space between given border of the container and the subcells // returns the indentation. ind is one of wxHTML_INDENT_* constants
// it m_Indent < 0 it is in PERCENTS, otherwise it is in pixels int GetIndent(int ind) const;
int m_MinHeight, m_MinHeightAlign; // returns type of value returned by GetIndent(ind)
// minimal height. int GetIndentUnits(int ind) const;
wxHtmlCell *m_Cells, *m_LastCell;
// internal cells, m_Cells points to the first of them, m_LastCell to the last one. // sets alignment info based on given tag's params
// (LastCell is needed only to speed-up InsertCell) void SetAlign(const wxHtmlTag& tag);
int m_AlignHor, m_AlignVer; // sets floating width adjustment
// alignment horizontal and vertical (left, center, right) // (examples : 32 percent of parent container,
int m_WidthFloat, m_WidthFloatUnits; // -15 pixels percent (this means 100 % - 15 pixels)
// width float is used in adjustWidth void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units; m_LastLayout = -1;}
bool m_UseBkColour; void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0);
wxColour m_BkColour; // sets minimal height of this container.
// background color of this container void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP) {m_MinHeight = h; m_MinHeightAlign = align; m_LastLayout = -1;}
bool m_UseBorder;
wxColour m_BorderColour1, m_BorderColour2; void SetBackgroundColour(const wxColour& clr) {m_UseBkColour = TRUE; m_BkColour = clr;}
// borders color of this container void SetBorder(const wxColour& clr1, const wxColour& clr2) {m_UseBorder = TRUE; m_BorderColour1 = clr1, m_BorderColour2 = clr2;}
int m_LastLayout; virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const;
// if != -1 then call to Layout may be no-op virtual const wxHtmlCell* Find(int condition, const void* param) const;
// if previous call to Layout has same argument virtual void OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event);
// returns pointer to the first cell in container or NULL
wxHtmlCell* GetFirstCell() const {return m_Cells;}
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.
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
int m_LastLayout;
// if != -1 then call to Layout may be no-op
// if previous call to Layout has same argument
}; };
@@ -240,14 +244,14 @@ class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlColourCell : 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;} 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 Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
virtual void DrawInvisible(wxDC& dc, int x, int y); virtual void DrawInvisible(wxDC& dc, int x, int y);
protected: protected:
wxColour m_Colour; wxColour m_Colour;
unsigned m_Flags; unsigned m_Flags;
}; };
@@ -260,13 +264,13 @@ class WXDLLEXPORT wxHtmlColourCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell
{ {
public: public:
wxHtmlFontCell(wxFont *font) : wxHtmlCell() { m_Font = (*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 Draw(wxDC& dc, int x, int y, int view_y1, int view_y2);
virtual void DrawInvisible(wxDC& dc, int x, int y); virtual void DrawInvisible(wxDC& dc, int x, int y);
protected: protected:
wxFont m_Font; wxFont m_Font;
}; };
@@ -283,21 +287,21 @@ class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell
{ {
public: public:
wxHtmlWidgetCell(wxWindow *wnd, int w = 0); // !!! wnd must have correct parent!
// !!! wnd must have correct parent! // if w != 0 then the m_Wnd has 'floating' width - it adjust
// if w != 0 then the m_Wnd has 'floating' width - it adjust // it's width according to parent container's width
// it's width according to parent container's width // (w is percent of parent's width)
// (w is percent of parent's width) wxHtmlWidgetCell(wxWindow *wnd, int w = 0);
~wxHtmlWidgetCell() { m_Wnd->Destroy(); } ~wxHtmlWidgetCell() { m_Wnd->Destroy(); }
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); 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 DrawInvisible(wxDC& dc, int x, int y);
virtual void Layout(int w); virtual void Layout(int w);
protected: protected:
wxWindow* m_Wnd; wxWindow* m_Wnd;
int m_WidthFloat; int m_WidthFloat;
// width float is used in adjustWidth (it is in percents) // width float is used in adjustWidth (it is in percents)
}; };
@@ -309,28 +313,30 @@ class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell
class WXDLLEXPORT wxHtmlLinkInfo : public wxObject class WXDLLEXPORT wxHtmlLinkInfo : public wxObject
{ {
public: public:
wxHtmlLinkInfo() : wxObject() wxHtmlLinkInfo() : wxObject()
{ m_Href = m_Target = wxEmptyString; m_Event = NULL, m_Cell = NULL; } { m_Href = m_Target = wxEmptyString; m_Event = NULL, m_Cell = NULL; }
wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString) : wxObject() wxHtmlLinkInfo(const wxString& href, const wxString& target = wxEmptyString) : wxObject()
{ m_Href = href; m_Target = target; m_Event = NULL, m_Cell = NULL; } { m_Href = href; m_Target = target; m_Event = NULL, m_Cell = NULL; }
wxHtmlLinkInfo(const wxHtmlLinkInfo& l) : wxObject() 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;
wxHtmlLinkInfo& operator=(const wxHtmlLinkInfo& l) 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; return *this; } 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; }
void SetEvent(const wxMouseEvent *e) { m_Event = e; } void SetEvent(const wxMouseEvent *e) { m_Event = e; }
void SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; } void SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; }
wxString GetHref() const { return m_Href; } wxString GetHref() const { return m_Href; }
wxString GetTarget() const { return m_Target; } wxString GetTarget() const { return m_Target; }
const wxMouseEvent* GetEvent() const { return m_Event; } const wxMouseEvent* GetEvent() const { return m_Event; }
const wxHtmlCell* GetHtmlCell() const { return m_Cell; } const wxHtmlCell* GetHtmlCell() const { return m_Cell; }
private: private:
wxString m_Href, m_Target; wxString m_Href, m_Target;
const wxMouseEvent *m_Event; const wxMouseEvent *m_Event;
const wxHtmlCell *m_Cell; const wxHtmlCell *m_Cell;
}; };

View File

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

View File

@@ -12,56 +12,38 @@
#define _WX_HTMLTAG_H_ #define _WX_HTMLTAG_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "htmltag.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_HTML #if wxUSE_HTML
//-----------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// wxHtmlTagsCache // wxHtmlTagsCache
// !! INTERNAL STRUCTURE !! Do not use in your program! // - internal wxHTML class, do not use!
// 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;
struct wxHtmlCacheItem;
class wxHtmlTagsCache : public wxObject class wxHtmlTagsCache : public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache) DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
private: private:
sCacheItem *m_Cache; wxHtmlCacheItem *m_Cache;
int m_CacheSize; int m_CacheSize;
int m_CachePos; int m_CachePos;
public: public:
wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;} wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
wxHtmlTagsCache(const wxString& source); wxHtmlTagsCache(const wxString& source);
~wxHtmlTagsCache() {free(m_Cache);} ~wxHtmlTagsCache() {free(m_Cache);}
void QueryTag(int at, int* end1, int* end2); // Finds parameters for tag starting at at and fills the variables
// Finds parameters for tag starting at at and fills the variables void QueryTag(int at, int* end1, int* end2);
}; };
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// wxHtmlTag // wxHtmlTag
// This represents single tag. It is used as internal structure // This represents single tag. It is used as internal structure
@@ -72,63 +54,62 @@ class WXDLLEXPORT wxHtmlTag : public wxObject
{ {
DECLARE_CLASS(wxHtmlTag) DECLARE_CLASS(wxHtmlTag)
public: public:
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); // constructs wxHtmlTag object based on HTML tag.
// constructs wxHtmlTag object based on HTML tag. // The tag begins (with '<' character) at position pos in source
// The tag begins (with '<' character) at position pos in source // end_pos is position where parsing ends (usually end of document)
// 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.
// 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
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)
int ScanParam(const wxString& par, wxChar *format, void *param) const; // Returns TRUE if the tag has given parameter. Parameter
// Scans param like scanf() functions family do. // should always be in uppercase.
// Example : ScanParam("COLOR", "\"#%X\"", &clr); // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
// This is always with with_commas=FALSE bool HasParam(const wxString& par) const;
// Returns number of scanned values
// (like sscanf() does)
// NOTE: unlike scanf family, this function only accepts
// *one* parameter !
inline const wxString& GetAllParams() const {return m_Params;} // Returns value of the param. Value is in uppercase unless it is
// Returns string containing all params. // enclosed with "
// Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
inline bool IsEnding() const {return m_Ending;} // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
// return TRUE if this is ending tag (</something>) or FALSE // (or ("WhaT.jpg") if with_commas == TRUE)
// if it isn't (<something>) wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
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;} // Scans param like scanf() functions family do.
// returns beginning position of _internal_ block of text // Example : ScanParam("COLOR", "\"#%X\"", &clr);
// See explanation (returned value is marked with *): // This is always with with_commas=FALSE
// bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla // Returns number of scanned values
inline int GetEndPos1() const {return m_End1;} // (like sscanf() does)
// returns ending position of _internal_ block of text. // NOTE: unlike scanf family, this function only accepts
// bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla // *one* parameter !
inline int GetEndPos2() const {return m_End2;} int ScanParam(const wxString& par, wxChar *format, void *param) const;
// returns end position 2 :
// bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
private: // Returns string containing all params.
wxString m_Name, m_Params; inline const wxString& GetAllParams() const {return m_Params;}
int m_Begin, m_End1, m_End2;
bool m_Ending;
// 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;}
// 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 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 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:
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_ #define _WX_HTMLWIN_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "htmlwin.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -43,17 +43,17 @@
// item of history list // item of history list
class WXDLLEXPORT HtmlHistoryItem : public wxObject class WXDLLEXPORT HtmlHistoryItem : public wxObject
{ {
public: public:
HtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;} HtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;}
int GetPos() const {return m_Pos;} int GetPos() const {return m_Pos;}
void SetPos(int p) {m_Pos = p;} void SetPos(int p) {m_Pos = p;}
const wxString& GetPage() const {return m_Page;} const wxString& GetPage() const {return m_Page;}
const wxString& GetAnchor() const {return m_Anchor;} const wxString& GetAnchor() const {return m_Anchor;}
private: private:
wxString m_Page; wxString m_Page;
wxString m_Anchor; wxString m_Anchor;
int m_Pos; int m_Pos;
}; };
@@ -64,166 +64,165 @@ class wxHtmlWinModule;
class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlWindow) DECLARE_DYNAMIC_CLASS(wxHtmlWindow)
friend class wxHtmlWinModule; friend class wxHtmlWinModule;
public: public:
wxHtmlWindow() : wxScrolledWindow() {}; wxHtmlWindow() : wxScrolledWindow() {};
wxHtmlWindow(wxWindow *parent, wxWindowID id = -1, wxHtmlWindow(wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition,
long style = wxHW_SCROLLBAR_AUTO, const wxSize& size = wxDefaultSize,
const wxString& name = "htmlWindow"); long style = wxHW_SCROLLBAR_AUTO,
~wxHtmlWindow(); const wxString& name = "htmlWindow");
~wxHtmlWindow();
bool SetPage(const wxString& source); // Set HTML page and display it. !! source is HTML document itself,
// Set HTML page and display it. !! source is HTML document itself, // it is NOT address/filename of HTML document. If you want to
// it is NOT address/filename of HTML document. If you want to // specify document location, use LoadPage() istead
// specify document location, use LoadPage() istead // Return value : FALSE if an error occured, TRUE otherwise
// 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
// Load HTML page from given location. Location can be either // a) /usr/wxGTK2/docs/html/wx.htm
// a) /usr/wxGTK2/docs/html/wx.htm // b) http://www.somewhere.uk/document.htm
// b) http://www.somewhere.uk/document.htm // c) ftp://ftp.somesite.cz/pub/something.htm
// c) ftp://ftp.somesite.cz/pub/something.htm // In case there is no prefix (http:,ftp:), the method
// In case there is no prefix (http:,ftp:), the method // will try to find it itself (1. local file, then http or ftp)
// 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.
// After the page is loaded, the method calls SetPage() to display it. // Note : you can also use path relative to previously loaded page
// Note : you can also use path relative to previously loaded page // Return value : same as SetPage
// Return value : same as SetPage bool LoadPage(const wxString& location);
wxString GetOpenedPage() const {return m_OpenedPage;} // Returns full location of opened page
// Returns full location of opened page wxString GetOpenedPage() const {return m_OpenedPage;}
wxString GetOpenedAnchor() const {return m_OpenedAnchor;} // Returns anchor within opened page
// Returns anchor within opened page wxString GetOpenedAnchor() const {return m_OpenedAnchor;}
wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;} // Returns <TITLE> of opened page or empty string otherwise
// 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
// 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;} 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.
// will be displayed. Default is -1 = no messages. void SetRelatedStatusBar(int bar);
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes); // Sets fonts to be used when displaying HTML page.
// sets fonts to be used when displaying HTML page. void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
virtual void OnSetTitle(const wxString& title); // Sets the title of the window
// Sets the title of the window // (depending on the information passed to SetRelatedFrame() method)
// (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.
// 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.
// if given, otherwise it will save info into currently selected path. // saved values : things set by SetFonts, SetBorders.
// saved values : things set by SetFonts, SetBorders. virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); // ...
// ... virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString);
bool HistoryBack(); // Goes to previous/next page (in browsing history)
bool HistoryForward(); // Returns TRUE if successful, FALSE otherwise
// Goes to previous/next page (in browsing history) bool HistoryBack();
// Returns TRUE if successful, FALSE otherwise bool HistoryForward();
bool HistoryCanBack(); bool HistoryCanBack();
bool HistoryCanForward(); bool HistoryCanForward();
// Resets history
void HistoryClear(); void HistoryClear();
// Resets history
wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;} // Returns pointer to conteiners/cells structure.
// Returns pointer to conteiners/cells structure. // It should be used ONLY when printing
// It should be used ONLY when printing wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;}
static void AddFilter(wxHtmlFilter *filter); // Adds input 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)
// call LoadPage(loc) virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
wxHtmlWinParser *GetParser() const { return m_Parser; } // Returns a pointer to the parser.
// return a pointer to the parser. wxHtmlWinParser *GetParser() const { return m_Parser; }
protected: protected:
bool ScrollToAnchor(const wxString& anchor); // Scrolls to anchor of this name. (Anchor is #news
// Scrolls to anchor of this name. (Anchor is #news // or #features etc. it is part of address sometimes:
// or #features etc. it is part of address sometimes: // http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html#news)
// http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html#news) // Return value : TRUE if anchor exists, FALSE otherwise
// Return value : TRUE if anchor exists, FALSE otherwise bool ScrollToAnchor(const wxString& anchor);
void CreateLayout(); // Prepares layout (= fill m_PosX, m_PosY for fragments) based on
// prepare layout (= fill m_PosX, m_PosY for fragments) based on actual size of // actual size of window. This method also setup scrollbars
// window. This method also setup scrollbars void CreateLayout();
void OnDraw(wxDC& dc); void OnDraw(wxDC& dc);
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnMouseEvent(wxMouseEvent& event); void OnMouseEvent(wxMouseEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);
virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;} // Returns new filter (will be stored into m_DefaultFilter variable)
// returns new filter (will be stored into m_DefaultFilter variable) virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;}
static void CleanUpStatics(); static void CleanUpStatics();
// cleans static variables // cleans static variables
protected: protected:
wxHtmlContainerCell *m_Cell; wxHtmlContainerCell *m_Cell;
// This is pointer to the first cell in parsed data. // 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) // (Note: the first cell is usually top one = all other cells are sub-cells of this one)
wxHtmlWinParser *m_Parser; wxHtmlWinParser *m_Parser;
// parser which is used to parse HTML input. // parser which is used to parse HTML input.
// Each wxHtmlWindow has it's own parser because sharing one global // Each wxHtmlWindow has it's own parser because sharing one global
// parser would be problematic (because of reentrancy) // parser would be problematic (because of reentrancy)
wxString m_OpenedPage; wxString m_OpenedPage;
// contains name of actualy opened page or empty string if no page opened // contains name of actualy opened page or empty string if no page opened
wxString m_OpenedAnchor; wxString m_OpenedAnchor;
// contains name of current anchor within m_OpenedPage // contains name of current anchor within m_OpenedPage
wxString m_OpenedPageTitle; wxString m_OpenedPageTitle;
// contains title of actualy opened page or empty string if no <TITLE> tag // contains title of actualy opened page or empty string if no <TITLE> tag
wxFileSystem* m_FS; wxFileSystem* m_FS;
// class for opening files (file system) // class for opening files (file system)
wxFrame *m_RelatedFrame; wxFrame *m_RelatedFrame;
wxString m_TitleFormat; wxString m_TitleFormat;
int m_RelatedStatusBar; int m_RelatedStatusBar;
// frame in which page title should be displayed & number of it's statusbar // frame in which page title should be displayed & number of it's statusbar
// reserved for usage with this html window // reserved for usage with this html window
int m_Borders; int m_Borders;
// borders (free space between text and window borders) // borders (free space between text and window borders)
// defaults to 10 pixels. // defaults to 10 pixels.
int m_Style; int m_Style;
private: private:
bool m_tmpMouseMoved; bool m_tmpMouseMoved;
// a flag indicated if mouse moved // a flag indicated if mouse moved
// (if TRUE we will try to change cursor in last call to OnIdle) // (if TRUE we will try to change cursor in last call to OnIdle)
wxHtmlLinkInfo *m_tmpLastLink; wxHtmlLinkInfo *m_tmpLastLink;
// contains last link name // contains last link name
int m_tmpCanDrawLocks; int m_tmpCanDrawLocks;
// if >0 contents of the window is not redrawn // if >0 contents of the window is not redrawn
// (in order to avoid ugly blinking) // (in order to avoid ugly blinking)
static wxList m_Filters; static wxList m_Filters;
// list of HTML filters // list of HTML filters
static wxHtmlFilter *m_DefaultFilter; static wxHtmlFilter *m_DefaultFilter;
// this filter is used when no filter is able to read some file // this filter is used when no filter is able to read some file
static wxCursor *s_cur_hand; static wxCursor *s_cur_hand;
static wxCursor *s_cur_arrow; static wxCursor *s_cur_arrow;
HtmlHistoryArray m_History; HtmlHistoryArray m_History;
int m_HistoryPos; int m_HistoryPos;
// browser history // browser history
bool m_HistoryOn; bool m_HistoryOn;
// if this FLAG is false, items are not added to history // if this FLAG is false, items are not added to history
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

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

View File

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

View File

@@ -12,7 +12,7 @@
#define _WX_WINPARS_H_ #define _WX_WINPARS_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface "winpars.h"
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
@@ -24,9 +24,9 @@
#include "wx/html/htmlcell.h" #include "wx/html/htmlcell.h"
#include "wx/encconv.h" #include "wx/encconv.h"
class wxHtmlWinParser; class WXDLLEXPORT wxHtmlWinParser;
class wxHtmlWinTagHandler; class WXDLLEXPORT wxHtmlWinTagHandler;
class wxHtmlTagsModule; class WXDLLEXPORT wxHtmlTagsModule;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// wxHtmlWinParser // wxHtmlWinParser
@@ -39,128 +39,137 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
{ {
friend class wxHtmlWindow; friend class wxHtmlWindow;
public: public:
wxHtmlWinParser(wxWindow *wnd = NULL); wxHtmlWinParser(wxWindow *wnd = NULL);
~wxHtmlWinParser(); ~wxHtmlWinParser();
virtual void InitParser(const wxString& source); virtual void InitParser(const wxString& source);
virtual void DoneParser(); virtual void DoneParser();
virtual wxObject* GetProduct(); 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,
// Set's the DC used for parsing. If SetDC() is not called, // parsing won't proceed
// parsing won't proceed virtual void SetDC(wxDC *dc, double pixel_scale = 1.0)
wxDC *GetDC() {return m_DC;} { m_DC = dc; m_PixelScale = pixel_scale; }
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
void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes); wxDC *GetDC() {return m_DC;}
// sets fonts to be used when displaying HTML page. double GetPixelScale() {return m_PixelScale;}
int GetCharHeight() const {return m_CharHeight;}
int GetCharWidth() const {return m_CharWidth;}
static void AddModule(wxHtmlTagsModule *module); // NOTE : these functions do _not_ return _actual_
// Adds tags module. see wxHtmlTagsModule for details. // height/width. They return h/w of default font
static void RemoveModule(wxHtmlTagsModule *module); // for this DC. If you want actual values, call
// GetDC()->GetChar...()
// returns associated wxWindow
wxWindow *GetWindow() {return m_Window;}
// parsing-related methods. These methods are called by tag handlers: // sets fonts to be used when displaying HTML page.
wxHtmlContainerCell *GetContainer() const {return m_Container;} void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes);
// Returns pointer to actual container. Common use in tag handler is :
// m_WParser->GetContainer()->InsertCell(new ...); // Adds tags module. see wxHtmlTagsModule for details.
wxHtmlContainerCell *OpenContainer(); static void AddModule(wxHtmlTagsModule *module);
// 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;} static void RemoveModule(wxHtmlTagsModule *module);
void SetFontSize(int 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;}
wxString GetFontFace() const {return GetFontFixed() ? m_FontFaceFixed : m_FontFaceNormal;}
void SetFontFace(const wxString& face);
int GetAlign() const {return m_Align;} // parsing-related methods. These methods are called by tag handlers:
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 wxHtmlLinkInfo& GetLink() const { return m_Link; }
void SetLink(const wxHtmlLinkInfo& link);
void SetInputEncoding(wxFontEncoding enc); // Returns pointer to actual container. Common use in tag handler is :
wxFontEncoding GetInputEncoding() const { return m_InputEnc; } // m_WParser->GetContainer()->InsertCell(new ...);
wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; } wxHtmlContainerCell *GetContainer() const {return m_Container;}
wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; }
virtual wxFont* CreateCurrentFont(); // opens new container. This container is sub-container of opened
// creates font depending on m_Font* members. // container. Sets GetContainer to newly created container
// and returns it.
wxHtmlContainerCell *OpenContainer();
protected: // works like OpenContainer except that new container is not created
virtual void AddText(const char *txt); // but c is used. You can use this to directly set actual container
wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c);
private: // closes the container and sets actual Container to upper-level
bool m_tmpLastWasSpace; // container
// temporary variable used by AddText wxHtmlContainerCell *CloseContainer();
wxWindow *m_Window;
// window we're parsing for
double m_PixelScale;
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; int GetFontSize() const {return m_FontSize;}
// actual container. See Open/CloseContainer for details. void SetFontSize(int 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;}
wxString GetFontFace() const {return GetFontFixed() ? m_FontFaceFixed : m_FontFaceNormal;}
void SetFontFace(const wxString& face);
int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not TRUE,FALSE but 1,0, we need it for indexing int GetAlign() const {return m_Align;}
int m_FontSize; /* -2 to +4, 0 is default */ void SetAlign(int a) {m_Align = a;}
wxColour m_LinkColor; const wxColour& GetLinkColor() const { return m_LinkColor; }
wxColour m_ActualColor; void SetLinkColor(const wxColour& clr) { m_LinkColor = clr; }
// basic font parameters. const wxColour& GetActualColor() const { return m_ActualColor; }
wxHtmlLinkInfo m_Link; void SetActualColor(const wxColour& clr) { m_ActualColor = clr ;}
// actual hypertext link or empty string const wxHtmlLinkInfo& GetLink() const { return m_Link; }
bool m_UseLink; void SetLink(const wxHtmlLinkInfo& link);
// TRUE if m_Link is not empty
long m_CharHeight, m_CharWidth; void SetInputEncoding(wxFontEncoding enc);
// average height of normal-sized text wxFontEncoding GetInputEncoding() const { return m_InputEnc; }
int m_Align; wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; }
// actual alignment wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; }
wxFont* m_FontsTable[2][2][2][2][7]; // creates font depending on m_Font* members.
wxString m_FontsFacesTable[2][2][2][2][7]; virtual wxFont* CreateCurrentFont();
wxFontEncoding m_FontsEncTable[2][2][2][2][7];
// table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off protected:
// state of these flags (from left to right): virtual void AddText(const char *txt);
// [bold][italic][underlined][fixed_size]
// last index is font size : from 0 to 6 (remapped from html sizes 1 to 7) private:
// Note : this table covers all possible combinations of fonts, but not bool m_tmpLastWasSpace;
// all of them are used, so many items in table are usually NULL. // temporary variable used by AddText
int m_FontsSizes[7]; wxWindow *m_Window;
wxString m_FontFaceFixed, m_FontFaceNormal; // window we're parsing for
// html font sizes and faces of fixed and proportional fonts double m_PixelScale;
wxDC *m_DC;
wxFontEncoding m_InputEnc, m_OutputEnc; // Device Context we're parsing for
// I/O font encodings static wxList m_Modules;
wxEncodingConverter *m_EncConv; // 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.
wxHtmlLinkInfo 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];
wxString m_FontsFacesTable[2][2][2][2][7];
wxFontEncoding m_FontsEncTable[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 6 (remapped from html sizes 1 to 7)
// 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;
// html font sizes and faces of fixed and proportional fonts
wxFontEncoding m_InputEnc, m_OutputEnc;
// I/O font encodings
wxEncodingConverter *m_EncConv;
}; };
@@ -179,14 +188,13 @@ class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler
{ {
DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler) DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler)
public: public:
wxHtmlWinTagHandler() : wxHtmlTagHandler() {}; wxHtmlWinTagHandler() : wxHtmlTagHandler() {};
virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;}; virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;};
protected: protected:
wxHtmlWinParser *m_WParser; wxHtmlWinParser *m_WParser; // same as m_Parser, but overcasted
// same as m_Parser, but overcasted
}; };
@@ -206,17 +214,16 @@ class WXDLLEXPORT wxHtmlTagsModule : public wxModule
{ {
DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule) DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule)
public: public:
wxHtmlTagsModule() : wxModule() {}; wxHtmlTagsModule() : wxModule() {};
virtual bool OnInit(); virtual bool OnInit();
virtual void OnExit(); 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
// 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)) { }
}; };