-
Notifications
You must be signed in to change notification settings - Fork 1
/
Fl_Choice02_no.nim
32 lines (28 loc) · 1.04 KB
/
Fl_Choice02_no.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import fltk_main
# test of:
# Fl_Choice http://www.fltk.org/doc-1.3/classFl__Choice.html
proc ChoiceCB(self: ptr Fl_Widget, cho: pointer) {.cdecl.} =
# get parent of the widget
var win = Fl_WidgetWindow(self)
# get index of selected item
var ind = Fl_ChoiceGetValue(cho)
# copy label from item to window caption
Fl_WindowCopyLabel win, Fl_Menu_GetMenu(cast[Fl_Menu_TT ptr](cho))[ind].text
#
# main
#
var win = Fl_WindowNew(640, 480, "Fl_Choice")
var cho = Fl_ChoiceNew(280, 240, 128, 24)
# add some items
Fl_Menu_Add3 cho, "ASM/FASM|ASM/TASM|ASM/MASM|ASM/NASM|ASM/WASM|ASM/YASM"
Fl_Menu_Add3 cho, "BASIC/Interpreter/ScriptBasic|BASIC/Compiler/FreeBASIC"
Fl_Menu_Add3 cho, "BASIC/Interpreter/SdlBasic|BASIC/Interpreter/Yabasic"
Fl_Menu_Add3 cho, "BASIC/Compiler/PureBasic|BASIC/Compiler/PowerBASIC"
Fl_Menu_Add3 cho, "GUI/GTK+|GUI/FLTK|GUI/QT|GUI/WX"
# select first iterm
Fl_ChoiceSetValue cho, 0
# add standard callback
Fl_WidgetSetCallbackArg cho, ChoiceCB, cho
# put window on desktop
Fl_WindowShow win
Fl_Run()