grid function example

0
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

DECLARE FUNCTION XuiDialog2B (grid, message, v0, v1, v2, v3, r0, ANY)
'
'
' ############################
' #####  XuiDialog2B ()  #####
' ############################
'
FUNCTION XuiDialog2B (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  STATIC designX, designY, designWidth, designHeight
  STATIC SUBADDR sub[]
  STATIC upperMessage
  STATIC XuiDialog2B
'  
  $XuiDialog2B = 0 ' kid 0
  $Label       = 1 ' kid 1
  $TextLine    = 2 ' kid 2
  $Button0     = 3 ' kid 3
  $Button1     = 4 ' kid 4
  $UpperKid    = 4 '
'
  IFZ sub[] THEN GOSUB Initialize
  IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, XuiDialog2B) THEN RETURN
  IF (message <= upperMessage) THEN GOSUB @sub[message]
  RETURN
'
'
' ***** Callback ***** message = Callback : r1 = original message
'
SUB Callback
  message = r1
  callback = message
  IF (message <= upperMessage) THEN GOSUB @sub[message]
END SUB
'
'
' ***** Create ***** v0123 = xywh : r0 = window : r1 = parent
'
SUB Create
  IF (v0 <= 0) THEN v0 = 0
  IF (v1 <= 0) THEN v1 = 0
  IF (v2 <= 0) THEN v2 = designWidth
  IF (v3 <= 0) THEN v3 = designHeight
  XuiCreateGrid (@grid, XuiDialog2B, @v0, @v1, @v2, @v3, r0, r1, &XuiDialog2B())
  XuiLabel       (@g, #Create, 0, 0, 0, 0, r0, grid)
  XuiTextLine    (@g, #Create, 0, 0, 0, 0, r0, grid)
  XuiSendMessage ( g, #SetCallback, grid, &XuiDialog2B(), -1, -1, $TextLine, grid)
  XuiPushButton  (@g, #Create, 0, 0, 0, 0, r0, grid)
  XuiSendMessage ( g, #SetCallback, grid, &XuiDialog2B(), -1, -1, $Button0, grid)
  XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Enter")
  XuiPushButton  (@g, #Create, 0, 0, 0, 0, r0, grid)
  XuiSendMessage ( g, #SetCallback, grid, &XuiDialog2B(), -1, -1, $Button1, grid)
  XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Cancel")
  GOSUB Resize
END SUB
'
'
' ***** CreateWindow ***** r0 = windowType : r1$ = display$
'
SUB CreateWindow
  IF (v0 = 0) THEN v0 = designX
  IF (v1 = 0) THEN v1 = designY
  IF (v2 <= 0) THEN v2 = designWidth
  IF (v3 <= 0) THEN v3 = designHeight
  XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
  v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
  GOSUB Create
  r1 = 0 : ATTACH display$ TO r1$
  XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"XuiDialog2B")
END SUB