Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
52
Task/Window-creation/Nim/window-creation-1.nim
Normal file
52
Task/Window-creation/Nim/window-creation-1.nim
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
import
|
||||
gdk2, glib2, gtk2
|
||||
|
||||
proc thisDestroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
const
|
||||
Inside: cstring = "Mouse is over label"
|
||||
OutSide: cstring = "Mouse is not over label"
|
||||
|
||||
var
|
||||
OverButton: bool
|
||||
|
||||
nim_init()
|
||||
var window = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
var stackbox = vbox_new(TRUE, 10)
|
||||
var button1 = button_new("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)
|
||||
var button3 = button_new("Quit")
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
add(button2, ALAbel)
|
||||
pack_start(stackbox, button1, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, button2, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, button3, TRUE, TRUE, 0)
|
||||
set_border_width(Window, 5)
|
||||
add(window, stackbox)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(thisDestroy), nil)
|
||||
overbutton = False
|
||||
discard signal_connect(button1, "enter_notify_event",
|
||||
SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
discard signal_connect(button1, "leave_notify_event",
|
||||
SIGNAL_FUNC(ChangeLabel), addr(OverButton))
|
||||
discard signal_connect(button3, "clicked",
|
||||
SIGNAL_FUNC(thisDestroy), nil)
|
||||
show_all(window)
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue