Creating gui binding for c++ and YUI - c++

I am planning to use yui or jquery ui as front end for native c++ applications. I found no bindings present for this purpose. Will it be feasible/possible to do this ? If it is so, then how shall i proceed? please suggest advice.thanks

#rwik - I can see your point and desire to do what you intend and I would presume it to be a wise move to be making at this point in time considering the vast facilities browsers bring to the table as well as other aspects... I know we are in September now and I have come across this pretty late, but this is also for others who have a similar problem...
As far as I know, descending from JavaScript in to C++ is pretty murky, mostly due to the heterogenous nature of Javascript engines [Rhino, Tracemonkey, Spidermonkey, V8, Caracan,Charka, etc] employed by different browsers. But there are indeed ways to do this - depending on how dirty you want to get your hands and, indeed, on your abilities...
If you were to go with Google as a browser, you should take a look at projects such as cproxyv8 - http://code.google.com/p/cproxyv8/ or v8-juice - http://code.google.com/p/v8-juice/ which both offer interesting facilities...
My preference however is with Mozilla - simply because of XML User-Interface Language (XUL) which, if you do not know, allows you to speedily create your own user interfaces by giving direct access to its layout engine. I.e., you can even do away with the browser look and have your own independent layout while still having all browser facilities at your disposal.
With respect to C++/Javascript interaction - projects should exist for all alternatives - it pays to check.
I wish you good luck if you haven't already solved this problem.

I'd recommend QT instead.
However since native C++ has nothing to do with GUI I'm going to assume you are making a library in C++. However Yui is basically just JavaScript as is jQuery. So if you're asking can a web page or script be a C++ application the answer is not really.
What you could do is create a web service which uses your C++ library and exposes an interface for your web based application to call it indirectly.

One way to accomplish this is to embed WebKit into your application and provide your custom C++ functionality via a plugin. Both the WebKit framework on OSX and the Chromium Embedded Framework on Windows allow this style of application development. This allows you to write a UI using local Javascript/HTML files without the need for a webserver.

There are no direct bindings in JQuery and YUI because these libraries run in a web browser. Thus unless you’re planning to write your own browser plugins, the integration with the C++ will happen at the webserver that serves the data to the browser.
You could feed the data from your C++ code directly into JQuery/YUI by building web services directly in C++. But you might want to build a web application that will be serving your JQuery/YUI pages and that act as user interface controller (like in the MVC pattern). Web application languages like Java, PHP, etc. all have ways to call native code. Java has JNDI and in PHP you build extensions that link to C++ code.

Related

How to port Qt qml to web server with C++ backend

Is it possible to write front-end of my application in QML and back-end in C++ and compile it somehow so that I can deploy it to a web-server like Apache or JBoss so that it is accessible from within a web browser ?
If yes, do you have any examples how to perform this ?
Thank you very much for your answers :)
I was trying to find an answer to my question on the Internet but I was not successful.
QmlWeb is a JavaScript library that is able to parse QML-code and create a website out of it using normal HTML/DOM elements and absolute positions within CSS, translating the QML properties into CSS properties.
QmlWeb is a small project started primarily by Lauri Paimen who developed it for a few years and is now a KDE project maintained by Anton Kreuzkamp.
QmlWeb of course doesn’t yet support everything Qt’s implementation of QML does, but it already supports a quite usable subset of it. It supports nearly all of the most basic QML syntax. Moreover it has support for HTML input elements (Button, TextInput, TextArea are currently supported, more to come).
Well, QmlWeb is not finished. I hope Digia help with this project to make it ready with mature features.
The javascript currently sits on top of v8 but serves the purpose of expressing complex bindings and some (preferably small) client logic. But the engine could change (http://blog.qt.digia.com/blog/2013/04/15/evolution-of-the-qml-engine-part-1/).
Like in a browser, the actual graphics are kind of orthogonal to javascript which can only interact (or instantiate) with already existing graphical objects. In a browser, the graphics are described by html/css/svg/dom, and interpreted by the web engine written in C++. In QtQuick, the graphics are written in Qml and interpreted by the qml engine (scengraph) written in C++.
The two stacks are completely different.
Exception made of the Html canvas and the Qml canvas (which almost share the same api). But those are graphics working in immediate mode (opposed to a SVG or Qml scenegraph, working in a Retained mode fashion).
That being said...
There are 3 attempts to port Qml to the web:
A Qt port to Google Nacl (never heard of it from a long time, most likely dead)
Qt port through Emscripten/asm.js (awesome project, but not viable for production, and I don't think QtQuick is even supported... might require a huge effort to be actively maintained)
QmlWeb (Javascript apis to translate Qml files and interpret those on top of the HTML5 stack). Work in progress and only a subset of the whole QtQuick ecosystem might be supported in the long term. But still a really interesting project and maybe the most promising of all three. At least, it is the youngest one, and it might get some traction from the KDE community. http://akreuzkamp.de/2013/07/10/webapps-written-in-qml-not-far-from-reality-anymore/
You might also be interested in other scenegraphs technologies sitting on top of the web stack (amino, cake.js, rapahel.js...).
Last but not least, you might be interested by Wt (http://www.webtoolkit.eu/wt).
No. You cannot compile QML, and in any form it cannot be deployed onto a Java Application server such as JBoss. Qml is strictly for creating applications to run on a local machine. It sounds like you want to build a Web Application out of HTML with some sort of backend like .Net.

Link C++ library to html front end

I do computational research with a C++/CUDA library that does intensive number crunching. Recently I was thinking to set up a little showcase of my library on my webpage where people could work interactively with the library and see the results (plots, animations, etc.) in real time.
I have very limited html and website creating expertise. Are there libraries out there to link the html front-end to the C++/CUDA back-end? I'm developing in Linux environment but obviously I'd like my webpage to be accessed by anyone independent of their OS and/or browser.
So after a little bit of research I found the Wt library which is written in C++ and used for webpage development. Based on the information on their homepage, it seems to be exactly what I'm looking for:
Typical use scenarios:
High performance, complex web applications which are fully personalized (and thus cannot benefit from caching), fully Ajax enabled and at the same time entirely accessible and Search Engine Optimized.
Web-based GUIs for embedded systems benefit from the low footprint of a C++ web application server.
Web-based GUIs that require integration with (existing) C++ libraries, for example for scientific or engineering applications, or existing C++ desktop applications
I did something like this. To do this, I used a simple library I wrote called jrb_node at https://github.com/kennethho/jrb_node
There are other libraries like cppnetlib http://cpp-netlib.org/
Basically you make a small http server that based on the request will perform some computation and return the results as an http response. You can then combine that with javascript and Ajax if you want to make it more interactive.
An alternative to consider is to use WebCL. CUDA is pretty similar to OpenCL and it should be pretty easy to convert your code to the latter. If you have other C++ code, that might be a bit of problem though.
Do you want to run CUDA on server (e.g. the users will input the parameters, push a button and your server will do number crunching) or on client (e.g. it will be user GPU that does computations)?
For server-side you should be able to use pretty much any server technology - PHP, JSP, etc. They all provide a way to integrate to "native code".
For client-side you will not be able to do with just HTML - you need to use some "fat client" technology - e.g. ActiveX, Java applet. I do not know if Silverlight or Flash have access to native code. IMHO, you might as well just write a Qt application and put a download link on your site.

Any way to display C++ on a webpage?

Is there a relatively easy way to display the output of a C++ program on a webpage? And I don't mean manually, in other words, you see it on a webpage as it runs not as in I make a code tag and write it in myself.
EDIT: Just so everybody can get this clear I am going to post this up here. I am NOT trying to make a webpage in C++. Please excuse me if this sounds spiteful or anything but I am getting a lot of answers relating to that.
Step one, get yourself a server-side language. Be that PHP, ASP, Python, Ruby, whatever. Get it set up so you can serve it.
Step two, find your language's exec equivalent. Practically all of them have them. It'll let you run a command as if it were from the command line, usually with arguments and capture the output. Here's PHP's:
http://php.net/manual/en/function.exec.php
Of course, if you're passing user-input as arguments, sanitise!
I've just seen that you accepted Scott's answer. I usually wouldn't chase up a SO thread so persistently but I fear you're about to make a mistake that you'll come to regret down the line. Giving direct access to your program and its own built-in server is a terrible idea for two reasons:
You waste a day implementing this built-in server and then getting it to persist and testing it
More importantly, you've just opened up another attack vector into your server. When it comes to security, keep it simple.
You're far better having your C++ app running behind another (mature) server side language as all the work is done for you and it can filter the input to keep things safe.
You could write a CGI app in C++, or you could use an existing web server language to execute the command and send the output to the client.
You want to use Witty.
Wt (pronounced 'witty') is a C++
library for developing interactive web
applications.
The API is widget-centric and similar
to desktop GUI APIs. To the developer,
it offers complete abstraction of any
web-specific implementation details,
including event handling, graphics
support, graceful degradation (or
progressive enhancement), and pretty
URLs.
Unlike many page-based frameworks, Wt
was designed for creating stateful
applications that are at the same time
highly interactive (leveraging
techinques such as AJAX to their
fullest) and accessible (supporting
plain HTML browsers), using automatic
graceful degradation or progressive
enhancement.
The library comes with an application
server that acts as a stand-alone web
server or integrates through FastCGI
with other web servers.
I am not sure this is what you are looking for but you may want CGI You may want to look at this SO question, C++ may not be the best language for what you want to do.
based off the questions you posted Writing a web app like what you want is no simple task. What I would recommend is use some other library (this is one i found with a quick google) to get a web console on your server and give the user it is running under execute deny permissions on every folder except the folder you have your app installed.
This is still is a risky method if you don't set up the security correctly but it is the easiest solution without digging around too much on existing libraries to just have the application interactive.
EDIT --
The "Best" solution is learn AJAX and have your program post its own pages with it but like I said, it will not be easy.
It sounds like you want something like a telnet session embedded in a webpage. A quick google turns up many Java telnet apps, though I'm not qualified to evaluate which would be most ideal to embed in html.
You would set up the login script on the host machine to run your c++ app and the user would interact with it through the shell window. Note though that this will only work for pure command line apps. If you want to use a GUI app in this way, then you should look into remote desktop software or VNC.
It may be worth looking into Adobe's "Alchemy" project on Adobe Labs
This may help you with what you're trying to achieve.
:)
Are you looking for something like what codepad.org does? I believe they explain how they did it here.
There is a library called C++ Server Pages - Poco. I used it for one of my college project, its pretty good. There is also good documentation to get started with, u can find it here http://pocoproject.org/docs/

Embedded ActiveX analog using Django

This might be a naive question, but when using a python framework, what approaches are available to provide the kind of functionality that can be exposed using an ActiveX control as an embedded object. The specific example I have in mind is a third party ocx we are using in some ASP.NET pages to provide TWAIN interaction on the client side. I'd like to avoid browser and platform specific approaches, if possible.
Your question is a little confused. If you're talking client-side, it makes no difference whether you are using Python or ASP.NET on the server - you can still embed the object in the HTML and the client will run it, assuming they are using Internet Explorer. However, this already is a browser- and platform-specific approach.
The best alternatives are probably Flash and Silverlight - although the latter is from Microsoft, it is pretty well cross-platform now since all the main browsers and OSs have implementations of it. Flash is still more widespread for now, though.

What embedded browser for C++ project?

Is there any browser I could embedd in C++ application on Windows?
I need all features typical browser has (HTTP client, cookies support, DOM style HTML parser, JavaScript engine) except rendering.
Because I don't need rendering capability (and that's rather big part of a browser) I would prefer a browser with non monolithic design so I wouldn't have to include rendering stuff into my project.
It would be nice if it had C++ rather than C API.
I need this embedded browser mainly because I have much trouble finding C++ HTML parser which could handle broken HTML like browsers do.
If you know any, please answer Library Recommendation: C++ HTML Parser SO question or at least vote on it to increase a chance someone will give a good answer.
Sounds like all you need is something like libcurl which is an HTTP library and will let you do GET/POST/etc.
When I think browser I generally think rendering/JavaScript and not HTTP library.
Edit
In that case I'd look at WebKit (which I think has a C++ API) and hope you don't have to pull too much in.
Edit Again
On second thought (since rendering is such a big part of what browsers do), you might be better off using a stand-alone JS engine like SpiderMonkey and a stand-alone XML parser like Xerces-C (plus maybe tidy to make your HTML into XML).
I'm a bit confused by your question regarding embedding a web browser for which you don't need rendering capabilities. A web browser is rendering web pages by definition, unless you just need HTTP and XML with JavaScript capabilities which is a subset of a browser functionalities?
If you need a web browser to embed in your C++ application, I would suggest to consider Qt that comes with the WebKit plugin. It is C++, LGPL and has a very nice IDE (Qt Creator). I tried Qt with Qt Creator on unix (Ubuntu) and it was very impressive. The debugger is a bit light but it is just the first version. The adapter of Qt into visual c++ 2008 is now free.
You might also want to check out Awesomium-- it's free for non-commercial use and has all of the features you're looking for (if you don't need rendering, simply don't use it).
There is a project called CEF = The Chromium Embedded Framework - it is:
a simple framework for
embedding Chromium-based browsers in other applications. It is a
BSD-licensed open source project founded by Marshall Greenblatt in
2008 and based on the Google Chromium project. Unlike the Chromium
project itself, which focuses mainly on Google Chrome application
development, CEF focuses on facilitating embedded browser use cases in
third-party applications.
and yes:
The base CEF framework includes support for the C and C++ programming
languages.
Including javascript support and html parsing makes this non-trivial task - you have to use one of the available browsers.
IE is usable through its COM model - you can create instance of it in your window be it invisible or not and call its javascript/html capabilities.
It has been designed to be used like that since the beginning and certainly it is working fine.
The other options are:
Gecko/Mozilla - a couple of years ago it wasn't usable like this, currently I think it is.
WebKit/V8 - no public API has been released for chrome yet, you could use webkit itself, but it doesn't have javascript engine. Another option is to take a look at the Chrome codebase and see if you could get out of it what you need.
I would probably go for IE, since it is maybe the easiest option and I have already used it. The other options seem to me more like building a browser instead of just using it.
How about Gecko ? You may not need the entire engine but you may find some its components useful like SpiderMonkey which is a JavaScript engine written in C.
I'd recommend picking up Qt for C++ programming. It has a built-in library that embeds Webkit with all the bells'n'whistles, and Qt is a great C++ library in general.
Old question, I know, but take a look on
http://msdn.microsoft.com/en-us/library/ky29ffxd%28v=vs.94%29.aspx
IActiveScript and family COM interfaces allows script execution (not only JS, any language that registers as script interpeter, for that matter) in-memory.