From: Václav Slavík Date: Sat, 2 Oct 1999 18:19:46 +0000 (+0000) Subject: making wxHTML 8.3 compliant X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/69941f05864fa8b37856ccc1338124bfac756a2b making wxHTML 8.3 compliant git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/Makefile.in b/Makefile.in index 3b83477621..9fbd4dac93 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# This file was automatically generated by tmake at 15:11, 1999/09/30 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -555,19 +555,19 @@ PROTOCOL_HEADERS = \ protocol/protocol.h HTML_HEADERS = \ - html/forcelink.h \ + html/forcelnk.h \ html/helpctrl.h \ html/helpdata.h \ html/helpfrm.h \ html/htmlcell.h \ html/htmldefs.h \ - html/htmlfilter.h \ - html/htmlparser.h \ + html/htmlfilt.h \ + html/htmlpars.h \ html/htmltag.h \ html/htmlwin.h \ - html/htmlwinparser.h \ - html/mod_templ.h \ - html/version.h + html/m_templ.h \ + html/version.h \ + html/winpars.h GTK_GENERICOBJS = \ busyinfo.o \ @@ -1206,6 +1206,7 @@ MOTIF_GUIOBJS = \ dialog.o \ filedlg.o \ font.o \ + fontenum.o \ frame.o \ gauge.o \ gdiobj.o \ @@ -1261,6 +1262,7 @@ MOTIF_GUIDEPS = \ dialog.d \ filedlg.d \ font.d \ + fontenum.d \ frame.d \ gauge.d \ gdiobj.d \ @@ -1690,40 +1692,40 @@ HTMLOBJS = \ helpdata.o \ helpfrm.o \ htmlcell.o \ - htmlfilter.o \ - htmlparser.o \ + htmlfilt.o \ + htmlpars.o \ htmltag.o \ htmlwin.o \ - htmlwinparser.o \ - mod_fonts.o \ - mod_hline.o \ - mod_image.o \ - mod_layout.o \ - mod_links.o \ - mod_list.o \ - mod_pre.o \ - mod_tables.o \ - search.o + m_fonts.o \ + m_hline.o \ + m_image.o \ + m_layout.o \ + m_links.o \ + m_list.o \ + m_pre.o \ + m_tables.o \ + search.o \ + winpars.o HTMLDEPS = \ helpctrl.d \ helpdata.d \ helpfrm.d \ htmlcell.d \ - htmlfilter.d \ - htmlparser.d \ + htmlfilt.d \ + htmlpars.d \ htmltag.d \ htmlwin.d \ - htmlwinparser.d \ - mod_fonts.d \ - mod_hline.d \ - mod_image.d \ - mod_layout.d \ - mod_links.d \ - mod_list.d \ - mod_pre.d \ - mod_tables.d \ - search.d + m_fonts.d \ + m_hline.d \ + m_image.d \ + m_layout.d \ + m_links.d \ + m_list.d \ + m_pre.d \ + m_tables.d \ + search.d \ + winpars.d UNIXOBJS = \ gsocket.o \ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 891772df07..faf662f04f 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -392,19 +392,19 @@ helpdata.cpp H helpfrm.cpp H helpctrl.cpp H htmlcell.cpp H -htmlfilter.cpp H -htmlparser.cpp H +htmlfilt.cpp H +htmlpars.cpp H htmltag.cpp H htmlwin.cpp H -htmlwinparser.cpp H -mod_fonts.cpp H -mod_hline.cpp H -mod_image.cpp H -mod_layout.cpp H -mod_links.cpp H -mod_list.cpp H -mod_pre.cpp H -mod_tables.cpp H +winpars.cpp H +m_fonts.cpp H +m_hline.cpp H +m_image.cpp H +m_layout.cpp H +m_links.cpp H +m_list.cpp H +m_pre.cpp H +m_tables.cpp H search.cpp H arrimpl.cpp W @@ -825,18 +825,18 @@ ftp.h P http.h P protocol.h P -forcelink.h L +forcelnk.h L helpdata.h L helpfrm.h L helpctrl.h L htmlcell.h L htmldefs.h L -htmlfilter.h L -htmlparser.h L +htmlfilt.h L +htmlpars.h L htmltag.h L htmlwin.h L -htmlwinparser.h L -mod_templ.h L +winpars.h L +m_templ.h L version.h L caret.h N diff --git a/include/wx/html/forcelink.h b/include/wx/html/forcelink.h deleted file mode 100644 index 2be0bc0cf6..0000000000 --- a/include/wx/html/forcelink.h +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: forcelink.h -// Purpose: see bellow -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -/* - -DESCRPITON: - -mod_*.cpp files contain handlers for tags. These files are modules - they contain -one wxTagModule class and it's OnInit() method is called from wxApp's init method. -The module is called even if you only link it into the executable, so everything -seems wonderful. - -The problem is that we have these modules in LIBRARY and mod_*.cpp files contain -no method nor class which is known out of the module. So the linker won't -link these .o/.obj files into executable because it detected that it is not used -by the program. - -To workaround this I introduced set of macros FORCE_LINK_ME and FORCE_LINK. These -macros are generic and are not limited to mod_*.cpp files. You may find them quite -useful somewhere else... - -How to use them: -let's suppose you want to always link file foo.cpp and that you have module -always.cpp that is certainly always linked (e.g. the one with main() function -or htmlwin.cpp in wxHtml library). - -Place FORCE_LINK_ME(foo) somewhere in foo.cpp and FORCE_LINK(foo) somewhere -in always.cpp -See mod_*.cpp and htmlwin.cpp for example :-) - -*/ - - -#ifndef __FORCELINK_H__ -#define __FORCELINK_H__ - - - -// This must be part of the module you want to force: -#define FORCE_LINK_ME(module_name) \ - int _link_dummy_func_##module_name () \ - { \ - return 1; \ - } - - -// And this must be somewhere where it certainly will be linked: -#define FORCE_LINK(module_name) \ - extern int _link_dummy_func_##module_name (); \ - static int _link_dummy_var_##module_name = \ - _link_dummy_func_##module_name (); - - -#endif // __FORCELINK_H__ diff --git a/include/wx/html/forcelnk.h b/include/wx/html/forcelnk.h new file mode 100644 index 0000000000..16485fdd57 --- /dev/null +++ b/include/wx/html/forcelnk.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: forcelnk.h +// Purpose: see bellow +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/* + +DESCRPITON: + +mod_*.cpp files contain handlers for tags. These files are modules - they contain +one wxTagModule class and it's OnInit() method is called from wxApp's init method. +The module is called even if you only link it into the executable, so everything +seems wonderful. + +The problem is that we have these modules in LIBRARY and mod_*.cpp files contain +no method nor class which is known out of the module. So the linker won't +link these .o/.obj files into executable because it detected that it is not used +by the program. + +To workaround this I introduced set of macros FORCE_LINK_ME and FORCE_LINK. These +macros are generic and are not limited to mod_*.cpp files. You may find them quite +useful somewhere else... + +How to use them: +let's suppose you want to always link file foo.cpp and that you have module +always.cpp that is certainly always linked (e.g. the one with main() function +or htmlwin.cpp in wxHtml library). + +Place FORCE_LINK_ME(foo) somewhere in foo.cpp and FORCE_LINK(foo) somewhere +in always.cpp +See mod_*.cpp and htmlwin.cpp for example :-) + +*/ + + +#ifndef _WX_FORCELNK_H_ +#define _WX_FORCELNK_H_ + + + +// This must be part of the module you want to force: +#define FORCE_LINK_ME(module_name) \ + int _link_dummy_func_##module_name () \ + { \ + return 1; \ + } + + +// And this must be somewhere where it certainly will be linked: +#define FORCE_LINK(module_name) \ + extern int _link_dummy_func_##module_name (); \ + static int _link_dummy_var_##module_name = \ + _link_dummy_func_##module_name (); + + +#endif // _WX_FORCELNK_H_ diff --git a/include/wx/html/helpctrl.h b/include/wx/html/helpctrl.h index 532c7e92f4..c2051ae8c9 100644 --- a/include/wx/html/helpctrl.h +++ b/include/wx/html/helpctrl.h @@ -4,8 +4,7 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -16,7 +15,7 @@ #include "wx/defs.h" #ifdef __GNUG__ -#pragma interface "helpctrl.h" +#pragma interface #endif #if wxUSE_HTML diff --git a/include/wx/html/helpdata.h b/include/wx/html/helpdata.h index a731bed94b..97fb804d94 100644 --- a/include/wx/html/helpdata.h +++ b/include/wx/html/helpdata.h @@ -4,8 +4,7 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,7 +13,7 @@ #define _WX_HELPDATA_H_ #ifdef __GNUG__ -#pragma interface "helpdata.h" +#pragma interface #endif #include "wx/defs.h" diff --git a/include/wx/html/helpfrm.h b/include/wx/html/helpfrm.h index 6be92402de..d83d5c4f86 100644 --- a/include/wx/html/helpfrm.h +++ b/include/wx/html/helpfrm.h @@ -4,8 +4,7 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -14,7 +13,7 @@ #define _WX_HELPFRM_H_ #ifdef __GNUG__ -#pragma interface "helpfrm.h" +#pragma interface #endif #include "wx/defs.h" diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 667682997d..7d725e29e1 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -3,16 +3,17 @@ // Purpose: wxHtmlCell class is used by wxHtmlWindow/wxHtmlWinParser // as a basic visual element of HTML page // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __HTMLCELL_H__ -#define __HTMLCELL_H__ +#ifndef _WX_HTMLCELL_H_ +#define _WX_HTMLCELL_H_ #ifdef __GNUG__ -#pragma interface "htmlcell.h" +#pragma interface #endif #include "wx/defs.h" @@ -36,19 +37,6 @@ class wxHtmlContainerCell; class WXDLLEXPORT wxHtmlCell : public wxObject { - protected: - wxHtmlCell *m_Next; - // pointer to the next cell - wxHtmlContainerCell *m_Parent; - // pointer to parent cell - long m_Width, m_Height, m_Descent; - // dimensions of fragment - // m_Descent is used to position text&images.. - long m_PosX, m_PosY; - // position where the fragment is drawn - wxString m_Link; - // destination address if this fragment is hypertext link, "" otherwise - public: wxHtmlCell() : wxObject() {m_Next = NULL; m_Parent = NULL; m_Width = m_Height = m_Descent = 0;}; virtual ~wxHtmlCell() {if (m_Next) delete m_Next;}; @@ -106,6 +94,21 @@ class WXDLLEXPORT wxHtmlCell : public wxObject // Parent is pointer to wxHtmlWindow that generated the event // HINT: if this handling is not enough for you you should use // wxHtmlBinderCell + + + protected: + wxHtmlCell *m_Next; + // pointer to the next cell + wxHtmlContainerCell *m_Parent; + // pointer to parent cell + long m_Width, m_Height, m_Descent; + // dimensions of fragment + // m_Descent is used to position text&images.. + long m_PosX, m_PosY; + // position where the fragment is drawn + wxString m_Link; + // destination address if this fragment is hypertext link, "" otherwise + }; @@ -281,15 +284,7 @@ class WXDLLEXPORT wxHtmlWidgetCell : public wxHtmlCell - -#endif // __HTMLCELL_H__ - #endif - - - - - - +#endif // _WX_HTMLCELL_H_ diff --git a/include/wx/html/htmldefs.h b/include/wx/html/htmldefs.h index 955b4456fd..6b0e43dbaf 100644 --- a/include/wx/html/htmldefs.h +++ b/include/wx/html/htmldefs.h @@ -2,13 +2,14 @@ // Name: htmldefs.h // Purpose: constants for wxhtml library // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __HTMLDEFS_H__ -#define __HTMLDEFS_H__ +#ifndef _WX_HTMLDEFS_H_ +#define _WX_HTMLDEFS_H_ #include "wx/defs.h" @@ -95,4 +96,4 @@ /* steps of array reallocation */ #endif -#endif \ No newline at end of file +#endif diff --git a/include/wx/html/htmlfilt.h b/include/wx/html/htmlfilt.h new file mode 100644 index 0000000000..cffb72f211 --- /dev/null +++ b/include/wx/html/htmlfilt.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlfilt.h +// Purpose: filters +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifndef _WX_HTMLFILT_H_ +#define _WX_HTMLFILT_H_ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" + +#if wxUSE_HTML + +#include "wx/filesys.h" + + +//-------------------------------------------------------------------------------- +// wxHtmlFilter +// This class is input filter. It can "translate" files +// in non-HTML format to HTML format +// interface to access certain +// kinds of files (HTPP, FTP, local, tar.gz etc..) +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlFilter : public wxObject +{ + DECLARE_ABSTRACT_CLASS(wxHtmlFilter) + + public: + wxHtmlFilter() : wxObject() {} + + virtual bool CanRead(const wxFSFile& file) const = 0; + // returns TRUE if this filter is able to open&read given file + + virtual wxString ReadFile(const wxFSFile& file) const = 0; + // reads given file and returns HTML document. + // Returns empty string if opening failed +}; + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// This filter is used as default filter if no other can +// be used (= uknown type of file). It is used by +// wxHtmlWindow itself. +//-------------------------------------------------------------------------------- + + +class WXDLLEXPORT wxHtmlFilterPlainText : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterPlainText) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + + + +#endif +#endif // _WX_HTMLFILT_H_ + diff --git a/include/wx/html/htmlfilter.h b/include/wx/html/htmlfilter.h deleted file mode 100644 index 100b31d8b5..0000000000 --- a/include/wx/html/htmlfilter.h +++ /dev/null @@ -1,71 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlfilter.h -// Purpose: filters -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __HTMLFILTER_H__ -#define __HTMLFILTER_H__ - -#ifdef __GNUG__ -#pragma interface "htmlfilter.h" -#endif - -#include "wx/defs.h" - -#if wxUSE_HTML - -#include "wx/filesys.h" - - -//-------------------------------------------------------------------------------- -// wxHtmlFilter -// This class is input filter. It can "translate" files -// in non-HTML format to HTML format -// interface to access certain -// kinds of files (HTPP, FTP, local, tar.gz etc..) -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlFilter : public wxObject -{ - DECLARE_ABSTRACT_CLASS(wxHtmlFilter) - - public: - wxHtmlFilter() : wxObject() {} - - virtual bool CanRead(const wxFSFile& file) const = 0; - // returns TRUE if this filter is able to open&read given file - - virtual wxString ReadFile(const wxFSFile& file) const = 0; - // reads given file and returns HTML document. - // Returns empty string if opening failed -}; - - - -//-------------------------------------------------------------------------------- -// wxHtmlFilterPlainText -// This filter is used as default filter if no other can -// be used (= uknown type of file). It is used by -// wxHtmlWindow itself. -//-------------------------------------------------------------------------------- - - -class WXDLLEXPORT wxHtmlFilterPlainText : public wxHtmlFilter -{ - DECLARE_DYNAMIC_CLASS(wxHtmlFilterPlainText) - - public: - virtual bool CanRead(const wxFSFile& file) const; - virtual wxString ReadFile(const wxFSFile& file) const; -}; - - - - -#endif // __HTMLFILTER_H__ - -#endif \ No newline at end of file diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h new file mode 100644 index 0000000000..bc098ba42b --- /dev/null +++ b/include/wx/html/htmlpars.h @@ -0,0 +1,178 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlpars.h +// Purpose: wxHtmlParser class (generic parser) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifndef _WX_HTMLPARS_H_ +#define _WX_HTMLPARS_H_ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#if wxUSE_HTML + +#include "wx/html/htmltag.h" +#include "wx/filesys.h" + +class wxHtmlParser; +class wxHtmlTagHandler; + +//-------------------------------------------------------------------------------- +// wxHtmlParser +// This class handles generic parsing of HTML document : it scans +// the document and divide it into blocks of tags (where one block +// consists of starting and ending tag and of text between these +// 2 tags. +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlParser : public wxObject +{ + DECLARE_ABSTRACT_CLASS(wxHtmlParser) + + public: + wxHtmlParser() : wxObject(), m_HandlersHash(wxKEY_STRING) {m_FS = NULL; m_Cache = NULL;} + virtual ~wxHtmlParser(); + + void SetFS(wxFileSystem *fs) {m_FS = fs;} + // Sets the class which will be used for opening files + wxFileSystem* GetFS() const {return m_FS;} + + wxObject* Parse(const wxString& source); + // You can simply call this method when you need parsed output. + // This method does these things: + // 1. call InitParser(source); + // 2. call DoParsing(); + // 3. call GetProduct(); (it's return value is then returned) + // 4. call DoneParser(); + + virtual void InitParser(const wxString& source); + // Sets the source. This must be called before running Parse() method. + virtual void DoneParser(); + // This must be called after Parse(). + + void DoParsing(int begin_pos, int end_pos); + inline void DoParsing() {DoParsing(0, m_Source.Length());}; + // Parses the m_Source from begin_pos to end_pos-1. + // (in noparams version it parses whole m_Source) + + virtual wxObject* GetProduct() = 0; + // Returns product of parsing + // Returned value is result of parsing of the part. The type of this result + // depends on internal representation in derived parser + // (see wxHtmlWinParser for details). + + virtual void AddTagHandler(wxHtmlTagHandler *handler); + // adds handler to the list & hash table of handlers. + + wxString* GetSource() {return &m_Source;} + + virtual wxList* GetTempData() {return NULL;} + // this method returns list of wxObjects that represents + // all data allocated by the parser. These can't be freeded + // by destructor because they must be valid as long as + // GetProduct's return value is valid - the caller must + // explicitly call delete MyParser -> GetTempData() to free + // the memory + // (this method always sets the list to delete its contents) + + protected: + + virtual void AddText(const char* txt) = 0; + // Adds text to the output. + // This is called from Parse() and must be overriden in derived classes. + // txt is not guaranteed to be only one word. It is largest continuous part of text + // (= not broken by tags) + // NOTE : using char* because of speed improvements + + virtual void AddTag(const wxHtmlTag& tag); + // Adds tag and proceeds it. Parse() may (and usually is) called from this method. + // This is called from Parse() and may be overriden. + // Default behavior is that it looks for proper handler in m_Handlers. The tag is + // ignored if no hander is found. + // Derived class is *responsible* for filling in m_Handlers table. + + + protected: + wxString m_Source; + // source being parsed + wxHtmlTagsCache *m_Cache; + // tags cache, used during parsing. + wxHashTable m_HandlersHash; + wxList m_HandlersList; + // handlers that handle particular tags. The table is accessed by + // key = tag's name. + // This attribute MUST be filled by derived class otherwise it would + // be empty and no tags would be recognized + // (see wxHtmlWinParser for details about filling it) + // m_HandlersHash is for random access based on knowledge of tag name (BR, P, etc.) + // it may (and often does) contain more references to one object + // m_HandlersList is list of all handlers and it is guaranteed to contain + // only one reference to each handler instance. + wxFileSystem *m_FS; + // class for opening files (file system) + +}; + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlTagHandler +// This class (and derived classes) cooperates with wxHtmlParser. +// Each recognized tag is passed to handler which is capable +// of handling it. Each tag is handled in 3 steps: +// 1. Handler will modifies state of parser +// (using it's public methods) +// 2. Parser parses source between starting and ending tag +// 3. Handler restores original state of the parser +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlTagHandler : public wxObject +{ + DECLARE_ABSTRACT_CLASS(wxHtmlTagHandler) + + protected: + wxHtmlParser *m_Parser; + + public: + wxHtmlTagHandler() : wxObject () {m_Parser = NULL;}; + + virtual void SetParser(wxHtmlParser *parser) {m_Parser = parser;} + // Sets the parser. + // NOTE : each _instance_ of handler is guaranteed to be called + // only by one parser. This means you don't have to care about + // reentrancy. + + virtual wxString GetSupportedTags() = 0; + // Returns list of supported tags. The list is in uppercase and + // tags are delimited by ','. + // Example : "I,B,FONT,P" + // is capable of handling italic, bold, font and paragraph tags + + virtual bool HandleTag(const wxHtmlTag& tag) = 0; + // This is hadling core method. It does all the Steps 1-3. + // To process step 2, you can call ParseInner() + // returned value : TRUE if it called ParseInner(), + // FALSE etherwise + + protected: + void ParseInner(const wxHtmlTag& tag) {m_Parser -> DoParsing(tag.GetBeginPos(), tag.GetEndPos1());} + // parses input between beginning and ending tag. + // m_Parser must be set. +}; + + + + +#endif + +#endif // _WX_HTMLPARS_H_ diff --git a/include/wx/html/htmlparser.h b/include/wx/html/htmlparser.h deleted file mode 100644 index d1c6a65070..0000000000 --- a/include/wx/html/htmlparser.h +++ /dev/null @@ -1,176 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlparser.h -// Purpose: wxHtmlParser class (generic parser) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __HTMLPARSER_H__ -#define __HTMLPARSER_H__ - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "wx/defs.h" -#if wxUSE_HTML - -#include -#include - -class wxHtmlParser; -class wxHtmlTagHandler; - -//-------------------------------------------------------------------------------- -// wxHtmlParser -// This class handles generic parsing of HTML document : it scans -// the document and divide it into blocks of tags (where one block -// consists of starting and ending tag and of text between these -// 2 tags. -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlParser : public wxObject -{ - DECLARE_ABSTRACT_CLASS(wxHtmlParser) - - protected: - wxString m_Source; - // source being parsed - wxHtmlTagsCache *m_Cache; - // tags cache, used during parsing. - wxHashTable m_HandlersHash; - wxList m_HandlersList; - // handlers that handle particular tags. The table is accessed by - // key = tag's name. - // This attribute MUST be filled by derived class otherwise it would - // be empty and no tags would be recognized - // (see wxHtmlWinParser for details about filling it) - // m_HandlersHash is for random access based on knowledge of tag name (BR, P, etc.) - // it may (and often does) contain more references to one object - // m_HandlersList is list of all handlers and it is guaranteed to contain - // only one reference to each handler instance. - wxFileSystem *m_FS; - // class for opening files (file system) - - public: - wxHtmlParser() : wxObject(), m_HandlersHash(wxKEY_STRING) {m_FS = NULL; m_Cache = NULL;} - virtual ~wxHtmlParser(); - - void SetFS(wxFileSystem *fs) {m_FS = fs;} - // Sets the class which will be used for opening files - wxFileSystem* GetFS() const {return m_FS;} - - wxObject* Parse(const wxString& source); - // You can simply call this method when you need parsed output. - // This method does these things: - // 1. call InitParser(source); - // 2. call DoParsing(); - // 3. call GetProduct(); (it's return value is then returned) - // 4. call DoneParser(); - - virtual void InitParser(const wxString& source); - // Sets the source. This must be called before running Parse() method. - virtual void DoneParser(); - // This must be called after Parse(). - - void DoParsing(int begin_pos, int end_pos); - inline void DoParsing() {DoParsing(0, m_Source.Length());}; - // Parses the m_Source from begin_pos to end_pos-1. - // (in noparams version it parses whole m_Source) - - virtual wxObject* GetProduct() = 0; - // Returns product of parsing - // Returned value is result of parsing of the part. The type of this result - // depends on internal representation in derived parser - // (see wxHtmlWinParser for details). - - virtual void AddTagHandler(wxHtmlTagHandler *handler); - // adds handler to the list & hash table of handlers. - - wxString* GetSource() {return &m_Source;} - - virtual wxList* GetTempData() {return NULL;} - // this method returns list of wxObjects that represents - // all data allocated by the parser. These can't be freeded - // by destructor because they must be valid as long as - // GetProduct's return value is valid - the caller must - // explicitly call delete MyParser -> GetTempData() to free - // the memory - // (this method always sets the list to delete its contents) - - protected: - - virtual void AddText(const char* txt) = 0; - // Adds text to the output. - // This is called from Parse() and must be overriden in derived classes. - // txt is not guaranteed to be only one word. It is largest continuous part of text - // (= not broken by tags) - // NOTE : using char* because of speed improvements - - virtual void AddTag(const wxHtmlTag& tag); - // Adds tag and proceeds it. Parse() may (and usually is) called from this method. - // This is called from Parse() and may be overriden. - // Default behavior is that it looks for proper handler in m_Handlers. The tag is - // ignored if no hander is found. - // Derived class is *responsible* for filling in m_Handlers table. -}; - - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlTagHandler -// This class (and derived classes) cooperates with wxHtmlParser. -// Each recognized tag is passed to handler which is capable -// of handling it. Each tag is handled in 3 steps: -// 1. Handler will modifies state of parser -// (using it's public methods) -// 2. Parser parses source between starting and ending tag -// 3. Handler restores original state of the parser -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlTagHandler : public wxObject -{ - DECLARE_ABSTRACT_CLASS(wxHtmlTagHandler) - - protected: - wxHtmlParser *m_Parser; - - public: - wxHtmlTagHandler() : wxObject () {m_Parser = NULL;}; - - virtual void SetParser(wxHtmlParser *parser) {m_Parser = parser;} - // Sets the parser. - // NOTE : each _instance_ of handler is guaranteed to be called - // only by one parser. This means you don't have to care about - // reentrancy. - - virtual wxString GetSupportedTags() = 0; - // Returns list of supported tags. The list is in uppercase and - // tags are delimited by ','. - // Example : "I,B,FONT,P" - // is capable of handling italic, bold, font and paragraph tags - - virtual bool HandleTag(const wxHtmlTag& tag) = 0; - // This is hadling core method. It does all the Steps 1-3. - // To process step 2, you can call ParseInner() - // returned value : TRUE if it called ParseInner(), - // FALSE etherwise - - protected: - void ParseInner(const wxHtmlTag& tag) {m_Parser -> DoParsing(tag.GetBeginPos(), tag.GetEndPos1());} - // parses input between beginning and ending tag. - // m_Parser must be set. -}; - - - - - -#endif // __HTMLPARSER_H__ - -#endif diff --git a/include/wx/html/htmltag.h b/include/wx/html/htmltag.h index 7b44f46e43..b24bdc0ec5 100644 --- a/include/wx/html/htmltag.h +++ b/include/wx/html/htmltag.h @@ -2,13 +2,14 @@ // Name: htmltag.h // Purpose: wxHtmlTag class (represents single tag) // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __HTMLTAG_H__ -#define __HTMLTAG_H__ +#ifndef _WX_HTMLTAG_H_ +#define _WX_HTMLTAG_H_ #ifdef __GNUG__ #pragma interface @@ -71,18 +72,13 @@ class WXDLLEXPORT wxHtmlTag : public wxObject { DECLARE_CLASS(wxHtmlTag) - private: - wxString m_Name, m_Params; - int m_Begin, m_End1, m_End2; - bool m_Ending; - public: wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache); // constructs wxHtmlTag object based on HTML tag. // The tag begins (with '<' character) at position pos in source // end_pos is position where parsing ends (usually end of document) - inline wxString GetName() const {return m_Name;}; + inline wxString GetName() const {return m_Name;} // Returns tag's name in uppercase. bool HasParam(const wxString& par) const; @@ -106,34 +102,40 @@ class WXDLLEXPORT wxHtmlTag : public wxObject // NOTE: unlike scanf family, this function only accepts // *one* parameter ! - inline const wxString& GetAllParams() const {return m_Params;}; + inline const wxString& GetAllParams() const {return m_Params;} // Returns string containing all params. - inline bool IsEnding() const {return m_Ending;}; + 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;}; + 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;}; + 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;}; + 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;}; + 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; +}; -#endif // __HTMLTAG_H__ #endif + +#endif // _WX_HTMLTAG_H_ + diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index cb339ec0b3..c7a8d35121 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -2,13 +2,14 @@ // Name: htmlwin.h // Purpose: wxHtmlWindow class for parsing & displaying HTML // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __HTMLWIN_H__ -#define __HTMLWIN_H__ +#ifndef _WX_HTMLWIN_H_ +#define _WX_HTMLWIN_H_ #ifdef __GNUG__ #pragma interface @@ -17,14 +18,14 @@ #include "wx/defs.h" #if wxUSE_HTML -#include -#include -#include -#include -#include -#include -#include -#include +#include "wx/window.h" +#include "wx/scrolwin.h" +#include "wx/config.h" +#include "wx/treectrl.h" +#include "wx/html/winpars.h" +#include "wx/html/htmlcell.h" +#include "wx/filesys.h" +#include "wx/html/htmlfilt.h" //-------------------------------------------------------------------------------- @@ -42,17 +43,17 @@ // item of history list class WXDLLEXPORT HtmlHistoryItem : public wxObject { - private: - wxString m_Page; - wxString m_Anchor; - int m_Pos; - public: HtmlHistoryItem(const wxString& p, const wxString& a) {m_Page = p, m_Anchor = a, m_Pos = 0;} int GetPos() const {return m_Pos;} void SetPos(int p) {m_Pos = p;} const wxString& GetPage() const {return m_Page;} const wxString& GetAnchor() const {return m_Anchor;} + + private: + wxString m_Page; + wxString m_Anchor; + int m_Pos; }; #undef WXDLLEXPORTLOCAL @@ -69,34 +70,6 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow { DECLARE_DYNAMIC_CLASS(wxHtmlWindow) - protected: - wxHtmlContainerCell *m_Cell; - // This is pointer to the first cell in parsed data. - // (Note: the first cell is usually top one = all other cells are sub-cells of this one) - wxHtmlWinParser *m_Parser; - // parser which is used to parse HTML input. - // Each wxHtmlWindow has it's own parser because sharing one global - // parser would be problematic (because of reentrancy) - wxString m_OpenedPage; - // contains name of actualy opened page or empty string if no page opened - wxString m_OpenedAnchor; - // contains name of current anchor within m_OpenedPage - wxFileSystem* m_FS; - // class for opening files (file system) - - wxFrame *m_RelatedFrame; - wxString m_TitleFormat; - int m_RelatedStatusBar; - // frame in which page title should be displayed & number of it's statusbar - // reserved for usage with this html window - - int m_Borders; - // borders (free space between text and window borders) - // defaults to 10 pixels. - - int m_Style; - - private: bool m_tmpMouseMoved; // a flag indicated if mouse moved @@ -215,14 +188,38 @@ class WXDLLEXPORT wxHtmlWindow : public wxScrolledWindow virtual wxHtmlFilter *GetDefaultFilter() {return new wxHtmlFilterPlainText;} // returns new filter (will be stored into m_DefaultFilter variable) - DECLARE_EVENT_TABLE() -}; + protected: + wxHtmlContainerCell *m_Cell; + // This is pointer to the first cell in parsed data. + // (Note: the first cell is usually top one = all other cells are sub-cells of this one) + wxHtmlWinParser *m_Parser; + // parser which is used to parse HTML input. + // Each wxHtmlWindow has it's own parser because sharing one global + // parser would be problematic (because of reentrancy) + wxString m_OpenedPage; + // contains name of actualy opened page or empty string if no page opened + wxString m_OpenedAnchor; + // contains name of current anchor within m_OpenedPage + wxFileSystem* m_FS; + // class for opening files (file system) + wxFrame *m_RelatedFrame; + wxString m_TitleFormat; + int m_RelatedStatusBar; + // frame in which page title should be displayed & number of it's statusbar + // reserved for usage with this html window + int m_Borders; + // borders (free space between text and window borders) + // defaults to 10 pixels. -#endif // __HTMLWIN_H__ + int m_Style; -#endif + DECLARE_EVENT_TABLE() +}; +#endif + +#endif // _WX_HTMLWIN_H_ diff --git a/include/wx/html/htmlwinparser.h b/include/wx/html/htmlwinparser.h deleted file mode 100644 index 84002b1a7e..0000000000 --- a/include/wx/html/htmlwinparser.h +++ /dev/null @@ -1,219 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlwinparser.h -// Purpose: wxHtmlWinParser class (parser to be used with wxHtmlWindow) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __HTMLWINPARSER_H__ -#define __HTMLWINPARSER_H__ - -#ifdef __GNUG__ -#pragma interface -#endif - -#include "wx/defs.h" -#if wxUSE_HTML - -#include -#include -#include - -class wxHtmlWinParser; -class wxHtmlWinTagHandler; -class wxHtmlTagsModule; - -//-------------------------------------------------------------------------------- -// wxHtmlWinParser -// This class is derived from wxHtmlParser and its mail goal -// is to parse HTML input so that it can be displayed in -// wxHtmlWindow. It uses special wxHtmlWinTagHandler. -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser -{ - DECLARE_DYNAMIC_CLASS(wxHtmlWinParser) - - friend class wxHtmlWindow; - - private: - wxWindow *m_Window; - // window we're parsing for - wxDC *m_DC; - // Device Context we're parsing for - static wxList m_Modules; - // list of tags modules (see wxHtmlTagsModule for details) - // This list is used to initialize m_Handlers member. - - wxHtmlContainerCell *m_Container; - // actual container. See Open/CloseContainer for details. - - int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not TRUE,FALSE but 1,0, we need it for indexing - int m_FontSize; /* -2 to +4, 0 is default */ - wxColour m_LinkColor; - wxColour m_ActualColor; - // basic font parameters. - wxString m_Link; - // actual hypertext link or empty string - bool m_UseLink; - // TRUE if m_Link is not empty - long m_CharHeight, m_CharWidth; - // average height of normal-sized text - int m_Align; - // actual alignment - - wxFont *m_FontsTable[2][2][2][2][7]; - // table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off - // state of these flags (from left to right): - // [bold][italic][underlined][fixed_size] - // last index is font size : from 0 to 7 (remapped from html sizes -2 to +4) - // Note : this table covers all possible combinations of fonts, but not - // all of them are used, so many items in table are usually NULL. - int m_FontsSizes[7]; - wxString m_FontFaceFixed, m_FontFaceNormal; - int m_ItalicModeFixed, m_ItalicModeNormal; - // html font sizes and faces of fixed and proportional fonts - - public: - wxHtmlWinParser() : wxHtmlParser() {wxHtmlWinParser(NULL);} - wxHtmlWinParser(wxWindow *wnd); - - virtual void InitParser(const wxString& source); - virtual void DoneParser(); - virtual wxObject* GetProduct(); - - virtual void SetDC(wxDC *dc) {m_DC = dc;} - // Set's the DC used for parsing. If SetDC() is not called, - // parsing won't proceed - wxDC *GetDC() {return m_DC;} - int GetCharHeight() const {return m_CharHeight;} - int GetCharWidth() const {return m_CharWidth;} - // NOTE : these functions do _not_ return _actual_ - // height/width. They return h/w of default font - // for this DC. If you want actual values, call - // GetDC() -> GetChar...() - wxWindow *GetWindow() {return m_Window;} - // returns associated wxWindow - - void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes); - // sets fonts to be used when displaying HTML page. - // *_italic_mode can be either wxSLANT or wxITALIC - - virtual wxList* GetTempData(); - - static void AddModule(wxHtmlTagsModule *module); - // Adds tags module. see wxHtmlTagsModule for details. - - // parsing-related methods. These methods are called by tag handlers: - wxHtmlContainerCell *GetContainer() const {return m_Container;} - // Returns pointer to actual container. Common use in tag handler is : - // m_WParser -> GetContainer() -> InsertCell(new ...); - wxHtmlContainerCell *OpenContainer(); - // opens new container. This container is sub-container of opened - // container. Sets GetContainer to newly created container - // and returns it. - wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); - // works like OpenContainer except that new container is not created - // but c is used. You can use this to directly set actual container - wxHtmlContainerCell *CloseContainer(); - // closes the container and sets actual Container to upper-level - // container - - int GetFontSize() const {return m_FontSize;} - void SetFontSize(int s) {m_FontSize = s;} - int GetFontBold() const {return m_FontBold;} - void SetFontBold(int x) {m_FontBold = x;} - int GetFontItalic() const {return m_FontItalic;} - void SetFontItalic(int x) {m_FontItalic = x;} - int GetFontUnderlined() const {return m_FontUnderlined;} - void SetFontUnderlined(int x) {m_FontUnderlined = x;} - int GetFontFixed() const {return m_FontFixed;} - void SetFontFixed(int x) {m_FontFixed = x;} - - int GetAlign() const {return m_Align;} - void SetAlign(int a) {m_Align = a;} - const wxColour& GetLinkColor() const {return m_LinkColor;} - void SetLinkColor(const wxColour& clr) {m_LinkColor = clr;} - const wxColour& GetActualColor() const {return m_ActualColor;} - void SetActualColor(const wxColour& clr) {m_ActualColor = clr;} - const wxString& GetLink() const {return m_Link;} - void SetLink(const wxString& link) {m_Link = link; m_UseLink = link.Length() > 0;} - - virtual wxFont* CreateCurrentFont(); - // creates font depending on m_Font* members. - // (note : it calls wxHtmlWindow's CreateCurrentFont...) - - protected: - virtual void AddText(const char *txt); - - private: - bool m_tmpLastWasSpace; - // temporary variable used by AddText -}; - - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlWinTagHandler -// This is basicly wxHtmlTagHandler except -// it is extended with protected member m_Parser pointing to -// the wxHtmlWinParser object -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler -{ - DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler) - - protected: - wxHtmlWinParser *m_WParser; - // same as m_Parser, but overcasted - - public: - wxHtmlWinTagHandler() : wxHtmlTagHandler() {}; - - virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;}; -}; - - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlTagsModule -// This is basic of dynamic tag handlers binding. -// The class provides methods for filling parser's handlers -// hash table. -// (See documentation for details) -//-------------------------------------------------------------------------------- - -class WXDLLEXPORT wxHtmlTagsModule : public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule) - - public: - wxHtmlTagsModule() : wxModule() {}; - - virtual bool OnInit(); - virtual void OnExit(); - - virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { } - // This is called by wxHtmlWinParser. - // The method must simply call parser->AddTagHandler(new ); - // for each handler - -}; - - - -#endif // __HTMLWINPARSER_H__ - -#endif - - - diff --git a/include/wx/html/m_templ.h b/include/wx/html/m_templ.h new file mode 100644 index 0000000000..a54725ee5f --- /dev/null +++ b/include/wx/html/m_templ.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: m_templ.h +// Purpose: Modules template file +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/* + +DESCRIPTION: +This is set of macros for easier writing of tag handlers. How to use it? +See mod_fonts.cpp for example... + +Attention! This is quite strange C++ bastard. Before using it, +I STRONGLY recommend reading and understanding these macros!! + +*/ + + +#ifndef _WX_M_TEMPL_H_ +#define _WX_M_TEMPL_H_ + +#include "wx/defs.h" +#if wxUSE_HTML + + +#ifdef __GNUG__ +#pragma interface +#pragma implementation +#endif + +#include + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + + + +#include "wx/html/winpars.h" + + +#define TAG_HANDLER_BEGIN(name,tags) \ + class HTML_Handler_##name : public wxHtmlWinTagHandler \ + { \ + public: \ + wxString GetSupportedTags() {return tags;} + + + +#define TAG_HANDLER_VARS \ + private: + +#define TAG_HANDLER_CONSTR(name) \ + public: \ + HTML_Handler_##name () : wxHtmlWinTagHandler() + + +#define TAG_HANDLER_PROC(varib) \ + public: \ + bool HandleTag(const wxHtmlTag& varib) + + + +#define TAG_HANDLER_END(name) \ + }; + + + + +#define TAGS_MODULE_BEGIN(name) \ + class HTML_Module##name : public wxHtmlTagsModule \ + { \ + DECLARE_DYNAMIC_CLASS(HTML_Module##name ) \ + public: \ + void FillHandlersTable(wxHtmlWinParser *parser) \ + { + + + + +#define TAGS_MODULE_ADD(handler) \ + parser -> AddTagHandler(new HTML_Handler_##handler); + + + + +#define TAGS_MODULE_END(name) \ + } \ + }; \ + IMPLEMENT_DYNAMIC_CLASS(HTML_Module##name , wxHtmlTagsModule) + + + +#endif +#endif diff --git a/include/wx/html/mod_templ.h b/include/wx/html/mod_templ.h deleted file mode 100644 index cb9f3fadb6..0000000000 --- a/include/wx/html/mod_templ.h +++ /dev/null @@ -1,102 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_templ.h -// Purpose: wxHtml tags module generic "template" -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -/* - -DESCRIPTION: -This is set of macros for easier writing of tag handlers. How to use it? -See mod_fonts.cpp for example... - -Attention! This is quite strange C++ bastard. Before using it, -I STRONGLY recommend reading and understanding these macros!! - -*/ - - -#ifndef __MOD_TEMPL_H__ -#define __MOD_TEMPL_H__ - -#include "wx/defs.h" -#if wxUSE_HTML - - -#ifdef __GNUG__ -#pragma interface -#pragma implementation -#endif - -#include - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - - - -#include - - -#define TAG_HANDLER_BEGIN(name,tags) \ - class HTML_Handler_##name : public wxHtmlWinTagHandler \ - { \ - public: \ - wxString GetSupportedTags() {return tags;} - - - -#define TAG_HANDLER_VARS \ - private: - -#define TAG_HANDLER_CONSTR(name) \ - public: \ - HTML_Handler_##name () : wxHtmlWinTagHandler() - - -#define TAG_HANDLER_PROC(varib) \ - public: \ - bool HandleTag(const wxHtmlTag& varib) - - - -#define TAG_HANDLER_END(name) \ - }; - - - - -#define TAGS_MODULE_BEGIN(name) \ - class HTML_Module##name : public wxHtmlTagsModule \ - { \ - DECLARE_DYNAMIC_CLASS(HTML_Module##name ) \ - public: \ - void FillHandlersTable(wxHtmlWinParser *parser) \ - { - - - - -#define TAGS_MODULE_ADD(handler) \ - parser -> AddTagHandler(new HTML_Handler_##handler); - - - - -#define TAGS_MODULE_END(name) \ - } \ - }; \ - IMPLEMENT_DYNAMIC_CLASS(HTML_Module##name , wxHtmlTagsModule) - - - -#endif -#endif \ No newline at end of file diff --git a/include/wx/html/winpars.h b/include/wx/html/winpars.h new file mode 100644 index 0000000000..5eca52c705 --- /dev/null +++ b/include/wx/html/winpars.h @@ -0,0 +1,218 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: winpars.h +// Purpose: wxHtmlWinParser class (parser to be used with wxHtmlWindow) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifndef _WX_WINPARS_H_ +#define _WX_WINPARS_H_ + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "wx/defs.h" +#if wxUSE_HTML + +#include "wx/module.h" +#include "wx/html/htmlpars.h" +#include "wx/html/htmlcell.h" + +class wxHtmlWinParser; +class wxHtmlWinTagHandler; +class wxHtmlTagsModule; + +//-------------------------------------------------------------------------------- +// wxHtmlWinParser +// This class is derived from wxHtmlParser and its mail goal +// is to parse HTML input so that it can be displayed in +// wxHtmlWindow. It uses special wxHtmlWinTagHandler. +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser +{ + DECLARE_DYNAMIC_CLASS(wxHtmlWinParser) + + friend class wxHtmlWindow; + + public: + wxHtmlWinParser() : wxHtmlParser() {wxHtmlWinParser(NULL);} + wxHtmlWinParser(wxWindow *wnd); + + virtual void InitParser(const wxString& source); + virtual void DoneParser(); + virtual wxObject* GetProduct(); + + virtual void SetDC(wxDC *dc) {m_DC = dc;} + // Set's the DC used for parsing. If SetDC() is not called, + // parsing won't proceed + wxDC *GetDC() {return m_DC;} + int GetCharHeight() const {return m_CharHeight;} + int GetCharWidth() const {return m_CharWidth;} + // NOTE : these functions do _not_ return _actual_ + // height/width. They return h/w of default font + // for this DC. If you want actual values, call + // GetDC() -> GetChar...() + wxWindow *GetWindow() {return m_Window;} + // returns associated wxWindow + + void SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes); + // sets fonts to be used when displaying HTML page. + // *_italic_mode can be either wxSLANT or wxITALIC + + virtual wxList* GetTempData(); + + static void AddModule(wxHtmlTagsModule *module); + // Adds tags module. see wxHtmlTagsModule for details. + + // parsing-related methods. These methods are called by tag handlers: + wxHtmlContainerCell *GetContainer() const {return m_Container;} + // Returns pointer to actual container. Common use in tag handler is : + // m_WParser -> GetContainer() -> InsertCell(new ...); + wxHtmlContainerCell *OpenContainer(); + // opens new container. This container is sub-container of opened + // container. Sets GetContainer to newly created container + // and returns it. + wxHtmlContainerCell *SetContainer(wxHtmlContainerCell *c); + // works like OpenContainer except that new container is not created + // but c is used. You can use this to directly set actual container + wxHtmlContainerCell *CloseContainer(); + // closes the container and sets actual Container to upper-level + // container + + int GetFontSize() const {return m_FontSize;} + void SetFontSize(int s) {m_FontSize = s;} + int GetFontBold() const {return m_FontBold;} + void SetFontBold(int x) {m_FontBold = x;} + int GetFontItalic() const {return m_FontItalic;} + void SetFontItalic(int x) {m_FontItalic = x;} + int GetFontUnderlined() const {return m_FontUnderlined;} + void SetFontUnderlined(int x) {m_FontUnderlined = x;} + int GetFontFixed() const {return m_FontFixed;} + void SetFontFixed(int x) {m_FontFixed = x;} + + int GetAlign() const {return m_Align;} + void SetAlign(int a) {m_Align = a;} + const wxColour& GetLinkColor() const {return m_LinkColor;} + void SetLinkColor(const wxColour& clr) {m_LinkColor = clr;} + const wxColour& GetActualColor() const {return m_ActualColor;} + void SetActualColor(const wxColour& clr) {m_ActualColor = clr;} + const wxString& GetLink() const {return m_Link;} + void SetLink(const wxString& link) {m_Link = link; m_UseLink = link.Length() > 0;} + + virtual wxFont* CreateCurrentFont(); + // creates font depending on m_Font* members. + // (note : it calls wxHtmlWindow's CreateCurrentFont...) + + protected: + virtual void AddText(const char *txt); + + private: + bool m_tmpLastWasSpace; + // temporary variable used by AddText + wxWindow *m_Window; + // window we're parsing for + wxDC *m_DC; + // Device Context we're parsing for + static wxList m_Modules; + // list of tags modules (see wxHtmlTagsModule for details) + // This list is used to initialize m_Handlers member. + + wxHtmlContainerCell *m_Container; + // actual container. See Open/CloseContainer for details. + + int m_FontBold, m_FontItalic, m_FontUnderlined, m_FontFixed; // this is not TRUE,FALSE but 1,0, we need it for indexing + int m_FontSize; /* -2 to +4, 0 is default */ + wxColour m_LinkColor; + wxColour m_ActualColor; + // basic font parameters. + wxString m_Link; + // actual hypertext link or empty string + bool m_UseLink; + // TRUE if m_Link is not empty + long m_CharHeight, m_CharWidth; + // average height of normal-sized text + int m_Align; + // actual alignment + + wxFont *m_FontsTable[2][2][2][2][7]; + // table of loaded fonts. 1st four indexes are 0 or 1, depending on on/off + // state of these flags (from left to right): + // [bold][italic][underlined][fixed_size] + // last index is font size : from 0 to 7 (remapped from html sizes -2 to +4) + // Note : this table covers all possible combinations of fonts, but not + // all of them are used, so many items in table are usually NULL. + int m_FontsSizes[7]; + wxString m_FontFaceFixed, m_FontFaceNormal; + int m_ItalicModeFixed, m_ItalicModeNormal; + // html font sizes and faces of fixed and proportional fonts +}; + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlWinTagHandler +// This is basicly wxHtmlTagHandler except +// it is extended with protected member m_Parser pointing to +// the wxHtmlWinParser object +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlWinTagHandler : public wxHtmlTagHandler +{ + DECLARE_ABSTRACT_CLASS(wxHtmlWinTagHandler) + + public: + wxHtmlWinTagHandler() : wxHtmlTagHandler() {}; + + virtual void SetParser(wxHtmlParser *parser) {wxHtmlTagHandler::SetParser(parser); m_WParser = (wxHtmlWinParser*) parser;}; + + protected: + wxHtmlWinParser *m_WParser; + // same as m_Parser, but overcasted +}; + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlTagsModule +// This is basic of dynamic tag handlers binding. +// The class provides methods for filling parser's handlers +// hash table. +// (See documentation for details) +//-------------------------------------------------------------------------------- + +class WXDLLEXPORT wxHtmlTagsModule : public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxHtmlTagsModule) + + public: + wxHtmlTagsModule() : wxModule() {}; + + virtual bool OnInit(); + virtual void OnExit(); + + virtual void FillHandlersTable(wxHtmlWinParser * WXUNUSED(parser)) { } + // This is called by wxHtmlWinParser. + // The method must simply call parser->AddTagHandler(new ); + // for each handler + +}; + + +#endif + +#endif // _WX_WINPARS_H_ + + + + diff --git a/include/wx/wxhtml.h b/include/wx/wxhtml.h index c4cf4f54e3..2489dbc0e3 100644 --- a/include/wx/wxhtml.h +++ b/include/wx/wxhtml.h @@ -2,12 +2,13 @@ // Name: wxhtml.h // Purpose: wxHTML library for wxWindows // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// -#ifndef __WXHTML_H__ -#define __WXHTML_H__ +#ifndef _WX_HTML_H_ +#define _WX_HTML_H_ #ifdef __GNUG__ #pragma interface @@ -17,9 +18,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include diff --git a/samples/html/widget/widget.cpp b/samples/html/widget/widget.cpp index 74fa22ff81..c2aaf87f3b 100644 --- a/samples/html/widget/widget.cpp +++ b/samples/html/widget/widget.cpp @@ -36,7 +36,7 @@ TAG HANDER FOR 'MYBIND' TAG */ -#include +#include TAG_HANDLER_BEGIN(MYBIND, "MYBIND") diff --git a/src/html/helpctrl.cpp b/src/html/helpctrl.cpp index 853dbc343a..e25e606060 100644 --- a/src/html/helpctrl.cpp +++ b/src/html/helpctrl.cpp @@ -4,14 +4,13 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "helpctrl.h" +#pragma implementation #endif // For compilers that support precompilation, includes "wx.h". @@ -61,7 +60,7 @@ bool wxHtmlHelpController::AddBook(const wxString& book, bool show_wait_msg) { wxBusyCursor cur; #if wxUSE_BUSYINFO - wxBusyInfo* busy; + wxBusyInfo* busy = NULL; wxString info; if (show_wait_msg) { info.Printf(_("Adding book %s"), book.c_str()); diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index df9d785d79..fb7f6cf871 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -4,14 +4,13 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "helpdata.h" +#pragma implementation #endif // For compilers that support precompilation, includes "wx.h". @@ -33,7 +32,7 @@ #include "wx/tokenzr.h" #include "wx/wfstream.h" #include "wx/busyinfo.h" -#include "wx/html/htmlparser.h" +#include "wx/html/htmlpars.h" #include "wx/html/htmldefs.h" #include "wx/arrimpl.cpp" diff --git a/src/html/helpfrm.cpp b/src/html/helpfrm.cpp index c74e46c0a9..4c69ea484e 100644 --- a/src/html/helpfrm.cpp +++ b/src/html/helpfrm.cpp @@ -4,14 +4,13 @@ // Notes: Based on htmlhelp.cpp, implementing a monolithic // HTML Help controller class, by Vaclav Slavik // Author: Harm van der Heijden and Vaclav Slavik -// Created: -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Harm van der Heijden and Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "helpfrm.h" +#pragma implementation #endif // For compilers that support precompilation, includes "wx.h". diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 8ad6774f34..4e58006621 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -2,12 +2,13 @@ // Name: htmlcell.cpp // Purpose: wxHtmlCell - basic element of HTML output // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation "htmlcell.h" +#pragma implementation #endif #include "wx/wxprec.h" diff --git a/src/html/htmlfilt.cpp b/src/html/htmlfilt.cpp new file mode 100644 index 0000000000..daddda164a --- /dev/null +++ b/src/html/htmlfilt.cpp @@ -0,0 +1,174 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlfilt.cpp +// Purpose: wxHtmlFilter - input filter for translating into HTML format +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/wxprec.h" + +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include "wx/wx.h" +#endif + +#include "wx/html/htmlfilt.h" +#include "wx/html/htmlwin.h" + + +/* + +There is code for several default filters: + +*/ + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlFilter, wxObject) + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// filter for text/plain or uknown +//-------------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterPlainText, wxHtmlFilter) + +bool wxHtmlFilterPlainText::CanRead(const wxFSFile& WXUNUSED(file)) const +{ + return TRUE; +} + + + +wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + char *src; + wxString doc, doc2; + + if (s == NULL) return wxEmptyString; + src = new char[s -> GetSize()+1]; + src[s -> GetSize()] = 0; + s -> Read(src, s -> GetSize()); + doc = src; + delete [] src; + + doc.Replace("<", "<", TRUE); + doc.Replace(">", ">", TRUE); + doc2 = "
\n" + doc + "\n
"; + return doc2; +} + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterImage +// filter for image/* +//-------------------------------------------------------------------------------- + +class wxHtmlFilterImage : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterImage) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter) + + + +bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const +{ + return (file.GetMimeType().Left(6) == "image/"); +} + + + +wxString wxHtmlFilterImage::ReadFile(const wxFSFile& file) const +{ + return (""); +} + + + + +//-------------------------------------------------------------------------------- +// wxHtmlFilterPlainText +// filter for text/plain or uknown +//-------------------------------------------------------------------------------- + +class wxHtmlFilterHTML : public wxHtmlFilter +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterHTML) + + public: + virtual bool CanRead(const wxFSFile& file) const; + virtual wxString ReadFile(const wxFSFile& file) const; +}; + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterHTML, wxHtmlFilter) + +bool wxHtmlFilterHTML::CanRead(const wxFSFile& file) const +{ +// return (file.GetMimeType() == "text/html"); +// This is true in most case but some page can return: +// "text/html; char-encoding=...." +// So we use Find instead + return (file.GetMimeType().Find(_T("text/html")) == 0); +} + + + +wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const +{ + wxInputStream *s = file.GetStream(); + char *src; + wxString doc; + + if (s == NULL) return wxEmptyString; + src = new char[s -> GetSize() + 1]; + src[s -> GetSize()] = 0; + s -> Read(src, s -> GetSize()); + doc = src; + delete[] src; + + return doc; +} + + + + +///// Module: + +class wxHtmlFilterModule : public wxModule +{ + DECLARE_DYNAMIC_CLASS(wxHtmlFilterModule) + + public: + virtual bool OnInit() + { + wxHtmlWindow::AddFilter(new wxHtmlFilterHTML); + wxHtmlWindow::AddFilter(new wxHtmlFilterImage); + return TRUE; + } + virtual void OnExit() {} +}; + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterModule, wxModule) + +#endif diff --git a/src/html/htmlfilter.cpp b/src/html/htmlfilter.cpp deleted file mode 100644 index fbe7ba9bfa..0000000000 --- a/src/html/htmlfilter.cpp +++ /dev/null @@ -1,173 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: filter.cpp -// Purpose: wxHtmlFilter - input filter for translating into HTML format -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifdef __GNUG__ -#pragma implementation "htmlfilter.h" -#endif - -#include "wx/wxprec.h" - -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include "wx/wx.h" -#endif - -#include "wx/html/htmlfilter.h" -#include "wx/html/htmlwin.h" - - -/* - -There is code for several default filters: - -*/ - -IMPLEMENT_ABSTRACT_CLASS(wxHtmlFilter, wxObject) - -//-------------------------------------------------------------------------------- -// wxHtmlFilterPlainText -// filter for text/plain or uknown -//-------------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterPlainText, wxHtmlFilter) - -bool wxHtmlFilterPlainText::CanRead(const wxFSFile& WXUNUSED(file)) const -{ - return TRUE; -} - - - -wxString wxHtmlFilterPlainText::ReadFile(const wxFSFile& file) const -{ - wxInputStream *s = file.GetStream(); - char *src; - wxString doc, doc2; - - if (s == NULL) return wxEmptyString; - src = new char[s -> GetSize()+1]; - src[s -> GetSize()] = 0; - s -> Read(src, s -> GetSize()); - doc = src; - delete [] src; - - doc.Replace("<", "<", TRUE); - doc.Replace(">", ">", TRUE); - doc2 = "
\n" + doc + "\n
"; - return doc2; -} - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlFilterImage -// filter for image/* -//-------------------------------------------------------------------------------- - -class wxHtmlFilterImage : public wxHtmlFilter -{ - DECLARE_DYNAMIC_CLASS(wxHtmlFilterImage) - - public: - virtual bool CanRead(const wxFSFile& file) const; - virtual wxString ReadFile(const wxFSFile& file) const; -}; - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterImage, wxHtmlFilter) - - - -bool wxHtmlFilterImage::CanRead(const wxFSFile& file) const -{ - return (file.GetMimeType().Left(6) == "image/"); -} - - - -wxString wxHtmlFilterImage::ReadFile(const wxFSFile& file) const -{ - return (""); -} - - - - -//-------------------------------------------------------------------------------- -// wxHtmlFilterPlainText -// filter for text/plain or uknown -//-------------------------------------------------------------------------------- - -class wxHtmlFilterHTML : public wxHtmlFilter -{ - DECLARE_DYNAMIC_CLASS(wxHtmlFilterHTML) - - public: - virtual bool CanRead(const wxFSFile& file) const; - virtual wxString ReadFile(const wxFSFile& file) const; -}; - - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterHTML, wxHtmlFilter) - -bool wxHtmlFilterHTML::CanRead(const wxFSFile& file) const -{ -// return (file.GetMimeType() == "text/html"); -// This is true in most case but some page can return: -// "text/html; char-encoding=...." -// So we use Find instead - return (file.GetMimeType().Find(_T("text/html")) == 0); -} - - - -wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const -{ - wxInputStream *s = file.GetStream(); - char *src; - wxString doc; - - if (s == NULL) return wxEmptyString; - src = new char[s -> GetSize() + 1]; - src[s -> GetSize()] = 0; - s -> Read(src, s -> GetSize()); - doc = src; - delete[] src; - - return doc; -} - - - - -///// Module: - -class wxHtmlFilterModule : public wxModule -{ - DECLARE_DYNAMIC_CLASS(wxHtmlFilterModule) - - public: - virtual bool OnInit() - { - wxHtmlWindow::AddFilter(new wxHtmlFilterHTML); - wxHtmlWindow::AddFilter(new wxHtmlFilterImage); - return TRUE; - } - virtual void OnExit() {} -}; - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlFilterModule, wxModule) - -#endif diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp new file mode 100644 index 0000000000..8692fccc95 --- /dev/null +++ b/src/html/htmlpars.cpp @@ -0,0 +1,170 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: htmlpars.cpp +// Purpose: wxHtmlParser class (generic parser) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + +#include "wx/tokenzr.h" +#include "wx/wfstream.h" +#include "wx/url.h" +#include "wx/html/htmldefs.h" +#include "wx/html/htmlpars.h" + + + +//----------------------------------------------------------------------------- +// wxHtmlParser +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject) + + +wxObject* wxHtmlParser::Parse(const wxString& source) +{ + wxObject *result; + + InitParser(source); + DoParsing(); + result = GetProduct(); + DoneParser(); + return result; +} + + + +void wxHtmlParser::InitParser(const wxString& source) +{ + m_Source = source; + m_Cache = new wxHtmlTagsCache(m_Source); +} + + + +void wxHtmlParser::DoneParser() +{ + delete m_Cache; + m_Cache = NULL; +} + + + +#define HTML_MAX_BUFLEN 1024 + +void wxHtmlParser::DoParsing(int begin_pos, int end_pos) +{ + char temp[HTML_BUFLEN], c; + int i; + int templen; + + templen = 0; + i = begin_pos; + + while (i < end_pos) { + c = m_Source[i]; + + // continue building word: + if (c != '<') { + temp[templen++] = c; + if (templen == HTML_BUFLEN-1) { + temp[templen] = 0; + AddText(temp); + templen = 0; + } + i++; + } + + else if (c == '<') { + wxHtmlTag tag(m_Source, i, end_pos, m_Cache); + + if (templen) { + temp[templen] = 0; + AddText(temp); + templen = 0; + } + AddTag(tag); + if (tag.HasEnding()) i = tag.GetEndPos2(); + else i = tag.GetBeginPos(); + } + } + + if (templen) { // last word of block :-( + temp[templen] = 0; + AddText(temp); + } +} + + + +void wxHtmlParser::AddTag(const wxHtmlTag& tag) +{ + wxHtmlTagHandler *h; + bool inner = FALSE; + + h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName()); + if (h) + inner = h -> HandleTag(tag); + if (!inner) { + if (tag.HasEnding()) + DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); + } +} + + + +void wxHtmlParser::AddTagHandler(wxHtmlTagHandler *handler) +{ + wxString s(handler -> GetSupportedTags()); + wxStringTokenizer tokenizer(s, ", "); + +#if (wxVERSION_NUMBER < 2100) + while (tokenizer.HasMoreToken()) +#else + while (tokenizer.HasMoreTokens()) +#endif + m_HandlersHash.Put(tokenizer.NextToken(), handler); + + if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND) + m_HandlersList.Append(handler); + + handler -> SetParser(this); +} + + + +wxHtmlParser::~wxHtmlParser() +{ + m_HandlersHash.Clear(); + m_HandlersList.DeleteContents(TRUE); + m_HandlersList.Clear(); +} + + + +//----------------------------------------------------------------------------- +// wxHtmlTagHandler +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlTagHandler,wxObject) + +#endif \ No newline at end of file diff --git a/src/html/htmlparser.cpp b/src/html/htmlparser.cpp deleted file mode 100644 index ff72c7d6cb..0000000000 --- a/src/html/htmlparser.cpp +++ /dev/null @@ -1,169 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlparser.cpp -// Purpose: wxHtmlParser class (generic parser) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include "wx/defs.h" -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - -#include -#include -#include -#include -#include - - - -//----------------------------------------------------------------------------- -// wxHtmlParser -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject) - - -wxObject* wxHtmlParser::Parse(const wxString& source) -{ - wxObject *result; - - InitParser(source); - DoParsing(); - result = GetProduct(); - DoneParser(); - return result; -} - - - -void wxHtmlParser::InitParser(const wxString& source) -{ - m_Source = source; - m_Cache = new wxHtmlTagsCache(m_Source); -} - - - -void wxHtmlParser::DoneParser() -{ - delete m_Cache; - m_Cache = NULL; -} - - - -#define HTML_MAX_BUFLEN 1024 - -void wxHtmlParser::DoParsing(int begin_pos, int end_pos) -{ - char temp[HTML_BUFLEN], c; - int i; - int templen; - - templen = 0; - i = begin_pos; - - while (i < end_pos) { - c = m_Source[i]; - - // continue building word: - if (c != '<') { - temp[templen++] = c; - if (templen == HTML_BUFLEN-1) { - temp[templen] = 0; - AddText(temp); - templen = 0; - } - i++; - } - - else if (c == '<') { - wxHtmlTag tag(m_Source, i, end_pos, m_Cache); - - if (templen) { - temp[templen] = 0; - AddText(temp); - templen = 0; - } - AddTag(tag); - if (tag.HasEnding()) i = tag.GetEndPos2(); - else i = tag.GetBeginPos(); - } - } - - if (templen) { // last word of block :-( - temp[templen] = 0; - AddText(temp); - } -} - - - -void wxHtmlParser::AddTag(const wxHtmlTag& tag) -{ - wxHtmlTagHandler *h; - bool inner = FALSE; - - h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName()); - if (h) - inner = h -> HandleTag(tag); - if (!inner) { - if (tag.HasEnding()) - DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); - } -} - - - -void wxHtmlParser::AddTagHandler(wxHtmlTagHandler *handler) -{ - wxString s(handler -> GetSupportedTags()); - wxStringTokenizer tokenizer(s, ", "); - -#if (wxVERSION_NUMBER < 2100) - while (tokenizer.HasMoreToken()) -#else - while (tokenizer.HasMoreTokens()) -#endif - m_HandlersHash.Put(tokenizer.NextToken(), handler); - - if (m_HandlersList.IndexOf(handler) == wxNOT_FOUND) - m_HandlersList.Append(handler); - - handler -> SetParser(this); -} - - - -wxHtmlParser::~wxHtmlParser() -{ - m_HandlersHash.Clear(); - m_HandlersList.DeleteContents(TRUE); - m_HandlersList.Clear(); -} - - - -//----------------------------------------------------------------------------- -// wxHtmlTagHandler -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxHtmlTagHandler,wxObject) - -#endif \ No newline at end of file diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index e173271235..24a45f4ca0 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -2,6 +2,7 @@ // Name: htmltag.cpp // Purpose: wxHtmlTag class (represents single tag) // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -24,7 +25,7 @@ #include #endif -#include +#include "wx/html/htmltag.h" #include // for vsscanf #include diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index f1efda140c..946aa06c1a 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -2,6 +2,7 @@ // Name: htmlwin.cpp // Purpose: wxHtmlWindow class for parsing & displaying HTML (implementation) // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// @@ -24,9 +25,9 @@ #include #endif -#include +#include "wx/html/htmlwin.h" -#include +#include "wx/html/forcelnk.h" diff --git a/src/html/htmlwinparser.cpp b/src/html/htmlwinparser.cpp deleted file mode 100644 index efc1d0d198..0000000000 --- a/src/html/htmlwinparser.cpp +++ /dev/null @@ -1,288 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: htmlwinparser.cpp -// Purpose: wxHtmlParser class (generic parser) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include "wx/defs.h" -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - -#include -#include -#include - - -//----------------------------------------------------------------------------- -// wxHtmlWinParser -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinParser,wxHtmlParser) - -wxList wxHtmlWinParser::m_Modules; - -wxHtmlWinParser::wxHtmlWinParser(wxWindow *wnd) : wxHtmlParser() -{ - m_Window = wnd; - m_Container = NULL; - m_DC = NULL; - m_CharHeight = m_CharWidth = 0; - m_UseLink = FALSE; - - { - int i, j, k, l, m; - for (i = 0; i < 2; i++) - for (j = 0; j < 2; j++) - for (k = 0; k < 2; k++) - for (l = 0; l < 2; l++) - for (m = 0; m < 7; m++) - m_FontsTable[i][j][k][l][m] = NULL; -#ifdef __WXMSW__ - int default_sizes[7] = {7, 8, 10, 12, 16, 22, 30}; -#else - int default_sizes[7] = {10, 12, 14, 16, 19, 24, 32}; -#endif - SetFonts("", wxSLANT, "", wxSLANT, default_sizes); - } - - // fill in wxHtmlParser's tables: - wxNode *node = m_Modules.GetFirst(); - while (node){ - wxHtmlTagsModule *mod = (wxHtmlTagsModule*) node -> GetData(); - mod -> FillHandlersTable(this); - node = node -> GetNext(); - } -} - - - -void wxHtmlWinParser::AddModule(wxHtmlTagsModule *module) -{ - m_Modules.Append(module); -} - - - -void wxHtmlWinParser::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes) -{ - for (int i = 0; i < 7; i++) m_FontsSizes[i] = sizes[i]; - m_FontFaceFixed = fixed_face; - m_FontFaceNormal = normal_face; - m_ItalicModeFixed = fixed_italic_mode; - m_ItalicModeNormal = normal_italic_mode; -} - - - -void wxHtmlWinParser::InitParser(const wxString& source) -{ - wxHtmlParser::InitParser(source); - wxASSERT_MSG(m_DC != NULL, _("no DC assigned to wxHtmlWinParser!!")); - - m_FontBold = m_FontItalic = m_FontUnderlined = m_FontFixed = FALSE; - m_FontSize = 0; - CreateCurrentFont(); // we're selecting default font into - m_DC -> GetTextExtent("H", &m_CharWidth, &m_CharHeight); - /* NOTE : we're not using GetCharWidth/Height() because - of differences under X and win - */ - - m_Link = ""; - m_LinkColor.Set(0, 0, 0xFF); - m_ActualColor.Set(0, 0, 0); - m_Align = HTML_ALIGN_LEFT; - m_tmpLastWasSpace = FALSE; - - OpenContainer(); - - OpenContainer(); - m_Container -> InsertCell(new wxHtmlColourCell(m_ActualColor)); - m_Container -> InsertCell(new wxHtmlFontCell(CreateCurrentFont())); -} - - - -void wxHtmlWinParser::DoneParser() -{ - m_Container = NULL; - wxHtmlParser::DoneParser(); -} - - - -wxObject* wxHtmlWinParser::GetProduct() -{ - wxHtmlContainerCell *top; - - CloseContainer(); - OpenContainer(); - GetContainer() -> SetIndent(m_CharHeight, HTML_INDENT_TOP); - top = m_Container; - while (top -> GetParent()) top = top -> GetParent(); - return top; -} - - - -wxList* wxHtmlWinParser::GetTempData() -{ - int i, j, k, l, m; - wxFont *f; - wxList *lst = wxHtmlParser::GetTempData(); - - if (lst == NULL) lst = new wxList; - lst -> DeleteContents(TRUE); - - for (i = 0; i < 2; i++) - for (j = 0; j < 2; j++) - for (k = 0; k < 2; k++) - for (l = 0; l < 2; l++) - for (m = 0; m < 7; m++) { - f = m_FontsTable[i][j][k][l][m]; - if (f) lst -> Append(f); - } - return lst; -} - - - -void wxHtmlWinParser::AddText(const char* txt) -{ - wxHtmlCell *c; - int i = 0, x, lng = strlen(txt); - char temp[HTML_BUFLEN]; - register char d; - int templen = 0; - - if (m_tmpLastWasSpace) { - while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++; - } - - while (i < lng) { - x = 0; - d = temp[templen++] = txt[i]; - if ((d == '\n') || (d == '\r') || (d == ' ') || (d == '\t')) { - i++, x++; - while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++, x++; - } - else i++; - - if (x) { - temp[templen-1] = ' '; - temp[templen] = 0; - templen = 0; - c = new wxHtmlWordCell(temp, *(GetDC())); - if (m_UseLink) c -> SetLink(m_Link); - m_Container -> InsertCell(c); - m_tmpLastWasSpace = TRUE; - } - } - if (templen) { - temp[templen] = 0; - c = new wxHtmlWordCell(temp, *(GetDC())); - if (m_UseLink) c -> SetLink(m_Link); - m_Container -> InsertCell(c); - m_tmpLastWasSpace = FALSE; - } -} - - - -wxHtmlContainerCell* wxHtmlWinParser::OpenContainer() -{ - m_Container = new wxHtmlContainerCell(m_Container); - m_Container -> SetAlignHor(m_Align); - m_tmpLastWasSpace = TRUE; - /* to avoid space being first character in paragraph */ - return m_Container; -} - - - -wxHtmlContainerCell* wxHtmlWinParser::SetContainer(wxHtmlContainerCell *c) -{ - m_tmpLastWasSpace = TRUE; - /* to avoid space being first character in paragraph */ - return m_Container = c; -} - - - -wxHtmlContainerCell* wxHtmlWinParser::CloseContainer() -{ - m_Container = m_Container -> GetParent(); - return m_Container; -} - - - -wxFont* wxHtmlWinParser::CreateCurrentFont() -{ - int fb = GetFontBold(), - fi = GetFontItalic(), - fu = GetFontUnderlined(), - ff = GetFontFixed(), - fs = GetFontSize() + 2 /*remap from <-2;4> to <0;7>*/ ; - - if (m_FontsTable[fb][fi][fu][ff][fs] == NULL) { - m_FontsTable[fb][fi][fu][ff][fs] = - //wxTheFontList -> FindOrCreateFont( - new wxFont( - m_FontsSizes[fs], - ff ? wxMODERN : wxSWISS, - fi ? (ff ? m_ItalicModeFixed : m_ItalicModeNormal) : wxNORMAL, - fb ? wxBOLD : wxNORMAL, - fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal); - } - m_DC -> SetFont(*(m_FontsTable[fb][fi][fu][ff][fs])); - return (m_FontsTable[fb][fi][fu][ff][fs]); -} - - - - -//----------------------------------------------------------------------------- -// wxHtmlWinTagHandler -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxHtmlWinTagHandler, wxHtmlTagHandler) - - - -//----------------------------------------------------------------------------- -// wxHtmlTagsModule -//----------------------------------------------------------------------------- - - -IMPLEMENT_DYNAMIC_CLASS(wxHtmlTagsModule, wxModule) - - -bool wxHtmlTagsModule::OnInit() -{ - wxHtmlWinParser::AddModule(this); - return TRUE; -} - - - -void wxHtmlTagsModule::OnExit() -{ -} - -#endif \ No newline at end of file diff --git a/src/html/m_fonts.cpp b/src/html/m_fonts.cpp new file mode 100644 index 0000000000..2919a029b4 --- /dev/null +++ b/src/html/m_fonts.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_fonts.cpp +// Purpose: wxHtml module for fonts & colors of fonts +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +FORCE_LINK_ME(mod_fonts) + + +TAG_HANDLER_BEGIN(FONT, "FONT") + + TAG_HANDLER_PROC(tag) + { + wxColour oldclr = m_WParser -> GetActualColor(); + int oldsize = m_WParser -> GetFontSize(); + + if (tag.HasParam("COLOR")) { + unsigned long tmp = 0; + wxColour clr; + if (tag.ScanParam("COLOR", "#%lX", &tmp) == 1) { + clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); + m_WParser -> SetActualColor(clr); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr)); + } + } + + if (tag.HasParam("SIZE")) { + long tmp = 0; + if (tag.ScanParam("SIZE", "%li", &tmp) == 1) { + m_WParser -> SetFontSize(oldsize+tmp); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + } + } + + ParseInner(tag); + + if (oldclr != m_WParser -> GetActualColor()) { + m_WParser -> SetActualColor(oldclr); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr)); + } + if (oldsize != m_WParser -> GetFontSize()) { + m_WParser -> SetFontSize(oldsize); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + } + return TRUE; + } + +TAG_HANDLER_END(FONT) + + +TAG_HANDLER_BEGIN(FACES, "U,I,B,TT") + + TAG_HANDLER_PROC(tag) + { + int fixed = m_WParser -> GetFontFixed(), + italic = m_WParser -> GetFontItalic(), + underlined = m_WParser -> GetFontUnderlined(), + bold = m_WParser -> GetFontBold(); + + if (tag.GetName() == "U") + m_WParser -> SetFontUnderlined(TRUE); + else if (tag.GetName() == "B") + m_WParser -> SetFontBold(TRUE); + else if (tag.GetName() == "I") + m_WParser -> SetFontItalic(TRUE); + else + m_WParser -> SetFontFixed(TRUE); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + + ParseInner(tag); + + m_WParser -> SetFontUnderlined(underlined); + m_WParser -> SetFontBold(bold); + m_WParser -> SetFontItalic(italic); + m_WParser -> SetFontFixed(fixed); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + return TRUE; + } + +TAG_HANDLER_END(FACES) + + + + + +TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6") + + TAG_HANDLER_PROC(tag) + { + int old_size, old_b, old_i, old_u, old_f, old_al; + wxHtmlContainerCell *c; + + old_size = m_WParser -> GetFontSize(); + old_b = m_WParser -> GetFontBold(); + old_i = m_WParser -> GetFontItalic(); + old_u = m_WParser -> GetFontUnderlined(); + old_f = m_WParser -> GetFontFixed(); + old_al = m_WParser -> GetAlign(); + + m_WParser -> SetFontBold(TRUE); + m_WParser -> SetFontItalic(FALSE); + m_WParser -> SetFontUnderlined(FALSE); + m_WParser -> SetFontFixed(FALSE); + + if (tag.GetName() == "H1") + m_WParser -> SetFontSize(+4); + else if (tag.GetName() == "H2") + m_WParser -> SetFontSize(+3); + else if (tag.GetName() == "H3") + m_WParser -> SetFontSize(+2); + else if (tag.GetName() == "H4") { + m_WParser -> SetFontSize(+2); + m_WParser -> SetFontItalic(TRUE); + m_WParser -> SetFontBold(FALSE); + } + else if (tag.GetName() == "H5") + m_WParser -> SetFontSize(+1); + else if (tag.GetName() == "H6") { + m_WParser -> SetFontSize(+1); + m_WParser -> SetFontItalic(TRUE); + m_WParser -> SetFontBold(FALSE); + } + + c = m_WParser -> GetContainer(); + if (c -> GetFirstCell()) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + c = m_WParser -> GetContainer(); + } + c = m_WParser -> GetContainer(); + + c -> SetAlign(tag); + c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); + m_WParser -> SetAlign(c -> GetAlignHor()); + + ParseInner(tag); + + m_WParser -> SetFontSize(old_size); + m_WParser -> SetFontBold(old_b); + m_WParser -> SetFontItalic(old_i); + m_WParser -> SetFontUnderlined(old_u); + m_WParser -> SetFontFixed(old_f); + m_WParser -> SetAlign(old_al); + + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + c = m_WParser -> GetContainer(); + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); + + return TRUE; + } + +TAG_HANDLER_END(Hx) + + + + +TAGS_MODULE_BEGIN(Fonts) + + TAGS_MODULE_ADD(FONT) + TAGS_MODULE_ADD(FACES) + TAGS_MODULE_ADD(Hx) + +TAGS_MODULE_END(Fonts) + + +#endif diff --git a/src/html/m_hline.cpp b/src/html/m_hline.cpp new file mode 100644 index 0000000000..76130b09d3 --- /dev/null +++ b/src/html/m_hline.cpp @@ -0,0 +1,104 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_hline.cpp +// Purpose: wxHtml module for horizontal line (HR tag) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + + +#include "wx/defs.h" +#if wxUSE_HTML +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +#include "wx/html/htmlcell.h" + +FORCE_LINK_ME(mod_hline) + + +//----------------------------------------------------------------------------- +// wxHtmlLineCell +//----------------------------------------------------------------------------- + +class wxHtmlLineCell : public wxHtmlCell +{ + public: + wxHtmlLineCell(int size) : wxHtmlCell() {m_Height = size;} + void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); + void Layout(int w) {m_Width = w; if (m_Next) m_Next -> Layout(w);} +}; + + +void wxHtmlLineCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) +{ + wxBrush mybrush("BLACK", wxSOLID); + wxPen mypen("BLACK", 1, wxSOLID); + dc.SetBrush(mybrush); + dc.SetPen(mypen); + dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height); + wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); +} + + + + +//----------------------------------------------------------------------------- +// The list handler: +//----------------------------------------------------------------------------- + + +TAG_HANDLER_BEGIN(HR, "HR") + + TAG_HANDLER_PROC(tag) + { + wxHtmlContainerCell *c; + int sz; + + m_WParser -> CloseContainer(); + c = m_WParser -> OpenContainer(); + + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_VERTICAL); + c -> SetAlignHor(HTML_ALIGN_CENTER); + c -> SetAlign(tag); + c -> SetWidthFloat(tag); + if (tag.HasParam("SIZE") && tag.ScanParam("SIZE", "%i", &sz) == 1) {} + else sz = 1; + c -> InsertCell(new wxHtmlLineCell(sz)); + + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + + return FALSE; + } + +TAG_HANDLER_END(HR) + + + + + +TAGS_MODULE_BEGIN(HLine) + + TAGS_MODULE_ADD(HR) + +TAGS_MODULE_END(HLine) + +#endif diff --git a/src/html/m_image.cpp b/src/html/m_image.cpp new file mode 100644 index 0000000000..020c60230e --- /dev/null +++ b/src/html/m_image.cpp @@ -0,0 +1,471 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_image.cpp +// Purpose: wxHtml module for displaying images +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik, Joel Lucsy +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/wxprec.h" + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include "wx/wx.h" +#endif + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + + +#include "wx/image.h" +#include "wx/dynarray.h" + +#include +#include + +FORCE_LINK_ME(mod_image) + + + + +WX_DECLARE_OBJARRAY(int, CoordArray); +#include // this is a magic incantation which must be done! +WX_DEFINE_OBJARRAY(CoordArray); + + +//-------------------------------------------------------------------------------- +// wxHtmlImageMapAreaCell +// 0-width, 0-height cell that represents single area in imagemap +// (it's GetLink is called from wxHtmlImageCell's) +//-------------------------------------------------------------------------------- + +class wxHtmlImageMapAreaCell : public wxHtmlCell +{ +public: + enum celltype{ CIRCLE, RECT, POLY }; +protected: + CoordArray coords; + celltype type; + int radius; +public: + wxHtmlImageMapAreaCell( celltype t, wxString &coords ); + virtual wxString GetLink( int x = 0, int y = 0 ) const; +}; + + + + + +wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype t, wxString &incoords ) +{ + int i; + wxString x = incoords, y; + + type = t; + while ((i = x.Find( ',' )) != -1) + { + coords.Add( atoi( x.Left( i ).c_str() ) ); + x = x.Mid( i + 1 ); + } + coords.Add( atoi( x.c_str() ) ); +} + +wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const +{ + switch (type) + { + case RECT: + { + int l, t, r, b; + + l = coords[ 0 ]; + t = coords[ 1 ]; + r = coords[ 2 ]; + b = coords[ 3 ]; + if (x >= l && x <= r && y >= t && y <= b) + { + return m_Link; + } + break; + } + case CIRCLE: + { + int l, t, r; + double d; + + l = coords[ 0 ]; + t = coords[ 1 ]; + r = coords[ 2 ]; + d = sqrt( ((x - l) * (x - l)) + ((y - t) * (y - t)) ); + if (d < (double)r) + { + return m_Link; + } + } + break; + case POLY: + { + if (coords.GetCount() >= 6) + { + int intersects = 0; + int wherex = x; + int wherey = y; + int totalv = coords.GetCount() / 2; + int totalc = totalv * 2; + int xval = coords[totalc - 2]; + int yval = coords[totalc - 1]; + int end = totalc; + int pointer = 1; + + if ((yval >= wherey) != (coords[pointer] >= wherey)) + { + if ((xval >= wherex) == (coords[0] >= wherex)) + { + intersects += (xval >= wherex) ? 1 : 0; + } + else + { + intersects += ((xval - (yval - wherey) * + (coords[0] - xval) / + (coords[pointer] - yval)) >= wherex) ? 1 : 0; + } + } + + while (pointer < end) + { + yval = coords[pointer]; + pointer += 2; + if (yval >= wherey) + { + while((pointer < end) && (coords[pointer] >= wherey)) + { + pointer+=2; + } + if (pointer >= end) + { + break; + } + if ((coords[pointer-3] >= wherex) == + (coords[pointer-1] >= wherex)) + { + intersects += (coords[pointer-3] >= wherex) ? 1 : 0; + } + else + { + intersects += + ((coords[pointer-3] - (coords[pointer-2] - wherey) * + (coords[pointer-1] - coords[pointer-3]) / + (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1:0; + } + } + else + { + while((pointer < end) && (coords[pointer] < wherey)) + { + pointer+=2; + } + if (pointer >= end) + { + break; + } + if ((coords[pointer-3] >= wherex) == + (coords[pointer-1] >= wherex)) + { + intersects += (coords[pointer-3] >= wherex) ? 1:0; + } + else + { + intersects += + ((coords[pointer-3] - (coords[pointer-2] - wherey) * + (coords[pointer-1] - coords[pointer-3]) / + (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1:0; + } + } + } + if ((intersects & 1) != 0) + { + return m_Link; + } + } + } + break; + } + if (m_Next) + { + wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; + return a->GetLink( x, y ); + } + return wxEmptyString; +} + + + + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlImageMapCell +// 0-width, 0-height cell that represents map from imagemaps +// it is always placed before wxHtmlImageMapAreaCells +// It responds to Find(HTML_COND_ISIMAGEMAP) +//-------------------------------------------------------------------------------- + + +class wxHtmlImageMapCell : public wxHtmlCell +{ +public: + wxHtmlImageMapCell( wxString &name ); +protected: + wxString m_Name; +public: + virtual wxString GetLink( int x = 0, int y = 0 ) const; + virtual const wxHtmlCell *Find( int cond, const void *param ) const; +}; + + +wxHtmlImageMapCell::wxHtmlImageMapCell( wxString &name ) +{ + m_Name = name ; +} + +wxString wxHtmlImageMapCell::GetLink( int x, int y ) const +{ + wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; + if (a) + return a->GetLink( x, y ); + return wxHtmlCell::GetLink( x, y ); +} + +const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const +{ + if (cond == HTML_COND_ISIMAGEMAP) + { + if (m_Name == *((wxString*)(param))) + return this; + } + return wxHtmlCell::Find(cond, param); +} + + + + + +//-------------------------------------------------------------------------------- +// wxHtmlImageCell +// Image/bitmap +//-------------------------------------------------------------------------------- + +class wxHtmlImageCell : public wxHtmlCell +{ + public: + wxBitmap *m_Image; + wxHtmlImageMapCell *m_ImageMap; + wxString m_MapName; + + wxHtmlImageCell(wxFSFile *input, int w = -1, int h = -1, int align = HTML_ALIGN_BOTTOM, wxString mapname = wxEmptyString); + ~wxHtmlImageCell() {if (m_Image) delete m_Image;} + void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); + virtual wxString GetLink( int x = 0, int y = 0 ) const; +}; + + + + +//-------------------------------------------------------------------------------- +// wxHtmlImageCell +//-------------------------------------------------------------------------------- + +wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align, wxString mapname) : wxHtmlCell() +{ + wxImage *img; + int ww, hh; + wxInputStream *s = input -> GetStream(); + + img = new wxImage(*s, wxBITMAP_TYPE_ANY); + + m_Image = NULL; + if (img && (img -> Ok())) { + ww = img -> GetWidth(); + hh = img -> GetHeight(); + if (w != -1) m_Width = w; else m_Width = ww; + if (h != -1) m_Height = h; else m_Height = hh; + if ((m_Width != ww) || (m_Height != hh)) { + wxImage img2 = img -> Scale(m_Width, m_Height); + m_Image = new wxBitmap(img2.ConvertToBitmap()); + } + else + m_Image = new wxBitmap(img -> ConvertToBitmap()); + delete img; + } + switch (align) { + case HTML_ALIGN_TOP : + m_Descent = m_Height; break; + case HTML_ALIGN_CENTER : + m_Descent = m_Height / 2; break; + case HTML_ALIGN_BOTTOM : default : + m_Descent = 0; break; + } + + m_ImageMap = NULL; + m_MapName = mapname; +} + + + +void wxHtmlImageCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) +{ + if (m_Image) + dc.DrawBitmap(*m_Image, x + m_PosX, y + m_PosY, TRUE); + wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); +} + +wxString wxHtmlImageCell::GetLink( int x, int y ) const +{ + if (m_MapName.IsEmpty()) + return wxHtmlCell::GetLink( x, y ); + if (!m_ImageMap) + { + wxHtmlContainerCell *p, *op; + op = p = GetParent(); + while (p) + { + op = p; + p = p->GetParent(); + } + p = op; + wxHtmlCell *cell = (wxHtmlCell*)p->Find( HTML_COND_ISIMAGEMAP, (const void*)(&m_MapName)); + if (!cell) + { + ((wxString&)m_MapName).Clear(); + return wxHtmlCell::GetLink( x, y ); + } + { // dirty hack, ask Joel why he fills m_ImageMap in this place + // THE problem is that we're in const method and we can't modify m_ImageMap + wxHtmlImageMapCell **cx = (wxHtmlImageMapCell**)(&m_ImageMap); + *cx = (wxHtmlImageMapCell*)cell; + } + } + return m_ImageMap->GetLink( x, y ); +} + + + +//-------------------------------------------------------------------------------- +// tag handler +//-------------------------------------------------------------------------------- + +TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA") + + TAG_HANDLER_PROC(tag) + { + if (tag.GetName() == "IMG") + { + if (tag.HasParam("SRC")) { + int w = -1, h = -1; + int al; + wxFSFile *str; + wxString tmp = tag.GetParam("SRC"); + wxString mn = wxEmptyString; + + str = m_WParser -> GetFS() -> OpenFile(tmp); + if (tag.HasParam("WIDTH")) tag.ScanParam("WIDTH", "%i", &w); + if (tag.HasParam("HEIGHT")) tag.ScanParam("HEIGHT", "%i", &h); + al = HTML_ALIGN_BOTTOM; + if (tag.HasParam("ALIGN")) { + wxString alstr = tag.GetParam("ALIGN"); + alstr.MakeUpper(); // for the case alignment was in ".." + if (alstr == "TEXTTOP") al = HTML_ALIGN_TOP; + else if ((alstr == "CENTER") || (alstr == "ABSCENTER")) al = HTML_ALIGN_CENTER; + } + if (tag.HasParam("USEMAP")) + { + mn = tag.GetParam( "USEMAP" ); + if (mn[ 0 ] == '#') + { + mn = mn.Mid( 1 ); + } + } + wxHtmlImageCell *cel = NULL; + if (str) { + cel = new wxHtmlImageCell(str, w, h, al, mn); + cel -> SetLink(m_WParser -> GetLink()); + m_WParser -> GetContainer() -> InsertCell(cel); + delete str; + } + } + } + if (tag.GetName() == "MAP") + { + m_WParser->CloseContainer(); + m_WParser->OpenContainer(); + if (tag.HasParam("NAME")) + { + wxString tmp = tag.GetParam("NAME"); + wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp ); + m_WParser->GetContainer()->InsertCell( cel ); + } + ParseInner( tag ); + m_WParser->CloseContainer(); + m_WParser->OpenContainer(); + } + if (tag.GetName() == "AREA") + { + if (tag.HasParam("SHAPE")) + { + wxString tmp = tag.GetParam("SHAPE"); + wxString coords; + tmp.MakeUpper(); + wxHtmlImageMapAreaCell *cel = NULL; + if (tag.HasParam("COORDS")) + { + coords = tag.GetParam("COORDS"); + } + if (tmp == "POLY") + { + cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords ); + } + else if (tmp == "CIRCLE") + { + cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords ); + } + else if (tmp == "RECT") + { + cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords ); + } + if (cel && tag.HasParam("HREF")) + { + wxString tmp = tag.GetParam("HREF"); + cel->SetLink( tmp ); + } + m_WParser->GetContainer()->InsertCell( cel ); + } + } + + return FALSE; + } + +TAG_HANDLER_END(IMAGE) + + + +TAGS_MODULE_BEGIN(Image) + + TAGS_MODULE_ADD(IMG) + +TAGS_MODULE_END(Image) + + +#endif diff --git a/src/html/m_layout.cpp b/src/html/m_layout.cpp new file mode 100644 index 0000000000..c34aa54868 --- /dev/null +++ b/src/html/m_layout.cpp @@ -0,0 +1,239 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_layout.cpp +// Purpose: wxHtml module for basic paragraphs/layout handling +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#if wxUSE_HTML +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +#include "wx/html/htmlwin.h" + +FORCE_LINK_ME(mod_layout) + + +TAG_HANDLER_BEGIN(P, "P") + + TAG_HANDLER_PROC(tag) + { + if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + } + m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); + m_WParser -> GetContainer() -> SetAlign(tag); + return FALSE; + } + +TAG_HANDLER_END(P) + + + +TAG_HANDLER_BEGIN(BR, "BR") + + TAG_HANDLER_PROC(tag) + { + int al = m_WParser -> GetContainer() -> GetAlignHor(); + wxHtmlContainerCell *c; + + m_WParser -> CloseContainer(); + c = m_WParser -> OpenContainer(); + c -> SetAlignHor(al); + c -> SetAlign(tag); + return FALSE; + } + +TAG_HANDLER_END(BR) + + + +TAG_HANDLER_BEGIN(CENTER, "CENTER") + + TAG_HANDLER_PROC(tag) + { + int old = m_WParser -> GetAlign(); + wxHtmlContainerCell *c = m_WParser -> GetContainer(); + + m_WParser -> SetAlign(HTML_ALIGN_CENTER); + if (c -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + } + else + c -> SetAlignHor(HTML_ALIGN_CENTER); + + if (tag.HasEnding()) { + ParseInner(tag); + + m_WParser -> SetAlign(old); + if (c -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + } + else + c -> SetAlignHor(old); + + return TRUE; + } + else return FALSE; + } + +TAG_HANDLER_END(CENTER) + + + +TAG_HANDLER_BEGIN(DIV, "DIV") + + TAG_HANDLER_PROC(tag) + { + int old = m_WParser -> GetAlign(); + wxHtmlContainerCell *c = m_WParser -> GetContainer(); + if (c -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + c = m_WParser -> GetContainer(); + c -> SetAlign(tag); + m_WParser -> SetAlign(c -> GetAlignHor()); + } + else { + c -> SetAlign(tag); + m_WParser -> SetAlign(c -> GetAlignHor()); + } + + ParseInner(tag); + + m_WParser -> SetAlign(old); + if (c -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + } + else + c -> SetAlignHor(old); + + return TRUE; + } + +TAG_HANDLER_END(DIV) + + + + +TAG_HANDLER_BEGIN(TITLE, "TITLE") + + TAG_HANDLER_PROC(tag) + { + if (m_WParser -> GetWindow()) { + wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow()); + if (wfr) { + wxString title = ""; + wxString *src = m_WParser -> GetSource(); + + for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[i]; + wfr -> SetTitle(title); + } + } + return TRUE; + } + +TAG_HANDLER_END(TITLE) + + + + +TAG_HANDLER_BEGIN(BODY, "BODY") + + TAG_HANDLER_PROC(tag) + { + unsigned long tmp; + wxColour clr; + + if (tag.HasParam("TEXT")) { + if (tag.ScanParam("TEXT", "#%lX", &tmp) == 1) { + clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); + m_WParser -> SetActualColor(clr); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr)); + } + } + + if (tag.HasParam("LINK")) { + if (tag.ScanParam("LINK", "#%lX", &tmp) == 1) { + clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); + m_WParser -> SetLinkColor(clr); + } + } + + if (tag.HasParam("BGCOLOR")) { + if (tag.ScanParam("BGCOLOR", "#%lX", &tmp) == 1) { + clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND)); + if (m_WParser -> GetWindow() != NULL) + m_WParser -> GetWindow() -> SetBackgroundColour(clr); + } + } + return FALSE; + } + +TAG_HANDLER_END(BODY) + + + +TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE") + + TAG_HANDLER_PROC(tag) + { + wxHtmlContainerCell *c; + + m_WParser -> CloseContainer(); + c = m_WParser -> OpenContainer(); + if (c -> GetAlignHor() == HTML_ALIGN_RIGHT) + c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_RIGHT); + else + c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT); + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); + m_WParser -> OpenContainer(); + ParseInner(tag); + c = m_WParser -> CloseContainer(); + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_BOTTOM); + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + return TRUE; + } + +TAG_HANDLER_END(BLOCKQUOTE) + + + + + + +TAGS_MODULE_BEGIN(Layout) + + TAGS_MODULE_ADD(P) + TAGS_MODULE_ADD(BR) + TAGS_MODULE_ADD(CENTER) + TAGS_MODULE_ADD(DIV) + TAGS_MODULE_ADD(TITLE) + TAGS_MODULE_ADD(BODY) + TAGS_MODULE_ADD(BLOCKQUOTE) + +TAGS_MODULE_END(Layout) + +#endif diff --git a/src/html/m_links.cpp b/src/html/m_links.cpp new file mode 100644 index 0000000000..58876ee6df --- /dev/null +++ b/src/html/m_links.cpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_links.cpp +// Purpose: wxHtml module for links & anchors +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + + +FORCE_LINK_ME(mod_links) + + +class wxHtmlAnchorCell : public wxHtmlCell +{ + private: + wxString m_AnchorName; + + public: + wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;} + virtual const wxHtmlCell* Find(int condition, const void* param) const + { + if ((condition == HTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param)))) + return this; + else + return wxHtmlCell::Find(condition, param); + } +}; + + + +TAG_HANDLER_BEGIN(A, "A") + + TAG_HANDLER_PROC(tag) + { + if (tag.HasParam("NAME")) { + m_WParser -> GetContainer() -> InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME"))); + } + + if (tag.HasParam("HREF")) { + wxString oldlnk = m_WParser -> GetLink(); + wxColour oldclr = m_WParser -> GetActualColor(); + int oldund = m_WParser -> GetFontUnderlined(); + + m_WParser -> SetActualColor(m_WParser -> GetLinkColor()); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(m_WParser -> GetLinkColor())); + m_WParser -> SetFontUnderlined(TRUE); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + m_WParser -> SetLink(tag.GetParam("HREF")); + + ParseInner(tag); + + m_WParser -> SetLink(oldlnk); + m_WParser -> SetFontUnderlined(oldund); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + m_WParser -> SetActualColor(oldclr); + m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr)); + + return TRUE; + } + else return FALSE; + } + +TAG_HANDLER_END(A) + + + +TAGS_MODULE_BEGIN(Links) + + TAGS_MODULE_ADD(A) + +TAGS_MODULE_END(Links) + + +#endif diff --git a/src/html/m_list.cpp b/src/html/m_list.cpp new file mode 100644 index 0000000000..feaae666fe --- /dev/null +++ b/src/html/m_list.cpp @@ -0,0 +1,158 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_list.cpp +// Purpose: wxHtml module for lists +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +#include "wx/html/htmlcell.h" + +FORCE_LINK_ME(mod_list) + + +//----------------------------------------------------------------------------- +// wxHtmlListmarkCell +//----------------------------------------------------------------------------- + +class wxHtmlListmarkCell : public wxHtmlCell +{ + private: + wxBrush m_Brush; + public: + wxHtmlListmarkCell(wxDC *dc, const wxColour& clr); + void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); +}; + +wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC* dc, const wxColour& clr) : wxHtmlCell(), m_Brush(clr, wxSOLID) +{ + m_Width = dc -> GetCharWidth(); + m_Height = dc -> GetCharHeight(); + m_Descent = 0; +} + + + +void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) +{ + dc.SetBrush(m_Brush); + dc.DrawEllipse(x + m_PosX + m_Width / 4, y + m_PosY + m_Height / 4, m_Width / 2, m_Width / 2); + wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); +} + + + + +//----------------------------------------------------------------------------- +// The list handler: +//----------------------------------------------------------------------------- + + +TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI") + + TAG_HANDLER_VARS + int m_Numbering; + // this is number of actual item of list or 0 for dots + + TAG_HANDLER_CONSTR(OLULLI) + { + m_Numbering = 0; + } + + TAG_HANDLER_PROC(tag) + { + wxHtmlContainerCell *c; + + // List Item: + if (tag.GetName() == "LI") { + if (!tag.IsEnding()) { + m_WParser -> CloseContainer(); + m_WParser -> CloseContainer(); + + c = m_WParser -> OpenContainer(); + c -> SetWidthFloat(2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS); + c -> SetAlignHor(HTML_ALIGN_RIGHT); + if (m_Numbering == 0) + c -> InsertCell(new wxHtmlListmarkCell(m_WParser -> GetDC(), m_WParser -> GetActualColor())); + else { + wxString mark; + mark.Printf("%i.", m_Numbering); + c -> InsertCell(new wxHtmlWordCell(mark, *(m_WParser -> GetDC()))); + } + m_WParser -> CloseContainer(); + + c = m_WParser -> OpenContainer(); + c -> SetIndent(m_WParser -> GetCharWidth() / 4, HTML_INDENT_LEFT); + c -> SetWidthFloat(-2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS); + + m_WParser -> OpenContainer(); + + if (m_Numbering != 0) m_Numbering++; + } + return FALSE; + } + + // Begin of List (not-numbered): "UL", "OL" + else { + int oldnum = m_Numbering; + + if (tag.GetName() == "UL") m_Numbering = 0; + else m_Numbering = 1; + + c = m_WParser -> GetContainer(); + if (c -> GetFirstCell() != NULL) { + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + c = m_WParser -> GetContainer(); + } + c -> SetAlignHor(HTML_ALIGN_LEFT); + c -> SetIndent(2 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT); + m_WParser -> OpenContainer() -> SetAlignVer(HTML_ALIGN_TOP); + + m_WParser -> OpenContainer(); + m_WParser -> OpenContainer(); + ParseInner(tag); + m_WParser -> CloseContainer(); + + m_WParser -> CloseContainer(); + m_WParser -> CloseContainer(); + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + + m_Numbering = oldnum; + return TRUE; + } + } + +TAG_HANDLER_END(OLULLI) + + +TAGS_MODULE_BEGIN(List) + + TAGS_MODULE_ADD(OLULLI) + +TAGS_MODULE_END(List) + +#endif diff --git a/src/html/m_pre.cpp b/src/html/m_pre.cpp new file mode 100644 index 0000000000..25e24cf402 --- /dev/null +++ b/src/html/m_pre.cpp @@ -0,0 +1,171 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_pre.cpp +// Purpose: wxHtml module for
 ... 
tag (code citation) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#if wxUSE_HTML +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +#include "wx/html/htmlcell.h" +#include + +FORCE_LINK_ME(mod_pre) + + +//----------------------------------------------------------------------------- +// wxHtmlCodeCell +//----------------------------------------------------------------------------- + +class wxHtmlPRECell : public wxHtmlCell +{ + private: + wxString** m_Text; + // list of wxString objects. + int m_LinesCnt; + // number of lines + int m_LineHeight; + // height of single line of text + + public: + wxHtmlPRECell(const wxString& s, wxDC& dc); + ~wxHtmlPRECell(); + void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); +}; + + +wxHtmlPRECell::wxHtmlPRECell(const wxString& s, wxDC& dc) : wxHtmlCell() +{ + wxStringTokenizer tokenizer(s, "\n"); + wxString tmp; + long int x, z; + int i; + + m_LineHeight = dc.GetCharHeight(); + m_LinesCnt = 0; + m_Text = NULL; + m_Width = m_Height = 0; + + i = 0; +#if (wxVERSION_NUMBER < 2100) + while (tokenizer.HasMoreToken()) { +#else + while (tokenizer.HasMoreTokens()) { +#endif + if (i % 10 == 0) m_Text = (wxString**) realloc(m_Text, sizeof(wxString*) * (i + 10)); + tmp = tokenizer.NextToken(); + tmp.Replace(" ", " ", TRUE); + tmp.Replace(""", "\"", TRUE); + tmp.Replace("<", "<", TRUE); + tmp.Replace(">", ">", TRUE); + tmp.Replace("&", "&", TRUE); + tmp.Replace("\t", " ", TRUE); + tmp.Replace("\r", "", TRUE); + m_Text[i++] = new wxString(tmp); + + dc.GetTextExtent(tmp, &x, &z, &z); + if (x > m_Width) m_Width = x; + m_Height += m_LineHeight; + m_LinesCnt++; + } +} + + + +wxHtmlPRECell::~wxHtmlPRECell() +{ + for (int i = 0; i < m_LinesCnt; i++) delete m_Text[i]; + free(m_Text); +} + + +void wxHtmlPRECell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) +{ + for (int i = 0; i < m_LinesCnt; i++) + dc.DrawText(*(m_Text[i]), x + m_PosX, y + m_PosY + m_LineHeight * i); + + wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); +} + + + + +//----------------------------------------------------------------------------- +// The list handler: +//----------------------------------------------------------------------------- + + +TAG_HANDLER_BEGIN(PRE, "PRE") + + TAG_HANDLER_PROC(tag) + { + wxHtmlContainerCell *c; + + int fixed = m_WParser -> GetFontFixed(), + italic = m_WParser -> GetFontItalic(), + underlined = m_WParser -> GetFontUnderlined(), + bold = m_WParser -> GetFontBold(), + fsize = m_WParser -> GetFontSize(); + + m_WParser -> CloseContainer(); + c = m_WParser -> OpenContainer(); + c -> SetAlignHor(HTML_ALIGN_LEFT); + c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_VERTICAL); + + m_WParser -> SetFontUnderlined(FALSE); + m_WParser -> SetFontBold(FALSE); + m_WParser -> SetFontItalic(FALSE); + m_WParser -> SetFontFixed(TRUE); + m_WParser -> SetFontSize(0); + c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + + { + wxString cit; + cit = m_WParser -> GetSource() -> Mid(tag.GetBeginPos(), tag.GetEndPos1() - tag.GetBeginPos()); + c -> InsertCell(new wxHtmlPRECell(cit, *(m_WParser -> GetDC()))); + } + + m_WParser -> SetFontUnderlined(underlined); + m_WParser -> SetFontBold(bold); + m_WParser -> SetFontItalic(italic); + m_WParser -> SetFontFixed(fixed); + m_WParser -> SetFontSize(fsize); + c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); + + m_WParser -> CloseContainer(); + m_WParser -> OpenContainer(); + return TRUE; + } + +TAG_HANDLER_END(PRE) + + + + + +TAGS_MODULE_BEGIN(Pre) + + TAGS_MODULE_ADD(PRE) + +TAGS_MODULE_END(Pre) + +#endif diff --git a/src/html/m_tables.cpp b/src/html/m_tables.cpp new file mode 100644 index 0000000000..a93a089c9a --- /dev/null +++ b/src/html/m_tables.cpp @@ -0,0 +1,494 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: mod_tables.cpp +// Purpose: wxHtml module for tables +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#if wxUSE_HTML +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + + +/* +REMARKS: + 1. This version of mod_tables doesn't support auto-layout algorithm. + This means that all columns are of same width unless explicitly specified. +*/ + + +#include "wx/html/forcelnk.h" +#include "wx/html/m_templ.h" + +#include "wx/html/htmlcell.h" + +FORCE_LINK_ME(mod_tables) + + +#define TABLE_BORDER_CLR_1 wxColour(0xC5, 0xC2, 0xC5) +#define TABLE_BORDER_CLR_2 wxColour(0x62, 0x61, 0x62) + + +//----------------------------------------------------------------------------- +// wxHtmlTableCell +//----------------------------------------------------------------------------- + + +typedef struct { + int width, units; // universal + int leftpos, pixwidth, maxrealwidth; // temporary (depends on width of table) + } colStruct; + +typedef enum { + cellSpan, + cellUsed, + cellFree + } cellState; + +typedef struct { + wxHtmlContainerCell *cont; + int colspan, rowspan; + int minheight, valign; + cellState flag; + } cellStruct; + + +class wxHtmlTableCell : public wxHtmlContainerCell +{ + protected: + /* These are real attributes: */ + bool m_HasBorders; + // should we draw borders or not? + int m_NumCols, m_NumRows; + // number of columns; rows + colStruct *m_ColsInfo; + // array of column information + cellStruct **m_CellInfo; + // 2D array of all cells in the table : m_CellInfo[row][column] + int m_Spacing; + // spaces between cells + int m_Padding; + // cells internal indentation + + private: + /* ...and these are valid only during parsing of table: */ + int m_ActualCol, m_ActualRow; + // number of actual column (ranging from 0..m_NumCols) + + // default values (for table and row): + int m_tBkg, m_rBkg; + wxString m_tValign, m_rValign; + + + public: + wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag); + ~wxHtmlTableCell(); + virtual void Layout(int w); + + void AddRow(const wxHtmlTag& tag); + void AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag); + private: + void ReallocCols(int cols); + void ReallocRows(int rows); + // reallocates memory to given number of cols/rows + // and changes m_NumCols/m_NumRows value to reflect this change + // NOTE! You CAN'T change m_NumCols/m_NumRows before calling this!! +}; + + + +wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag) + : wxHtmlContainerCell(parent) +{ + m_HasBorders = tag.HasParam("BORDER"); + m_ColsInfo = NULL; + m_NumCols = m_NumRows = 0; + m_CellInfo = NULL; + m_ActualCol = m_ActualRow = -1; + + /* scan params: */ + m_tBkg = m_rBkg = -1; + if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_tBkg); + if (tag.HasParam("VALIGN")) m_tValign = tag.GetParam("VALIGN"); else m_tValign = wxEmptyString; + if (tag.HasParam("CELLSPACING") && tag.ScanParam("CELLSPACING", "%i", &m_Spacing) == 1) {} else m_Spacing = 2; + if (tag.HasParam("CELLPADDING") && tag.ScanParam("CELLPADDING", "%i", &m_Padding) == 1) {} else m_Padding = 3; + + if (m_HasBorders) + SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2); +} + + + +wxHtmlTableCell::~wxHtmlTableCell() +{ + if (m_ColsInfo) free(m_ColsInfo); + if (m_CellInfo) { + for (int i = 0; i < m_NumRows; i++) + free(m_CellInfo[i]); + free(m_CellInfo); + } +} + + + +void wxHtmlTableCell::ReallocCols(int cols) +{ + int i,j; + + for (i = 0; i < m_NumRows; i++) { + m_CellInfo[i] = (cellStruct*) realloc(m_CellInfo[i], sizeof(cellStruct) * cols); + for (j = m_NumCols; j < cols; j++) + m_CellInfo[i][j].flag = cellFree; + } + + m_ColsInfo = (colStruct*) realloc(m_ColsInfo, sizeof(colStruct) * cols); + for (j = m_NumCols; j < cols; j++) { + m_ColsInfo[j].width = 0; + m_ColsInfo[j].units = HTML_UNITS_PERCENT; + } + + m_NumCols = cols; +} + + + +void wxHtmlTableCell::ReallocRows(int rows) +{ + m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows); + if (m_NumCols != 0) { + int x = rows - 1; + m_CellInfo[x] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols); + for (int i = 0; i < m_NumCols; i++) + m_CellInfo[x][i].flag = cellFree; + } + else + m_CellInfo[rows - 1] = NULL; + m_NumRows = rows; +} + + + +void wxHtmlTableCell::AddRow(const wxHtmlTag& tag) +{ + if (m_ActualRow + 1 > m_NumRows - 1) + ReallocRows(m_ActualRow + 2); + m_ActualRow++; + m_ActualCol = -1; + + /* scan params: */ + m_rBkg = m_tBkg; + if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_rBkg); + if (tag.HasParam("VALIGN")) m_rValign = tag.GetParam("VALIGN"); else m_rValign = m_tValign; +} + + + +void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) +{ + do { + m_ActualCol++; + } while ((m_ActualCol < m_NumCols) && (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree)); + if (m_ActualCol > m_NumCols - 1) + ReallocCols(m_ActualCol + 1); + + int r = m_ActualRow, c = m_ActualCol; + + m_CellInfo[r][c].cont = cell; + m_CellInfo[r][c].colspan = 1; + m_CellInfo[r][c].rowspan = 1; + m_CellInfo[r][c].flag = cellUsed; + m_CellInfo[r][c].minheight = 0; + m_CellInfo[r][c].valign = HTML_ALIGN_TOP; + + /* scan for parameters: */ + + // width: + { + if (tag.HasParam("WIDTH")) { + wxString wd = tag.GetParam("WIDTH"); + + if (wd[wd.Length()-1] == '%') { + sscanf(wd.c_str(), "%i%%", &m_ColsInfo[c].width); + m_ColsInfo[c].units = HTML_UNITS_PERCENT; + } + else { + sscanf(wd.c_str(), "%i", &m_ColsInfo[c].width); + m_ColsInfo[c].units = HTML_UNITS_PIXELS; + } + } + } + + + // spanning: + { + if (tag.HasParam("COLSPAN")) tag.ScanParam("COLSPAN", "%i", &m_CellInfo[r][c].colspan); + if (tag.HasParam("ROWSPAN")) tag.ScanParam("ROWSPAN", "%i", &m_CellInfo[r][c].rowspan); + if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) { + int i, j; + + if (r + m_CellInfo[r][c].rowspan > m_NumRows) ReallocRows(r + m_CellInfo[r][c].rowspan); + if (c + m_CellInfo[r][c].colspan > m_NumCols) ReallocCols(c + m_CellInfo[r][c].colspan); + for (i = r; i < r + m_CellInfo[r][c].rowspan; i++) + for (j = c; j < c + m_CellInfo[r][c].colspan; j++) + m_CellInfo[i][j].flag = cellSpan; + m_CellInfo[r][c].flag = cellUsed; + } + } + + //background color: + { + int bk = m_rBkg; + if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &bk); + if (bk != -1) { + wxColour clr = wxColour((bk & 0xFF0000) >> 16 , (bk & 0x00FF00) >> 8, (bk & 0x0000FF)); + cell -> SetBackgroundColour(clr); + } + } + if (m_HasBorders) + cell -> SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1); + + // vertical alignment: + { + wxString valign; + if (tag.HasParam("VALIGN")) valign = tag.GetParam("VALIGN"); else valign = m_tValign; + valign.MakeUpper(); + if (valign == "TOP") m_CellInfo[r][c].valign = HTML_ALIGN_TOP; + else if (valign == "BOTTOM") m_CellInfo[r][c].valign = HTML_ALIGN_BOTTOM; + else m_CellInfo[r][c].valign = HTML_ALIGN_CENTER; + } + + cell -> SetIndent(m_Padding, HTML_INDENT_ALL, HTML_UNITS_PIXELS); +} + + + + + +void wxHtmlTableCell::Layout(int w) +{ + /* + + WIDTH ADJUSTING : + + */ + + if (m_WidthFloatUnits == HTML_UNITS_PERCENT) { + if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; + else m_Width = m_WidthFloat * w / 100; + } + else { + if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; + else m_Width = m_WidthFloat; + } + + + /* + + LAYOUTING : + + */ + + /* 1. setup columns widths: */ + { + int wpix = m_Width - (m_NumCols + 1) * m_Spacing; + int i, j; + int wtemp = 0; + + // 1a. setup fixed-width columns: + for (i = 0; i < m_NumCols; i++) + if (m_ColsInfo[i].units == HTML_UNITS_PIXELS) + wpix -= (m_ColsInfo[i].pixwidth = m_ColsInfo[i].width); + + // 1b. setup floating-width columns: + for (i = 0; i < m_NumCols; i++) + if ((m_ColsInfo[i].units == HTML_UNITS_PERCENT) && (m_ColsInfo[i].width != 0)) + wtemp += (m_ColsInfo[i].pixwidth = m_ColsInfo[i].width * wpix / 100); + wpix -= wtemp; + + // 1c. setup defalut columns (no width specification supplied): + // NOTE! This algorithm doesn't conform to HTML standard : it assigns equal widths + // instead of optimal + for (i = j = 0; i < m_NumCols; i++) + if (m_ColsInfo[i].width == 0) j++; + for (i = 0; i < m_NumCols; i++) + if (m_ColsInfo[i].width == 0) + m_ColsInfo[i].pixwidth = wpix / j; + } + + /* 2. compute positions of columns: */ + { + int wpos = m_Spacing; + for (int i = 0; i < m_NumCols; i++) { + m_ColsInfo[i].leftpos = wpos; + wpos += m_ColsInfo[i].pixwidth + m_Spacing; + } + } + + /* 3. sub-layout all cells: */ + { + int *ypos = new int[m_NumRows + 1]; + + int actcol, actrow; + int fullwid; + wxHtmlContainerCell *actcell; + + for (actrow = 0; actrow <= m_NumRows; actrow++) ypos[actrow] = m_Spacing; + + for (actrow = 0; actrow < m_NumRows; actrow++) { + + // 3a. sub-layout and detect max height: + + for (actcol = 0; actcol < m_NumCols; actcol++) { + if (m_CellInfo[actrow][actcol].flag != cellUsed) continue; + actcell = m_CellInfo[actrow][actcol].cont; + fullwid = 0; + for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++) + fullwid += m_ColsInfo[i].pixwidth; + actcell -> SetMinHeight(m_CellInfo[actrow][actcol].minheight, m_CellInfo[actrow][actcol].valign); + actcell -> Layout(fullwid); + + if (ypos[actrow] + actcell -> GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing > ypos[actrow + m_CellInfo[actrow][actcol].rowspan]) + ypos[actrow + m_CellInfo[actrow][actcol].rowspan] = + ypos[actrow] + actcell -> GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing; + } + } + + + for (actrow = 0; actrow < m_NumRows; actrow++) { + + // 3b. place cells in row & let'em all have same height: + + for (actcol = 0; actcol < m_NumCols; actcol++) { + if (m_CellInfo[actrow][actcol].flag != cellUsed) continue; + actcell = m_CellInfo[actrow][actcol].cont; + actcell -> SetMinHeight( + ypos[actrow + m_CellInfo[actrow][actcol].rowspan] - ypos[actrow] - m_CellInfo[actrow][actcol].rowspan * m_Spacing, + m_CellInfo[actrow][actcol].valign); + fullwid = 0; + for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++) + fullwid += m_ColsInfo[i].pixwidth; + actcell -> Layout(fullwid); + actcell -> SetPos(m_ColsInfo[actcol].leftpos, ypos[actrow]); + } + + } + m_Height = ypos[m_NumRows]; + delete[] ypos; + } +} + + + + + + +//----------------------------------------------------------------------------- +// The tables handler: +//----------------------------------------------------------------------------- + + +TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") + + TAG_HANDLER_VARS + wxHtmlTableCell* m_Table; + wxString m_tAlign, m_rAlign; + int m_OldAlign; + + TAG_HANDLER_CONSTR(TABLE) + { + m_Table = NULL; + m_tAlign = m_rAlign = wxEmptyString; + m_OldAlign = HTML_ALIGN_LEFT; + } + + + TAG_HANDLER_PROC(tag) + { + wxHtmlContainerCell *c; + + // new table started, backup upper-level table (if any) and create new: + if (tag.GetName() == "TABLE") { + wxHtmlTableCell *oldt = m_Table; + wxHtmlContainerCell *oldcont; + int m_OldAlign; + + oldcont = c = m_WParser -> OpenContainer(); + + c -> SetWidthFloat(tag); + m_Table = new wxHtmlTableCell(c, tag); + m_OldAlign = m_WParser -> GetAlign(); + m_tAlign = wxEmptyString; + if (tag.HasParam("ALIGN")) m_tAlign = tag.GetParam("ALIGN"); + + ParseInner(tag); + + m_WParser -> SetAlign(m_OldAlign); + m_WParser -> SetContainer(oldcont); + m_WParser -> CloseContainer(); + m_Table = oldt; + return TRUE; + } + + + else if (m_Table && !tag.IsEnding()) { + // new row in table + if (tag.GetName() == "TR") { + m_Table -> AddRow(tag); + m_rAlign = m_tAlign; + if (tag.HasParam("ALIGN")) m_rAlign = tag.GetParam("ALIGN"); + } + + // new cell + else { + m_WParser -> SetAlign(m_OldAlign); + c = m_WParser -> SetContainer(new wxHtmlContainerCell(m_Table)); + m_Table -> AddCell(c, tag); + + m_WParser -> OpenContainer(); + + if (tag.GetName() == "TH") /*header style*/ { + m_WParser -> SetAlign(HTML_ALIGN_CENTER); + } + + { + wxString als; + + als = m_rAlign; + if (tag.HasParam("ALIGN")) als = tag.GetParam("ALIGN"); + als.MakeUpper(); + if (als == "RIGHT") m_WParser -> SetAlign(HTML_ALIGN_RIGHT); + else if (als == "CENTER") m_WParser -> SetAlign(HTML_ALIGN_CENTER); + } + m_WParser -> OpenContainer(); + } + } + return FALSE; + } + +TAG_HANDLER_END(TABLE) + + + + + +TAGS_MODULE_BEGIN(Tables) + + TAGS_MODULE_ADD(TABLE) + +TAGS_MODULE_END(Tables) + + +#endif diff --git a/src/html/mod_fonts.cpp b/src/html/mod_fonts.cpp deleted file mode 100644 index 006fc4865e..0000000000 --- a/src/html/mod_fonts.cpp +++ /dev/null @@ -1,191 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_fonts.cpp -// Purpose: wxHtml module for fonts & colors of fonts -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#include "wx/defs.h" -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - -#include -#include - -FORCE_LINK_ME(mod_fonts) - - -TAG_HANDLER_BEGIN(FONT, "FONT") - - TAG_HANDLER_PROC(tag) - { - wxColour oldclr = m_WParser -> GetActualColor(); - int oldsize = m_WParser -> GetFontSize(); - - if (tag.HasParam("COLOR")) { - unsigned long tmp = 0; - wxColour clr; - if (tag.ScanParam("COLOR", "#%lX", &tmp) == 1) { - clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); - m_WParser -> SetActualColor(clr); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr)); - } - } - - if (tag.HasParam("SIZE")) { - long tmp = 0; - if (tag.ScanParam("SIZE", "%li", &tmp) == 1) { - m_WParser -> SetFontSize(oldsize+tmp); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - } - } - - ParseInner(tag); - - if (oldclr != m_WParser -> GetActualColor()) { - m_WParser -> SetActualColor(oldclr); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr)); - } - if (oldsize != m_WParser -> GetFontSize()) { - m_WParser -> SetFontSize(oldsize); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - } - return TRUE; - } - -TAG_HANDLER_END(FONT) - - -TAG_HANDLER_BEGIN(FACES, "U,I,B,TT") - - TAG_HANDLER_PROC(tag) - { - int fixed = m_WParser -> GetFontFixed(), - italic = m_WParser -> GetFontItalic(), - underlined = m_WParser -> GetFontUnderlined(), - bold = m_WParser -> GetFontBold(); - - if (tag.GetName() == "U") - m_WParser -> SetFontUnderlined(TRUE); - else if (tag.GetName() == "B") - m_WParser -> SetFontBold(TRUE); - else if (tag.GetName() == "I") - m_WParser -> SetFontItalic(TRUE); - else - m_WParser -> SetFontFixed(TRUE); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - - ParseInner(tag); - - m_WParser -> SetFontUnderlined(underlined); - m_WParser -> SetFontBold(bold); - m_WParser -> SetFontItalic(italic); - m_WParser -> SetFontFixed(fixed); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - return TRUE; - } - -TAG_HANDLER_END(FACES) - - - - - -TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6") - - TAG_HANDLER_PROC(tag) - { - int old_size, old_b, old_i, old_u, old_f, old_al; - wxHtmlContainerCell *c; - - old_size = m_WParser -> GetFontSize(); - old_b = m_WParser -> GetFontBold(); - old_i = m_WParser -> GetFontItalic(); - old_u = m_WParser -> GetFontUnderlined(); - old_f = m_WParser -> GetFontFixed(); - old_al = m_WParser -> GetAlign(); - - m_WParser -> SetFontBold(TRUE); - m_WParser -> SetFontItalic(FALSE); - m_WParser -> SetFontUnderlined(FALSE); - m_WParser -> SetFontFixed(FALSE); - - if (tag.GetName() == "H1") - m_WParser -> SetFontSize(+4); - else if (tag.GetName() == "H2") - m_WParser -> SetFontSize(+3); - else if (tag.GetName() == "H3") - m_WParser -> SetFontSize(+2); - else if (tag.GetName() == "H4") { - m_WParser -> SetFontSize(+2); - m_WParser -> SetFontItalic(TRUE); - m_WParser -> SetFontBold(FALSE); - } - else if (tag.GetName() == "H5") - m_WParser -> SetFontSize(+1); - else if (tag.GetName() == "H6") { - m_WParser -> SetFontSize(+1); - m_WParser -> SetFontItalic(TRUE); - m_WParser -> SetFontBold(FALSE); - } - - c = m_WParser -> GetContainer(); - if (c -> GetFirstCell()) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - c = m_WParser -> GetContainer(); - } - c = m_WParser -> GetContainer(); - - c -> SetAlign(tag); - c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); - m_WParser -> SetAlign(c -> GetAlignHor()); - - ParseInner(tag); - - m_WParser -> SetFontSize(old_size); - m_WParser -> SetFontBold(old_b); - m_WParser -> SetFontItalic(old_i); - m_WParser -> SetFontUnderlined(old_u); - m_WParser -> SetFontFixed(old_f); - m_WParser -> SetAlign(old_al); - - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - c = m_WParser -> GetContainer(); - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); - - return TRUE; - } - -TAG_HANDLER_END(Hx) - - - - -TAGS_MODULE_BEGIN(Fonts) - - TAGS_MODULE_ADD(FONT) - TAGS_MODULE_ADD(FACES) - TAGS_MODULE_ADD(Hx) - -TAGS_MODULE_END(Fonts) - - -#endif diff --git a/src/html/mod_hline.cpp b/src/html/mod_hline.cpp deleted file mode 100644 index 7bada2919b..0000000000 --- a/src/html/mod_hline.cpp +++ /dev/null @@ -1,103 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_hline.cpp -// Purpose: wxHtml module for horizontal line (HR tag) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - - -#include "wx/defs.h" -#if wxUSE_HTML -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - - -#include -#include - -#include - -FORCE_LINK_ME(mod_hline) - - -//----------------------------------------------------------------------------- -// wxHtmlLineCell -//----------------------------------------------------------------------------- - -class wxHtmlLineCell : public wxHtmlCell -{ - public: - wxHtmlLineCell(int size) : wxHtmlCell() {m_Height = size;} - void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); - void Layout(int w) {m_Width = w; if (m_Next) m_Next -> Layout(w);} -}; - - -void wxHtmlLineCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) -{ - wxBrush mybrush("BLACK", wxSOLID); - wxPen mypen("BLACK", 1, wxSOLID); - dc.SetBrush(mybrush); - dc.SetPen(mypen); - dc.DrawRectangle(x + m_PosX, y + m_PosY, m_Width, m_Height); - wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); -} - - - - -//----------------------------------------------------------------------------- -// The list handler: -//----------------------------------------------------------------------------- - - -TAG_HANDLER_BEGIN(HR, "HR") - - TAG_HANDLER_PROC(tag) - { - wxHtmlContainerCell *c; - int sz; - - m_WParser -> CloseContainer(); - c = m_WParser -> OpenContainer(); - - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_VERTICAL); - c -> SetAlignHor(HTML_ALIGN_CENTER); - c -> SetAlign(tag); - c -> SetWidthFloat(tag); - if (tag.HasParam("SIZE") && tag.ScanParam("SIZE", "%i", &sz) == 1) {} - else sz = 1; - c -> InsertCell(new wxHtmlLineCell(sz)); - - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - - return FALSE; - } - -TAG_HANDLER_END(HR) - - - - - -TAGS_MODULE_BEGIN(HLine) - - TAGS_MODULE_ADD(HR) - -TAGS_MODULE_END(HLine) - -#endif diff --git a/src/html/mod_image.cpp b/src/html/mod_image.cpp deleted file mode 100644 index fda3e4ad52..0000000000 --- a/src/html/mod_image.cpp +++ /dev/null @@ -1,470 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_image.cpp -// Purpose: wxHtml module for displaying images -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik, Joel Lucsy -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "wx/wxprec.h" - -#include "wx/defs.h" -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include "wx/wx.h" -#endif - -#include "wx/html/forcelink.h" -#include "wx/html/mod_templ.h" - - -#include "wx/image.h" -#include "wx/dynarray.h" - -#include -#include - -FORCE_LINK_ME(mod_image) - - - - -WX_DECLARE_OBJARRAY(int, CoordArray); -#include // this is a magic incantation which must be done! -WX_DEFINE_OBJARRAY(CoordArray); - - -//-------------------------------------------------------------------------------- -// wxHtmlImageMapAreaCell -// 0-width, 0-height cell that represents single area in imagemap -// (it's GetLink is called from wxHtmlImageCell's) -//-------------------------------------------------------------------------------- - -class wxHtmlImageMapAreaCell : public wxHtmlCell -{ -public: - enum celltype{ CIRCLE, RECT, POLY }; -protected: - CoordArray coords; - celltype type; - int radius; -public: - wxHtmlImageMapAreaCell( celltype t, wxString &coords ); - virtual wxString GetLink( int x = 0, int y = 0 ) const; -}; - - - - - -wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype t, wxString &incoords ) -{ - int i; - wxString x = incoords, y; - - type = t; - while ((i = x.Find( ',' )) != -1) - { - coords.Add( atoi( x.Left( i ).c_str() ) ); - x = x.Mid( i + 1 ); - } - coords.Add( atoi( x.c_str() ) ); -} - -wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const -{ - switch (type) - { - case RECT: - { - int l, t, r, b; - - l = coords[ 0 ]; - t = coords[ 1 ]; - r = coords[ 2 ]; - b = coords[ 3 ]; - if (x >= l && x <= r && y >= t && y <= b) - { - return m_Link; - } - break; - } - case CIRCLE: - { - int l, t, r; - double d; - - l = coords[ 0 ]; - t = coords[ 1 ]; - r = coords[ 2 ]; - d = sqrt( ((x - l) * (x - l)) + ((y - t) * (y - t)) ); - if (d < (double)r) - { - return m_Link; - } - } - break; - case POLY: - { - if (coords.GetCount() >= 6) - { - int intersects = 0; - int wherex = x; - int wherey = y; - int totalv = coords.GetCount() / 2; - int totalc = totalv * 2; - int xval = coords[totalc - 2]; - int yval = coords[totalc - 1]; - int end = totalc; - int pointer = 1; - - if ((yval >= wherey) != (coords[pointer] >= wherey)) - { - if ((xval >= wherex) == (coords[0] >= wherex)) - { - intersects += (xval >= wherex) ? 1 : 0; - } - else - { - intersects += ((xval - (yval - wherey) * - (coords[0] - xval) / - (coords[pointer] - yval)) >= wherex) ? 1 : 0; - } - } - - while (pointer < end) - { - yval = coords[pointer]; - pointer += 2; - if (yval >= wherey) - { - while((pointer < end) && (coords[pointer] >= wherey)) - { - pointer+=2; - } - if (pointer >= end) - { - break; - } - if ((coords[pointer-3] >= wherex) == - (coords[pointer-1] >= wherex)) - { - intersects += (coords[pointer-3] >= wherex) ? 1 : 0; - } - else - { - intersects += - ((coords[pointer-3] - (coords[pointer-2] - wherey) * - (coords[pointer-1] - coords[pointer-3]) / - (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1:0; - } - } - else - { - while((pointer < end) && (coords[pointer] < wherey)) - { - pointer+=2; - } - if (pointer >= end) - { - break; - } - if ((coords[pointer-3] >= wherex) == - (coords[pointer-1] >= wherex)) - { - intersects += (coords[pointer-3] >= wherex) ? 1:0; - } - else - { - intersects += - ((coords[pointer-3] - (coords[pointer-2] - wherey) * - (coords[pointer-1] - coords[pointer-3]) / - (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1:0; - } - } - } - if ((intersects & 1) != 0) - { - return m_Link; - } - } - } - break; - } - if (m_Next) - { - wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; - return a->GetLink( x, y ); - } - return wxEmptyString; -} - - - - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlImageMapCell -// 0-width, 0-height cell that represents map from imagemaps -// it is always placed before wxHtmlImageMapAreaCells -// It responds to Find(HTML_COND_ISIMAGEMAP) -//-------------------------------------------------------------------------------- - - -class wxHtmlImageMapCell : public wxHtmlCell -{ -public: - wxHtmlImageMapCell( wxString &name ); -protected: - wxString m_Name; -public: - virtual wxString GetLink( int x = 0, int y = 0 ) const; - virtual const wxHtmlCell *Find( int cond, const void *param ) const; -}; - - -wxHtmlImageMapCell::wxHtmlImageMapCell( wxString &name ) -{ - m_Name = name ; -} - -wxString wxHtmlImageMapCell::GetLink( int x, int y ) const -{ - wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; - if (a) - return a->GetLink( x, y ); - return wxHtmlCell::GetLink( x, y ); -} - -const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const -{ - if (cond == HTML_COND_ISIMAGEMAP) - { - if (m_Name == *((wxString*)(param))) - return this; - } - return wxHtmlCell::Find(cond, param); -} - - - - - -//-------------------------------------------------------------------------------- -// wxHtmlImageCell -// Image/bitmap -//-------------------------------------------------------------------------------- - -class wxHtmlImageCell : public wxHtmlCell -{ - public: - wxBitmap *m_Image; - wxHtmlImageMapCell *m_ImageMap; - wxString m_MapName; - - wxHtmlImageCell(wxFSFile *input, int w = -1, int h = -1, int align = HTML_ALIGN_BOTTOM, wxString mapname = wxEmptyString); - ~wxHtmlImageCell() {if (m_Image) delete m_Image;} - void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); - virtual wxString GetLink( int x = 0, int y = 0 ) const; -}; - - - - -//-------------------------------------------------------------------------------- -// wxHtmlImageCell -//-------------------------------------------------------------------------------- - -wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align, wxString mapname) : wxHtmlCell() -{ - wxImage *img; - int ww, hh; - wxInputStream *s = input -> GetStream(); - - img = new wxImage(*s, wxBITMAP_TYPE_ANY); - - m_Image = NULL; - if (img && (img -> Ok())) { - ww = img -> GetWidth(); - hh = img -> GetHeight(); - if (w != -1) m_Width = w; else m_Width = ww; - if (h != -1) m_Height = h; else m_Height = hh; - if ((m_Width != ww) || (m_Height != hh)) { - wxImage img2 = img -> Scale(m_Width, m_Height); - m_Image = new wxBitmap(img2.ConvertToBitmap()); - } - else - m_Image = new wxBitmap(img -> ConvertToBitmap()); - delete img; - } - switch (align) { - case HTML_ALIGN_TOP : - m_Descent = m_Height; break; - case HTML_ALIGN_CENTER : - m_Descent = m_Height / 2; break; - case HTML_ALIGN_BOTTOM : default : - m_Descent = 0; break; - } - - m_ImageMap = NULL; - m_MapName = mapname; -} - - - -void wxHtmlImageCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) -{ - if (m_Image) - dc.DrawBitmap(*m_Image, x + m_PosX, y + m_PosY, TRUE); - wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); -} - -wxString wxHtmlImageCell::GetLink( int x, int y ) const -{ - if (m_MapName.IsEmpty()) - return wxHtmlCell::GetLink( x, y ); - if (!m_ImageMap) - { - wxHtmlContainerCell *p, *op; - op = p = GetParent(); - while (p) - { - op = p; - p = p->GetParent(); - } - p = op; - wxHtmlCell *cell = (wxHtmlCell*)p->Find( HTML_COND_ISIMAGEMAP, (const void*)(&m_MapName)); - if (!cell) - { - ((wxString&)m_MapName).Clear(); - return wxHtmlCell::GetLink( x, y ); - } - { // dirty hack, ask Joel why he fills m_ImageMap in this place - // THE problem is that we're in const method and we can't modify m_ImageMap - wxHtmlImageMapCell **cx = (wxHtmlImageMapCell**)(&m_ImageMap); - *cx = (wxHtmlImageMapCell*)cell; - } - } - return m_ImageMap->GetLink( x, y ); -} - - - -//-------------------------------------------------------------------------------- -// tag handler -//-------------------------------------------------------------------------------- - -TAG_HANDLER_BEGIN(IMG, "IMG, MAP, AREA") - - TAG_HANDLER_PROC(tag) - { - if (tag.GetName() == "IMG") - { - if (tag.HasParam("SRC")) { - int w = -1, h = -1; - int al; - wxFSFile *str; - wxString tmp = tag.GetParam("SRC"); - wxString mn = wxEmptyString; - - str = m_WParser -> GetFS() -> OpenFile(tmp); - if (tag.HasParam("WIDTH")) tag.ScanParam("WIDTH", "%i", &w); - if (tag.HasParam("HEIGHT")) tag.ScanParam("HEIGHT", "%i", &h); - al = HTML_ALIGN_BOTTOM; - if (tag.HasParam("ALIGN")) { - wxString alstr = tag.GetParam("ALIGN"); - alstr.MakeUpper(); // for the case alignment was in ".." - if (alstr == "TEXTTOP") al = HTML_ALIGN_TOP; - else if ((alstr == "CENTER") || (alstr == "ABSCENTER")) al = HTML_ALIGN_CENTER; - } - if (tag.HasParam("USEMAP")) - { - mn = tag.GetParam( "USEMAP" ); - if (mn[ 0 ] == '#') - { - mn = mn.Mid( 1 ); - } - } - wxHtmlImageCell *cel = NULL; - if (str) { - cel = new wxHtmlImageCell(str, w, h, al, mn); - cel -> SetLink(m_WParser -> GetLink()); - m_WParser -> GetContainer() -> InsertCell(cel); - delete str; - } - } - } - if (tag.GetName() == "MAP") - { - m_WParser->CloseContainer(); - m_WParser->OpenContainer(); - if (tag.HasParam("NAME")) - { - wxString tmp = tag.GetParam("NAME"); - wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp ); - m_WParser->GetContainer()->InsertCell( cel ); - } - ParseInner( tag ); - m_WParser->CloseContainer(); - m_WParser->OpenContainer(); - } - if (tag.GetName() == "AREA") - { - if (tag.HasParam("SHAPE")) - { - wxString tmp = tag.GetParam("SHAPE"); - wxString coords; - tmp.MakeUpper(); - wxHtmlImageMapAreaCell *cel = NULL; - if (tag.HasParam("COORDS")) - { - coords = tag.GetParam("COORDS"); - } - if (tmp == "POLY") - { - cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords ); - } - else if (tmp == "CIRCLE") - { - cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords ); - } - else if (tmp == "RECT") - { - cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords ); - } - if (cel && tag.HasParam("HREF")) - { - wxString tmp = tag.GetParam("HREF"); - cel->SetLink( tmp ); - } - m_WParser->GetContainer()->InsertCell( cel ); - } - } - - return FALSE; - } - -TAG_HANDLER_END(IMAGE) - - - -TAGS_MODULE_BEGIN(Image) - - TAGS_MODULE_ADD(IMG) - -TAGS_MODULE_END(Image) - - -#endif diff --git a/src/html/mod_layout.cpp b/src/html/mod_layout.cpp deleted file mode 100644 index 1913589b1a..0000000000 --- a/src/html/mod_layout.cpp +++ /dev/null @@ -1,238 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_layout.cpp -// Purpose: wxHtml module for basic paragraphs/layout handling -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#if wxUSE_HTML -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - -#include -#include - -#include - -FORCE_LINK_ME(mod_layout) - - -TAG_HANDLER_BEGIN(P, "P") - - TAG_HANDLER_PROC(tag) - { - if (m_WParser -> GetContainer() -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - } - m_WParser -> GetContainer() -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); - m_WParser -> GetContainer() -> SetAlign(tag); - return FALSE; - } - -TAG_HANDLER_END(P) - - - -TAG_HANDLER_BEGIN(BR, "BR") - - TAG_HANDLER_PROC(tag) - { - int al = m_WParser -> GetContainer() -> GetAlignHor(); - wxHtmlContainerCell *c; - - m_WParser -> CloseContainer(); - c = m_WParser -> OpenContainer(); - c -> SetAlignHor(al); - c -> SetAlign(tag); - return FALSE; - } - -TAG_HANDLER_END(BR) - - - -TAG_HANDLER_BEGIN(CENTER, "CENTER") - - TAG_HANDLER_PROC(tag) - { - int old = m_WParser -> GetAlign(); - wxHtmlContainerCell *c = m_WParser -> GetContainer(); - - m_WParser -> SetAlign(HTML_ALIGN_CENTER); - if (c -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - } - else - c -> SetAlignHor(HTML_ALIGN_CENTER); - - if (tag.HasEnding()) { - ParseInner(tag); - - m_WParser -> SetAlign(old); - if (c -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - } - else - c -> SetAlignHor(old); - - return TRUE; - } - else return FALSE; - } - -TAG_HANDLER_END(CENTER) - - - -TAG_HANDLER_BEGIN(DIV, "DIV") - - TAG_HANDLER_PROC(tag) - { - int old = m_WParser -> GetAlign(); - wxHtmlContainerCell *c = m_WParser -> GetContainer(); - if (c -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - c = m_WParser -> GetContainer(); - c -> SetAlign(tag); - m_WParser -> SetAlign(c -> GetAlignHor()); - } - else { - c -> SetAlign(tag); - m_WParser -> SetAlign(c -> GetAlignHor()); - } - - ParseInner(tag); - - m_WParser -> SetAlign(old); - if (c -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - } - else - c -> SetAlignHor(old); - - return TRUE; - } - -TAG_HANDLER_END(DIV) - - - - -TAG_HANDLER_BEGIN(TITLE, "TITLE") - - TAG_HANDLER_PROC(tag) - { - if (m_WParser -> GetWindow()) { - wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser -> GetWindow()); - if (wfr) { - wxString title = ""; - wxString *src = m_WParser -> GetSource(); - - for (int i = tag.GetBeginPos(); i < tag.GetEndPos1(); i++) title += (*src)[i]; - wfr -> SetTitle(title); - } - } - return TRUE; - } - -TAG_HANDLER_END(TITLE) - - - - -TAG_HANDLER_BEGIN(BODY, "BODY") - - TAG_HANDLER_PROC(tag) - { - unsigned long tmp; - wxColour clr; - - if (tag.HasParam("TEXT")) { - if (tag.ScanParam("TEXT", "#%lX", &tmp) == 1) { - clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); - m_WParser -> SetActualColor(clr); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr)); - } - } - - if (tag.HasParam("LINK")) { - if (tag.ScanParam("LINK", "#%lX", &tmp) == 1) { - clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); - m_WParser -> SetLinkColor(clr); - } - } - - if (tag.HasParam("BGCOLOR")) { - if (tag.ScanParam("BGCOLOR", "#%lX", &tmp) == 1) { - clr = wxColour((tmp & 0xFF0000) >> 16 , (tmp & 0x00FF00) >> 8, (tmp & 0x0000FF)); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(clr, HTML_CLR_BACKGROUND)); - if (m_WParser -> GetWindow() != NULL) - m_WParser -> GetWindow() -> SetBackgroundColour(clr); - } - } - return FALSE; - } - -TAG_HANDLER_END(BODY) - - - -TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE") - - TAG_HANDLER_PROC(tag) - { - wxHtmlContainerCell *c; - - m_WParser -> CloseContainer(); - c = m_WParser -> OpenContainer(); - if (c -> GetAlignHor() == HTML_ALIGN_RIGHT) - c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_RIGHT); - else - c -> SetIndent(5 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT); - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_TOP); - m_WParser -> OpenContainer(); - ParseInner(tag); - c = m_WParser -> CloseContainer(); - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_BOTTOM); - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - return TRUE; - } - -TAG_HANDLER_END(BLOCKQUOTE) - - - - - - -TAGS_MODULE_BEGIN(Layout) - - TAGS_MODULE_ADD(P) - TAGS_MODULE_ADD(BR) - TAGS_MODULE_ADD(CENTER) - TAGS_MODULE_ADD(DIV) - TAGS_MODULE_ADD(TITLE) - TAGS_MODULE_ADD(BODY) - TAGS_MODULE_ADD(BLOCKQUOTE) - -TAGS_MODULE_END(Layout) - -#endif diff --git a/src/html/mod_links.cpp b/src/html/mod_links.cpp deleted file mode 100644 index b3c6ec943f..0000000000 --- a/src/html/mod_links.cpp +++ /dev/null @@ -1,94 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_links.cpp -// Purpose: wxHtml module for links & anchors -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - -#include -#include - - -FORCE_LINK_ME(mod_links) - - -class wxHtmlAnchorCell : public wxHtmlCell -{ - private: - wxString m_AnchorName; - - public: - wxHtmlAnchorCell(const wxString& name) : wxHtmlCell() {m_AnchorName = name;} - virtual const wxHtmlCell* Find(int condition, const void* param) const - { - if ((condition == HTML_COND_ISANCHOR) && (m_AnchorName == (*((const wxString*)param)))) - return this; - else - return wxHtmlCell::Find(condition, param); - } -}; - - - -TAG_HANDLER_BEGIN(A, "A") - - TAG_HANDLER_PROC(tag) - { - if (tag.HasParam("NAME")) { - m_WParser -> GetContainer() -> InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME"))); - } - - if (tag.HasParam("HREF")) { - wxString oldlnk = m_WParser -> GetLink(); - wxColour oldclr = m_WParser -> GetActualColor(); - int oldund = m_WParser -> GetFontUnderlined(); - - m_WParser -> SetActualColor(m_WParser -> GetLinkColor()); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(m_WParser -> GetLinkColor())); - m_WParser -> SetFontUnderlined(TRUE); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - m_WParser -> SetLink(tag.GetParam("HREF")); - - ParseInner(tag); - - m_WParser -> SetLink(oldlnk); - m_WParser -> SetFontUnderlined(oldund); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - m_WParser -> SetActualColor(oldclr); - m_WParser -> GetContainer() -> InsertCell(new wxHtmlColourCell(oldclr)); - - return TRUE; - } - else return FALSE; - } - -TAG_HANDLER_END(A) - - - -TAGS_MODULE_BEGIN(Links) - - TAGS_MODULE_ADD(A) - -TAGS_MODULE_END(Links) - - -#endif diff --git a/src/html/mod_list.cpp b/src/html/mod_list.cpp deleted file mode 100644 index 1f3b49a4eb..0000000000 --- a/src/html/mod_list.cpp +++ /dev/null @@ -1,157 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_list.cpp -// Purpose: wxHtml module for lists -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - - -#include "wx/defs.h" -#if wxUSE_HTML - -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - -#include -#include - -#include - -FORCE_LINK_ME(mod_list) - - -//----------------------------------------------------------------------------- -// wxHtmlListmarkCell -//----------------------------------------------------------------------------- - -class wxHtmlListmarkCell : public wxHtmlCell -{ - private: - wxBrush m_Brush; - public: - wxHtmlListmarkCell(wxDC *dc, const wxColour& clr); - void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); -}; - -wxHtmlListmarkCell::wxHtmlListmarkCell(wxDC* dc, const wxColour& clr) : wxHtmlCell(), m_Brush(clr, wxSOLID) -{ - m_Width = dc -> GetCharWidth(); - m_Height = dc -> GetCharHeight(); - m_Descent = 0; -} - - - -void wxHtmlListmarkCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) -{ - dc.SetBrush(m_Brush); - dc.DrawEllipse(x + m_PosX + m_Width / 4, y + m_PosY + m_Height / 4, m_Width / 2, m_Width / 2); - wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); -} - - - - -//----------------------------------------------------------------------------- -// The list handler: -//----------------------------------------------------------------------------- - - -TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI") - - TAG_HANDLER_VARS - int m_Numbering; - // this is number of actual item of list or 0 for dots - - TAG_HANDLER_CONSTR(OLULLI) - { - m_Numbering = 0; - } - - TAG_HANDLER_PROC(tag) - { - wxHtmlContainerCell *c; - - // List Item: - if (tag.GetName() == "LI") { - if (!tag.IsEnding()) { - m_WParser -> CloseContainer(); - m_WParser -> CloseContainer(); - - c = m_WParser -> OpenContainer(); - c -> SetWidthFloat(2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS); - c -> SetAlignHor(HTML_ALIGN_RIGHT); - if (m_Numbering == 0) - c -> InsertCell(new wxHtmlListmarkCell(m_WParser -> GetDC(), m_WParser -> GetActualColor())); - else { - wxString mark; - mark.Printf("%i.", m_Numbering); - c -> InsertCell(new wxHtmlWordCell(mark, *(m_WParser -> GetDC()))); - } - m_WParser -> CloseContainer(); - - c = m_WParser -> OpenContainer(); - c -> SetIndent(m_WParser -> GetCharWidth() / 4, HTML_INDENT_LEFT); - c -> SetWidthFloat(-2 * m_WParser -> GetCharWidth(), HTML_UNITS_PIXELS); - - m_WParser -> OpenContainer(); - - if (m_Numbering != 0) m_Numbering++; - } - return FALSE; - } - - // Begin of List (not-numbered): "UL", "OL" - else { - int oldnum = m_Numbering; - - if (tag.GetName() == "UL") m_Numbering = 0; - else m_Numbering = 1; - - c = m_WParser -> GetContainer(); - if (c -> GetFirstCell() != NULL) { - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - c = m_WParser -> GetContainer(); - } - c -> SetAlignHor(HTML_ALIGN_LEFT); - c -> SetIndent(2 * m_WParser -> GetCharWidth(), HTML_INDENT_LEFT); - m_WParser -> OpenContainer() -> SetAlignVer(HTML_ALIGN_TOP); - - m_WParser -> OpenContainer(); - m_WParser -> OpenContainer(); - ParseInner(tag); - m_WParser -> CloseContainer(); - - m_WParser -> CloseContainer(); - m_WParser -> CloseContainer(); - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - - m_Numbering = oldnum; - return TRUE; - } - } - -TAG_HANDLER_END(OLULLI) - - -TAGS_MODULE_BEGIN(List) - - TAGS_MODULE_ADD(OLULLI) - -TAGS_MODULE_END(List) - -#endif diff --git a/src/html/mod_pre.cpp b/src/html/mod_pre.cpp deleted file mode 100644 index 0227f795b2..0000000000 --- a/src/html/mod_pre.cpp +++ /dev/null @@ -1,170 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_pre.cpp -// Purpose: wxHtml module for
 ... 
tag (code citation) -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#if wxUSE_HTML -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - -#include -#include - -#include -#include - -FORCE_LINK_ME(mod_pre) - - -//----------------------------------------------------------------------------- -// wxHtmlCodeCell -//----------------------------------------------------------------------------- - -class wxHtmlPRECell : public wxHtmlCell -{ - private: - wxString** m_Text; - // list of wxString objects. - int m_LinesCnt; - // number of lines - int m_LineHeight; - // height of single line of text - - public: - wxHtmlPRECell(const wxString& s, wxDC& dc); - ~wxHtmlPRECell(); - void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); -}; - - -wxHtmlPRECell::wxHtmlPRECell(const wxString& s, wxDC& dc) : wxHtmlCell() -{ - wxStringTokenizer tokenizer(s, "\n"); - wxString tmp; - long int x, z; - int i; - - m_LineHeight = dc.GetCharHeight(); - m_LinesCnt = 0; - m_Text = NULL; - m_Width = m_Height = 0; - - i = 0; -#if (wxVERSION_NUMBER < 2100) - while (tokenizer.HasMoreToken()) { -#else - while (tokenizer.HasMoreTokens()) { -#endif - if (i % 10 == 0) m_Text = (wxString**) realloc(m_Text, sizeof(wxString*) * (i + 10)); - tmp = tokenizer.NextToken(); - tmp.Replace(" ", " ", TRUE); - tmp.Replace(""", "\"", TRUE); - tmp.Replace("<", "<", TRUE); - tmp.Replace(">", ">", TRUE); - tmp.Replace("&", "&", TRUE); - tmp.Replace("\t", " ", TRUE); - tmp.Replace("\r", "", TRUE); - m_Text[i++] = new wxString(tmp); - - dc.GetTextExtent(tmp, &x, &z, &z); - if (x > m_Width) m_Width = x; - m_Height += m_LineHeight; - m_LinesCnt++; - } -} - - - -wxHtmlPRECell::~wxHtmlPRECell() -{ - for (int i = 0; i < m_LinesCnt; i++) delete m_Text[i]; - free(m_Text); -} - - -void wxHtmlPRECell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) -{ - for (int i = 0; i < m_LinesCnt; i++) - dc.DrawText(*(m_Text[i]), x + m_PosX, y + m_PosY + m_LineHeight * i); - - wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); -} - - - - -//----------------------------------------------------------------------------- -// The list handler: -//----------------------------------------------------------------------------- - - -TAG_HANDLER_BEGIN(PRE, "PRE") - - TAG_HANDLER_PROC(tag) - { - wxHtmlContainerCell *c; - - int fixed = m_WParser -> GetFontFixed(), - italic = m_WParser -> GetFontItalic(), - underlined = m_WParser -> GetFontUnderlined(), - bold = m_WParser -> GetFontBold(), - fsize = m_WParser -> GetFontSize(); - - m_WParser -> CloseContainer(); - c = m_WParser -> OpenContainer(); - c -> SetAlignHor(HTML_ALIGN_LEFT); - c -> SetIndent(m_WParser -> GetCharHeight(), HTML_INDENT_VERTICAL); - - m_WParser -> SetFontUnderlined(FALSE); - m_WParser -> SetFontBold(FALSE); - m_WParser -> SetFontItalic(FALSE); - m_WParser -> SetFontFixed(TRUE); - m_WParser -> SetFontSize(0); - c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - - { - wxString cit; - cit = m_WParser -> GetSource() -> Mid(tag.GetBeginPos(), tag.GetEndPos1() - tag.GetBeginPos()); - c -> InsertCell(new wxHtmlPRECell(cit, *(m_WParser -> GetDC()))); - } - - m_WParser -> SetFontUnderlined(underlined); - m_WParser -> SetFontBold(bold); - m_WParser -> SetFontItalic(italic); - m_WParser -> SetFontFixed(fixed); - m_WParser -> SetFontSize(fsize); - c -> InsertCell(new wxHtmlFontCell(m_WParser -> CreateCurrentFont())); - - m_WParser -> CloseContainer(); - m_WParser -> OpenContainer(); - return TRUE; - } - -TAG_HANDLER_END(PRE) - - - - - -TAGS_MODULE_BEGIN(Pre) - - TAGS_MODULE_ADD(PRE) - -TAGS_MODULE_END(Pre) - -#endif diff --git a/src/html/mod_tables.cpp b/src/html/mod_tables.cpp deleted file mode 100644 index 35f14a2849..0000000000 --- a/src/html/mod_tables.cpp +++ /dev/null @@ -1,493 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mod_tables.cpp -// Purpose: wxHtml module for tables -// Author: Vaclav Slavik -// Copyright: (c) 1999 Vaclav Slavik -// Licence: wxWindows Licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation -#endif - -#include - -#if wxUSE_HTML -#ifdef __BORDLANDC__ -#pragma hdrstop -#endif - -#ifndef WXPRECOMP -#include -#endif - - -/* -REMARKS: - 1. This version of mod_tables doesn't support auto-layout algorithm. - This means that all columns are of same width unless explicitly specified. -*/ - - -#include -#include - -#include - -FORCE_LINK_ME(mod_tables) - - -#define TABLE_BORDER_CLR_1 wxColour(0xC5, 0xC2, 0xC5) -#define TABLE_BORDER_CLR_2 wxColour(0x62, 0x61, 0x62) - - -//----------------------------------------------------------------------------- -// wxHtmlTableCell -//----------------------------------------------------------------------------- - - -typedef struct { - int width, units; // universal - int leftpos, pixwidth, maxrealwidth; // temporary (depends on width of table) - } colStruct; - -typedef enum { - cellSpan, - cellUsed, - cellFree - } cellState; - -typedef struct { - wxHtmlContainerCell *cont; - int colspan, rowspan; - int minheight, valign; - cellState flag; - } cellStruct; - - -class wxHtmlTableCell : public wxHtmlContainerCell -{ - protected: - /* These are real attributes: */ - bool m_HasBorders; - // should we draw borders or not? - int m_NumCols, m_NumRows; - // number of columns; rows - colStruct *m_ColsInfo; - // array of column information - cellStruct **m_CellInfo; - // 2D array of all cells in the table : m_CellInfo[row][column] - int m_Spacing; - // spaces between cells - int m_Padding; - // cells internal indentation - - private: - /* ...and these are valid only during parsing of table: */ - int m_ActualCol, m_ActualRow; - // number of actual column (ranging from 0..m_NumCols) - - // default values (for table and row): - int m_tBkg, m_rBkg; - wxString m_tValign, m_rValign; - - - public: - wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag); - ~wxHtmlTableCell(); - virtual void Layout(int w); - - void AddRow(const wxHtmlTag& tag); - void AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag); - private: - void ReallocCols(int cols); - void ReallocRows(int rows); - // reallocates memory to given number of cols/rows - // and changes m_NumCols/m_NumRows value to reflect this change - // NOTE! You CAN'T change m_NumCols/m_NumRows before calling this!! -}; - - - -wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag) - : wxHtmlContainerCell(parent) -{ - m_HasBorders = tag.HasParam("BORDER"); - m_ColsInfo = NULL; - m_NumCols = m_NumRows = 0; - m_CellInfo = NULL; - m_ActualCol = m_ActualRow = -1; - - /* scan params: */ - m_tBkg = m_rBkg = -1; - if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_tBkg); - if (tag.HasParam("VALIGN")) m_tValign = tag.GetParam("VALIGN"); else m_tValign = wxEmptyString; - if (tag.HasParam("CELLSPACING") && tag.ScanParam("CELLSPACING", "%i", &m_Spacing) == 1) {} else m_Spacing = 2; - if (tag.HasParam("CELLPADDING") && tag.ScanParam("CELLPADDING", "%i", &m_Padding) == 1) {} else m_Padding = 3; - - if (m_HasBorders) - SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2); -} - - - -wxHtmlTableCell::~wxHtmlTableCell() -{ - if (m_ColsInfo) free(m_ColsInfo); - if (m_CellInfo) { - for (int i = 0; i < m_NumRows; i++) - free(m_CellInfo[i]); - free(m_CellInfo); - } -} - - - -void wxHtmlTableCell::ReallocCols(int cols) -{ - int i,j; - - for (i = 0; i < m_NumRows; i++) { - m_CellInfo[i] = (cellStruct*) realloc(m_CellInfo[i], sizeof(cellStruct) * cols); - for (j = m_NumCols; j < cols; j++) - m_CellInfo[i][j].flag = cellFree; - } - - m_ColsInfo = (colStruct*) realloc(m_ColsInfo, sizeof(colStruct) * cols); - for (j = m_NumCols; j < cols; j++) { - m_ColsInfo[j].width = 0; - m_ColsInfo[j].units = HTML_UNITS_PERCENT; - } - - m_NumCols = cols; -} - - - -void wxHtmlTableCell::ReallocRows(int rows) -{ - m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows); - if (m_NumCols != 0) { - int x = rows - 1; - m_CellInfo[x] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols); - for (int i = 0; i < m_NumCols; i++) - m_CellInfo[x][i].flag = cellFree; - } - else - m_CellInfo[rows - 1] = NULL; - m_NumRows = rows; -} - - - -void wxHtmlTableCell::AddRow(const wxHtmlTag& tag) -{ - if (m_ActualRow + 1 > m_NumRows - 1) - ReallocRows(m_ActualRow + 2); - m_ActualRow++; - m_ActualCol = -1; - - /* scan params: */ - m_rBkg = m_tBkg; - if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &m_rBkg); - if (tag.HasParam("VALIGN")) m_rValign = tag.GetParam("VALIGN"); else m_rValign = m_tValign; -} - - - -void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag) -{ - do { - m_ActualCol++; - } while ((m_ActualCol < m_NumCols) && (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree)); - if (m_ActualCol > m_NumCols - 1) - ReallocCols(m_ActualCol + 1); - - int r = m_ActualRow, c = m_ActualCol; - - m_CellInfo[r][c].cont = cell; - m_CellInfo[r][c].colspan = 1; - m_CellInfo[r][c].rowspan = 1; - m_CellInfo[r][c].flag = cellUsed; - m_CellInfo[r][c].minheight = 0; - m_CellInfo[r][c].valign = HTML_ALIGN_TOP; - - /* scan for parameters: */ - - // width: - { - if (tag.HasParam("WIDTH")) { - wxString wd = tag.GetParam("WIDTH"); - - if (wd[wd.Length()-1] == '%') { - sscanf(wd.c_str(), "%i%%", &m_ColsInfo[c].width); - m_ColsInfo[c].units = HTML_UNITS_PERCENT; - } - else { - sscanf(wd.c_str(), "%i", &m_ColsInfo[c].width); - m_ColsInfo[c].units = HTML_UNITS_PIXELS; - } - } - } - - - // spanning: - { - if (tag.HasParam("COLSPAN")) tag.ScanParam("COLSPAN", "%i", &m_CellInfo[r][c].colspan); - if (tag.HasParam("ROWSPAN")) tag.ScanParam("ROWSPAN", "%i", &m_CellInfo[r][c].rowspan); - if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) { - int i, j; - - if (r + m_CellInfo[r][c].rowspan > m_NumRows) ReallocRows(r + m_CellInfo[r][c].rowspan); - if (c + m_CellInfo[r][c].colspan > m_NumCols) ReallocCols(c + m_CellInfo[r][c].colspan); - for (i = r; i < r + m_CellInfo[r][c].rowspan; i++) - for (j = c; j < c + m_CellInfo[r][c].colspan; j++) - m_CellInfo[i][j].flag = cellSpan; - m_CellInfo[r][c].flag = cellUsed; - } - } - - //background color: - { - int bk = m_rBkg; - if (tag.HasParam("BGCOLOR")) tag.ScanParam("BGCOLOR", "#%lX", &bk); - if (bk != -1) { - wxColour clr = wxColour((bk & 0xFF0000) >> 16 , (bk & 0x00FF00) >> 8, (bk & 0x0000FF)); - cell -> SetBackgroundColour(clr); - } - } - if (m_HasBorders) - cell -> SetBorder(TABLE_BORDER_CLR_2, TABLE_BORDER_CLR_1); - - // vertical alignment: - { - wxString valign; - if (tag.HasParam("VALIGN")) valign = tag.GetParam("VALIGN"); else valign = m_tValign; - valign.MakeUpper(); - if (valign == "TOP") m_CellInfo[r][c].valign = HTML_ALIGN_TOP; - else if (valign == "BOTTOM") m_CellInfo[r][c].valign = HTML_ALIGN_BOTTOM; - else m_CellInfo[r][c].valign = HTML_ALIGN_CENTER; - } - - cell -> SetIndent(m_Padding, HTML_INDENT_ALL, HTML_UNITS_PIXELS); -} - - - - - -void wxHtmlTableCell::Layout(int w) -{ - /* - - WIDTH ADJUSTING : - - */ - - if (m_WidthFloatUnits == HTML_UNITS_PERCENT) { - if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; - else m_Width = m_WidthFloat * w / 100; - } - else { - if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; - else m_Width = m_WidthFloat; - } - - - /* - - LAYOUTING : - - */ - - /* 1. setup columns widths: */ - { - int wpix = m_Width - (m_NumCols + 1) * m_Spacing; - int i, j; - int wtemp = 0; - - // 1a. setup fixed-width columns: - for (i = 0; i < m_NumCols; i++) - if (m_ColsInfo[i].units == HTML_UNITS_PIXELS) - wpix -= (m_ColsInfo[i].pixwidth = m_ColsInfo[i].width); - - // 1b. setup floating-width columns: - for (i = 0; i < m_NumCols; i++) - if ((m_ColsInfo[i].units == HTML_UNITS_PERCENT) && (m_ColsInfo[i].width != 0)) - wtemp += (m_ColsInfo[i].pixwidth = m_ColsInfo[i].width * wpix / 100); - wpix -= wtemp; - - // 1c. setup defalut columns (no width specification supplied): - // NOTE! This algorithm doesn't conform to HTML standard : it assigns equal widths - // instead of optimal - for (i = j = 0; i < m_NumCols; i++) - if (m_ColsInfo[i].width == 0) j++; - for (i = 0; i < m_NumCols; i++) - if (m_ColsInfo[i].width == 0) - m_ColsInfo[i].pixwidth = wpix / j; - } - - /* 2. compute positions of columns: */ - { - int wpos = m_Spacing; - for (int i = 0; i < m_NumCols; i++) { - m_ColsInfo[i].leftpos = wpos; - wpos += m_ColsInfo[i].pixwidth + m_Spacing; - } - } - - /* 3. sub-layout all cells: */ - { - int *ypos = new int[m_NumRows + 1]; - - int actcol, actrow; - int fullwid; - wxHtmlContainerCell *actcell; - - for (actrow = 0; actrow <= m_NumRows; actrow++) ypos[actrow] = m_Spacing; - - for (actrow = 0; actrow < m_NumRows; actrow++) { - - // 3a. sub-layout and detect max height: - - for (actcol = 0; actcol < m_NumCols; actcol++) { - if (m_CellInfo[actrow][actcol].flag != cellUsed) continue; - actcell = m_CellInfo[actrow][actcol].cont; - fullwid = 0; - for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++) - fullwid += m_ColsInfo[i].pixwidth; - actcell -> SetMinHeight(m_CellInfo[actrow][actcol].minheight, m_CellInfo[actrow][actcol].valign); - actcell -> Layout(fullwid); - - if (ypos[actrow] + actcell -> GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing > ypos[actrow + m_CellInfo[actrow][actcol].rowspan]) - ypos[actrow + m_CellInfo[actrow][actcol].rowspan] = - ypos[actrow] + actcell -> GetHeight() + m_CellInfo[actrow][actcol].rowspan * m_Spacing; - } - } - - - for (actrow = 0; actrow < m_NumRows; actrow++) { - - // 3b. place cells in row & let'em all have same height: - - for (actcol = 0; actcol < m_NumCols; actcol++) { - if (m_CellInfo[actrow][actcol].flag != cellUsed) continue; - actcell = m_CellInfo[actrow][actcol].cont; - actcell -> SetMinHeight( - ypos[actrow + m_CellInfo[actrow][actcol].rowspan] - ypos[actrow] - m_CellInfo[actrow][actcol].rowspan * m_Spacing, - m_CellInfo[actrow][actcol].valign); - fullwid = 0; - for (int i = actcol; i < m_CellInfo[actrow][actcol].colspan + actcol; i++) - fullwid += m_ColsInfo[i].pixwidth; - actcell -> Layout(fullwid); - actcell -> SetPos(m_ColsInfo[actcol].leftpos, ypos[actrow]); - } - - } - m_Height = ypos[m_NumRows]; - delete[] ypos; - } -} - - - - - - -//----------------------------------------------------------------------------- -// The tables handler: -//----------------------------------------------------------------------------- - - -TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH") - - TAG_HANDLER_VARS - wxHtmlTableCell* m_Table; - wxString m_tAlign, m_rAlign; - int m_OldAlign; - - TAG_HANDLER_CONSTR(TABLE) - { - m_Table = NULL; - m_tAlign = m_rAlign = wxEmptyString; - m_OldAlign = HTML_ALIGN_LEFT; - } - - - TAG_HANDLER_PROC(tag) - { - wxHtmlContainerCell *c; - - // new table started, backup upper-level table (if any) and create new: - if (tag.GetName() == "TABLE") { - wxHtmlTableCell *oldt = m_Table; - wxHtmlContainerCell *oldcont; - int m_OldAlign; - - oldcont = c = m_WParser -> OpenContainer(); - - c -> SetWidthFloat(tag); - m_Table = new wxHtmlTableCell(c, tag); - m_OldAlign = m_WParser -> GetAlign(); - m_tAlign = wxEmptyString; - if (tag.HasParam("ALIGN")) m_tAlign = tag.GetParam("ALIGN"); - - ParseInner(tag); - - m_WParser -> SetAlign(m_OldAlign); - m_WParser -> SetContainer(oldcont); - m_WParser -> CloseContainer(); - m_Table = oldt; - return TRUE; - } - - - else if (m_Table && !tag.IsEnding()) { - // new row in table - if (tag.GetName() == "TR") { - m_Table -> AddRow(tag); - m_rAlign = m_tAlign; - if (tag.HasParam("ALIGN")) m_rAlign = tag.GetParam("ALIGN"); - } - - // new cell - else { - m_WParser -> SetAlign(m_OldAlign); - c = m_WParser -> SetContainer(new wxHtmlContainerCell(m_Table)); - m_Table -> AddCell(c, tag); - - m_WParser -> OpenContainer(); - - if (tag.GetName() == "TH") /*header style*/ { - m_WParser -> SetAlign(HTML_ALIGN_CENTER); - } - - { - wxString als; - - als = m_rAlign; - if (tag.HasParam("ALIGN")) als = tag.GetParam("ALIGN"); - als.MakeUpper(); - if (als == "RIGHT") m_WParser -> SetAlign(HTML_ALIGN_RIGHT); - else if (als == "CENTER") m_WParser -> SetAlign(HTML_ALIGN_CENTER); - } - m_WParser -> OpenContainer(); - } - } - return FALSE; - } - -TAG_HANDLER_END(TABLE) - - - - - -TAGS_MODULE_BEGIN(Tables) - - TAGS_MODULE_ADD(TABLE) - -TAGS_MODULE_END(Tables) - - -#endif diff --git a/src/html/search.cpp b/src/html/search.cpp index 73b317620f..1c6e8c77fa 100644 --- a/src/html/search.cpp +++ b/src/html/search.cpp @@ -2,6 +2,7 @@ // Name: search.cpp // Purpose: search engine // Author: Vaclav Slavik +// RCS-ID: $Id$ // Copyright: (c) 1999 Vaclav Slavik // Licence: wxWindows Licence ///////////////////////////////////////////////////////////////////////////// diff --git a/src/html/winpars.cpp b/src/html/winpars.cpp new file mode 100644 index 0000000000..88bf5cc529 --- /dev/null +++ b/src/html/winpars.cpp @@ -0,0 +1,289 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: winpars.cpp +// Purpose: wxHtmlParser class (generic parser) +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vaclav Slavik +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include + +#include "wx/defs.h" +#if wxUSE_HTML + +#ifdef __BORDLANDC__ +#pragma hdrstop +#endif + +#ifndef WXPRECOMP +#include +#endif + +#include "wx/html/htmldefs.h" +#include "wx/html/winpars.h" +#include "wx/html/htmlwin.h" + + +//----------------------------------------------------------------------------- +// wxHtmlWinParser +//----------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlWinParser,wxHtmlParser) + +wxList wxHtmlWinParser::m_Modules; + +wxHtmlWinParser::wxHtmlWinParser(wxWindow *wnd) : wxHtmlParser() +{ + m_Window = wnd; + m_Container = NULL; + m_DC = NULL; + m_CharHeight = m_CharWidth = 0; + m_UseLink = FALSE; + + { + int i, j, k, l, m; + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 2; k++) + for (l = 0; l < 2; l++) + for (m = 0; m < 7; m++) + m_FontsTable[i][j][k][l][m] = NULL; +#ifdef __WXMSW__ + int default_sizes[7] = {7, 8, 10, 12, 16, 22, 30}; +#else + int default_sizes[7] = {10, 12, 14, 16, 19, 24, 32}; +#endif + SetFonts("", wxSLANT, "", wxSLANT, default_sizes); + } + + // fill in wxHtmlParser's tables: + wxNode *node = m_Modules.GetFirst(); + while (node){ + wxHtmlTagsModule *mod = (wxHtmlTagsModule*) node -> GetData(); + mod -> FillHandlersTable(this); + node = node -> GetNext(); + } +} + + + +void wxHtmlWinParser::AddModule(wxHtmlTagsModule *module) +{ + m_Modules.Append(module); +} + + + +void wxHtmlWinParser::SetFonts(wxString normal_face, int normal_italic_mode, wxString fixed_face, int fixed_italic_mode, int *sizes) +{ + for (int i = 0; i < 7; i++) m_FontsSizes[i] = sizes[i]; + m_FontFaceFixed = fixed_face; + m_FontFaceNormal = normal_face; + m_ItalicModeFixed = fixed_italic_mode; + m_ItalicModeNormal = normal_italic_mode; +} + + + +void wxHtmlWinParser::InitParser(const wxString& source) +{ + wxHtmlParser::InitParser(source); + wxASSERT_MSG(m_DC != NULL, _("no DC assigned to wxHtmlWinParser!!")); + + m_FontBold = m_FontItalic = m_FontUnderlined = m_FontFixed = FALSE; + m_FontSize = 0; + CreateCurrentFont(); // we're selecting default font into + m_DC -> GetTextExtent("H", &m_CharWidth, &m_CharHeight); + /* NOTE : we're not using GetCharWidth/Height() because + of differences under X and win + */ + + m_Link = ""; + m_LinkColor.Set(0, 0, 0xFF); + m_ActualColor.Set(0, 0, 0); + m_Align = HTML_ALIGN_LEFT; + m_tmpLastWasSpace = FALSE; + + OpenContainer(); + + OpenContainer(); + m_Container -> InsertCell(new wxHtmlColourCell(m_ActualColor)); + m_Container -> InsertCell(new wxHtmlFontCell(CreateCurrentFont())); +} + + + +void wxHtmlWinParser::DoneParser() +{ + m_Container = NULL; + wxHtmlParser::DoneParser(); +} + + + +wxObject* wxHtmlWinParser::GetProduct() +{ + wxHtmlContainerCell *top; + + CloseContainer(); + OpenContainer(); + GetContainer() -> SetIndent(m_CharHeight, HTML_INDENT_TOP); + top = m_Container; + while (top -> GetParent()) top = top -> GetParent(); + return top; +} + + + +wxList* wxHtmlWinParser::GetTempData() +{ + int i, j, k, l, m; + wxFont *f; + wxList *lst = wxHtmlParser::GetTempData(); + + if (lst == NULL) lst = new wxList; + lst -> DeleteContents(TRUE); + + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + for (k = 0; k < 2; k++) + for (l = 0; l < 2; l++) + for (m = 0; m < 7; m++) { + f = m_FontsTable[i][j][k][l][m]; + if (f) lst -> Append(f); + } + return lst; +} + + + +void wxHtmlWinParser::AddText(const char* txt) +{ + wxHtmlCell *c; + int i = 0, x, lng = strlen(txt); + char temp[HTML_BUFLEN]; + register char d; + int templen = 0; + + if (m_tmpLastWasSpace) { + while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++; + } + + while (i < lng) { + x = 0; + d = temp[templen++] = txt[i]; + if ((d == '\n') || (d == '\r') || (d == ' ') || (d == '\t')) { + i++, x++; + while ((i < lng) && ((txt[i] == '\n') || (txt[i] == '\r') || (txt[i] == ' ') || (txt[i] == '\t'))) i++, x++; + } + else i++; + + if (x) { + temp[templen-1] = ' '; + temp[templen] = 0; + templen = 0; + c = new wxHtmlWordCell(temp, *(GetDC())); + if (m_UseLink) c -> SetLink(m_Link); + m_Container -> InsertCell(c); + m_tmpLastWasSpace = TRUE; + } + } + if (templen) { + temp[templen] = 0; + c = new wxHtmlWordCell(temp, *(GetDC())); + if (m_UseLink) c -> SetLink(m_Link); + m_Container -> InsertCell(c); + m_tmpLastWasSpace = FALSE; + } +} + + + +wxHtmlContainerCell* wxHtmlWinParser::OpenContainer() +{ + m_Container = new wxHtmlContainerCell(m_Container); + m_Container -> SetAlignHor(m_Align); + m_tmpLastWasSpace = TRUE; + /* to avoid space being first character in paragraph */ + return m_Container; +} + + + +wxHtmlContainerCell* wxHtmlWinParser::SetContainer(wxHtmlContainerCell *c) +{ + m_tmpLastWasSpace = TRUE; + /* to avoid space being first character in paragraph */ + return m_Container = c; +} + + + +wxHtmlContainerCell* wxHtmlWinParser::CloseContainer() +{ + m_Container = m_Container -> GetParent(); + return m_Container; +} + + + +wxFont* wxHtmlWinParser::CreateCurrentFont() +{ + int fb = GetFontBold(), + fi = GetFontItalic(), + fu = GetFontUnderlined(), + ff = GetFontFixed(), + fs = GetFontSize() + 2 /*remap from <-2;4> to <0;7>*/ ; + + if (m_FontsTable[fb][fi][fu][ff][fs] == NULL) { + m_FontsTable[fb][fi][fu][ff][fs] = + //wxTheFontList -> FindOrCreateFont( + new wxFont( + m_FontsSizes[fs], + ff ? wxMODERN : wxSWISS, + fi ? (ff ? m_ItalicModeFixed : m_ItalicModeNormal) : wxNORMAL, + fb ? wxBOLD : wxNORMAL, + fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal); + } + m_DC -> SetFont(*(m_FontsTable[fb][fi][fu][ff][fs])); + return (m_FontsTable[fb][fi][fu][ff][fs]); +} + + + + +//----------------------------------------------------------------------------- +// wxHtmlWinTagHandler +//----------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxHtmlWinTagHandler, wxHtmlTagHandler) + + + +//----------------------------------------------------------------------------- +// wxHtmlTagsModule +//----------------------------------------------------------------------------- + + +IMPLEMENT_DYNAMIC_CLASS(wxHtmlTagsModule, wxModule) + + +bool wxHtmlTagsModule::OnInit() +{ + wxHtmlWinParser::AddModule(this); + return TRUE; +} + + + +void wxHtmlTagsModule::OnExit() +{ +} + +#endif \ No newline at end of file diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index b13d2e9459..0428ee6578 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 00:54, 1999/10/02 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T! # diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index 221354d244..d8a2b497bd 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 00:58, 1999/10/02 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T! # diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 124d7a5756..76899b1063 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 20:00, 1999/10/01 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T! # diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index df39ab1845..39aa3176d8 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,5 +1,5 @@ -# This file was automatically generated by tmake at 20:00, 1999/10/01 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T! # @@ -152,20 +152,20 @@ HTMLOBJS = \ $(HTMLDIR)/helpdata.$(OBJSUFF) \ $(HTMLDIR)/helpfrm.$(OBJSUFF) \ $(HTMLDIR)/htmlcell.$(OBJSUFF) \ - $(HTMLDIR)/htmlfilter.$(OBJSUFF) \ - $(HTMLDIR)/htmlparser.$(OBJSUFF) \ + $(HTMLDIR)/htmlfilt.$(OBJSUFF) \ + $(HTMLDIR)/htmlpars.$(OBJSUFF) \ $(HTMLDIR)/htmltag.$(OBJSUFF) \ $(HTMLDIR)/htmlwin.$(OBJSUFF) \ - $(HTMLDIR)/htmlwinparser.$(OBJSUFF) \ - $(HTMLDIR)/mod_fonts.$(OBJSUFF) \ - $(HTMLDIR)/mod_hline.$(OBJSUFF) \ - $(HTMLDIR)/mod_image.$(OBJSUFF) \ - $(HTMLDIR)/mod_layout.$(OBJSUFF) \ - $(HTMLDIR)/mod_links.$(OBJSUFF) \ - $(HTMLDIR)/mod_list.$(OBJSUFF) \ - $(HTMLDIR)/mod_pre.$(OBJSUFF) \ - $(HTMLDIR)/mod_tables.$(OBJSUFF) \ - $(HTMLDIR)/search.$(OBJSUFF) + $(HTMLDIR)/m_fonts.$(OBJSUFF) \ + $(HTMLDIR)/m_hline.$(OBJSUFF) \ + $(HTMLDIR)/m_image.$(OBJSUFF) \ + $(HTMLDIR)/m_layout.$(OBJSUFF) \ + $(HTMLDIR)/m_links.$(OBJSUFF) \ + $(HTMLDIR)/m_list.$(OBJSUFF) \ + $(HTMLDIR)/m_pre.$(OBJSUFF) \ + $(HTMLDIR)/m_tables.$(OBJSUFF) \ + $(HTMLDIR)/search.$(OBJSUFF) \ + $(HTMLDIR)/winpars.$(OBJSUFF) MSWOBJS = \ $(MSWDIR)/accel.$(OBJSUFF) \ diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index e6a5ae8fd7..0c3c083c72 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 20:00, 1999/10/01 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T! # Symantec C++ makefile for the msw objects diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index c3999e489a..41e9982554 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 20:01, 1999/10/01 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T! # File: makefile.vc diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index 30a88a097b..c08b07b927 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 20:01, 1999/10/01 +# This file was automatically generated by tmake at 20:06, 1999/10/02 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T! #!/binb/wmake.exe