mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-05 23:22:25 +00:00
gtk example
This commit is contained in:
parent
9fb89d2a14
commit
97181a4b8d
10 changed files with 730 additions and 0 deletions
88
src/test/Gtk/G.Mod
Normal file
88
src/test/Gtk/G.Mod
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
(***************************************************************************
|
||||
Project: G
|
||||
Purpose: Interface to Gtk GLib
|
||||
Version: 2.0
|
||||
Predecessor: Glib
|
||||
Changes: don't repeat 'g_' at the beginning of the names, change some
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: jan 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE G (*[INTERFACE "C"; LINK LIB "glib-2.0" ADD_OPTION LibGladePrefix END]*);
|
||||
|
||||
IMPORT SYSTEM;
|
||||
|
||||
CONST
|
||||
FALSE* = 0;
|
||||
TRUE* = 1; (* original: #define TRUE (!FALSE) *)
|
||||
|
||||
TYPE
|
||||
boolean* = LONGINT;
|
||||
char* = CHAR;
|
||||
float* = REAL;
|
||||
double* = LONGREAL;
|
||||
int* = LONGINT;
|
||||
size* = LONGINT;
|
||||
ssize* = LONGINT;
|
||||
uint* = LONGINT;
|
||||
uint8* = CHAR;
|
||||
uint16* = INTEGER;
|
||||
uint32* = LONGINT;
|
||||
ulong* = LONGINT;
|
||||
ushort* = INTEGER;
|
||||
Quark* = LONGINT;
|
||||
|
||||
VoidPtr* = SYSTEM.PTR;
|
||||
ArrayPtr* = VoidPtr;
|
||||
DataPtr* = VoidPtr;
|
||||
pointer* = VoidPtr;
|
||||
SListPtr* = VoidPtr;
|
||||
TypeClassPtr* = VoidPtr;
|
||||
|
||||
string* = POINTER (*[ CSTRING ]*) TO ARRAY OF char;
|
||||
|
||||
VoidFunc* = PROCEDURE ();
|
||||
|
||||
ErrorPtr*= POINTER TO Error;
|
||||
Error* = RECORD
|
||||
domain*: Quark;
|
||||
code*: int;
|
||||
message*: string;
|
||||
END;
|
||||
|
||||
TypeInstance* = RECORD (* gtype.h *)
|
||||
gClass*: TypeClassPtr
|
||||
END;
|
||||
|
||||
Object* = RECORD (* gobject.h *)
|
||||
gTypeInstance*: TypeInstance;
|
||||
refCount*: uint;
|
||||
qdata*: DataPtr
|
||||
END;
|
||||
|
||||
(*
|
||||
PROCEDURE -includeglib()
|
||||
"#include <glib-2.0/glib.h>";
|
||||
|
||||
PROCEDURE -includegmem()
|
||||
"#include <glib-2.0/glib/gmem.h>";
|
||||
|
||||
PROCEDURE -includegconvert()
|
||||
"#include <glib-2.0/glib/gconvert.h";
|
||||
*)
|
||||
PROCEDURE (*["g_free"]*) -free* (mem:pointer)
|
||||
"g_free(mem)";
|
||||
(* 2 versions of g_localeto_utf8: first for using param.'error', second for
|
||||
calling the proc.with act.param.'NIL', t.i. not using it.*)
|
||||
(*PROCEDURE g_locale_to_utf8* (opsysstring:Ptr_gchar; len:gssize;
|
||||
VAR bytes_read,bytes_written:gsize; VAR error:GErrorPtr): Ptr_gchar;*)
|
||||
PROCEDURE (*["g_locale_to_utf8"]*) -localeToUtf8* (opsysstring:string; len:ssize;
|
||||
VAR bytesRead,bytesWritten:size; error:VoidPtr): string
|
||||
"(G_string)g_locale_to_utf8 (opsysstring, len, bytesRead, bytesWritten, size)";
|
||||
|
||||
END G.
|
||||
|
||||
204
src/test/Gtk/Gdk.Mod
Normal file
204
src/test/Gtk/Gdk.Mod
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
(***************************************************************************
|
||||
Project: Gdk
|
||||
Purpose: Interface
|
||||
Version: 2.0
|
||||
Predecessor: GTK
|
||||
Changes: don't repeat 'g_' at the beginning of the names, change some
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: jan 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE Gdk
|
||||
(*[INTERFACE "C"; LINK LIB "gdk-x11-2.0" ADD_OPTION LibGladePrefix END]*);
|
||||
|
||||
IMPORT G, Pango, SYSTEM;
|
||||
|
||||
CONST
|
||||
GravityNorthWest* = 1;
|
||||
HintMinSize* = 2;
|
||||
|
||||
(* GdkFunction *)
|
||||
Copy* = 00H;
|
||||
Invert* = 01H;
|
||||
XOR* = 02H;
|
||||
Clear* = 03H;
|
||||
And* = 04H;
|
||||
AndReverse* = 05H;
|
||||
AndInvert* = 06H;
|
||||
Noop* = 07H;
|
||||
Or* = 08H;
|
||||
Equiv* = 09H;
|
||||
OrReverse* = 0AH;
|
||||
CopyInvert* = 0BH;
|
||||
OrInvert* = 0CH;
|
||||
Nand* = 0DH;
|
||||
Set* = 0EH;
|
||||
|
||||
(* GdkCapStyle *)
|
||||
CapNotLastT* = 0;
|
||||
CapButt* = 1;
|
||||
CapRound* = 2;
|
||||
CapProjecting* = 3;
|
||||
|
||||
(* GdkJoinStyle *)
|
||||
JoinMiter* = 0;
|
||||
JoinRound* = 1;
|
||||
JounBevel* = 2;
|
||||
|
||||
(* GdkLineStyle *)
|
||||
LineSolid* = 0;
|
||||
LineOnOffDash* = 1;
|
||||
LineDoubleDash* = 2;
|
||||
|
||||
TYPE
|
||||
ColormapPtr* = G.VoidPtr;
|
||||
EventPtr* = G.VoidPtr;
|
||||
EventExposePtr* = G.VoidPtr;
|
||||
FontPtr* = G.VoidPtr;
|
||||
CPtr* = G.VoidPtr;
|
||||
ImagePtr* = G.VoidPtr;
|
||||
PixmapPtr* = G.VoidPtr;
|
||||
|
||||
ColorPtr* = POINTER TO Color;
|
||||
Color* = RECORD
|
||||
pixel* : G.uint32;
|
||||
red*, green*, blue*: G.uint16;
|
||||
END;
|
||||
|
||||
DrawablePtr* = POINTER TO Drawable;
|
||||
Drawable* = RECORD (* gdkdrawable.h *)
|
||||
parentInstance*: G.Object
|
||||
END;
|
||||
|
||||
GCValuesPtr* = POINTER TO GCValues;
|
||||
GCValues* = RECORD
|
||||
foreground*, background*: Color;
|
||||
font*: FontPtr;
|
||||
function*, fill*: G.int;
|
||||
tile*, stipple*, clipMask*: PixmapPtr;
|
||||
subwindowMode*,
|
||||
tsXOrigin*, tsYOrigin*,
|
||||
clipXOrigin*, clipYOrigin*,
|
||||
graphicsExposures*, lineWidth*,
|
||||
lineStyle*, capStyle*, joinStyle*: G.int
|
||||
END;
|
||||
|
||||
GeometryPtr* = POINTER TO Geometry;
|
||||
Geometry* = RECORD
|
||||
minWidth*, minHeight*,
|
||||
maxWidth*, maxHeight*,
|
||||
baseWidth*, baseHeight*,
|
||||
widthInc*, heightInc*: G.int;
|
||||
minAspect*, maxAspect*: G.double;
|
||||
winGravity*: G.int;
|
||||
END;
|
||||
|
||||
RectanglePtr* = POINTER TO Rectangle;
|
||||
Rectangle*= RECORD (* gdktypes.h *)
|
||||
x*, y*, width*, height*: G.int
|
||||
END;
|
||||
|
||||
Window* = Drawable; (* gdktypes.h *)
|
||||
WindowPtr* = DrawablePtr;
|
||||
|
||||
(*
|
||||
PROCEDURE -includeGdkColor()
|
||||
"#include <gtk-2.0/gdk/gdkcolor.h>";
|
||||
|
||||
PROCEDURE -includeGdkDrawable()
|
||||
"#include <gtk-2.0/gdk/gdkdrawable.h>";
|
||||
|
||||
PROCEDURE -includeGdkGc()
|
||||
"#include <gtk-2.0/gdk/gdkgc.h>";
|
||||
|
||||
PROCEDURE -includeGkdImage()
|
||||
"#include <gtk-2.0/gdk/gdkimage.h>";
|
||||
|
||||
PROCEDURE -includeGdkPixmap()
|
||||
"#include <gtk-2.0/gdk/gdkpixmap.h>";
|
||||
*)
|
||||
PROCEDURE (*["gdk_colormap_alloc_color"]*) -colormapAllocColor*
|
||||
(colormap:ColormapPtr; color:ColorPtr;
|
||||
writeable,bestMatch:G.boolean): G.boolean
|
||||
"(G_boolean)gdk_colormap_alloc_color(colormap, color, writeable, bestMatch)";
|
||||
|
||||
PROCEDURE (*["gdk_colormap_get_system"]*) -colormapGetSystem* (): ColormapPtr
|
||||
"(Gdk_ColormapPtr)gdk_colormap_get_system ()";
|
||||
|
||||
PROCEDURE (*["gdk_draw_arc"]*) -drawArc* (drawable:DrawablePtr; gc:CPtr;
|
||||
filled:G.boolean; x,y,width,height,angle1,angle2:G.int)
|
||||
"gdk_draw_arc(drawable, gc, filled, x, y, width, height, angle1, angle2)";
|
||||
|
||||
PROCEDURE (*["gdk_draw_image"]*) -drawImage* (drawable:DrawablePtr;
|
||||
gc:CPtr; image:ImagePtr; xsrc,ysrc,xdest,ydest,width,height:G.int)
|
||||
"gdk_draw_image(drawable, gc, image, xsrc, ysrc, xdest, ydest, width, height)";
|
||||
|
||||
PROCEDURE (*["gdk_draw_layout"]*) -drawLayout* (drawable:DrawablePtr;
|
||||
gc:CPtr; x,y:G.int; layout:Pango.LayoutPtr)
|
||||
"gdk_draw_layout(drawable, gc, x, y, layout)";
|
||||
|
||||
PROCEDURE (*["gdk_draw_line"]*) -drawLine* (drawable:DrawablePtr;
|
||||
gc:CPtr; x1,y1,x2,y2:G.int)
|
||||
"gdk_draw_line(drawable, gc, x1, y1, x2, y2)";
|
||||
|
||||
PROCEDURE (*["gdk_draw_point"]*) -drawPoint* (drawable:DrawablePtr;
|
||||
gc:CPtr; x,y:G.int)
|
||||
"gdk_draw_point(drawable, gc, x, y)";
|
||||
|
||||
PROCEDURE (*["gdk_draw_rectangle"]*) -drawRectangle* (drawable:DrawablePtr;
|
||||
gc:CPtr; filled:G.boolean; x, y, width, height : G.int)
|
||||
"gdk_draw_rectangle(drawable, gc, filled, x, y, width, height)";
|
||||
|
||||
PROCEDURE (*["gdk_drawable_get_image"]*) -drawableGetImage* (drawable : DrawablePtr; x, y, width, height : G.int): ImagePtr
|
||||
"(Gdk_ImagePtr)gdk_drawable_get_image(drawable, x, y, width, height)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_get_values"]*) -gcGetValues* (gc:CPtr; VAR values:GCValues)
|
||||
"gdk_gc_get_values(gc, values)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_new"]*) -gcNew* (drawable:DrawablePtr): CPtr
|
||||
"(Gdk_PCtr)gdk_gc_new(drawable)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_background"]*) -gcSetBackground*(gc:CPtr; color:ColorPtr)
|
||||
"gdk_gc_set_background(gc, color)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_clip_origin"]*) -gcSetClipOrigin* (gc:CPtr; x,y:G.int)
|
||||
"gdk_gc_set_clip_origin(gc, x, y)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_clip_rectangle"]*) -gcSetClipRectangle* (gc:CPtr; rectangle:RectanglePtr)
|
||||
"gdk_gc_set_clip_rectangle(gc, rectangle)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_foreground"]*) -gcSetForeground* (gc:CPtr; color:ColorPtr)
|
||||
"gdk_gc_set_foreground(gc, color)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_function"]*) -gcSetFunction* (gc:CPtr; function:G.int)
|
||||
"gdk_gc_set_function(gc, function)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_line_attributes"]*) -gcSetLineAttributes*
|
||||
(gc:CPtr; lineWidth,lineStyle,capStyle,joinStyle:G.int)
|
||||
"gdk_gc_set_line_attributes(gc, lineWidth, lineStyle, capStyle, joinStyle)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_rgb_fg_color"]*) -gcSetRgbFgColor*(gc:CPtr; color:ColorPtr)
|
||||
"gdk_gc_set_rgb_fg_color(gc, color)";
|
||||
|
||||
PROCEDURE (*["gdk_gc_set_rgb_bg_color"]*) -gcSetRgbBgColor*
|
||||
(gc:CPtr; color:ColorPtr)
|
||||
"gdk_gc_set_rgb_bg_color(gc, color)";
|
||||
|
||||
PROCEDURE (*["gdk_image_get_pixel"]*) -imageGetPixel*
|
||||
(image:ImagePtr; x,y:G.int): G.uint32
|
||||
"(G_uint32)gdk_image_get_pixel(image, x, y)";
|
||||
|
||||
PROCEDURE (*["gdk_image_put_pixel"]*) -imagePutPixel*
|
||||
(image:ImagePtr; x,y:G.int; pixel:G.uint32)
|
||||
"gdk_image_put_pixel(image, x, y, pixel)";
|
||||
|
||||
PROCEDURE (*["gdk_pixmap_new"]*) -pixmapNew*
|
||||
(drawable:DrawablePtr; width,height,depth:G.int): PixmapPtr
|
||||
"(Gdk_PixmapPtr)gdk_pixmap_new(drawable, width, height, depth)";
|
||||
|
||||
END Gdk.
|
||||
|
||||
44
src/test/Gtk/Glade.Mod
Normal file
44
src/test/Gtk/Glade.Mod
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
(***************************************************************************
|
||||
Project: Glade
|
||||
Purpose: Interface
|
||||
Version: 1.0
|
||||
Predecessor: -
|
||||
Changes: -
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: jan 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE Glade
|
||||
(*[INTERFACE "C"; LINK LIB "glade-2.0" ADD_OPTION LibGladePrefix END]*);
|
||||
|
||||
IMPORT
|
||||
SYSTEM, Gtk;
|
||||
|
||||
TYPE
|
||||
|
||||
String* = ARRAY 256 OF CHAR;
|
||||
GString = ARRAY 16000 OF CHAR;
|
||||
CString* = POINTER (*[CSTRING]*) TO String;
|
||||
XMLPtr* = (*SYSTEM.PTR*) POINTER TO GString;
|
||||
|
||||
(*
|
||||
PROCEDURE -includeGladeXml()
|
||||
"#include <libglade-2.0/glade/glade-xml.h>";
|
||||
*)
|
||||
PROCEDURE (*["glade_xml_new"]*) -xmlNew*
|
||||
(fname,root,domain:CString): XMLPtr
|
||||
"(Glade_XMLPtr)glade_xml_new(fname, root, domain)";
|
||||
|
||||
PROCEDURE (*["glade_xml_signal_autoconnect"]*) -xmlSignalAutoconnect*
|
||||
(self:XMLPtr)
|
||||
"glade_xml_signal_autoconnect(self)";
|
||||
|
||||
PROCEDURE (*["glade_xml_get_widget"]*) -xmlGetWidget*
|
||||
(self:XMLPtr; name:CString): Gtk.WidgetPtr
|
||||
"(Gtk_WidgetPtr)glade_xml_get_widget(self, name)";
|
||||
|
||||
END Glade.
|
||||
102
src/test/Gtk/Gtk.Mod
Normal file
102
src/test/Gtk/Gtk.Mod
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
(***************************************************************************
|
||||
Project: Gtk
|
||||
Purpose: Interface
|
||||
Version: 2.0
|
||||
Predecessor: GTK 1.1
|
||||
Changes: don't repeat 'gtk_' at the beginning of the names
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: jan 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE Gtk
|
||||
(*[INTERFACE "C"; LINK LIB "gtk-x11-2.0" ADD_OPTION LibGladePrefix END]*);
|
||||
|
||||
IMPORT G, Gdk, Pango, SYSTEM;
|
||||
|
||||
CONST
|
||||
WindowToplevel* = 0;
|
||||
(* GtkAttachOptions *)
|
||||
EXPAND* = 1;
|
||||
SHRINK* = 2;
|
||||
FILL* = 4;
|
||||
(* GtkButtonsType *)
|
||||
ButtonsNone* = 0;
|
||||
ButtonsOk* = 1;
|
||||
ButtonsClose* = 2;
|
||||
ButtonsCancel* = 3;
|
||||
ButtonsYesNo* = 4;
|
||||
ButtonsOkCancel* = 5;
|
||||
(* GtkDialogFlags *)
|
||||
DialogModal* = 1;
|
||||
DialogDestroyWithParent* = 2;
|
||||
DialogNoSeparator* = 4;
|
||||
(* GtkMessageType *)
|
||||
MessageInfo* = 0;
|
||||
MessageWarning* = 1;
|
||||
MessageQuestion* = 2;
|
||||
MessageError* = 3;
|
||||
|
||||
TYPE
|
||||
Object* = RECORD (* gtkobject.h *)
|
||||
parentInstance*: G.Object;
|
||||
flags*: G.uint32
|
||||
END;
|
||||
RcStylePtr = G.VoidPtr;
|
||||
Allocation = Gdk.Rectangle;
|
||||
|
||||
StylePtr* = POINTER TO Style;
|
||||
Style* = RECORD (* gtkstyle.h *)
|
||||
parentInstance*: G.Object;
|
||||
fg*, bg*, light*, dark*, mid*, text*,
|
||||
base*, textAa*: ARRAY 5 OF Gdk.Color;
|
||||
black*, white*: Gdk.Color;
|
||||
fontDesc*: Pango.FontDescriptionPtr;
|
||||
xthickness*, ythickness*: G.int;
|
||||
fgGc*, bgGc*, lightGc*, darkGc*,
|
||||
midGc*, textGc*, baseGc*, textAaGc*: ARRAY 5 OF Gdk.CPtr;
|
||||
blackGc*, whiteGc*: Gdk.CPtr;
|
||||
bgPixmap*: ARRAY 5 OF Gdk.PixmapPtr;
|
||||
attachCount*, depth*: G.int;
|
||||
colormap*: Gdk.ColormapPtr;
|
||||
privateFont*: Gdk.FontPtr;
|
||||
privateFontDesc*: Pango.FontDescriptionPtr;
|
||||
rcStyle*: RcStylePtr;
|
||||
styles*: G.SListPtr;
|
||||
propertyCache*: G.ArrayPtr;
|
||||
iconFactories*: G.SListPtr
|
||||
END;
|
||||
|
||||
Requisition* = RECORD (* gtkwidget.h *)
|
||||
width*, height*: G.int
|
||||
END;
|
||||
|
||||
WidgetPtr* = POINTER TO Widget;
|
||||
Widget* = RECORD (* gtkwidget.h *)
|
||||
object*: Object;
|
||||
privateFlags*: G.uint16;
|
||||
state*: G.uint8;
|
||||
savedState*: G.uint8;
|
||||
name*: G.string;
|
||||
style*: StylePtr;
|
||||
requisition*: Requisition;
|
||||
allocation*: Allocation;
|
||||
window*: Gdk.WindowPtr;
|
||||
parent*: WidgetPtr
|
||||
END;
|
||||
|
||||
ArgVector* = POINTER TO ARRAY OF POINTER TO ARRAY OF CHAR;
|
||||
(*
|
||||
PROCEDURE -includeGtk()
|
||||
"#include <gtk-2.0/gtk/gtkmain.h>";
|
||||
*)
|
||||
PROCEDURE (*["gtk_init"]*) -init* (VAR argc:LONGINT; VAR argv:ArgVector)
|
||||
"gtk_init(argc, argv)";
|
||||
|
||||
PROCEDURE (*["gtk_main"]*) -main*
|
||||
"gtk_main()";
|
||||
|
||||
END Gtk.
|
||||
61
src/test/Gtk/HelloWorld.Mod
Normal file
61
src/test/Gtk/HelloWorld.Mod
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
(***************************************************************************
|
||||
Project: HelloWorld
|
||||
Purpose: A libglade-Hello-World with oo2c
|
||||
Version: 1.0
|
||||
Predecessor: -
|
||||
Changes: -
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: Jan. 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE HelloWorld;
|
||||
|
||||
IMPORT
|
||||
SYSTEM, Args, Out := Console, G, Gdk, Gtk, Glade, handlers;
|
||||
|
||||
CONST
|
||||
(*GUIFILE = "gui.glade";*)
|
||||
ERRXML = 1; (* xml file problem *)
|
||||
ERRNOTFOUND = 2; (* widget not found *)
|
||||
|
||||
VAR
|
||||
argc : LONGINT;
|
||||
argv : Gtk.ArgVector;
|
||||
xml: Glade.XMLPtr;
|
||||
drawing: Gtk.WidgetPtr;
|
||||
GuiFile, name: Glade.CString;
|
||||
|
||||
PROCEDURE (*["Hello"]*) Hello* (widget:Gtk.WidgetPtr; data:SYSTEM.PTR);
|
||||
BEGIN
|
||||
Out.String("Hello, world!"); Out.Ln;
|
||||
END Hello;
|
||||
|
||||
|
||||
PROCEDURE (*["Draw"]*) Draw* (widget:Gtk.WidgetPtr;
|
||||
event:Gdk.EventExposePtr; data:G.pointer): G.boolean;
|
||||
VAR a: G.int;
|
||||
BEGIN
|
||||
a:= widget.allocation.width DIV 2;
|
||||
Gdk.drawArc (widget.window, widget.style.fgGc[ORD(widget.state)], G.TRUE,
|
||||
a DIV 2, a DIV 2, a, a, 0, 64*360);
|
||||
RETURN G.TRUE;
|
||||
END Draw;
|
||||
|
||||
BEGIN
|
||||
argc:= Args.argc;
|
||||
argv:= SYSTEM.VAL (Gtk.ArgVector, Args.argv);
|
||||
Gtk.init (argc, argv);
|
||||
NEW(GuiFile);
|
||||
COPY("gui.glade", GuiFile^);
|
||||
xml:= Glade.xmlNew (GuiFile, NIL, NIL);
|
||||
ASSERT (SYSTEM.VAL(SYSTEM.PTR, xml)#NIL, ERRXML);
|
||||
Glade.xmlSignalAutoconnect (xml);
|
||||
NEW(name); COPY("drawing", name^);
|
||||
drawing:= Glade.xmlGetWidget (xml, name);
|
||||
ASSERT (drawing#NIL, ERRNOTFOUND);
|
||||
Gtk.main;
|
||||
END HelloWorld.
|
||||
90
src/test/Gtk/Pango.Mod
Normal file
90
src/test/Gtk/Pango.Mod
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
(***************************************************************************
|
||||
Project: Pango
|
||||
Purpose: Interface
|
||||
Version: 2.0
|
||||
Predecessor:
|
||||
Changes: don't repeat 'g_' at the beginning of the names, change some
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: jan 2009
|
||||
Author: Frank Hrebabetzky
|
||||
|
||||
-- converted to use with voc by noch
|
||||
***************************************************************************)
|
||||
|
||||
MODULE Pango
|
||||
(*[INTERFACE "C"; LINK LIB "pango-1.0" ADD_OPTION LibGTKPrefix END]*);
|
||||
|
||||
IMPORT G, SYSTEM;
|
||||
|
||||
CONST
|
||||
SCALE* = 1024;
|
||||
|
||||
TYPE
|
||||
ContextPtr* = G.VoidPtr;
|
||||
FontDescriptionPtr* = G.VoidPtr;
|
||||
FontPtr* = G.VoidPtr;
|
||||
LanguagePtr* = G.VoidPtr;
|
||||
LayoutPtr* = G.VoidPtr;
|
||||
|
||||
FontMetricsPtr* = POINTER TO FontMetrics;
|
||||
FontMetrics* = RECORD
|
||||
refCount*: G.uint;
|
||||
ascent*, descent*,
|
||||
approximateCharWidth*,
|
||||
approximateDigitWidth*: G.int
|
||||
END;
|
||||
|
||||
RectanglePtr* = POINTER TO Rectangle;
|
||||
Rectangle* = RECORD
|
||||
x*, y*, width*, height*: G.int
|
||||
END;
|
||||
(*
|
||||
PROCEDURE -includePangoContext()
|
||||
"#include <pango-1.0/pango/pango-context.h>";
|
||||
|
||||
PROCEDURE -includePangoFont()
|
||||
"#include <pango-1.0/pango/pango-font.h>";
|
||||
|
||||
PROCEDURE -includePangoLayout()
|
||||
"#include <pango-1.0/pango/pango-layout.h>";
|
||||
*)
|
||||
|
||||
|
||||
|
||||
PROCEDURE (*["pango_context_get_metrics"]*) -contextGetMetrics*
|
||||
(context:ContextPtr; desc:FontDescriptionPtr; language:LanguagePtr):
|
||||
FontMetricsPtr
|
||||
"(FontMetricsPtr)pango_context_get_metrics(context, desc, language)";
|
||||
|
||||
PROCEDURE (*["pango_font_description_from_string"]*) -fontDescriptionFromString*
|
||||
(str:G.string): FontDescriptionPtr
|
||||
"(Pango_FontDescriptorPtr)pango_font_description_from_string(str)";
|
||||
|
||||
PROCEDURE (*["pango_font_get_metrics"]*) -fontGetMetrics*
|
||||
(font:FontPtr; language:LanguagePtr): FontMetricsPtr
|
||||
"(Pango_FontMetricsPtr)pango_font_get_metrics(font, language)";
|
||||
|
||||
PROCEDURE (*["pango_font_metrics_unref"]*) -fontMetricsUnref*
|
||||
(metrics:FontMetricsPtr)
|
||||
"pango_font_metrics_unref(metrics)";
|
||||
|
||||
PROCEDURE (*["pango_layout_get_pixel_extents"]*) -layoutGetPixelExtents*
|
||||
(layout:LayoutPtr; VAR inkRect,logicalRect:Rectangle)
|
||||
"pango_layout_get_pixel_extents(layout, incRect, logicalRect)";
|
||||
|
||||
PROCEDURE (*["pango_layout_get_pixel_size"]*) -layoutGetPixelSize*
|
||||
(layout:LayoutPtr; VAR width,height:G.int)
|
||||
"pango_layout_get_pixel_size(layout, width, height)";
|
||||
|
||||
|
||||
PROCEDURE (*["pango_layout_set_font_description"]*) -layoutSetFontDescription*
|
||||
(layout:LayoutPtr; desc:FontDescriptionPtr)
|
||||
"pango_layout_set_font_description(layout, desc)";
|
||||
|
||||
PROCEDURE (*["pango_layout_set_text"]*) -layoutSetText*
|
||||
(layout:LayoutPtr; text:G.string; length:G.int)
|
||||
"pango_layout_set_text(layout, text, lenght)";
|
||||
|
||||
END Pango.
|
||||
|
||||
1
src/test/Gtk/Readme.md
Normal file
1
src/test/Gtk/Readme.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
this is an example how to write gtk applications with vishap oberon compiler
|
||||
85
src/test/Gtk/gui.glade
Normal file
85
src/test/Gtk/gui.glade
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<glade-interface>
|
||||
<!-- interface-requires gtk+ 2.6 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<widget class="GtkWindow" id="winMain">
|
||||
<property name="width_request">250</property>
|
||||
<property name="height_request">150</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">OOC-Glade-Test</property>
|
||||
<property name="resizable">False</property>
|
||||
<signal name="destroy_event" handler="gtk_main_quit" />
|
||||
<signal name="delete_event" handler="gtk_main_quit" />
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hboxMain">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vboxLeft">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Print to stdout</property>
|
||||
<property name="single_line_mode">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkButton" id="button">
|
||||
<property name="label" translatable="yes">Hello</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="handlers_Hello"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="padding">8</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkVSeparator" id="vsep">
|
||||
<property name="width_request">2</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkDrawingArea" id="drawing">
|
||||
<property name="visible">True</property>
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="expose_event" handler="handlers_Draw"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
34
src/test/Gtk/handlers.Mod
Normal file
34
src/test/Gtk/handlers.Mod
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
(***************************************************************************
|
||||
Project: HelloWorld
|
||||
Purpose: A libglade-Hello-World with oo2c
|
||||
Version: 1.0
|
||||
Predecessor: -
|
||||
Changes: -
|
||||
Target: Linux
|
||||
Compiler: oo2c
|
||||
Date: Jan. 2009
|
||||
Author: Frank Hrebabetzky
|
||||
***************************************************************************)
|
||||
|
||||
MODULE handlers;
|
||||
|
||||
IMPORT
|
||||
SYSTEM, Out := Console, G, Gdk, Gtk;
|
||||
|
||||
PROCEDURE (*["Hello"]*) Hello* (widget:Gtk.WidgetPtr; data:SYSTEM.PTR);
|
||||
BEGIN
|
||||
Out.String("Hello, world!"); Out.Ln;
|
||||
END Hello;
|
||||
|
||||
|
||||
PROCEDURE (*["Draw"]*) Draw* (widget:Gtk.WidgetPtr;
|
||||
event:Gdk.EventExposePtr; data:G.pointer): G.boolean;
|
||||
VAR a: G.int;
|
||||
BEGIN
|
||||
a:= widget.allocation.width DIV 2;
|
||||
Gdk.drawArc (widget.window, widget.style.fgGc[ORD(widget.state)], G.TRUE,
|
||||
a DIV 2, a DIV 2, a, a, 0, 64*360);
|
||||
RETURN G.TRUE;
|
||||
END Draw;
|
||||
|
||||
END handlers.
|
||||
21
src/test/Gtk/makefile
Normal file
21
src/test/Gtk/makefile
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
CFLAGS=`pkg-config --cflags --libs libglade-2.0` -export-dynamic
|
||||
export CFLAGS
|
||||
|
||||
VOC = /opt/voc/bin/voc
|
||||
|
||||
all:
|
||||
$(VOC) -s G.Mod
|
||||
$(VOC) -s Pango.Mod
|
||||
$(VOC) -s Gdk.Mod
|
||||
$(VOC) -s Gtk.Mod
|
||||
$(VOC) -s Glade.Mod
|
||||
$(VOC) -m HelloWorld.Mod
|
||||
|
||||
test0:
|
||||
$(VOC) -s G.Mod Pango.Mod Gdk.Mod Gtk.Mod Glade.Mod handlers.Mod HelloWorld.Mod -m
|
||||
|
||||
clean:
|
||||
rm *.c
|
||||
rm *.h
|
||||
rm *.sym
|
||||
rm *.o
|
||||
Loading…
Add table
Add a link
Reference in a new issue