Skip to content

Commit 7cd3cae

Browse files
author
Your Name
committed
20190122
1 parent 88bd154 commit 7cd3cae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1106
-525
lines changed

Drawing02_no.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ proc DrawCB (self: ptr Fl_Double_WindowEx): long{.cdecl.} =
1717
font: FL_FONT
1818

1919
DrawPushClip(0, 0, w, h)
20-
DrawRectFillRGBColor(0, 0, w, h, ubyte(rand(255)), ubyte(rand(255)), ubyte(rand(255)))
20+
DrawRectFillRGBColor(0, 0, w, h, rand(255), rand(255), rand(255))
2121
for font in 0 .. 15:
2222
size = long(6 + rand(70))
2323
DrawSetFont(cast[FL_FONT](font), size)
2424
for i in 0 .. 1:
25-
DrawSetRGBColor(ubyte(rand(255)), ubyte(rand(255)), ubyte(rand(255)))
26-
x = long(rand(int(w)))
27-
y = long(rand(int(h)))
25+
DrawSetRGBColor(rand(255), rand(255), rand(255))
26+
x = rand(int(w))
27+
y = rand(int(h))
2828
if i == 1 :
2929
DrawStr("DrawStr()", x, y)
3030
else:

Drawing03.nim

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fltk_main
99

1010
proc `\` (x: long; y: long): long = long(x.float / y.float)
1111

12+
1213
proc DrawMe(win: ptr Fl_Window) =
1314
var gfxPrimitive{.global.}: long = 0
1415
# select the window as curent drawing target
@@ -31,24 +32,24 @@ proc DrawMe(win: ptr Fl_Window) =
3132
i: int
3233

3334
for i in 1 .. 10:
34-
DrawSetRGBColor ubyte(rand(255)), ubyte(rand(255)), ubyte(rand(255))
35+
DrawSetRGBColor rand(255), rand(255), rand(255)
3536
case gfxPrimitive:
3637
of 0 :
37-
DrawPoint long(rand(w)), long(rand(h))
38+
DrawPoint rand(w), rand(h)
3839
of 1 :
39-
DrawLine long(rand(w)), long(rand(h)), long(rand(w)), long(rand(h))
40+
DrawLine rand(w), rand(h), rand(w), rand(h)
4041
of 2 :
41-
DrawRect long(rand(w)), long(rand(h)), long(rand(w)), long(rand(h))
42+
DrawRect rand(w), rand(h), rand(w), rand(h)
4243
of 3 :
43-
r = long(rand(h))\2
44-
DrawArc long(rand(w)), long(rand(h)), r, r, 0, 360 # circle
44+
r = rand(h)\2
45+
DrawArc rand(w), rand(h), r, r, 0, 360 # circle
4546
of 4 :
46-
DrawRectFill long(rand(w)), long(rand(h)), long(rand(w)), long(rand(h))
47+
DrawRectFill rand(w), rand(h), rand(w), rand(h)
4748
of 5 :
4849
var bt = FL_BOXTYPE(1 + rand(15))
49-
DrawBox bt, long(rand(w)), long(rand(h)), long(rand(w)), long(rand(h)), Fl_RGB_Color(ubyte(rand(255)), ubyte(rand(255)), ubyte(rand(255)))
50+
DrawBox bt, rand(w), rand(h), rand(w), rand(h), Fl_RGB_Color(rand(255), rand(255), rand(255))
5051
of 6 :
51-
DrawArc long(rand(w)), long(rand(h)), long(rand(w)), long(rand(h)), 0, 360 # oval
52+
DrawArc rand(w), rand(h), rand(w), rand(h), 0, 360 # oval
5253
else:
5354
discard
5455

Drawing04_no.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ proc SliderCB (self: ptr Fl_Widget, sld: ptr Fl_Hor_Value_Slider){.cdecl.}=
7272
# main
7373
#
7474
var win = Fl_Double_WindowNew(640, 480, "Drawing04.nim")
75-
#~ var box = Fl_BoxExNew(0, 0, 640, 430)
76-
var box = Fl_BoxNew(0, 0, 640, 430)
75+
var box = Fl_BoxExNew(0, 0, 640, 430)
76+
#~ var box = Fl_BoxNew(0, 0, 640, 430)
7777
var sld = Fl_Hor_Value_SliderNew(10, 430, 620, 30, "zoom")
78-
#~ Fl_BoxExSetDrawCB box, DrawCB
79-
Fl_BoxSetDrawCB box, DrawCB
78+
Fl_BoxExSetDrawCB box, DrawCB
79+
#~ Fl_BoxSetDrawCB box, DrawCB
8080
Fl_WidgetSetUserData box, sld
8181
Fl_WidgetSetCallbackArg sld, SliderCB, sld
8282
Fl_ValuatorBounds sld, 0.01, 3.0

Drawing05_no.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fltk_main
22

33
#~ ' test of 8 bit palette drawing
44

5-
proc DrawCB (self: ptr any): long {.cdecl.} =
5+
proc DrawCB (self: pointer): long {.cdecl.} =
66
echo "DrawCB"
77
var x, y, z: long
88

@@ -19,7 +19,7 @@ proc DrawCB (self: ptr any): long {.cdecl.} =
1919
#~ '
2020
var win = Fl_WindowExNew(8*80,5*16,"Drawing05.nim")
2121
#~ var win = Fl_WindowNew(8*80,5*16,"Drawing05.nim")
22-
#~ Fl_WindowExSetDrawCB win, DrawCB
22+
Fl_WindowExSetDrawCB win, DrawCB
2323
#~ Fl_WindowSetDrawCB win, DrawCB
2424
Fl_WindowShow win
2525
Fl_Run()

DrawingAndSavingImage_no.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ proc DrawCB(self: ptr Fl_Widget, SaveButton: ptr Fl_Button){. cdecl .}=
55
Fl_WindowMakeCurrent(Fl_WidgetWindow(self))
66
var i: int
77
for i in 1 .. 100:
8-
DrawSetRGBColor(ubyte(rand(256)), ubyte(rand(256)), ubyte(rand(256)))
9-
DrawLine((rand(128)), (rand(128)), (rand(128)), (rand(128)))
8+
DrawSetRGBColor(rand(256), rand(256), rand(256))
9+
DrawLine(rand(128), rand(128), rand(128), rand(128))
1010

1111
Fl_WidgetActivate SaveButton
1212

Fl_Align_Image_no.nim

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
import fltk_main
2+
13
#include "fltk-c.bi"
24
#include "media/gradient_xpm.bi"
35

4-
' test of:
5-
' Fl_PixmapNew
6-
' FL_ALIGN_IMAGE_BACKDROP
6+
# test of:
7+
# Fl_PixmapNew
8+
# FL_ALIGN_IMAGE_BACKDROP
79

8-
var win = Fl_WindowNew(320,45,"FL_ALIGN_IMAGE_BACKDROP")
9-
var but1 = Fl_ButtonNew( 10, 10,140,25,"Button 1")
10-
var but2 = Fl_ButtonNew(160, 10,140,25,"Button 2")
11-
Fl_WidgetSetImage but1,Fl_PixmapNew(@gradient_xpm(0))
12-
Fl_WidgetSetAlign but1,FL_ALIGN_IMAGE_BACKDROP
10+
var win = Fl_WindowNew(320, 45, "FL_ALIGN_IMAGE_BACKDROP")
11+
var but1 = Fl_ButtonNew( 10, 10, 140, 25, "Button 1")
12+
var but2 = Fl_ButtonNew(160, 10, 140, 25, "Button 2")
13+
#~ Fl_WidgetSetImage but1, Fl_PixmapNew(@gradient_xpm(0))
14+
Fl_WidgetSetAlign but1, FL_ALIGN_IMAGE_BACKDROP
1315

1416
Fl_WindowShow win
15-
Fl_Run
17+
Fl_Run()
1618

1719

Fl_Boxtype01.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const BOX_HEIGHT = 50
1111

1212
var i, row, col: int
1313

14-
var win = Fl_Double_WindowNew(long(6*10+5*BOX_WIDTH), long(12*10+11*BOX_HEIGHT), "Fl_Boxtype01.nim")
14+
var win = Fl_Double_WindowNew(6*10+5*BOX_WIDTH, 12*10+11*BOX_HEIGHT, "Fl_Boxtype01.nim")
1515
Fl_WidgetSetColor win,12
1616
for i in 0 .. 55:
1717
row = int(i / 5)

Fl_Clock02.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import fltk_c
66
proc `/`(x:long; y: long): long = long(x.float / y.float)
77

88
#~ ' centered window
9-
var win = Fl_Double_WindowNew2(Fl_GetW()/2-300,Fl_GetH()/2-150,600,300,"FL_CLOCK")
9+
var win = Fl_Double_WindowNew2(Fl_GetW()/2-300, Fl_GetH()/2-150, 600, 300,"FL_CLOCK")
1010
var w = Fl_WidgetGetW(win)/2
1111
var h = Fl_WidgetGetH(win)
12-
Fl_WidgetSetType Fl_ClockNew(0,0,w,h),FL_CLOCK_SQUARE
13-
Fl_WidgetSetType Fl_ClockNew(w,0,w,h),FL_CLOCK_ROUND
12+
Fl_WidgetSetType Fl_ClockNew(0, 0, w, h), FL_CLOCK_SQUARE
13+
Fl_WidgetSetType Fl_ClockNew(w, 0, w, h), FL_CLOCK_ROUND
1414

1515
Fl_WindowShow win
1616
Fl_Run()

Fl_CommonDialogs_no.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ var
1212
file: string
1313
path:string
1414

15-
proc FileOrFolderCB (path: string){.cdecl.} =
15+
proc FileOrFolderCB (path: cstring){.cdecl.} =
1616
if len(path) != 0 :
17-
echo """FileChFileOrFolderCB("""" & path & """")"""
17+
echo """FileChFileOrFolderCB("""" & $path & """")"""
1818

1919

2020

Fl_File_Browser02_no.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ else:
1717
const PATH = "$HOME"
1818

1919

20-
var UserPath: string
20+
var UserPath: cstring
2121
#~ UserPath = callocate(FL_MAX_PATH)
22+
#~ var UserPath: array[FL_MAX_PATH, char]
2223
flFilenameExpand(UserPath, FL_MAX_PATH, PATH)
2324

2425
proc BrowserCB (self: ptr FL_WIDGET, filebrowser: ptr Fl_File_Browser){.cdecl.}=

0 commit comments

Comments
 (0)