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

  1. '
  2. ' ####################
  3. ' #####  PROLOG  #####
  4. ' ####################
  5. '
  6. PROGRAM "ttxtarea"
  7. VERSION "0.0000"
  8. '
  9. IMPORT  "xst"
  10. IMPORT  "xgr"
  11. IMPORT  "xui"
  12. '
  13. INTERNAL FUNCTION  TextArea        ( )
  14. INTERNAL FUNCTION  GetDisplayGrid  ( @label )
  15. INTERNAL FUNCTION  DisplayCallback ( grid, message$, v0, v1, v2, v3, kid, r1$ )
  16. '
  17. '
  18. ' ######################
  19. ' #####  TextArea  #####
  20. ' ######################
  21. '
  22. FUNCTION  TextArea ()
  23.   $XuiTextArea = 11
  24. '
  25.   GetDisplayGrid ( @label )
  26. '
  27. ' create window with XuiTextArea grid
  28. '
  29.   XuiCreateWindow      (@grid, @"XuiTextArea", 100, 256, 256, 128, 0, "")
  30.   XuiSendStringMessage ( grid, @"SetCallback", grid, &XuiQueueCallbacks(), -1, -1, $XuiTextArea, -1)
  31.   XuiSendStringMessage ( grid, @"SetGridName", 0, 0, 0, 0, 0, @"TextArea")
  32.   XuiSendStringMessage ( grid, @"SetTextString", 0, 0, 0, 0, 0, @"XuiTextArea")
  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.   DisplayCallback (grid, @message$, v0, v1, v2, v3, kid, @r1$)
  61. END SUB
  62. END FUNCTION
  63. '
  64. '
  65. ' ###############################
  66. ' #####  GetDisplayGrid ()  #####
  67. ' ###############################
  68. '
  69. FUNCTION  GetDisplayGrid ( label )
  70.   STATIC  grid
  71. '
  72.   IFZ grid THEN
  73.     XuiCreateWindow      (@grid, @"XuiLabel", 100, 100, 512, 128, 0, "")
  74.     XuiSendStringMessage ( grid, @"SetColor", $$BrightGreen, -1, -1, -1, 0, 0)
  75.     XuiSendStringMessage ( grid, @"SetAlign", $$AlignUpperLeft, 0, 0, 0, 0, 0)
  76.     XuiSendStringMessage ( grid, @"SetJustify", $$JustifyLeft, 0, 0, 0, 0, 0)
  77.     XuiSendStringMessage ( grid, @"SetIndent", 6, 4, 0, 0, 0, 0)
  78.     XuiSendStringMessage ( grid, @"DisplayWindow", 0, 0, 0, 0, 0, 0)
  79.   END IF
  80. '
  81.   label = grid
  82. END FUNCTION
  83. '
  84. '
  85. ' ################################
  86. ' #####  DisplayCallback ()  #####
  87. ' ################################
  88. '
  89. FUNCTION  DisplayCallback ( grid, message$, v0, v1, v2, v3, kid, r1$ )
  90. '
  91.   XgrGetGridType (grid, @gridType)
  92.   XgrGridTypeNumberToName (gridType, @gridType$)
  93. '
  94.   text$ = gridType$ + "\n"
  95.   text$ = text$ + "   grid = " + HEX$ (grid, 8) + "\n"
  96.   text$ = text$ + "message = " + message$ + "\n"
  97.   text$ = text$ + "     v0 = " + HEX$ (v0,8) + "\n"
  98.   text$ = text$ + "     v1 = " + HEX$ (v1,8) + "\n"
  99.   text$ = text$ + "     v2 = " + HEX$ (v2,8) + "\n"
  100.   text$ = text$ + "     v3 = " + HEX$ (v3,8) + "\n"
  101.   text$ = text$ + "    kid = " + HEX$ (kid,8) + "\n"
  102.   text$ = text$ + "    r1$ = " + r1$
  103. '
  104.   GetDisplayGrid (@label)
  105.   XuiSendStringMessage (label, @"SetTextString", 0, 0, 0, 0, 0, @text$)
  106.   XuiSendStringMessage (label, @"Redraw", 0, 0, 0, 0, 0, 0)
  107. END FUNCTION
  108. END PROGRAM