HTML_IMAGE *FOX16_HtmlCtx::getImage(const char *fileName) { GWEN_STRINGLIST *sl; sl=HtmlCtx_GetMediaPaths(_context); if (sl) { GWEN_BUFFER *tbuf; int rv; FXImage *ximg; HTML_IMAGE *img; tbuf=GWEN_Buffer_new(0, 256, 0, 1); rv=GWEN_Directory_FindFileInPaths(sl, fileName, tbuf); if (rv<0) { DBG_ERROR(GWEN_LOGDOMAIN, "here (%d)", rv); GWEN_Buffer_free(tbuf); return NULL; } if (m_iconSource==NULL) m_iconSource=new FXIconSource(FXApp::instance()); ximg=m_iconSource->loadIconFile(GWEN_Buffer_GetStart(tbuf)); if (ximg==NULL) { DBG_ERROR(GWEN_LOGDOMAIN, "Could not load icon [%s]", GWEN_Buffer_GetStart(tbuf)); GWEN_Buffer_free(tbuf); return NULL; } ximg->create(); img=HtmlImage_new(); HtmlImage_SetImageName(img, GWEN_Buffer_GetStart(tbuf)); HtmlImage_SetWidth(img, ximg->getWidth()); HtmlImage_SetHeight(img, ximg->getHeight()); GWEN_INHERIT_SETDATA(HTML_IMAGE, FXImage, img, ximg, FOX16_HtmlCtxLinker::freeImageData); GWEN_Buffer_free(tbuf); return img; } else { DBG_ERROR(GWEN_LOGDOMAIN, "No media paths in dialog"); return NULL; } }
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); } }