HTML renderer drop-in, C++ code - c++

I want to drop in an HTML renderer that will basically be used for render-to-texture operations.
If I can render the HTML to an HDC, that would be perfect.
I found HTMLayout, which isn't bad. But it isn't open source. But I'm wondering if there's a way to somehow tap into IE or Mozilla/Gecko code, how realisitic/difficult this will be, and possibly some pointers on how to do it.
It will be for a regular straight C++ directx application
Edit
Wow! Mozilla has an embedding kit!

Take a look at WebKit.

Qt can do it, render to a QPainter. See for example http://doc.trolltech.com/4.6/qwebpage.html But not sure if it's easily used if you are not already using Qt.

Related

C++ ImGui - Display a Gif or Video?

I am currently coding a winrate statistics menu for League of Legends (which got approved) using ImGui and I wonder if it is possible to display a GIF or MP4 on the Menu as a Preview or Usage Tutorial not from File/Memory but from an URL as I want to keep the File as small as possible for now.
You probably would have to use a filestream, downloading the file to tmp and then displaying it as a Texture?
I found a similar question, and I wonder if something since then has changed:
https://github.com/ocornut/imgui/issues/2680
Is it still required to use an additional GIF loader?
Are there any easy ways now to achieve that?
I am a bit (new) to ImGui and would be very happy about any reference source code (not to copy paste, just to learn it).
Thanks for any help :).

QPdfDocument/QPdfView: How to display an animated PDF?

I implemented a PDF Viewing widget in C++ using Qt, loosely based on https://doc.qt.io/qt-5/qtpdf-pdfviewer-example.html, using the pdfwidgets module. (For this question, we can assume that I copied the code in that link 1:1).
This works well so far.
But now the thing is, the PDF I want to display happens to be an animated PDF. Opened in a regular viewer like Acrobat, it will show a short sequence. That sequence is located on a single page, the frames are not different slides.
In the documentation of the QPdfDocument and the QPdfPageNavigation classes, I can't find any functionality that deals with animated pages. It would suffice if I had any way to set the current animation phase.
Is this possible at all? If so, how?
It's not implemented at the moment. On Windows, you could use an ActiveQt widget to embed Acrobat Reader inside your application, if present. Otherwise you'd need to find a PDF rendering library - most likely a commercial one - that has such support.

Making a fancy looking window with messages stack

I try to make fancy looking messages viewer, where messages divided by formatting, other background of smth. similar. They need to looks like this - http://pastebin.com/GU1Lq087. What I found in wxWidgets to solve this problem, and why I can't use it:
wxHtmlWindow
Supports minimal HTML (a few tags). But big problem with this - html representation doesnt fill parent window. So element with width=100% will have 100% width only on standard window size. And even p tag doesnt have word wrapping (long long paragraph goes in one line with vertical scroolbar).
wxWebWiew
I need to have the ability to set generated HTML to it, but IE must to load some page first and I can rely only on IE background. It has some time to load page, even if I set HTML-string.
wxRichText
Most suitable for me. But I can't draw line like HTML's hr, or change background for the entire message block (to distinguish it from common background)
I need to show messages like this. But i didn't know how and which tool is better.
One way of achieving this would be using wxWebView with WebKit backend but I am afraid that Windows can only use IE's engine. However, there is project which allows you to use Gecko engine. I use WebKit for rendering chat in my application and it works really good (although I am using Qt). (http://www.kirix.com/labs/wxwebconnect.html)
You can always do it regular way - just create separate widget (I think it is called "frame" in wxWidgets) for single message. This way you get almost infinite possibilities. E.g. you can make "AbstractMessage" with virtual methods and then things like "AdministratorMessage", "MOTD" etc. will be a breeze.
wxRichText Most suitable for me. But I can't draw line like HTML's hr
Really? Have you looked at the docs?
( http://docs.wxwidgets.org/trunk/overview_richtextctrl.html )
Here's a couple simple ideas:
a. Write a line of blanks, underlined.
http://docs.wxwidgets.org/trunk/classwx_rich_text_ctrl.html#a333b2e675617ed2299cf91e7c0dbd0d8
b. Create an image of a horizontal line, display it using WriteImage
http://docs.wxwidgets.org/trunk/classwx_rich_text_ctrl.html#a1315611c0741d03e852ee26eba3a9d94
The funny thing is that what you want can be done using any of the 3 controls you mention. With wxHtmlWindow you just need to set its size correctly, with wxWebView I don't understand what your problem with it is at all and with wxRichTextCtrl you could just use separate controls for the areas with different backgrounds (you could almost certainly use a single control with different styles but using several controls seems simpler).

programmatically feed a kml-file and retrieve/generate a .png-file

How can I, programmatically, draw a KML-file (routing information on a map) onto a map and then save the result to a .png-file?
What I try to accomplish: a program of mine (written in C++) produces a route. Now I would like this program to emit a .png-file instead with the route draw on it.
I've looked into the google maps api as well as others (e.g. cartagen) but google maps is java-script oriented and cartagen produces html5 output.
Probably you can use Qt Framework to achive this.
It has great XML support so it should be easy to read KML.
It has support for drawing simple shapes.
It has support for PNGs too.
There is also library called libkml - it can probably help you with manipulating with KML files.
I highly doubt if there is any "Ready to Use" solution.

How to extract selected area of the gui component to PDF in QT

I need to make the tool like Snagit and to take the picture the selected area of the component. I'm searching how to make this tool in Qt.
I firstly prefer using Qt native library but if there is no library which fullfills this requirement, any good c++ libray can be accepted for me.
Any help will be appreciated.
Thanks
I'm not sure to understand exactly what you want. I assume you want to take a screen shot ? and then put this picture into a PDF document.
To take a screenshot with Qt, have a look at this :
http://doc.qt.nokia.com/4.0/widgets-screenshot.html
This will show you how to take a screenshot (using QDesktopWidget) and get a QPixmap.
You can then display this QPixmap into a QTextDocument (see QTextDocument::addResource) and print this document into a PDF file. Something like this :
QPrinter MyPrinter(QPrinter::HighResolution);
MyPrinter.setOutputFormat(QPrinter::PdfFormat);
MyPrinter.setOutputFileName("test.pdf");
MyPrinter.setPageSize(QPrinter::Letter);
MyPrinter.setColorMode(QPrinter::GrayScale);
MyPrinter.setOrientation(QPrinter::Landscape);
MyTextDocument.print(&MyPrinter);