home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / app / tradiobx.x < prev    next >
Text File  |  1995-08-11  |  3KB  |  113 lines

  1. '
  2. ' ####################
  3. ' #####  PROLOG  #####
  4. ' ####################
  5. '
  6. PROGRAM "tradiobx"
  7. VERSION "0.0000"
  8. '
  9. IMPORT  "xst"
  10. IMPORT  "xgr"
  11. IMPORT  "xui"
  12. '
  13. INTERNAL FUNCTION  RadioBox        ( )
  14. INTERNAL FUNCTION  GetDisplayGrid  ( @label )
  15. INTERNAL FUNCTION  DisplayCallback ( grid, message$, v0, v1, v2, v3, kid, r1$ )
  16. '
  17. '
  18. ' ######################
  19. ' #####  RadioBox  #####
  20. ' ######################
  21. '
  22. FUNCTION  RadioBox ()
  23.   $XuiRadioBox = 3
  24. '
  25.   GetDisplayGrid ( @label )
  26. '
  27. ' create window with XuiRadioBox grid
  28. '
  29.   XuiCreateWindow      (@grid, @"XuiRadioBox", 100, 256, 256, 128, 0, "")
  30.   XuiSendStringMessage ( grid, @"SetCallback", grid, &XuiQueueCallbacks(), -1, -1, $XuiRadioBox, -1)
  31.   XuiSendStringMessage ( grid, @"SetGridName", 0, 0, 0, 0, 0, @"RadioBox")
  32.   XuiSendStringMessage ( grid, @"SetTextString", 0, 0, 0, 0, 0, @"XuiRadioBox")
  33.   XuiSendStringMessage ( grid, @"DisplayWindow", 0, 0, 0, 0, 0, 0)
  34. '
  35. ' convenience function message loop
  36. '
  37.   DO
  38.     XgrProcessMessages (1)
  39.     DO WHILE XuiGetNextCallback (@grid, @message$, @v0, @v1, @v2, @v3, @kid, @r1$)
  40.       GOSUB Callback
  41.     LOOP
  42.   LOOP
  43.   RETURN
  44. '
  45. ' callback
  46. '
  47. SUB Callback
  48.   win = kid >> 16
  49.   kid = kid AND 0xFF
  50.   SELECT CASE message$
  51.     CASE "CloseWindow" : QUIT (0)
  52.     CASE "Selection"   : GOSUB Selection
  53.     CASE ELSE          : DisplayCallback (grid, @message$, v0, v1, v2, v3, kid, @r1$)
  54.   END SELECT
  55. END SUB
  56. '
  57. ' Selection message
  58. '
  59. SUB Selection
  60.   IF v0 THEN selected$ = "selected" ELSE selected$ = "not selected"
  61.   text$ = "XuiRadioBox\n\n "
  62.   text$ = text$ + selected$
  63.   XuiSendStringMessage (label, @"SetTextString", 0, 0, 0, 0, 0, @text$)    ' set message text
  64.   XuiSendStringMessage (label, @"Redraw", 0, 0, 0, 0, 0, 0)                ' redraw label
  65. END SUB
  66. END FUNCTION
  67. '
  68. '
  69. ' ###############################
  70. ' #####  GetDisplayGrid ()  #####
  71. ' ###############################
  72. '
  73. FUNCTION  GetDisplayGrid ( label )
  74.   STATIC  grid
  75. '
  76.   IFZ grid THEN
  77.     XuiCreateWindow      (@grid, @"XuiLabel", 100, 100, 512, 128, 0, "")
  78.     XuiSendStringMessage ( grid, @"SetColor", $$BrightGreen, -1, -1, -1, 0, 0)
  79.     XuiSendStringMessage ( grid, @"SetAlign", $$AlignUpperLeft, 0, 0, 0, 0, 0)
  80.     XuiSendStringMessage ( grid, @"SetJustify", $$JustifyLeft, 0, 0, 0, 0, 0)
  81.     XuiSendStringMessage ( grid, @"SetIndent", 6, 4, 0, 0, 0, 0)
  82.     XuiSendStringMessage ( grid, @"DisplayWindow", 0, 0, 0, 0, 0, 0)
  83.   END IF
  84. '
  85.   label = grid
  86. END FUNCTION
  87. '
  88. '
  89. ' ################################
  90. ' #####  DisplayCallback ()  #####
  91. ' ################################
  92. '
  93. FUNCTION  DisplayCallback ( grid, message$, v0, v1, v2, v3, kid, r1$ )
  94. '
  95.   XgrGetGridType (grid, @gridType)
  96.   XgrGridTypeNumberToName (gridType, @gridType$)
  97. '
  98.   text$ = gridType$ + "\n"
  99.   text$ = text$ + "    grid = " + HEX$ (grid, 8) + "\n"
  100.   text$ = text$ + " message = " + message$ + "\n"
  101.   text$ = text$ + "      v0 = " + HEX$ (v0,8) + "\n"
  102.   text$ = text$ + "      v1 = " + HEX$ (v1,8) + "\n"
  103.   text$ = text$ + "      v2 = " + HEX$ (v2,8) + "\n"
  104.   text$ = text$ + "      v3 = " + HEX$ (v3,8) + "\n"
  105.   text$ = text$ + "     kid = " + HEX$ (kid,8) + "\n"
  106.   text$ = text$ + "     r1$ = " + r1$
  107. '
  108.   GetDisplayGrid (@label)
  109.   XuiSendStringMessage (label, @"SetTextString", 0, 0, 0, 0, 0, @text$)
  110.   XuiSendStringMessage (label, @"Redraw", 0, 0, 0, 0, 0, 0)
  111. END FUNCTION
  112. END PROGRAM