<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Approximatrix Forums — Cairo calling]]></title>
		<link>https://forums.approximatrix.com/viewtopic.php?id=781</link>
		<atom:link href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=781&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Cairo calling.]]></description>
		<lastBuildDate>Tue, 20 Oct 2020 01:34:40 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3631#p3631</link>
			<description><![CDATA[<p><span class="bbu">Useless fact no 376.5</span>.</p><p>Did you realise, Carlos, the user of <span class="bbu">CAIRO</span> graphics and initiator of the Simply Fortran forum thread, <span class="bbu">CAIRO Calling</span>, that your name, <strong>CA</strong>(rlos) <strong>HERR</strong>er<strong>A</strong> sounds a little bit like the Arabic &#039;<strong>القاهرة</strong>&#039; ? </p><p>it means the name of probably the most most important Arabic city in history.</p><p>Pronounced something along the lines of, (Al) <strong>KAHheiRR</strong>a<br />We call it &#039;<span class="bbu">The</span> [city of] <strong><span class="bbu">Cairo</span></strong>&#039;!<br />---<br />John</p>]]></description>
			<author><![CDATA[null@example.com (JohnWasilewski)]]></author>
			<pubDate>Tue, 20 Oct 2020 01:34:40 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3631#p3631</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3629#p3629</link>
			<description><![CDATA[<p>John,<br />I used GTK+, however not with Fortran, but with compiler called FreeBasic. As far as I remember, Glade<br />produced a text file (with extension .ui) where the GUI elements were described in a readable markup <br />language called XML. Then this file was read, during compilation, by gtk_builder_add_from_file command. <br />The resulting exe was of course dynamically linked to GTK+ dll libraries.<br />Carlos</p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Mon, 19 Oct 2020 18:09:30 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3629#p3629</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3628#p3628</link>
			<description><![CDATA[<div class="quotebox"><cite>Carlos Herrera wrote:</cite><blockquote><p>...for GUI creation you can use very nice program called Glade.<br />I believe that the Simply Fortran IDE itself is written in GTK</p></blockquote></div><p>I looked at Glade a year or two ago and it certainly seemed like an excellent visual graphical way to construct GUIs, but I backed away from it at the time because I formed the impression that it resulted in object code that could not be linked with the Fortran .o files to create a single final executable but needed a separate component at runtime, in addition to the linked Fortran executable.&nbsp; I would love to discover now that I was mistaken about that.&nbsp; Was I?<br />—-<br />John</p>]]></description>
			<author><![CDATA[null@example.com (JohnWasilewski)]]></author>
			<pubDate>Sun, 18 Oct 2020 23:13:07 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3628#p3628</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3623#p3623</link>
			<description><![CDATA[<div class="quotebox"><cite>Carlos Herrera wrote:</cite><blockquote><p>I believe that the Simply Fortran IDE itself is written in GTK.</p></blockquote></div><p>Simply Fortran for GNU/Linux and macOS is indeed written using GTK+ for its user interface.&nbsp; Simply Fortran for Windows uses the Windows API directly for its user interface and does not use any GTK+ code.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Mon, 12 Oct 2020 13:14:23 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3623#p3623</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3622#p3622</link>
			<description><![CDATA[<p>John,<br />The best way to learn Cairo is to install&nbsp; GTK for Fortran package.<br />Cairo is included, it is even used for drawing the GUI controls.<br />Moreover, for GUI creation you can use very nice program called Glade.<br />I believe that the Simply Fortran IDE itself is written in GTK.<br />For me, however,&nbsp; GTK is an overkill, since I program only in win.<br />Carlos</p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Sun, 11 Oct 2020 08:53:47 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3622#p3622</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3621#p3621</link>
			<description><![CDATA[<p>Where is the best place to go to teach myself how to use CG with Fortran?<br />Will is be any good for creating a GUI?</p>]]></description>
			<author><![CDATA[null@example.com (JohnWasilewski)]]></author>
			<pubDate>Sat, 10 Oct 2020 21:10:54 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3621#p3621</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3619#p3619</link>
			<description><![CDATA[<p>Cairo, I believe, performs anti-aliasing while drawing, so it will almost certainly look &quot;nicer&quot; than AppGraphics.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Fri, 09 Oct 2020 11:10:14 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3619#p3619</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3618#p3618</link>
			<description><![CDATA[<p>Jeff,<br />I think that your approach, in which AppGraphics doesn&#039;t expose any of the Windows API to the user,<br />is actually an advantage. It would be nice, however, if AppGraphics supported also png files.<br />John,<br />You are right, AppGraphics is great, but Cairo lines and shapes are somehow &quot;nicer&quot;.&nbsp; As regards<br />dislin , I use it quite often, but at some point I would like to create my own simple 2d plot module for SF.<br />Carlos</p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Thu, 08 Oct 2020 20:05:52 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3618#p3618</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3615#p3615</link>
			<description><![CDATA[<p>Alternatives:</p><p>(1) Use Appgraphics!&nbsp; Brilliant, and built into SF.</p><p>(2) Use the fantastic, free, DISLIN library. <br />&nbsp; &nbsp; &nbsp;Full &#039;Windows&#039; style facilities, text, vectors, bitmaps, GUIs.</p><p>Both of the above can be used completely withing Fortran source files.<br />No Java, or C.&nbsp; Nothing but Fortran calls and functions.</p>]]></description>
			<author><![CDATA[null@example.com (JohnWasilewski)]]></author>
			<pubDate>Thu, 08 Oct 2020 13:36:10 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3615#p3615</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3613#p3613</link>
			<description><![CDATA[<p>Carlos,</p><p>AppGraphics doesn&#039;t expose any of the Windows API, so applying a cairo surface to an AppGraphics window would be a problem.&nbsp; Specifically, the <em>initwindow</em> call returns an integer that corresponds to an internal library array that tracks the windows handle (the HWND value) internally only.&nbsp; There isn&#039;t a supported way of retrieving this value.</p><p>The problem actually gets messier because, even if we did provide a way to get the handle, using a cairo surface probably still wouldn&#039;t work.&nbsp; In order to effectively apply static display of drawn graphics in an AppGraphics window, the library dispatches a new thread to handle presenting the window and responding to Windows messages.&nbsp; The actual drawing requested by the user is always performed on an internal bitmap which is then copied to the actual visual window whenever painting is requested.&nbsp; If you tried to attach a cairo surface to an AppGraphics window, this automatic, threaded redrawing would actually overwrite the cairo surface over and over again.&nbsp; </p><p>So while the window handle isn&#039;t exposed to the user at all (making calls to <em>GetDC</em> difficult), the actual architecture of AppGraphics would make this task fail anyway.</p><p>However, I do understand wanting to use cairo.&nbsp; Creating and managing a window in Windows is difficult, though.&nbsp; Let me see if I can think of a good way to do this instead of working through AppGraphics.&nbsp; There&#039;s only a bit of C code to get a window open and attach cairo to the drawing context.</p>]]></description>
			<author><![CDATA[null@example.com (jeff)]]></author>
			<pubDate>Wed, 07 Oct 2020 23:45:06 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3613#p3613</guid>
		</item>
		<item>
			<title><![CDATA[Cairo calling]]></title>
			<link>https://forums.approximatrix.com/viewtopic.php?pid=3612#p3612</link>
			<description><![CDATA[<p>Jeff,<br />Thanks to the Simply Fortran magic, I have been able to call <br />Cairo graphics library (almost) directly from Fortran. I just created SF project <br />with two files:<br />(fortran code )<br />!!!<br />program cairo_two<br />&nbsp; &nbsp; use iso_c_binding<br />&nbsp; &nbsp; implicit none<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; interface<br />&nbsp; &nbsp; &nbsp; &nbsp; subroutine spiral_png (a, b) bind (c, name = &#039;spiral_png&#039;)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ! plots spiral shape with label text at position a, b<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; use iso_c_binding<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; real(c_float), value :: a, b<br />&nbsp; &nbsp; &nbsp; &nbsp; end subroutine<br />&nbsp; &nbsp; end interface<br />&nbsp; &nbsp; !<br />&nbsp; &nbsp; real a, b<br />&nbsp; &nbsp; a = 40.0<br />&nbsp; &nbsp; b = 60.0<br />&nbsp; &nbsp; print *, &quot;Fortran calling Cairo void function spiral_png&quot;<br />&nbsp; &nbsp; call spiral_png(a, b)<br />end program<br />!!!<br />(and C-code)<br />!!!<br />/* C source to be compiled by SF, no main function */<br />#include &lt;cairo.h&gt;<br />#define _USE_MATH_DEFINES<br />#include &lt;math.h&gt;<br />/* spiral png*/<br />void spiral_png(float a, float b) {<br />&nbsp; &nbsp; cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 800, 800);<br />&nbsp; &nbsp; cairo_t *cr = cairo_create(surface);<br />&nbsp; &nbsp; cairo_set_source_rgb(cr, 1, 1, 1);<br />&nbsp; &nbsp; cairo_paint(cr);<br />&nbsp; &nbsp; cairo_set_source_rgb(cr, 0, 0, 0);<br />&nbsp; &nbsp; for (int i = 0; i &lt;= 10000; i++) {<br />&nbsp; &nbsp; &nbsp; &nbsp; double x = 400 + cos(2 * M_PI * i / 500) * 140 + cos(2 * M_PI * i / 10000) * 220;<br />&nbsp; &nbsp; &nbsp; &nbsp; double y = 400 + sin(2 * M_PI * i / 500) * 140 + sin(2 * M_PI * i / 10000) * 220;<br />&nbsp; &nbsp; &nbsp; &nbsp; if (i == 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cairo_move_to(cr, x, y);<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cairo_line_to(cr, x, y);<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; cairo_close_path(cr);<br />&nbsp; &nbsp; cairo_stroke(cr);<br />&nbsp; &nbsp; cairo_select_font_face(cr, &quot;Sans&quot;, CAIRO_FONT_SLANT_NORMAL,<br />&nbsp; &nbsp; CAIRO_FONT_WEIGHT_NORMAL);<br />&nbsp; &nbsp; cairo_set_font_size(cr, 40.0);<br />&nbsp; &nbsp; cairo_move_to(cr, a, b);<br />&nbsp; &nbsp; cairo_show_text(cr, &quot;Spiral&quot;);<br />&nbsp; &nbsp; cairo_surface_write_to_png(surface, &quot;spiral.png&quot;);<br />&nbsp; &nbsp; cairo_destroy(cr);<br />&nbsp; &nbsp; cairo_surface_destroy(surface);<br />}<br />!!!!<br />Project compiles and PNG file with a nice plot is created. <br />My question is: How to draw on window created by AppGraphics?<br />Win32/GDI/C programming is high above me, but I tried blindly:<br />...<br />#include &lt;cairo-win32.h&gt;<br />#include &lt;appgraphics.h&gt;<br />...<br />void spiral_gdi(float a, float b) {<br />&nbsp; &nbsp; int wiha;<br />&nbsp; &nbsp; wiha = initwindow(800, 800,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;Cairo drawing&quot;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT_POSITION, DEFAULT_POSITION,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FALSE,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TRUE);<br />&nbsp; &nbsp; HDC dc = GetDC(wiha);<br />&nbsp; &nbsp; cairo_surface_t *surface = cairo_win32_surface_create(dc);<br />&nbsp; &nbsp; ReleaseDC(wiha, dc);<br />...<br />...<br />I don&#039;t know if it has any sense, since I have got compile error<br />(..undefined reference to `initwindow&#039;).<br />Any help is appreciated,<br />Carlos,<br />BTW, Cairo binaries came from <a href="https://github.com/preshing/cairo-windows/releases">https://github.com/preshing/cairo-windows/releases</a></p>]]></description>
			<author><![CDATA[null@example.com (Carlos Herrera)]]></author>
			<pubDate>Wed, 07 Oct 2020 13:32:22 +0000</pubDate>
			<guid>https://forums.approximatrix.com/viewtopic.php?pid=3612#p3612</guid>
		</item>
	</channel>
</rss>
