home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 August / PCWorld_2000-08_cd.bin / Software / TemaCD / xbasic / xbpro.exe / xb / simple.win < prev    next >
Text File  |  1996-02-15  |  11KB  |  248 lines

  1. '
  2. '
  3. ' #######################
  4. ' #####  Simple ()  #####
  5. ' #######################
  6. '
  7. ' "Anatomy of Grid Functions" in the GuiDesigner Programmer Guide
  8. ' describes the operation and modification of grid functions in detail.
  9. '
  10. ' WindowFromFunction and/or WindowToFunction may not work, or may not generate the desired results if you:
  11. '   * Modify the kid constant definition improperly.
  12. '   * Modify the code in the Create subroutine improperly.
  13. '   * Imbed blank or comment lines in the Create subroutine.
  14. '   * Remove the GOSUB Resize line in the Create subroutine (comment out is okay).
  15. '   * Imbed special purpose code in the Create subroutine before the GOSUB Resize line.
  16. '   * Delete any of the four lines that assign values to designX, designY, designWidth, designHeight.
  17. '
  18. FUNCTION  Simple (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  19.   STATIC  designX,  designY,  designWidth,  designHeight
  20.   STATIC  SUBADDR  sub[]
  21.   STATIC  upperMessage
  22.   STATIC  Simple
  23. '
  24.   $Simple       =   0  ' kid   0 grid type = Simple
  25.   $Menu         =   1  ' kid   1 grid type = XuiMenu
  26.   $Region       =   2  ' kid   2 grid type = XuiLabel
  27.   $RegionList   =   3  ' kid   3 grid type = XuiListBox
  28.   $State        =   4  ' kid   4 grid type = XuiLabel
  29.   $StateList    =   5  ' kid   5 grid type = XuiListBox
  30.   $Country      =   6  ' kid   6 grid type = XuiLabel
  31.   $CountryList  =   7  ' kid   7 grid type = XuiListBox
  32.   $Comments     =   8  ' kid   8 grid type = XuiLabel
  33.   $TextArea     =   9  ' kid   9 grid type = XuiTextArea
  34.   $UpperKid     =   9  ' kid maximum
  35. '
  36. '
  37.   IFZ sub[] THEN GOSUB Initialize
  38. ' XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  39.   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Simple) THEN RETURN
  40.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  41.   RETURN
  42. '
  43. '
  44. ' *****  Callback  *****  message = Callback : r1 = original message
  45. '
  46. SUB Callback
  47.   message = r1
  48.   callback = message
  49.   IF (message <= upperMessage) THEN GOSUB @sub[message]
  50. END SUB
  51. '
  52. '
  53. ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  54. '
  55. SUB Create
  56.   IF (v0 <= 0) THEN v0 = 0
  57.   IF (v1 <= 0) THEN v1 = 0
  58.   IF (v2 <= 0) THEN v2 = designWidth
  59.   IF (v3 <= 0) THEN v3 = designHeight
  60.   XuiCreateGrid (@grid, Simple, @v0, @v1, @v2, @v3, r0, r1, &Simple())
  61.   XuiSendMessage ( grid, #SetGridName, 0, 0, 0, 0, 0, @"Simple")
  62.   XuiMenu        (@g, #Create, 4, 4, 316, 24, r0, grid)
  63.   XuiSendMessage ( g, #SetCallback, grid, &Simple(), -1, -1, $Menu, grid)
  64.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Menu")
  65.   XuiSendMessage ( g, #SetColor, $$LightRed, $$Black, $$Black, $$BrightGrey, 0, 0)
  66.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"_File  _Edit  _Help  ")
  67.   DIM text$[11]
  68.   text$[ 0] = "_File"
  69.   text$[ 1] = " _Load"
  70.   text$[ 2] = " _Save"
  71.   text$[ 3] = " _Quit"
  72.   text$[ 4] = "_Edit"
  73.   text$[ 5] = " _Cut"
  74.   text$[ 6] = " _Grab"
  75.   text$[ 7] = " _Paste"
  76.   text$[ 8] = "_Help"
  77.   text$[ 9] = " _Index"
  78.   text$[10] = " _Summary"
  79.   text$[11] = " _Contents"
  80.   XuiSendMessage ( g, #SetTextArray, 0, 0, 0, 0, 0, @text$[])
  81.   XuiLabel       (@g, #Create, 4, 28, 144, 32, r0, grid)
  82.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Region")
  83.   XuiSendMessage ( g, #SetColor, $$DarkGreen, $$Black, $$Black, $$BrightGrey, 0, 0)
  84.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Region:")
  85.   XuiListBox     (@g, #Create, 148, 28, 172, 32, r0, grid)
  86.   XuiSendMessage ( g, #SetCallback, grid, &Simple(), -1, -1, $RegionList, grid)
  87.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"RegionList")
  88.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Foreign")
  89.   DIM text$[6]
  90.   text$[0] = "_Eastern USA"
  91.   text$[1] = "_Midwest USA"
  92.   text$[2] = "_Rockies USA"
  93.   text$[3] = "_Western USA"
  94.   text$[4] = "_Alaska  USA"
  95.   text$[5] = "_Hawaii  USA"
  96.   text$[6] = "_Foreign"
  97.   XuiSendMessage ( g, #SetTextArray, 0, 0, 0, 0, 0, @text$[])
  98.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 1, @"TextLine")
  99.   XuiSendMessage ( g, #SetBorder, $$BorderRaise1, $$BorderRaise1, $$BorderRaise1, 0, 1, 0)
  100.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 1, @"Foreign")
  101.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 2, @"PressButton")
  102.   XuiLabel       (@g, #Create, 4, 60, 144, 32, r0, grid)
  103.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"State")
  104.   XuiSendMessage ( g, #SetColor, $$DarkGreen, $$Black, $$Black, $$BrightGrey, 0, 0)
  105.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"State/Province:")
  106.   XuiListBox     (@g, #Create, 148, 60, 172, 32, r0, grid)
  107.   XuiSendMessage ( g, #SetCallback, grid, &Simple(), -1, -1, $StateList, grid)
  108.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"StateList")
  109.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Arkansas")
  110.   DIM text$[7]
  111.   text$[0] = "Alabama"
  112.   text$[1] = "Alaska"
  113.   text$[2] = "Arkansas"
  114.   text$[3] = "Connecticut"
  115.   text$[4] = "Delaware"
  116.   text$[5] = "etc..."
  117.   text$[6] = "Virginia"
  118.   text$[7] = "Washington"
  119.   XuiSendMessage ( g, #SetTextArray, 0, 0, 0, 0, 0, @text$[])
  120.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 1, @"TextLine")
  121.   XuiSendMessage ( g, #SetBorder, $$BorderRaise1, $$BorderRaise1, $$BorderRaise1, 0, 1, 0)
  122.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 1, @"Arkansas")
  123.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 2, @"PressButton")
  124.   XuiLabel       (@g, #Create, 4, 92, 144, 32, r0, grid)
  125.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Country")
  126.   XuiSendMessage ( g, #SetColor, $$DarkGreen, $$Black, $$Black, $$BrightGrey, 0, 0)
  127.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Country:")
  128.   XuiListBox     (@g, #Create, 148, 92, 172, 32, r0, grid)
  129.   XuiSendMessage ( g, #SetCallback, grid, &Simple(), -1, -1, $CountryList, grid)
  130.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CountryList")
  131.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Chili")
  132.   DIM text$[8]
  133.   text$[0] = "Albania"
  134.   text$[1] = "Arkaroola"
  135.   text$[2] = "Chili"
  136.   text$[3] = "England"
  137.   text$[4] = "Finland"
  138.   text$[5] = "Germany"
  139.   text$[6] = "Japan"
  140.   text$[7] = "Switzerland"
  141.   text$[8] = "USSA"
  142.   XuiSendMessage ( g, #SetTextArray, 0, 0, 0, 0, 0, @text$[])
  143.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 1, @"TextLine")
  144.   XuiSendMessage ( g, #SetBorder, $$BorderRaise1, $$BorderRaise1, $$BorderRaise1, 0, 1, 0)
  145.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 1, @"Chili")
  146.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 2, @"PressButton")
  147.   XuiLabel       (@g, #Create, 4, 124, 316, 28, r0, grid)
  148.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Comments")
  149.   XuiSendMessage ( g, #SetColor, $$DarkSteel, $$Black, $$Black, $$BrightGrey, 0, 0)
  150.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Comments  Comments  Comments")
  151.   XuiTextArea    (@g, #Create, 4, 152, 316, 100, r0, grid)
  152.   XuiSendMessage ( g, #SetCallback, grid, &Simple(), -1, -1, $TextArea, grid)
  153.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"TextArea")
  154.   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"The USSA, once called the USA, was\nonce a relatively free country.  But\nthen the government taught a couple\ngenerations of kids that their wacko\nabstractions had meaning.  Then it\nwas easy to enslave the country.\n")
  155.   DIM text$[5]
  156.   text$[0] = "The USSA, once called the USA, was"
  157.   text$[1] = "once a relatively free country.  But"
  158.   text$[2] = "then the government taught a couple"
  159.   text$[3] = "generations of kids that their wacko"
  160.   text$[4] = "abstractions had meaning.  Then it"
  161.   text$[5] = "was easy to enslave the country."
  162.   XuiSendMessage ( g, #SetTextArray, 0, 0, 0, 0, 0, @text$[])
  163.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 1, @"Area")
  164.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 2, @"ScrollH")
  165.   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 3, @"ScrollV")
  166.   GOSUB Resize
  167. END SUB
  168. '
  169. '
  170. ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1 = &WindowFunc()
  171. '
  172. SUB CreateWindow
  173.   IF (v0 =  0) THEN v0 = designX
  174.   IF (v1 =  0) THEN v1 = designY
  175.   IF (v2 <= 0) THEN v2 = designWidth
  176.   IF (v3 <= 0) THEN v3 = designHeight
  177.   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, r1)
  178.   v0 = 0 : v1 = 0 : r0 = window : r1 = 0
  179.   GOSUB Create
  180.   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Simple")
  181. END SUB
  182. '
  183. '
  184. ' *****  GetSmallestSize  *****  See "Anatomy of Grid Functions"
  185. '
  186. SUB GetSmallestSize
  187. END SUB
  188. '
  189. '
  190. ' *****  Resize  *****  See "Anatomy of Grid Functions"
  191. '
  192. SUB Resize
  193. END SUB
  194. '
  195. '
  196. ' *****  Selection  *****  See "Anatomy of Grid Functions"
  197. '
  198. SUB Selection
  199. END SUB
  200. '
  201. '
  202. ' *****  Initialize  *****  ' see "Anatomy of Grid Functions"
  203. '
  204. SUB Initialize
  205.   XuiGetDefaultMessageFuncArray (@func[])
  206.   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
  207. '
  208.   func[#Callback]           = &XuiCallback ()               ' disable to handle Callback messages internally
  209. ' func[#GetSmallestSize]    = 0                             ' enable to add internal GetSmallestSize routine
  210. ' func[#Resize]             = 0                             ' enable to add internal Resize routine
  211. '
  212.   DIM sub[upperMessage]
  213. ' sub[#Callback]            = SUBADDRESS (Callback)         ' enable to handle Callback messages internally
  214.   sub[#Create]              = SUBADDRESS (Create)           ' must be internal routine
  215.   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)     ' must be internal routine
  216. ' sub[#GetSmallestSize]     = SUBADDRESS (GetSmallestSize)  ' enable to add internal GetSmallestSize routine
  217. ' sub[#Resize]              = SUBADDRESS (Resize)           ' enable to add internal Resize routine
  218.   sub[#Selection]           = SUBADDRESS (Selection)        ' routes Selection callbacks to subroutine
  219. '
  220.   IF sub[0] THEN PRINT "Simple(): Initialize: Error::: (Undefined Message)
  221.   IF func[0] THEN PRINT "Simple(): Initialize: Error::: (Undefined Message)
  222.   XuiRegisterGridType (@Simple, "Simple", &Simple(), @func[], @sub[])
  223. '
  224. ' Don't remove the following 4 lines, or WindowFromFunction/WindowToFunction will not work
  225. '
  226.   designX = 156
  227.   designY = 32
  228.   designWidth = 324
  229.   designHeight = 256
  230. '
  231.   gridType = Simple
  232.   XuiSetGridTypeValue (gridType, @"x",                designX)
  233.   XuiSetGridTypeValue (gridType, @"y",                designY)
  234.   XuiSetGridTypeValue (gridType, @"width",            designWidth)
  235.   XuiSetGridTypeValue (gridType, @"height",           designHeight)
  236.   XuiSetGridTypeValue (gridType, @"maxWidth",         designWidth)
  237.   XuiSetGridTypeValue (gridType, @"maxHeight",        designHeight)
  238.   XuiSetGridTypeValue (gridType, @"minWidth",         designWidth)
  239.   XuiSetGridTypeValue (gridType, @"minHeight",        designHeight)
  240.   XuiSetGridTypeValue (gridType, @"border",           $$BorderFrame)
  241.   XuiSetGridTypeValue (gridType, @"can",              $$Focus OR $$Respond OR $$Callback OR $$InputTextString OR $$TextSelection)
  242.   XuiSetGridTypeValue (gridType, @"focusKid",         $RegionList)
  243.   XuiSetGridTypeValue (gridType, @"inputTextArray",   $TextArea)
  244.   XuiSetGridTypeValue (gridType, @"inputTextString",  $RegionList)
  245.   IFZ message THEN RETURN
  246. END SUB
  247. END FUNCTION
  248.