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

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