]> git.saurik.com Git - wxWidgets.git/commitdiff
new wxHTML printing code ; parser now supports scaling
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 11 Dec 1999 21:50:44 +0000 (21:50 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 11 Dec 1999 21:50:44 +0000 (21:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4906 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
docs/latex/wx/htcontnr.tex
docs/latex/wx/htdcrend.tex
docs/latex/wx/htwinprs.tex
include/wx/html/htmlcell.h
include/wx/html/htmprint.h
include/wx/html/winpars.h
src/html/htmlcell.cpp
src/html/htmprint.cpp
src/html/m_hline.cpp
src/html/m_image.cpp
src/html/m_tables.cpp
src/html/winpars.cpp

index f7662a26e7f1cfefb9be560f86c3d021dddb572a..2053c88c8745193503fae927ea19a8fe570c2a23 100644 (file)
@@ -205,7 +205,7 @@ empty place!}
 
 \func{void}{SetWidthFloat}{\param{int }{w}, \param{int }{units}}
 
-\func{void}{SetWidthFloat}{\param{const wxHtmlTag\& }{tag}}
+\func{void}{SetWidthFloat}{\param{const wxHtmlTag\& }{tag}, \param{double }{pixel_scale = 1.0}}
 
 Sets floating width adjustment.
 
@@ -213,6 +213,8 @@ The normal behaviour of container is that its width is the same as the width of
 parent container (and thus you can have only one sub-container per line).
 You can change this by setting FWA.
 
+{\it pixel_scale} is number of real pixels that equals to 1 HTML pixel.
+
 \wxheading{Parameters}
 
 \docparam{w}{Width of the container. If the value is negative it means
index 0c02abc77adcf8077e4e7680d88301f77a5db2b1..58ae47a2f9765249786650c6d94929a23cf42244 100644 (file)
@@ -23,10 +23,14 @@ Constructor.
 
 \membersection{wxHtmlDCRenderer::SetDC}\label{wxhtmldcrenderersetdc}
 
-\func{void}{SetDC}{\param{wxDC* }{dc}, \param{int }{maxwidth}}
+\func{void}{SetDC}{\param{wxDC* }{dc}, \param{double }{pixel_scale = 1.0}}
 
 Assign DC instance to the renderer.
 
+{\it pixel_scale} can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics.
+(Many dimensions in HTML are given in pixels - e.g. image sizes. 300x300 image would be only one
+inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)
+
 \wxheading{Parameters}
 
 \docparam{maxwidth}{width of the area (on this DC) that is equivalent to screen's width, 
@@ -45,9 +49,6 @@ See also \helpref{SetSize}{wxhtmldcrenderersetsize}.
 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}
 
index 6d3e4aab6197fac1f3f38224f960739da060920e..d8019eb86b30f7c28be8e6bd0305bda67624bf1f 100644 (file)
@@ -200,9 +200,12 @@ Alignment of newly opened container is set to this value.
 
 \membersection{wxHtmlWinParser::SetDC}\label{wxhtmlwinparsersetdc}
 
-\func{virtual void}{SetDC}{\param{wxDC }{*dc}}
+\func{virtual void}{SetDC}{\param{wxDC }{*dc}, \param{double }{pixel_scale = 1.0}
 
-Sets the DC. This must be called before \helpref{Parse}{wxhtmlparserparse}!
+Sets the DC. This must be called before \helpref{Parse}{wxhtmlparserparse}! {\it pixel_scale} 
+can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics.
+(Many dimensions in HTML are given in pixels - e.g. image sizes. 300x300 image would be only one
+inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)
 
 \membersection{wxHtmlWinParser::SetFontBold}\label{wxhtmlwinparsersetfontbold}
 
index 0dd32f2fea5c8bfcd16de22bd3b4af69a7ceae17..a0f585232e4dd1995ce0c1c0d8bfa8d19d6c2da0 100644 (file)
@@ -210,7 +210,7 @@ class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell
         void SetAlign(const wxHtmlTag& tag);
                 // sets alignment info based on given tag's params
         void SetWidthFloat(int w, int units) {m_WidthFloat = w; m_WidthFloatUnits = units;}
-        void SetWidthFloat(const wxHtmlTag& tag);
+        void SetWidthFloat(const wxHtmlTag& tag, double pixel_scale = 1.0);
                 // sets floating width adjustment
                 // (examples : 32 percent of parent container,
                 // -15 pixels percent (this means 100 % - 15 pixels)
index e7d6dc59e81de018bc7796ff531d3c29cb9bb006..f84dea24af2a77dd21d1e788820e404da097385e 100644 (file)
@@ -38,17 +38,11 @@ class WXDLLEXPORT wxHtmlDCRenderer : public wxObject
         ~wxHtmlDCRenderer();
         
         // Following 3 methods *must* be called before any call to Render:
-        void SetDC(wxDC *dc, int maxwidth);
+        void SetDC(wxDC *dc, double pixel_scale = 1.0);
                 // 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
                 //
@@ -79,7 +73,6 @@ class WXDLLEXPORT wxHtmlDCRenderer : public wxObject
         wxFileSystem *m_FS;
         wxHtmlContainerCell *m_Cells;
         int m_MaxWidth, m_Width, m_Height;
-        double m_Scale;
 };
 
 
index 34765ac387e2001eb3402f283f66cf312d5722f6..4d0c8cd520abd39df54a42de4cec2aed5bca162d 100644 (file)
@@ -44,10 +44,11 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
         virtual void DoneParser();
         virtual wxObject* GetProduct();
 
-        virtual void SetDC(wxDC *dc) {m_DC = dc;}
+        virtual void SetDC(wxDC *dc, double pixel_scale = 1.0) {m_DC = dc; m_PixelScale = pixel_scale;}
                 // Set's the DC used for parsing. If SetDC() is not called,
                 // parsing won't proceed
         wxDC *GetDC() {return m_DC;}
+        double GetPixelScale() {return m_PixelScale;}
         int GetCharHeight() const {return m_CharHeight;}
         int GetCharWidth() const {return m_CharWidth;}
             // NOTE : these functions do _not_ return _actual_
@@ -113,6 +114,7 @@ class WXDLLEXPORT wxHtmlWinParser : public wxHtmlParser
             // temporary variable used by AddText
         wxWindow *m_Window;
                 // window we're parsing for
+        double m_PixelScale;
         wxDC *m_DC;
                 // Device Context we're parsing for
         static wxList m_Modules;
index 71633156ea371002239144af3da5644b5fe3933e..e8680be944ef868e670de1f7822dcca267d65e2f 100644 (file)
@@ -390,7 +390,7 @@ void wxHtmlContainerCell::SetAlign(const wxHtmlTag& tag)
 
 
 
-void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag)
+void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag, double pixel_scale)
 {
     if (tag.HasParam("WIDTH")) {
         int wdi;
@@ -402,7 +402,7 @@ void wxHtmlContainerCell::SetWidthFloat(const wxHtmlTag& tag)
         }
         else {
             wxSscanf(wd.c_str(), wxT("%i"), &wdi);
-            SetWidthFloat(wdi, wxHTML_UNITS_PIXELS);
+            SetWidthFloat((int)(pixel_scale * (double)wdi), wxHTML_UNITS_PIXELS);
         }
     }
 }
index f7072abf468765cae6a06d1547f7b0e6f5fe1801..ef8c0b5a23b8edec31fb053e7777e5166e8fd373 100644 (file)
@@ -1,4 +1,3 @@
-
 /////////////////////////////////////////////////////////////////////////////
 // Name:        htmprint.cpp
 // Purpose:     html printing classes
@@ -49,7 +48,6 @@ wxHtmlDCRenderer::wxHtmlDCRenderer() : wxObject()
     m_Parser = new wxHtmlWinParser(NULL);
     m_FS = new wxFileSystem();
     m_Parser -> SetFS(m_FS);
-    m_Scale = 1.0;
 }
 
 
@@ -63,29 +61,18 @@ wxHtmlDCRenderer::~wxHtmlDCRenderer()
 
 
 
-void wxHtmlDCRenderer::SetDC(wxDC *dc, int maxwidth)
+void wxHtmlDCRenderer::SetDC(wxDC *dc, double pixel_scale)
 {
-    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);
+    m_Parser -> SetDC(m_DC, pixel_scale);
 }
 
 
 
 void wxHtmlDCRenderer::SetSize(int width, int height)
 {
-    m_Width = (int)(width * m_Scale);
-    m_Height = (int)(height * m_Scale);
+    m_Width = width;
+    m_Height = height;
 }
 
 
@@ -97,7 +84,6 @@ void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepat
     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, wxHTML_INDENT_ALL, wxHTML_UNITS_PIXELS);
     m_Cells -> Layout(m_Width);
@@ -111,26 +97,21 @@ int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render)
     
     if (m_Cells == NULL || m_DC == NULL) return 0;
     
-    pbreak = (int)(from * m_Scale + m_Height);
+    pbreak = (int)(from + m_Height);
     while (m_Cells -> AdjustPagebreak(&pbreak)) {}
-    hght = pbreak - (int)(from * m_Scale);
+    hght = pbreak - from;
     
     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, hght);
+        m_DC -> SetClippingRegion(x, y, m_Width, hght);
         m_Cells -> Draw(*m_DC, 
-                        x * m_Scale, (y - from) * m_Scale, 
-                        y * m_Scale, pbreak + (y /*- from*/) * m_Scale);
+                        x, (y - from),
+                        y, pbreak + (y /*- from*/));
         m_DC -> DestroyClippingRegion();
     }
     
-    if (pbreak < m_Cells -> GetHeight()) return (int)(pbreak / m_Scale);
+    if (pbreak < m_Cells -> GetHeight()) return pbreak;
     else return GetTotalHeight();
 }
 
@@ -138,7 +119,7 @@ int wxHtmlDCRenderer::Render(int x, int y, int from, int dont_render)
 
 int wxHtmlDCRenderer::GetTotalHeight()
 {
-    if (m_Cells) return (int)(m_Cells -> GetHeight() / m_Scale);
+    if (m_Cells) return m_Cells -> GetHeight();
     else return 0;
 }
 
@@ -187,7 +168,7 @@ wxHtmlPrintout::~wxHtmlPrintout()
 
 bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
 {
-    int pageWidth, pageHeight, mm_w, mm_h;
+    int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_h;
     float ppmm_h, ppmm_v;
     
     if (!wxPrintout::OnBeginDocument(startPage, endPage)) return FALSE;
@@ -197,9 +178,19 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
     ppmm_h = (float)pageWidth / mm_w;
     ppmm_v = (float)pageHeight / mm_h;
 
+    int ppiPrinterX, ppiPrinterY;
+    GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
+    int ppiScreenX, ppiScreenY;
+    GetPPIScreen(&ppiScreenX, &ppiScreenY);
+
+    wxDisplaySize(&scr_w, &scr_h);
+    GetDC() -> GetSize(&dc_w, &dc_h);
+
+    GetDC() -> SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
+
     /* prepare headers/footers renderer: */
     
-    m_RendererHdr -> SetDC(GetDC(), pageWidth);
+    m_RendererHdr -> SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
     m_RendererHdr -> SetSize(ppmm_h * (mm_w - m_MarginLeft - m_MarginTop), 
                           ppmm_v * (mm_h - m_MarginTop - m_MarginBottom));
     if (m_Headers[0] != wxEmptyString) {
@@ -220,7 +211,7 @@ bool wxHtmlPrintout::OnBeginDocument(int startPage, int endPage)
     }
     
     /* prepare main renderer: */
-    m_Renderer -> SetDC(GetDC(), pageWidth);
+    m_Renderer -> SetDC(GetDC(), (double)ppiPrinterY / (double)ppiScreenY);
     m_Renderer -> SetSize(ppmm_h * (mm_w - m_MarginLeft - m_MarginTop), 
                           ppmm_v * (mm_h - m_MarginTop - m_MarginBottom) - 
                           m_FooterHeight - m_HeaderHeight -
@@ -339,23 +330,32 @@ void wxHtmlPrintout::RenderPage(wxDC *dc, int page)
 {
     wxBusyCursor wait;
 
-    int pageWidth, pageHeight, mm_w, mm_h;
+    int pageWidth, pageHeight, mm_w, mm_h, scr_w, scr_h, dc_w, dc_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);
+    wxDisplaySize(&scr_w, &scr_h);
+    dc -> GetSize(&dc_w, &dc_h);
 
+    int ppiPrinterX, ppiPrinterY;
+    GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
+    int ppiScreenX, ppiScreenY;
+    GetPPIScreen(&ppiScreenX, &ppiScreenY);
+
+    dc -> SetUserScale((double)dc_w / (double)pageWidth, (double)dc_w / (double)pageWidth);
+    
+    m_Renderer -> SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
+    
     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);
+    m_RendererHdr -> SetDC(dc, (double)ppiPrinterY / (double)ppiScreenY);
     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);
index c4099f34a4187ec949ac3b3c6dab171d1d2b0b19..1f09c5d378f37ad3c76718d5a106bd2950aabbdf 100644 (file)
@@ -81,7 +81,7 @@ TAG_HANDLER_BEGIN(HR, "HR")
         c -> SetWidthFloat(tag);
         sz = 1;
         if (tag.HasParam(wxT("SIZE")) && tag.ScanParam(wxT("SIZE"), wxT("%i"), &sz) == 1) {}
-        c -> InsertCell(new wxHtmlLineCell(sz));
+        c -> InsertCell(new wxHtmlLineCell((int)((double)sz * m_WParser -> GetPixelScale())));
 
         m_WParser -> CloseContainer();
         m_WParser -> OpenContainer();
index bec8f9064dd690dd4ff71d3f1e030952fa1ae0dd..c8b27e55ae56d39fecbc80db057713fd7d206529 100644 (file)
@@ -57,9 +57,9 @@ class wxHtmlImageMapAreaCell : public wxHtmlCell
     protected:
         CoordArray coords;
         celltype type;
-        int    radius;
+        int radius;
     public:
-        wxHtmlImageMapAreaCell( celltype t, wxString &coords );
+        wxHtmlImageMapAreaCell( celltype t, wxString &coords, double pixel_scale = 1.0);
         virtual wxString GetLink( int x = 0, int y = 0 ) const;
 };
 
@@ -67,17 +67,17 @@ class wxHtmlImageMapAreaCell : public wxHtmlCell
 
 
 
-wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype t, wxString &incoords )
+wxHtmlImageMapAreaCell::wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::celltype t, wxString &incoords, double pixel_scale )
 {
-    int        i;
+    int i;
     wxString x = incoords, y;
 
     type = t;
     while ((i = x.Find( ',' )) != -1) {
-        coords.Add( wxAtoi( x.Left( i ).c_str() ) );
+        coords.Add( (int)(pixel_scale * (double)wxAtoi( x.Left( i ).c_str())) );
         x = x.Mid( i + 1 );
     }
-    coords.Add( wxAtoi( x.c_str() ) );
+    coords.Add( (int)(pixel_scale * (double)wxAtoi( x.c_str())) );
 }
 
 wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
@@ -85,7 +85,7 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
     switch (type) {
         case RECT:
             {
-                int    l, t, r, b;
+                int l, t, r, b;
 
                 l = coords[ 0 ];
                 t = coords[ 1 ];
@@ -98,8 +98,8 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
             }
         case CIRCLE:
             {
-                int    l, t, r;
-                double d;
+                int l, t, r;
+                double  d;
 
                 l = coords[ 0 ];
                 t = coords[ 1 ];
@@ -113,15 +113,15 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
         case POLY:
             {
                 if (coords.GetCount() >= 6) {
-                    int        intersects = 0;
-                    int        wherex = x;
-                    int        wherey = y;
-                    int        totalv = coords.GetCount() / 2;
-                    int        totalc = totalv * 2;
-                    int        xval = coords[totalc - 2];
-                    int        yval = coords[totalc - 1];
-                    int        end = totalc;
-                    int        pointer = 1;
+                    int intersects = 0;
+                    int wherex = x;
+                    int wherey = y;
+                    int totalv = coords.GetCount() / 2;
+                    int totalc = totalv * 2;
+                    int xval = coords[totalc - 2];
+                    int yval = coords[totalc - 1];
+                    int end = totalc;
+                    int pointer = 1;
 
                     if ((yval >= wherey) != (coords[pointer] >= wherey)) {
                         if ((xval >= wherex) == (coords[0] >= wherex)) {
@@ -178,7 +178,7 @@ wxString wxHtmlImageMapAreaCell::GetLink( int x, int y ) const
             break;
     }
     if (m_Next) {
-        wxHtmlImageMapAreaCell *a = (wxHtmlImageMapAreaCell*)m_Next;
+        wxHtmlImageMapAreaCell  *a = (wxHtmlImageMapAreaCell*)m_Next;
         return a->GetLink( x, y );
     }
     return wxEmptyString;
@@ -218,7 +218,7 @@ wxHtmlImageMapCell::wxHtmlImageMapCell( wxString &name )
 
 wxString wxHtmlImageMapCell::GetLink( int x, int y ) const
 {
-    wxHtmlImageMapAreaCell     *a = (wxHtmlImageMapAreaCell*)m_Next;
+    wxHtmlImageMapAreaCell  *a = (wxHtmlImageMapAreaCell*)m_Next;
     if (a)
         return a->GetLink( x, y );
     return wxHtmlCell::GetLink( x, y );
@@ -315,7 +315,7 @@ wxString wxHtmlImageCell::GetLink( int x, int y ) const
     if (m_MapName.IsEmpty())
         return wxHtmlCell::GetLink( x, y );
     if (!m_ImageMap) {
-        wxHtmlContainerCell    *p, *op;
+        wxHtmlContainerCell *p, *op;
         op = p = GetParent();
         while (p) {
             op = p;
@@ -372,7 +372,10 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
                 }
                 wxHtmlImageCell *cel = NULL;
                 if (str) {
-                    cel = new wxHtmlImageCell(str, w, h, al, mn);
+                    cel = new wxHtmlImageCell(str, 
+                                (int)(m_WParser -> GetPixelScale() * (double)w), 
+                                (int)(m_WParser -> GetPixelScale() * (double)h), 
+                                al, mn);
                     cel -> SetLink(m_WParser -> GetLink());
                     m_WParser -> GetContainer() -> InsertCell(cel);
                     delete str;
@@ -394,18 +397,18 @@ TAG_HANDLER_BEGIN(IMG, "IMG,MAP,AREA")
         if (tag.GetName() == "AREA") {
             if (tag.HasParam("SHAPE")) {
                 wxString tmp = tag.GetParam("SHAPE");
-                wxString coords;
+                wxString coords = wxEmptyString;
                 tmp.MakeUpper();
                 wxHtmlImageMapAreaCell *cel = NULL;
                 if (tag.HasParam("COORDS")) {
                     coords = tag.GetParam("COORDS");
                 }
                 if (tmp == "POLY") {
-                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords );
+                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::POLY, coords, m_WParser -> GetPixelScale() );
                 } else if (tmp == "CIRCLE") {
-                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords );
+                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::CIRCLE, coords, m_WParser -> GetPixelScale() );
                 } else if (tmp == "RECT") {
-                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords );
+                    cel = new wxHtmlImageMapAreaCell( wxHtmlImageMapAreaCell::RECT, coords, m_WParser -> GetPixelScale() );
                 }
                 if (cel != NULL && tag.HasParam("HREF")) {
                     wxString tmp = tag.GetParam("HREF");
index 4850c1b0075c29e7a911690bb2656ceddb81d8f2..6f631bb527a4a0a9de45ad6c1e4af7c220e03bee 100644 (file)
@@ -93,9 +93,11 @@ class wxHtmlTableCell : public wxHtmlContainerCell
         int m_tBkg, m_rBkg;
         wxString m_tValign, m_rValign;
 
+        double m_PixelScale;
+
 
     public:
-        wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag);
+        wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale = 1.0);
         ~wxHtmlTableCell();
         virtual void Layout(int w);
 
@@ -111,9 +113,10 @@ class wxHtmlTableCell : public wxHtmlContainerCell
 
 
 
-wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag)
+wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& tag, double pixel_scale)
  : wxHtmlContainerCell(parent)
 {
+    m_PixelScale = pixel_scale;
     m_HasBorders = (tag.HasParam("BORDER") && tag.GetParam("BORDER") != "0");
     m_ColsInfo = NULL;
     m_NumCols = m_NumRows = 0;
@@ -126,6 +129,8 @@ wxHtmlTableCell::wxHtmlTableCell(wxHtmlContainerCell *parent, const wxHtmlTag& t
     if (tag.HasParam(wxT("VALIGN"))) m_tValign = tag.GetParam(wxT("VALIGN")); else m_tValign = wxEmptyString;
     if (tag.HasParam(wxT("CELLSPACING")) && tag.ScanParam(wxT("CELLSPACING"), wxT("%i"), &m_Spacing) == 1) {} else m_Spacing = 2;
     if (tag.HasParam(wxT("CELLPADDING")) && tag.ScanParam(wxT("CELLPADDING"), wxT("%i"), &m_Padding) == 1) {} else m_Padding = 3;
+    m_Spacing = (int)(m_PixelScale * (double)m_Spacing);
+    m_Padding = (int)(m_PixelScale * (double)m_Padding);
 
     if (m_HasBorders)
         SetBorder(TABLE_BORDER_CLR_1, TABLE_BORDER_CLR_2);
@@ -229,6 +234,7 @@ void wxHtmlTableCell::AddCell(wxHtmlContainerCell *cell, const wxHtmlTag& tag)
             }
             else {
                 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].units = wxHTML_UNITS_PIXELS;
             }
         }
@@ -432,8 +438,8 @@ TAG_HANDLER_BEGIN(TABLE, "TABLE,TR,TD,TH")
 
             oldcont = c = m_WParser -> OpenContainer();
 
-            c -> SetWidthFloat(tag);
-            m_Table = new wxHtmlTableCell(c, tag);
+            c -> SetWidthFloat(tag, m_WParser -> GetPixelScale());
+            m_Table = new wxHtmlTableCell(c, tag, m_WParser -> GetPixelScale());
             m_OldAlign = m_WParser -> GetAlign();
             m_tAlign = wxEmptyString;
             if (tag.HasParam("ALIGN")) m_tAlign = tag.GetParam("ALIGN");
index 3c3fbb22a72e74e6efd4bb1c145bca7d10bf4b6c..5e1a83ff074db4864944debbdb4fe3a6ecec1d38 100644 (file)
@@ -244,7 +244,6 @@ wxHtmlContainerCell* wxHtmlWinParser::CloseContainer()
 }
 
 
-
 wxFont* wxHtmlWinParser::CreateCurrentFont()
 {
     int fb = GetFontBold(),
@@ -256,11 +255,11 @@ wxFont* wxHtmlWinParser::CreateCurrentFont()
     if (m_FontsTable[fb][fi][fu][ff][fs] == NULL) {
         m_FontsTable[fb][fi][fu][ff][fs] =
             new wxFont(
-            m_FontsSizes[fs],
-            ff ? wxMODERN : wxSWISS,
-            fi ? (ff ? m_ItalicModeFixed : m_ItalicModeNormal) : wxNORMAL,
-            fb ? wxBOLD : wxNORMAL,
-            fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal);
+                m_FontsSizes[fs] * m_PixelScale,
+                ff ? wxMODERN : wxSWISS,
+                fi ? (ff ? m_ItalicModeFixed : m_ItalicModeNormal) : wxNORMAL,
+                fb ? wxBOLD : wxNORMAL,
+                fu ? TRUE : FALSE, ff ? m_FontFaceFixed : m_FontFaceNormal);
     }
     m_DC -> SetFont(*(m_FontsTable[fb][fi][fu][ff][fs]));
     return (m_FontsTable[fb][fi][fu][ff][fs]);