From 9749497156909657d17ef972857caaca4bd09da2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 29 Apr 2001 17:57:59 +0000 Subject: [PATCH] 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 --- include/wx/html/helpctrl.h | 161 +++++++------- include/wx/html/helpdata.h | 256 +++++++++++----------- include/wx/html/helpfrm.h | 304 +++++++++++++------------- include/wx/html/htmlcell.h | 424 +++++++++++++++++++------------------ include/wx/html/htmlpars.h | 2 +- include/wx/html/htmltag.h | 161 +++++++------- include/wx/html/htmlwin.h | 339 +++++++++++++++-------------- include/wx/html/htmprint.h | 83 ++++---- include/wx/html/m_templ.h | 2 +- include/wx/html/winpars.h | 289 +++++++++++++------------ 10 files changed, 1006 insertions(+), 1015 deletions(-) diff --git a/include/wx/html/helpctrl.h b/include/wx/html/helpctrl.h index f168680ad5..8251c044f4 100644 --- a/include/wx/html/helpctrl.h +++ b/include/wx/html/helpctrl.h @@ -15,7 +15,7 @@ #include "wx/defs.h" #ifdef __GNUG__ -#pragma interface +#pragma interface "helpctrl.h" #endif #if wxUSE_HTML @@ -25,85 +25,86 @@ class WXDLLEXPORT wxHtmlHelpController : public wxHelpControllerBase // wxEvtHandler { - DECLARE_DYNAMIC_CLASS(wxHtmlHelpController) - - public: - wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE); - virtual ~wxHtmlHelpController(); - - void SetTitleFormat(const wxString& format); - void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); } - bool AddBook(const wxString& book, bool show_wait_msg = FALSE); - bool Display(const wxString& x) - { - CreateHelpWindow(); return m_helpFrame->Display(x); - } - bool Display(int id) - { - CreateHelpWindow(); return m_helpFrame->Display(id); - } - bool DisplayContents() - { - CreateHelpWindow(); return m_helpFrame->DisplayContents(); - } - bool DisplayIndex() - { - CreateHelpWindow(); return m_helpFrame->DisplayIndex(); - } - bool KeywordSearch(const wxString& keyword) - { - CreateHelpWindow(); return m_helpFrame->KeywordSearch(keyword); - } - wxHtmlHelpFrame* GetFrame() { return m_helpFrame; } - 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 - - virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize(file); } - 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, - 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); - - // Sets the specified book or all books to have the given base path - virtual void SetBookBasePath(const wxString& basePath, int which = -1); - - virtual bool Quit() ; - virtual void OnQuit() {}; - - void OnCloseFrame(wxCloseEvent& evt); - protected: - virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data); - - virtual void CreateHelpWindow(); - virtual void DestroyHelpWindow(); - - wxHtmlHelpData m_helpData; - wxHtmlHelpFrame* m_helpFrame; - wxConfigBase * m_Config; - wxString m_ConfigRoot; - wxString m_titleFormat; - int m_FrameStyle; - // DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS(wxHtmlHelpController) + +public: + wxHtmlHelpController(int style = wxHF_DEFAULTSTYLE); + virtual ~wxHtmlHelpController(); + + void SetTitleFormat(const wxString& format); + void SetTempDir(const wxString& path) { m_helpData.SetTempDir(path); } + bool AddBook(const wxString& book, bool show_wait_msg = FALSE); + bool Display(const wxString& x) + { + CreateHelpWindow(); return m_helpFrame->Display(x); + } + bool Display(int id) + { + CreateHelpWindow(); return m_helpFrame->Display(id); + } + bool DisplayContents() + { + CreateHelpWindow(); return m_helpFrame->DisplayContents(); + } + bool DisplayIndex() + { + CreateHelpWindow(); return m_helpFrame->DisplayIndex(); + } + bool KeywordSearch(const wxString& keyword) + { + CreateHelpWindow(); return m_helpFrame->KeywordSearch(keyword); + } + wxHtmlHelpFrame* GetFrame() { return m_helpFrame; } + 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 + + virtual bool Initialize(const wxString& file, int WXUNUSED(server) ) { return Initialize(file); } + 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, + 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); + + // Sets the specified book or all books to have the given base path + virtual void SetBookBasePath(const wxString& basePath, int which = -1); + + virtual bool Quit() ; + virtual void OnQuit() {}; + + void OnCloseFrame(wxCloseEvent& evt); + +protected: + virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData *data); + + virtual void CreateHelpWindow(); + 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 diff --git a/include/wx/html/helpdata.h b/include/wx/html/helpdata.h index be84c07264..dd7135f7d2 100644 --- a/include/wx/html/helpdata.h +++ b/include/wx/html/helpdata.h @@ -13,7 +13,7 @@ #define _WX_HELPDATA_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "helpdata.h" #endif #include "wx/defs.h" @@ -26,85 +26,86 @@ #include "wx/dynarray.h" #include "wx/font.h" +class WXDLLEXPORT wxHtmlHelpData; + //-------------------------------------------------------------------------------- // helper classes & structs //-------------------------------------------------------------------------------- class WXDLLEXPORT wxHtmlBookRecord : public wxObject { - public: - wxHtmlBookRecord(const wxString& basepath, const wxString& title, - const wxString& start) - { - m_BasePath = basepath; - m_Title = title; - m_Start = start; - // for debugging, give the contents index obvious default values - m_ContentsStart = m_ContentsEnd = -1; - } - wxString GetTitle() const { return m_Title; } - wxString GetStart() const { return m_Start; } - wxString GetBasePath() const { return m_BasePath; } - /* 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. - * This code will have to be revised when loading/removing books becomes dynamic. - * (as opposed to appending only) - * 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; } - int GetContentsStart() const { return m_ContentsStart; } - int GetContentsEnd() const { return m_ContentsEnd; } - - void SetTitle(const wxString& title) { m_Title = title; } - void SetBasePath(const wxString& path) { m_BasePath = path; } - void SetStart(const wxString& start) { m_Start = start; } - - protected: - wxString m_BasePath; - wxString m_Title; - wxString m_Start; - int m_ContentsStart; - int m_ContentsEnd; +public: + wxHtmlBookRecord(const wxString& basepath, const wxString& title, + const wxString& start) + { + m_BasePath = basepath; + m_Title = title; + m_Start = start; + // for debugging, give the contents index obvious default values + m_ContentsStart = m_ContentsEnd = -1; + } + wxString GetTitle() const { return m_Title; } + wxString GetStart() const { return m_Start; } + wxString GetBasePath() const { return m_BasePath; } + /* 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. + * This code will have to be revised when loading/removing books becomes dynamic. + * (as opposed to appending only) + * 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; } + int GetContentsStart() const { return m_ContentsStart; } + int GetContentsEnd() const { return m_ContentsEnd; } + + void SetTitle(const wxString& title) { m_Title = title; } + void SetBasePath(const wxString& path) { m_BasePath = path; } + void SetStart(const wxString& start) { m_Start = start; } + +protected: + wxString m_BasePath; + wxString m_Title; + wxString m_Start; + int m_ContentsStart; + int m_ContentsEnd; }; 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: - wxSearchEngine() : wxObject() {m_Keyword = NULL; } - ~wxSearchEngine() {if (m_Keyword) delete[] m_Keyword; } +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 + // 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 + // Scans the stream for the keyword. + // Returns TRUE if the stream contains keyword, fALSE otherwise + virtual bool Scan(wxInputStream *stream); - private: - wxChar *m_Keyword; - bool m_CaseSensitive; - bool m_WholeWords; +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,90 +113,87 @@ class wxHtmlHelpData; // wxHtmlHelpData::PrepareKeywordSearch(const wxString& key) class WXDLLEXPORT wxHtmlSearchStatus { - 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); - 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; } - - 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 +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); + 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; } + +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 { - DECLARE_DYNAMIC_CLASS(wxHtmlHelpData) - - friend class wxHtmlSearchStatus; - - 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. - - 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 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 - wxString FindPageByName(const wxString& page); - // returns URL of page on basis of (file)name - wxString FindPageById(int id); - // returns URL of page on basis of MS id - - const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; } - wxHtmlContentsItem* GetContents() { return m_Contents; } - int GetContentsCnt() { return m_ContentsCnt; } - wxHtmlContentsItem* GetIndex() { return m_Index; } - int GetIndexCnt() { return m_IndexCnt; } - - protected: - wxString m_TempPath; - - wxHtmlBookRecArray m_BookRecords; - // 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 - - protected: - 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); - // Writes binary book + DECLARE_DYNAMIC_CLASS(wxHtmlHelpData) + friend class wxHtmlSearchStatus; + +public: + wxHtmlHelpData(); + ~wxHtmlHelpData(); + + // 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); + + // 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, + 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); + // returns URL of page on basis of MS id + wxString FindPageById(int id); + + const wxHtmlBookRecArray& GetBookRecArray() { return m_BookRecords; } + wxHtmlContentsItem* GetContents() { return m_Contents; } + int GetContentsCnt() { return m_ContentsCnt; } + wxHtmlContentsItem* GetIndex() { return m_Index; } + int GetIndexCnt() { return m_IndexCnt; } + +protected: + wxString m_TempPath; + + wxHtmlBookRecArray m_BookRecords; + // each book has one record in this array: + wxHtmlContentsItem* m_Contents; + int m_ContentsCnt; + wxHtmlContentsItem* m_Index; // list of all available books and pages. + int m_IndexCnt; // list of index items + +protected: + // Imports .hhp files (MS HTML Help Workshop) + bool LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, + const wxString& indexfile, const wxString& contentsfile); + // Reads binary book + bool LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f); + // Writes binary book + bool SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f); }; // Utility function diff --git a/include/wx/html/helpfrm.h b/include/wx/html/helpfrm.h index 9bcf7574a4..a15cd0419c 100644 --- a/include/wx/html/helpfrm.h +++ b/include/wx/html/helpfrm.h @@ -13,7 +13,7 @@ #define _WX_HELPFRM_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "helpfrm.h" #endif #include "wx/defs.h" @@ -77,174 +77,172 @@ 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; class WXDLLEXPORT wxHtmlHelpFrame : public wxFrame { - DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame) - - public: - wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); } - wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID, - const wxString& title = wxEmptyString, - int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); - bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString, - int style = wxHF_DEFAULTSTYLE); - ~wxHtmlHelpFrame(); - - wxHtmlHelpData* GetData() { return m_Data; } - 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) - - 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: - // 1. try to locate file named x (if x is for example "doc/howto.htm") - // 2. try to open starting page of book x - // 3. try to find x in contents (if x is for example "How To ...") - // 4. try to find x in index (if x is for example "How To ...") - bool Display(const int id); - // Alternative version that works with numeric ID. - // (uses extension to MS format, , see docs) - - bool DisplayContents(); - // Displays help window and focuses contents. - - bool DisplayIndex(); - // Displays help window and focuses index. - - bool KeywordSearch(const wxString& keyword); - // Searches for keyword. Returns TRUE and display page if found, return - // FALSE otherwise - // Syntax of keyword is Altavista-like: - // * words are separated by spaces - // (but "\"hello world\"" is only one world "hello world") - // * word may be pretended by + or - - // (+ : page must contain the word ; - : page can't contain the word) - // * if there is no + or - before the word, + is default - - void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) - { - m_Config = config; - m_ConfigRoot = rootpath; - ReadCustomization(config, rootpath); - } - - void ReadCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); - // saves custom settings into cfg config. it will use the path 'path' - // if given, otherwise it will save info into currently selected path. - // saved values : things set by SetFonts, SetBorders. - void WriteCustomization(wxConfigBase *cfg, const wxString& path = wxEmptyString); - // ... - - void NotifyPageChanged(); - // call this to let wxHtmlHelpFrame know page changed - - protected: - void Init(wxHtmlHelpData* data = NULL); - - void RefreshLists(); - // Refreshes Contents and Index tabs - - void CreateContents(); - // Adds items to m_Contents tree control - - void CreateIndex(); - // Adds items to m_IndexList - - void CreateSearch(); - // Add books to search choice panel - - virtual void AddToolbarButtons(wxToolBar *toolBar, int style); - // Add custom buttons to toolbar - - virtual void OptionsDialog(); - // Displays options dialog (fonts etc.) - - void OnToolbar(wxCommandEvent& event); - void OnContentsSel(wxTreeEvent& event); - 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: - enum { - IMG_Book = 0, - IMG_Folder, - IMG_Page, - IMG_RootFolder - }; - - 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; - - wxComboBox *m_Bookmarks; - wxArrayString m_BookmarksNames, m_BookmarksPages; - - wxHtmlHelpFrameCfg m_Cfg; - - wxConfigBase *m_Config; - wxString m_ConfigRoot; - - // pagenumbers of controls in notebook (usually 0,1,2) - int m_ContentsPage; - int m_IndexPage; - int m_SearchPage; - - // 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; + DECLARE_DYNAMIC_CLASS(wxHtmlHelpFrame) + +public: + wxHtmlHelpFrame(wxHtmlHelpData* data = NULL) { Init(data); } + wxHtmlHelpFrame(wxWindow* parent, wxWindowID wxWindowID, + const wxString& title = wxEmptyString, + int style = wxHF_DEFAULTSTYLE, wxHtmlHelpData* data = NULL); + bool Create(wxWindow* parent, wxWindowID id, const wxString& title = wxEmptyString, + int style = wxHF_DEFAULTSTYLE); + ~wxHtmlHelpFrame(); + + wxHtmlHelpData* GetData() { return m_Data; } + wxHelpControllerBase* GetController() const { return m_helpController; } + void SetController(wxHelpControllerBase* controller) { m_helpController = controller; } + + // Sets format of title of the frame. Must contain exactly one "%s" + // (for title of displayed HTML page) + void SetTitleFormat(const wxString& format); + + // Displays page x. If not found it will offect the user a choice of + // searching books. + // Looking for the page runs in these steps: + // 1. try to locate file named x (if x is for example "doc/howto.htm") + // 2. try to open starting page of book x + // 3. try to find x in contents (if x is for example "How To ...") + // 4. try to find x in index (if x is for example "How To ...") + bool Display(const wxString& x); + + // Alternative version that works with numeric ID. + // (uses extension to MS format, , see docs) + bool Display(const int id); + + // Displays help window and focuses contents. + bool DisplayContents(); + + // Displays help window and focuses index. + bool DisplayIndex(); + + // Searches for keyword. Returns TRUE and display page if found, return + // FALSE otherwise + // Syntax of keyword is Altavista-like: + // * words are separated by spaces + // (but "\"hello world\"" is only one world "hello world") + // * word may be pretended by + or - + // (+ : page must contain the word ; - : page can't contain the word) + // * if there is no + or - before the word, + is default + bool KeywordSearch(const wxString& keyword); + + void UseConfig(wxConfigBase *config, const wxString& rootpath = wxEmptyString) + { + m_Config = config; + m_ConfigRoot = rootpath; + ReadCustomization(config, rootpath); + } + + // 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); + + // call this to let wxHtmlHelpFrame know page changed + void NotifyPageChanged(); + +protected: + void Init(wxHtmlHelpData* data = NULL); + + // Refreshes Contents and Index tabs + void RefreshLists(); + + // Adds items to m_Contents tree control + void CreateContents(); + + // Adds items to m_IndexList + void CreateIndex(); + + // Add books to search choice panel + void CreateSearch(); + + // Add custom buttons to toolbar + virtual void AddToolbarButtons(wxToolBar *toolBar, int style); + + // Displays options dialog (fonts etc.) + virtual void OptionsDialog(); + + void OnToolbar(wxCommandEvent& event); + void OnContentsSel(wxTreeEvent& event); + 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: + enum { + IMG_Book = 0, + IMG_Folder, + IMG_Page, + IMG_RootFolder + }; + +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; + + wxComboBox *m_Bookmarks; + wxArrayString m_BookmarksNames, m_BookmarksPages; + + wxHtmlHelpFrameCfg m_Cfg; + + wxConfigBase *m_Config; + wxString m_ConfigRoot; + + // pagenumbers of controls in notebook (usually 0,1,2) + int m_ContentsPage; + int m_IndexPage; + int m_SearchPage; + + // 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 - wxHtmlEasyPrinting *m_Printer; + wxHtmlEasyPrinting *m_Printer; #endif - wxHashTable *m_PagesHash; - wxHelpControllerBase* m_helpController; + wxHashTable *m_PagesHash; + wxHelpControllerBase* m_helpController; - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; #endif // wxUSE_HTML diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index ef3c6952a8..4f7532a910 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -13,7 +13,7 @@ #define _WX_HTMLCELL_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "htmlcell.h" #endif #include "wx/defs.h" @@ -39,94 +39,94 @@ class WXDLLEXPORT wxHtmlContainerCell; class WXDLLEXPORT wxHtmlCell : public wxObject { - public: - wxHtmlCell(); - virtual ~wxHtmlCell(); - - void SetParent(wxHtmlContainerCell *p) {m_Parent = p;} - wxHtmlContainerCell *GetParent() const {return m_Parent;} - - int GetPosX() const {return m_PosX;} - int GetPosY() const {return m_PosY;} - int GetWidth() const {return m_Width;} - int GetHeight() const {return m_Height;} - int GetDescent() const {return m_Descent;} - virtual 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;} - 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 Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); - // renders the cell - - 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 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 - // 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); - // 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 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 - // 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)) {} - - 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 - - - protected: - wxHtmlCell *m_Next; - // pointer to the next cell - wxHtmlContainerCell *m_Parent; - // pointer to parent cell - long m_Width, m_Height, m_Descent; - // dimensions of fragment - // m_Descent is used to position text&images.. - long m_PosX, m_PosY; - // position where the fragment is drawn - wxHtmlLinkInfo *m_Link; - // destination address if this fragment is hypertext link, "" otherwise - bool m_CanLiveOnPagebreak; - // true if this cell can be placed on pagebreak, false otherwise - +public: + wxHtmlCell(); + virtual ~wxHtmlCell(); + + void SetParent(wxHtmlContainerCell *p) {m_Parent = p;} + wxHtmlContainerCell *GetParent() const {return m_Parent;} + + int GetPosX() const {return m_PosX;} + int GetPosY() const {return m_PosY;} + int GetWidth() const {return m_Width;} + int GetHeight() const {return m_Height;} + int GetDescent() const {return m_Descent;} + + // 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 + 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;} + + // 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); + + // renders the cell + virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); + + // 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); + + // This method returns pointer to the FIRST cell for that + // the condition + // is true. It first checks if the condition is true for this + // cell and then calls m_Next->Find(). (Note: it checks + // all subcells if the cell is container) + // Condition is unique condition identifier (see htmldefs.h) + // (user-defined condition IDs should start from 10000) + // and param is optional parameter + // Example : m_Cell->Find(wxHTML_COND_ISANCHOR, "news"); + // returns pointer to anchor news + virtual const wxHtmlCell* Find(int condition, const void* param) const; + + // 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); + + // 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: + wxHtmlCell *m_Next; + // pointer to the next cell + wxHtmlContainerCell *m_Parent; + // pointer to parent cell + long m_Width, m_Height, m_Descent; + // dimensions of fragment + // m_Descent is used to position text&images.. + long m_PosX, m_PosY; + // position where the fragment is drawn + wxHtmlLinkInfo *m_Link; + // destination address if this fragment is hypertext link, "" otherwise + bool m_CanLiveOnPagebreak; + // 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 { - public: - wxHtmlWordCell(const wxString& word, wxDC& dc); - void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); +public: + wxHtmlWordCell(const wxString& word, wxDC& dc); + void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); - protected: - wxString m_Word; +protected: + wxString m_Word; }; @@ -163,70 +163,74 @@ class WXDLLEXPORT wxHtmlWordCell : public wxHtmlCell class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell { - public: - wxHtmlContainerCell(wxHtmlContainerCell *parent); - ~wxHtmlContainerCell(); - - virtual void Layout(int w); - virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); - virtual void DrawInvisible(wxDC& dc, int x, int y); - virtual bool AdjustPagebreak(int *pagebreak) const; - - void InsertCell(wxHtmlCell *cell); - // insert cell at the end of m_Cells list - 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;} - // returns pointer to the first cell in container or NULL - - 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 +public: + wxHtmlContainerCell(wxHtmlContainerCell *parent); + ~wxHtmlContainerCell(); + + virtual void Layout(int w); + virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); + virtual void DrawInvisible(wxDC& dc, int x, int y); + virtual bool AdjustPagebreak(int *pagebreak) const; + + // 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;} + int GetAlignVer() const {return m_AlignVer;} + + // sets left-border indentation. units is one of wxHTML_UNITS_* constants + // what is combination of wxHTML_INDENT_* + void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS); + // returns the indentation. ind is one of wxHTML_INDENT_* constants + int GetIndent(int ind) const; + // returns type of value returned by GetIndent(ind) + int GetIndentUnits(int ind) const; + + // sets alignment info based on given tag's params + void SetAlign(const wxHtmlTag& tag); + // sets floating width adjustment + // (examples : 32 percent of parent container, + // -15 pixels percent (this means 100 % - 15 pixels) + 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); + + // 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 { - 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: - wxColour m_Colour; - unsigned m_Flags; +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: + wxColour m_Colour; + unsigned m_Flags; }; @@ -260,13 +264,13 @@ class WXDLLEXPORT wxHtmlColourCell : public wxHtmlCell class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell { - 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); +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: - wxFont m_Font; +protected: + wxFont m_Font; }; @@ -283,21 +287,21 @@ class WXDLLEXPORT wxHtmlFontCell : public wxHtmlCell class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell { - public: - wxHtmlWidgetCell(wxWindow *wnd, int w = 0); - // !!! wnd must have correct parent! - // if w != 0 then the m_Wnd has 'floating' width - it adjust - // it's width according to parent container's width - // (w is percent of parent's width) - ~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: - wxWindow* m_Wnd; - int m_WidthFloat; - // width float is used in adjustWidth (it is in percents) +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: + wxWindow* m_Wnd; + int m_WidthFloat; + // width float is used in adjustWidth (it is in percents) }; @@ -309,28 +313,30 @@ class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell class WXDLLEXPORT wxHtmlLinkInfo : public wxObject { - 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; } - 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 SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; } - - wxString GetHref() const { return m_Href; } - wxString GetTarget() const { return m_Target; } - const wxMouseEvent* GetEvent() const { return m_Event; } - const wxHtmlCell* GetHtmlCell() const { return m_Cell; } - - private: - wxString m_Href, m_Target; - const wxMouseEvent *m_Event; - const wxHtmlCell *m_Cell; +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; } + 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 SetHtmlCell(const wxHtmlCell *e) { m_Cell = e; } + + wxString GetHref() const { return m_Href; } + wxString GetTarget() const { return m_Target; } + const wxMouseEvent* GetEvent() const { return m_Event; } + const wxHtmlCell* GetHtmlCell() const { return m_Cell; } + +private: + wxString m_Href, m_Target; + const wxMouseEvent *m_Event; + const wxHtmlCell *m_Cell; }; diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h index 272c44ad5e..6a93d07ddb 100644 --- a/include/wx/html/htmlpars.h +++ b/include/wx/html/htmlpars.h @@ -12,7 +12,7 @@ #define _WX_HTMLPARS_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "htmlpars.h" #endif #include "wx/defs.h" diff --git a/include/wx/html/htmltag.h b/include/wx/html/htmltag.h index 88aacdd4dd..7ce80f3629 100644 --- a/include/wx/html/htmltag.h +++ b/include/wx/html/htmltag.h @@ -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; - int m_CacheSize; - int m_CachePos; +private: + wxHtmlCacheItem *m_Cache; + int m_CacheSize; + int m_CachePos; - public: - wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;} - wxHtmlTagsCache(const wxString& source); - ~wxHtmlTagsCache() {free(m_Cache);} +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 + // 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,63 +54,62 @@ class WXDLLEXPORT wxHtmlTag : public wxObject { DECLARE_CLASS(wxHtmlTag) - public: - wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); - // constructs wxHtmlTag object based on HTML tag. - // The tag begins (with '<' character) at position pos in source - // end_pos is position where parsing ends (usually end of document) - - inline wxString GetName() const {return m_Name;} - // Returns tag's name in uppercase. - - bool HasParam(const wxString& par) const; - // Returns TRUE if the tag has given parameter. Parameter - // should always be in uppercase. - // Example : 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 :

GetParam("ALIGN") returns (RIGHT) - //

GetParam("SRC") returns (WhaT.jpg) - // (or ("WhaT.jpg") if with_commas == TRUE) - - 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 - // 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 string containing all params. - - inline bool IsEnding() const {return m_Ending;} - // return TRUE if this is ending tag () or FALSE - // if it isn't () - - inline bool HasEnding() const {return m_End1 >= 0;} - // return TRUE if this is ending tag () or FALSE - // if it isn't () - - 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 * bla bla intenal text bla bla - inline int GetEndPos1() const {return m_End1;} - // returns ending position of _internal_ block of text. - // bla bla bla bla bla intenal text* bla bla - inline int GetEndPos2() const {return m_End2;} - // returns end position 2 : - // bla bla bla bla bla internal text* bla bla - - private: - wxString m_Name, m_Params; - int m_Begin, m_End1, m_End2; - bool m_Ending; - +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); + + // Returns tag's name in uppercase. + inline wxString GetName() const {return m_Name;} + + // Returns TRUE if the tag has given parameter. Parameter + // should always be in uppercase. + // Example : HasParam("SRC") returns TRUE + bool HasParam(const wxString& par) const; + + // Returns value of the param. Value is in uppercase unless it is + // enclosed with " + // Example :

GetParam("ALIGN") returns (RIGHT) + //

GetParam("SRC") returns (WhaT.jpg) + // (or ("WhaT.jpg") if with_commas == TRUE) + wxString GetParam(const wxString& par, bool with_commas = FALSE) const; + + // Scans param like scanf() functions family do. + // Example : ScanParam("COLOR", "\"#%X\"", &clr); + // This is always with with_commas=FALSE + // Returns number of scanned values + // (like sscanf() does) + // NOTE: unlike scanf family, this function only accepts + // *one* parameter ! + int ScanParam(const wxString& par, wxChar *format, void *param) const; + + // Returns string containing all params. + inline const wxString& GetAllParams() const {return m_Params;} + + // return TRUE if this is ending tag () or FALSE + // if it isn't () + inline bool IsEnding() const {return m_Ending;} + + // return TRUE if this is ending tag () or FALSE + // if it isn't () + 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 * bla bla intenal text bla bla + inline int GetBeginPos() const {return m_Begin;} + // returns ending position of _internal_ block of text. + // bla bla bla bla bla intenal text* bla bla + inline int GetEndPos1() const {return m_End1;} + // returns end position 2 : + // bla bla bla bla bla internal text* 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; }; diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index 822cc96547..75585561b6 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -12,7 +12,7 @@ #define _WX_HTMLWIN_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "htmlwin.h" #endif #include "wx/defs.h" @@ -43,17 +43,17 @@ // item of history list class WXDLLEXPORT HtmlHistoryItem : public wxObject { - 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: - wxString m_Page; - wxString m_Anchor; - int m_Pos; +public: + HtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;} + int GetPos() const {return m_Pos;} + void SetPos(int p) {m_Pos = p;} + const wxString& GetPage() const {return m_Page;} + const wxString& GetAnchor() const {return m_Anchor;} + +private: + wxString m_Page; + wxString m_Anchor; + int m_Pos; }; @@ -64,166 +64,165 @@ class wxHtmlWinModule; class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow { DECLARE_DYNAMIC_CLASS(wxHtmlWindow) - friend class wxHtmlWinModule; - public: - wxHtmlWindow() : wxScrolledWindow() {}; - wxHtmlWindow(wxWindow *parent, wxWindowID id = -1, - 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 LoadPage(const wxString& location); - // Load HTML page from given location. Location can be either - // a) /usr/wxGTK2/docs/html/wx.htm - // b) http://www.somewhere.uk/document.htm - // c) ftp://ftp.somesite.cz/pub/something.htm - // In case there is no prefix (http:,ftp:), the method - // will try to find it itself (1. local file, then http or ftp) - // After the page is loaded, the method calls SetPage() to display it. - // Note : you can also use path relative to previously loaded page - // Return value : same as SetPage - - wxString GetOpenedPage() const {return m_OpenedPage;} - // Returns full location of opened page - wxString GetOpenedAnchor() const {return m_OpenedAnchor;} - // Returns anchor within opened page - wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;} - // Returns of opened page or empty string otherwise - - void SetRelatedFrame(wxFrame* frame, const wxString& format); - // sets frame in which page title will be displayed. Format is format of - // frame title, e.g. "HtmlHelp : %s". It must contain exactly one %s - wxFrame* GetRelatedFrame() const {return m_RelatedFrame;} - - void SetRelatedStatusBar(int bar); - // after(!) calling SetRelatedFrame, this sets statusbar slot where messages - // will be displayed. Default is -1 = no messages. - - void SetFonts(wxString normal_face, 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) - - void SetBorders(int b) {m_Borders = b;} - // Sets space between text and window borders. - - virtual void ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); - // saves custom settings into cfg config. it will use the path 'path' - // if given, otherwise it will save info into currently selected path. - // saved values : things set by SetFonts, SetBorders. - virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); - // ... - - bool HistoryBack(); - bool HistoryForward(); - // Goes to previous/next page (in browsing history) - // Returns TRUE if successful, FALSE otherwise - bool HistoryCanBack(); - bool HistoryCanForward(); - - void HistoryClear(); - // Resets history - - wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;} - // Returns pointer to conteiners/cells structure. - // It should be used ONLY when printing - - static void AddFilter(wxHtmlFilter *filter); - // Adds input filter - - virtual void OnLinkClicked(const wxHtmlLinkInfo& link); - // called when users clicked on hypertext link. Default behavior is to - // call LoadPage(loc) - - wxHtmlWinParser *GetParser() const { return m_Parser; } - // return a pointer to the parser. - - protected: - bool ScrollToAnchor(const wxString& anchor); - // Scrolls to anchor of this name. (Anchor is #news - // or #features etc. it is part of address sometimes: - // http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html#news) - // Return value : TRUE if anchor exists, FALSE otherwise - - void CreateLayout(); - // prepare layout (= fill m_PosX, m_PosY for fragments) based on actual size of - // window. This method also setup scrollbars - - void OnDraw(wxDC& dc); - void OnSize(wxSizeEvent& event); - void OnMouseEvent(wxMouseEvent& event); - void OnIdle(wxIdleEvent& event); - - virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;} - // returns new filter (will be stored into m_DefaultFilter variable) - - static void CleanUpStatics(); - // cleans static variables - - - protected: - wxHtmlContainerCell *m_Cell; - // This is pointer to the first cell in parsed data. - // (Note: the first cell is usually top one = all other cells are sub-cells of this one) - wxHtmlWinParser *m_Parser; - // parser which is used to parse HTML input. - // Each wxHtmlWindow has it's own parser because sharing one global - // parser would be problematic (because of reentrancy) - wxString m_OpenedPage; - // contains name of actualy opened page or empty string if no page opened - wxString m_OpenedAnchor; - // contains name of current anchor within m_OpenedPage - wxString m_OpenedPageTitle; - // contains title of actualy opened page or empty string if no <TITLE> tag - wxFileSystem* m_FS; - // class for opening files (file system) - - wxFrame *m_RelatedFrame; - wxString m_TitleFormat; - int m_RelatedStatusBar; - // frame in which page title should be displayed & number of it's statusbar - // reserved for usage with this html window - - int m_Borders; - // borders (free space between text and window borders) - // defaults to 10 pixels. - - int m_Style; - - private: - bool m_tmpMouseMoved; - // a flag indicated if mouse moved - // (if TRUE we will try to change cursor in last call to OnIdle) - wxHtmlLinkInfo *m_tmpLastLink; - // contains last link name - int m_tmpCanDrawLocks; - // if >0 contents of the window is not redrawn - // (in order to avoid ugly blinking) - - static wxList m_Filters; - // list of HTML filters - static wxHtmlFilter *m_DefaultFilter; - // this filter is used when no filter is able to read some file - - static wxCursor *s_cur_hand; - static wxCursor *s_cur_arrow; - - HtmlHistoryArray m_History; - int m_HistoryPos; - // browser history - bool m_HistoryOn; - // if this FLAG is false, items are not added to history +public: + wxHtmlWindow() : wxScrolledWindow() {}; + wxHtmlWindow(wxWindow *parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxHW_SCROLLBAR_AUTO, + const wxString& name = "htmlWindow"); + ~wxHtmlWindow(); + + // 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); + + // Load HTML page from given location. Location can be either + // a) /usr/wxGTK2/docs/html/wx.htm + // b) http://www.somewhere.uk/document.htm + // c) ftp://ftp.somesite.cz/pub/something.htm + // In case there is no prefix (http:,ftp:), the method + // will try to find it itself (1. local file, then http or ftp) + // After the page is loaded, the method calls SetPage() to display it. + // Note : you can also use path relative to previously loaded page + // Return value : same as SetPage + bool LoadPage(const wxString& location); + + // Returns full location of opened page + wxString GetOpenedPage() const {return m_OpenedPage;} + // Returns anchor within opened page + wxString GetOpenedAnchor() const {return m_OpenedAnchor;} + // Returns <TITLE> of opened page or empty string otherwise + wxString GetOpenedPageTitle() const {return m_OpenedPageTitle;} + + // 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;} + + // 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 the title of the window + // (depending on the information passed to SetRelatedFrame() method) + virtual void OnSetTitle(const wxString& title); + + // Sets space between text and window borders. + void SetBorders(int b) {m_Borders = b;} + + // 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 ReadCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); + // ... + virtual void WriteCustomization(wxConfigBase *cfg, wxString path = wxEmptyString); + + // Goes to previous/next page (in browsing history) + // Returns TRUE if successful, FALSE otherwise + bool HistoryBack(); + bool HistoryForward(); + bool HistoryCanBack(); + bool HistoryCanForward(); + // Resets history + void HistoryClear(); + + // Returns pointer to conteiners/cells structure. + // It should be used ONLY when printing + wxHtmlContainerCell* GetInternalRepresentation() const {return m_Cell;} + + // Adds input filter + static void AddFilter(wxHtmlFilter *filter); + + // 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; } + +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(); + + 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;} + + static void CleanUpStatics(); + // cleans static variables + + +protected: + wxHtmlContainerCell *m_Cell; + // This is pointer to the first cell in parsed data. + // (Note: the first cell is usually top one = all other cells are sub-cells of this one) + wxHtmlWinParser *m_Parser; + // parser which is used to parse HTML input. + // Each wxHtmlWindow has it's own parser because sharing one global + // parser would be problematic (because of reentrancy) + wxString m_OpenedPage; + // contains name of actualy opened page or empty string if no page opened + wxString m_OpenedAnchor; + // contains name of current anchor within m_OpenedPage + wxString m_OpenedPageTitle; + // contains title of actualy opened page or empty string if no <TITLE> tag + wxFileSystem* m_FS; + // class for opening files (file system) + + wxFrame *m_RelatedFrame; + wxString m_TitleFormat; + int m_RelatedStatusBar; + // frame in which page title should be displayed & number of it's statusbar + // reserved for usage with this html window + + int m_Borders; + // borders (free space between text and window borders) + // defaults to 10 pixels. + + int m_Style; + +private: + bool m_tmpMouseMoved; + // a flag indicated if mouse moved + // (if TRUE we will try to change cursor in last call to OnIdle) + wxHtmlLinkInfo *m_tmpLastLink; + // contains last link name + int m_tmpCanDrawLocks; + // if >0 contents of the window is not redrawn + // (in order to avoid ugly blinking) + + static wxList m_Filters; + // list of HTML filters + static wxHtmlFilter *m_DefaultFilter; + // this filter is used when no filter is able to read some file + + static wxCursor *s_cur_hand; + static wxCursor *s_cur_arrow; + + HtmlHistoryArray m_History; + int m_HistoryPos; + // browser history + bool m_HistoryOn; + // if this FLAG is false, items are not added to history DECLARE_EVENT_TABLE() diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index d185767c94..e3d527d1f4 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -12,7 +12,7 @@ #define _WX_HTMPRINT_H_ #ifdef __GNUG__ -#pragma interface +#pragma interface "htmprint.h" #endif #include <wx/defs.h> @@ -33,46 +33,47 @@ class WXDLLEXPORT wxHtmlDCRenderer : public wxObject { - public: - wxHtmlDCRenderer(); - ~wxHtmlDCRenderer(); - - // 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 - void SetSize(int width, int height); - // 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 - // 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) - - 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. - // Use this value as 'from' in next call to Render in order to print multiple pages - // document - // 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! - - int GetTotalHeight(); - // returns total height of the html document - // (compare Render's return value with this) - - private: - - wxDC *m_DC; - wxHtmlWinParser *m_Parser; - wxFileSystem *m_FS; - wxHtmlContainerCell *m_Cells; - int m_MaxWidth, m_Width, m_Height; +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); + + // 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 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); + + // [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. + // Use this value as 'from' in next call to Render in order to print multiple pages + // document + // 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! + 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) + int GetTotalHeight(); + +private: + wxDC *m_DC; + wxHtmlWinParser *m_Parser; + wxFileSystem *m_FS; + wxHtmlContainerCell *m_Cells; + int m_MaxWidth, m_Width, m_Height; }; diff --git a/include/wx/html/m_templ.h b/include/wx/html/m_templ.h index 4df782c6a2..63d29000bb 100644 --- a/include/wx/html/m_templ.h +++ b/include/wx/html/m_templ.h @@ -27,7 +27,7 @@ I STRONGLY recommend reading and understanding these macros!! #ifdef __GNUG__ -#pragma interface +#pragma interface "m_templ.h" #pragma implementation #endif diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h index e44b2f5fba..fee91731c2 100644 --- a/include/wx/html/winpars.h +++ b/include/wx/html/winpars.h @@ -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,128 +39,137 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser { friend class wxHtmlWindow; - public: - wxHtmlWinParser(wxWindow *wnd = NULL); - ~wxHtmlWinParser(); - - virtual void InitParser(const wxString& source); - 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 - 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 - - void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes); - // sets fonts to be used when displaying HTML page. - - static void AddModule(wxHtmlTagsModule *module); - // Adds tags module. see wxHtmlTagsModule for details. - 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(); - // opens new container. This container is sub-container of opened - // container. Sets GetContainer to newly created container - // and returns it. - wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); - // works like OpenContainer except that new container is not created - // but c is used. You can use this to directly set actual container - wxHtmlContainerCell *CloseContainer(); - // closes the container and sets actual Container to upper-level - // container - - int GetFontSize() const {return m_FontSize;} - void SetFontSize(int s); - 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;} - 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); - wxFontEncoding GetInputEncoding() const { return m_InputEnc; } - wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; } - wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; } - - virtual wxFont* CreateCurrentFont(); - // creates font depending on m_Font* members. - - protected: - virtual void AddText(const char *txt); - - private: - bool m_tmpLastWasSpace; - // temporary variable used by AddText - 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; - // 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; +public: + wxHtmlWinParser(wxWindow *wnd = NULL); + ~wxHtmlWinParser(); + + virtual void InitParser(const wxString& source); + virtual void DoneParser(); + virtual wxObject* GetProduct(); + + // 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...() + + // returns associated wxWindow + wxWindow *GetWindow() {return m_Window;} + + // sets fonts to be used when displaying HTML page. + void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes); + + // 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: + + // Returns pointer to actual container. Common use in tag handler is : + // m_WParser->GetContainer()->InsertCell(new ...); + 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 *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 *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); + 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;} + 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); + wxFontEncoding GetInputEncoding() const { return m_InputEnc; } + wxFontEncoding GetOutputEncoding() const { return m_OutputEnc; } + wxEncodingConverter *GetEncodingConverter() const { return m_EncConv; } + + // creates font depending on m_Font* members. + virtual wxFont* CreateCurrentFont(); + +protected: + virtual void AddText(const char *txt); + +private: + bool m_tmpLastWasSpace; + // temporary variable used by AddText + 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; + // 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) - public: - wxHtmlWinTagHandler() : wxHtmlTagHandler() {}; +public: + 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: - 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: - wxHtmlTagsModule() : wxModule() {}; +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 bool OnInit(); + virtual void OnExit(); + // 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)) { } }; -- 2.45.2