Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,6 +1,7 @@
---
category:
- Basic language learning
- Simple
note: GUI
requires:
- Graphics

View file

@ -1,35 +1,101 @@
//
#include
"share/atspre_define.hats"
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
staload UN = $UNSAFE
(* ****** ****** *)
staload "{$GLIB}/SATS/glib.sats"
(* ****** ****** *)
staload "{$GTK}/SATS/gdk.sats"
staload "{$GTK}/SATS/gtk.sats"
staload "{$GLIB}/SATS/glib-object.sats"
(* ****** ****** *)
%{^
extern
ats_void_type
mainats (ats_int_type argc, ats_ptr_type argv);
%}
typedef char **charpp ;
%} ;
abstype charpp = $extype"charpp"
staload "contrib/glib/SATS/glib.sats"
staload "contrib/glib/SATS/glib-object.sats"
staload "contrib/GTK/SATS/gtk.sats"
(* ****** ****** *)
extern fun main1 (): void = "main1"
fun hello
(
widget: !GtkWidget1, _: gpointer
) : void = print ("Goodbye, world!\n")
implement main1 () = () where {
val window = gtk_window_new (GTK_WINDOW_TOPLEVEL)
val (pf | title) = gstring_of_string ("Goodbye, World!")
val () = gtk_window_set_title (window, title)
prval () = pf (title)
val _sid = g_signal_connect
(window, (gsignal)"delete-event", (G_CALLBACK)gtk_main_quit, (gpointer)null)
val () = gtk_widget_show (window)
val () = gtk_main ()
val () = gtk_widget_destroy0 (window)
}
fun on_delete_event
(
widget: !GtkWidget1
, event: &GdkEvent, udata: gpointer
) : gboolean = let
val () = print ("delete event occurred\n")
in
GTRUE // handling of delete-event is finished
end // end of [on_delete_event]
implement main_dummy () = ()
fun on_destroy
(widget: !GtkWidget1, _: gpointer): void = gtk_main_quit ()
// end of [on_destroy]
%{$
ats_void_type
mainats (ats_int_type argc, ats_ptr_type argv)
(* ****** ****** *)
macdef nullp = the_null_ptr
(* ****** ****** *)
implement
main0 (argc, argv) =
{
gtk_init ((int*)&argc, (char***)&argv);
main1 ();
return;
}
%}
//
var argc: int = argc
var argv: charpp = $UN.castvwtp1{charpp}(argv)
//
val () = $extfcall (void, "gtk_init", addr@(argc), addr@(argv))
//
val window =
gtk_window_new (GTK_WINDOW_TOPLEVEL)
val () = assertloc (ptrcast(window) > 0)
//
val _(*id*) =
g_signal_connect (
window, (gsignal)"destroy", (G_CALLBACK)on_destroy, (gpointer)nullp
) (* end of [val] *)
val _(*id*) =
g_signal_connect (
window, (gsignal)"delete_event", (G_CALLBACK)on_delete_event, (gpointer)nullp
) (* end of [val] *)
//
val () = gtk_container_set_border_width (window, (guint)10)
val button = gtk_button_new_with_label (gstring("Goodbye, world!"))
val () = assertloc (ptrcast(button) > 0)
//
val () = gtk_widget_show (button)
val () = gtk_container_add (window, button)
val () = gtk_widget_show (window)
//
val _(*id*) =
g_signal_connect
(
button, (gsignal)"clicked", (G_CALLBACK)hello, (gpointer)nullp
)
val _(*id*) =
g_signal_connect_swapped
(
button, (gsignal)"clicked", (G_CALLBACK)gtk_widget_destroy, window
)
//
val () = g_object_unref (button)
val () = g_object_unref (window) // ref-count becomes 1!
//
val ((*void*)) = gtk_main ()
//
} (* end of [main0] *)

View file

@ -0,0 +1,2 @@
# Usage: awk -f hi_win.awk
BEGIN { system("msg * Goodbye, Msgbox !") }

View file

@ -4,7 +4,7 @@
int main(int argc, char **argv) {
Fl_Window *window = new Fl_Window(300,180);
Fl_Box *box = new Fl_Box(20,40,260,100,"Goodby, World!");
Fl_Box *box = new Fl_Box(20,40,260,100,"Goodbye, World!");
box->box(FL_UP_BOX);
box->labelsize(36);
box->labelfont(FL_BOLD+FL_ITALIC);

View file

@ -0,0 +1 @@
s" Goodbye, World!" MsgBox

View file

@ -0,0 +1,3 @@
function love.draw()
love.graphics.print("Goodbye, World!", 400, 300)
end

View file

@ -1,5 +1,8 @@
use strict;
use warnings;
use XUL::Gui;
use QtGui4;
display Label 'Goodbye, World!';
my $app = Qt::Application(\@ARGV);
my $label = Qt::Label('Goodbye, World');
$label->show;
exit $app->exec;

View file

@ -2,6 +2,4 @@ use strict;
use warnings;
use XUL::Gui;
display Button
label => 'Goodbye, World!',
oncommand => sub {quit};
display Label 'Goodbye, World!';

View file

@ -0,0 +1,7 @@
use strict;
use warnings;
use XUL::Gui;
display Button
label => 'Goodbye, World!',
oncommand => sub {quit};

View file

@ -1,6 +1,53 @@
import wx
# HelloWorld for VPython - HaJo Gurt - 2014-09-20
from visual import *
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello, World")
frame.Show(True)
app.MainLoop()
scene.title = "VPython Demo"
scene.background = color.gray(0.2)
scene.width = 600
scene.height = 400
scene.range = 4
#scene.autocenter = True
S = sphere(pos=(0,0,0), radius=1, material=materials.earth)
rot=0.005
txPos=(0, 1.2, 0)
from visual.text import *
# Old 3D text machinery (pre-Visual 5.3): numbers and uppercase letters only:
T1 = text(pos=txPos, string='HELLO', color=color.red, depth=0.3, justify='center')
import vis
# new text object, can render text from any font (default: "sans") :
T2 = vis.text(pos=txPos, text="Goodbye", color=color.green, depth=-0.3, align='center')
T2.visible=False
Lbl_w = label(pos=(0,0,0), text='World', color=color.cyan,
xoffset=80, yoffset=-40) # in screen-pixels
L1 = label(pos=(0,-1.5,0), text='Drag with right mousebutton to rotate view', box=0)
L2 = label(pos=(0,-1.9,0), text='Drag up+down with middle mousebutton to zoom', box=0)
L3 = label(pos=(0,-2.3,0), text='Left-click to change', color=color.orange, box=0)
print "Hello World" # Console
cCount = 0
def change():
global rot, cCount
cCount=cCount+1
print "change:", cCount
rot=-rot
if T1.visible:
T1.visible=False
T2.visible=True
else:
T1.visible=True
T2.visible=False
scene.bind( 'click', change )
while True:
rate(100)
S.rotate( angle=rot, axis=(0,1,0) )

View file

@ -0,0 +1,6 @@
import wx
app = wx.App(False)
frame = wx.Frame(None, wx.ID_ANY, "Hello, World")
frame.Show(True)
app.MainLoop()

View file

@ -0,0 +1 @@
MsgBox("Goodbye, World!")

View file

@ -0,0 +1 @@
MsgBox("Goodbye, World!")

View file

@ -0,0 +1,21 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/*">
<!--
Use a template to insert some text into a simple SVG graphic
with hideous colors.
-->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200">
<rect x="0" y="0" width="400" height="200" fill="cyan"/>
<circle cx="200" cy="100" r="50" fill="yellow"/>
<text x="200" y="115"
style="font-size: 40px;
text-align: center;
text-anchor: middle;
fill: black;">
<!-- The text inside the element -->
<xsl:value-of select="."/>
</text>
</svg>
</xsl:template>
</xsl:stylesheet>

View file

@ -0,0 +1 @@
<message>Goodbye, World!</message>

View file

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200">
<rect x="0" y="0" width="400" height="200" fill="cyan"/>
<circle cx="200" cy="100" r="50" fill="yellow"/>
<text x="200" y="115" style="font-size: 40px;
text-align: center;
text-anchor: middle;
fill: black;">Goodbye, World!</text>
</svg>

After

Width:  |  Height:  |  Size: 315 B