removed/replaced include 'wx/wx.h'

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10850 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-07-05 18:48:48 +00:00
parent 2734d68772
commit 04dbb6467b
41 changed files with 587 additions and 625 deletions

View File

@@ -8,7 +8,7 @@
/* /*
REMARKS : REMARKS :
This FS creates local cache (in /tmp directory). The cache is freed This FS creates local cache (in /tmp directory). The cache is freed
on program exit. on program exit.
@@ -31,13 +31,8 @@ limitation)
#if wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS #if wxUSE_FILESYSTEM && wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS
#ifndef WXPRECOMP
#include "wx/wx.h"
#endif
#include "wx/filesys.h" #include "wx/filesys.h"
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// wxInternetFSHandler // wxInternetFSHandler
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------

View File

@@ -19,14 +19,11 @@
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
#ifndef WXPRECOMP
#include "wx/wx.h"
#endif
#include "wx/filesys.h" #include "wx/filesys.h"
#if wxUSE_GUI #if wxUSE_GUI
#include "wx/image.h" #include "wx/image.h"
#include "wx/bitmap.h" #include "wx/bitmap.h"
#endif #endif
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@@ -45,24 +42,24 @@ class WXDLLEXPORT wxMemoryFSHandler : public wxFileSystemHandler
static void AddFile(const wxString& filename, wxImage& image, long type); static void AddFile(const wxString& filename, wxImage& image, long type);
static void AddFile(const wxString& filename, const wxBitmap& bitmap, long type); static void AddFile(const wxString& filename, const wxBitmap& bitmap, long type);
#endif #endif
static void AddFile(const wxString& filename, const wxString& textdata); static void AddFile(const wxString& filename, const wxString& textdata);
static void AddFile(const wxString& filename, const void *binarydata, size_t size); static void AddFile(const wxString& filename, const void *binarydata, size_t size);
// Remove file from memory FS and free occupied memory // Remove file from memory FS and free occupied memory
static void RemoveFile(const wxString& filename); static void RemoveFile(const wxString& filename);
virtual bool CanOpen(const wxString& location); virtual bool CanOpen(const wxString& location);
virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location); virtual wxFSFile* OpenFile(wxFileSystem& fs, const wxString& location);
virtual wxString FindFirst(const wxString& spec, int flags = 0); virtual wxString FindFirst(const wxString& spec, int flags = 0);
virtual wxString FindNext(); virtual wxString FindNext();
private: private:
static wxHashTable *m_Hash; static wxHashTable *m_Hash;
static bool CheckHash(const wxString& filename); static bool CheckHash(const wxString& filename);
}; };
#endif #endif
// wxUSE_FILESYSTEM // wxUSE_FILESYSTEM

View File

@@ -20,11 +20,6 @@
#if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_STREAMS #if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_STREAMS
#ifndef WXPRECOMP
#include "wx/wx.h"
#endif
#include "wx/filesys.h" #include "wx/filesys.h"
class WXDLLEXPORT wxHashTableLong; class WXDLLEXPORT wxHashTableLong;
@@ -42,14 +37,14 @@ class WXDLLEXPORT wxZipFSHandler : public wxFileSystemHandler
virtual wxString FindFirst(const wxString& spec, int flags = 0); virtual wxString FindFirst(const wxString& spec, int flags = 0);
virtual wxString FindNext(); virtual wxString FindNext();
~wxZipFSHandler(); ~wxZipFSHandler();
private: private:
// these vars are used by FindFirst/Next: // these vars are used by FindFirst/Next:
void *m_Archive; void *m_Archive;
wxString m_Pattern, m_BaseDir, m_ZipFile; wxString m_Pattern, m_BaseDir, m_ZipFile;
bool m_AllowDirs, m_AllowFiles; bool m_AllowDirs, m_AllowFiles;
wxHashTableLong *m_DirsFound; wxHashTableLong *m_DirsFound;
wxString DoFind(); wxString DoFind();
}; };

View File

@@ -16,15 +16,7 @@
#pragma interface "filedlgg.h" #pragma interface "filedlgg.h"
#endif #endif
#include "wx/defs.h"
#include "wx/dialog.h" #include "wx/dialog.h"
#include "wx/checkbox.h"
#include "wx/listctrl.h"
#include "wx/textctrl.h"
#include "wx/choice.h"
#include "wx/checkbox.h"
#include "wx/stattext.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
@@ -37,91 +29,14 @@ WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorDefaultWildcardStr;
// classes // classes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxCheckBox;
class wxChoice;
class wxFileData; class wxFileData;
class wxFileCtrl; class wxFileCtrl;
class wxFileDialog; class wxFileDialog;
class wxListEvent;
//----------------------------------------------------------------------------- class wxStaticText;
// wxFileData class wxTextCtrl;
//-----------------------------------------------------------------------------
class wxFileData : public wxObject
{
private:
wxString m_name;
wxString m_fileName;
long m_size;
int m_hour;
int m_minute;
int m_year;
int m_month;
int m_day;
wxString m_permissions;
bool m_isDir;
bool m_isLink;
bool m_isExe;
public:
wxFileData() { }
wxFileData( const wxString &name, const wxString &fname );
wxString GetName() const;
wxString GetFullName() const;
wxString GetHint() const;
wxString GetEntry( int num );
bool IsDir();
bool IsLink();
bool IsExe();
long GetSize();
void MakeItem( wxListItem &item );
void SetNewName( const wxString &name, const wxString &fname );
private:
DECLARE_DYNAMIC_CLASS(wxFileData);
};
//-----------------------------------------------------------------------------
// wxFileCtrl
//-----------------------------------------------------------------------------
class wxFileCtrl : public wxListCtrl
{
private:
wxString m_dirName;
bool m_showHidden;
wxString m_wild;
public:
wxFileCtrl();
wxFileCtrl( wxWindow *win,
wxWindowID id,
const wxString &dirName,
const wxString &wild,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_LIST,
const wxValidator &validator = wxDefaultValidator,
const wxString &name = wxT("filelist") );
void ChangeToListMode();
void ChangeToReportMode();
void ChangeToIconMode();
void ShowHidden( bool show = TRUE );
long Add( wxFileData *fd, wxListItem &item );
void Update();
virtual void StatusbarText( wxChar *WXUNUSED(text) ) {};
void MakeDir();
void GoToParentDir();
void GoToHomeDir();
void GoToDir( const wxString &dir );
void SetWild( const wxString &wild );
void GetDir( wxString &dir );
void OnListDeleteItem( wxListEvent &event );
void OnListDeleteAllItems( wxListEvent &event );
void OnListEndLabelEdit( wxListEvent &event );
private:
DECLARE_DYNAMIC_CLASS(wxFileCtrl);
DECLARE_EVENT_TABLE()
};
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// File selector // File selector
@@ -139,7 +54,7 @@ public:
const wxString& wildCard = wxFileSelectorDefaultWildcardStr, const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0, long style = 0,
const wxPoint& pos = wxDefaultPosition); const wxPoint& pos = wxDefaultPosition);
~wxFileDialog(); virtual ~wxFileDialog();
void SetMessage(const wxString& message) { m_message = message; } void SetMessage(const wxString& message) { m_message = message; }
void SetPath(const wxString& path); void SetPath(const wxString& path);

View File

@@ -16,8 +16,7 @@
#pragma interface "helpxlp.h" #pragma interface "helpxlp.h"
#endif #endif
#include <stdio.h> #include "wx/defs.h"
#include "wx/wx.h"
#if wxUSE_HELP #if wxUSE_HELP

View File

@@ -205,10 +205,7 @@ public:
// mainWindow is sized to whatever's left over. This function for backward // mainWindow is sized to whatever's left over. This function for backward
// compatibility; use LayoutWindow. // compatibility; use LayoutWindow.
bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL) bool LayoutFrame(wxFrame* frame, wxWindow* mainWindow = (wxWindow*) NULL);
{
return LayoutWindow(frame, mainWindow);
}
// mainWindow is sized to whatever's left over. // mainWindow is sized to whatever's left over.
bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL); bool LayoutWindow(wxWindow* frame, wxWindow* mainWindow = (wxWindow*) NULL);

View File

@@ -16,8 +16,12 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_HTML #if wxUSE_HTML
#include "wx/object.h"
class WXDLLEXPORT wxColour;
class WXDLLEXPORT wxHtmlEntitiesParser; class WXDLLEXPORT wxHtmlEntitiesParser;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -60,7 +64,7 @@ public:
// constructs wxHtmlTag object based on HTML tag. // constructs wxHtmlTag object based on HTML tag.
// The tag begins (with '<' character) at position pos in source // The tag begins (with '<' character) at position pos in source
// end_pos is position where parsing ends (usually end of document) // end_pos is position where parsing ends (usually end of document)
wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTag(const wxString& source, int pos, int end_pos,
wxHtmlTagsCache *cache, wxHtmlTagsCache *cache,
wxHtmlEntitiesParser *entParser = NULL); wxHtmlEntitiesParser *entParser = NULL);
@@ -79,7 +83,7 @@ public:
// (or ("WhaT.jpg") if with_commas == TRUE) // (or ("WhaT.jpg") if with_commas == TRUE)
wxString GetParam(const wxString& par, bool with_commas = FALSE) const; wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
// Convenience functions: // Convenience functions:
bool GetParamAsColour(const wxString& par, wxColour *clr) const; bool GetParamAsColour(const wxString& par, wxColour *clr) const;
bool GetParamAsInt(const wxString& par, int *clr) const; bool GetParamAsInt(const wxString& par, int *clr) const;

View File

@@ -23,30 +23,11 @@ I STRONGLY recommend reading and understanding these macros!!
#define _WX_M_TEMPL_H_ #define _WX_M_TEMPL_H_
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_HTML #if wxUSE_HTML
#ifdef __GNUG__
#pragma interface "m_templ.h"
#pragma implementation
#endif
#include <wx/wxprec.h>
#ifdef __BORDLANDC__
#pragma hdrstop
#endif
#ifndef WXPRECOMP
#include <wx/wx.h>
#endif
#include "wx/html/winpars.h" #include "wx/html/winpars.h"
#define TAG_HANDLER_BEGIN(name,tags) \ #define TAG_HANDLER_BEGIN(name,tags) \
class HTML_Handler_##name : public wxHtmlWinTagHandler \ class HTML_Handler_##name : public wxHtmlWinTagHandler \
{ \ { \

View File

@@ -37,7 +37,6 @@ limitation)
#if wxUSE_FILESYSTEM && wxUSE_FS_INET #if wxUSE_FILESYSTEM && wxUSE_FS_INET
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/wfstream.h" #include "wx/wfstream.h"
@@ -74,7 +73,7 @@ static wxString StripProtocolAnchor(const wxString& location)
else myloc = myloc.AfterFirst(wxT(':')); else myloc = myloc.AfterFirst(wxT(':'));
// fix malformed url: // fix malformed url:
if (myloc.Left(2) != wxT("//")) if (myloc.Left(2) != wxT("//"))
{ {
if (myloc.GetChar(0) != wxT('/')) myloc = wxT("//") + myloc; if (myloc.GetChar(0) != wxT('/')) myloc = wxT("//") + myloc;
else myloc = wxT("/") + myloc; else myloc = wxT("/") + myloc;
@@ -89,7 +88,7 @@ static wxString StripProtocolAnchor(const wxString& location)
bool wxInternetFSHandler::CanOpen(const wxString& location) bool wxInternetFSHandler::CanOpen(const wxString& location)
{ {
wxString p = GetProtocol(location); wxString p = GetProtocol(location);
if ((p == wxT("http")) || (p == wxT("ftp"))) if ((p == wxT("http")) || (p == wxT("ftp")))
{ {
wxURL url(p + wxT(":") + StripProtocolAnchor(location)); wxURL url(p + wxT(":") + StripProtocolAnchor(location));
return (url.GetError() == wxURL_NOERR); return (url.GetError() == wxURL_NOERR);
@@ -112,7 +111,7 @@ wxFSFile* wxInternetFSHandler::OpenFile(wxFileSystem& WXUNUSED(fs), const wxStri
if (info == NULL) if (info == NULL)
{ {
wxURL url(right); wxURL url(right);
if (url.GetError() == wxURL_NOERR) if (url.GetError() == wxURL_NOERR)
{ {
s = url.GetInputStream(); s = url.GetInputStream();
content = url.GetProtocol().GetContentType(); content = url.GetProtocol().GetContentType();

View File

@@ -20,7 +20,8 @@
#if wxUSE_FILESYSTEM && wxUSE_STREAMS #if wxUSE_FILESYSTEM && wxUSE_STREAMS
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/intl.h"
#include "wx/log.h"
#endif #endif
#include "wx/filesys.h" #include "wx/filesys.h"
@@ -30,7 +31,7 @@
class MemFSHashObj : public wxObject class MemFSHashObj : public wxObject
{ {
public: public:
MemFSHashObj(const void *data, size_t len) MemFSHashObj(const void *data, size_t len)
{ {
m_Data = new char[len]; m_Data = new char[len];
@@ -38,7 +39,7 @@ class MemFSHashObj : public wxObject
m_Len = len; m_Len = len;
m_Time = wxDateTime::Now(); m_Time = wxDateTime::Now();
} }
MemFSHashObj(wxMemoryOutputStream& stream) MemFSHashObj(wxMemoryOutputStream& stream)
{ {
m_Len = stream.GetSize(); m_Len = stream.GetSize();
@@ -46,12 +47,12 @@ class MemFSHashObj : public wxObject
stream.CopyTo(m_Data, m_Len); stream.CopyTo(m_Data, m_Len);
m_Time = wxDateTime::Now(); m_Time = wxDateTime::Now();
} }
~MemFSHashObj() ~MemFSHashObj()
{ {
delete[] m_Data; delete[] m_Data;
} }
char *m_Data; char *m_Data;
size_t m_Len; size_t m_Len;
wxDateTime m_Time; wxDateTime m_Time;
@@ -78,8 +79,8 @@ wxMemoryFSHandler::~wxMemoryFSHandler()
// as only one copy of FS handler is supposed to exist, we may silently // as only one copy of FS handler is supposed to exist, we may silently
// delete static data here. (There is no way how to remove FS handler from // delete static data here. (There is no way how to remove FS handler from
// wxFileSystem other than releasing _all_ handlers.) // wxFileSystem other than releasing _all_ handlers.)
if (m_Hash) delete m_Hash; if (m_Hash) delete m_Hash;
m_Hash = NULL; m_Hash = NULL;
} }
@@ -131,12 +132,12 @@ wxString wxMemoryFSHandler::FindNext()
bool wxMemoryFSHandler::CheckHash(const wxString& filename) bool wxMemoryFSHandler::CheckHash(const wxString& filename)
{ {
if (m_Hash == NULL) if (m_Hash == NULL)
{ {
m_Hash = new wxHashTable(wxKEY_STRING); m_Hash = new wxHashTable(wxKEY_STRING);
m_Hash -> DeleteContents(TRUE); m_Hash -> DeleteContents(TRUE);
} }
if (m_Hash -> Get(filename) != NULL) if (m_Hash -> Get(filename) != NULL)
{ {
wxString s; wxString s;
@@ -156,7 +157,7 @@ bool wxMemoryFSHandler::CheckHash(const wxString& filename)
{ {
if (!CheckHash(filename)) return; if (!CheckHash(filename)) return;
wxMemoryOutputStream mems; wxMemoryOutputStream mems;
if (image.Ok() && image.SaveFile(mems, (int)type)) if (image.Ok() && image.SaveFile(mems, (int)type))
m_Hash -> Put(filename, new MemFSHashObj(mems)); m_Hash -> Put(filename, new MemFSHashObj(mems));

View File

@@ -22,7 +22,8 @@
#if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_ZIPSTREAM #if wxUSE_FILESYSTEM && wxUSE_FS_ZIP && wxUSE_ZIPSTREAM
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/intl.h"
#include "wx/log.h"
#endif #endif
#include "wx/hash.h" #include "wx/hash.h"

View File

@@ -31,7 +31,6 @@
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/frame.h" #include "wx/frame.h"

View File

@@ -21,8 +21,6 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/defs.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
#if wxUSE_PRINTING_ARCHITECTURE #if wxUSE_PRINTING_ARCHITECTURE

View File

@@ -26,10 +26,16 @@
#error wxFileDialog currently only supports unix #error wxFileDialog currently only supports unix
#endif #endif
#include "wx/checkbox.h"
#include "wx/textctrl.h"
#include "wx/choice.h"
#include "wx/checkbox.h"
#include "wx/stattext.h"
#include "wx/filedlg.h" #include "wx/filedlg.h"
#include "wx/debug.h" #include "wx/debug.h"
#include "wx/log.h" #include "wx/log.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/listctrl.h"
#include "wx/msgdlg.h" #include "wx/msgdlg.h"
#include "wx/sizer.h" #include "wx/sizer.h"
#include "wx/bmpbuttn.h" #include "wx/bmpbuttn.h"
@@ -63,6 +69,88 @@
#include "wx/generic/deffile.xpm" #include "wx/generic/deffile.xpm"
#include "wx/generic/exefile.xpm" #include "wx/generic/exefile.xpm"
//-----------------------------------------------------------------------------
// wxFileData
//-----------------------------------------------------------------------------
class wxFileData : public wxObject
{
private:
wxString m_name;
wxString m_fileName;
long m_size;
int m_hour;
int m_minute;
int m_year;
int m_month;
int m_day;
wxString m_permissions;
bool m_isDir;
bool m_isLink;
bool m_isExe;
public:
wxFileData() { }
wxFileData( const wxString &name, const wxString &fname );
wxString GetName() const;
wxString GetFullName() const;
wxString GetHint() const;
wxString GetEntry( int num );
bool IsDir();
bool IsLink();
bool IsExe();
long GetSize();
void MakeItem( wxListItem &item );
void SetNewName( const wxString &name, const wxString &fname );
private:
DECLARE_DYNAMIC_CLASS(wxFileData);
};
//-----------------------------------------------------------------------------
// wxFileCtrl
//-----------------------------------------------------------------------------
class wxFileCtrl : public wxListCtrl
{
private:
wxString m_dirName;
bool m_showHidden;
wxString m_wild;
public:
wxFileCtrl();
wxFileCtrl( wxWindow *win,
wxWindowID id,
const wxString &dirName,
const wxString &wild,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLC_LIST,
const wxValidator &validator = wxDefaultValidator,
const wxString &name = wxT("filelist") );
void ChangeToListMode();
void ChangeToReportMode();
void ChangeToIconMode();
void ShowHidden( bool show = TRUE );
long Add( wxFileData *fd, wxListItem &item );
void Update();
virtual void StatusbarText( wxChar *WXUNUSED(text) ) {};
void MakeDir();
void GoToParentDir();
void GoToHomeDir();
void GoToDir( const wxString &dir );
void SetWild( const wxString &wild );
void GetDir( wxString &dir );
void OnListDeleteItem( wxListEvent &event );
void OnListDeleteAllItems( wxListEvent &event );
void OnListEndLabelEdit( wxListEvent &event );
private:
DECLARE_DYNAMIC_CLASS(wxFileCtrl);
DECLARE_EVENT_TABLE()
};
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes - icons list management // private classes - icons list management
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -24,7 +24,8 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/mdi.h" #include "wx/frame.h"
#include "wx/mdi.h"
#endif #endif
#include "wx/laywin.h" #include "wx/laywin.h"
@@ -219,6 +220,11 @@ bool wxLayoutAlgorithm::LayoutMDIFrame(wxMDIParentFrame* frame, wxRect* r)
#endif // wxUSE_MDI_ARCHITECTURE #endif // wxUSE_MDI_ARCHITECTURE
bool wxLayoutAlgorithm::LayoutFrame(wxFrame* frame, wxWindow* mainWindow)
{
return LayoutWindow(frame, mainWindow);
}
// Layout algorithm for any window. mainWindow gets what's left over. // Layout algorithm for any window. mainWindow gets what's left over.
bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow) bool wxLayoutAlgorithm::LayoutWindow(wxWindow* parent, wxWindow* mainWindow)
{ {

View File

@@ -28,8 +28,6 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#include "wx/defs.h"
#if wxUSE_PRINTING_ARCHITECTURE #if wxUSE_PRINTING_ARCHITECTURE
#ifndef WX_PRECOMP #ifndef WX_PRECOMP

View File

@@ -23,7 +23,6 @@
#if wxUSE_PROPSHEET #if wxUSE_PROPSHEET
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/debug.h" #include "wx/debug.h"

View File

@@ -23,7 +23,6 @@
#if wxUSE_PROPSHEET #if wxUSE_PROPSHEET
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/propform.h" #include "wx/propform.h"

View File

@@ -25,13 +25,14 @@
#if wxUSE_SASH #if wxUSE_SASH
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h" #include "wx/dialog.h"
#include "wx/frame.h"
#include "wx/settings.h"
#endif #endif
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include "wx/string.h"
#include "wx/dcscreen.h" #include "wx/dcscreen.h"
#include "wx/sashwin.h" #include "wx/sashwin.h"
#include "wx/laywin.h" #include "wx/laywin.h"

View File

@@ -6,7 +6,7 @@
// Created: 28/6/2000 // Created: 28/6/2000
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
@@ -23,7 +23,6 @@
#if wxUSE_SPLASH #if wxUSE_SPLASH
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/splash.h" #include "wx/splash.h"

View File

@@ -25,7 +25,8 @@
#if wxUSE_HTML && wxUSE_STREAMS #if wxUSE_HTML && wxUSE_STREAMS
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/intl.h"
#include "wx/log.h"
#endif #endif
#include "wx/html/helpdata.h" #include "wx/html/helpdata.h"
@@ -93,9 +94,9 @@ class HP_TagHandler : public wxHtmlTagHandler
wxHtmlBookRecord *m_Book; wxHtmlBookRecord *m_Book;
public: public:
HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler() HP_TagHandler(wxHtmlBookRecord *b) : wxHtmlTagHandler()
{ m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString; { m_Book = b; m_Items = NULL; m_ItemsCnt = 0; m_Name = m_Page = wxEmptyString;
m_Level = 0; m_ID = -1; } m_Level = 0; m_ID = -1; }
wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); } wxString GetSupportedTags() { return wxT("UL,OBJECT,PARAM"); }
bool HandleTag(const wxHtmlTag& tag); bool HandleTag(const wxHtmlTag& tag);
void WriteOut(wxHtmlContentsItem*& array, int& size); void WriteOut(wxHtmlContentsItem*& array, int& size);
@@ -105,14 +106,14 @@ class HP_TagHandler : public wxHtmlTagHandler
bool HP_TagHandler::HandleTag(const wxHtmlTag& tag) bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
{ {
if (tag.GetName() == wxT("UL")) if (tag.GetName() == wxT("UL"))
{ {
m_Level++; m_Level++;
ParseInner(tag); ParseInner(tag);
m_Level--; m_Level--;
return TRUE; return TRUE;
} }
else if (tag.GetName() == wxT("OBJECT")) else if (tag.GetName() == wxT("OBJECT"))
{ {
m_Name = m_Page = wxEmptyString; m_Name = m_Page = wxEmptyString;
ParseInner(tag); ParseInner(tag);
@@ -120,18 +121,18 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
#if 0 #if 0
if (!m_Page.IsEmpty()) if (!m_Page.IsEmpty())
/* Valid HHW's file may contain only two object tags: /* Valid HHW's file may contain only two object tags:
<OBJECT type="text/site properties"> <OBJECT type="text/site properties">
<param name="ImageType" value="Folder"> <param name="ImageType" value="Folder">
</OBJECT> </OBJECT>
or or
<OBJECT type="text/sitemap"> <OBJECT type="text/sitemap">
<param name="Name" value="main page"> <param name="Name" value="main page">
<param name="Local" value="another.htm"> <param name="Local" value="another.htm">
</OBJECT> </OBJECT>
We're interested in the latter. !m_Page.IsEmpty() is valid We're interested in the latter. !m_Page.IsEmpty() is valid
condition because text/site properties does not contain Local param condition because text/site properties does not contain Local param
*/ */
@@ -139,8 +140,8 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
if (tag.GetParam(wxT("TYPE")) == wxT("text/sitemap")) if (tag.GetParam(wxT("TYPE")) == wxT("text/sitemap"))
{ {
if (m_ItemsCnt % wxHTML_REALLOC_STEP == 0) if (m_ItemsCnt % wxHTML_REALLOC_STEP == 0)
m_Items = (wxHtmlContentsItem*) realloc(m_Items, m_Items = (wxHtmlContentsItem*) realloc(m_Items,
(m_ItemsCnt + wxHTML_REALLOC_STEP) * (m_ItemsCnt + wxHTML_REALLOC_STEP) *
sizeof(wxHtmlContentsItem)); sizeof(wxHtmlContentsItem));
m_Items[m_ItemsCnt].m_Level = m_Level; m_Items[m_ItemsCnt].m_Level = m_Level;
@@ -155,13 +156,13 @@ bool HP_TagHandler::HandleTag(const wxHtmlTag& tag)
return TRUE; return TRUE;
} }
else else
{ // "PARAM" { // "PARAM"
if (m_Name == wxEmptyString && tag.GetParam(wxT("NAME")) == wxT("Name")) if (m_Name == wxEmptyString && tag.GetParam(wxT("NAME")) == wxT("Name"))
m_Name = tag.GetParam(wxT("VALUE")); m_Name = tag.GetParam(wxT("VALUE"));
if (tag.GetParam(wxT("NAME")) == wxT("Local")) if (tag.GetParam(wxT("NAME")) == wxT("Local"))
m_Page = tag.GetParam(wxT("VALUE")); m_Page = tag.GetParam(wxT("VALUE"));
if (tag.GetParam(wxT("NAME")) == wxT("ID")) if (tag.GetParam(wxT("NAME")) == wxT("ID"))
tag.GetParamAsInt(wxT("VALUE"), &m_ID); tag.GetParamAsInt(wxT("VALUE"), &m_ID);
return FALSE; return FALSE;
} }
@@ -217,19 +218,19 @@ wxHtmlHelpData::~wxHtmlHelpData()
int i; int i;
m_BookRecords.Empty(); m_BookRecords.Empty();
if (m_Contents) if (m_Contents)
{ {
for (i = 0; i < m_ContentsCnt; i++) for (i = 0; i < m_ContentsCnt; i++)
{ {
delete[] m_Contents[i].m_Page; delete[] m_Contents[i].m_Page;
delete[] m_Contents[i].m_Name; delete[] m_Contents[i].m_Name;
} }
free(m_Contents); free(m_Contents);
} }
if (m_Index) if (m_Index)
{ {
for (i = 0; i < m_IndexCnt; i++) for (i = 0; i < m_IndexCnt; i++)
{ {
delete[] m_Index[i].m_Page; delete[] m_Index[i].m_Page;
delete[] m_Index[i].m_Name; delete[] m_Index[i].m_Name;
} }
@@ -249,7 +250,7 @@ bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, c
parser.AddTagHandler(handler); parser.AddTagHandler(handler);
f = ( contentsfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(contentsfile) ); f = ( contentsfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(contentsfile) );
if (f) if (f)
{ {
sz = f->GetStream()->GetSize(); sz = f->GetStream()->GetSize();
buf = new char[sz + 1]; buf = new char[sz + 1];
@@ -265,7 +266,7 @@ bool wxHtmlHelpData::LoadMSProject(wxHtmlBookRecord *book, wxFileSystem& fsys, c
wxLogError(_("Cannot open contents file: %s"), contentsfile.c_str()); wxLogError(_("Cannot open contents file: %s"), contentsfile.c_str());
f = ( indexfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(indexfile) ); f = ( indexfile.IsEmpty() ? (wxFSFile*) NULL : fsys.OpenFile(indexfile) );
if (f) if (f)
{ {
sz = f->GetStream()->GetSize(); sz = f->GetStream()->GetSize();
buf = new char[sz + 1]; buf = new char[sz + 1];
@@ -310,23 +311,23 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f)
f->Read(&x, sizeof(x)); f->Read(&x, sizeof(x));
version = wxINT32_SWAP_ON_BE(x); version = wxINT32_SWAP_ON_BE(x);
if (version != CURRENT_CACHED_BOOK_VERSION) if (version != CURRENT_CACHED_BOOK_VERSION)
{ {
wxLogError(_("Incorrect version of HTML help book")); wxLogError(_("Incorrect version of HTML help book"));
return FALSE; return FALSE;
// NOTE: when adding new version, please ensure backward compatibility! // NOTE: when adding new version, please ensure backward compatibility!
} }
/* load contents : */ /* load contents : */
f->Read(&x, sizeof(x)); f->Read(&x, sizeof(x));
st = m_ContentsCnt; st = m_ContentsCnt;
m_ContentsCnt += wxINT32_SWAP_ON_BE(x); m_ContentsCnt += wxINT32_SWAP_ON_BE(x);
m_Contents = (wxHtmlContentsItem*) realloc(m_Contents, m_Contents = (wxHtmlContentsItem*) realloc(m_Contents,
(m_ContentsCnt / wxHTML_REALLOC_STEP + 1) * (m_ContentsCnt / wxHTML_REALLOC_STEP + 1) *
wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem)); wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem));
for (i = st; i < m_ContentsCnt; i++) for (i = st; i < m_ContentsCnt; i++)
{ {
f->Read(&x, sizeof(x)); f->Read(&x, sizeof(x));
m_Contents[i].m_Level = wxINT32_SWAP_ON_BE(x); m_Contents[i].m_Level = wxINT32_SWAP_ON_BE(x);
@@ -346,9 +347,9 @@ bool wxHtmlHelpData::LoadCachedBook(wxHtmlBookRecord *book, wxInputStream *f)
f->Read(&x, sizeof(x)); f->Read(&x, sizeof(x));
st = m_IndexCnt; st = m_IndexCnt;
m_IndexCnt += wxINT32_SWAP_ON_BE(x); m_IndexCnt += wxINT32_SWAP_ON_BE(x);
m_Index = (wxHtmlContentsItem*) realloc(m_Index, (m_IndexCnt / wxHTML_REALLOC_STEP + 1) * m_Index = (wxHtmlContentsItem*) realloc(m_Index, (m_IndexCnt / wxHTML_REALLOC_STEP + 1) *
wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem)); wxHTML_REALLOC_STEP * sizeof(wxHtmlContentsItem));
for (i = st; i < m_IndexCnt; i++) for (i = st; i < m_IndexCnt; i++)
{ {
f->Read(&x, sizeof(x)); x = wxINT32_SWAP_ON_BE(x); f->Read(&x, sizeof(x)); x = wxINT32_SWAP_ON_BE(x);
m_Index[i].m_Name = new wxChar[x]; m_Index[i].m_Name = new wxChar[x];
@@ -378,7 +379,7 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f)
for (i = 0; i < m_ContentsCnt; i++) if (m_Contents[i].m_Book == book && m_Contents[i].m_Level > 0) x++; for (i = 0; i < m_ContentsCnt; i++) if (m_Contents[i].m_Book == book && m_Contents[i].m_Level > 0) x++;
x = wxINT32_SWAP_ON_BE(x); x = wxINT32_SWAP_ON_BE(x);
f->Write(&x, sizeof(x)); f->Write(&x, sizeof(x));
for (i = 0; i < m_ContentsCnt; i++) for (i = 0; i < m_ContentsCnt; i++)
{ {
if (m_Contents[i].m_Book != book || m_Contents[i].m_Level == 0) continue; if (m_Contents[i].m_Book != book || m_Contents[i].m_Level == 0) continue;
x = wxINT32_SWAP_ON_BE(m_Contents[i].m_Level); x = wxINT32_SWAP_ON_BE(m_Contents[i].m_Level);
@@ -399,7 +400,7 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f)
for (i = 0; i < m_IndexCnt; i++) if (m_Index[i].m_Book == book && m_Index[i].m_Level > 0) x++; for (i = 0; i < m_IndexCnt; i++) if (m_Index[i].m_Book == book && m_Index[i].m_Level > 0) x++;
x = wxINT32_SWAP_ON_BE(x); x = wxINT32_SWAP_ON_BE(x);
f->Write(&x, sizeof(x)); f->Write(&x, sizeof(x));
for (i = 0; i < m_IndexCnt; i++) for (i = 0; i < m_IndexCnt; i++)
{ {
if (m_Index[i].m_Book != book || m_Index[i].m_Level == 0) continue; if (m_Index[i].m_Book != book || m_Index[i].m_Level == 0) continue;
x = wxINT32_SWAP_ON_BE(wxStrlen(m_Index[i].m_Name) + 1); x = wxINT32_SWAP_ON_BE(wxStrlen(m_Index[i].m_Name) + 1);
@@ -416,7 +417,7 @@ bool wxHtmlHelpData::SaveCachedBook(wxHtmlBookRecord *book, wxOutputStream *f)
void wxHtmlHelpData::SetTempDir(const wxString& path) void wxHtmlHelpData::SetTempDir(const wxString& path)
{ {
if (path == wxEmptyString) m_TempPath = path; if (path == wxEmptyString) m_TempPath = path;
else else
{ {
if (wxIsAbsolutePath(path)) m_TempPath = path; if (wxIsAbsolutePath(path)) m_TempPath = path;
else m_TempPath = wxGetCwd() + _T("/") + path; else m_TempPath = wxGetCwd() + _T("/") + path;
@@ -447,7 +448,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
wxFileSystem fsys; wxFileSystem fsys;
wxFSFile *fi; wxFSFile *fi;
wxHtmlBookRecord *bookr; wxHtmlBookRecord *bookr;
int IndexOld = m_IndexCnt, int IndexOld = m_IndexCnt,
ContentsOld = m_ContentsCnt; ContentsOld = m_ContentsCnt;
@@ -473,35 +474,35 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
// 1. save file as book, but with .hhp.cached extension // 1. save file as book, but with .hhp.cached extension
// 2. same as 1. but in temp path // 2. same as 1. but in temp path
// 3. otherwise or if cache load failed, load it from MS. // 3. otherwise or if cache load failed, load it from MS.
fi = fsys.OpenFile(bookfile.GetLocation() + wxT(".cached")); fi = fsys.OpenFile(bookfile.GetLocation() + wxT(".cached"));
if (fi == NULL || if (fi == NULL ||
fi->GetModificationTime() < bookfile.GetModificationTime() || fi->GetModificationTime() < bookfile.GetModificationTime() ||
!LoadCachedBook(bookr, fi->GetStream())) !LoadCachedBook(bookr, fi->GetStream()))
{ {
if (fi != NULL) delete fi; if (fi != NULL) delete fi;
fi = fsys.OpenFile(m_TempPath + wxFileNameFromPath(bookfile.GetLocation()) + wxT(".cached")); fi = fsys.OpenFile(m_TempPath + wxFileNameFromPath(bookfile.GetLocation()) + wxT(".cached"));
if (m_TempPath == wxEmptyString || fi == NULL || if (m_TempPath == wxEmptyString || fi == NULL ||
fi->GetModificationTime() < bookfile.GetModificationTime() || fi->GetModificationTime() < bookfile.GetModificationTime() ||
!LoadCachedBook(bookr, fi->GetStream())) !LoadCachedBook(bookr, fi->GetStream()))
{ {
LoadMSProject(bookr, fsys, indexfile, contfile); LoadMSProject(bookr, fsys, indexfile, contfile);
if (m_TempPath != wxEmptyString) if (m_TempPath != wxEmptyString)
{ {
wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath + wxFileOutputStream *outs = new wxFileOutputStream(m_TempPath +
SafeFileName(wxFileNameFromPath(bookfile.GetLocation())) + wxT(".cached")); SafeFileName(wxFileNameFromPath(bookfile.GetLocation())) + wxT(".cached"));
SaveCachedBook(bookr, outs); SaveCachedBook(bookr, outs);
delete outs; delete outs;
} }
} }
} }
if (fi != NULL) delete fi; if (fi != NULL) delete fi;
// Now store the contents range // Now store the contents range
bookr->SetContentsRange(cont_start, m_ContentsCnt); bookr->SetContentsRange(cont_start, m_ContentsCnt);
// Convert encoding, if neccessary: // Convert encoding, if neccessary:
if (encoding != wxFONTENCODING_SYSTEM) if (encoding != wxFONTENCODING_SYSTEM)
{ {
@@ -511,7 +512,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
int i; int i;
wxEncodingConverter conv; wxEncodingConverter conv;
conv.Init(encoding, a[0]); conv.Init(encoding, a[0]);
for (i = IndexOld; i < m_IndexCnt; i++) for (i = IndexOld; i < m_IndexCnt; i++)
conv.Convert(m_Index[i].m_Name); conv.Convert(m_Index[i].m_Name);
for (i = ContentsOld; i < m_ContentsCnt; i++) for (i = ContentsOld; i < m_ContentsCnt; i++)
@@ -530,7 +531,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile,
bool wxHtmlHelpData::AddBook(const wxString& book) bool wxHtmlHelpData::AddBook(const wxString& book)
{ {
if (book.Right(4).Lower() == wxT(".zip") || if (book.Right(4).Lower() == wxT(".zip") ||
book.Right(4).Lower() == wxT(".htb") /*html book*/) book.Right(4).Lower() == wxT(".htb") /*html book*/)
{ {
wxFileSystem fsys; wxFileSystem fsys;
@@ -538,18 +539,18 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
bool rt = FALSE; bool rt = FALSE;
s = fsys.FindFirst(book + wxT("#zip:") + wxT("*.hhp"), wxFILE); s = fsys.FindFirst(book + wxT("#zip:") + wxT("*.hhp"), wxFILE);
while (!s.IsEmpty()) while (!s.IsEmpty())
{ {
if (AddBook(s)) rt = TRUE; if (AddBook(s)) rt = TRUE;
s = fsys.FindNext(); s = fsys.FindNext();
} }
return rt; return rt;
} }
else else
{ {
wxFSFile *fi; wxFSFile *fi;
wxFileSystem fsys; wxFileSystem fsys;
wxInputStream *s; wxInputStream *s;
@@ -562,7 +563,7 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
wxString title = _("noname"), wxString title = _("noname"),
safetitle, safetitle,
start = wxEmptyString, start = wxEmptyString,
contents = wxEmptyString, contents = wxEmptyString,
index = wxEmptyString, index = wxEmptyString,
charset = wxEmptyString; charset = wxEmptyString;
@@ -570,7 +571,7 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
else bookFull = wxGetCwd() + "/" + book; else bookFull = wxGetCwd() + "/" + book;
fi = fsys.OpenFile(bookFull); fi = fsys.OpenFile(bookFull);
if (fi == NULL) if (fi == NULL)
{ {
wxLogError(_("Cannot open HTML help book: %s"), bookFull.c_str()); wxLogError(_("Cannot open HTML help book: %s"), bookFull.c_str());
return FALSE; return FALSE;
@@ -598,11 +599,11 @@ bool wxHtmlHelpData::AddBook(const wxString& book)
charset = linebuf + strlen("Charset="); charset = linebuf + strlen("Charset=");
} while (lineptr != NULL); } while (lineptr != NULL);
delete[] buff; delete[] buff;
wxFontEncoding enc; wxFontEncoding enc;
if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM; if (charset == wxEmptyString) enc = wxFONTENCODING_SYSTEM;
else enc = wxTheFontMapper->CharsetToEncoding(charset); else enc = wxTheFontMapper->CharsetToEncoding(charset);
bool rtval = AddBookParam(*fi, enc, bool rtval = AddBookParam(*fi, enc,
title, contents, index, start, fsys.GetPath()); title, contents, index, start, fsys.GetPath());
delete fi; delete fi;
return rtval; return rtval;
@@ -620,11 +621,11 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
/* 1. try to open given file: */ /* 1. try to open given file: */
cnt = m_BookRecords.GetCount(); cnt = m_BookRecords.GetCount();
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
f = fsys.OpenFile(m_BookRecords[i].GetFullPath(x)); f = fsys.OpenFile(m_BookRecords[i].GetFullPath(x));
if (f) if (f)
{ {
url = m_BookRecords[i].GetFullPath(x); url = m_BookRecords[i].GetFullPath(x);
delete f; delete f;
return url; return url;
@@ -634,10 +635,10 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
/* 2. try to find a book: */ /* 2. try to find a book: */
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
if (m_BookRecords[i].GetTitle() == x) if (m_BookRecords[i].GetTitle() == x)
{ {
url = m_BookRecords[i].GetFullPath(m_BookRecords[i].GetStart()); url = m_BookRecords[i].GetFullPath(m_BookRecords[i].GetStart());
return url; return url;
} }
@@ -646,10 +647,10 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
/* 3. try to find in contents: */ /* 3. try to find in contents: */
cnt = m_ContentsCnt; cnt = m_ContentsCnt;
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
if (wxStrcmp(m_Contents[i].m_Name, x) == 0) if (wxStrcmp(m_Contents[i].m_Name, x) == 0)
{ {
url = m_Contents[i].GetFullPath(); url = m_Contents[i].GetFullPath();
return url; return url;
} }
@@ -659,10 +660,10 @@ wxString wxHtmlHelpData::FindPageByName(const wxString& x)
/* 4. try to find in index: */ /* 4. try to find in index: */
cnt = m_IndexCnt; cnt = m_IndexCnt;
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
{ {
if (wxStrcmp(m_Index[i].m_Name, x) == 0) if (wxStrcmp(m_Index[i].m_Name, x) == 0)
{ {
url = m_Index[i].GetFullPath(); url = m_Index[i].GetFullPath();
return url; return url;
} }
@@ -676,10 +677,10 @@ wxString wxHtmlHelpData::FindPageById(int id)
int i; int i;
wxString url(wxEmptyString); wxString url(wxEmptyString);
for (i = 0; i < m_ContentsCnt; i++) for (i = 0; i < m_ContentsCnt; i++)
{ {
if (m_Contents[i].m_ID == id) if (m_Contents[i].m_ID == id)
{ {
url = m_Contents[i].GetFullPath(); url = m_Contents[i].GetFullPath();
return url; return url;
} }
@@ -699,13 +700,13 @@ wxHtmlSearchStatus::wxHtmlSearchStatus(wxHtmlHelpData* data, const wxString& key
m_Data = data; m_Data = data;
m_Keyword = keyword; m_Keyword = keyword;
wxHtmlBookRecord* bookr = NULL; wxHtmlBookRecord* bookr = NULL;
if (book != wxEmptyString) if (book != wxEmptyString)
{ {
// we have to search in a specific book. Find it first // we have to search in a specific book. Find it first
int i, cnt = data->m_BookRecords.GetCount(); int i, cnt = data->m_BookRecords.GetCount();
for (i = 0; i < cnt; i++) for (i = 0; i < cnt; i++)
if (data->m_BookRecords[i].GetTitle() == book) if (data->m_BookRecords[i].GetTitle() == book)
{ {
bookr = &(data->m_BookRecords[i]); bookr = &(data->m_BookRecords[i]);
m_CurIndex = bookr->GetContentsStart(); m_CurIndex = bookr->GetContentsStart();
m_MaxIndex = bookr->GetContentsEnd(); m_MaxIndex = bookr->GetContentsEnd();
@@ -714,7 +715,7 @@ wxHtmlSearchStatus::wxHtmlSearchStatus(wxHtmlHelpData* data, const wxString& key
// check; we won't crash if the book doesn't exist, but it's Bad Anyway. // check; we won't crash if the book doesn't exist, but it's Bad Anyway.
wxASSERT(bookr); wxASSERT(bookr);
} }
if (! bookr) if (! bookr)
{ {
// no book specified; search all books // no book specified; search all books
m_CurIndex = 0; m_CurIndex = 0;
@@ -732,7 +733,7 @@ bool wxHtmlSearchStatus::Search()
bool found = FALSE; bool found = FALSE;
wxChar *thepage; wxChar *thepage;
if (!m_Active) if (!m_Active)
{ {
// sanity check. Illegal use, but we'll try to prevent a crash anyway // sanity check. Illegal use, but we'll try to prevent a crash anyway
wxASSERT(m_Active); wxASSERT(m_Active);
@@ -748,7 +749,7 @@ bool wxHtmlSearchStatus::Search()
if (m_LastPage != NULL) if (m_LastPage != NULL)
{ {
wxChar *p1, *p2; wxChar *p1, *p2;
for (p1 = thepage, p2 = m_LastPage; for (p1 = thepage, p2 = m_LastPage;
*p1 != 0 && *p1 != _T('#') && *p1 == *p2; p1++, p2++) {} *p1 != 0 && *p1 != _T('#') && *p1 == *p2; p1++, p2++) {}
m_LastPage = thepage; m_LastPage = thepage;
@@ -757,12 +758,12 @@ bool wxHtmlSearchStatus::Search()
return FALSE; return FALSE;
} }
else m_LastPage = thepage; else m_LastPage = thepage;
wxFileSystem fsys; wxFileSystem fsys;
file = fsys.OpenFile(m_Data->m_Contents[i].m_Book->GetFullPath(thepage)); file = fsys.OpenFile(m_Data->m_Contents[i].m_Book->GetFullPath(thepage));
if (file) if (file)
{ {
if (m_Engine.Scan(file->GetStream())) if (m_Engine.Scan(file->GetStream()))
{ {
m_Name = m_Data->m_Contents[i].m_Name; m_Name = m_Data->m_Contents[i].m_Name;
m_ContentsItem = m_Data->m_Contents + i; m_ContentsItem = m_Data->m_Contents + i;
@@ -791,15 +792,15 @@ void wxSearchEngine::LookFor(const wxString& keyword, bool case_sensitive, bool
if (m_Keyword) delete[] m_Keyword; if (m_Keyword) delete[] m_Keyword;
m_Keyword = new wxChar[keyword.Length() + 1]; m_Keyword = new wxChar[keyword.Length() + 1];
wxStrcpy(m_Keyword, keyword.c_str()); wxStrcpy(m_Keyword, keyword.c_str());
if (!m_CaseSensitive) if (!m_CaseSensitive)
{ {
for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--) for (int i = wxStrlen(m_Keyword) - 1; i >= 0; i--)
{ {
if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z'))) if ((m_Keyword[i] >= wxT('A')) && (m_Keyword[i] <= wxT('Z')))
m_Keyword[i] += wxT('a') - wxT('A'); m_Keyword[i] += wxT('a') - wxT('A');
} }
} }
} }
@@ -824,19 +825,19 @@ bool wxSearchEngine::Scan(wxInputStream *stream)
if (m_WholeWords) if (m_WholeWords)
{ {
for (i = 0; i < lng - wrd; i++) for (i = 0; i < lng - wrd; i++)
{ {
if (WHITESPACE(buf[i])) continue; if (WHITESPACE(buf[i])) continue;
j = 0; j = 0;
while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++; while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++;
if (j == wrd && WHITESPACE(buf[i + j])) { found = TRUE; break; } if (j == wrd && WHITESPACE(buf[i + j])) { found = TRUE; break; }
} }
} }
else else
{ {
for (i = 0; i < lng - wrd; i++) for (i = 0; i < lng - wrd; i++)
{ {
j = 0; j = 0;
while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++; while ((j < wrd) && (buf[i + j] == m_Keyword[j])) j++;
if (j == wrd) { found = TRUE; break; } if (j == wrd) { found = TRUE; break; }

View File

@@ -22,7 +22,9 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/brush.h"
#include "wx/colour.h"
#include "wx/dc.h"
#endif #endif
#include "wx/html/htmlcell.h" #include "wx/html/htmlcell.h"
@@ -34,23 +36,23 @@
// wxHtmlCell // wxHtmlCell
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
wxHtmlCell::wxHtmlCell() : wxObject() wxHtmlCell::wxHtmlCell() : wxObject()
{ {
m_Next = NULL; m_Next = NULL;
m_Parent = NULL; m_Parent = NULL;
m_Width = m_Height = m_Descent = 0; m_Width = m_Height = m_Descent = 0;
m_CanLiveOnPagebreak = TRUE; m_CanLiveOnPagebreak = TRUE;
m_Link = NULL; m_Link = NULL;
} }
wxHtmlCell::~wxHtmlCell() wxHtmlCell::~wxHtmlCell()
{ {
if (m_Link) delete m_Link; if (m_Link) delete m_Link;
if (m_Next) delete m_Next; if (m_Next) delete m_Next;
} }
void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
const wxMouseEvent& event) const wxMouseEvent& event)
{ {
wxHtmlLinkInfo *lnk = GetLink(x, y); wxHtmlLinkInfo *lnk = GetLink(x, y);
@@ -68,15 +70,15 @@ void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y,
bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
{ {
if ((!m_CanLiveOnPagebreak) && if ((!m_CanLiveOnPagebreak) &&
m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak) m_PosY < *pagebreak && m_PosY + m_Height > *pagebreak)
{ {
*pagebreak = m_PosY; *pagebreak = m_PosY;
if (m_Next != NULL) m_Next->AdjustPagebreak(pagebreak); if (m_Next != NULL) m_Next->AdjustPagebreak(pagebreak);
return TRUE; return TRUE;
} }
else else
{ {
if (m_Next != NULL) return m_Next->AdjustPagebreak(pagebreak); if (m_Next != NULL) return m_Next->AdjustPagebreak(pagebreak);
else return FALSE; else return FALSE;
@@ -85,7 +87,7 @@ bool wxHtmlCell::AdjustPagebreak(int *pagebreak) const
void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
{ {
if (m_Link) delete m_Link; if (m_Link) delete m_Link;
m_Link = NULL; m_Link = NULL;
@@ -95,30 +97,30 @@ void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link)
void wxHtmlCell::Layout(int w) void wxHtmlCell::Layout(int w)
{ {
SetPos(0, 0); SetPos(0, 0);
if (m_Next) m_Next->Layout(w); if (m_Next) m_Next->Layout(w);
} }
void wxHtmlCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) void wxHtmlCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
{ {
if (m_Next) m_Next->Draw(dc, x, y, view_y1, view_y2); if (m_Next) m_Next->Draw(dc, x, y, view_y1, view_y2);
} }
void wxHtmlCell::DrawInvisible(wxDC& dc, int x, int y) void wxHtmlCell::DrawInvisible(wxDC& dc, int x, int y)
{ {
if (m_Next) m_Next->DrawInvisible(dc, x, y); if (m_Next) m_Next->DrawInvisible(dc, x, y);
} }
const wxHtmlCell* wxHtmlCell::Find(int condition, const void* param) const const wxHtmlCell* wxHtmlCell::Find(int condition, const void* param) const
{ {
if (m_Next) return m_Next->Find(condition, param); if (m_Next) return m_Next->Find(condition, param);
else return NULL; else return NULL;
} }
@@ -166,7 +168,7 @@ wxHtmlContainerCell::wxHtmlContainerCell(wxHtmlContainerCell *parent) : wxHtmlCe
m_LastLayout = -1; m_LastLayout = -1;
} }
wxHtmlContainerCell::~wxHtmlContainerCell() wxHtmlContainerCell::~wxHtmlContainerCell()
{ {
if (m_Cells) delete m_Cells; if (m_Cells) delete m_Cells;
} }
@@ -212,16 +214,16 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const
bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const
{ {
if (!m_CanLiveOnPagebreak) if (!m_CanLiveOnPagebreak)
return wxHtmlCell::AdjustPagebreak(pagebreak); return wxHtmlCell::AdjustPagebreak(pagebreak);
else else
{ {
wxHtmlCell *c = GetFirstCell(); wxHtmlCell *c = GetFirstCell();
bool rt = FALSE; bool rt = FALSE;
int pbrk = *pagebreak - m_PosY; int pbrk = *pagebreak - m_PosY;
while (c) while (c)
{ {
if (c->AdjustPagebreak(&pbrk)) rt = TRUE; if (c->AdjustPagebreak(&pbrk)) rt = TRUE;
c = c->GetNext(); c = c->GetNext();
@@ -235,11 +237,11 @@ bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) const
void wxHtmlContainerCell::Layout(int w) void wxHtmlContainerCell::Layout(int w)
{ {
if (m_LastLayout == w) if (m_LastLayout == w)
{ {
wxHtmlCell::Layout(w); wxHtmlCell::Layout(w);
return; return;
} }
wxHtmlCell *cell = m_Cells, *line = m_Cells; wxHtmlCell *cell = m_Cells, *line = m_Cells;
long xpos = 0, ypos = m_IndentTop; long xpos = 0, ypos = m_IndentTop;
@@ -256,18 +258,18 @@ void wxHtmlContainerCell::Layout(int w)
*/ */
if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT)
{ {
if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100;
else m_Width = m_WidthFloat * w / 100; else m_Width = m_WidthFloat * w / 100;
} }
else else
{ {
if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; if (m_WidthFloat < 0) m_Width = w + m_WidthFloat;
else m_Width = m_WidthFloat; else m_Width = m_WidthFloat;
} }
if (m_Cells) if (m_Cells)
{ {
int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft; int l = (m_IndentLeft < 0) ? (-m_IndentLeft * m_Width / 100) : m_IndentLeft;
int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight; int r = (m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight;
@@ -285,9 +287,9 @@ void wxHtmlContainerCell::Layout(int w)
s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight); s_width = m_Width - s_indent - ((m_IndentRight < 0) ? (-m_IndentRight * m_Width / 100) : m_IndentRight);
// my own layouting: // my own layouting:
while (cell != NULL) while (cell != NULL)
{ {
switch (m_AlignVer) switch (m_AlignVer)
{ {
case wxHTML_ALIGN_TOP : ybasicpos = 0; break; case wxHTML_ALIGN_TOP : ybasicpos = 0; break;
case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell->GetHeight(); break; case wxHTML_ALIGN_BOTTOM : ybasicpos = - cell->GetHeight(); break;
@@ -304,42 +306,42 @@ void wxHtmlContainerCell::Layout(int w)
xcnt++; xcnt++;
// force new line if occured: // force new line if occured:
if ((cell == NULL) || (xpos + cell->GetWidth() > s_width)) if ((cell == NULL) || (xpos + cell->GetWidth() > s_width))
{ {
if (xpos > MaxLineWidth) MaxLineWidth = xpos; if (xpos > MaxLineWidth) MaxLineWidth = xpos;
if (ysizeup < 0) ysizeup = 0; if (ysizeup < 0) ysizeup = 0;
if (ysizedown < 0) ysizedown = 0; if (ysizedown < 0) ysizedown = 0;
switch (m_AlignHor) { switch (m_AlignHor) {
case wxHTML_ALIGN_LEFT : case wxHTML_ALIGN_LEFT :
case wxHTML_ALIGN_JUSTIFY : case wxHTML_ALIGN_JUSTIFY :
xdelta = 0; xdelta = 0;
break; break;
case wxHTML_ALIGN_RIGHT : case wxHTML_ALIGN_RIGHT :
xdelta = 0 + (s_width - xpos); xdelta = 0 + (s_width - xpos);
break; break;
case wxHTML_ALIGN_CENTER : case wxHTML_ALIGN_CENTER :
xdelta = 0 + (s_width - xpos) / 2; xdelta = 0 + (s_width - xpos) / 2;
break; break;
} }
if (xdelta < 0) xdelta = 0; if (xdelta < 0) xdelta = 0;
xdelta += s_indent; xdelta += s_indent;
ypos += ysizeup; ypos += ysizeup;
if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL) if (m_AlignHor != wxHTML_ALIGN_JUSTIFY || cell == NULL)
while (line != cell) while (line != cell)
{ {
line->SetPos(line->GetPosX() + xdelta, line->SetPos(line->GetPosX() + xdelta,
ypos + line->GetPosY()); ypos + line->GetPosY());
line = line->GetNext(); line = line->GetNext();
} }
else else
{ {
int counter = 0; int counter = 0;
int step = (s_width - xpos); int step = (s_width - xpos);
if (step < 0) step = 0; if (step < 0) step = 0;
xcnt--; xcnt--;
if (xcnt > 0) while (line != cell) if (xcnt > 0) while (line != cell)
{ {
line->SetPos(line->GetPosX() + s_indent + line->SetPos(line->GetPosX() + s_indent +
(counter++ * step / xcnt), (counter++ * step / xcnt),
@@ -359,14 +361,14 @@ void wxHtmlContainerCell::Layout(int w)
// setup height & width, depending on container layout: // setup height & width, depending on container layout:
m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom; m_Height = ypos + (ysizedown + ysizeup) + m_IndentBottom;
if (m_Height < m_MinHeight) if (m_Height < m_MinHeight)
{ {
if (m_MinHeightAlign != wxHTML_ALIGN_TOP) if (m_MinHeightAlign != wxHTML_ALIGN_TOP)
{ {
int diff = m_MinHeight - m_Height; int diff = m_MinHeight - m_Height;
if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2; if (m_MinHeightAlign == wxHTML_ALIGN_CENTER) diff /= 2;
cell = m_Cells; cell = m_Cells;
while (cell) while (cell)
{ {
cell->SetPos(cell->GetPosX(), cell->GetPosY() + diff); cell->SetPos(cell->GetPosX(), cell->GetPosY() + diff);
cell = cell->GetNext(); cell = cell->GetNext();
@@ -390,10 +392,10 @@ void wxHtmlContainerCell::Layout(int w)
void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
{ {
// container visible, draw it: // container visible, draw it:
if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1)) if ((y + m_PosY < view_y2) && (y + m_PosY + m_Height > view_y1))
{ {
if (m_UseBkColour) if (m_UseBkColour)
{ {
wxBrush myb = wxBrush(m_BkColour, wxSOLID); wxBrush myb = wxBrush(m_BkColour, wxSOLID);
@@ -405,7 +407,7 @@ void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1); dc.DrawRectangle(x + m_PosX, real_y1, m_Width, real_y2 - real_y1 + 1);
} }
if (m_UseBorder) if (m_UseBorder)
{ {
wxPen mypen1(m_BorderColour1, 1, wxSOLID); wxPen mypen1(m_BorderColour1, 1, wxSOLID);
wxPen mypen2(m_BorderColour2, 1, wxSOLID); wxPen mypen2(m_BorderColour2, 1, wxSOLID);
@@ -421,7 +423,7 @@ void wxHtmlContainerCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
if (m_Cells) m_Cells->Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2); if (m_Cells) m_Cells->Draw(dc, x + m_PosX, y + m_PosY, view_y1, view_y2);
} }
// container invisible, just proceed font+color changing: // container invisible, just proceed font+color changing:
else else
{ {
if (m_Cells) m_Cells->DrawInvisible(dc, x + m_PosX, y + m_PosY); if (m_Cells) m_Cells->DrawInvisible(dc, x + m_PosX, y + m_PosY);
} }
@@ -444,7 +446,7 @@ wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const
wxHtmlCell *c = m_Cells; wxHtmlCell *c = m_Cells;
int cx, cy, cw, ch; int cx, cy, cw, ch;
while (c) while (c)
{ {
cx = c->GetPosX(), cy = c->GetPosY(); cx = c->GetPosX(), cy = c->GetPosY();
cw = c->GetWidth(), ch = c->GetHeight(); cw = c->GetWidth(), ch = c->GetHeight();
@@ -460,7 +462,7 @@ wxHtmlLinkInfo *wxHtmlContainerCell::GetLink(int x, int y) const
void wxHtmlContainerCell::InsertCell(wxHtmlCell *f) void wxHtmlContainerCell::InsertCell(wxHtmlCell *f)
{ {
if (!m_Cells) m_Cells = m_LastCell = f; if (!m_Cells) m_Cells = m_LastCell = f;
else else
{ {
m_LastCell->SetNext(f); m_LastCell->SetNext(f);
m_LastCell = f; m_LastCell = f;
@@ -474,7 +476,7 @@ void wxHtmlContainerCell::InsertCell(wxHtmlCell *f)
void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag) void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
{ {
if (tag.HasParam(wxT("ALIGN"))) if (tag.HasParam(wxT("ALIGN")))
{ {
wxString alg = tag.GetParam(wxT("ALIGN")); wxString alg = tag.GetParam(wxT("ALIGN"));
alg.MakeUpper(); alg.MakeUpper();
@@ -494,17 +496,17 @@ void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale) void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale)
{ {
if (tag.HasParam(wxT("WIDTH"))) if (tag.HasParam(wxT("WIDTH")))
{ {
int wdi; int wdi;
wxString wd = tag.GetParam(wxT("WIDTH")); wxString wd = tag.GetParam(wxT("WIDTH"));
if (wd[wd.Length()-1] == wxT('%')) if (wd[wd.Length()-1] == wxT('%'))
{ {
wxSscanf(wd.c_str(), wxT("%i%%"), &wdi); wxSscanf(wd.c_str(), wxT("%i%%"), &wdi);
SetWidthFloat(wdi, wxHTML_UNITS_PERCENT); SetWidthFloat(wdi, wxHTML_UNITS_PERCENT);
} }
else else
{ {
wxSscanf(wd.c_str(), wxT("%i"), &wdi); wxSscanf(wd.c_str(), wxT("%i"), &wdi);
SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS); SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
@@ -519,7 +521,7 @@ const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) co
{ {
const wxHtmlCell *r = NULL; const wxHtmlCell *r = NULL;
if (m_Cells) if (m_Cells)
{ {
r = m_Cells->Find(condition, param); r = m_Cells->Find(condition, param);
if (r) return r; if (r) return r;
@@ -532,15 +534,15 @@ const wxHtmlCell* wxHtmlContainerCell::Find(int condition, const void* param) co
void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event) void wxHtmlContainerCell::OnMouseClick(wxWindow *parent, int x, int y, const wxMouseEvent& event)
{ {
if (m_Cells) if (m_Cells)
{ {
wxHtmlCell *c = m_Cells; wxHtmlCell *c = m_Cells;
while (c) while (c)
{ {
if ( (c->GetPosX() <= x) && if ( (c->GetPosX() <= x) &&
(c->GetPosY() <= y) && (c->GetPosY() <= y) &&
(c->GetPosX() + c->GetWidth() > x) && (c->GetPosX() + c->GetWidth() > x) &&
(c->GetPosY() + c->GetHeight() > y)) (c->GetPosY() + c->GetHeight() > y))
{ {
c->OnMouseClick(parent, x - c->GetPosX(), y - c->GetPosY(), event); c->OnMouseClick(parent, x - c->GetPosX(), y - c->GetPosY(), event);
break; break;
@@ -562,7 +564,7 @@ void wxHtmlColourCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
{ {
if (m_Flags & wxHTML_CLR_FOREGROUND) if (m_Flags & wxHTML_CLR_FOREGROUND)
dc.SetTextForeground(m_Colour); dc.SetTextForeground(m_Colour);
if (m_Flags & wxHTML_CLR_BACKGROUND) if (m_Flags & wxHTML_CLR_BACKGROUND)
{ {
dc.SetBackground(wxBrush(m_Colour, wxSOLID)); dc.SetBackground(wxBrush(m_Colour, wxSOLID));
dc.SetTextBackground(m_Colour); dc.SetTextBackground(m_Colour);
@@ -574,7 +576,7 @@ void wxHtmlColourCell::DrawInvisible(wxDC& dc, int x, int y)
{ {
if (m_Flags & wxHTML_CLR_FOREGROUND) if (m_Flags & wxHTML_CLR_FOREGROUND)
dc.SetTextForeground(m_Colour); dc.SetTextForeground(m_Colour);
if (m_Flags & wxHTML_CLR_BACKGROUND) if (m_Flags & wxHTML_CLR_BACKGROUND)
{ {
dc.SetBackground(wxBrush(m_Colour, wxSOLID)); dc.SetBackground(wxBrush(m_Colour, wxSOLID));
dc.SetTextBackground(m_Colour); dc.SetTextBackground(m_Colour);
@@ -627,7 +629,7 @@ void wxHtmlWidgetCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
int absx = 0, absy = 0, stx, sty; int absx = 0, absy = 0, stx, sty;
wxHtmlCell *c = this; wxHtmlCell *c = this;
while (c) while (c)
{ {
absx += c->GetPosX(); absx += c->GetPosX();
absy += c->GetPosY(); absy += c->GetPosY();
@@ -647,7 +649,7 @@ void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y)
int absx = 0, absy = 0, stx, sty; int absx = 0, absy = 0, stx, sty;
wxHtmlCell *c = this; wxHtmlCell *c = this;
while (c) while (c)
{ {
absx += c->GetPosX(); absx += c->GetPosX();
absy += c->GetPosY(); absy += c->GetPosY();
@@ -664,7 +666,7 @@ void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y)
void wxHtmlWidgetCell::Layout(int w) void wxHtmlWidgetCell::Layout(int w)
{ {
if (m_WidthFloat != 0) if (m_WidthFloat != 0)
{ {
m_Width = (w * m_WidthFloat) / 100; m_Width = (w * m_WidthFloat) / 100;
m_Wnd->SetSize(m_Width, m_Height); m_Wnd->SetSize(m_Width, m_Height);

View File

@@ -22,7 +22,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/log.h"
#include "wx/intl.h"
#endif #endif
#include "wx/html/htmlfilt.h" #include "wx/html/htmlfilt.h"
@@ -141,7 +142,7 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const
char *src; char *src;
wxString doc; wxString doc;
if (s == NULL) if (s == NULL)
{ {
wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().c_str()); wxLogError(_("Cannot open HTML document: %s"), file.GetLocation().c_str());
return wxEmptyString; return wxEmptyString;
@@ -152,7 +153,7 @@ wxString wxHtmlFilterHTML::ReadFile(const wxFSFile& file) const
doc = src; doc = src;
delete[] src; delete[] src;
// add meta tag if we obtained this through http: // add meta tag if we obtained this through http:
if (file.GetMimeType().Find(_T("; charset=")) == 0) if (file.GetMimeType().Find(_T("; charset=")) == 0)
{ {
wxString s(_T("<meta http-equiv=\"Content-Type\" content=\"")); wxString s(_T("<meta http-equiv=\"Content-Type\" content=\""));

View File

@@ -20,7 +20,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/htmlfilter.h" #include "wx/html/htmlfilter.h"

View File

@@ -23,10 +23,8 @@ file is only left to point out the problem and will be removed r.s.n.
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include <wx/wx.h>
#endif #endif
#include <wx/notebook.h> #include <wx/notebook.h>
#include <wx/imaglist.h> #include <wx/imaglist.h>
#include <wx/treectrl.h> #include <wx/treectrl.h>

View File

@@ -22,7 +22,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/log.h"
#include "wx/intl.h"
#endif #endif
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
@@ -40,8 +41,8 @@
IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject) IMPLEMENT_ABSTRACT_CLASS(wxHtmlParser,wxObject)
wxHtmlParser::wxHtmlParser() wxHtmlParser::wxHtmlParser()
: wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING), : wxObject(), m_Cache(NULL), m_HandlersHash(wxKEY_STRING),
m_FS(NULL), m_HandlersStack(NULL) m_FS(NULL), m_HandlersStack(NULL)
{ {
m_entitiesParser = new wxHtmlEntitiesParser; m_entitiesParser = new wxHtmlEntitiesParser;
@@ -97,22 +98,22 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos)
templen = 0; templen = 0;
i = begin_pos; i = begin_pos;
while (i < end_pos) while (i < end_pos)
{ {
c = m_Source[(unsigned int) i]; c = m_Source[(unsigned int) i];
// continue building word: // continue building word:
if (c != '<') if (c != '<')
{ {
temp[templen++] = c; temp[templen++] = c;
i++; i++;
} }
else if (c == '<') else if (c == '<')
{ {
wxHtmlTag tag(m_Source, i, end_pos, m_Cache, m_entitiesParser); wxHtmlTag tag(m_Source, i, end_pos, m_Cache, m_entitiesParser);
if (templen) if (templen)
{ {
temp[templen] = 0; temp[templen] = 0;
AddText(temp); AddText(temp);
@@ -124,7 +125,7 @@ void wxHtmlParser::DoParsing(int begin_pos, int end_pos)
} }
} }
if (templen) if (templen)
{ // last word of block :-( { // last word of block :-(
temp[templen] = 0; temp[templen] = 0;
AddText(temp); AddText(temp);
@@ -140,7 +141,7 @@ void wxHtmlParser::AddTag(const wxHtmlTag& tag)
h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName()); h = (wxHtmlTagHandler*) m_HandlersHash.Get(tag.GetName());
if (h) if (h)
inner = h->HandleTag(tag); inner = h->HandleTag(tag);
if (!inner) if (!inner)
{ {
if (tag.HasEnding()) if (tag.HasEnding())
DoParsing(tag.GetBeginPos(), tag.GetEndPos1()); DoParsing(tag.GetBeginPos(), tag.GetEndPos1());
@@ -166,7 +167,7 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags)
wxStringTokenizer tokenizer(tags, ", "); wxStringTokenizer tokenizer(tags, ", ");
wxString key; wxString key;
if (m_HandlersStack == NULL) if (m_HandlersStack == NULL)
{ {
m_HandlersStack = new wxList; m_HandlersStack = new wxList;
m_HandlersStack->DeleteContents(TRUE); m_HandlersStack->DeleteContents(TRUE);
@@ -174,7 +175,7 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags)
m_HandlersStack->Insert(new wxHashTable(m_HandlersHash)); m_HandlersStack->Insert(new wxHashTable(m_HandlersHash));
while (tokenizer.HasMoreTokens()) while (tokenizer.HasMoreTokens())
{ {
key = tokenizer.NextToken(); key = tokenizer.NextToken();
m_HandlersHash.Delete(key); m_HandlersHash.Delete(key);
@@ -185,9 +186,9 @@ void wxHtmlParser::PushTagHandler(wxHtmlTagHandler *handler, wxString tags)
void wxHtmlParser::PopTagHandler() void wxHtmlParser::PopTagHandler()
{ {
wxNode *first; wxNode *first;
if (m_HandlersStack == NULL || if (m_HandlersStack == NULL ||
(first = m_HandlersStack->GetFirst()) == NULL) (first = m_HandlersStack->GetFirst()) == NULL)
{ {
wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack.")); wxLogWarning(_("Warning: attempt to remove HTML tag handler from empty stack."));
return; return;
@@ -238,7 +239,7 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input)
const wxChar *c, *last; const wxChar *c, *last;
const wxChar *in_str = input.c_str(); const wxChar *in_str = input.c_str();
wxString output; wxString output;
for (c = in_str, last = in_str; *c != wxT('\0'); c++) for (c = in_str, last = in_str; *c != wxT('\0'); c++)
{ {
if (*c == wxT('&')) if (*c == wxT('&'))
@@ -295,12 +296,12 @@ wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code)
wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity) wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity)
{ {
unsigned code = 0; unsigned code = 0;
if (entity[0] == wxT('#')) if (entity[0] == wxT('#'))
{ {
const wxChar *ent_s = entity.c_str(); const wxChar *ent_s = entity.c_str();
const wxChar *format; const wxChar *format;
if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X')) if (ent_s[1] == wxT('x') || ent_s[1] == wxT('X'))
{ {
format = wxT("%x"); format = wxT("%x");
@@ -570,20 +571,20 @@ wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity)
{ wxT("zwnj"),8204 }, { wxT("zwnj"),8204 },
{NULL, 0}}; {NULL, 0}};
static size_t substitutions_cnt = 0; static size_t substitutions_cnt = 0;
if (substitutions_cnt == 0) if (substitutions_cnt == 0)
while (substitutions[substitutions_cnt].code != 0) while (substitutions[substitutions_cnt].code != 0)
substitutions_cnt++; substitutions_cnt++;
wxHtmlEntityInfo *info; wxHtmlEntityInfo *info;
info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions, info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions,
substitutions_cnt, substitutions_cnt,
sizeof(wxHtmlEntityInfo), sizeof(wxHtmlEntityInfo),
compar_entity); compar_entity);
if (info) if (info)
code = info->code; code = info->code;
} }
if (code == 0) if (code == 0)
return wxT('?'); return wxT('?');
else else

View File

@@ -22,7 +22,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/htmltag.h" #include "wx/html/htmltag.h"

View File

@@ -23,15 +23,18 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/log.h"
#include "wx/intl.h"
#include "wx/dcclient.h"
#include "wx/frame.h"
#endif #endif
#include "wx/html/htmlwin.h" #include "wx/html/htmlwin.h"
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/htmlproc.h" #include "wx/html/htmlproc.h"
#include "wx/log.h"
#include "wx/arrimpl.cpp"
#include "wx/list.h" #include "wx/list.h"
#include "wx/arrimpl.cpp"
#include "wx/listimpl.cpp" #include "wx/listimpl.cpp"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -23,7 +23,8 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h" #include "wx/log.h"
#include "wx/intl.h"
#endif #endif
#if wxUSE_HTML && wxUSE_PRINTING_ARCHITECTURE && wxUSE_STREAMS #if wxUSE_HTML && wxUSE_PRINTING_ARCHITECTURE && wxUSE_STREAMS
@@ -82,7 +83,7 @@ void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepat
if (m_DC == NULL) return; if (m_DC == NULL) return;
if (m_Cells != NULL) delete m_Cells; if (m_Cells != NULL) delete m_Cells;
m_FS->ChangePathTo(basepath, isdir); m_FS->ChangePathTo(basepath, isdir);
m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html); m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html);
m_Cells->SetIndent(0, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS); m_Cells->SetIndent(0, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
@@ -94,24 +95,24 @@ void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepat
int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render) int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render)
{ {
int pbreak, hght; int pbreak, hght;
if (m_Cells == NULL || m_DC == NULL) return 0; if (m_Cells == NULL || m_DC == NULL) return 0;
pbreak = (int)(from + m_Height); pbreak = (int)(from + m_Height);
while (m_Cells->AdjustPagebreak(&pbreak)) {} while (m_Cells->AdjustPagebreak(&pbreak)) {}
hght = pbreak - from; hght = pbreak - from;
if (!dont_render) if (!dont_render)
{ {
m_DC->SetBrush(*wxWHITE_BRUSH); m_DC->SetBrush(*wxWHITE_BRUSH);
m_DC->SetClippingRegion(x, y, m_Width, hght); m_DC->SetClippingRegion(x, y, m_Width, hght);
m_Cells->Draw(*m_DC, m_Cells->Draw(*m_DC,
x, (y - from), x, (y - from),
y, pbreak + (y /*- from*/)); y, pbreak + (y /*- from*/));
m_DC->DestroyClippingRegion(); m_DC->DestroyClippingRegion();
} }
if (pbreak < m_Cells->GetHeight()) return pbreak; if (pbreak < m_Cells->GetHeight()) return pbreak;
else return GetTotalHeight(); else return GetTotalHeight();
} }
@@ -171,7 +172,7 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
{ {
int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h; int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
float ppmm_h, ppmm_v; float ppmm_h, ppmm_v;
if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE; if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE;
GetPageSizePixels(&pageWidth, &pageHeight); GetPageSizePixels(&pageWidth, &pageHeight);
@@ -190,35 +191,35 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
GetDC()->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth); GetDC()->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
/* prepare headers/footers renderer: */ /* prepare headers/footers renderer: */
m_RendererHdr->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY); m_RendererHdr->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
m_RendererHdr->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)), m_RendererHdr->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
(int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom))); (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom)));
if (m_Headers[0] != wxEmptyString) if (m_Headers[0] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[0], 1)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[0], 1));
m_HeaderHeight = m_RendererHdr->GetTotalHeight(); m_HeaderHeight = m_RendererHdr->GetTotalHeight();
} }
else if (m_Headers[1] != wxEmptyString) else if (m_Headers[1] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[1], 1)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[1], 1));
m_HeaderHeight = m_RendererHdr->GetTotalHeight(); m_HeaderHeight = m_RendererHdr->GetTotalHeight();
} }
if (m_Footers[0] != wxEmptyString) if (m_Footers[0] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[0], 1)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[0], 1));
m_FooterHeight = m_RendererHdr->GetTotalHeight(); m_FooterHeight = m_RendererHdr->GetTotalHeight();
} }
else if (m_Footers[1] != wxEmptyString) else if (m_Footers[1] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[1], 1)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[1], 1));
m_FooterHeight = m_RendererHdr->GetTotalHeight(); m_FooterHeight = m_RendererHdr->GetTotalHeight();
} }
/* prepare main renderer: */ /* prepare main renderer: */
m_Renderer->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY); m_Renderer->SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
m_Renderer->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)), m_Renderer->SetSize((int) (ppmm_h * (mm_w - m_MarginLeft - m_MarginRight)),
(int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) - (int) (ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) -
m_FooterHeight - m_HeaderHeight - m_FooterHeight - m_HeaderHeight -
((m_HeaderHeight == 0) ? 0 : m_MarginSpace * ppmm_v) - ((m_HeaderHeight == 0) ? 0 : m_MarginSpace * ppmm_v) -
((m_FooterHeight == 0) ? 0 : m_MarginSpace * ppmm_v) ((m_FooterHeight == 0) ? 0 : m_MarginSpace * ppmm_v)
@@ -232,12 +233,12 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
bool wxHtmlPrintout::OnPrintPage(int page) bool wxHtmlPrintout::OnPrintPage(int page)
{ {
wxDC *dc = GetDC(); wxDC *dc = GetDC();
if (dc) if (dc)
{ {
if (HasPage(page)) if (HasPage(page))
RenderPage(dc, page); RenderPage(dc, page);
return TRUE; return TRUE;
} }
else return FALSE; else return FALSE;
} }
@@ -272,22 +273,22 @@ void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile)
{ {
wxFileSystem fs; wxFileSystem fs;
wxFSFile *ff = fs.OpenFile(htmlfile); wxFSFile *ff = fs.OpenFile(htmlfile);
if (ff == NULL) if (ff == NULL)
{ {
wxLogError(htmlfile + _(": file does not exist!")); wxLogError(htmlfile + _(": file does not exist!"));
return; return;
} }
wxInputStream *st = ff->GetStream(); wxInputStream *st = ff->GetStream();
char *t = new char[st->GetSize() + 1]; char *t = new char[st->GetSize() + 1];
st->Read(t, st->GetSize()); st->Read(t, st->GetSize());
t[st->GetSize()] = 0; t[st->GetSize()] = 0;
wxString doc = wxString(t); wxString doc = wxString(t);
delete t; delete t;
delete ff; delete ff;
SetHtmlText(doc, htmlfile, FALSE); SetHtmlText(doc, htmlfile, FALSE);
} }
@@ -295,9 +296,9 @@ void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile)
void wxHtmlPrintout::SetHeader(const wxString& header, int pg) void wxHtmlPrintout::SetHeader(const wxString& header, int pg)
{ {
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN) if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
m_Headers[0] = header; m_Headers[0] = header;
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD) if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
m_Headers[1] = header; m_Headers[1] = header;
} }
@@ -305,9 +306,9 @@ void wxHtmlPrintout::SetHeader(const wxString& header, int pg)
void wxHtmlPrintout::SetFooter(const wxString& footer, int pg) void wxHtmlPrintout::SetFooter(const wxString& footer, int pg)
{ {
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN) if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
m_Footers[0] = footer; m_Footers[0] = footer;
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD) if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
m_Footers[1] = footer; m_Footers[1] = footer;
} }
@@ -327,11 +328,11 @@ void wxHtmlPrintout::CountPages()
int pos = 0; int pos = 0;
m_NumPages = 0; m_NumPages = 0;
m_PageBreaks[0] = 0; m_PageBreaks[0] = 0;
do do
{ {
pos = m_Renderer->Render((int)( ppmm_h * m_MarginLeft), pos = m_Renderer->Render((int)( ppmm_h * m_MarginLeft),
(int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight), (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
pos, TRUE); pos, TRUE);
m_PageBreaks[++m_NumPages] = pos; m_PageBreaks[++m_NumPages] = pos;
@@ -360,22 +361,22 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page)
GetPPIScreen(&ppiScreenX, &ppiScreenY); GetPPIScreen(&ppiScreenX, &ppiScreenY);
dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth); dc->SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
m_Renderer->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY); m_Renderer->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
dc->SetBackgroundMode(wxTRANSPARENT); dc->SetBackgroundMode(wxTRANSPARENT);
m_Renderer->Render((int) (ppmm_h * m_MarginLeft), m_Renderer->Render((int) (ppmm_h * m_MarginLeft),
(int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight), (int) (ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight),
m_PageBreaks[page-1]); m_PageBreaks[page-1]);
m_RendererHdr->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY); m_RendererHdr->SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
if (m_Headers[page % 2] != wxEmptyString) if (m_Headers[page % 2] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[page % 2], page)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Headers[page % 2], page));
m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * m_MarginTop)); m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (ppmm_v * m_MarginTop));
} }
if (m_Footers[page % 2] != wxEmptyString) if (m_Footers[page % 2] != wxEmptyString)
{ {
m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[page % 2], page)); m_RendererHdr->SetHtmlText(TranslateHeader(m_Footers[page % 2], page));
m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (pageHeight - ppmm_v * m_MarginBottom - m_FooterHeight)); m_RendererHdr->Render((int) (ppmm_h * m_MarginLeft), (int) (pageHeight - ppmm_v * m_MarginBottom - m_FooterHeight));
@@ -388,7 +389,7 @@ wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
{ {
wxString r = instr; wxString r = instr;
wxString num; wxString num;
num.Printf(wxT("%i"), page); num.Printf(wxT("%i"), page);
r.Replace(wxT("@PAGENUM@"), num); r.Replace(wxT("@PAGENUM@"), num);
@@ -429,9 +430,9 @@ wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxFrame *parent_fra
#endif #endif
m_PageSetupData = new wxPageSetupDialogData; m_PageSetupData = new wxPageSetupDialogData;
m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString; m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString;
m_PageSetupData->EnableMargins(TRUE); m_PageSetupData->EnableMargins(TRUE);
m_PageSetupData->SetMarginTopLeft(wxPoint(25, 25)); m_PageSetupData->SetMarginTopLeft(wxPoint(25, 25));
m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25)); m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25));
} }
@@ -494,14 +495,14 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr
// Pass two printout objects: for preview, and possible printing. // Pass two printout objects: for preview, and possible printing.
wxPrintDialogData printDialogData(*m_PrintData); wxPrintDialogData printDialogData(*m_PrintData);
wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData); wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData);
if (!preview->Ok()) if (!preview->Ok())
{ {
delete preview; delete preview;
return FALSE; return FALSE;
} }
wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame, wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame,
m_Name + _(" Preview"), m_Name + _(" Preview"),
wxPoint(100, 100), wxSize(650, 500)); wxPoint(100, 100), wxSize(650, 500));
frame->Centre(wxBOTH); frame->Centre(wxBOTH);
frame->Initialize(); frame->Initialize();
@@ -531,7 +532,7 @@ void wxHtmlEasyPrinting::PrinterSetup()
{ {
wxPrintDialogData printDialogData(*m_PrintData); wxPrintDialogData printDialogData(*m_PrintData);
wxPrintDialog printerDialog(m_Frame, &printDialogData); wxPrintDialog printerDialog(m_Frame, &printDialogData);
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE); printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
if (printerDialog.ShowModal() == wxID_OK) if (printerDialog.ShowModal() == wxID_OK)
@@ -545,7 +546,7 @@ void wxHtmlEasyPrinting::PageSetup()
m_PageSetupData->SetPrintData(*m_PrintData); m_PageSetupData->SetPrintData(*m_PrintData);
wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData); wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData);
if (pageSetupDialog.ShowModal() == wxID_OK) if (pageSetupDialog.ShowModal() == wxID_OK)
{ {
(*m_PrintData) = pageSetupDialog.GetPageSetupData().GetPrintData(); (*m_PrintData) = pageSetupDialog.GetPageSetupData().GetPrintData();
(*m_PageSetupData) = pageSetupDialog.GetPageSetupData(); (*m_PageSetupData) = pageSetupDialog.GetPageSetupData();
@@ -556,9 +557,9 @@ void wxHtmlEasyPrinting::PageSetup()
void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg) void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg)
{ {
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN) if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
m_Headers[0] = header; m_Headers[0] = header;
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD) if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
m_Headers[1] = header; m_Headers[1] = header;
} }
@@ -566,9 +567,9 @@ void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg)
void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg) void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
{ {
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN) if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
m_Footers[0] = footer; m_Footers[0] = footer;
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD) if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
m_Footers[1] = footer; m_Footers[1] = footer;
} }
@@ -577,7 +578,7 @@ void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout() wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
{ {
wxHtmlPrintout *p = new wxHtmlPrintout(m_Name); wxHtmlPrintout *p = new wxHtmlPrintout(m_Name);
p->SetHeader(m_Headers[0], wxPAGE_EVEN); p->SetHeader(m_Headers[0], wxPAGE_EVEN);
p->SetHeader(m_Headers[1], wxPAGE_ODD); p->SetHeader(m_Headers[1], wxPAGE_ODD);
p->SetFooter(m_Footers[0], wxPAGE_EVEN); p->SetFooter(m_Footers[0], wxPAGE_EVEN);
@@ -587,7 +588,7 @@ wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
m_PageSetupData->GetMarginBottomRight().y, m_PageSetupData->GetMarginBottomRight().y,
m_PageSetupData->GetMarginTopLeft().x, m_PageSetupData->GetMarginTopLeft().x,
m_PageSetupData->GetMarginBottomRight().x); m_PageSetupData->GetMarginBottomRight().x);
return p; return p;
} }

View File

@@ -22,10 +22,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
@@ -43,10 +41,10 @@ TAG_HANDLER_BEGIN(DEFLIST, "DL,DT,DD")
wxHtmlContainerCell *c; wxHtmlContainerCell *c;
if (tag.GetName() == wxT("DL")) if (tag.GetName() == wxT("DL"))
{ {
if (m_WParser->GetContainer()->GetFirstCell() != NULL) if (m_WParser->GetContainer()->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -54,8 +52,8 @@ TAG_HANDLER_BEGIN(DEFLIST, "DL,DT,DD")
ParseInner(tag); ParseInner(tag);
if (m_WParser->GetContainer()->GetFirstCell() != NULL) if (m_WParser->GetContainer()->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -63,11 +61,10 @@ TAG_HANDLER_BEGIN(DEFLIST, "DL,DT,DD")
return TRUE; return TRUE;
} }
else if (tag.GetName() == wxT("DT"))
else if (tag.GetName() == wxT("DT")) {
{ if (!tag.IsEnding())
if (!tag.IsEnding()) {
{
m_WParser->CloseContainer(); m_WParser->CloseContainer();
c = m_WParser->OpenContainer(); c = m_WParser->OpenContainer();
c->SetAlignHor(wxHTML_ALIGN_LEFT); c->SetAlignHor(wxHTML_ALIGN_LEFT);
@@ -75,15 +72,14 @@ TAG_HANDLER_BEGIN(DEFLIST, "DL,DT,DD")
} }
return FALSE; return FALSE;
} }
else if (!tag.IsEnding()) // "DD" else if (!tag.IsEnding()) // "DD"
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
c = m_WParser->OpenContainer(); c = m_WParser->OpenContainer();
c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT); c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
return FALSE; return FALSE;
} }
else return FALSE; else return FALSE;
} }

View File

@@ -21,7 +21,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
@@ -44,21 +43,21 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
wxString oldface = m_WParser->GetFontFace(); wxString oldface = m_WParser->GetFontFace();
if (tag.HasParam(wxT("COLOR"))) if (tag.HasParam(wxT("COLOR")))
{ {
wxColour clr; wxColour clr;
if (tag.GetParamAsColour(wxT("COLOR"), &clr)) if (tag.GetParamAsColour(wxT("COLOR"), &clr))
{ {
m_WParser->SetActualColor(clr); m_WParser->SetActualColor(clr);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr)); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
} }
} }
if (tag.HasParam(wxT("SIZE"))) if (tag.HasParam(wxT("SIZE")))
{ {
int tmp = 0; int tmp = 0;
wxChar c = tag.GetParam(wxT("SIZE")).GetChar(0); wxChar c = tag.GetParam(wxT("SIZE")).GetChar(0);
if (tag.GetParamAsInt(wxT("SIZE"), &tmp)) if (tag.GetParamAsInt(wxT("SIZE"), &tmp))
{ {
if (c == wxT('+') || c == wxT('-')) if (c == wxT('+') || c == wxT('-'))
m_WParser->SetFontSize(oldsize+tmp); m_WParser->SetFontSize(oldsize+tmp);
else else
@@ -69,9 +68,9 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
} }
if (tag.HasParam(wxT("FACE"))) if (tag.HasParam(wxT("FACE")))
{ {
if (m_Faces.GetCount() == 0) if (m_Faces.GetCount() == 0)
{ {
wxFontEnumerator enu; wxFontEnumerator enu;
enu.EnumerateFacenames(); enu.EnumerateFacenames();
m_Faces = *enu.GetFacenames(); m_Faces = *enu.GetFacenames();
@@ -80,30 +79,30 @@ TAG_HANDLER_BEGIN(FONT, "FONT")
int index; int index;
while (tk.HasMoreTokens()) while (tk.HasMoreTokens())
{ {
if ((index = m_Faces.Index(tk.GetNextToken())) != wxNOT_FOUND) if ((index = m_Faces.Index(tk.GetNextToken())) != wxNOT_FOUND)
{ {
m_WParser->SetFontFace(m_Faces[index]); m_WParser->SetFontFace(m_Faces[index]);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
break; break;
} }
} }
} }
ParseInner(tag); ParseInner(tag);
if (oldface != m_WParser->GetFontFace()) if (oldface != m_WParser->GetFontFace())
{ {
m_WParser->SetFontFace(oldface); m_WParser->SetFontFace(oldface);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
} }
if (oldsize != m_WParser->GetFontSize()) if (oldsize != m_WParser->GetFontSize())
{ {
m_WParser->SetFontSize(oldsize); m_WParser->SetFontSize(oldsize);
m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont())); m_WParser->GetContainer()->InsertCell(new wxHtmlFontCell(m_WParser->CreateCurrentFont()));
} }
if (oldclr != m_WParser->GetActualColor()) if (oldclr != m_WParser->GetActualColor())
{ {
m_WParser->SetActualColor(oldclr); m_WParser->SetActualColor(oldclr);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr)); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(oldclr));
} }
@@ -232,7 +231,7 @@ TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
else if (tag.GetName() == wxT("H3")) else if (tag.GetName() == wxT("H3"))
m_WParser->SetFontSize(5); m_WParser->SetFontSize(5);
else if (tag.GetName() == wxT("H4")) else if (tag.GetName() == wxT("H4"))
{ {
m_WParser->SetFontSize(5); m_WParser->SetFontSize(5);
m_WParser->SetFontItalic(TRUE); m_WParser->SetFontItalic(TRUE);
m_WParser->SetFontBold(FALSE); m_WParser->SetFontBold(FALSE);
@@ -240,7 +239,7 @@ TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
else if (tag.GetName() == wxT("H5")) else if (tag.GetName() == wxT("H5"))
m_WParser->SetFontSize(4); m_WParser->SetFontSize(4);
else if (tag.GetName() == wxT("H6")) else if (tag.GetName() == wxT("H6"))
{ {
m_WParser->SetFontSize(4); m_WParser->SetFontSize(4);
m_WParser->SetFontItalic(TRUE); m_WParser->SetFontItalic(TRUE);
m_WParser->SetFontBold(FALSE); m_WParser->SetFontBold(FALSE);
@@ -248,7 +247,7 @@ TAG_HANDLER_BEGIN(Hx, "H1,H2,H3,H4,H5,H6")
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();
if (c->GetFirstCell()) if (c->GetFirstCell())
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();

View File

@@ -21,11 +21,11 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/brush.h"
#include "wx/pen.h"
#include "wx/dc.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"

View File

@@ -21,13 +21,12 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/dc.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/dynarray.h" #include "wx/dynarray.h"
@@ -73,7 +72,7 @@ wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype
wxString x = incoords, y; wxString x = incoords, y;
type = t; type = t;
while ((i = x.Find( ',' )) != -1) while ((i = x.Find( ',' )) != -1)
{ {
coords.Add( (int)(pixel_scale * (double)wxAtoi( x.Left( i ).c_str())) ); coords.Add( (int)(pixel_scale * (double)wxAtoi( x.Left( i ).c_str())) );
x = x.Mid( i + 1 ); x = x.Mid( i + 1 );
@@ -83,7 +82,7 @@ wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype
wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
{ {
switch (type) switch (type)
{ {
case RECT: case RECT:
{ {
@@ -93,8 +92,8 @@ wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
t = coords[ 1 ]; t = coords[ 1 ];
r = coords[ 2 ]; r = coords[ 2 ];
b = coords[ 3 ]; b = coords[ 3 ];
if (x >= l && x <= r && y >= t && y <= b) if (x >= l && x <= r && y >= t && y <= b)
{ {
return m_Link; return m_Link;
} }
break; break;
@@ -108,16 +107,16 @@ wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
t = coords[ 1 ]; t = coords[ 1 ];
r = coords[ 2 ]; r = coords[ 2 ];
d = sqrt( (double) (((x - l) * (x - l)) + ((y - t) * (y - t))) ); d = sqrt( (double) (((x - l) * (x - l)) + ((y - t) * (y - t))) );
if (d < (double)r) if (d < (double)r)
{ {
return m_Link; return m_Link;
} }
} }
break; break;
case POLY: case POLY:
{ {
if (coords.GetCount() >= 6) if (coords.GetCount() >= 6)
{ {
int intersects = 0; int intersects = 0;
int wherex = x; int wherex = x;
int wherey = y; int wherey = y;
@@ -128,63 +127,63 @@ wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
int end = totalc; int end = totalc;
int pointer = 1; int pointer = 1;
if ((yval >= wherey) != (coords[pointer] >= wherey)) if ((yval >= wherey) != (coords[pointer] >= wherey))
{ {
if ((xval >= wherex) == (coords[0] >= wherex)) if ((xval >= wherex) == (coords[0] >= wherex))
{ {
intersects += (xval >= wherex) ? 1 : 0; intersects += (xval >= wherex) ? 1 : 0;
} }
else else
{ {
intersects += ((xval - (yval - wherey) * intersects += ((xval - (yval - wherey) *
(coords[0] - xval) / (coords[0] - xval) /
(coords[pointer] - yval)) >= wherex) ? 1 : 0; (coords[pointer] - yval)) >= wherex) ? 1 : 0;
} }
} }
while (pointer < end) while (pointer < end)
{ {
yval = coords[pointer]; yval = coords[pointer];
pointer += 2; pointer += 2;
if (yval >= wherey) if (yval >= wherey)
{ {
while ((pointer < end) && (coords[pointer] >= wherey)) while ((pointer < end) && (coords[pointer] >= wherey))
{ {
pointer += 2; pointer += 2;
} }
if (pointer >= end) if (pointer >= end)
{ {
break; break;
} }
if ((coords[pointer - 3] >= wherex) == if ((coords[pointer - 3] >= wherex) ==
(coords[pointer - 1] >= wherex)) { (coords[pointer - 1] >= wherex)) {
intersects += (coords[pointer - 3] >= wherex) ? 1 : 0; intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
} }
else else
{ {
intersects += intersects +=
((coords[pointer - 3] - (coords[pointer - 2] - wherey) * ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
(coords[pointer - 1] - coords[pointer - 3]) / (coords[pointer - 1] - coords[pointer - 3]) /
(coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0; (coords[pointer] - coords[pointer - 2])) >= wherex) ? 1 : 0;
} }
} }
else else
{ {
while ((pointer < end) && (coords[pointer] < wherey)) while ((pointer < end) && (coords[pointer] < wherey))
{ {
pointer += 2; pointer += 2;
} }
if (pointer >= end) if (pointer >= end)
{ {
break; break;
} }
if ((coords[pointer - 3] >= wherex) == if ((coords[pointer - 3] >= wherex) ==
(coords[pointer - 1] >= wherex)) (coords[pointer - 1] >= wherex))
{ {
intersects += (coords[pointer - 3] >= wherex) ? 1 : 0; intersects += (coords[pointer - 3] >= wherex) ? 1 : 0;
} }
else else
{ {
intersects += intersects +=
((coords[pointer - 3] - (coords[pointer - 2] - wherey) * ((coords[pointer - 3] - (coords[pointer - 2] - wherey) *
(coords[pointer - 1] - coords[pointer - 3]) / (coords[pointer - 1] - coords[pointer - 3]) /
@@ -192,8 +191,8 @@ wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
} }
} }
} }
if ((intersects & 1) != 0) if ((intersects & 1) != 0)
{ {
return m_Link; return m_Link;
} }
} }
@@ -201,7 +200,7 @@ wxHtmlLinkInfo *wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
break; break;
} }
if (m_Next) if (m_Next)
{ {
wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next; wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next;
return a->GetLink( x, y ); return a->GetLink( x, y );
@@ -251,7 +250,7 @@ wxHtmlLinkInfo *wxHtmlImageMapCell::GetLink( int x, int y ) const
const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const const wxHtmlCell *wxHtmlImageMapCell::Find( int cond, const void *param ) const
{ {
if (cond == wxHTML_COND_ISIMAGEMAP) if (cond == wxHTML_COND_ISIMAGEMAP)
{ {
if (m_Name == *((wxString*)(param))) if (m_Name == *((wxString*)(param)))
return this; return this;
@@ -294,11 +293,11 @@ wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, double scale, in
wxImage *img; wxImage *img;
int ww, hh, bw, bh; int ww, hh, bw, bh;
wxInputStream *s = input->GetStream(); wxInputStream *s = input->GetStream();
m_Scale = scale; m_Scale = scale;
img = new wxImage(*s, wxBITMAP_TYPE_ANY); img = new wxImage(*s, wxBITMAP_TYPE_ANY);
m_Image = NULL; m_Image = NULL;
if (img && (img->Ok())) if (img && (img->Ok()))
{ {
ww = img->GetWidth(); ww = img->GetWidth();
hh = img->GetHeight(); hh = img->GetHeight();
@@ -308,16 +307,16 @@ wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, double scale, in
m_Width = (int)(scale * (double)bw); m_Width = (int)(scale * (double)bw);
m_Height = (int)(scale * (double)bh); m_Height = (int)(scale * (double)bh);
if ((bw != ww) || (bh != hh)) if ((bw != ww) || (bh != hh))
{ {
wxImage img2 = img->Scale(bw, bh); wxImage img2 = img->Scale(bw, bh);
m_Image = new wxBitmap(img2.ConvertToBitmap()); m_Image = new wxBitmap(img2.ConvertToBitmap());
} }
else else
m_Image = new wxBitmap(img->ConvertToBitmap()); m_Image = new wxBitmap(img->ConvertToBitmap());
delete img; delete img;
} }
switch (align) switch (align)
{ {
case wxHTML_ALIGN_TOP : case wxHTML_ALIGN_TOP :
m_Descent = m_Height; m_Descent = m_Height;
@@ -345,9 +344,9 @@ void wxHtmlImageCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2)
double us_x, us_y; double us_x, us_y;
dc.GetUserScale(&us_x, &us_y); dc.GetUserScale(&us_x, &us_y);
dc.SetUserScale(us_x * m_Scale, us_y * m_Scale); dc.SetUserScale(us_x * m_Scale, us_y * m_Scale);
// dc.DrawBitmap(*m_Image, x + m_PosX, y + m_PosY, (m_Image->GetMask() != (wxMask*) 0)); // dc.DrawBitmap(*m_Image, x + m_PosX, y + m_PosY, (m_Image->GetMask() != (wxMask*) 0));
dc.DrawBitmap(*m_Image, (int) ((x + m_PosX) / m_Scale), dc.DrawBitmap(*m_Image, (int) ((x + m_PosX) / m_Scale),
(int) ((y + m_PosY) / m_Scale), TRUE); (int) ((y + m_PosY) / m_Scale), TRUE);
dc.SetUserScale(us_x, us_y); dc.SetUserScale(us_x, us_y);
} }
@@ -358,19 +357,19 @@ wxHtmlLinkInfo *wxHtmlImageCell::GetLink( int x, int y ) const
{ {
if (m_MapName.IsEmpty()) if (m_MapName.IsEmpty())
return wxHtmlCell::GetLink( x, y ); return wxHtmlCell::GetLink( x, y );
if (!m_ImageMap) if (!m_ImageMap)
{ {
wxHtmlContainerCell *p, *op; wxHtmlContainerCell *p, *op;
op = p = GetParent(); op = p = GetParent();
while (p) while (p)
{ {
op = p; op = p;
p = p->GetParent(); p = p->GetParent();
} }
p = op; p = op;
wxHtmlCell *cell = (wxHtmlCell*)p->Find( wxHTML_COND_ISIMAGEMAP, (const void*)(&m_MapName)); wxHtmlCell *cell = (wxHtmlCell*)p->Find( wxHTML_COND_ISIMAGEMAP, (const void*)(&m_MapName));
if (!cell) if (!cell)
{ {
((wxString&)m_MapName).Clear(); ((wxString&)m_MapName).Clear();
return wxHtmlCell::GetLink( x, y ); return wxHtmlCell::GetLink( x, y );
} }
@@ -393,10 +392,10 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (tag.GetName() == wxT("IMG")) if (tag.GetName() == wxT("IMG"))
{ {
if (tag.HasParam(wxT("SRC"))) if (tag.HasParam(wxT("SRC")))
{ {
int w = -1, h = -1; int w = -1, h = -1;
int al; int al;
wxFSFile *str; wxFSFile *str;
@@ -404,31 +403,31 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
wxString mn = wxEmptyString; wxString mn = wxEmptyString;
str = m_WParser->GetFS()->OpenFile(tmp); str = m_WParser->GetFS()->OpenFile(tmp);
if (tag.HasParam(wxT("WIDTH"))) if (tag.HasParam(wxT("WIDTH")))
tag.GetParamAsInt(wxT("WIDTH"), &w); tag.GetParamAsInt(wxT("WIDTH"), &w);
if (tag.HasParam(wxT("HEIGHT"))) if (tag.HasParam(wxT("HEIGHT")))
tag.GetParamAsInt(wxT("HEIGHT"), &h); tag.GetParamAsInt(wxT("HEIGHT"), &h);
al = wxHTML_ALIGN_BOTTOM; al = wxHTML_ALIGN_BOTTOM;
if (tag.HasParam(wxT("ALIGN"))) if (tag.HasParam(wxT("ALIGN")))
{ {
wxString alstr = tag.GetParam(wxT("ALIGN")); wxString alstr = tag.GetParam(wxT("ALIGN"));
alstr.MakeUpper(); // for the case alignment was in ".." alstr.MakeUpper(); // for the case alignment was in ".."
if (alstr == wxT("TEXTTOP")) if (alstr == wxT("TEXTTOP"))
al = wxHTML_ALIGN_TOP; al = wxHTML_ALIGN_TOP;
else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER"))) else if ((alstr == wxT("CENTER")) || (alstr == wxT("ABSCENTER")))
al = wxHTML_ALIGN_CENTER; al = wxHTML_ALIGN_CENTER;
} }
if (tag.HasParam(wxT("USEMAP"))) if (tag.HasParam(wxT("USEMAP")))
{ {
mn = tag.GetParam( wxT("USEMAP") ); mn = tag.GetParam( wxT("USEMAP") );
if (mn.GetChar(0) == wxT('#')) if (mn.GetChar(0) == wxT('#'))
{ {
mn = mn.Mid( 1 ); mn = mn.Mid( 1 );
} }
} }
wxHtmlImageCell *cel = NULL; wxHtmlImageCell *cel = NULL;
if (str) if (str)
{ {
cel = new wxHtmlImageCell(str, w, h, m_WParser->GetPixelScale(), al, mn); cel = new wxHtmlImageCell(str, w, h, m_WParser->GetPixelScale(), al, mn);
cel->SetLink(m_WParser->GetLink()); cel->SetLink(m_WParser->GetLink());
m_WParser->GetContainer()->InsertCell(cel); m_WParser->GetContainer()->InsertCell(cel);
@@ -436,12 +435,12 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
} }
} }
} }
if (tag.GetName() == wxT("MAP")) if (tag.GetName() == wxT("MAP"))
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
if (tag.HasParam(wxT("NAME"))) if (tag.HasParam(wxT("NAME")))
{ {
wxString tmp = tag.GetParam(wxT("NAME")); wxString tmp = tag.GetParam(wxT("NAME"));
wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp ); wxHtmlImageMapCell *cel = new wxHtmlImageMapCell( tmp );
m_WParser->GetContainer()->InsertCell( cel ); m_WParser->GetContainer()->InsertCell( cel );
@@ -450,32 +449,32 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
if (tag.GetName() == wxT("AREA")) if (tag.GetName() == wxT("AREA"))
{ {
if (tag.HasParam(wxT("SHAPE"))) if (tag.HasParam(wxT("SHAPE")))
{ {
wxString tmp = tag.GetParam(wxT("SHAPE")); wxString tmp = tag.GetParam(wxT("SHAPE"));
wxString coords = wxEmptyString; wxString coords = wxEmptyString;
tmp.MakeUpper(); tmp.MakeUpper();
wxHtmlImageMapAreaCell *cel = NULL; wxHtmlImageMapAreaCell *cel = NULL;
if (tag.HasParam(wxT("COORDS"))) if (tag.HasParam(wxT("COORDS")))
{ {
coords = tag.GetParam(wxT("COORDS")); coords = tag.GetParam(wxT("COORDS"));
} }
if (tmp == wxT("POLY")) if (tmp == wxT("POLY"))
{ {
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords, m_WParser->GetPixelScale() ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords, m_WParser->GetPixelScale() );
} }
else if (tmp == wxT("CIRCLE")) else if (tmp == wxT("CIRCLE"))
{ {
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords, m_WParser->GetPixelScale() ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords, m_WParser->GetPixelScale() );
} }
else if (tmp == wxT("RECT")) else if (tmp == wxT("RECT"))
{ {
cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords, m_WParser->GetPixelScale() ); cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords, m_WParser->GetPixelScale() );
} }
if (cel != NULL && tag.HasParam(wxT("HREF"))) if (cel != NULL && tag.HasParam(wxT("HREF")))
{ {
wxString tmp = tag.GetParam(wxT("HREF")); wxString tmp = tag.GetParam(wxT("HREF"));
wxString target = wxEmptyString; wxString target = wxEmptyString;
if (tag.HasParam(wxT("TARGET"))) target = tag.GetParam(wxT("TARGET")); if (tag.HasParam(wxT("TARGET"))) target = tag.GetParam(wxT("TARGET"));

View File

@@ -20,7 +20,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
@@ -37,7 +36,7 @@ TAG_HANDLER_BEGIN(P, "P")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (m_WParser->GetContainer()->GetFirstCell() != NULL) if (m_WParser->GetContainer()->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -78,7 +77,7 @@ TAG_HANDLER_BEGIN(CENTER, "CENTER")
m_WParser->SetAlign(wxHTML_ALIGN_CENTER); m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
if (c->GetFirstCell() != NULL) if (c->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -86,12 +85,12 @@ TAG_HANDLER_BEGIN(CENTER, "CENTER")
c->SetAlignHor(wxHTML_ALIGN_CENTER); c->SetAlignHor(wxHTML_ALIGN_CENTER);
if (tag.HasEnding()) if (tag.HasEnding())
{ {
ParseInner(tag); ParseInner(tag);
m_WParser->SetAlign(old); m_WParser->SetAlign(old);
if (c->GetFirstCell() != NULL) if (c->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -114,7 +113,7 @@ TAG_HANDLER_BEGIN(DIV, "DIV")
int old = m_WParser->GetAlign(); int old = m_WParser->GetAlign();
wxHtmlContainerCell *c = m_WParser->GetContainer(); wxHtmlContainerCell *c = m_WParser->GetContainer();
if (c->GetFirstCell() != NULL) if (c->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();
@@ -122,7 +121,7 @@ TAG_HANDLER_BEGIN(DIV, "DIV")
m_WParser->SetAlign(c->GetAlignHor()); m_WParser->SetAlign(c->GetAlignHor());
} }
else else
{ {
c->SetAlign(tag); c->SetAlign(tag);
m_WParser->SetAlign(c->GetAlignHor()); m_WParser->SetAlign(c->GetAlignHor());
} }
@@ -131,7 +130,7 @@ TAG_HANDLER_BEGIN(DIV, "DIV")
m_WParser->SetAlign(old); m_WParser->SetAlign(old);
if (c->GetFirstCell() != NULL) if (c->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
} }
@@ -151,10 +150,10 @@ TAG_HANDLER_BEGIN(TITLE, "TITLE")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (m_WParser->GetWindow()) if (m_WParser->GetWindow())
{ {
wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser->GetWindow()); wxHtmlWindow *wfr = (wxHtmlWindow*)(m_WParser->GetWindow());
if (wfr) if (wfr)
{ {
wxString title = ""; wxString title = "";
wxString *src = m_WParser->GetSource(); wxString *src = m_WParser->GetSource();
@@ -177,7 +176,7 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
wxColour clr; wxColour clr;
if (tag.GetParamAsColour(wxT("TEXT"), &clr)) if (tag.GetParamAsColour(wxT("TEXT"), &clr))
{ {
m_WParser->SetActualColor(clr); m_WParser->SetActualColor(clr);
m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr)); m_WParser->GetContainer()->InsertCell(new wxHtmlColourCell(clr));
} }
@@ -186,7 +185,7 @@ TAG_HANDLER_BEGIN(BODY, "BODY")
m_WParser->SetLinkColor(clr); m_WParser->SetLinkColor(clr);
if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr)) if (tag.GetParamAsColour(wxT("BGCOLOR"), &clr))
{ {
m_WParser->GetContainer()->InsertCell( m_WParser->GetContainer()->InsertCell(
new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND)); new wxHtmlColourCell(clr, wxHTML_CLR_BACKGROUND));
if (m_WParser->GetWindow() != NULL) if (m_WParser->GetWindow() != NULL)
@@ -208,12 +207,12 @@ TAG_HANDLER_BEGIN(BLOCKQUOTE, "BLOCKQUOTE")
m_WParser->CloseContainer(); m_WParser->CloseContainer();
c = m_WParser->OpenContainer(); c = m_WParser->OpenContainer();
if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT) if (c->GetAlignHor() == wxHTML_ALIGN_RIGHT)
c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT); c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_RIGHT);
else else
c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT); c->SetIndent(5 * m_WParser->GetCharWidth(), wxHTML_INDENT_LEFT);
c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP); c->SetIndent(m_WParser->GetCharHeight(), wxHTML_INDENT_TOP);
m_WParser->OpenContainer(); m_WParser->OpenContainer();
ParseInner(tag); ParseInner(tag);
c = m_WParser->CloseContainer(); c = m_WParser->CloseContainer();

View File

@@ -21,10 +21,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
@@ -55,12 +53,12 @@ TAG_HANDLER_BEGIN(A, "A")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (tag.HasParam("NAME")) if (tag.HasParam("NAME"))
{ {
m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME"))); m_WParser->GetContainer()->InsertCell(new wxHtmlAnchorCell(tag.GetParam("NAME")));
} }
if (tag.HasParam("HREF")) if (tag.HasParam("HREF"))
{ {
wxHtmlLinkInfo oldlnk = m_WParser->GetLink(); wxHtmlLinkInfo oldlnk = m_WParser->GetLink();
wxColour oldclr = m_WParser->GetActualColor(); wxColour oldclr = m_WParser->GetActualColor();
int oldund = m_WParser->GetFontUnderlined(); int oldund = m_WParser->GetFontUnderlined();

View File

@@ -21,10 +21,10 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/brush.h"
#include "wx/dc.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
@@ -86,10 +86,10 @@ TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
wxHtmlContainerCell *c; wxHtmlContainerCell *c;
// List Item: // List Item:
if (tag.GetName() == wxT("LI")) if (tag.GetName() == wxT("LI"))
{ {
if (!tag.IsEnding()) if (!tag.IsEnding())
{ {
m_WParser->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP); m_WParser->GetContainer()->SetIndent(0, wxHTML_INDENT_TOP);
// this is to prevent indetation in <li><p> case // this is to prevent indetation in <li><p> case
m_WParser->CloseContainer(); m_WParser->CloseContainer();
@@ -100,8 +100,8 @@ TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
c->SetAlignHor(wxHTML_ALIGN_RIGHT); c->SetAlignHor(wxHTML_ALIGN_RIGHT);
if (m_Numbering == 0) if (m_Numbering == 0)
c->InsertCell(new wxHtmlListmarkCell(m_WParser->GetDC(), m_WParser->GetActualColor())); c->InsertCell(new wxHtmlListmarkCell(m_WParser->GetDC(), m_WParser->GetActualColor()));
else else
{ {
wxString mark; wxString mark;
mark.Printf(wxT("%i."), m_Numbering); mark.Printf(wxT("%i."), m_Numbering);
c->InsertCell(new wxHtmlWordCell(mark, *(m_WParser->GetDC()))); c->InsertCell(new wxHtmlWordCell(mark, *(m_WParser->GetDC())));
@@ -120,16 +120,16 @@ TAG_HANDLER_BEGIN(OLULLI, "OL,UL,LI")
} }
// Begin of List (not-numbered): "UL", "OL" // Begin of List (not-numbered): "UL", "OL"
else else
{ {
int oldnum = m_Numbering; int oldnum = m_Numbering;
if (tag.GetName() == wxT("UL")) m_Numbering = 0; if (tag.GetName() == wxT("UL")) m_Numbering = 0;
else m_Numbering = 1; else m_Numbering = 1;
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();
if (c->GetFirstCell() != NULL) if (c->GetFirstCell() != NULL)
{ {
m_WParser->CloseContainer(); m_WParser->CloseContainer();
m_WParser->OpenContainer(); m_WParser->OpenContainer();
c = m_WParser->GetContainer(); c = m_WParser->GetContainer();

View File

@@ -22,7 +22,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/fontmap.h" #include "wx/fontmap.h"
@@ -39,14 +38,14 @@ TAG_HANDLER_BEGIN(META, "META")
TAG_HANDLER_PROC(tag) TAG_HANDLER_PROC(tag)
{ {
if (tag.HasParam(_T("HTTP-EQUIV")) && if (tag.HasParam(_T("HTTP-EQUIV")) &&
tag.GetParam(_T("HTTP-EQUIV")) == _T("Content-Type") && tag.GetParam(_T("HTTP-EQUIV")) == _T("Content-Type") &&
tag.HasParam(_T("CONTENT"))) tag.HasParam(_T("CONTENT")))
{ {
wxString content = tag.GetParam(_T("CONTENT")); wxString content = tag.GetParam(_T("CONTENT"));
if (content.Left(19) == _T("text/html; charset=")) if (content.Left(19) == _T("text/html; charset="))
{ {
wxFontEncoding enc = wxFontEncoding enc =
wxTheFontMapper->CharsetToEncoding(content.Mid(19)); wxTheFontMapper->CharsetToEncoding(content.Mid(19));
if (enc == wxFONTENCODING_SYSTEM) return FALSE; if (enc == wxFONTENCODING_SYSTEM) return FALSE;
if (enc == m_WParser->GetInputEncoding()) return FALSE; if (enc == m_WParser->GetInputEncoding()) return FALSE;

View File

@@ -20,10 +20,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
#include "wx/html/forcelnk.h" #include "wx/html/forcelnk.h"
#include "wx/html/m_templ.h" #include "wx/html/m_templ.h"
@@ -65,7 +63,7 @@ TAG_HANDLER_BEGIN(PRE, "PRE")
wxString src, srcMid; wxString src, srcMid;
src = *m_WParser->GetSource(); src = *m_WParser->GetSource();
srcMid = src.Mid(tag.GetBeginPos(), srcMid = src.Mid(tag.GetBeginPos(),
tag.GetEndPos1() - tag.GetBeginPos()); tag.GetEndPos1() - tag.GetBeginPos());
srcMid.Replace(wxT("\t"), wxT(" ")); srcMid.Replace(wxT("\t"), wxT(" "));
srcMid.Replace(wxT(" "), wxT("&nbsp;")); srcMid.Replace(wxT(" "), wxT("&nbsp;"));
@@ -76,7 +74,7 @@ TAG_HANDLER_BEGIN(PRE, "PRE")
m_Parser->SetSource(srcMid); m_Parser->SetSource(srcMid);
m_Parser->DoParsing(); m_Parser->DoParsing();
m_Parser->SetSource(src); m_Parser->SetSource(src);
m_WParser->CloseContainer(); m_WParser->CloseContainer();
c = m_WParser->OpenContainer(); c = m_WParser->OpenContainer();

View File

@@ -20,7 +20,6 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h"
#endif #endif
@@ -49,9 +48,9 @@ FORCE_LINK_ME(m_tables)
typedef struct { typedef struct {
int width, units; int width, units;
// universal // universal
int leftpos, pixwidth, maxrealwidth; int leftpos, pixwidth, maxrealwidth;
// temporary (depends on width of table) // temporary (depends on width of table)
} colStruct; } colStruct;
@@ -126,11 +125,11 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
m_ActualCol = m_ActualRow = -1; m_ActualCol = m_ActualRow = -1;
/* scan params: */ /* scan params: */
if (tag.HasParam(wxT("BGCOLOR"))) if (tag.HasParam(wxT("BGCOLOR")))
tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg); tag.GetParamAsColour(wxT("BGCOLOR"), &m_tBkg);
if (tag.HasParam(wxT("VALIGN"))) if (tag.HasParam(wxT("VALIGN")))
m_tValign = tag.GetParam(wxT("VALIGN")); m_tValign = tag.GetParam(wxT("VALIGN"));
else else
m_tValign = wxEmptyString; m_tValign = wxEmptyString;
if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing)) if (!tag.GetParamAsInt(wxT("CELLSPACING"), &m_Spacing))
m_Spacing = 2; m_Spacing = 2;
@@ -148,7 +147,7 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
wxHtmlTableCell::~wxHtmlTableCell() wxHtmlTableCell::~wxHtmlTableCell()
{ {
if (m_ColsInfo) free(m_ColsInfo); if (m_ColsInfo) free(m_ColsInfo);
if (m_CellInfo) if (m_CellInfo)
{ {
for (int i = 0; i < m_NumRows; i++) for (int i = 0; i < m_NumRows; i++)
free(m_CellInfo[i]); free(m_CellInfo[i]);
@@ -162,7 +161,7 @@ void wxHtmlTableCell::ReallocCols(int cols)
{ {
int i,j; int i,j;
for (i = 0; i < m_NumRows; i++) for (i = 0; i < m_NumRows; i++)
{ {
m_CellInfo[i] = (cellStruct*) realloc(m_CellInfo[i], sizeof(cellStruct) * cols); m_CellInfo[i] = (cellStruct*) realloc(m_CellInfo[i], sizeof(cellStruct) * cols);
for (j = m_NumCols; j < cols; j++) for (j = m_NumCols; j < cols; j++)
@@ -170,7 +169,7 @@ void wxHtmlTableCell::ReallocCols(int cols)
} }
m_ColsInfo = (colStruct*) realloc(m_ColsInfo, sizeof(colStruct) * cols); m_ColsInfo = (colStruct*) realloc(m_ColsInfo, sizeof(colStruct) * cols);
for (j = m_NumCols; j < cols; j++) for (j = m_NumCols; j < cols; j++)
{ {
m_ColsInfo[j].width = 0; m_ColsInfo[j].width = 0;
m_ColsInfo[j].units = wxHTML_UNITS_PERCENT; m_ColsInfo[j].units = wxHTML_UNITS_PERCENT;
@@ -184,11 +183,11 @@ void wxHtmlTableCell::ReallocCols(int cols)
void wxHtmlTableCell::ReallocRows(int rows) void wxHtmlTableCell::ReallocRows(int rows)
{ {
m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows); m_CellInfo = (cellStruct**) realloc(m_CellInfo, sizeof(cellStruct*) * rows);
for (int row = m_NumRows; row < rows ; row++) for (int row = m_NumRows; row < rows ; row++)
{ {
if (m_NumCols == 0) if (m_NumCols == 0)
m_CellInfo[row] = NULL; m_CellInfo[row] = NULL;
else else
{ {
m_CellInfo[row] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols); m_CellInfo[row] = (cellStruct*) malloc(sizeof(cellStruct) * m_NumCols);
for (int col = 0; col < m_NumCols; col++) for (int col = 0; col < m_NumCols; col++)
@@ -208,11 +207,11 @@ void wxHtmlTableCell::AddRow(const wxHtmlTag& tag)
// scan params: // scan params:
m_rBkg = m_tBkg; m_rBkg = m_tBkg;
if (tag.HasParam(wxT("BGCOLOR"))) if (tag.HasParam(wxT("BGCOLOR")))
tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg); tag.GetParamAsColour(wxT("BGCOLOR"), &m_rBkg);
if (tag.HasParam(wxT("VALIGN"))) if (tag.HasParam(wxT("VALIGN")))
m_rValign = tag.GetParam(wxT("VALIGN")); m_rValign = tag.GetParam(wxT("VALIGN"));
else else
m_rValign = m_tValign; m_rValign = m_tValign;
} }
@@ -230,12 +229,12 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
} }
// cells & columns: // cells & columns:
do do
{ {
m_ActualCol++; m_ActualCol++;
} while ((m_ActualCol < m_NumCols) && } while ((m_ActualCol < m_NumCols) &&
(m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree)); (m_CellInfo[m_ActualRow][m_ActualCol].flag != cellFree));
if (m_ActualCol > m_NumCols - 1) if (m_ActualCol > m_NumCols - 1)
ReallocCols(m_ActualCol + 1); ReallocCols(m_ActualCol + 1);
@@ -261,7 +260,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width); wxSscanf(wd.c_str(), wxT("%i%%"), &m_ColsInfo[c].width);
m_ColsInfo[c].units = wxHTML_UNITS_PERCENT; m_ColsInfo[c].units = wxHTML_UNITS_PERCENT;
} }
else else
{ {
wxSscanf(wd.c_str(), wxT("%i"), &m_ColsInfo[c].width); wxSscanf(wd.c_str(), wxT("%i"), &m_ColsInfo[c].width);
m_ColsInfo[c].width = (int)(m_PixelScale * (double)m_ColsInfo[c].width); m_ColsInfo[c].width = (int)(m_PixelScale * (double)m_ColsInfo[c].width);
@@ -275,13 +274,13 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
{ {
tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan); tag.GetParamAsInt(wxT("COLSPAN"), &m_CellInfo[r][c].colspan);
tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan); tag.GetParamAsInt(wxT("ROWSPAN"), &m_CellInfo[r][c].rowspan);
if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1)) if ((m_CellInfo[r][c].colspan != 1) || (m_CellInfo[r][c].rowspan != 1))
{ {
int i, j; int i, j;
if (r + m_CellInfo[r][c].rowspan > m_NumRows) if (r + m_CellInfo[r][c].rowspan > m_NumRows)
ReallocRows(r + m_CellInfo[r][c].rowspan); ReallocRows(r + m_CellInfo[r][c].rowspan);
if (c + m_CellInfo[r][c].colspan > m_NumCols) if (c + m_CellInfo[r][c].colspan > m_NumCols)
ReallocCols(c + m_CellInfo[r][c].colspan); ReallocCols(c + m_CellInfo[r][c].colspan);
for (i = r; i < r + m_CellInfo[r][c].rowspan; i++) for (i = r; i < r + m_CellInfo[r][c].rowspan; i++)
for (j = c; j < c + m_CellInfo[r][c].colspan; j++) for (j = c; j < c + m_CellInfo[r][c].colspan; j++)
@@ -293,7 +292,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
//background color: //background color:
{ {
wxColour bk = m_rBkg; wxColour bk = m_rBkg;
if (tag.HasParam(wxT("BGCOLOR"))) if (tag.HasParam(wxT("BGCOLOR")))
tag.GetParamAsColour(wxT("BGCOLOR"), &bk); tag.GetParamAsColour(wxT("BGCOLOR"), &bk);
if (bk.Ok()) if (bk.Ok())
cell->SetBackgroundColour(bk); cell->SetBackgroundColour(bk);
@@ -304,14 +303,14 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
// vertical alignment: // vertical alignment:
{ {
wxString valign; wxString valign;
if (tag.HasParam(wxT("VALIGN"))) if (tag.HasParam(wxT("VALIGN")))
valign = tag.GetParam(wxT("VALIGN")); valign = tag.GetParam(wxT("VALIGN"));
else else
valign = m_tValign; valign = m_tValign;
valign.MakeUpper(); valign.MakeUpper();
if (valign == wxT("TOP")) if (valign == wxT("TOP"))
m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP; m_CellInfo[r][c].valign = wxHTML_ALIGN_TOP;
else if (valign == wxT("BOTTOM")) else if (valign == wxT("BOTTOM"))
m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM; m_CellInfo[r][c].valign = wxHTML_ALIGN_BOTTOM;
else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER; else m_CellInfo[r][c].valign = wxHTML_ALIGN_CENTER;
} }
@@ -331,12 +330,12 @@ void wxHtmlTableCell::Layout(int w)
*/ */
if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT) if (m_WidthFloatUnits == wxHTML_UNITS_PERCENT)
{ {
if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100; if (m_WidthFloat < 0) m_Width = (100 + m_WidthFloat) * w / 100;
else m_Width = m_WidthFloat * w / 100; else m_Width = m_WidthFloat * w / 100;
} }
else else
{ {
if (m_WidthFloat < 0) m_Width = w + m_WidthFloat; if (m_WidthFloat < 0) m_Width = w + m_WidthFloat;
else m_Width = m_WidthFloat; else m_Width = m_WidthFloat;
@@ -379,7 +378,7 @@ void wxHtmlTableCell::Layout(int w)
/* 2. compute positions of columns: */ /* 2. compute positions of columns: */
{ {
int wpos = m_Spacing; int wpos = m_Spacing;
for (int i = 0; i < m_NumCols; i++) for (int i = 0; i < m_NumCols; i++)
{ {
m_ColsInfo[i].leftpos = wpos; m_ColsInfo[i].leftpos = wpos;
wpos += m_ColsInfo[i].pixwidth + m_Spacing; wpos += m_ColsInfo[i].pixwidth + m_Spacing;
@@ -396,7 +395,7 @@ void wxHtmlTableCell::Layout(int w)
ypos[0] = m_Spacing; ypos[0] = m_Spacing;
for (actrow = 1; actrow <= m_NumRows; actrow++) ypos[actrow] = -1; for (actrow = 1; actrow <= m_NumRows; actrow++) ypos[actrow] = -1;
for (actrow = 0; actrow < m_NumRows; actrow++) for (actrow = 0; actrow < m_NumRows; actrow++)
{ {
if (ypos[actrow] == -1) ypos[actrow] = ypos[actrow-1]; if (ypos[actrow] == -1) ypos[actrow] = ypos[actrow-1];
// 3a. sub-layout and detect max height: // 3a. sub-layout and detect max height:
@@ -417,11 +416,11 @@ void wxHtmlTableCell::Layout(int w)
} }
} }
for (actrow = 0; actrow < m_NumRows; actrow++) for (actrow = 0; actrow < m_NumRows; actrow++)
{ {
// 3b. place cells in row & let'em all have same height: // 3b. place cells in row & let'em all have same height:
for (actcol = 0; actcol < m_NumCols; actcol++) for (actcol = 0; actcol < m_NumCols; actcol++)
{ {
if (m_CellInfo[actrow][actcol].flag != cellUsed) continue; if (m_CellInfo[actrow][actcol].flag != cellUsed) continue;
actcell = m_CellInfo[actrow][actcol].cont; actcell = m_CellInfo[actrow][actcol].cont;
@@ -471,7 +470,7 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
wxHtmlContainerCell *c; wxHtmlContainerCell *c;
// new table started, backup upper-level table (if any) and create new: // new table started, backup upper-level table (if any) and create new:
if (tag.GetName() == wxT("TABLE")) if (tag.GetName() == wxT("TABLE"))
{ {
wxHtmlTableCell *oldt = m_Table; wxHtmlTableCell *oldt = m_Table;
wxHtmlContainerCell *oldcont; wxHtmlContainerCell *oldcont;
@@ -496,19 +495,19 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
} }
else if (m_Table && !tag.IsEnding()) else if (m_Table && !tag.IsEnding())
{ {
// new row in table // new row in table
if (tag.GetName() == wxT("TR")) if (tag.GetName() == wxT("TR"))
{ {
m_Table->AddRow(tag); m_Table->AddRow(tag);
m_rAlign = m_tAlign; m_rAlign = m_tAlign;
if (tag.HasParam(wxT("ALIGN"))) if (tag.HasParam(wxT("ALIGN")))
m_rAlign = tag.GetParam(wxT("ALIGN")); m_rAlign = tag.GetParam(wxT("ALIGN"));
} }
// new cell // new cell
else else
{ {
m_WParser->SetAlign(m_OldAlign); m_WParser->SetAlign(m_OldAlign);
c = m_WParser->SetContainer(new wxHtmlContainerCell(m_Table)); c = m_WParser->SetContainer(new wxHtmlContainerCell(m_Table));
@@ -516,7 +515,7 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
m_WParser->OpenContainer(); m_WParser->OpenContainer();
if (tag.GetName() == wxT("TH")) /*header style*/ if (tag.GetName() == wxT("TH")) /*header style*/
{ {
m_WParser->SetAlign(wxHTML_ALIGN_CENTER); m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
} }
@@ -525,12 +524,12 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
wxString als; wxString als;
als = m_rAlign; als = m_rAlign;
if (tag.HasParam(wxT("ALIGN"))) if (tag.HasParam(wxT("ALIGN")))
als = tag.GetParam(wxT("ALIGN")); als = tag.GetParam(wxT("ALIGN"));
als.MakeUpper(); als.MakeUpper();
if (als == wxT("RIGHT")) if (als == wxT("RIGHT"))
m_WParser->SetAlign(wxHTML_ALIGN_RIGHT); m_WParser->SetAlign(wxHTML_ALIGN_RIGHT);
else if (als == wxT("CENTER")) else if (als == wxT("CENTER"))
m_WParser->SetAlign(wxHTML_ALIGN_CENTER); m_WParser->SetAlign(wxHTML_ALIGN_CENTER);
} }
m_WParser->OpenContainer(); m_WParser->OpenContainer();

View File

@@ -23,13 +23,11 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include <wx/wx.h>
#endif #endif
#include "wx/html/helpdata.h" #include "wx/html/helpdata.h"
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
// wxSearchEngine // wxSearchEngine
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------

View File

@@ -22,7 +22,8 @@
#endif #endif
#ifndef WXPRECOMP #ifndef WXPRECOMP
#include "wx/wx.h" #include "wx/intl.h"
#include "wx/dc.h"
#endif #endif
#include "wx/html/htmldefs.h" #include "wx/html/htmldefs.h"