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
|
|
@ -0,0 +1,41 @@
|
|||
#Include "windows.bi"
|
||||
|
||||
Dim As HWND Window_Main, Edit_Number, Button_Inc, Button_Rnd
|
||||
Dim As MSG msg
|
||||
Dim As Integer n
|
||||
Dim As String text
|
||||
|
||||
'Create a window with an input field and two buttons:
|
||||
Window_Main = CreateWindow("#32770", "GUI Component Interaction", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 250, 200, 0, 0, 0, 0)
|
||||
Var Static_Number = CreateWindow("STATIC", "Value:", WS_VISIBLE Or WS_CHILD, 10, 10, 100, 20, Window_Main, 0, 0, 0)
|
||||
Edit_Number = CreateWindow("EDIT", "0", WS_BORDER Or WS_VISIBLE Or WS_CHILD Or ES_AUTOHSCROLL Or ES_Number, 110, 10, 100, 20, Window_Main, 0, 0, 0)
|
||||
Button_Inc = CreateWindow("BUTTON", "Increment", WS_VISIBLE Or WS_CHILD, 110, 40, 100, 20, Window_Main, 0, 0, 0)
|
||||
Button_Rnd = CreateWindow("BUTTON", "Random", WS_VISIBLE Or WS_CHILD, 110, 70, 100, 20, Window_Main, 0, 0, 0)
|
||||
|
||||
'Windows message loop:
|
||||
While GetMessage(@msg, Window_Main, 0, 0)
|
||||
TranslateMessage(@msg)
|
||||
DispatchMessage(@msg)
|
||||
Select Case msg.hwnd
|
||||
Case Button_Inc
|
||||
If msg.message = WM_LBUTTONDOWN Then
|
||||
'Increment value:
|
||||
text = Space(GetWindowTextLength(Edit_Number) + 1) 'Buffer for the text
|
||||
GetWindowText(Edit_Number, text, Len(text))
|
||||
n = Val(text)
|
||||
SetWindowText(Edit_Number, Str(n + 1))
|
||||
End If
|
||||
Case Button_Rnd
|
||||
If msg.message = WM_LBUTTONDOWN THEN
|
||||
'Random value (max. 100000):
|
||||
If MessageBox(0, "Set input field to random value?", "Please confirm", MB_ICONQUESTION Or MB_YESNO) = IDYES Then
|
||||
n = 100000 * RND
|
||||
SetWindowText(Edit_Number, Str(n))
|
||||
End If
|
||||
End If
|
||||
Case Window_Main
|
||||
If msg.message = WM_COMMAND Then End
|
||||
End Select
|
||||
Wend
|
||||
|
||||
End
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
import
|
||||
gtk2, gdk2, glib2, strutils, math
|
||||
|
||||
import
|
||||
gtk2, gdk2, glib2, strutils, math
|
||||
|
||||
var valu: int = 0
|
||||
var chngd_txt_hndler: gulong = 0
|
||||
|
||||
proc thisDestroy(widget: PWidget, data: Pgpointer) {.cdecl.} =
|
||||
main_quit()
|
||||
|
||||
randomize()
|
||||
nim_init()
|
||||
var win = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
var content = vbox_new(true,10)
|
||||
var hbox1 = hbox_new(true,10)
|
||||
var hbox2 = hbox_new(false,1)
|
||||
var lbl = label_new("Value:")
|
||||
var entry_fld = entry_new()
|
||||
entry_fld.set_text("0")
|
||||
var btn_quit = button_new("Quit")
|
||||
var btn_inc = button_new("Increment")
|
||||
var btn_rnd = button_new("Random")
|
||||
add(hbox2,lbl)
|
||||
add(hbox2,entry_fld)
|
||||
add(hbox1,btn_inc)
|
||||
add(hbox1,btn_rnd)
|
||||
pack_start(content, hbox2, true, true, 0)
|
||||
pack_start(content, hbox1, true, true, 0)
|
||||
pack_start(content, btn_quit, true, true, 0)
|
||||
set_border_width(win, 5)
|
||||
add(win, content)
|
||||
|
||||
proc on_question_clicked: bool =
|
||||
var dialog = win.message_dialog_new(0, MESSAGE_QUESTION,
|
||||
BUTTONS_YES_NO, "Use a Random number?")
|
||||
var response = dialog.run()
|
||||
if response == RESPONSE_YES:
|
||||
result = true
|
||||
elif response == RESPONSE_NO:
|
||||
result = false
|
||||
dialog.destroy()
|
||||
|
||||
proc thisInc(widget: PWidget, data: Pgpointer){.cdecl.} =
|
||||
inc(valu)
|
||||
entry_fld.set_text($valu)
|
||||
|
||||
proc thisRnd(widget: PWidget, data: Pgpointer){.cdecl.} =
|
||||
if on_question_clicked():
|
||||
valu = random(20)
|
||||
entry_fld.set_text($valu)
|
||||
|
||||
proc thisTextChanged(widget: PWidget, data: Pgpointer) {.cdecl.} =
|
||||
#signal_handler_block(entry_fld, chngd_txt_hndler)
|
||||
try:
|
||||
valu = parseInt($entry_fld.get_text())
|
||||
except EInvalidValue:
|
||||
valu = 0
|
||||
entry_fld.set_text($valu)
|
||||
#signal_handler_unblock(entry_fld, chngd_txt_hndler)
|
||||
#signal_emit_stop(entry_fld, signal_lookup("changed",TYPE_EDITABLE()),0)
|
||||
|
||||
discard signal_connect(win, "destroy", SIGNAL_FUNC(thisDestroy), nil)
|
||||
discard signal_connect(btn_quit, "clicked", SIGNAL_FUNC(thisDestroy), nil)
|
||||
discard signal_connect(btn_inc, "clicked", SIGNAL_FUNC(thisInc), nil)
|
||||
discard signal_connect(btn_rnd, "clicked", SIGNAL_FUNC(thisRnd), nil)
|
||||
chngd_txt_hndler = signal_connect(entry_fld, "changed", SIGNAL_FUNC(thisTextChanged), nil)
|
||||
|
||||
win.show_all()
|
||||
main()
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
import
|
||||
iup, strutils, math
|
||||
|
||||
# assumes you have the iup .dll or .so installed
|
||||
|
||||
randomize()
|
||||
discard iup.open(nil,nil)
|
||||
|
||||
|
||||
var lbl = Label("Value:")
|
||||
setAttribute(lbl,"PADDING","2x2")
|
||||
|
||||
var valu = Text(nil)
|
||||
SetAttribute(valu, "PADDING", "2x2")
|
||||
SetAttribute(valu, "VALUE", "0")
|
||||
|
||||
proc toCB(fp: proc): ICallback =
|
||||
return cast[ICallback](fp)
|
||||
|
||||
# Click handler for Click button
|
||||
proc incClick(ih:PIhandle): cint {.cdecl.} =
|
||||
var s: string = $(GetAttribute(valu,"VALUE"))
|
||||
var x: int = 0
|
||||
try:
|
||||
x = 1 + parseInt(s)
|
||||
except:
|
||||
x = 1 # default to 1 if non-numeric entry
|
||||
setAttribute(valu,"VALUE", $x)
|
||||
return IUP_DEFAULT
|
||||
|
||||
# Click handler for Random button
|
||||
proc randClick(ih:PIhandle): cint {.cdecl.} =
|
||||
if Iup.Alarm("Random Value?", "Set value to a random numer < 100 ?","Yes","No",nil) == 1:
|
||||
setAttribute(valu,"VALUE", $random(100))
|
||||
return IUP_DEFAULT
|
||||
|
||||
# Key handler to check for Esc pressed
|
||||
proc key_cb(ih:PIhandle, c: cint):cint {.cdecl.} =
|
||||
#echo c
|
||||
if (c == Iup.K_esc) and (Iup.Alarm("Exit?", "Had enough?","Yes","Keep going",nil) == 1):
|
||||
return IUP_CLOSE # Exit application
|
||||
return IUP_CONTINUE
|
||||
|
||||
|
||||
var txtBox = Hbox(lbl, valu, nil)
|
||||
SetAttribute(txtBox, "MARGIN", "10x10")
|
||||
|
||||
var incBtn = Button("&Increment", "")
|
||||
var randBtn = Button("&Randomize", "")
|
||||
var btnBox = Vbox(incBtn, randBtn, nil)
|
||||
SetAttribute(btnBox, "MARGIN", "5x5")
|
||||
|
||||
var contents = Hbox(txtBox, btnBox, nil)
|
||||
SetAttribute(contents, "MARGIN", "2x2")
|
||||
|
||||
discard setCallback(incBtn,"ACTION", toCB(incClick))
|
||||
discard setCallback(randBtn,"ACTION", toCB(randClick))
|
||||
discard setCallback(contents,"K_ANY", toCB(key_cb))
|
||||
|
||||
var dlg = Dialog(contents)
|
||||
discard dlg.show()
|
||||
discard mainloop()
|
||||
iup.close()
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
include pGUI.e
|
||||
|
||||
Ihandle txt, increment, random, hbx, vbx, dlg
|
||||
|
||||
function action_cb(Ihandle /*ih*/, integer ch)
|
||||
if not find(ch,"0123456789-") then return IUP_IGNORE end if
|
||||
return IUP_CONTINUE
|
||||
end function
|
||||
|
||||
function increment_cb(Ihandle /*ih*/)
|
||||
integer v = IupGetInt(txt,"VALUE")+1
|
||||
IupSetInt(txt,"VALUE",v)
|
||||
return IUP_CONTINUE
|
||||
end function
|
||||
|
||||
function random_cb(Ihandle /*ih*/)
|
||||
if IupAlarm("Confirm","Replace wth random value?","Yes","No")=1 then
|
||||
IupSetInt(txt,"VALUE",rand(1000))
|
||||
end if
|
||||
return IUP_CONTINUE
|
||||
end function
|
||||
|
||||
function esc_close(Ihandle /*ih*/, atom c)
|
||||
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
|
||||
end function
|
||||
|
||||
IupOpen("../pGUI/")
|
||||
txt = IupText(Icallback("action_cb"),"EXPAND=YES")
|
||||
increment = IupButton("increment",Icallback("increment_cb"))
|
||||
random = IupButton("random",Icallback("random_cb"))
|
||||
hbx = IupHbox({increment,random},"MARGIN=0x10, GAP=20")
|
||||
vbx = IupVbox({txt,hbx},"MARGIN=40x20")
|
||||
dlg = IupDialog(vbx)
|
||||
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
|
||||
IupShow(dlg)
|
||||
IupMainLoop()
|
||||
IupClose()
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
Load "guilib.ring"
|
||||
|
||||
MyApp = New qApp {
|
||||
num = 0
|
||||
win1 = new qWidget() {
|
||||
setwindowtitle("Hello World")
|
||||
setGeometry(100,100,370,250)
|
||||
|
||||
btn1 = new qpushbutton(win1) {
|
||||
setGeometry(200,200,100,30)
|
||||
settext("Random")
|
||||
setclickevent("Rand()")}
|
||||
|
||||
btn2 = new qpushbutton(win1) {
|
||||
setGeometry(50,200,100,30)
|
||||
settext("Increment")
|
||||
setclickevent("Increment()")}
|
||||
|
||||
lineedit1 = new qlineedit(win1) {
|
||||
setGeometry(10,100,350,30)}
|
||||
show()}
|
||||
exec()}
|
||||
|
||||
func Rand
|
||||
num = string(random(10000))
|
||||
lineedit1.settext(num)
|
||||
|
||||
func Increment
|
||||
lineedit1{ num = text()}
|
||||
num = string(number(num)+1)
|
||||
lineedit1.settext(num)
|
||||
Loading…
Add table
Add a link
Reference in a new issue