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
79
Task/Window-management/Nim/window-management-1.nim
Normal file
79
Task/Window-management/Nim/window-management-1.nim
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
import
|
||||
gdk2, glib2, gtk2,
|
||||
os
|
||||
|
||||
proc thisDestroy(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
main_quit()
|
||||
proc thisMax(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
maximize(get_parent_window(widget))
|
||||
proc thisUnmax(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
unmaximize(get_parent_window(widget))
|
||||
proc thisIcon(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
iconify(get_parent_window(widget))
|
||||
proc thisDeicon(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
deiconify(get_parent_window(widget))
|
||||
proc thisHide(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
hide(get_parent_window(widget))
|
||||
sleep(5)
|
||||
show(get_parent_window(widget))
|
||||
|
||||
proc thisShow(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
show(get_parent_window(widget))
|
||||
|
||||
var isshifted: bool = false
|
||||
|
||||
proc thisMove(widget: pWidget, data: pgpointer){.cdecl.} =
|
||||
var w, h: gint
|
||||
get_size(get_parent_window(widget), Addr(w), Addr(h))
|
||||
if isshifted:
|
||||
move(get_parent_window(widget), w-10, h-10)
|
||||
else:
|
||||
move(get_parent_window(widget), w+10, h+10)
|
||||
isshifted = not isshifted
|
||||
|
||||
|
||||
nim_init()
|
||||
var window = window_new(gtk2.WINDOW_TOPLEVEL)
|
||||
discard allow_grow(window)
|
||||
set_title(window,"Window management")
|
||||
var stackbox = vbox_new(TRUE, 10)
|
||||
var bmax = button_new("maximize")
|
||||
var bunmax = button_new("unmaximize")
|
||||
var bicon = button_new("iconize")
|
||||
var bdeicon = button_new("deiconize")
|
||||
var bhide = button_new("hide")
|
||||
var bshow = button_new("show")
|
||||
var bmove = button_new("move")
|
||||
var bquit = button_new("Quit")
|
||||
|
||||
pack_start(stackbox, bmax, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bunmax, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bicon, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bdeicon, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bhide, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bshow, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bmove, TRUE, TRUE, 0)
|
||||
pack_start(stackbox, bquit, TRUE, TRUE, 0)
|
||||
set_border_width(Window, 5)
|
||||
add(window, stackbox)
|
||||
discard signal_connect(window, "destroy",
|
||||
SIGNAL_FUNC(thisDestroy), nil)
|
||||
|
||||
discard signal_connect(bicon, "clicked",
|
||||
SIGNAL_FUNC(thisIcon), nil)
|
||||
discard signal_connect(bdeicon, "clicked",
|
||||
SIGNAL_FUNC(thisDeicon), nil)
|
||||
discard signal_connect(bmax, "clicked",
|
||||
SIGNAL_FUNC(thisMax), nil)
|
||||
discard signal_connect(bunmax, "clicked",
|
||||
SIGNAL_FUNC(thisUnmax), nil)
|
||||
discard signal_connect(bhide, "clicked",
|
||||
SIGNAL_FUNC(thisHide), nil)
|
||||
discard signal_connect(bshow, "clicked",
|
||||
SIGNAL_FUNC(thisShow), nil)
|
||||
discard signal_connect(bmove, "clicked",
|
||||
SIGNAL_FUNC(thismove), nil)
|
||||
discard signal_connect(bquit, "clicked",
|
||||
SIGNAL_FUNC(thisDestroy), nil)
|
||||
show_all(window)
|
||||
main()
|
||||
68
Task/Window-management/Nim/window-management-2.nim
Normal file
68
Task/Window-management/Nim/window-management-2.nim
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import iup
|
||||
|
||||
# assumes you have the iup .dll or .so installed
|
||||
|
||||
proc toCB(fp: proc): ICallback =
|
||||
return cast[ICallback](fp)
|
||||
|
||||
discard iup.open(nil,nil)
|
||||
|
||||
var btnRestore = button("restore","")
|
||||
var btnFull = button("Full screen","")
|
||||
var btnMin = button("minimize","")
|
||||
var btnMax = button("maximize","")
|
||||
var btnHide = button("Transparent","")
|
||||
#var btnHide = button("Hide (close)","")
|
||||
var btnShow = button("Show","")
|
||||
|
||||
var hbox = Hbox(btnRestore, btnFull, btnMax, btnMin, btnShow, btnHide, nil)
|
||||
setAttribute(hbox,"MARGIN", "10x10")
|
||||
setAttribute(hbox,"PADDING", "5x5")
|
||||
|
||||
var dlg = Dialog(hbox)
|
||||
#SetAttribute(dlg, "SIZE", "100x50")
|
||||
|
||||
proc doFull(ih:PIhandle): cint {.cdecl.} =
|
||||
setAttribute(dlg,"FULLSCREEN","YES")
|
||||
return IUP_DEFAULT
|
||||
|
||||
proc doMax(ih:PIhandle): cint {.cdecl.} =
|
||||
#setAttribute(dlg,"FULLSCREEN","YES")
|
||||
setAttribute(dlg,"PLACEMENT","MAXIMIZED")
|
||||
# this is a work-around to get the dialog minimised (on win platform)
|
||||
setAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
|
||||
proc doMin(ih:PIhandle): cint {.cdecl.} =
|
||||
setAttribute(dlg,"PLACEMENT","MINIMIZED")
|
||||
# this is a work-around to get the dialog minimised (on win platform)
|
||||
setAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
|
||||
proc doRestore(ih:PIhandle): cint {.cdecl.} =
|
||||
setAttribute(dlg,"OPACITY","255")
|
||||
setAttribute(dlg,"FULLSCREEN","NO")
|
||||
setAttribute(dlg,"PLACEMENT","NORMAL")
|
||||
setAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
|
||||
proc doHide(ih:PIhandle): cint {.cdecl.} =
|
||||
#setAttribute(dlg,"VISIBLE","NO")
|
||||
setAttribute(dlg,"OPACITY","60")
|
||||
return IUP_DEFAULT
|
||||
|
||||
proc doShow(ih:PIhandle): cint {.cdecl.} =
|
||||
setAttribute(dlg,"OPACITY","255")
|
||||
setAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
|
||||
discard setCallback(btnRestore,"ACTION", toCB(doRestore))
|
||||
discard setCallback(btnFull,"ACTION", toCB(doFull))
|
||||
discard setCallback(btnMax,"ACTION", toCB(doMax))
|
||||
discard setCallback(btnMin,"ACTION", toCB(doMin))
|
||||
discard setCallback(btnShow,"ACTION", toCB(doShow))
|
||||
discard setCallback(btnHide,"ACTION", toCB(doHide))
|
||||
|
||||
discard dlg.show()
|
||||
discard mainloop()
|
||||
iup.Close()
|
||||
69
Task/Window-management/Phix/window-management.phix
Normal file
69
Task/Window-management/Phix/window-management.phix
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
include pGUI.e
|
||||
|
||||
Ihandle dlg
|
||||
|
||||
function doFull(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"FULLSCREEN","YES")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doMax(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"PLACEMENT","MAXIMIZED")
|
||||
-- this is a work-around to get the dialog minimised (on win platform)
|
||||
IupSetAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doMin(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"PLACEMENT","MINIMIZED")
|
||||
-- this is a work-around to get the dialog minimised (on win platform)
|
||||
IupSetAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doRestore(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"OPACITY","255")
|
||||
IupSetAttribute(dlg,"FULLSCREEN","NO")
|
||||
IupSetAttribute(dlg,"PLACEMENT","NORMAL")
|
||||
IupSetAttribute(dlg,"VISIBLE","YES")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doDim(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"OPACITY","60")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doShow(Ihandle /*ih*/)
|
||||
IupSetAttribute(dlg,"OPACITY","255")
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function doMove(Ihandle /*ih*/)
|
||||
integer {x,y} = IupGetIntInt(dlg,"SCREENPOSITION")
|
||||
integer shift = iff(IupGetInt(NULL,"SHIFTKEY")?-10,+10)
|
||||
IupShowXY(dlg,x+shift,y+shift)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
procedure main()
|
||||
IupOpen("../pGUI/")
|
||||
|
||||
Ihandle hbox = IupHbox({IupButton("restore", Icallback("doRestore")),
|
||||
IupButton("full screen",Icallback("doFull")),
|
||||
IupButton("maximize", Icallback("doMax")),
|
||||
IupButton("minimize", Icallback("doMin")),
|
||||
IupButton("dim", Icallback("doDim")),
|
||||
IupButton("show", Icallback("doShow")),
|
||||
IupButton("move", Icallback("doMove"))})
|
||||
IupSetAttribute(hbox,"MARGIN", "10x10")
|
||||
IupSetAttribute(hbox,"PADDING", "5x5")
|
||||
|
||||
dlg = IupDialog(hbox)
|
||||
IupSetAttribute(dlg,"OPACITY","255")
|
||||
|
||||
IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
|
||||
IupMainLoop()
|
||||
IupClose()
|
||||
end procedure
|
||||
main()
|
||||
152
Task/Window-management/Ring/window-management.ring
Normal file
152
Task/Window-management/Ring/window-management.ring
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
Load "guilib.ring"
|
||||
|
||||
/*
|
||||
+--------------------------------------------------------------------------
|
||||
+ Program Name : ScreenDrawOnReSize.ring
|
||||
+ Date : 2016.06.16
|
||||
+ Author : Bert Mariani
|
||||
+ Purpose : Re-Draw Chart after ReSize or move
|
||||
+--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
###-------------------------------
|
||||
### DRAW CHART size 1000 x 1000
|
||||
###
|
||||
|
||||
###------------------------------
|
||||
|
||||
### Window Size
|
||||
WinLeft = 80 ### 80 Window position on screen
|
||||
WinTop = 80 ### 80 Window position on screen
|
||||
WinWidth = 1000 ### 1000 Window Size - Horizontal-X WinWidth
|
||||
WinHeight = 750 ### 750 Window Size - Vertical-Y WinHeight
|
||||
WinRight = WinLeft + WinWidth ### 1080
|
||||
WinBottom = WinTop + WinHeight ### 830
|
||||
|
||||
### Label Box Size
|
||||
BoxLeft = 40 ### Start corner Label1 Box Start Position inside WIN1
|
||||
BoxTop = 40 ### Start corner
|
||||
BoxWidth = WinWidth -80 ### End corner Label1 Box Size
|
||||
BoxHeight = WinHeight -80 ### End corner
|
||||
|
||||
###----------------------------
|
||||
|
||||
|
||||
New qapp {
|
||||
win1 = new qwidget() {
|
||||
|
||||
### Position and Size of WINDOW on the Screen
|
||||
setwindowtitle("DrawChart using QPainter")
|
||||
setgeometry( WinLeft, WinTop, WinWidth, WinHeight)
|
||||
|
||||
win1{ setwindowtitle("Initial Window Position: " +" L " + WinLeft +" T " + WinTop +" Width" + width() +" Height " + height() ) }
|
||||
|
||||
### ReSizeEvent ... Call WhereAreWe function
|
||||
myfilter = new qallevents(win1)
|
||||
myfilter.setResizeEvent("WhereAreWe()")
|
||||
installeventfilter(myfilter)
|
||||
|
||||
### Draw within this BOX
|
||||
label1 = new qlabel(win1) {
|
||||
setgeometry(BoxLeft, BoxTop, BoxWidth, BoxHeight)
|
||||
settext("We are Here")
|
||||
}
|
||||
|
||||
|
||||
### Button Position and Size ... Call DRAW function
|
||||
new qpushbutton(win1) {
|
||||
setgeometry( 30, 30, 80, 20)
|
||||
settext("Draw")
|
||||
setclickevent("Draw()")
|
||||
}
|
||||
|
||||
###---------------
|
||||
|
||||
show()
|
||||
}
|
||||
|
||||
exec()
|
||||
}
|
||||
|
||||
|
||||
###-----------------
|
||||
### FUNCTION Draw
|
||||
###-----------------
|
||||
|
||||
Func WhereAreWe
|
||||
Rec = win1.framegeometry()
|
||||
|
||||
WinWidth = win1.width() ### 1000 Current Values
|
||||
WinHeight = win1.height() ### 750
|
||||
|
||||
WinLeft = Rec.left() +8 ### <<< QT FIX because of Win Title
|
||||
WinTop = Rec.top() +30 ### <<< QT FIX because of Win Title
|
||||
WinRight = Rec.right()
|
||||
WinBottom = Rec.bottom()
|
||||
|
||||
BoxWidth = WinWidth -80 ### 950
|
||||
BoxHeight = WinHeight -80 ### 700
|
||||
|
||||
win1{ setwindowtitle("Window ReSize: Win " + WinWidth + "x" + WinHeight + " --- Box " + BoxWidth + "x" + BoxHeight +
|
||||
" --- LT " + WinLeft + "-" + WinTop + " --- RB " + WinRight + "-" + WinBottom ) }
|
||||
|
||||
See "We Are Here - setResizeEvent - "
|
||||
See " Win " + WinWidth + "x" + WinHeight + " --- Box " + BoxWidth + "x" + BoxHeight
|
||||
See " --- LT " + Winleft + "-" + WinTop + " --- RB " + WinRight + "-" + WinBottom +nl
|
||||
|
||||
win1.setgeometry( WinLeft, WinTop, WinWidth, WinHeight )
|
||||
label1.setgeometry( BoxLeft, BoxTop, BoxWidth, BoxHeight )
|
||||
|
||||
|
||||
return
|
||||
|
||||
Func Draw
|
||||
|
||||
win1{ setwindowtitle("Draw Position: Win " + WinWidth + "x" + WinHeight + " --- Box " + BoxWidth + "x" + BoxHeight +
|
||||
" --- LT " + WinLeft + "-" + WinTop + " --- RB " + WinRight + "-" + WinBottom ) }
|
||||
|
||||
See "Draw Position: " + WinWidth + "x" + WinHeight + " --- Box " + BoxWidth + "x" + BoxHeight +
|
||||
" --- LT " + WinLeft + "-" + WinTop + " --- RB " + WinRight + "-" + WinBottom + nl
|
||||
|
||||
|
||||
# ##-----------------------------
|
||||
### PEN Colors
|
||||
|
||||
p1 = new qpicture()
|
||||
|
||||
colorBlue = new qcolor() { setrgb(0, 0,255,255) }
|
||||
penBlue = new qpen() { setcolor(colorBlue) setwidth(1) }
|
||||
|
||||
|
||||
###-----------------------
|
||||
### PAINT the Chart
|
||||
|
||||
new qpainter() {
|
||||
begin(p1)
|
||||
setpen(penBlue)
|
||||
|
||||
###---------------------
|
||||
### Draw Line Chart
|
||||
|
||||
drawline( 1 , 1 , BoxWidth , 1 ) ### WinTop line horizonal
|
||||
drawline( 1 , 1 , 1 , BoxHeight ) ### WinLeft Line vetical
|
||||
|
||||
drawline( 1 , BoxHeight , BoxWidth , BoxHeight ) ### Bottom Line horizontal
|
||||
drawline( BoxWidth , 1 , BoxWidth , BoxHeight ) ### WinRight Line vertical
|
||||
|
||||
drawline( BoxWidth / 2 , 1 , BoxWidth / 2 , BoxHeight ) ### Central vertical
|
||||
drawline( 1 , BoxHeight / 2 , BoxWidth , BoxHeight / 2 ) ### Central horizontal
|
||||
|
||||
|
||||
###--------------------------------------------------
|
||||
|
||||
|
||||
endpaint()
|
||||
}
|
||||
|
||||
|
||||
label1 { setpicture(p1) show() }
|
||||
|
||||
return
|
||||
###--------------------------------------------
|
||||
Loading…
Add table
Add a link
Reference in a new issue