added HTML printing
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -607,6 +607,7 @@ HTML_HEADERS = \
|
|||||||
html/htmlpars.h \
|
html/htmlpars.h \
|
||||||
html/htmltag.h \
|
html/htmltag.h \
|
||||||
html/htmlwin.h \
|
html/htmlwin.h \
|
||||||
|
html/htmprint.h \
|
||||||
html/m_templ.h \
|
html/m_templ.h \
|
||||||
html/winpars.h
|
html/winpars.h
|
||||||
|
|
||||||
@@ -1811,6 +1812,7 @@ HTMLOBJS = \
|
|||||||
htmlpars.o \
|
htmlpars.o \
|
||||||
htmltag.o \
|
htmltag.o \
|
||||||
htmlwin.o \
|
htmlwin.o \
|
||||||
|
htmprint.o \
|
||||||
m_fonts.o \
|
m_fonts.o \
|
||||||
m_hline.o \
|
m_hline.o \
|
||||||
m_image.o \
|
m_image.o \
|
||||||
@@ -1831,6 +1833,7 @@ HTMLDEPS = \
|
|||||||
htmlpars.d \
|
htmlpars.d \
|
||||||
htmltag.d \
|
htmltag.d \
|
||||||
htmlwin.d \
|
htmlwin.d \
|
||||||
|
htmprint.d \
|
||||||
m_fonts.d \
|
m_fonts.d \
|
||||||
m_hline.d \
|
m_hline.d \
|
||||||
m_image.d \
|
m_image.d \
|
||||||
|
@@ -413,6 +413,7 @@ m_list.cpp H
|
|||||||
m_pre.cpp H
|
m_pre.cpp H
|
||||||
m_tables.cpp H
|
m_tables.cpp H
|
||||||
search.cpp H
|
search.cpp H
|
||||||
|
htmprint.cpp H
|
||||||
|
|
||||||
arrimpl.cpp W
|
arrimpl.cpp W
|
||||||
listimpl.cpp W
|
listimpl.cpp W
|
||||||
@@ -846,6 +847,7 @@ htmltag.h L
|
|||||||
htmlwin.h L
|
htmlwin.h L
|
||||||
winpars.h L
|
winpars.h L
|
||||||
m_templ.h L
|
m_templ.h L
|
||||||
|
htmprint.h L
|
||||||
|
|
||||||
caret.h N
|
caret.h N
|
||||||
choicdgg.h N
|
choicdgg.h N
|
||||||
|
@@ -90,9 +90,12 @@
|
|||||||
\input htcell.tex
|
\input htcell.tex
|
||||||
\input htcolor.tex
|
\input htcolor.tex
|
||||||
\input htcontnr.tex
|
\input htcontnr.tex
|
||||||
|
\input htdcrend.tex
|
||||||
|
\input hteasypr.tex
|
||||||
\input htfilter.tex
|
\input htfilter.tex
|
||||||
\input hthelpct.tex
|
\input hthelpct.tex
|
||||||
\input htparser.tex
|
\input htparser.tex
|
||||||
|
\input htprint.tex
|
||||||
\input httag.tex
|
\input httag.tex
|
||||||
\input httaghnd.tex
|
\input httaghnd.tex
|
||||||
\input httagmod.tex
|
\input httagmod.tex
|
||||||
|
129
docs/latex/wx/htdcrend.tex
Normal file
129
docs/latex/wx/htdcrend.tex
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
%
|
||||||
|
% automatically generated by HelpGen from
|
||||||
|
% htmprint.h at 17/Oct/99 12:48:02
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
\section{\class{wxHtmlDCRenderer}}\label{wxhtmldcrenderer}
|
||||||
|
|
||||||
|
This class can render HTML document into specified area of DC. You can use it
|
||||||
|
in your own printing code, although use of \helpref{wxHtmlEasyPrinting}{wxhtmleasyprinting}
|
||||||
|
or \helpref{wxHtmlPrintout}{wxhtmlprintout} is strongly recommended.
|
||||||
|
|
||||||
|
|
||||||
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
\helpref{wxObject}{wxobject}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::wxHtmlDCRenderer}\label{wxhtmldcrendererwxhtmldcrenderer}
|
||||||
|
|
||||||
|
\func{}{wxHtmlDCRenderer}{\void}
|
||||||
|
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::SetDC}\label{wxhtmldcrenderersetdc}
|
||||||
|
|
||||||
|
\func{void}{SetDC}{\param{wxDC* }{dc}, \param{int }{maxwidth}}
|
||||||
|
|
||||||
|
Assign DC instance to the renderer.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{maxwidth}{width of the area (on this DC) that is equivalent to screen's width,
|
||||||
|
in pixels (you should set it to page width minus margins).
|
||||||
|
|
||||||
|
{\bf Note:} In current implementation
|
||||||
|
screen width is always 800 pixels : it gives best results and ensures (almost) same printed outputs
|
||||||
|
across platforms and differently configured desktops.}
|
||||||
|
|
||||||
|
Also see \helpref{SetSize}{wxhtmldcrenderersetsize}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::SetSize}\label{wxhtmldcrenderersetsize}
|
||||||
|
|
||||||
|
\func{void}{SetSize}{\param{int }{width}, \param{int }{height}}
|
||||||
|
|
||||||
|
Set size of output rectangle, in pixels. Note that you {\bf can't} change
|
||||||
|
width of the rectangle between calls to \helpref{Render}{wxhtmldcrendererrender}!
|
||||||
|
(You can freely change height.)
|
||||||
|
If you set width equal to maxwidth then HTML is rendered as if it were displayed in fullscreen.
|
||||||
|
If you set width = 1/2 maxwidth the it is rendered as if it covered half the screen
|
||||||
|
and so on.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::SetHtmlText}\label{wxhtmldcrenderersethtmltext}
|
||||||
|
|
||||||
|
\func{void}{SetHtmlText}{\param{const wxString\& }{html}, \param{const wxString\& }{basepath = wxEmptyString}, \param{bool }{isdir = TRUE}}
|
||||||
|
|
||||||
|
Assign text to the renderer. \helpref{Render}{wxhtmldcrendererrender} then draws
|
||||||
|
the text onto DC.
|
||||||
|
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{html}{HTML text. (NOT file!)}
|
||||||
|
|
||||||
|
\docparam{basepath}{base directory (html string would be stored there if it was in
|
||||||
|
file). It is used to determine path for loading images, for example.}
|
||||||
|
|
||||||
|
\docparam{isdir}{FALSE if basepath is filename, TRUE if it is directory name
|
||||||
|
(see \helpref{wxFileSystem}{wxfilesystem} for detailed explanation)}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::Render}\label{wxhtmldcrendererrender}
|
||||||
|
|
||||||
|
\func{int}{Render}{\param{int }{x}, \param{int }{y}, \param{int }{from = 0}, \param{int }{dont\_render = FALSE}}
|
||||||
|
|
||||||
|
Renders HTML text to the DC.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
|
||||||
|
\docparam{x,y}{ position of upper-left corner of printing rectangle (see \helpref{SetSize}{wxhtmldcrenderersetsize})}
|
||||||
|
|
||||||
|
|
||||||
|
\docparam{from}{y-coordinate of the very first visible cell}
|
||||||
|
|
||||||
|
\docparam{dont\_render}{if TRUE then this method only returns y coordinate of the next page
|
||||||
|
and does not output anything}
|
||||||
|
|
||||||
|
Returned value is y coordinate of first cell than didn't fit onto page.
|
||||||
|
Use this value as {\it from} in next call to Render in order to print multipages
|
||||||
|
document.
|
||||||
|
|
||||||
|
|
||||||
|
\wxheading{Caution!}
|
||||||
|
|
||||||
|
Following 3 methods {\bf must} always be called before any call to Render (preferably
|
||||||
|
in this order):
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
|
||||||
|
\item \helpref{SetDC}{wxhtmldcrenderersetdc}
|
||||||
|
\item \helpref{SetSize}{wxhtmldcrenderersetsize}
|
||||||
|
\item \helpref{SetHtmlText}{wxhtmldcrenderersethtmltext}
|
||||||
|
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
{\bf Render() changes DC's user scale and does NOT restore it!!}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlDCRenderer::GetTotalHeight}\label{wxhtmldcrenderergettotalheight}
|
||||||
|
|
||||||
|
\func{int}{GetTotalHeight}{\void}
|
||||||
|
|
||||||
|
Returns height of the HTML text. This is important if area height (see \helpref{SetSize}{wxhtmldcrenderersetsize})
|
||||||
|
is smaller that total height and thus the page cannot fit into it. In that case you're supposed to
|
||||||
|
call \helpref{Render}{wxhtmldcrendererrender} as long as it's return value is smaller than GetTotalHeight's.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
151
docs/latex/wx/hteasypr.tex
Normal file
151
docs/latex/wx/hteasypr.tex
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
%
|
||||||
|
% automatically generated by HelpGen from
|
||||||
|
% htmprint.h at 17/Oct/99 12:48:02
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
\section{\class{wxHtmlEasyPrinting}}\label{wxhtmleasyprinting}
|
||||||
|
|
||||||
|
|
||||||
|
This class provides very simple interface to printing
|
||||||
|
architecture. It allows you to print HTML documents only
|
||||||
|
with very few commands.
|
||||||
|
|
||||||
|
|
||||||
|
\wxheading{Note}
|
||||||
|
Do not create this class on stack only. You should create an instance on app
|
||||||
|
startup and use this instance for all printing operations. The reason is that
|
||||||
|
this class stores various settings in it.
|
||||||
|
|
||||||
|
|
||||||
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
\helpref{wxObject}{wxobject}
|
||||||
|
|
||||||
|
|
||||||
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::wxHtmlEasyPrinting}\label{wxhtmleasyprintingwxhtmleasyprinting}
|
||||||
|
|
||||||
|
\func{}{wxHtmlEasyPrinting}{\param{const wxString\& }{name = "Printing"}, \param{wxFrame* }{parent\_frame = NULL}}
|
||||||
|
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{name}{Name of the printing. Used by preview frames and setup dialogs.}
|
||||||
|
|
||||||
|
\docparam{parent\_frame}{pointer to the frame that will own preview frame and setup dialogs. May be NULL.}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PreviewFile}\label{wxhtmleasyprintingpreviewfile}
|
||||||
|
|
||||||
|
\func{void}{PreviewFile}{\param{const wxString\& }{htmlfile}}
|
||||||
|
|
||||||
|
Previews HTML file.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PreviewText}\label{wxhtmleasyprintingpreviewtext}
|
||||||
|
|
||||||
|
\func{void}{PreviewText}{\param{const wxString\& }{htmltext}, \param{const wxString\& }{basepath = wxEmptyString}}
|
||||||
|
|
||||||
|
Previews HTML text (not file!).
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{htmltext}{HTML text.}
|
||||||
|
|
||||||
|
\docparam{basepath}{base directory (html string would be stored there if it was in
|
||||||
|
file). It is used to determine path for loading images, for example.}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PrintFile}\label{wxhtmleasyprintingprintfile}
|
||||||
|
|
||||||
|
\func{void}{PrintFile}{\param{const wxString\& }{htmlfile}}
|
||||||
|
|
||||||
|
Prints HTML file.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PrintText}\label{wxhtmleasyprintingprinttext}
|
||||||
|
|
||||||
|
\func{void}{PrintText}{\param{const wxString\& }{htmltext}, \param{const wxString\& }{basepath = wxEmptyString}}
|
||||||
|
|
||||||
|
Prints HTML text (not file!).
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{htmltext}{HTML text.}
|
||||||
|
|
||||||
|
\docparam{basepath}{base directory (html string would be stored there if it was in
|
||||||
|
file). It is used to determine path for loading images, for example.}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PrinterSetup}\label{wxhtmleasyprintingprintersetup}
|
||||||
|
|
||||||
|
\func{void}{PrinterSetup}{\void}
|
||||||
|
|
||||||
|
Displays printer setup dialog and allows the user to modify settings.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::PageSetup}\label{wxhtmleasyprintingpagesetup}
|
||||||
|
|
||||||
|
\func{void}{PageSetup}{\void}
|
||||||
|
|
||||||
|
Displays page setup dialog and allows the user to modify settings.
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::SetHeader}\label{wxhtmleasyprintingsetheader}
|
||||||
|
|
||||||
|
\func{void}{SetHeader}{\param{const wxString\& }{header}, \param{int }{pg = wxPAGE\_ALL}}
|
||||||
|
|
||||||
|
Sets page header.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{header}{HTML text to be used as header. You can use macros in it:
|
||||||
|
\begin{itemize}
|
||||||
|
\item @PAGENUM@ is replaced by page number
|
||||||
|
\item @PAGESCNT@ is replaced by total number of pages
|
||||||
|
\end{itemize}
|
||||||
|
}
|
||||||
|
|
||||||
|
\docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::SetFooter}\label{wxhtmleasyprintingsetfooter}
|
||||||
|
|
||||||
|
\func{void}{SetFooter}{\param{const wxString\& }{footer}, \param{int }{pg = wxPAGE\_ALL}}
|
||||||
|
|
||||||
|
Sets page footer.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{footer}{HTML text to be used as footer. You can use macros in it:
|
||||||
|
\begin{itemize}
|
||||||
|
\item @PAGENUM@ is replaced by page number
|
||||||
|
\item @PAGESCNT@ is replaced by total number of pages
|
||||||
|
\end{itemize}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
\docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::GetPrintData}\label{wxhtmleasyprintinggetprintdata}
|
||||||
|
|
||||||
|
\func{wxPrintData*}{GetPrintData}{\void}
|
||||||
|
|
||||||
|
Returns pointer to \helpref{wxPrintData}{wxprintdata} instance used by this class. You can
|
||||||
|
set its parameters (via SetXXXX methods).
|
||||||
|
|
||||||
|
\membersection{wxHtmlEasyPrinting::GetPageSetupData}\label{wxhtmleasyprintinggetpagesetupdata}
|
||||||
|
|
||||||
|
\func{wxPageSetupDialogData*}{GetPageSetupData}{\void}
|
||||||
|
|
||||||
|
Returns pointer to \helpref{wxPageSetupDialogData}{wxpagesetupdialogdata} instance used by
|
||||||
|
this class. You can set its parameters (via SetXXXX methods).
|
@@ -1,63 +1,14 @@
|
|||||||
\membersection{Printing}\label{printing}
|
\membersection{HTML Printing}\label{printing}
|
||||||
|
|
||||||
The wxHTML library provides printing facilities.
|
The wxHTML library provides printing facilities with several levels of complexity.
|
||||||
|
|
||||||
You can redirect output displayed by \helpref{wxHtmlWindow}{wxhtmlwindow}
|
The easiest way to print an HTML document is to use
|
||||||
to the printer DC using this (or similar) code (see {\bf printing} sample for
|
\helpref{wxHtmlEasyPrinting class}{wxhtmleasyprinting}. It lets you print HTML documents with only one
|
||||||
more details) :
|
command and you don't have to care about wxPrintouts etc. at all. It is only simple wrapper around
|
||||||
|
\helpref{wxHtmlPrintout}{wxhtmlprintout}, normal wxWindows printout class.
|
||||||
|
|
||||||
\begin{verbatim}
|
|
||||||
//
|
|
||||||
// This method prints page number one to dc:
|
|
||||||
//
|
|
||||||
|
|
||||||
void MyPrintout::DrawPageOne(wxDC *dc)
|
And finally there is low level class \helpref{wxHtmlDCRenderer}{wxhtmldcrenderer} which you can use to
|
||||||
{
|
render HTML into rectangular area on any DC. It supports rendering into multiple rectangles with same
|
||||||
int leftMargin = 20;
|
width. (Most common use is placing one rectangle on each page or printing into two columns.)
|
||||||
int topMargin = 50;
|
|
||||||
// You must compute the margins there.
|
|
||||||
// Caution! These values are NOT in printer DC's units.
|
|
||||||
// These values are in screen pixels.
|
|
||||||
// (see bellow)
|
|
||||||
|
|
||||||
// Here we obtain internal cell representation of HTML document:
|
|
||||||
// (html is our pointer to wxHtmlWindow object)
|
|
||||||
wxHtmlContainerCell *cell = html -> GetInternalRepresentation();
|
|
||||||
|
|
||||||
// Now we have to check in case our real page size is reduced
|
|
||||||
// (e.g. because we're drawing to a print preview memory DC)
|
|
||||||
int pageWidth, pageHeight;
|
|
||||||
int w, h;
|
|
||||||
dc->GetSize(&w, &h); // DC size
|
|
||||||
GetPageSizePixels(&pageWidth, &pageHeight); // real size
|
|
||||||
|
|
||||||
// Now we must scale it. This equation will map wxHtmlWindow
|
|
||||||
// to page in this way:
|
|
||||||
// |--this is whole page as printed---------|
|
|
||||||
// | | | |
|
|
||||||
// | | | |
|
|
||||||
// |-margin-|-----wxHtmlWindow-----|-margin-|
|
|
||||||
//
|
|
||||||
// So page width is 2*leftMargin + [wxHtmlWindow size]
|
|
||||||
// (measured in screen pixels).
|
|
||||||
// We will scale the printer DC so that wxHtmlWindow's content
|
|
||||||
// spreads from left to right:
|
|
||||||
float scale = (float)(
|
|
||||||
(float)(pageWidth) /
|
|
||||||
(float)(2 * leftMargin + cell -> GetMaxLineWidth()));
|
|
||||||
|
|
||||||
// If printer pageWidth == current DC width, then this doesn't
|
|
||||||
// change. But w might be the preview bitmap width, so scale down.
|
|
||||||
float overallScale = scale * (float)(w/(float)pageWidth);
|
|
||||||
|
|
||||||
// Set the user scale so that our computations take effect:
|
|
||||||
dc->SetUserScale(overallScale, overallScale);
|
|
||||||
dc->SetBackgroundMode(wxTRANSPARENT);
|
|
||||||
|
|
||||||
// And this is - finally - HTML stuff:
|
|
||||||
cell -> Draw(*dc, leftMargin, topMargin, 0, cell -> GetHeight());
|
|
||||||
}
|
|
||||||
\end{verbatim}
|
|
||||||
|
|
||||||
(Thanks to Julian Smart for sample)
|
|
||||||
|
|
||||||
|
96
docs/latex/wx/htprint.tex
Normal file
96
docs/latex/wx/htprint.tex
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
%
|
||||||
|
% automatically generated by HelpGen from
|
||||||
|
% htmprint.h at 17/Oct/99 12:48:02
|
||||||
|
%
|
||||||
|
|
||||||
|
|
||||||
|
\section{\class{wxHtmlPrintout}}\label{wxhtmlprintout}
|
||||||
|
|
||||||
|
This class serves as printout class for HTML documents.
|
||||||
|
|
||||||
|
\wxheading{Derived from}
|
||||||
|
|
||||||
|
\helpref{wxPrintout}{wxprintout}
|
||||||
|
|
||||||
|
|
||||||
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::wxHtmlPrintout}\label{wxhtmlprintoutwxhtmlprintout}
|
||||||
|
|
||||||
|
\func{}{wxHtmlPrintout}{\param{const wxString\& }{title = "Printout"}}
|
||||||
|
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::SetHtmlText}\label{wxhtmlprintoutsethtmltext}
|
||||||
|
|
||||||
|
\func{void}{SetHtmlText}{\param{const wxString\& }{html}, \param{const wxString\& }{basepath = wxEmptyString}, \param{bool }{isdir = TRUE}}
|
||||||
|
|
||||||
|
Prepare the class for printing this HTML text.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{html}{HTML text. (NOT file!)}
|
||||||
|
|
||||||
|
\docparam{basepath}{base directory (html string would be stored there if it was in
|
||||||
|
file). It is used to determine path for loading images, for example.}
|
||||||
|
|
||||||
|
\docparam{isdir}{FALSE if basepath is filename, TRUE if it is directory name
|
||||||
|
(see \helpref{wxFileSystem}{wxfilesystem} for detailed explanation)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::SetHtmlFile}\label{wxhtmlprintoutsethtmlfile}
|
||||||
|
|
||||||
|
\func{void}{SetHtmlFile}{\param{const wxString\& }{htmlfile}}
|
||||||
|
|
||||||
|
Prepare the class for printing this HTML {\bf file}. The file may be located on
|
||||||
|
any virtual file system or it may be normal file.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::SetHeader}\label{wxhtmlprintoutsetheader}
|
||||||
|
|
||||||
|
\func{void}{SetHeader}{\param{const wxString\& }{header}, \param{int }{pg = wxPAGE\_ALL}}
|
||||||
|
|
||||||
|
Sets page header.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{header}{HTML text to be used as header. You can use macros in it:
|
||||||
|
\begin{itemize}
|
||||||
|
\item @PAGENUM@ is replaced by page number
|
||||||
|
\item @PAGESCNT@ is replaced by total number of pages
|
||||||
|
\end{itemize}
|
||||||
|
}
|
||||||
|
|
||||||
|
\docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::SetFooter}\label{wxhtmlprintoutsetfooter}
|
||||||
|
|
||||||
|
\func{void}{SetFooter}{\param{const wxString\& }{footer}, \param{int }{pg = wxPAGE\_ALL}}
|
||||||
|
|
||||||
|
Sets page footer.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{footer}{HTML text to be used as footer. You can use macros in it:
|
||||||
|
\begin{itemize}
|
||||||
|
\item @PAGENUM@ is replaced by page number
|
||||||
|
\item @PAGESCNT@ is replaced by total number of pages
|
||||||
|
\end{itemize}
|
||||||
|
}
|
||||||
|
|
||||||
|
\docparam{pg}{one of wxPAGE\_ODD, wxPAGE\_EVEN and wxPAGE\_ALL constants.}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxHtmlPrintout::SetMargins}\label{wxhtmlprintoutsetmargins}
|
||||||
|
|
||||||
|
\func{void}{SetMargins}{\param{float }{top = 25.2}, \param{float }{bottom = 25.2}, \param{float }{left = 25.2}, \param{float }{right = 25.2}, \param{float }{spaces = 5}}
|
||||||
|
|
||||||
|
Sets margins in milimeters. Defaults to 1 inch for margins and 0.5cm for space
|
||||||
|
between text and header and/or footer
|
||||||
|
|
239
include/wx/html/htmprint.h
Normal file
239
include/wx/html/htmprint.h
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmprint.h
|
||||||
|
// Purpose: html printing classes
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Created: 25/09/99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c)
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_HTMPRINT_H_
|
||||||
|
#define _WX_HTMPRINT_H_
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wx/defs.h>
|
||||||
|
|
||||||
|
#if wxUSE_PRINTING_ARCHITECTURE
|
||||||
|
|
||||||
|
#include "wx/html/htmlcell.h"
|
||||||
|
#include "wx/html/winpars.h"
|
||||||
|
|
||||||
|
#include "wx/print.h"
|
||||||
|
#include "wx/printdlg.h"
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlDCRenderer
|
||||||
|
// This class is capable of rendering HTML into specified
|
||||||
|
// portion of DC
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class wxHtmlDCRenderer : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxHtmlDCRenderer();
|
||||||
|
~wxHtmlDCRenderer();
|
||||||
|
|
||||||
|
// Following 3 methods *must* be called before any call to Render:
|
||||||
|
void SetDC(wxDC *dc, int maxwidth);
|
||||||
|
// asign DC to this render
|
||||||
|
// maxwidth is width of area (on this DC) that is equivalent to screen's width, in pixels
|
||||||
|
// (you should set it to page width minus margins)
|
||||||
|
// Also see SetSize
|
||||||
|
void SetSize(int width, int height);
|
||||||
|
// sets size of output rectangle, in pixels. Note that you *can't* change
|
||||||
|
// width of the rectangle between calls to Render! (You can freely change height.)
|
||||||
|
// If you set width = maxwidth then HTML is rendered as if it were displayed in fullscreen.
|
||||||
|
// If you set width = 1/2 maxwidth the it is rendered as if it covered half the screen
|
||||||
|
// and so on..
|
||||||
|
void SetHtmlText(const wxString& html, const wxString& basepath = wxEmptyString, bool isdir = TRUE);
|
||||||
|
// sets the text to be displayed
|
||||||
|
//
|
||||||
|
// basepath is base directory (html string would be stored there if it was in
|
||||||
|
// file). It is used to determine path for loading images, for example.
|
||||||
|
// isdir is FALSE if basepath is filename, TRUE if it is directory name
|
||||||
|
// (see wxFileSystem for detailed explanation)
|
||||||
|
|
||||||
|
int Render(int x, int y, int from = 0, int dont_render = FALSE);
|
||||||
|
// [x,y] is position of upper-left corner of printing rectangle (see SetSize)
|
||||||
|
// from is y-coordinate of the very first visible cell
|
||||||
|
// Returned value is y coordinate of first cell than didn't fit onto page.
|
||||||
|
// Use this value as 'from' in next call to Render in order to print multiple pages
|
||||||
|
// document
|
||||||
|
// If dont_render is TRUE then nothing is rendered into DC and it only counts
|
||||||
|
// pixels and return y coord of the next page
|
||||||
|
//
|
||||||
|
// CAUTION! Render() changes DC's user scale and does NOT restore it!
|
||||||
|
|
||||||
|
int GetTotalHeight();
|
||||||
|
// returns total height of the html document
|
||||||
|
// (compare Render's return value with this)
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
wxDC *m_DC;
|
||||||
|
wxHtmlWinParser *m_Parser;
|
||||||
|
wxFileSystem *m_FS;
|
||||||
|
wxHtmlContainerCell *m_Cells;
|
||||||
|
int m_MaxWidth, m_Width, m_Height;
|
||||||
|
double m_Scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
wxPAGE_ODD,
|
||||||
|
wxPAGE_EVEN,
|
||||||
|
wxPAGE_ALL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlPrintout
|
||||||
|
// This class is derived from standard wxWindows printout class
|
||||||
|
// and is used to print HTML documents.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
class wxHtmlPrintout : public wxPrintout
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxHtmlPrintout(const wxString& title = "Printout");
|
||||||
|
~wxHtmlPrintout();
|
||||||
|
|
||||||
|
void SetHtmlText(const wxString& html, const wxString &basepath = wxEmptyString, bool isdir = TRUE);
|
||||||
|
// prepares the class for printing this html document.
|
||||||
|
// Must be called before using the class, in fact just after constructor
|
||||||
|
//
|
||||||
|
// basepath is base directory (html string would be stored there if it was in
|
||||||
|
// file). It is used to determine path for loading images, for example.
|
||||||
|
// isdir is FALSE if basepath is filename, TRUE if it is directory name
|
||||||
|
// (see wxFileSystem for detailed explanation)
|
||||||
|
|
||||||
|
void SetHtmlFile(const wxString &htmlfile);
|
||||||
|
// same as SetHtmlText except that it takes regular file as the parameter
|
||||||
|
|
||||||
|
void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
|
||||||
|
void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
|
||||||
|
// sets header/footer for the document. The argument is interpreted as HTML document.
|
||||||
|
// You can use macros in it:
|
||||||
|
// @PAGENUM@ is replaced by page number
|
||||||
|
// @PAGESCNT@ is replaced by total number of pages
|
||||||
|
//
|
||||||
|
// pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants.
|
||||||
|
// You can set different header/footer for odd and even pages
|
||||||
|
|
||||||
|
void SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2,
|
||||||
|
float spaces = 5);
|
||||||
|
// sets margins in milimeters. Defaults to 1 inch for margins and 0.5cm for space
|
||||||
|
// between text and header and/or footer
|
||||||
|
|
||||||
|
// wxPrintout stuff:
|
||||||
|
bool OnPrintPage(int page);
|
||||||
|
bool HasPage(int page);
|
||||||
|
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
||||||
|
bool OnBeginDocument(int start, int end);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void RenderPage(wxDC *dc, int page);
|
||||||
|
// renders one page into dc
|
||||||
|
wxString TranslateHeader(const wxString& instr, int page);
|
||||||
|
// substitute @PAGENUM@ and @PAGESCNT@ by real values
|
||||||
|
void CountPages();
|
||||||
|
// counts pages and fills m_NumPages and m_PageBreaks
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_NumPages;
|
||||||
|
int m_PageBreaks[HTML_PRINT_MAX_PAGES];
|
||||||
|
|
||||||
|
wxString m_Document, m_BasePath;
|
||||||
|
bool m_BasePathIsDir;
|
||||||
|
wxString m_Headers[2], m_Footers[2];
|
||||||
|
|
||||||
|
int m_HeaderHeight, m_FooterHeight;
|
||||||
|
wxHtmlDCRenderer *m_Renderer, *m_RendererHdr;
|
||||||
|
float m_MarginTop, m_MarginBottom, m_MarginLeft, m_MarginRight, m_MarginSpace;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlEasyPrinting
|
||||||
|
// This class provides very simple interface to printing
|
||||||
|
// architecture. It allows you to print HTML documents only
|
||||||
|
// with very few commands.
|
||||||
|
//
|
||||||
|
// Note : do not create this class on stack only.
|
||||||
|
// You should create an instance on app startup and
|
||||||
|
// use this instance for all printing. Why? The class
|
||||||
|
// stores page&printer settings in it.
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxHtmlEasyPrinting : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
wxHtmlEasyPrinting(const wxString& name = "Printing", wxFrame *parent_frame = NULL);
|
||||||
|
~wxHtmlEasyPrinting();
|
||||||
|
|
||||||
|
void PreviewFile(const wxString &htmlfile);
|
||||||
|
void PreviewText(const wxString &htmltext, const wxString& basepath = wxEmptyString);
|
||||||
|
// Preview file / html-text for printing
|
||||||
|
// (and offers printing)
|
||||||
|
// basepath is base directory for opening subsequent files (e.g. from <img> tag)
|
||||||
|
|
||||||
|
void PrintFile(const wxString &htmlfile);
|
||||||
|
void PrintText(const wxString &htmltext, const wxString& basepath = wxEmptyString);
|
||||||
|
// Print file / html-text w/o preview
|
||||||
|
|
||||||
|
void PrinterSetup();
|
||||||
|
void PageSetup();
|
||||||
|
// pop up printer or page setup dialog
|
||||||
|
|
||||||
|
void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
|
||||||
|
void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
|
||||||
|
// sets header/footer for the document. The argument is interpreted as HTML document.
|
||||||
|
// You can use macros in it:
|
||||||
|
// @PAGENUM@ is replaced by page number
|
||||||
|
// @PAGESCNT@ is replaced by total number of pages
|
||||||
|
//
|
||||||
|
// pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants.
|
||||||
|
// You can set different header/footer for odd and even pages
|
||||||
|
|
||||||
|
wxPrintData *GetPrintData() {return m_PrintData;}
|
||||||
|
wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;}
|
||||||
|
// return page setting data objects.
|
||||||
|
// (You can set their parameters.)
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
wxHtmlPrintout *CreatePrintout();
|
||||||
|
void DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2);
|
||||||
|
void DoPrint(wxHtmlPrintout *printout);
|
||||||
|
|
||||||
|
wxPrintData *m_PrintData;
|
||||||
|
wxPageSetupDialogData *m_PageSetupData;
|
||||||
|
wxString m_Name;
|
||||||
|
wxString m_Headers[2], m_Footers[2];
|
||||||
|
wxFrame *m_Frame;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
||||||
|
|
||||||
|
#endif // _WX_HTMPRINT_H_
|
||||||
|
|
@@ -13,7 +13,7 @@ top_srcdir = @top_srcdir@
|
|||||||
top_builddir = ../../..
|
top_builddir = ../../..
|
||||||
program_dir = samples/html/printing
|
program_dir = samples/html/printing
|
||||||
|
|
||||||
DATAFILES = test.htm pic.png
|
DATAFILES = test.htm
|
||||||
|
|
||||||
PROGRAM=printing
|
PROGRAM=printing
|
||||||
|
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
/* XPM */
|
|
||||||
static char *mondrian_xpm[] = {
|
|
||||||
/* columns rows colors chars-per-pixel */
|
|
||||||
"32 32 6 1",
|
|
||||||
" c Black",
|
|
||||||
". c Blue",
|
|
||||||
"X c #00bf00",
|
|
||||||
"o c Red",
|
|
||||||
"O c Yellow",
|
|
||||||
"+ c Gray100",
|
|
||||||
/* pixels */
|
|
||||||
" ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" oooooo +++++++++++++++++++++++ ",
|
|
||||||
" ",
|
|
||||||
" ++++++ ++++++++++++++++++ .... ",
|
|
||||||
" ++++++ ++++++++++++++++++ .... ",
|
|
||||||
" ++++++ ++++++++++++++++++ .... ",
|
|
||||||
" ++++++ ++++++++++++++++++ .... ",
|
|
||||||
" ++++++ ++++++++++++++++++ .... ",
|
|
||||||
" ++++++ ++++++++++++++++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++++++++++++++++ ++++ ",
|
|
||||||
" ++++++ ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
|
||||||
" "
|
|
||||||
};
|
|
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
@@ -1,312 +1,244 @@
|
|||||||
/*
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
* File: printing.cc
|
// Name: printimg.cpp
|
||||||
* Purpose: Printing demo for wxWindows class library
|
// Purpose: wxHtmlEasyPrinting testing example
|
||||||
* Author: Julian Smart
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
* modified by Vaclav Slavik (wxHTML stuffs)
|
|
||||||
* Created: 1995
|
|
||||||
* Updated:
|
|
||||||
* Copyright: (c) 1995, AIAI, University of Edinburgh
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* static const char sccsid[] = "%W% %G%"; */
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma implementation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx/wx.h".
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include <wx/wxprec.h>
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// for all others, include the necessary headers (this file is usually all you
|
||||||
|
// need because it includes almost all "standard" wxWindows headers
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/wx.h"
|
#include <wx/wx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !wxUSE_PRINTING_ARCHITECTURE
|
#include <wx/image.h>
|
||||||
#error You must set wxUSE_PRINTING_ARCHITECTURE to 1 in setup.h to compile this demo.
|
#include <wx/html/htmlwin.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set this to 1 if you want to test PostScript printing under MSW.
|
#include <wx/html/htmprint.h>
|
||||||
// However, you'll also need to edit src/msw/makefile.nt.
|
|
||||||
|
|
||||||
//!!! DON'T DO THAT! This is wxHTML sample now
|
|
||||||
#define wxTEST_POSTSCRIPT_IN_MSW 0
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include "wx/metafile.h"
|
|
||||||
#include "wx/print.h"
|
|
||||||
#include "wx/printdlg.h"
|
|
||||||
|
|
||||||
#include "wx/accel.h"
|
|
||||||
|
|
||||||
#if wxTEST_POSTSCRIPT_IN_MSW
|
|
||||||
#include "wx/generic/printps.h"
|
|
||||||
#include "wx/generic/prntdlgg.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <wx/wxhtml.h>
|
|
||||||
#include <wx/wfstream.h>
|
|
||||||
#include "printing.h"
|
|
||||||
|
|
||||||
#ifndef __WXMSW__
|
|
||||||
#include "mondrian.xpm"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Global print data, to remember settings during the session
|
|
||||||
wxPrintData *g_printData = (wxPrintData*) NULL ;
|
|
||||||
|
|
||||||
// Global page setup data
|
|
||||||
wxPageSetupData* g_pageSetupData = (wxPageSetupData*) NULL;
|
|
||||||
|
|
||||||
|
|
||||||
// Declare a frame
|
// ----------------------------------------------------------------------------
|
||||||
MyFrame *frame = (MyFrame *) NULL;
|
// private classes
|
||||||
wxHtmlWindow *html = NULL;
|
// ----------------------------------------------------------------------------
|
||||||
int orientation = wxPORTRAIT;
|
|
||||||
|
|
||||||
// Main proc
|
// Define a new application type, each program should derive a class from wxApp
|
||||||
|
class MyApp : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// override base class virtuals
|
||||||
|
// ----------------------------
|
||||||
|
|
||||||
|
// this one is called on application startup and is a good place for the app
|
||||||
|
// initialization (doing it here and not in the ctor allows to have an error
|
||||||
|
// return: if OnInit() returns false, the application terminates)
|
||||||
|
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Define a new frame type: this is going to be our main frame
|
||||||
|
class MyFrame : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor(s)
|
||||||
|
|
||||||
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||||
|
|
||||||
|
// event handlers (these functions should _not_ be virtual)
|
||||||
|
void OnQuit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
|
void OnPrintSetup(wxCommandEvent& event);
|
||||||
|
void OnPageSetup(wxCommandEvent& event);
|
||||||
|
void OnPrint(wxCommandEvent& event);
|
||||||
|
void OnPreview(wxCommandEvent& event);
|
||||||
|
void OnOpen(wxCommandEvent& event);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxHtmlWindow *m_Html;
|
||||||
|
wxHtmlEasyPrinting *m_Prn;
|
||||||
|
wxString m_Name;
|
||||||
|
// any class wishing to process wxWindows events must use this macro
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// IDs for the controls and the menu commands
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// menu items
|
||||||
|
Minimal_Quit = 1,
|
||||||
|
Minimal_About,
|
||||||
|
Minimal_Print,
|
||||||
|
Minimal_Preview,
|
||||||
|
Minimal_PageSetup,
|
||||||
|
Minimal_PrintSetup,
|
||||||
|
Minimal_Open
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// event tables and other macros for wxWindows
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the event tables connect the wxWindows events with the functions (event
|
||||||
|
// handlers) which process them. It can be also done at run-time, but for the
|
||||||
|
// simple menu events like this the static method is much simpler.
|
||||||
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
EVT_MENU(Minimal_Print, MyFrame::OnPrint)
|
||||||
|
EVT_MENU(Minimal_Preview, MyFrame::OnPreview)
|
||||||
|
EVT_MENU(Minimal_PageSetup, MyFrame::OnPageSetup)
|
||||||
|
EVT_MENU(Minimal_PrintSetup, MyFrame::OnPrintSetup)
|
||||||
|
EVT_MENU(Minimal_Open, MyFrame::OnOpen)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
|
// the application object during program execution (it's better than using a
|
||||||
|
// static object for many reasons) and also declares the accessor function
|
||||||
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
|
// not wxApp)
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
MyApp::MyApp()
|
// ----------------------------------------------------------------------------
|
||||||
|
// the application class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// `Main program' equivalent: the program execution "starts" here
|
||||||
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
}
|
#if wxUSE_LIBPNG
|
||||||
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
#endif
|
||||||
|
#if wxUSE_LIBJPEG
|
||||||
|
wxImage::AddHandler(new wxJPEGHandler);
|
||||||
|
#endif
|
||||||
|
#if wxUSE_GIF
|
||||||
|
wxImage::AddHandler(new wxGIFHandler);
|
||||||
|
#endif
|
||||||
|
|
||||||
// The `main program' equivalent, creating the windows and returning the
|
MyFrame *frame = new MyFrame("Printing test",
|
||||||
// main frame
|
wxPoint(150, 50), wxSize(640, 480));
|
||||||
bool MyApp::OnInit(void)
|
|
||||||
{
|
|
||||||
g_printData = new wxPrintData;
|
|
||||||
g_pageSetupData = new wxPageSetupDialogData;
|
|
||||||
|
|
||||||
// Create the main frame window
|
// Show it and tell the application that it's our main window
|
||||||
frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows Printing Demo", wxPoint(0, 0), wxSize(600, 400));
|
// @@@ what does it do exactly, in fact? is it necessary here?
|
||||||
|
|
||||||
// Give it a status line
|
|
||||||
frame->CreateStatusBar(2);
|
|
||||||
|
|
||||||
// Load icon and bitmap
|
|
||||||
frame->SetIcon( wxICON( mondrian) );
|
|
||||||
|
|
||||||
// Make a menubar
|
|
||||||
wxMenu *file_menu = new wxMenu;
|
|
||||||
|
|
||||||
file_menu->Append(WXPRINT_PRINT, "&Print...", "Print");
|
|
||||||
file_menu->Append(WXPRINT_PRINT_SETUP, "Print &Setup...", "Setup printer properties");
|
|
||||||
file_menu->Append(WXPRINT_PAGE_SETUP, "Page Set&up...", "Page setup");
|
|
||||||
file_menu->Append(WXPRINT_PREVIEW, "Print Pre&view", "Preview");
|
|
||||||
|
|
||||||
// Accelerators
|
|
||||||
wxAcceleratorEntry entries[1];
|
|
||||||
entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
|
|
||||||
wxAcceleratorTable accel(1, entries);
|
|
||||||
frame->SetAcceleratorTable(accel);
|
|
||||||
|
|
||||||
file_menu->AppendSeparator();
|
|
||||||
file_menu->Append(WXPRINT_QUIT, "E&xit", "Exit program");
|
|
||||||
|
|
||||||
wxMenu *help_menu = new wxMenu;
|
|
||||||
help_menu->Append(WXPRINT_ABOUT, "&About", "About this demo");
|
|
||||||
|
|
||||||
wxMenuBar *menu_bar = new wxMenuBar;
|
|
||||||
|
|
||||||
menu_bar->Append(file_menu, "&File");
|
|
||||||
menu_bar->Append(help_menu, "&Help");
|
|
||||||
|
|
||||||
// Associate the menu bar with the frame
|
|
||||||
frame->SetMenuBar(menu_bar);
|
|
||||||
|
|
||||||
frame->Centre(wxBOTH);
|
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
|
|
||||||
frame->SetStatusText("Printing demo");
|
|
||||||
|
|
||||||
SetTopWindow(frame);
|
SetTopWindow(frame);
|
||||||
|
|
||||||
|
|
||||||
|
// success: wxApp::OnRun() will be called which will enter the main message
|
||||||
|
// loop and the application will run. If we returned FALSE here, the
|
||||||
|
// application would exit immediately.
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MyApp::OnExit()
|
// ----------------------------------------------------------------------------
|
||||||
|
// main frame
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// frame constructor
|
||||||
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||||
|
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
|
||||||
{
|
{
|
||||||
delete g_printData;
|
// create a menu bar
|
||||||
delete g_pageSetupData;
|
wxMenu *menuFile = new wxMenu;
|
||||||
return 1;
|
wxMenu *menuNav = new wxMenu;
|
||||||
|
|
||||||
|
menuFile->Append(Minimal_Open, "Open...\tCtrl-O");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(Minimal_PageSetup, "Page Setup");
|
||||||
|
menuFile->Append(Minimal_PrintSetup, "Printer Setup");
|
||||||
|
menuFile->Append(Minimal_Print, "Print...");
|
||||||
|
menuFile->Append(Minimal_Preview, "Preview...");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(Minimal_About, "&About");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(Minimal_Quit, "&Exit");
|
||||||
|
|
||||||
|
// now append the freshly created menu to the menu bar...
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
|
||||||
|
// ... and attach this menu bar to the frame
|
||||||
|
SetMenuBar(menuBar);
|
||||||
|
|
||||||
|
CreateStatusBar(1);
|
||||||
|
|
||||||
|
m_Html = new wxHtmlWindow(this);
|
||||||
|
m_Html -> SetRelatedFrame(this, "HTML : %s");
|
||||||
|
m_Html -> SetRelatedStatusBar(0);
|
||||||
|
m_Name = "test.htm";
|
||||||
|
m_Html -> LoadPage(m_Name);
|
||||||
|
|
||||||
|
m_Prn = new wxHtmlEasyPrinting("Easy Printing Demo", this);
|
||||||
|
m_Prn -> SetHeader(m_Name + "(@PAGENUM@/@PAGESCNT@)<hr>", wxPAGE_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
||||||
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
|
|
||||||
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
|
|
||||||
EVT_MENU(WXPRINT_PREVIEW, MyFrame::OnPrintPreview)
|
|
||||||
EVT_MENU(WXPRINT_PRINT_SETUP, MyFrame::OnPrintSetup)
|
|
||||||
EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
|
|
||||||
EVT_MENU(WXPRINT_ABOUT, MyFrame::OnPrintAbout)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
// Define my frame constructor
|
// event handlers
|
||||||
MyFrame::MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
|
|
||||||
wxFrame(frame, -1, title, pos, size)
|
|
||||||
{
|
|
||||||
html = new wxHtmlWindow(this);
|
|
||||||
html -> LoadPage("test.htm");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
|
delete m_Prn;
|
||||||
|
// TRUE is to force the frame to close
|
||||||
Close(TRUE);
|
Close(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPrinter printer;
|
wxMessageBox("HTML printing sample\n\n(c) Vaclav Slavik, 1999");
|
||||||
MyPrintout printout("My printout");
|
|
||||||
if (!printer.Print(this, &printout, TRUE))
|
|
||||||
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxPrintData printData;
|
|
||||||
printData.SetOrientation(orientation);
|
|
||||||
|
|
||||||
// Pass two printout objects: for preview, and possible printing.
|
|
||||||
wxPrintPreview *preview = new wxPrintPreview(new MyPrintout, new MyPrintout, & printData);
|
|
||||||
if (!preview->Ok())
|
|
||||||
{
|
|
||||||
delete preview;
|
|
||||||
wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Previewing", wxOK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxPreviewFrame *frame = new wxPreviewFrame(preview, this, "Demo Print Preview", wxPoint(100, 100), wxSize(600, 650));
|
|
||||||
frame->Centre(wxBOTH);
|
|
||||||
frame->Initialize();
|
|
||||||
frame->Show(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPrintDialogData printDialogData(* g_printData);
|
m_Prn -> PrinterSetup();
|
||||||
wxPrintDialog printerDialog(this, & printDialogData);
|
|
||||||
|
|
||||||
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
|
||||||
printerDialog.ShowModal();
|
|
||||||
|
|
||||||
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
(*g_pageSetupData) = * g_printData;
|
m_Prn -> PageSetup();
|
||||||
|
|
||||||
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
|
|
||||||
pageSetupDialog.ShowModal();
|
|
||||||
|
|
||||||
(*g_printData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
|
||||||
(*g_pageSetupData) = pageSetupDialog.GetPageSetupData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
|
||||||
void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
{
|
||||||
(void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\n\nModified by Vaclav Slavik to show wxHtml features",
|
m_Prn -> PrintFile(m_Name);
|
||||||
"About wxWindows printing demo", wxOK|wxCENTRE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MyPrintout::OnPrintPage(int page)
|
void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxDC *dc = GetDC();
|
m_Prn -> PreviewFile(m_Name);
|
||||||
if (dc)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxFileDialog dialog(this, "Open HTML page", "", "", "*.htm", 0);
|
||||||
|
|
||||||
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
if (page == 1)
|
m_Name = dialog.GetPath();
|
||||||
DrawPageOne(dc);
|
m_Html -> LoadPage(m_Name);
|
||||||
|
m_Prn -> SetHeader(m_Name + "(@PAGENUM@/@PAGESCNT@)<hr>", wxPAGE_ALL);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyPrintout::OnBeginDocument(int startPage, int endPage)
|
|
||||||
{
|
|
||||||
if (!wxPrintout::OnBeginDocument(startPage, endPage))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
|
|
||||||
{
|
|
||||||
*minPage = 1;
|
|
||||||
*maxPage = 1;
|
|
||||||
*selPageFrom = 1;
|
|
||||||
*selPageTo = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MyPrintout::HasPage(int pageNum)
|
|
||||||
{
|
|
||||||
return (pageNum == 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MyPrintout::DrawPageOne(wxDC *dc)
|
|
||||||
{
|
|
||||||
int leftMargin = 20;
|
|
||||||
int topMargin = 40;
|
|
||||||
|
|
||||||
/* You might use THIS code to set the printer DC to ROUGHLY reflect
|
|
||||||
* the screen text size. This page also draws lines of actual length 5cm
|
|
||||||
* on the page.
|
|
||||||
*/
|
|
||||||
// Get the logical pixels per inch of screen and printer
|
|
||||||
int ppiScreenX, ppiScreenY;
|
|
||||||
GetPPIScreen(&ppiScreenX, &ppiScreenY);
|
|
||||||
int ppiPrinterX, ppiPrinterY;
|
|
||||||
GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
|
|
||||||
|
|
||||||
// Here we obtain internal cell representation of HTML document:
|
|
||||||
wxHtmlContainerCell *cell = html -> GetInternalRepresentation();
|
|
||||||
|
|
||||||
// Now we have to check in case our real page size is reduced
|
|
||||||
// (e.g. because we're drawing to a print preview memory DC)
|
|
||||||
int pageWidth, pageHeight;
|
|
||||||
int w, h;
|
|
||||||
dc->GetSize(&w, &h);
|
|
||||||
GetPageSizePixels(&pageWidth, &pageHeight);
|
|
||||||
|
|
||||||
// Now we must scale it somehow. The best would be to suppose that html window
|
|
||||||
// width is equal to page width:
|
|
||||||
|
|
||||||
float scale = (float)((float)(pageWidth - 0 * leftMargin)/((float)cell -> GetMaxLineWidth() + 2 * leftMargin));
|
|
||||||
|
|
||||||
// If printer pageWidth == current DC width, then this doesn't
|
|
||||||
// change. But w might be the preview bitmap width, so scale down.
|
|
||||||
float overallScale = scale * (float)(w/(float)pageWidth);
|
|
||||||
dc->SetUserScale(overallScale, overallScale);
|
|
||||||
|
|
||||||
// Calculate conversion factor for converting millimetres into
|
|
||||||
// logical units.
|
|
||||||
// There are approx. 25.1 mm to the inch. There are ppi
|
|
||||||
// device units to the inch. Therefore 1 mm corresponds to
|
|
||||||
// ppi/25.1 device units. We also divide by the
|
|
||||||
// screen-to-printer scaling factor, because we need to
|
|
||||||
// unscale to pass logical units to DrawLine.
|
|
||||||
|
|
||||||
dc->SetBackgroundMode(wxTRANSPARENT);
|
|
||||||
|
|
||||||
// TESTING
|
|
||||||
|
|
||||||
int pageWidthMM, pageHeightMM;
|
|
||||||
GetPageSizeMM(&pageWidthMM, &pageHeightMM);
|
|
||||||
|
|
||||||
|
|
||||||
// This is all the printing :
|
|
||||||
cell -> Draw(*dc, leftMargin, topMargin, 0, cell -> GetHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* File: printing.h
|
|
||||||
* Purpose: Printing demo for wxWindows class library
|
|
||||||
* Author: Julian Smart
|
|
||||||
* Created: 1995
|
|
||||||
* Updated:
|
|
||||||
* Copyright: (c) 1995, AIAI, University of Edinburgh
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* sccsid[] = "%W% %G%" */
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
|
||||||
#pragma interface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Define a new application
|
|
||||||
class MyApp: public wxApp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyApp() ;
|
|
||||||
bool OnInit();
|
|
||||||
int OnExit();
|
|
||||||
};
|
|
||||||
|
|
||||||
DECLARE_APP(MyApp)
|
|
||||||
|
|
||||||
class MyCanvas;
|
|
||||||
|
|
||||||
// Define a new canvas and frame
|
|
||||||
class MyFrame: public wxFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
|
|
||||||
|
|
||||||
void OnPrint(wxCommandEvent& event);
|
|
||||||
void OnPrintPreview(wxCommandEvent& event);
|
|
||||||
void OnPrintSetup(wxCommandEvent& event);
|
|
||||||
void OnPageSetup(wxCommandEvent& event);
|
|
||||||
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
|
|
||||||
void OnPrintPS(wxCommandEvent& event);
|
|
||||||
void OnPrintPreviewPS(wxCommandEvent& event);
|
|
||||||
void OnPrintSetupPS(wxCommandEvent& event);
|
|
||||||
void OnPageSetupPS(wxCommandEvent& event);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void OnExit(wxCommandEvent& event);
|
|
||||||
void OnPrintAbout(wxCommandEvent& event);
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class MyPrintout: public wxPrintout
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
MyPrintout(char *title = "My printout"):wxPrintout(title) {}
|
|
||||||
bool OnPrintPage(int page);
|
|
||||||
bool HasPage(int page);
|
|
||||||
bool OnBeginDocument(int startPage, int endPage);
|
|
||||||
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
|
|
||||||
|
|
||||||
void DrawPageOne(wxDC *dc);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define WXPRINT_QUIT 100
|
|
||||||
#define WXPRINT_PRINT 101
|
|
||||||
#define WXPRINT_PRINT_SETUP 102
|
|
||||||
#define WXPRINT_PAGE_SETUP 103
|
|
||||||
#define WXPRINT_PREVIEW 104
|
|
||||||
|
|
||||||
#define WXPRINT_PRINT_PS 105
|
|
||||||
#define WXPRINT_PRINT_SETUP_PS 106
|
|
||||||
#define WXPRINT_PAGE_SETUP_PS 107
|
|
||||||
#define WXPRINT_PREVIEW_PS 108
|
|
||||||
|
|
||||||
#define WXPRINT_ABOUT 109
|
|
||||||
|
|
@@ -1,126 +1,186 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
<TITLE>wxWindows Roadmap</TITLE>
|
||||||
<META NAME="GENERATOR" CONTENT="Mozilla/4.06 [en] (X11; I; Linux 2.0.35 i686) [Netscape]">
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#FF0000" ALINK="#000088">
|
|
||||||
This is - - default text, now switching to
|
<BODY>
|
||||||
|
|
||||||
|
<a name="top"></a>
|
||||||
|
|
||||||
|
<font face="Arial, Lucida Sans, Helvetica">
|
||||||
|
|
||||||
|
<table width=100% border=4 cellpadding=5 cellspacing=0>
|
||||||
|
<tr>
|
||||||
|
<td bgcolor="#660000">
|
||||||
|
<font size=+1 face="Arial, Lucida Sans, Helvetica" color="#FFFFFF">
|
||||||
|
wxWindows Roadmap
|
||||||
|
</font>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
<CENTER>
|
<CENTER>
|
||||||
<P>center, now still ctr, now exiting</CENTER>
|
<a href="#schedule">Schedule</a> | <a href="#todo">To-Do List</a>
|
||||||
|
</CENTER>
|
||||||
|
|
||||||
<P>exited!.<A HREF="#downtown">[link to down]</A>
|
<P>
|
||||||
<P>Hello, this *is* default charset (helvetica, probably) and it is displayed
|
|
||||||
with one <FONT COLOR="#FF0000">COLOR CHANGE</FONT>. Of course we
|
|
||||||
can have as many color changes as we can, what about this <FONT COLOR="#FF0000">M</FONT><FONT COLOR="#FFFF00">A</FONT><FONT COLOR="#33FF33">D</FONT><B><FONT COLOR="#FFFFFF"><FONT SIZE=+1>N</FONT></FONT></B>E<FONT COLOR="#999999">S</FONT><FONT COLOR="#CC33CC">S?</FONT>
|
|
||||||
<P><FONT COLOR="#000000">There was a space above.</FONT>
|
|
||||||
<BR>
|
|
||||||
<HR WIDTH="100%">This was a line. <TT>(BTW we are in <B>fixed</B> font
|
|
||||||
/ <I><U>typewriter</U> font</I> right now :-)</TT>
|
|
||||||
<BR>This is in <B>BOLD</B> face. This is <I>ITALIC.</I> This is <B><I><U>E
|
|
||||||
V E R Y T H I N G</U></I></B>.
|
|
||||||
<BR>
|
|
||||||
<BR>
|
|
||||||
<BR>
|
|
||||||
<BR>
|
|
||||||
<BR>
|
|
||||||
<CENTER>
|
|
||||||
<P>Right now, <FONT COLOR="#0000FF"><FONT SIZE=+4>centered REALLY Big Text</FONT></FONT>,
|
|
||||||
how do you like (space) it?</CENTER>
|
|
||||||
|
|
||||||
<DIV ALIGN=right>RIGHT: <FONT SIZE=-2>text-2, </FONT><FONT SIZE=-1>text-1,
|
This page represents current thinking about where wxWindows is going in the near,
|
||||||
</FONT>text+0,
|
medium and long-term. It also serves as a schedule for new releases so
|
||||||
<FONT SIZE=+1>text+1,
|
that both developers and users can know what to expect when, at least approximately.<P>
|
||||||
</FONT><FONT COLOR="#FF0000"><FONT SIZE=+2>text+2,
|
|
||||||
</FONT></FONT><FONT SIZE=+3>text+3,
|
|
||||||
</FONT><FONT SIZE=+4>text+4</FONT>
|
|
||||||
<BR><U><FONT SIZE=+1>we are right now</FONT></U></DIV>
|
|
||||||
|
|
||||||
<CENTER><U><FONT SIZE=+1>we are center now</FONT></U></CENTER>
|
Note (1): as the wxWindows effort is voluntary, these are not hard-and-fast deadlines:
|
||||||
<U><FONT SIZE=+1>we are left now.</FONT></U>
|
but we will endeavour to follow them as closely as possible.<P>
|
||||||
<P><I><FONT COLOR="#3366FF">Blue italic text is displayed there....</FONT></I>
|
|
||||||
<H1>
|
|
||||||
|
|
||||||
<HR ALIGN=LEFT SIZE=10 WIDTH="50%">This is heading one.</H1>
|
Note (2): the releases described are for wxGTK, wxMSW and wxMotif ports. wxMac currently follows
|
||||||
this is normal
|
its own development path. Also, minor snapshot releases for specific platforms may be
|
||||||
<CENTER>
|
available at dates convenient to the developers.<P>
|
||||||
<H1>
|
|
||||||
This is <FONT COLOR="#33FF33">CENTERED</FONT> heading one</H1></CENTER>
|
|
||||||
<IMG SRC="pic.png" ALT="Testing image image" >and this is text......
|
|
||||||
<BR>
|
|
||||||
<UL>
|
|
||||||
<LI>
|
|
||||||
item 1</LI>
|
|
||||||
|
|
||||||
<LI>
|
<HR> <FONT SIZE=+2><I><B><a name="schedule">Schedule</a></B></I></FONT> <HR>
|
||||||
item 2</LI>
|
<P>
|
||||||
|
|
||||||
<UL>
|
<H4>Release 2.1.10</H4>
|
||||||
<LI>
|
|
||||||
nested item</LI>
|
|
||||||
|
|
||||||
<LI>
|
<ul>
|
||||||
nested item 2</LI>
|
<li>Release date: October 3rd, 1999
|
||||||
</UL>
|
<li>This beta is intended to be the last stable snapshot before wxWindows
|
||||||
|
is split into base and GUI libraries.
|
||||||
|
<li>New wxGrid in beta.
|
||||||
|
</ul>
|
||||||
|
|
||||||
<LI>
|
<P>
|
||||||
item 3</LI>
|
|
||||||
</UL>
|
|
||||||
|
|
||||||
<OL>
|
<H2>Release 2.1.11 (final)</H2>
|
||||||
<LI>
|
|
||||||
item one</LI>
|
|
||||||
|
|
||||||
<LI>
|
<ul>
|
||||||
item two</LI>
|
<li>Release date: November 7th, 1999
|
||||||
|
<li>Splits wxWindows into base and GUI libraries. Most, but not all makefiles
|
||||||
|
are expected to support this: for the rest, the makefiles will build a valid
|
||||||
|
combined base/GUI library for GUI applications only.
|
||||||
|
<li>New wxGrid.
|
||||||
|
<li>wxSocket working.
|
||||||
|
<li>wxHTML printing (possibly).
|
||||||
|
<li>Animation classes (possibly).
|
||||||
|
<li>PCX writing capability (possibly).
|
||||||
|
<li>wxImage handlers in separate .h and .cpp files.
|
||||||
|
<li>Rewritten timer.cpp, possible wxChrono class.
|
||||||
|
<li>Bug tracking system in place.
|
||||||
|
</ul>
|
||||||
|
|
||||||
<OL>
|
<P>
|
||||||
<LI>
|
|
||||||
nsted item</LI>
|
|
||||||
</OL>
|
|
||||||
|
|
||||||
<LI>
|
<H4>Release 2.1.12</H4>
|
||||||
last numbered item</LI>
|
|
||||||
</OL>
|
|
||||||
|
|
||||||
<H1>
|
<ul>
|
||||||
Heading 1</H1>
|
<li>Release date: January 9th, 2000
|
||||||
<I>Italic text now...</I>
|
<li>Miscellaneous fixes and small enhancements.
|
||||||
<H2>
|
</ul>
|
||||||
<I>Heading 2</I></H2>
|
|
||||||
<I>and now?</I>
|
|
||||||
<H3>
|
|
||||||
Heading 3</H3>
|
|
||||||
|
|
||||||
<H4>
|
<P>
|
||||||
Heading 4</H4>
|
|
||||||
|
|
||||||
<H5>
|
<H4>Release 2.1.13</H4>
|
||||||
Heading 5</H5>
|
|
||||||
|
|
||||||
<H6>
|
<ul>
|
||||||
Heading 6</H6>
|
<li>Release date: March 5th, 2000
|
||||||
And this is normal text, once again :-)
|
<li>Miscellaneous fixes and small enhancements.
|
||||||
<P>And yes, we're in <FONT SIZE=+4>HTML DOCUMENT, </FONT><FONT SIZE=+1>so
|
<li>wxDateTime class in beta.
|
||||||
what about some nice <A HREF="fft.html">hypertext link</A>??</FONT>
|
</ul>
|
||||||
<P>hello?
|
|
||||||
<CENTER>
|
|
||||||
<P>This is <A NAME="downtown"></A>centered paragraph</CENTER>
|
|
||||||
|
|
||||||
<P>Now, you will see some PRE text:
|
<P>
|
||||||
<PRE>// This is sample C++ code:
|
|
||||||
|
<H4>Release 2.2.0</H4>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Release date: May 7th, 2000
|
||||||
|
<li>Unicode compilation starting to work in wxGTK and wxMSW.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<H2>Release 2.2.x (final)</H2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Release date: c. July 2nd, 2000
|
||||||
|
<li>Unicode compilation working in wxGTK and wxMSW.
|
||||||
|
<li>wxDateTime class.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<H2>Release 2.3.x (final)</H2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Release date: unknown
|
||||||
|
<li>WinCE port available.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<HR> <FONT SIZE=+2><I><B><a name="todo">To-Do List</a></B></I></FONT> <HR>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
Developers: please feel free to add to these, and delete them when they are done.
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<B><I>General</I></B><P>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>wxHTML printing. When finished, this will allow an application to generate
|
||||||
|
printed reports with very little effort.
|
||||||
|
<li>wxSocket.
|
||||||
|
<li>Split library into several, for base (classes and functions usable by console and GUI
|
||||||
|
applications), console (classes and functions usable by console application only)
|
||||||
|
and GUI (classes and functions usable by GUI application only).
|
||||||
|
<li>Extend and unify drag and drop handling (e.g. we need to specify multiple drop targets
|
||||||
|
that can handle multiple formats).
|
||||||
|
<li>Expand the number of controls that can be specified in a WXR file.
|
||||||
|
<li>Rewrite Dialog Editor.
|
||||||
|
<li>PCX writing code.
|
||||||
|
<li>GIF animation code.
|
||||||
|
<li>Tidying of timer code, addition of wxChrono class.
|
||||||
|
<li>wxDateTime class.
|
||||||
|
<li>MGL port (see Backroom/Future Ports page).
|
||||||
|
<li>Rotated text support.
|
||||||
|
<li>FreeType support.
|
||||||
|
<li>Support for 'skins', perhaps using a set of alternative control and window classes
|
||||||
|
written generically in wxWindows.
|
||||||
|
<li>Book, tutorial.
|
||||||
|
<li>More examples.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<B><I>wxMSW</I></B><P>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Windows CE port.
|
||||||
|
<li>Cure bug whereby in a panel within another panel, all buttons become
|
||||||
|
default buttons (heavy black border).
|
||||||
|
<li>Write a RC->WXR converter.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<B><I>wxGTK</I></B><P>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>GNOME/KDE integration libraries.
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
|
||||||
|
<B><I>wxMotif</I></B><P>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Allow wxSystemSettings to be configurable, perhaps via a control
|
||||||
|
panel application.
|
||||||
|
</ul>
|
||||||
|
|
||||||
void main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
printf("Go away, man!\n");
|
|
||||||
i = 666;
|
|
||||||
printf("\n\n\nCRASH\n DOWN NOW. . . \n");
|
|
||||||
}</PRE>
|
|
||||||
|
|
||||||
<H3>
|
|
||||||
WWW</H3>
|
|
||||||
<A HREF="http://www.kde.org">This is WWW link to KDE site!</A>
|
|
||||||
<BR><A HREF="http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/index.html">(one
|
|
||||||
folder up)</A>
|
|
||||||
</BODY>
|
</BODY>
|
||||||
</HTML>
|
</HTML>
|
||||||
|
|
||||||
|
570
src/html/htmprint.cpp
Normal file
570
src/html/htmprint.cpp
Normal file
@@ -0,0 +1,570 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: htmprint.cpp
|
||||||
|
// Purpose: html printing classes
|
||||||
|
// Author: Vaclav Slavik
|
||||||
|
// Created: 25/09/99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) Vaclav Slavik, 1999
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_PRINTING_ARCHITECTURE
|
||||||
|
|
||||||
|
#include "wx/print.h"
|
||||||
|
#include "wx/printdlg.h"
|
||||||
|
#include "wx/html/htmprint.h"
|
||||||
|
#include "wx/wxhtml.h"
|
||||||
|
#include "wx/wfstream.h"
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlDCRenderer
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlDCRenderer::wxHtmlDCRenderer() : wxObject()
|
||||||
|
{
|
||||||
|
m_DC = NULL;
|
||||||
|
m_Width = m_Height = 0;
|
||||||
|
m_Cells = NULL;
|
||||||
|
m_Parser = new wxHtmlWinParser(NULL);
|
||||||
|
m_FS = new wxFileSystem();
|
||||||
|
m_Parser -> SetFS(m_FS);
|
||||||
|
m_Scale = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlDCRenderer::~wxHtmlDCRenderer()
|
||||||
|
{
|
||||||
|
if (m_Cells) delete m_Cells;
|
||||||
|
if (m_Parser) delete m_Parser;
|
||||||
|
if (m_FS) delete m_FS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlDCRenderer::SetDC(wxDC *dc, int maxwidth)
|
||||||
|
{
|
||||||
|
int dx, dy;
|
||||||
|
|
||||||
|
wxDisplaySize(&dx, &dy);
|
||||||
|
m_MaxWidth = maxwidth;
|
||||||
|
#if 0
|
||||||
|
m_Scale = (float)dx * 2 / 3 / (float)maxwidth;
|
||||||
|
// let the width of A4 is approximately 2/3 the screen width
|
||||||
|
#endif
|
||||||
|
m_Scale = (float)800 / (float)maxwidth;
|
||||||
|
// for now, assume screen width = 800 => good results
|
||||||
|
|
||||||
|
m_DC = dc;
|
||||||
|
m_Parser -> SetDC(dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlDCRenderer::SetSize(int width, int height)
|
||||||
|
{
|
||||||
|
m_Width = (int)(width * m_Scale);
|
||||||
|
m_Height = (int)(height * m_Scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepath, bool isdir)
|
||||||
|
{
|
||||||
|
if (m_DC == NULL) return;
|
||||||
|
|
||||||
|
if (m_Cells != NULL) delete m_Cells;
|
||||||
|
|
||||||
|
m_FS -> ChangePathTo(basepath, isdir);
|
||||||
|
m_DC -> SetUserScale(1.0, 1.0);
|
||||||
|
m_Cells = (wxHtmlContainerCell*) m_Parser -> Parse(html);
|
||||||
|
m_Cells -> SetIndent(0, HTML_INDENT_ALL, HTML_UNITS_PIXELS);
|
||||||
|
m_Cells -> Layout(m_Width);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render)
|
||||||
|
{
|
||||||
|
int pbreak;
|
||||||
|
|
||||||
|
if (m_Cells == NULL || m_DC == NULL) return 0;
|
||||||
|
|
||||||
|
pbreak = (int)(from * m_Scale + m_Height);
|
||||||
|
while (m_Cells -> AdjustPagebreak(&pbreak)) {}
|
||||||
|
|
||||||
|
if (!dont_render) {
|
||||||
|
int w, h;
|
||||||
|
m_DC -> GetSize(&w, &h);
|
||||||
|
float overallScale = (float)(w/(float)m_MaxWidth) / m_Scale;
|
||||||
|
m_DC -> SetUserScale(overallScale, overallScale);
|
||||||
|
|
||||||
|
m_DC -> SetBrush(*wxWHITE_BRUSH);
|
||||||
|
|
||||||
|
m_DC -> SetClippingRegion(x * m_Scale, y * m_Scale, m_Width, m_Height);
|
||||||
|
m_Cells -> Draw(*m_DC,
|
||||||
|
x * m_Scale, (y - from) * m_Scale,
|
||||||
|
y * m_Scale, pbreak + (y - from) * m_Scale);
|
||||||
|
m_DC -> DestroyClippingRegion();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pbreak < m_Cells -> GetHeight()) return (int)(pbreak / m_Scale);
|
||||||
|
else return GetTotalHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int wxHtmlDCRenderer::GetTotalHeight()
|
||||||
|
{
|
||||||
|
if (m_Cells) return (int)(m_Cells -> GetHeight() / m_Scale);
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlPrintout
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlPrintout::wxHtmlPrintout(const wxString& title) : wxPrintout(title)
|
||||||
|
{
|
||||||
|
m_Renderer = new wxHtmlDCRenderer;
|
||||||
|
m_RendererHdr = new wxHtmlDCRenderer;
|
||||||
|
m_NumPages = HTML_PRINT_MAX_PAGES;
|
||||||
|
m_Document = m_BasePath = wxEmptyString; m_BasePathIsDir = TRUE;
|
||||||
|
m_Headers[0] = m_Headers[1] = wxEmptyString;
|
||||||
|
m_Footers[0] = m_Footers[1] = wxEmptyString;
|
||||||
|
m_HeaderHeight = m_FooterHeight = 0;
|
||||||
|
SetMargins(); // to default values
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlPrintout::~wxHtmlPrintout()
|
||||||
|
{
|
||||||
|
delete m_Renderer;
|
||||||
|
delete m_RendererHdr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlPrintout::OnBeginDocument(int start, int end)
|
||||||
|
{
|
||||||
|
int pageWidth, pageHeight, mm_w, mm_h;
|
||||||
|
float ppmm_h, ppmm_v;
|
||||||
|
|
||||||
|
if (!wxPrintout::OnBeginDocument(start, end)) return FALSE;
|
||||||
|
|
||||||
|
GetPageSizePixels(&pageWidth, &pageHeight);
|
||||||
|
GetPageSizeMM(&mm_w, &mm_h);
|
||||||
|
ppmm_h = (float)pageWidth / mm_w;
|
||||||
|
ppmm_v = (float)pageHeight / mm_h;
|
||||||
|
|
||||||
|
/* prepare headers/footers renderer: */
|
||||||
|
|
||||||
|
m_RendererHdr -> SetDC(GetDC(), pageWidth);
|
||||||
|
m_RendererHdr -> SetSize(ppmm_h * (mm_w - m_MarginLeft - m_MarginTop),
|
||||||
|
ppmm_v * (mm_h - m_MarginTop - m_MarginBottom));
|
||||||
|
if (m_Headers[0] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Headers[0], 1));
|
||||||
|
m_HeaderHeight = m_RendererHdr -> GetTotalHeight();
|
||||||
|
}
|
||||||
|
else if (m_Headers[1] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Headers[1], 1));
|
||||||
|
m_HeaderHeight = m_RendererHdr -> GetTotalHeight();
|
||||||
|
}
|
||||||
|
if (m_Footers[0] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Footers[0], 1));
|
||||||
|
m_FooterHeight = m_RendererHdr -> GetTotalHeight();
|
||||||
|
}
|
||||||
|
else if (m_Footers[1] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Footers[1], 1));
|
||||||
|
m_FooterHeight = m_RendererHdr -> GetTotalHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prepare main renderer: */
|
||||||
|
m_Renderer -> SetDC(GetDC(), pageWidth);
|
||||||
|
m_Renderer -> SetSize(ppmm_h * (mm_w - m_MarginLeft - m_MarginTop),
|
||||||
|
ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) -
|
||||||
|
m_FooterHeight - m_HeaderHeight -
|
||||||
|
((m_HeaderHeight == 0) ? 0 : m_MarginSpace * ppmm_v) -
|
||||||
|
((m_FooterHeight == 0) ? 0 : m_MarginSpace * ppmm_v)
|
||||||
|
);
|
||||||
|
m_Renderer -> SetHtmlText(m_Document, m_BasePath, m_BasePathIsDir);
|
||||||
|
CountPages();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlPrintout::OnPrintPage(int page)
|
||||||
|
{
|
||||||
|
wxDC *dc = GetDC();
|
||||||
|
if (dc) {
|
||||||
|
if (HasPage(page))
|
||||||
|
RenderPage(dc, page);
|
||||||
|
return TRUE;
|
||||||
|
} else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
|
||||||
|
{
|
||||||
|
*minPage = 1;
|
||||||
|
*maxPage = HTML_PRINT_MAX_PAGES;
|
||||||
|
*selPageFrom = 1;
|
||||||
|
*selPageTo = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool wxHtmlPrintout::HasPage(int pageNum)
|
||||||
|
{
|
||||||
|
return (pageNum >= 1 && pageNum <= m_NumPages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::SetHtmlText(const wxString& html, const wxString &basepath, bool isdir)
|
||||||
|
{
|
||||||
|
m_Document = html;
|
||||||
|
m_BasePath = basepath;
|
||||||
|
m_BasePathIsDir = isdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::SetHtmlFile(const wxString& htmlfile)
|
||||||
|
{
|
||||||
|
wxFileSystem fs;
|
||||||
|
wxFSFile *ff = fs.OpenFile(htmlfile);
|
||||||
|
wxInputStream *st = ff -> GetStream();
|
||||||
|
char *t = new char[st -> GetSize() + 1];
|
||||||
|
st -> Read(t, st -> GetSize());
|
||||||
|
t[st -> GetSize()] = 0;
|
||||||
|
|
||||||
|
wxString doc = wxString(t);
|
||||||
|
delete t;
|
||||||
|
delete ff;
|
||||||
|
|
||||||
|
SetHtmlText(doc, htmlfile, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::SetHeader(const wxString& header, int pg)
|
||||||
|
{
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
|
||||||
|
m_Headers[0] = header;
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
|
||||||
|
m_Headers[1] = header;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::SetFooter(const wxString& footer, int pg)
|
||||||
|
{
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
|
||||||
|
m_Footers[0] = footer;
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
|
||||||
|
m_Footers[1] = footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::CountPages()
|
||||||
|
{
|
||||||
|
wxBusyCursor wait;
|
||||||
|
int pageWidth, pageHeight, mm_w, mm_h;
|
||||||
|
float ppmm_h, ppmm_v;
|
||||||
|
|
||||||
|
GetPageSizePixels(&pageWidth, &pageHeight);
|
||||||
|
GetPageSizeMM(&mm_w, &mm_h);
|
||||||
|
ppmm_h = (float)pageWidth / mm_w;
|
||||||
|
ppmm_v = (float)pageHeight / mm_h;
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
|
|
||||||
|
m_NumPages = 0;
|
||||||
|
|
||||||
|
m_PageBreaks[0] = 0;
|
||||||
|
do {
|
||||||
|
pos = m_Renderer -> Render(ppmm_h * m_MarginLeft,
|
||||||
|
ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight,
|
||||||
|
pos, TRUE);
|
||||||
|
m_PageBreaks[++m_NumPages] = pos;
|
||||||
|
} while (pos < m_Renderer -> GetTotalHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::RenderPage(wxDC *dc, int page)
|
||||||
|
{
|
||||||
|
wxBusyCursor wait;
|
||||||
|
|
||||||
|
int pageWidth, pageHeight, mm_w, mm_h;
|
||||||
|
float ppmm_h, ppmm_v;
|
||||||
|
|
||||||
|
GetPageSizePixels(&pageWidth, &pageHeight);
|
||||||
|
GetPageSizeMM(&mm_w, &mm_h);
|
||||||
|
ppmm_h = (float)pageWidth / mm_w;
|
||||||
|
ppmm_v = (float)pageHeight / mm_h;
|
||||||
|
|
||||||
|
m_Renderer -> SetDC(dc, pageWidth);
|
||||||
|
|
||||||
|
dc -> SetBackgroundMode(wxTRANSPARENT);
|
||||||
|
|
||||||
|
m_Renderer -> Render(ppmm_h * m_MarginLeft,
|
||||||
|
ppmm_v * (m_MarginTop + (m_HeaderHeight == 0 ? 0 : m_MarginSpace)) + m_HeaderHeight,
|
||||||
|
m_PageBreaks[page-1]);
|
||||||
|
|
||||||
|
m_RendererHdr -> SetDC(dc, pageWidth);
|
||||||
|
if (m_Headers[page % 2] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Headers[page % 2], page));
|
||||||
|
m_RendererHdr -> Render(ppmm_h * m_MarginLeft, ppmm_v * m_MarginTop);
|
||||||
|
}
|
||||||
|
if (m_Footers[page % 2] != wxEmptyString) {
|
||||||
|
m_RendererHdr -> SetHtmlText(TranslateHeader(m_Footers[page % 2], page));
|
||||||
|
m_RendererHdr -> Render(ppmm_h * m_MarginLeft, pageHeight - ppmm_v * m_MarginBottom - m_FooterHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxString wxHtmlPrintout::TranslateHeader(const wxString& instr, int page)
|
||||||
|
{
|
||||||
|
wxString r = instr;
|
||||||
|
wxString num;
|
||||||
|
|
||||||
|
num.Printf("%i", page);
|
||||||
|
r.Replace("@PAGENUM@", num);
|
||||||
|
|
||||||
|
num.Printf("%i", m_NumPages);
|
||||||
|
r.Replace("@PAGESCNT@", num);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlPrintout::SetMargins(float top, float bottom, float left, float right, float spaces)
|
||||||
|
{
|
||||||
|
m_MarginTop = top;
|
||||||
|
m_MarginBottom = bottom;
|
||||||
|
m_MarginLeft = left;
|
||||||
|
m_MarginRight = right;
|
||||||
|
m_MarginSpace = spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// wxHtmlEasyPrinting
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxFrame *parent_frame)
|
||||||
|
{
|
||||||
|
m_Frame = parent_frame;
|
||||||
|
m_Name = name;
|
||||||
|
m_PrintData = new wxPrintData;
|
||||||
|
m_PageSetupData = new wxPageSetupDialogData;
|
||||||
|
m_Headers[0] = m_Headers[1] = m_Footers[0] = m_Footers[1] = wxEmptyString;
|
||||||
|
|
||||||
|
m_PageSetupData -> EnableMargins(TRUE);
|
||||||
|
m_PageSetupData -> SetMarginTopLeft(wxPoint(25, 25));
|
||||||
|
m_PageSetupData -> SetMarginBottomRight(wxPoint(25, 25));
|
||||||
|
|
||||||
|
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||||
|
m_PrintData -> SetPrinterCommand("lpr");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlEasyPrinting::~wxHtmlEasyPrinting()
|
||||||
|
{
|
||||||
|
delete m_PrintData;
|
||||||
|
delete m_PageSetupData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PreviewFile(const wxString &htmlfile)
|
||||||
|
{
|
||||||
|
wxHtmlPrintout *p1 = CreatePrintout();
|
||||||
|
p1 -> SetHtmlFile(htmlfile);
|
||||||
|
wxHtmlPrintout *p2 = CreatePrintout();
|
||||||
|
p2 -> SetHtmlFile(htmlfile);
|
||||||
|
DoPreview(p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PreviewText(const wxString &htmltext, const wxString &basepath)
|
||||||
|
{
|
||||||
|
wxHtmlPrintout *p1 = CreatePrintout();
|
||||||
|
p1 -> SetHtmlText(htmltext, basepath, TRUE);
|
||||||
|
wxHtmlPrintout *p2 = CreatePrintout();
|
||||||
|
p2 -> SetHtmlText(htmltext, basepath, TRUE);
|
||||||
|
DoPreview(p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PrintFile(const wxString &htmlfile)
|
||||||
|
{
|
||||||
|
wxHtmlPrintout *p = CreatePrintout();
|
||||||
|
p -> SetHtmlFile(htmlfile);
|
||||||
|
DoPrint(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PrintText(const wxString &htmltext, const wxString &basepath)
|
||||||
|
{
|
||||||
|
wxHtmlPrintout *p = CreatePrintout();
|
||||||
|
p -> SetHtmlText(htmltext, basepath, TRUE);
|
||||||
|
DoPrint(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2)
|
||||||
|
{
|
||||||
|
// Pass two printout objects: for preview, and possible printing.
|
||||||
|
wxPrintDialogData printDialogData(*m_PrintData);
|
||||||
|
wxPrintPreview *preview = new wxPrintPreview(printout1, printout2, &printDialogData);
|
||||||
|
if (!preview -> Ok()) {
|
||||||
|
delete preview;
|
||||||
|
wxMessageBox(_("There was a problem previewing.\nPerhaps your current printer is not set correctly?"), _("Previewing"), wxOK);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
wxPreviewFrame *frame = new wxPreviewFrame(preview, m_Frame,
|
||||||
|
m_Name + _(" Preview"),
|
||||||
|
wxPoint(100, 100), wxSize(500, 500));
|
||||||
|
frame -> Centre(wxBOTH);
|
||||||
|
frame -> Initialize();
|
||||||
|
frame -> Show(TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout)
|
||||||
|
{
|
||||||
|
wxPrintDialogData printDialogData(*m_PrintData);
|
||||||
|
wxPrinter printer(&printDialogData);
|
||||||
|
|
||||||
|
if (!printer.Print(m_Frame, printout, TRUE))
|
||||||
|
wxMessageBox(_("There was a problem printing.\nPerhaps your current printer is not set correctly?"), _("Printing"), wxOK);
|
||||||
|
else
|
||||||
|
(*m_PrintData) = printer.GetPrintDialogData().GetPrintData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PrinterSetup()
|
||||||
|
{
|
||||||
|
wxPrintDialogData printDialogData(*m_PrintData);
|
||||||
|
wxPrintDialog printerDialog(m_Frame, &printDialogData);
|
||||||
|
|
||||||
|
printerDialog.GetPrintDialogData().SetSetupDialog(TRUE);
|
||||||
|
|
||||||
|
if (printerDialog.ShowModal() == wxID_OK)
|
||||||
|
(*m_PrintData) = printerDialog.GetPrintDialogData().GetPrintData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::PageSetup()
|
||||||
|
{
|
||||||
|
m_PageSetupData -> SetPrintData(*m_PrintData);
|
||||||
|
wxPageSetupDialog pageSetupDialog(m_Frame, m_PageSetupData);
|
||||||
|
|
||||||
|
if (pageSetupDialog.ShowModal() == wxID_OK) {
|
||||||
|
(*m_PrintData) = pageSetupDialog.GetPageSetupData().GetPrintData();
|
||||||
|
(*m_PageSetupData) = pageSetupDialog.GetPageSetupData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::SetHeader(const wxString& header, int pg)
|
||||||
|
{
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
|
||||||
|
m_Headers[0] = header;
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
|
||||||
|
m_Headers[1] = header;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void wxHtmlEasyPrinting::SetFooter(const wxString& footer, int pg)
|
||||||
|
{
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_EVEN)
|
||||||
|
m_Footers[0] = footer;
|
||||||
|
if (pg == wxPAGE_ALL || pg == wxPAGE_ODD)
|
||||||
|
m_Footers[1] = footer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
wxHtmlPrintout *wxHtmlEasyPrinting::CreatePrintout()
|
||||||
|
{
|
||||||
|
wxHtmlPrintout *p = new wxHtmlPrintout(m_Name);
|
||||||
|
|
||||||
|
p -> SetHeader(m_Headers[0], wxPAGE_EVEN);
|
||||||
|
p -> SetHeader(m_Headers[1], wxPAGE_ODD);
|
||||||
|
p -> SetFooter(m_Footers[0], wxPAGE_EVEN);
|
||||||
|
p -> SetFooter(m_Footers[1], wxPAGE_ODD);
|
||||||
|
|
||||||
|
p -> SetMargins(m_PageSetupData -> GetMarginTopLeft().y,
|
||||||
|
m_PageSetupData -> GetMarginBottomRight().y,
|
||||||
|
m_PageSetupData -> GetMarginTopLeft().x,
|
||||||
|
m_PageSetupData -> GetMarginBottomRight().x);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // wxUSE_PRINTING_ARCHITECTURE
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -156,6 +156,7 @@ HTMLOBJS = \
|
|||||||
$(HTMLDIR)/htmlpars.$(OBJSUFF) \
|
$(HTMLDIR)/htmlpars.$(OBJSUFF) \
|
||||||
$(HTMLDIR)/htmltag.$(OBJSUFF) \
|
$(HTMLDIR)/htmltag.$(OBJSUFF) \
|
||||||
$(HTMLDIR)/htmlwin.$(OBJSUFF) \
|
$(HTMLDIR)/htmlwin.$(OBJSUFF) \
|
||||||
|
$(HTMLDIR)/htmprint.$(OBJSUFF) \
|
||||||
$(HTMLDIR)/m_fonts.$(OBJSUFF) \
|
$(HTMLDIR)/m_fonts.$(OBJSUFF) \
|
||||||
$(HTMLDIR)/m_hline.$(OBJSUFF) \
|
$(HTMLDIR)/m_hline.$(OBJSUFF) \
|
||||||
$(HTMLDIR)/m_image.$(OBJSUFF) \
|
$(HTMLDIR)/m_image.$(OBJSUFF) \
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
||||||
|
|
||||||
# Symantec C++ makefile for the msw objects
|
# Symantec C++ makefile for the msw objects
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
||||||
|
|
||||||
# File: makefile.vc
|
# File: makefile.vc
|
||||||
@@ -314,6 +314,7 @@ HTMLOBJS = ..\html\$D\helpctrl.obj \
|
|||||||
..\html\$D\htmlpars.obj \
|
..\html\$D\htmlpars.obj \
|
||||||
..\html\$D\htmltag.obj \
|
..\html\$D\htmltag.obj \
|
||||||
..\html\$D\htmlwin.obj \
|
..\html\$D\htmlwin.obj \
|
||||||
|
..\html\$D\htmprint.obj \
|
||||||
..\html\$D\m_fonts.obj \
|
..\html\$D\m_fonts.obj \
|
||||||
..\html\$D\m_hline.obj \
|
..\html\$D\m_hline.obj \
|
||||||
..\html\$D\m_image.obj \
|
..\html\$D\m_image.obj \
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:54, 1999/10/14
|
# This file was automatically generated by tmake at 22:30, 1999/10/16
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
||||||
|
|
||||||
#!/binb/wmake.exe
|
#!/binb/wmake.exe
|
||||||
|
@@ -563,6 +563,10 @@ SOURCE=.\html\htmlwin.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\html\htmprint.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\html\m_fonts.cpp
|
SOURCE=.\html\m_fonts.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -578,6 +578,10 @@ SOURCE=.\html\htmlwin.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\html\htmprint.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\html\m_fonts.cpp
|
SOURCE=.\html\m_fonts.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -571,6 +571,10 @@ SOURCE=.\html\htmlwin.cpp
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\html\htmprint.cpp
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\html\winpars.cpp
|
SOURCE=.\html\winpars.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
Reference in New Issue
Block a user