examples/lib use the new wrappers
This commit is contained in:
parent
ddb7185482
commit
b559285b78
133 changed files with 17038 additions and 151734 deletions
|
|
@ -2,46 +2,48 @@
|
|||
import
|
||||
gdk2, glib2, gtk2
|
||||
|
||||
proc destroy(widget: pGtkWidget, data: pgpointer){.cdecl.} =
|
||||
gtk_main_quit()
|
||||
proc destroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
const
|
||||
Inside: cstring = "Mouse is over label"
|
||||
OutSide: cstring = "Mouse is not over label"
|
||||
|
||||
var
|
||||
window, button1, Button2, Alabel, stackbox: PGtkWidget
|
||||
buttonstyle: pgtkstyle
|
||||
OverButton: bool
|
||||
|
||||
proc ChangeLabel(P: PGtkWidget, Event: PGdkEventCrossing, Data: var bool){.cdecl.} =
|
||||
if Not Data: gtk_label_set_text(GTKLABEL(ALabel), Inside)
|
||||
else: gtk_label_set_text(GTKLABEL(ALabel), Outside)
|
||||
nimrod_init()
|
||||
var window = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
var stackbox = vbox_new(TRUE, 10)
|
||||
var button1 = button_new_with_label("Move mouse over button")
|
||||
var buttonstyle = copy(get_style(Button1))
|
||||
ButtonStyle.bg[STATE_PRELIGHT].pixel = 0
|
||||
ButtonStyle.bg[STATE_PRELIGHT].red = -1'i16
|
||||
ButtonStyle.bg[STATE_PRELIGHT].blue = 0'i16
|
||||
ButtonStyle.bg[STATE_PRELIGHT].green = 0'i16
|
||||
set_style(button1, buttonstyle)
|
||||
var button2 = button_new()
|
||||
var ALabel = label_new(Outside)
|
||||
|
||||
|
||||
proc ChangeLabel(P: PWidget, Event: gdk2.PEventCrossing,
|
||||
Data: var bool){.cdecl.} =
|
||||
if Not Data: set_text(ALabel, Inside)
|
||||
else: set_text(ALabel, Outside)
|
||||
Data = Not Data
|
||||
|
||||
gtk_nimrod_init()
|
||||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL)
|
||||
stackbox = gtk_vbox_new(TRUE, 10)
|
||||
button1 = gtk_button_new_with_label("Move mouse over button")
|
||||
buttonstyle = gtk_style_copy(gtk_widget_get_style(Button1))
|
||||
ButtonStyle.bg[GTK_STATE_PRELIGHT].pixel = 0
|
||||
ButtonStyle.bg[GTK_STATE_PRELIGHT].red = 0x0000FFFF'i16
|
||||
ButtonStyle.bg[GTK_STATE_PRELIGHT].blue = 0'i16
|
||||
ButtonStyle.bg[GTK_STATE_PRELIGHT].green = 0'i16
|
||||
gtk_widget_set_style(button1, buttonstyle)
|
||||
button2 = gtk_button_new()
|
||||
ALabel = gtk_label_new(Outside)
|
||||
gtk_container_add(GTK_CONTAINER(button2), ALAbel)
|
||||
gtk_box_pack_start(GTK_BOX(stackbox), button1, TRUE, TRUE, 0)
|
||||
gtk_box_pack_start(GTK_BOX(stackbox), button2, TRUE, TRUE, 0)
|
||||
gtk_container_set_border_width(GTK_CONTAINER(Window), 5)
|
||||
gtk_container_add(GTK_Container(window), stackbox)
|
||||
discard gtk_signal_connect(GTKOBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(destroy), nil)
|
||||
|
||||
add(button2, ALAbel)
|
||||
pack_start(stackbox, button1, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, button2, TRUE, TRUE, 0)
|
||||
set_border_width(Window, 5)
|
||||
add(window, stackbox)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(ex9.destroy), nil)
|
||||
overbutton = False
|
||||
discard gtk_signal_connect(GTKOBJECT(button1), "enter_notify_event",
|
||||
GTK_SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
discard gtk_signal_connect(GTKOBJECT(button1), "leave_notify_event",
|
||||
GTK_SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
gtk_widget_show_all(window)
|
||||
gtk_main()
|
||||
discard signal_connect(button1, "enter_notify_event",
|
||||
SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
discard signal_connect(button1, "leave_notify_event",
|
||||
SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
show_all(window)
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue