void FOX16_HtmlCtx::_paintAt(FXDC *dc, HTML_OBJECT *o,
                             int xOffset, int yOffset,
                             int xText, int yText,
                             int w, int h) {
  HTML_OBJECT *c;
  int x;
  int y;
  int printX;
  int printY;
  int objectW;
  int objectH;

  x=xText+HtmlObject_GetX(o);
  y=yText+HtmlObject_GetY(o);
  objectW=HtmlObject_GetWidth(o);
  objectH=HtmlObject_GetHeight(o);

  printX=x-xOffset;
  printY=y-yOffset;

  if (printX<w && printX+objectW>=0 &&
      printY<h && printY+objectH>=0) {
    switch(HtmlObject_GetObjectType(o)) {
#if 0
    case HtmlObjectType_Grid:
      dc->setForeground(FXRGB(255,0,0));
      dc->fillRectangle(printX, printY,
                        HtmlObject_GetWidth(o),
                        HtmlObject_GetHeight(o));
#endif
    case HtmlObjectType_Word: {
      HTML_PROPS *pr;
      HTML_FONT *fnt;
      FXFont *xfnt;
      int ascent=0;
      uint32_t col;

      pr=HtmlObject_GetProperties(o);

      /* select font */
      fnt=HtmlProps_GetFont(pr);
      xfnt=_getFoxFont(fnt);
      if (xfnt) {
        dc->setFont(xfnt);
        ascent=xfnt->getFontAscent();
      }

      /* select foreground color */
      col=HtmlProps_GetForegroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setForeground(_fgColor);
      else
        dc->setForeground(col);

      /* select background color */
      col=HtmlProps_GetBackgroundColor(pr);
      if (col==HTML_PROPS_NOCOLOR)
        dc->setBackground(_bgColor);
      else
        dc->setBackground(col);

      dc->drawText(printX, printY+ascent, HtmlObject_GetText(o));
      break;
    }

    case HtmlObjectType_Image: {
      HTML_IMAGE *img;

      img=HtmlObject_Image_GetImage(o);
      if (img) {
        FXImage *ximg;

        ximg=GWEN_INHERIT_GETDATA(HTML_IMAGE, FXImage, img);
        if (ximg) {
          HTML_PROPS *pr;
          uint32_t col;

          pr=HtmlObject_GetProperties(o);

          /* select background color */
          col=HtmlProps_GetBackgroundColor(pr);
          if (col==HTML_PROPS_NOCOLOR) {
            dc->setBackground(_bgColor);
            dc->setForeground(_bgColor);
          }
          else {
            dc->setBackground(col);
            dc->setForeground(col);
          }
          dc->fillRectangle(printX, printY, ximg->getWidth(), ximg->getHeight());

          dc->drawImage(ximg, printX, printY);
        }
      }
      break;
    }
    default:
      break;
    }


    c=HtmlObject_Tree_GetFirstChild(o);
    while(c) {
      _paintAt(dc, c, xOffset, yOffset, x, y, w, h);
      c=HtmlObject_Tree_GetNext(c);
    }
  }
}
void FOX16_HtmlCtx::_paint(FXDC *dc, HTML_OBJECT *o, int xOffset, int yOffset) {
  HTML_OBJECT *c;

  xOffset+=HtmlObject_GetX(o);
  yOffset+=HtmlObject_GetY(o);

  switch(HtmlObject_GetObjectType(o)) {
  case HtmlObjectType_Word: {
    HTML_PROPS *pr;
    HTML_FONT *fnt;
    FXFont *xfnt;
    int ascent=0;
    uint32_t col;

    pr=HtmlObject_GetProperties(o);

    /* select font */
    fnt=HtmlProps_GetFont(pr);
    xfnt=_getFoxFont(fnt);
    if (xfnt) {
      dc->setFont(xfnt);
      ascent=xfnt->getFontAscent();
    }

    /* select foreground color */
    col=HtmlProps_GetForegroundColor(pr);
    if (col==HTML_PROPS_NOCOLOR)
      dc->setForeground(_fgColor);
    else
      dc->setForeground(col);

    /* select background color */
    col=HtmlProps_GetBackgroundColor(pr);
    if (col==HTML_PROPS_NOCOLOR)
      dc->setBackground(_bgColor);
    else
      dc->setBackground(col);

    dc->drawText(xOffset, yOffset+ascent, HtmlObject_GetText(o));
    break;
  }

  case HtmlObjectType_Image: {
    HTML_IMAGE *img;

    img=HtmlObject_Image_GetImage(o);
    if (img) {
      FXImage *ximg;

      ximg=GWEN_INHERIT_GETDATA(HTML_IMAGE, FXImage, img);
      if (ximg) {
        HTML_PROPS *pr;
        uint32_t col;

        pr=HtmlObject_GetProperties(o);

        /* select background color */
        col=HtmlProps_GetBackgroundColor(pr);
        if (col==HTML_PROPS_NOCOLOR) {
          dc->setBackground(_bgColor);
          dc->setForeground(_bgColor);
        }
        else {
          dc->setBackground(col);
          dc->setForeground(col);
        }

        dc->fillRectangle(xOffset, yOffset, ximg->getWidth(), ximg->getHeight());

        dc->drawImage(ximg, xOffset, yOffset);
      }
    }
    break;
  }
  default:
    break;
  }

  c=HtmlObject_Tree_GetFirstChild(o);
  while(c) {
    _paint(dc, c, xOffset, yOffset);
    c=HtmlObject_Tree_GetNext(c);
  }
}