home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / devtools / files / lb202win.exe / LB202W.EXE / FFORM201.BAS < prev    next >
Encoding:
BASIC Source File  |  2000-11-27  |  92.7 KB  |  2,553 lines

  1.  
  2.     'Freeform v2.01 for Liberty BASIC
  3.     'A special thanks for Alyce Watson for her work on this
  4.     'version of Freeform!
  5.  
  6.     'Copyright 2000 Shoptalk Systems
  7.     'All Rights Reserved
  8.  
  9.     'This program lets you graphically lay out
  10.     'windows and their controls, and then converts
  11.     'this visual layout to Liberty BASIC source code
  12.     'that you can paste into your Liberty BASIC
  13.     'programming session.
  14.  
  15.     'set up an arrays to hold control specs
  16.  
  17.     dim font$(2)    'font$(1)=user chosen font,font$(2)=titlebar font
  18.     dim type$(100)
  19.     dim label$(100)
  20.     dim names$(100)
  21.     dim xOrg(100)
  22.     dim yOrg(100)
  23.     dim width(100)
  24.     dim height(100)
  25.     dim corner$(100)
  26.     dim branchLabel$(100)
  27.     dim segment(100)
  28.     dim handle$(100)
  29.     dim bmpName$(100)
  30.     dim arrayName$(100)
  31.     dim menu$(20)
  32.     dim menuItem$(20, 30)
  33.     dim menuItemLocal$(30)
  34.     dim menuItemCount(20)
  35.     dim winType$(20)
  36.     dim colorType$(20)
  37.     dim info$(10, 10)   'used for getting file listing info
  38.     ffVersion$ = "2.01"
  39.     index = 0
  40.     resizeable$ = " combobox textbox listbox graphicbox groupbox statictext windowframe textedit button "   'add more as you go
  41.     newControlNumber = 0  'increment by one each time a new control is added
  42.     qu$ = chr$(34)
  43.     controlsThatBranch$ = " button listbox combobox bmpbutton checkbox radiobutton "
  44.     snapOn = 1
  45.     xInterval = 8
  46.     yInterval = 5
  47.     createInspect = 1
  48.  
  49.     formName$ = "untitled.fr2"
  50.     windowXOrigin = 70
  51.     windowYOrigin = 10
  52.     windowXExtent = 550
  53.     windowYExtent = 410
  54.     windowLabel$ = "untitled"
  55.     windowType$ = "window"
  56.     winHandle$ = "#main"
  57.     wincolor$ = "white"
  58.     textcolor$ = "black"
  59.     boxcolor$ = "white"
  60.     menuCount = 0
  61.  
  62.     winType$(0) = "window"
  63.     winType$(1) = "window_nf"
  64.     winType$(2) = "dialog"
  65.     winType$(3) = "dialog_nf"
  66.     winType$(4) = "dialog_modal"
  67.     winType$(5) = "dialog_nf_modal"
  68.     winType$(6) = "graphics"
  69.     winType$(7) = "graphics_nsb"
  70.     winType$(8) = "graphics_nsb_nf"
  71.  
  72.     colorType$(1) = "black"
  73.     colorType$(2) = "blue"
  74.     colorType$(3) = "brown"
  75.     colorType$(4) = "cyan"
  76.     colorType$(5) = "darkblue"
  77.     colorType$(6) = "darkcyan"
  78.     colorType$(7) = "darkgray"
  79.     colorType$(8) = "darkgreen"
  80.     colorType$(9) = "darkpink"
  81.     colorType$(10) = "darkred"
  82.     colorType$(11) = "green"
  83.     colorType$(12) = "lightgray"
  84.     colorType$(13) = "palegray"
  85.     colorType$(14) = "pink"
  86.     colorType$(15) = "red"
  87.     colorType$(16) = "white"
  88.     colorType$(17) = "yellow"
  89.  
  90.     gosub [loadIniFile]
  91.  
  92.     if displayFormat = 0 then loadbmp "systemBox", "bmp\systembx.bmp"
  93.     if displayFormat = 1 and left$(windowType$, 6) = "dialog" then loadbmp "systemBox", "bmp\95sysbxd.bmp"
  94.     if displayFormat = 1 and left$(windowType$, 6) <> "dialog" then loadbmp "systemBox", "bmp\95sysbx.bmp"
  95.     if displayFormat = 0 then loadbmp "minBox", "bmp\minbx.bmp" else loadbmp "minBox", "bmp\95minbx.bmp"
  96.     if displayFormat = 0 then loadbmp "maxBox", "bmp\maxbx.bmp" else loadbmp "maxBox", "bmp\95maxbx.bmp"
  97.     loadbmp "closebox",    "bmp\95exit.bmp"
  98.     loadbmp "comboButton", "bmp\cmbobttn.bmp"
  99.     loadbmp "radioButton", "bmp\radibttn.bmp"
  100.     loadbmp "checkBox",    "bmp\checkbox.bmp"
  101.     loadbmp "scrollUp",    "bmp\scrlup.bmp"
  102.     loadbmp "scrollDown",  "bmp\scrldown.bmp"
  103.     loadbmp "scrollRight", "bmp\scrlrght.bmp"
  104.     loadbmp "scrollLeft",  "bmp\scrlleft.bmp"
  105.  
  106. [setUpWindowAndOpenIt]
  107.     nomainwin
  108.  
  109.     menu #form, "&File", "&New", [newFile], "&Open", [openFile], "&Save", [saveFile], |,"Q&uit", [quit]
  110.     menu #form, "&Control", "&Inspect", [inspectControl], "&Delete", [deleteControl], |, "Move to &front", [moveToFront], "Move to &back", [moveToBack]
  111.     menu #form, "&Output", "&Produce Code", [produceCode], "Produce Code + Outline", [produceCodeAndOutline]
  112.     menu #form, "&Window", "&Title", [changeTitle], "T&ype", [changeWindowType], "&Handle", [changeHandle], "&Window Colour", [changeColorType], "&Box Colour", [changeBoxColorType], "&Font for controls",[changeControlFont]
  113.     menu #form, "O&ptions", "&Auto Snap to Grid", [gridDialog], "&Settings", [settingsDialog]
  114.     menu #form, "&Menu", "&Add a Menu", [addAMenu], "&Remove a Menu", [removeMenu], "&Edit Menus", [editMenus]
  115.  
  116.     bmpbutton #form.load,   "bmp\loadbttn.bmp", [openFile],           UL, 5, 40
  117.     bmpbutton #form.save,   "bmp\savebttn.bmp", [saveFile],           UL, 35, 40
  118.     bmpbutton #form.static, "bmp\textbttn.bmp", [addStaticText],      UL, 5, 80
  119.     bmpbutton #form.field,  "bmp\efldbttn.bmp", [addField],           UL, 35, 80
  120.     bmpbutton #form.button, "bmp\bttnbttn.bmp", [addButton],          UL, 5, 110
  121.     bmpbutton #form.bmp,    "bmp\usrdbttn.bmp", [addBmpButton],       UL, 35, 110
  122.     bmpbutton #form.list,   "bmp\lboxbttn.bmp", [addListBox],         UL, 5, 140
  123.     bmpbutton #form.combo,  "bmp\cboxbttn.bmp", [addComboBox],        UL, 35, 140
  124.     bmpbutton #form.radio,  "bmp\rdiobttn.bmp", [addRadioButton],     UL, 5, 170
  125.     bmpbutton #form.check,  "bmp\chbxbttn.bmp", [addCheckBox],        UL, 35, 170
  126.     bmpbutton #form.group,  "bmp\gboxbttn.bmp", [addGroupBox],        UL, 5, 200
  127.     bmpbutton #form.edit,   "bmp\tedtbttn.bmp", [addTextEdit],        UL, 35, 200
  128.     bmpbutton #form.graphic,"bmp\grbxbttn.bmp", [addGraphicBox],      UL, 5, 230
  129.     bmpbutton #form.fill,   "bmp\windfill.bmp", [changeBoxColorType], UL, 35, 230
  130.     bmpbutton #form.inspect,"bmp\check.bmp",    [inspectControl],     UL, 5, 270
  131.     bmpbutton #form.delete, "bmp\checkout.bmp", [deleteControl],      UL, 35, 270
  132.     bmpbutton #form.infront,"bmp\infront.bmp",  [moveToFront],        UL, 5, 300
  133.     bmpbutton #form.inback, "bmp\inback.bmp",   [moveToBack],         UL, 35, 300
  134.     bmpbutton #form.code,   "bmp\compile.bmp",  [produceCode],        UL, 5, 330
  135.     bmpbutton #form.outline,"bmp\compile2.bmp", [produceCodeAndOutline], UL, 35, 330
  136.  
  137.  
  138.     open "FreeForm "+ffVersion$+" for Liberty BASIC" for graphics_fs_nsb as #form
  139.     if Platform$ = "OS/2" then font$(1)="systemmonospaced 8 12"
  140.     if Platform$ = "Windows" and displayFormat = 0 then font$(2)="fixedsys 8 15"
  141.     if Platform$ = "Windows" and displayFormat = 1 then font$(2)="system 7 16"
  142.     font$(1)="ms_sans_serif 0 16"
  143.     print #form, "font ";font$(1)
  144.     print #form, "trapclose [quit]";
  145.  
  146.  
  147. [drawTheWindow]
  148.     gosub [renderWindow]
  149.     gosub [addWindowFrame]
  150.  
  151.     confirm "Use Tooltips?  Tooltips might not work on some systems.";answer$
  152.     if answer$="yes" then gosub [addTooltips]
  153.     goto [setForSelection]
  154.  
  155.  
  156. [addWindowFrame]    'add the window frame as the first object
  157.     objectCount = objectCount + 1
  158.     idx = objectCount
  159.     xOrg(idx) = 70
  160.     yOrg(idx) = 10
  161.     width(idx) = 550
  162.     height(idx) = 410
  163.     type$(idx) = "windowframe"
  164.     return
  165.  
  166. 'This sub is used when adding any control
  167. sub addControl type$, count, idx, width, height, text$, corner$
  168.     xOrg(idx) = 100
  169.     yOrg(idx) = 50
  170.     width(idx) = width
  171.     height(idx) = height
  172.     type$(idx) = type$
  173.     names$(idx) = type$+str$(count)
  174.     corner$(idx) = corner$
  175.     label$(idx) = text$
  176. end sub
  177.  
  178. 'Return a string without quotes
  179. 'This is used when getting typed input
  180. function noQuotes$(text$)
  181.     for x = 1 to len(text$)
  182.         if mid$(text$, x, 1) <> chr$(34) then
  183.             noQuotes$ = noQuotes$ + mid$(text$, x, 1)
  184.         end if
  185.     next x
  186. end function
  187.  
  188. [addButton]     'add a new button to the form
  189.     text$ = "Button Caption"
  190.     prompt "Please enter text for this button"; text$
  191.     text$ = noQuotes$(text$)
  192.     if text$ = "" then [inputLoop]
  193.  
  194.     newControlNumber = newControlNumber + 1
  195.     objectCount = objectCount + 1
  196.     idx = objectCount
  197.     call addControl "button", newControlNumber, idx, 8*len(text$)+10, 25, text$, "UL"
  198.     branchLabel$(idx) = "["+names$(idx)+"Click]"
  199.     gosub [renderButton]
  200.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  201.     goto [inputLoop]
  202.  
  203.  
  204. [addBmpButton]     'add a new bmpButton to the form
  205.     bmp$ = ""
  206.     filedialog "Select a bitmap for this button", "*.bmp", bmp$
  207.     if bmp$ = "" then [inputLoop]
  208.  
  209.     WindowWidth=222:WindowHeight=240
  210.     UpperLeftX=50:UpperLeftY=50
  211.     graphicbox #bb.g, 10,10,200,100
  212.     button #bb.okay, "OKAY",[bmpbuttonOkay],UL,110,120,100,26
  213.     button #bb.cancel "Cancel",[bmpbuttonCancel],UL,110,150,100,26
  214.     button #bb.again "Select Again",[bmpbuttonSelect],UL,110,180,100,26
  215.     open "Bmpbutton Preview" for window_nf as #bb
  216.  
  217. [displayBmpbutton]
  218.     print #bb.g, "cls";
  219.     loadbmp "bmptest",bmp$
  220.     print #bb.g, "drawbmp bmptest 0 0";
  221.     wait
  222.  
  223. [bmpbuttonSelect]
  224.     bmp$ = ""
  225.     filedialog "Select a bitmap for this button", "*.bmp", bmp$
  226.     if bmp$ = "" then [inputLoop]
  227.     goto [displayBmpbutton]
  228.  
  229. [bmpbuttonCancel]
  230.     unloadbmp "bmptest"
  231.     close #bb:goto [inputLoop]
  232.  
  233. [bmpbuttonOkay]
  234.     close #bb
  235.     newControlNumber = newControlNumber + 1
  236.     objectCount = objectCount + 1
  237.     idx = objectCount
  238.     call addControl "bmpbutton", newControlNumber, idx, 16, 16, "", "UL"
  239.     bmpName$(idx) = bmp$
  240.     loadbmp bmp$, bmp$
  241.     branchLabel$(idx) = "["+names$(idx)+"Click]"
  242.     gosub [renderBmpButton]
  243.  
  244.     if createInspect then
  245.         gosub [deselectOnly]
  246.         index = idx
  247.         gosub [selectDeselect]
  248.         goto [inspectControl]
  249.     end if
  250.  
  251.     goto [inputLoop]
  252.  
  253.  
  254. [addField]     'add a new field (textBox) to the form
  255.     newControlNumber = newControlNumber + 1
  256.     objectCount = objectCount + 1
  257.     idx = objectCount
  258.     call addControl "textbox", newControlNumber, idx, 100, 25, "", ""
  259.     gosub [renderTextBox]
  260.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  261.     goto [inputLoop]
  262.  
  263.  
  264. [addTextEdit]     'add a new field (textBox) to the form
  265.     newControlNumber = newControlNumber + 1
  266.     objectCount = objectCount + 1
  267.     idx = objectCount
  268.     call addControl "textedit", newControlNumber, idx, 100, 100, "", ""
  269.     gosub [renderTextEdit]
  270.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  271.     goto [inputLoop]
  272.  
  273.  
  274. [addComboBox]     'add a new combobox to the form
  275.     newControlNumber = newControlNumber + 1
  276.     objectCount = objectCount + 1
  277.     idx = objectCount
  278.     call addControl "combobox", newControlNumber, idx, 100, 100, "", ""
  279.     branchLabel$(idx) = "["+names$(idx)+"DoubleClick]"
  280.     arrayName$(idx) = "array$("
  281.     gosub [renderComboBox]
  282.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  283.     goto [inputLoop]
  284.  
  285.  
  286. [addListBox]     'add a new listbox to the form
  287.     newControlNumber = newControlNumber + 1
  288.     objectCount = objectCount + 1
  289.     idx = objectCount
  290.     call addControl "listbox", newControlNumber, idx, 100, 100, "", ""
  291.     branchLabel$(idx) = "["+names$(idx)+"DoubleClick]"
  292.     arrayName$(idx) = "array$("
  293.     gosub [renderListBox]
  294.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  295.     goto [inputLoop]
  296.  
  297.  
  298. [addStaticText]     'add statictext to the form
  299.     text$ = "StaticText Caption"
  300.     prompt "Please enter the text you would like to add:"; text$
  301.     text$ = noQuotes$(text$)
  302.     if text$ = "" then [inputLoop]
  303.  
  304.     newControlNumber = newControlNumber + 1
  305.     objectCount = objectCount + 1
  306.     idx = objectCount
  307.     call addControl "statictext", newControlNumber, idx, 8 * len(text$), 20, text$, ""
  308.     gosub [renderStaticText]
  309.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  310.     goto [inputLoop]
  311.  
  312.  
  313. [addGroupBox]     'add groupbox to the form
  314.     text$ = "GroupBox Caption"
  315.     prompt "Please enter the text this GroupBox :"; text$
  316.     text$ = noQuotes$(text$)
  317.     if text$ = "" then [inputLoop]
  318.  
  319.     newControlNumber = newControlNumber + 1
  320.     objectCount = objectCount + 1
  321.     idx = objectCount
  322.     call addControl "groupbox", newControlNumber, idx, 100, 100, text$, ""
  323.     gosub [renderGroupBox]
  324.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  325.     goto [inputLoop]
  326.  
  327. [addGraphicBox]     'add graphicbox to the form
  328.     newControlNumber = newControlNumber + 1
  329.     objectCount = objectCount + 1
  330.     idx = objectCount
  331.     call addControl "graphicbox", newControlNumber, idx, 100, 100, "", ""
  332.     gosub [renderGraphicBox]
  333.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  334.     goto [inputLoop]
  335.  
  336. [addRadioButton]     'add radiobutton to the form
  337.     text$ = "RadioButton Caption"
  338.     prompt "Please enter a label for the radiobutton:"; text$
  339.     text$ = noQuotes$(text$)
  340.     if text$ = "" then [inputLoop]
  341.  
  342.     newControlNumber = newControlNumber + 1
  343.     objectCount = objectCount + 1
  344.     idx = objectCount
  345.     call addControl "radiobutton", newControlNumber, idx, 100, 25, text$, ""
  346.     branchLabel$(idx) = "["+names$(idx)+"Set] ["+names$(idx)+"Reset]"
  347.     gosub [renderRadioButton]
  348.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  349.     goto [inputLoop]
  350.  
  351.  
  352. [addCheckBox]     'add checkbox to the form
  353.     text$ = "CheckBox Caption"
  354.     prompt "Please enter a label for the checkbox"; text$
  355.     text$ = noQuotes$(text$)
  356.     if text$ = "" then [inputLoop]
  357.  
  358.     newControlNumber = newControlNumber + 1
  359.     objectCount = objectCount + 1
  360.     idx = objectCount
  361.     call addControl "checkbox", newControlNumber, idx, 100, 25, text$, ""
  362.     branchLabel$(idx) = "["+names$(idx)+"Set] ["+names$(idx)+"Reset]"
  363.     gosub [renderCheckBox]
  364.     if createInspect then gosub [deselectOnly] : index = idx : gosub [selectDeselect] : goto [inspectControl]
  365.     goto [inputLoop]
  366.  
  367.  
  368. [inputLoop]
  369.     scan
  370.     goto [inputLoop]
  371.  
  372.  
  373. [renderWindow]
  374.     'render the window depending on the value of windowType$
  375.  
  376.     xOrg = windowXOrigin
  377.     yOrg = windowYOrigin
  378.     xExt = windowXExtent
  379.     yExt = windowYExtent
  380.  
  381.     print #form, "cls; fill 255 250 230";
  382.     gosub [renderToolbox]
  383.  
  384.     'render gui:
  385.     print #form, "font ";font$(1);
  386.  
  387.     print #form, "color black ; down ; size 1";
  388.     print #form, "place "; xOrg + 4; " "; yOrg + 4;
  389.     print #form, "backcolor "; wincolor$;"";
  390.     print #form, "boxfilled "; xOrg + xExt - 4; " "; yOrg + yExt - 4;
  391.     if instr(windowType$, "_nf") > 0 then [noResizingFrame]
  392.  
  393.     'draw resizing frame
  394.     print #form, "color lightgray ; size 3";
  395.     if Platform$ = "OS/2" then print #form, "color yellow";
  396.     if windowType$ = "dialog" then print #form, "color darkgray";
  397.     if windowType$ = "dialog" and Platform$ = "OS/2" then print #form, "color darkcyan";
  398.     print #form, "place "; xOrg + 2; " "; yOrg + 2;
  399.     print #form, "box "; xOrg + xExt - 2; " "; yOrg + yExt - 2;
  400.     print #form, "color black ; backcolor white ; size 1";
  401.     print #form, "place "; xOrg; " "; yOrg;
  402.     print #form, "box "; xOrg + xExt ; " "; yOrg + yExt;
  403.  
  404.   [noResizingFrame]
  405.     'draw titlebar
  406.     print #form, "color black ; backcolor darkblue";
  407.     if left$(windowType$, 6) = "dialog" then print #form, "backcolor darkgray";
  408.     if Platform$ = "OS/2" then print #form, "color darkgray ; backcolor darkcyan";
  409.     print #form, "place "; 4 + xOrg; " "; 4 + yOrg;
  410.     print #form, "boxfilled "; xOrg + xExt - 4; " "; 4 + yOrg + 20;
  411.     if displayFormat = 0 then print #form, "place "; int(xExt/2) + xOrg - len(windowLabel$) * 4; " "; 18 + yOrg;
  412.     if displayFormat = 1 then print #form, "place "; 20 + xOrg ; " "; 18 + yOrg;
  413.     if Platform$ = "OS/2" then print #form, "place "; 48 + xOrg; " "; 18 + yOrg;
  414.     print #form, "color white; font ";font$(2)
  415.     print #form, "\"; windowLabel$;
  416.     print #form, "font ";font$(1)
  417.  
  418.     'draw buttons
  419.     if Platform$ = "OS/2" then print #form, "drawbmp systemBox "; xOrg + 5; " "; 4 + yOrg;
  420.     if Platform$ = "Windows" then print #form, "drawbmp systemBox "; xOrg + 4; " "; 4 + yOrg;
  421.     print #form, "backcolor white ; color black ; down ; size 1";
  422.     if windowType$ = "dialog" then print #form, "color white" ;
  423.     if windowType$ = "dialog" and Platform$ = "OS/2" then print #form, "color darkgray" ;
  424.     print #form, "place "; xOrg + 4; " "; yOrg + 4;
  425.     print #form, "box "; xOrg + xExt - 4; " "; yOrg + yExt - 4;
  426.     if left$(windowType$, 6) = "dialog" then [drawMenus]
  427.     if displayFormat = 0 and instr(windowType$, "_nf") then print #form, "drawbmp minBox "; xOrg + xExt - 24 - 1; " "; 4 + yOrg; : goto [drawMenus]
  428.     if displayFormat = 1 and instr(windowType$, "_nf") then print #form, "drawbmp closebox "; xOrg + xExt - 24 - 1; " "; 7 + yOrg; : goto [drawMenus]
  429.     if Platform$ = "OS/2" then print #form, "drawbmp minBox "; xOrg + xExt - 43 - 2; " "; 4 + yOrg;
  430.     if Platform$ = "OS/2" then print #form, "drawbmp maxBox "; xOrg + xExt - 24 - 1; " "; 4 + yOrg;
  431.     if Platform$ = "Windows" and displayFormat = 1 then print #form, "drawbmp minBox "; xOrg + xExt - 60; " "; 7 + yOrg;
  432.     if Platform$ = "Windows" and displayFormat = 0 then print #form, "drawbmp minBox "; xOrg + xExt - 43; " "; 4 + yOrg;
  433.     if Platform$ = "Windows" and displayFormat = 1 then print #form, "drawbmp maxBox "; xOrg + xExt - 44; " "; 7 + yOrg;
  434.     if Platform$ = "Windows" and displayFormat = 0 then print #form, "drawbmp maxBox "; xOrg + xExt - 24; " "; 4 + yOrg;
  435.     if Platform$ = "Windows" and displayFormat = 1 then print #form, "drawbmp closebox "; xOrg + xExt - 24; " "; 7 + yOrg;
  436.  
  437.  
  438.   [drawMenus]
  439.     if menuCount = 0 then [dontDrawMenus]
  440.     if displayFormat = 0 then print #form, "color black ; backcolor white" ;
  441.     if displayFormat = 1 then print #form, "color black ; backcolor lightgray" ;
  442.     if Platform$ = "Windows" then print #form, "place "; 4 + xOrg; " "; 23 + yOrg;
  443.     if Platform$ = "OS/2" then print #form, "color darkgray ; place "; 4 + xOrg; " "; 25 + yOrg;
  444.     print #form, "boxfilled "; xOrg + xExt - 4; " "; 24 + yOrg + 20 ;
  445.     string$ = ""
  446.     underline$ = ""
  447.     for x = 0 to menuCount - 1
  448.         item$ = menu$(x)
  449.         hkIndex = instr(menu$(x), "&")
  450.         if hkIndex = 0 then [noHotKey]
  451.         item$ = left$(item$, hkIndex - 1) + mid$(item$, hkIndex + 1)
  452.         underline$ = underline$ + chr$(len(string$)+hkIndex)
  453.       [noHotKey]
  454.         string$ = string$ + item$ + "  "
  455.     next x
  456.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  457.     print #form, "place "; xOrg + 10; " "; 38 + yOrg ;
  458.     print #form, "\"; string$;
  459.     if len(underline$) = 0 then [dontDrawMenus]
  460.     for x = 1 to len(underline$)
  461.         print #form, "place "; xOrg + 10 + (asc(mid$(underline$, x, 1)) - 1) * 8; " "; yOrg + 40 ;
  462.         print #form, "north ; turn 90 ; go 8";
  463.     next x
  464.  
  465.   [dontDrawMenus]
  466.     print #form, "flush" ;
  467.     return
  468.  
  469. [renderToolbox]
  470.    'render toolbox:
  471.     print #form, "color darkgray; down; size 2; backcolor lightgray";
  472.     print #form, "place 2 11; boxfilled 67 362";
  473.     print #form, "color 200 180 110;backcolor 200 180 110";
  474.     print #form, "place 5 13;boxfilled 65 34"
  475.     print #form, "color white; font arial bold 10"
  476.     print #form, "place 8 28;|Toolbox";
  477.     return
  478.  
  479. [changeTitle]
  480.     'change the window's title
  481.     newWindowLabel$ = windowLabel$
  482.     prompt "Specify the window's title"; newWindowLabel$
  483.     if newWindowLabel$ <> "" then windowLabel$ = newWindowLabel$
  484.     gosub [redrawAll]
  485.     goto [inputLoop]
  486.  
  487.  
  488. [changeWindowType]
  489.     WindowWidth = 290
  490.     WindowHeight = 140
  491.  
  492.     'change the window's type
  493.     statictext #type.statictext1, "Select the type of window desired:", 14, 11, 272, 20
  494.     combobox #type.types, winType$(, [selectWinType], 14, 36, 256, 115
  495.     button #type, "Accept", [acceptWinType], UL, 146, 71,100,24
  496.     button #type, "Cancel", [cancelWinType], UL, 30, 71,100,24
  497.     open "Select Window Type" for dialog_modal as #type
  498.     print #type.types, "select "; windowType$ 
  499.     print #type, "trapclose [cancelWinType]"
  500.     defaultType$ = windowType$ 
  501.  
  502.     goto [inputLoop]
  503.  
  504.  
  505. [changeControlFont]
  506.     fontdialog font$(1),fontChosen$
  507.     font$(1)=word$(fontChosen$,1)+" 0 16"
  508.     gosub [redrawAll]
  509.     goto [inputLoop]
  510.  
  511.  
  512. [selectWinType]   'Perform action for the combobox named 'types'
  513.     'select the type of window desired
  514.     print #type.types, "selection?";
  515.     input #type.types, defaultType$
  516.  
  517.     goto [inputLoop]
  518.  
  519.  
  520. [acceptWinType]   'Perform action for the button named 'acceptWinType'
  521.     'accept the selected window type
  522.     close #type
  523.     if windowType$ <> defaultType$ then windowType$ = defaultType$
  524.     If left$(windowType$,6) = "dialog" or  left$(windowType$,6) = "window" then wincolor$ = "white"
  525.     if displayFormat = 0 then loadbmp "systemBox", "bmp\systembx.bmp"
  526.     if displayFormat = 1 and left$(windowType$, 6) = "dialog" then loadbmp "systemBox", "bmp\95sysbxd.bmp"
  527.     if displayFormat = 1 and left$(windowType$, 6) <> "dialog" then loadbmp "systemBox", "bmp\95sysbx.bmp"
  528.     gosub [redrawAll]
  529.     goto [inputLoop]
  530.  
  531.  
  532. [cancelWinType]   'Perform action for the button named 'cancelWinType'
  533.     'close the window, don't accept type change
  534.     close #type
  535.     goto [inputLoop]
  536.  
  537. [changeColorType]
  538.     if  left$(windowType$, 8) <> "graphics" then notice " Error!" + chr$(13) + " Colored windows only supported in Graphics" : goto [inputLoop]
  539.     WindowWidth = 290
  540.     WindowHeight = 140
  541.     'change the window's color type
  542.     statictext #type.statictext1, "Select the window color desired:", 14, 11, 272, 20
  543.     combobox #type.types, colorType$(, [selectColorType],  14, 36, 256, 115
  544.     button #type, "Accept", [acceptColorType], UL, 146, 71,100,24
  545.     button #type, "Cancel", [cancelColorType], UL, 30, 71,100,24
  546.     open "Select Window Type" for dialog_modal as #type
  547.     print #type.types, "select "; wincolor$ 
  548.     print #type, "trapclose [cancelColorType]"
  549.     colorDefaultType$ = colorType$
  550.  
  551.     goto [inputLoop]
  552.  
  553.  
  554. [selectColorType]   'Perform action for the combobox named 'types'
  555.     'select the type of window color desired
  556.     print #type.types, "selection?";
  557.     input #type.types, colorDefaultType$
  558.  
  559.     goto [inputLoop]
  560.  
  561.  
  562. [acceptColorType]   'Perform action for the button named 'acceptColorType'
  563.     'accept the selected window type
  564.     close #type
  565.     if colorType$ <> colorDefaultType$ then colorType$ = colorDefaultType$
  566.     wincolor$ = colorType$
  567.     gosub [redrawAll]
  568.     goto [inputLoop]
  569.  
  570.  
  571. [cancelColorType]   'Perform action for the button named 'cancelColorType'
  572.     'close the window, don't accept type change
  573.     close #type
  574.     goto [inputLoop]
  575.  
  576. [changeBoxColorType]
  577.     if  left$(windowType$, 8) <> "graphics" then notice " Error!" + chr$(13) + " Colored windows only supported in Graphics" : goto [inputLoop]
  578.     WindowWidth = 290
  579.     WindowHeight = 140
  580.     'change the window's color type
  581.     statictext #type.statictext1, "Select the window color desired:", 14, 11, 272, 20
  582.     combobox #type.types, colorType$(, [selectBoxColorType],  14, 36, 256, 115
  583.     button #type, "Accept", [acceptBoxColorType], UL, 146, 71,100,24
  584.     button #type, "Cancel", [cancelBoxColorType], UL, 30, 71,100,24
  585.     open "Select Window Type" for dialog_modal as #type
  586.     print #type.types, "select "; boxcolor$ 
  587.     print #type, "trapclose [cancelBoxColorType]"
  588.     colorBoxDefaultType$ = colorType$
  589.  
  590.     goto [inputLoop]
  591.  
  592.  
  593. [selectBoxColorType]   'Perform action for the combobox named 'types'
  594.     'select the type of window color desired
  595.     print #type.types, "selection?";
  596.     input #type.types, colorBoxDefaultType$
  597.  
  598.     goto [inputLoop]
  599.  
  600.  
  601. [acceptBoxColorType]   'Perform action for the button named 'acceptColorType'
  602.     'accept the selected window type
  603.     close #type
  604.     if colorType$ <> colorBoxDefaultType$ then colorType$ = colorBoxDefaultType$
  605.    boxcolor$ = colorType$
  606.     gosub [redrawAll]
  607.     goto [inputLoop]
  608.  
  609.  
  610. [cancelBoxColorType]   'Perform action for the button named 'cancelColorType'
  611.     'close the window, don't accept type change
  612.     close #type
  613.     goto [inputLoop]
  614.  
  615. [changeHandle]
  616.     'change the window's handle
  617.     prompt "Specify the window's handle (starts with a #)"; result$
  618.     if result$ = "" then [inputLoop]
  619.     winHandle$ = result$
  620.     if left$(winHandle$, 1) <> "#" then winHandle$ = "#" + winHandle$ : notice "Window handle defaults to: " + winHandle$
  621.     goto [inputLoop]
  622.  
  623.  
  624. 'This function is used at the tail end of rendering any control
  625. function postRender(idx, displayOrdering)
  626.     if displayOrdering then
  627.         print #form, "color white ; backcolor black ; place " + str$(xOrg(idx)-4) + " " + str$(yOrg(idx)+7)
  628.         print #form, "\" + str$(idx - 1)
  629.     end if
  630.     print #form, "up ; flush" ;
  631.     print #form, "segment" : input #form, id
  632.     segment(idx) = id
  633. end function
  634.  
  635.  
  636. [renderButton]
  637.     'render the button at idx.
  638.     'assume an font 8 bits wide
  639.     'type$(idx) = "button"
  640.     xOrgIdx = xOrg(idx)
  641.     yOrgIdx = yOrg(idx)
  642.     print #form, "place "; xOrgIdx; " "; yOrgIdx ;
  643.     print #form, "place "; xOrgIdx; " "; yOrgIdx ;
  644.     print #form, "color black ; backcolor lightgray ; size 1" ;
  645.     print #form, "down ; boxfilled "; xOrgIdx+width(idx); " "; yOrgIdx+height(idx) ;
  646.     print #form, "size 2 ; color darkgray ; place "; xOrgIdx+2; " "; yOrgIdx+2 ;
  647.     print #form, "box "; xOrgIdx+width(idx)-1; " "; yOrgIdx+height(idx)-1 ;
  648.     print #form, "color white" ;
  649.     print #form, "place  "; xOrgIdx+2; " "; yOrgIdx+height(idx)-3 ;
  650.     print #form, "goto "; xOrgIdx+2; " "; yOrgIdx+2 ;
  651.     print #form, "goto "; xOrgIdx+width(idx)-3; " "; yOrgIdx+2 ;
  652.     print #form, "color black ; backcolor lightgray ; size 1" ;
  653.     print #form, "place "; xOrgIdx+int((width(idx)-len(label$(idx))*8)/2); " "; yOrgIdx+int((height(idx)-15)/2)+12 ;
  654.     print #form, "\"; label$(idx);
  655.     result = postRender(idx, displayOrdering)
  656.     return
  657.  
  658.  
  659. [renderStaticText]
  660.     'render the statictext at idx.
  661.     'assume an font 8 bits wide, 15 high
  662.     'type$(idx) = "statictext"
  663.     print #form, "place "; xOrg(idx); " "; yOrg(idx)+15-3 ; " ; place "; xOrg(idx); " "; yOrg(idx)+15-3 ;
  664.     print #form, "down ; color black ; backcolor white";
  665.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  666.     print #form, "\"; label$(idx);
  667.     result = postRender(idx, displayOrdering)
  668.     return
  669.  
  670.  
  671. [renderRadioButton]
  672.     'render the radiobutton at idx.
  673.     'assume an font 8 bits wide, 15 high
  674.     'type$(idx) = "radiobutton"
  675.     width(idx) = 8 * len(label$(idx)) + 16
  676.     height(idx) = 20
  677.     print #form, "down" ;
  678.     print #form, "place "; xOrg(idx); " "; yOrg(idx);
  679.     print #form, "drawbmp radioButton "; xOrg(idx); " "; yOrg(idx);
  680.     print #form, "color black ; backcolor white" ;
  681.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  682.     print #form, "place "; xOrg(idx)+16; " "; yOrg(idx)+15-3 ;
  683.     print #form, "\"; label$(idx);
  684.     result = postRender(idx, displayOrdering)
  685.     return
  686.  
  687.  
  688. [renderCheckBox]
  689.     'render the checkbox at idx.
  690.     'assume an font 8 bits wide, 15 high
  691.     'type$(idx) = "checkbox"
  692.     width(idx) = 8 * len(label$(idx)) + 16
  693.     height(idx) = 20
  694.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  695.     print #form, "down" ;
  696.     print #form, "drawbmp checkBox "; xOrg(idx); " "; yOrg(idx);
  697.     print #form, "color black ; backcolor white" ;
  698.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  699.     print #form, "place "; xOrg(idx)+16; " "; yOrg(idx)+15-3 ;
  700.     print #form, "\"; label$(idx);
  701.     result = postRender(idx, displayOrdering)
  702.     return
  703.  
  704.  
  705. [renderBmpButton]
  706.     'render the bmpbutton at idx.
  707.     'assume an font 8 bits wide
  708.     'type$(idx) = "bmpbutton"
  709.     width(idx) = 20
  710.     height(idx) = 20
  711.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  712.     print #form, "drawbmp "; bmpName$(idx); " "; xOrg(idx); " "; yOrg(idx);
  713.     result = postRender(idx, displayOrdering)
  714.     return
  715.  
  716.  
  717. [renderComboBox]
  718.     'render the comboBox at idx.
  719.     'type$(idx) = "combobox"
  720.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  721.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  722.     print #form, "color black ; backcolor white ; size 1" ;
  723.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx)-24; " "; yOrg(idx)+22 ;
  724.     print #form, "drawbmp comboButton "; xOrg(idx)+width(idx)-16 ; " "; yOrg(idx) ;
  725.     result = postRender(idx, displayOrdering)
  726.     return
  727.  
  728. [renderTextBox]
  729.     'render the textbox at idx.
  730.     'type$(idx) = "textbox"
  731.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ; " ; place "; xOrg(idx); " "; yOrg(idx) ;
  732.     print #form, "color black ; backcolor white ; size 1" ;
  733.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx) ;
  734.     result = postRender(idx, displayOrdering)
  735.     return
  736.  
  737.  
  738. [renderTextEdit]
  739.     'render the textedit at idx.
  740.     'type$(idx) = "textedit"
  741.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  742.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  743.     print #form, "color black ; backcolor white ; size 1" ;
  744.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx) ;
  745.     print #form, "color black ; backcolor lightgray" ;
  746.     print #form, "place "; xOrg(idx)+width(idx)-17; " "; yOrg(idx);
  747.     print #form, "boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx)-17 ;
  748.     print #form, "drawbmp scrollUp "; xOrg(idx)+width(idx)-17; " "; yOrg(idx);
  749.     print #form, "drawbmp scrollDown "; xOrg(idx)+width(idx)-17; " "; yOrg(idx)+height(idx)-33;
  750.     print #form, "place "; xOrg(idx); " "; yOrg(idx)+height(idx)-17;
  751.     print #form, "boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx) ;
  752.     print #form, "drawbmp scrollLeft "; xOrg(idx); " "; yOrg(idx)+height(idx)-17;
  753.     print #form, "drawbmp scrollRight "; xOrg(idx)+width(idx)-33; " "; yOrg(idx)+height(idx)-17;
  754.     result = postRender(idx, displayOrdering)
  755.     return
  756.  
  757.  
  758. [renderListBox]
  759.     'render the listbox at idx.
  760.     'type$(idx) = "listbox"
  761.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  762.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  763.     print #form, "color black ; backcolor white ; size 1" ;
  764.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx) ;
  765.     print #form, "color black ; backcolor lightgray" ;
  766.     print #form, "place "; xOrg(idx)+width(idx)-17; " "; yOrg(idx);
  767.     print #form, "boxfilled "; xOrg(idx)+width(idx); " "; yOrg(idx)+height(idx) ;
  768.     print #form, "drawbmp scrollUp "; xOrg(idx)+width(idx)-17; " "; yOrg(idx);
  769.     print #form, "drawbmp scrollDown "; xOrg(idx)+width(idx)-17; " "; yOrg(idx)+height(idx)-17;
  770.     result = postRender(idx, displayOrdering)
  771.     return
  772.  
  773. [renderGraphicBox]
  774.     'render the graphicbox at idx.  assume a font 8x15.
  775.     'type$(idx) = "graphicbox"
  776.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  777.     print #form, "place "; xOrg(idx)+4 ; " "; yOrg(idx)+8 ;
  778.     print #form, "color black ; backcolor "; boxcolor$ ;"; size 1" ;
  779.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  780.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx)-4; " "; yOrg(idx)+height(idx)-7 ;
  781.     result = postRender(idx, displayOrdering)
  782.     return
  783.  
  784. [renderGroupBox]
  785.     'render the groupbox at idx.  assume a font 8x15.
  786.     'type$(idx) = "groupbox"
  787.     print #form, "place "; xOrg(idx); " "; yOrg(idx) ;
  788.     print #form, "place "; xOrg(idx)+4 ; " "; yOrg(idx)+8 ;
  789.     print #form, "color black ; backcolor white ; size 1" ;
  790.     if Platform$ = "OS/2" then print #form, "backcolor palegray" ;
  791.     print #form, "down ; boxfilled "; xOrg(idx)+width(idx)-4; " "; yOrg(idx)+height(idx)-7 ;
  792.     print #form, "place "; xOrg(idx)+8; " "; yOrg(idx)+15 ;
  793.     print #form, "\"; label$(idx);
  794.     result = postRender(idx, displayOrdering)
  795.     return
  796.  
  797. [inspectControl]
  798.     'pop up a dialog for displaying/modifying control
  799.     'properties
  800.  
  801.     if index < 2 then [inputLoop]
  802.  
  803.     if inspectIsOpen = 1 then close #inspect
  804.     inspectIsOpen = 1
  805.  
  806. NOMAINWIN
  807. WindowWidth =  155 : WindowHeight =  255
  808. UpperLeftX=100:UpperLeftY=50
  809.     statictext #inspect.st, "type",    1, 0, 48, 18
  810.     statictext #inspect.sx, "x-org",   1, 21, 48, 18
  811.     statictext #inspect.sy, "y-org",   1, 42, 48, 18
  812.     statictext #inspect.sw, "width",   1, 63, 48, 18
  813.     statictext #inspect.sh, "height",  1, 84, 48, 18
  814.     statictext #inspect.sc, "caption", 1, 105, 48, 18
  815.     statictext #inspect.sb, "branch",  1, 126, 48, 18
  816.     statictext #inspect.se, ".ext",    1, 147, 48, 18
  817.     statictext #inspect.sa, "array(",  1, 168, 48, 18
  818.  
  819.     statictext #inspect.type, "Type",  50, 0, 90, 18
  820.     textbox #inspect.x,                50, 21, 90, 24
  821.     textbox #inspect.y,                50, 42, 90, 24
  822.     textbox #inspect.w,                50, 63, 90, 24
  823.     textbox #inspect.h,                50, 84, 90, 24
  824.     textbox #inspect.labelField,       50, 105, 90, 24
  825.     textbox #inspect.branchLabelField, 50, 126, 90, 24
  826.     textbox #inspect.nameField,        50, 147, 90, 24
  827.     textbox #inspect.arrayNameField,   50, 168, 90, 24
  828.  
  829.     button #inspect.default, "Accept",[acceptInspect],UL,74,196,70,24
  830.     button #inspect.cancel, "Cancel",[cancelInspect],UL,  1,196,70,24
  831.  
  832.     Open "Properties" for dialog as #inspect
  833.     print #inspect, "trapclose [cancelInspect]";
  834.     print #inspect, "font ms_sans_serif 8"
  835.     print #inspect.x, "!setfocus"
  836.  
  837.     print #inspect.type, upper$(type$(index))
  838.  
  839.     print #inspect.labelField, label$(index)
  840.     print #inspect.nameField, names$(index)
  841.     print #inspect.branchLabelField, branchLabel$(index)
  842.     print #inspect.arrayNameField, arrayName$(index)
  843.     dummyx$=str$(xOrg(index)-xOrg-4)
  844.     dummyy$=str$(yOrg(index)-yOrg-20-4)
  845.     print #inspect.x, dummyx$
  846.     print #inspect.y, dummyy$
  847.     print #inspect.w, str$(width(index))
  848.     print #inspect.h, str$(height(index))
  849.  
  850.     if instr(" button statictext checkbox radiobutton graphicbox groupbox ", type$(index)) = 0 then print #inspect.labelField, "n/a"
  851.     if instr(controlsThatBranch$, type$(index)) = 0 then print #inspect.branchLabelField, "n/a"
  852.     if instr(" listbox combobox ", type$(index)) > 0 then print #inspect.arrayNameField, arrayName$(index) else print #inspect.arrayNameField, "n/a"
  853.  
  854.     goto [inputLoop]
  855.  
  856.  
  857. [acceptInspect]
  858.     'set the properties as modified by the user
  859.     isModified = 1  'the form has been modified
  860.     print #inspect.nameField, "!contents? names$" : names$(index) = names$
  861.     branches = instr(controlsThatBranch$, type$(index))
  862.     if branches > 0 then print #inspect.branchLabelField, "!contents? bLabel$" : branchLabel$(index) = bLabel$
  863.     usesArray = instr(" listbox combobox ", type$(index))
  864.     if usesArray > 0 then print #inspect.arrayNameField, "!contents? aName$" : arrayName$(index) = aName$
  865.  
  866.     print #inspect.x, "!contents? dummy$" : xOrg(index)=val(dummy$)+xOrg+4
  867.     print #inspect.y, "!contents? dummy$" : yOrg(index)=val(dummy$)+yOrg+24
  868.     print #inspect.w, "!contents? dummy$" : width(index)=val(dummy$)
  869.     print #inspect.h, "!contents? dummy$" : height(index)=val(dummy$)
  870.     print #inspect.labelField, "!contents? label$" : label$(index) = label$ 
  871.  
  872.     close #inspect
  873.     inspectIsOpen = 0
  874.  
  875.     gosub [redrawAll]
  876.     goto [inputLoop]
  877.  
  878.  
  879. [cancelInspect]
  880.     'close the inspector window
  881.     close #inspect
  882.     inspectIsOpen = 0
  883.     goto [inputLoop]
  884.  
  885.  
  886. [setForSelection]
  887.     'set up event handling for the default behavior (selection)
  888.     print #form, "when leftButtonDown [selectControl]";
  889.     print #form, "when leftButtonDouble [inspectControl]";
  890.     print #form, "when rightButtonDown [popupMenu]";
  891.     print #form, "when leftButtonMove" ;
  892.     print #form, "when leftButtonUp" ;
  893.  
  894.     goto [inputLoop]
  895.  
  896.  
  897. [selectControl]
  898.     'set up event handling
  899.     print #form, "when leftButtonUp [setForSelection]" ;
  900.     print #form, "when leftButtonDown" ;
  901.  
  902.     'highlight the control at the mouse click position
  903.     x = MouseX : y = MouseY
  904.  
  905.     if index = 0 then [dontDeselect]
  906.  
  907.     'check to see if the resize handle has been clicked on, if applicable
  908.     if instr(resizeable$, type$(index)) = 0 then [deselect]
  909.     if x < xOrg(index)+width(index)-3 or x > xOrg(index)+width(index)+3 then [deselect]
  910.     if y < yOrg(index)+height(index)-3 or y > yOrg(index)+height(index)+3 then [deselect]
  911.     goto [resizeControl]
  912.  
  913. [deselect]
  914.     print #form, "delsegment "; selectId -1 ;
  915.     gosub [selectDeselect]
  916.     index = 0
  917.     print #form, "delsegment "; selectId - 1 ;
  918.  
  919. [dontDeselect]
  920.     gosub [determineControl]
  921.     if newIndex = 0 then [setUpMovementEvent]
  922.  
  923.     index = newIndex
  924.     gosub [selectDeselect]
  925.     lastMouseX = MouseX
  926.     lastMouseY = MouseY
  927.  
  928. [setUpMovementEvent]
  929.     if type$(newIndex) = "windowframe" then [inputLoop]
  930.     print #form, "when leftButtonMove [beginObjectMove]" ;
  931.     goto [inputLoop]
  932.  
  933.  
  934. [determineControl]
  935.  
  936.     'based on x/y, determine which control is selected
  937.     'set newIndex to point to this control, if found
  938.     'otherwise set newIndex to 0
  939.  
  940.     if objectCount = 0 then return
  941.  
  942.     newIndex = 0
  943.     for i = objectCount to 1 step -1
  944.         if newIndex > 0 then [skipControl]
  945.         if type$(i) = "" then [skipControl]
  946.         if x < xOrg(i) or x > xOrg(i)+width(i) then [skipControl]
  947.         if y < yOrg(i) or y > yOrg(i)+height(i) then [skipControl]
  948.         newIndex = i
  949.         i = 1
  950. [skipControl]
  951.     next i
  952.  
  953.     return
  954.  
  955.  
  956. [selectDeselect]
  957.     'select or deselect the object at index by drawing handles
  958.     xOrgIdx = xOrg(index)
  959.     yOrgIdx = yOrg(index)
  960.     xow = xOrgIdx+width(index)
  961.     yoh = yOrgIdx+height(index)
  962.     print #form, "rule xor ; down";
  963.     if type$(index) = "windowframe" then [drawSizingHandle]
  964.     print #form, "color darkgray ; backcolor white" ;
  965.     print #form, "place "; xOrgIdx-3; " "; yOrgIdx-3 ;
  966.     print #form, "boxfilled "; xOrgIdx+3; " "; yOrgIdx+3 ;
  967.     print #form, "place "; xow-3; " "; yOrgIdx-3 ;
  968.     print #form, "boxfilled "; xow+3; " "; yOrgIdx+3 ;
  969.     print #form, "place "; xOrgIdx-3; " "; yoh-3 ;
  970.     print #form, "boxfilled "; xOrgIdx+3; " "; yoh+3 ;
  971.  
  972.   [drawSizingHandle]
  973.     if instr(resizeable$, type$(index)) > 0 then print #form, "backcolor black" ;
  974.     print #form, "place "; xow-3; " "; yoh-3 ;
  975.     print #form, "boxfilled "; xow+3; " "; yoh+3 ;
  976.     print #form, "rule over ; flush" ;
  977.     print #form, "segment" ;
  978.     input #form, selectId
  979.  
  980.  
  981.     return
  982.  
  983.  
  984. [deselectOnly]  'if there is a selected control, deselect it
  985.     if index = 0 then return  'nothing is selected, do nothing
  986.     print #form, "delsegment "; selectId -1 ;
  987.     gosub [selectDeselect]
  988.     index = 0
  989.     print #form, "delsegment "; selectId - 1 ;
  990.  
  991.     return
  992.  
  993.  
  994.  
  995. [beginObjectMove]
  996.     'if the mouse has only slightly moved, ignore the event
  997.     if abs(MouseX - x) < 3 and abs(MouseY - y) < 3 then [inputLoop]
  998.  
  999.     'set up to begin moving the selected object
  1000.     print #form, "delsegment "; selectId - 1 ;
  1001.     print #form, "when leftButtonMove [additionalObjectMoves]" ;
  1002.     print #form, "when leftButtonUp [acceptMovement]" ;
  1003.  
  1004.  
  1005. [additionalObjectMoves]
  1006.     'adjust the position of the selected object, then draw an object frame the size of the
  1007.     'selected object at that new position using xor rule.  set event handling to manage
  1008.     'additional movements or termination of this object's movement.
  1009.  
  1010.     gosub [snapMouse]
  1011.     if MouseX = lastMouseX and MouseY = lastMouseY then [inputLoop]
  1012.  
  1013.     gosub [eraseObjectFrame]
  1014.     xOrg(index) = xOrg(index) + (MouseX - lastMouseX)
  1015.     yOrg(index) = yOrg(index) + (MouseY - lastMouseY)
  1016.     gosub [snapXY]
  1017.     lastMouseX = MouseX
  1018.     lastMouseY = MouseY
  1019.  
  1020.     print #form, "color black ; backcolor white ; size 1" ;
  1021.     print #form, "place "; xOrg(index); " "; yOrg(index) ;
  1022.     print #form, "down ; rule xor ; box "; xOrg(index)+width(index); " "; yOrg(index)+height(index) ;
  1023.     print #form, "rule over ; up ; flush" ;
  1024.     print #form, "segment" : input #form, id
  1025.     print #form, "delsegment "; id - 1 ;
  1026.  
  1027.     goto [inputLoop]
  1028.  
  1029.  
  1030. [eraseObjectFrame]
  1031.     'erase the object frame (for movement)
  1032.     print #form, "color black ; backcolor white ; size 1" ;
  1033.     print #form, "place "; xOrg(index); " "; yOrg(index) ;
  1034.     print #form, "down ; rule xor ; box "; xOrg(index)+width(index); " "; yOrg(index)+height(index) ;
  1035.     print #form, "rule over ; up ; flush" ;
  1036.     print #form, "segment" : input #form, id
  1037.     print #form, "delsegment "; id - 1 ;
  1038.  
  1039.     return
  1040.  
  1041.  
  1042. [acceptResizing]
  1043.     if width(index) < 25 then width(index) = 25
  1044.     if type$(index) <> "textbox" and height(index) < 20 then height(index) = 20
  1045.     if type$(index) = "textbox" and height(index) < 25 then height(index) = 25
  1046.  
  1047.     if type$(index) <> "windowframe" then [acceptMovement]
  1048.     if width(index) < 100 then width(index) = 100
  1049.     if height(index) < 50 then height(index) = 50
  1050.     windowXExtent = width(index)
  1051.     windowYExtent = height(index)
  1052.  
  1053.  
  1054. [acceptMovement]
  1055.     'end the movement phase, and redraw all objects
  1056.     print #form, "delsegment "; segment(index) - 1 ;
  1057.     gosub [redrawAll]
  1058.     'index = 0
  1059.     gosub [selectDeselect]
  1060.     firstObjectMove = false
  1061.     goto [setForSelection]
  1062.  
  1063.  
  1064. [resizeControl]
  1065.     'set up to begin resizing the selected object
  1066.     firstObjectMove = true
  1067.     print #form, "delsegment "; selectId - 1 ;
  1068.     print #form, "when leftButtonMove [additionalResizes]" ;
  1069.     print #form, "when leftButtonUp [acceptResizing]" ;
  1070.     gosub [snapMouse]
  1071.     lastMouseX = MouseX
  1072.     lastMouseY = MouseY
  1073.  
  1074. [additionalResizes]
  1075.     'adjust the position of the selected object, then draw an object frame the size of the
  1076.     'selected object at that new position using xor rule.  set event handling to manage
  1077.     'additional movements or termination of this object's movement.
  1078.  
  1079.     if firstObjectMove = false then gosub [eraseObjectFrame]
  1080.  
  1081.     gosub [snapMouse]
  1082.     width(index) = width(index) + (MouseX - lastMouseX)
  1083.     height(index) = height(index) + (MouseY - lastMouseY)
  1084.     gosub [snapWH]
  1085.     lastMouseX = MouseX
  1086.     lastMouseY = MouseY
  1087.  
  1088.     print #form, "color black ; backcolor white ; size 1" ;
  1089.     print #form, "place "; xOrg(index); " "; yOrg(index) ;
  1090.     print #form, "down ; rule xor ; box "; xOrg(index)+width(index); " "; yOrg(index)+height(index) ;
  1091.     print #form, "rule over ; up ; flush" ;
  1092.     print #form, "segment" : input #form, id
  1093.     print #form, "delsegment "; id - 1 ;
  1094.  
  1095.     goto [inputLoop]
  1096.  
  1097.  
  1098. [snapMouse]  'if snapOn is selected, then snap the mouse to grid
  1099.     if snapOn = 0 then return
  1100.  
  1101.     MouseX = int((MouseX + int(xInterval / 2)) / xInterval) * xInterval
  1102.     MouseY = int((MouseY + int(yInterval / 2)) / yInterval) * yInterval
  1103.     return
  1104.  
  1105.  
  1106. [snapWH]  'if snapOn is selected, then snap the width & height to grid
  1107.     if snapOn = 0 then return
  1108.  
  1109.     width(index) = int((width(index) + int(xInterval / 2)) / xInterval) * xInterval
  1110.     height(index) = int((height(index) + int(yInterval / 2)) / yInterval) * yInterval
  1111.     return
  1112.  
  1113.  
  1114. [snapXY]  'if snapOn is selected, then snap the x,y position to grid
  1115.     if snapOn = 0 then return
  1116.  
  1117.     xOrg(index) = int((xOrg(index) + int(xInterval / 2)) / xInterval) * xInterval
  1118.     yOrg(index) = int((yOrg(index) + int(yInterval / 2)) / yInterval) * yInterval
  1119.     return
  1120.  
  1121.  
  1122. [redrawAll]
  1123.     'redraw all controls
  1124.     isModified = 1  'the form has been modified
  1125.     print #form, "cls";
  1126.     index = 0
  1127.     gosub [renderWindow]
  1128.     if objectCount = 0 then return
  1129.     for idx = 1 to objectCount
  1130.         typeIdx$ = type$(idx)
  1131.         if typeIdx$ = "textbox" then gosub [renderTextBox] : goto [redrawNext]
  1132.         if typeIdx$ = "statictext" then gosub [renderStaticText] : goto [redrawNext]
  1133.         if typeIdx$ = "button" then gosub [renderButton] : goto [redrawNext]
  1134.         if typeIdx$ = "combobox" then gosub [renderComboBox] : goto [redrawNext]
  1135.         if typeIdx$ = "listbox" then gosub [renderListBox] : goto [redrawNext]
  1136.         if typeIdx$ = "bmpbutton" then gosub [renderBmpButton] : goto [redrawNext]
  1137.         if typeIdx$ = "radiobutton" then gosub [renderRadioButton] : goto [redrawNext]
  1138.         if typeIdx$ = "checkbox" then gosub [renderCheckBox] : goto [redrawNext]
  1139.         if typeIdx$ = "groupbox" then gosub [renderGroupBox] : goto [redrawNext]
  1140.         if typeIdx$ = "graphicbox" then gosub [renderGraphicBox] : goto [redrawNext]
  1141.         if typeIdx$ = "textedit" then gosub [renderTextEdit]
  1142.       [redrawNext]
  1143.     next idx
  1144.     gosub [clipControls]
  1145.     return
  1146.  
  1147. [clipControls]
  1148. 'erase any controls outside of window:
  1149.     xOrg = windowXOrigin
  1150.     yOrg = windowYOrigin
  1151.     xExt = windowXExtent
  1152.     yExt = windowYExtent
  1153.  
  1154.     print #form, "down;color 255 250 230";
  1155.     print #form, "backcolor 255 250 230";
  1156.     print #form, "place 0 ";yExt+yOrg
  1157.     print #form, "boxfilled 2000 2000";
  1158.     print #form, "place ";xExt+xOrg;" 0"
  1159.     print #form, "boxfilled 2000 2000";
  1160.     print #form, "place 0 0"
  1161.     print #form, "boxfilled ";xOrg;" 2000"
  1162.     gosub [renderToolbox]
  1163.     return
  1164.  
  1165.  
  1166. [moveToBack]
  1167.     'move the selected control to the back (first item drawn)
  1168.     if index < 2 or objectCount < 2 then [inputLoop]
  1169.     if index = 2 then gosub [redrawAll] : goto [inputLoop]
  1170.  
  1171.     tmpType$ = type$(index)
  1172.     tmpLabel$ = label$(index)
  1173.     tmpNames$ = names$(index)
  1174.     tmpXOrigin = xOrg(index)
  1175.     tmpYOrigin = yOrg(index)
  1176.     tmpWidth = width(index)
  1177.     tmpHeight = height(index)
  1178.     tmpCorner$ = corner$(index)
  1179.     tmpBranchLabel$ = branchLabel$(index)
  1180.     tmpSegment = segment(index)
  1181.     tmpHandle$ = handle$(index)
  1182.     tmpBmpName$ = bmpName$(index)
  1183.     tmpArrayName$ = arrayName$(index)
  1184.  
  1185.     for idx = index - 1 to 2 step -1
  1186.         type$(idx+1) = type$(idx)
  1187.         label$(idx+1) = label$(idx)
  1188.         names$(idx+1) = names$(idx)
  1189.         xOrg(idx+1) = xOrg(idx)
  1190.         yOrg(idx+1) = yOrg(idx)
  1191.         width(idx+1) = width(idx)
  1192.         height(idx+1) = height(idx)
  1193.         corner$(idx+1) = corner$(idx)
  1194.         branchLabel$(idx+1) = branchLabel$(idx)
  1195.         segment(idx+1) = segment(idx)
  1196.         handle$(idx+1) = handle$(idx)
  1197.         bmpName$(idx+1) = bmpName$(idx)
  1198.         arrayName$(idx+1) = arrayName$(idx)
  1199.     next idx
  1200.  
  1201.     type$(2) = tmpType$
  1202.     label$(2) = tmpLabel$
  1203.     names$(2) = tmpNames$
  1204.     xOrg(2) = tmpXOrigin
  1205.     yOrg(2) = tmpYOrigin
  1206.     width(2) = tmpWidth
  1207.     height(2) = tmpHeight
  1208.     corner$(2) = tmpCorner$
  1209.     branchLabel$(2) = tmpBranchLabel$
  1210.     segment(2) = tmpSegment
  1211.     handle$(2) = tmpHandle$
  1212.     bmpName$(2) = tmpBmpName$
  1213.     arrayName$(2) = tmpArrayName$
  1214.     gosub [redrawAll]
  1215.     index = 0 'necessary here
  1216.  
  1217.     goto [inputLoop]
  1218.  
  1219.  
  1220. [moveToFront]
  1221.     'move the selected control to the front (last item drawn)
  1222.     if index < 2 or objectCount < 2 then [inputLoop]
  1223.     if index = objectCount then gosub [redrawAll] : goto [inputLoop]
  1224.  
  1225.     tmpType$ = type$(index)
  1226.     tmpLabel$ = label$(index)
  1227.     tmpNames$ = names$(index)
  1228.     tmpXOrigin = xOrg(index)
  1229.     tmpYOrigin = yOrg(index)
  1230.     tmpWidth = width(index)
  1231.     tmpHeight = height(index)
  1232.     tmpCorner$ = corner$(index)
  1233.     tmpBranchLabel$ = branchLabel$(index)
  1234.     tmpSegment = segment(index)
  1235.     tmpHandle$ = handle$(index)
  1236.     tmpBmpName$ = bmpName$(index)
  1237.     tmpArrayName$ = arrayName$(index)
  1238.  
  1239.     for idx = index to objectCount - 1
  1240.         type$(idx) = type$(idx+1)
  1241.         label$(idx) = label$(idx+1)
  1242.         names$(idx) = names$(idx+1)
  1243.         xOrg(idx) = xOrg(idx+1)
  1244.         yOrg(idx) = yOrg(idx+1)
  1245.         width(idx) = width(idx+1)
  1246.         height(idx) = height(idx+1)
  1247.         corner$(idx) = corner$(idx+1)
  1248.         branchLabel$(idx) = branchLabel$(idx+1)
  1249.         segment(idx) = segment(idx+1)
  1250.         handle$(idx) = handle$(idx+1)
  1251.         bmpName$(idx) = bmpName$(idx+1)
  1252.         arrayName$(idx) = arrayName$(idx+1)
  1253.     next idx
  1254.  
  1255.     type$(objectCount) = tmpType$
  1256.     label$(objectCount) = tmpLabel$
  1257.     names$(objectCount) = tmpNames$
  1258.     xOrg(objectCount) = tmpXOrigin
  1259.     yOrg(objectCount) = tmpYOrigin
  1260.     width(objectCount) = tmpWidth
  1261.     height(objectCount) = tmpHeight
  1262.     corner$(objectCount) = tmpCorner$
  1263.     branchLabel$(objectCount) = tmpBranchLabel$
  1264.     segment(objectCount) = tmpSegment
  1265.     handle$(objectCount) = tmpHandle$
  1266.     bmpName$(objectCount) = tmpBmpName$
  1267.     arrayName$(objectCount) = tmpArrayName$
  1268.  
  1269.     gosub [redrawAll]
  1270.     gosub [selectDeselect]
  1271.  
  1272.     goto [inputLoop]
  1273.  
  1274.  
  1275. [deleteControl]
  1276.     'delete the selected control
  1277.     if index < 2 then [inputLoop]
  1278.  
  1279.     'delete graphical segments and clean up display
  1280.     print #form, "delsegment "; selectId -1 ;
  1281.     gosub [selectDeselect]
  1282.     print #form, "delsegment "; selectId - 1 ;
  1283.  
  1284.     for idx = index to objectCount
  1285.         type$(idx) = type$(idx+1)
  1286.         label$(idx) = label$(idx+1)
  1287.         names$(idx) = names$(idx+1)
  1288.         xOrg(idx) = xOrg(idx+1)
  1289.         yOrg(idx) = yOrg(idx+1)
  1290.         width(idx) = width(idx+1)
  1291.         height(idx) = height(idx+1)
  1292.         corner$(idx) = corner$(idx+1)
  1293.         branchLabel$(idx) = branchLabel$(idx+1)
  1294.         segment(idx) = segment(idx+1)
  1295.         handle$(idx) = handle$(idx+1)
  1296.         bmpName$(idx) = bmpName$(idx+1)
  1297.         arrayName$(idx) = arrayName$(idx+1)
  1298.     next idx
  1299.  
  1300.     objectCount = objectCount - 1
  1301.  
  1302.     gosub [redrawAll]
  1303.     index = 0
  1304.  
  1305.     goto [inputLoop]
  1306.  
  1307.  
  1308. [produceCodeAndOutline]
  1309.     'set a flag so that an outline will be added
  1310.     produceOutline = 1
  1311.  
  1312. [produceCode]
  1313.     'produce code for the controls in the form
  1314.     if codeIsOpen = 1 then close #code : codeIsOpen = 0
  1315.     WindowWidth=450:WindowHeight=330
  1316.     UpperLeftX=100:UpperLeftY=30
  1317.     open "Free Form output window" for text as #code
  1318.     codeIsOpen = 1
  1319.     print #code, ""
  1320.     print #code, ""
  1321.     print #code, "    WindowWidth = "; windowXExtent
  1322.     print #code, "    WindowHeight = "; windowYExtent
  1323.     print #code, ""
  1324.     if left$(windowType$, 8) = "graphics" then print #code, "    nomainwin";chr$(13); ""
  1325.  
  1326.     if objectCount < 2 then [menuCode]
  1327.  
  1328.     for x = 2 to objectCount
  1329.         if type$(x) = "button" then gosub [codeForButton]
  1330.         if type$(x) = "combobox" then gosub [codeForComboBox]
  1331.         if type$(x) = "textbox" then gosub [codeForTextBox]
  1332.         if type$(x) = "listbox" then gosub [codeForListBox]
  1333.         if type$(x) = "bmpbutton" then gosub [codeForBmpButton]
  1334.         if type$(x) = "statictext" then gosub [codeForStaticText]
  1335.         if type$(x) = "radiobutton" then gosub [codeForRadioButton]
  1336.         if type$(x) = "checkbox" then gosub [codeForCheckBox]
  1337.         if type$(x) = "graphicbox" then gosub [codeForGraphicBox]
  1338.         if type$(x) = "groupbox" then gosub [codeForGroupBox]
  1339.         if type$(x) = "textedit" then gosub [codeForTextEdit]
  1340.         print #code, code$
  1341.     next x
  1342.  
  1343. [menuCode]   'write menu code
  1344.     if menuCount = 0 then [noMenuCode]
  1345.  
  1346.     if left$(windowType$, 6) = "dialog" then print #code, "    '*** menus are not supported in windows of type "; windowType$; " ***"
  1347.  
  1348.     for x = 0 to menuCount - 1
  1349.         print #code, "    menu "; winHandle$; ", "; qu$; menu$(x); qu$;
  1350.         if menuItemCount(x) = 0 then print #code, ", "; chr$(34); "&FixMe"; chr$(34); ", [fixMe]  ' <-- this menu has no items!" : goto [produceNextMenu]
  1351.         for y = 0 to menuItemCount(x) - 1
  1352.             print #code, ", ";
  1353.             mi$ = menuItem$(x, y)
  1354.             print #code, qu$; left$(mi$, instr(mi$, chr$(0)) - 1) ; qu$;
  1355.             print #code, ", "; mid$(mi$, instr(mi$, chr$(0)) + 1) ;
  1356.         next y
  1357.         print #code, ""
  1358.       [produceNextMenu]
  1359.     next x
  1360.  
  1361.  
  1362. [noMenuCode] 'don't produce menu code
  1363.     print #code, "    open "; qu$; windowLabel$; qu$; " for "; windowType$; " as "; winHandle$
  1364.     for idx = 1 to objectCount
  1365.         if type$(idx) = "graphicbox" then  print #code, "    print ";winHandle$;".graph, ";qu$;"fill "; boxcolor$;"; flush";qu$ 
  1366.      next idx
  1367.     if left$(windowType$, 8) = "graphics" then print #code, "    print ";winHandle$;", ";qu$;"fill "; wincolor$;"; flush";qu$
  1368.     print #code, "    print ";winHandle$;", ";qu$;"font "; font$(1);qu$
  1369.     if produceOutline = 0 then [doneProducingCode]
  1370.  
  1371. [produceOutline]
  1372.     inputLoopLabel$ = "[" + mid$(winHandle$, 2) + ".inputLoop]"
  1373.  
  1374.     print #code, ""
  1375.     print #code, ""
  1376.     print #code, inputLoopLabel$; "   'wait here for input event"
  1377.     print #code, "    wait"
  1378.     print #code, "    goto "; inputLoopLabel$
  1379.     print #code, ""
  1380.  
  1381.     produceOutline = 0
  1382.     branchLabels$ = ""
  1383.  
  1384.     if objectCount < 2 then [outlineForMenus]
  1385.  
  1386.     for x = 2 to objectCount
  1387.         if left$(trim$(branchLabel$(x)), 1) <> "[" then [nextOutlineObject]
  1388.         if instr(trim$(branchLabel$(x)), " ") > 0 then gosub [handleMultiBranchLabels] : goto [nextOutlineObject]
  1389.         if instr(branchLabels$, branchLabel$(x)) > 0 then [nextOutlineObject]
  1390.         branchLabels$ = branchLabels$ + " " + branchLabel$(x)
  1391.         print #code, ""
  1392.         print #code, ""
  1393.         print #code, branchLabel$(x); "   'Perform action for the "; type$(x); " named '"; names$(x); "'"
  1394.         print #code, ""
  1395.         print #code, "    'Insert your own code here"
  1396.         print #code, ""
  1397.         print #code, "    goto "; inputLoopLabel$
  1398.  
  1399.       [nextOutlineObject]
  1400.     next x
  1401.  
  1402. [outlineForMenus]   'produce outline code for menus
  1403.     if menuCount = 0 then [doneProducingCode]
  1404.  
  1405.     for x = 0 to menuCount - 1
  1406.         if menuItemCount(x) = 0 then [writeNextMenu]
  1407.         for y = 0 to menuItemCount(x) - 1
  1408.             mi$ = menuItem$(x, y)
  1409.             bl$ = mid$(mi$, instr(mi$, chr$(0)) + 1)
  1410.             if instr(branchLabels$, bl$) > 0 then [writeNextMenuItem]
  1411.             branchLabels$ = branchLabels$ + " " + bl$
  1412.             print #code, ""
  1413.             print #code, ""
  1414.             print #code, bl$; "   'Perform action for menu "; menu$(x); ", item "; left$(mi$, instr(mi$, chr$(0)) - 1)
  1415.             print #code, ""
  1416.             print #code, "    'Insert your own code here"
  1417.           [writeNextMenuItem]
  1418.         next y
  1419.       [writeNextMenu]
  1420.     next x
  1421.  
  1422.  
  1423. [doneProducingCode]
  1424.     print #code, "!selectall";
  1425.     print #code, "!copy";
  1426.     print #code, "!origin 1 1";
  1427.     notice "Done.  This code has been copied to clipboard.  You may paste it into your program."
  1428.     goto [inputLoop]
  1429.  
  1430.  
  1431. [handleMultiBranchLabels]   'handle the case where a control has more than 1 branching option
  1432.     if instr(branchLabels$, word$(branchLabel$(x), 1)) > 0 then [nextMultiBranchLabel]
  1433.     print #code, ""
  1434.     print #code, ""
  1435.     print #code, word$(branchLabel$(x), 1); "   'Perform action for the "; type$(x); " named '"; names$(x); "'"
  1436.     print #code, ""
  1437.     print #code, "    'Insert your own code here"
  1438.     print #code, ""
  1439.     print #code, "    goto "; inputLoopLabel$
  1440.  
  1441.     branchLabels$ = branchLabels$ + " " + word$(branchLabel$(x), 1)
  1442.  
  1443.   [nextMultiBranchLabel]
  1444.     if instr(branchLabels$, word$(branchLabel$(x), 2)) > 0 then [doneMultiBranchLabel]
  1445.     print #code, ""
  1446.     print #code, ""
  1447.     print #code, word$(branchLabel$(x), 2); "   'Perform action for the "; type$(x); " named '"; names$(x); "'"
  1448.     print #code, ""
  1449.     print #code, "    'Insert your own code here"
  1450.     print #code, ""
  1451.     print #code, "    goto "; inputLoopLabel$
  1452.     branchLabels$ = branchLabels$ + " " + word$(branchLabel$(x), 2)
  1453.  
  1454.   [doneMultiBranchLabel]
  1455.     return
  1456.  
  1457.  
  1458. [codeForButton]
  1459.     'produce code for a text button
  1460.     code$ = "    button "+winHandle$+"."+names$(x)+", "+qu$+label$(x)+qu$+", "+branchLabel$(x)+", "+corner$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1461.     return
  1462.  
  1463. [codeForBmpButton]
  1464.     'produce code for a bmp button
  1465.     code$ = "    bmpbutton "+winHandle$+"."+names$(x)+", "+qu$+bmpName$(x)+qu$+", "+branchLabel$(x)+", "+corner$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)
  1466.     return
  1467.  
  1468. [codeForTextBox]
  1469.     'produce code for a text box
  1470.     code$ = "    textbox "+winHandle$+"."+names$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1471.     return
  1472.  
  1473. [codeForStaticText]
  1474.    'produce code for a static text
  1475.     code$ = "    statictext "+winHandle$+"."+names$(x)+", "+qu$+label$(x)+qu$+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1476.     return
  1477.  
  1478. [codeForGroupBox]
  1479.     'produce code for a group box
  1480.      code$ = "    groupbox "+winHandle$+"."+names$(x)+", "+qu$+label$(x)+qu$+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1481.     return
  1482.  
  1483. [codeForGraphicBox]
  1484.     'produce code for a graphic box
  1485.     code$ = "    graphicbox "+winHandle$+".graph, "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1486.     return
  1487.  
  1488. [codeForListBox]
  1489.     'produce code for a listbox
  1490.     code$ = "    listbox "+winHandle$+"."+names$(x)+", "+arrayName$(x)+", "+branchLabel$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1491.     return
  1492.  
  1493. [codeForComboBox]
  1494.     'produce code for a listbox
  1495.     code$ = "    combobox "+winHandle$+"."+names$(x)+", "+arrayName$(x)+", "+branchLabel$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1496.     return
  1497.  
  1498. [codeForRadioButton]
  1499.     'produce code for a radiobutton
  1500.     code$ = "    radiobutton "+winHandle$+"."+names$(x)+", "+qu$+label$(x)+qu$+", "+word$(branchLabel$(x), 1)+", "+word$(branchLabel$(x), 2)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1501.     return
  1502.  
  1503. [codeForCheckBox]
  1504.     'produce code for a checkbox
  1505.     code$ = "    checkbox "+winHandle$+"."+names$(x)+", "+qu$+label$(x)+qu$+", "+word$(branchLabel$(x), 1)+", "+word$(branchLabel$(x), 2)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1506.     return
  1507.  
  1508. [codeForTextEdit]
  1509.     'produce code for a text edit box
  1510.     code$ = "    texteditor "+winHandle$+"."+names$(x)+", "+str$(xOrg(x)-xOrg-4)+", "+str$(yOrg(x)-yOrg-20-4)+", "+str$(width(x))+", "+str$(height(x))
  1511.     return
  1512.  
  1513.  
  1514. [newFile]
  1515.     'clear the contents of the form editor and start over
  1516.  
  1517.     if isModified = 1 then gosub [formIsModified]
  1518.  
  1519.     newControlNumber = 0
  1520.     windowLabel$ = "untitled"
  1521.     windowType$ = "window"
  1522.     objectCount = 0
  1523.     winHandle$ = "#main"
  1524.     windowXExtent = 550
  1525.     windowYExtent = 410
  1526.  
  1527.     gosub [clearMenuData]
  1528.     gosub [addWindowFrame]
  1529.     gosub [redrawAll]
  1530.  
  1531.     isModified = 0
  1532.  
  1533.     goto [inputLoop]
  1534.  
  1535.  
  1536. [saveFile]
  1537.     'abort if no controls
  1538.     if objectCount < 2 then notice "No controls.  Save aborted" : goto [inputLoop]
  1539.     confirm "Click YES to save in new format, NO to save in old format";answer$
  1540.  
  1541.     if answer$="yes" then
  1542.         'save the form into a *.fr2 file
  1543.         if formName$ = "" then formName$ = "untitled.fr2"
  1544.         filedialog "Save form", "*.fr2", formName$
  1545.         if formName$ = "" then [inputLoop]
  1546.     else
  1547.         if formName$ = "" then formName$ = "untitled.fre"
  1548.         filedialog "Save form", "*.fre", formName$
  1549.         if formName$ = "" then [inputLoop]
  1550.     end if
  1551.  
  1552.     gosub [saveFormSubroutine]
  1553.  
  1554.     notice "Done.  File saved as " + formName$
  1555.     goto [inputLoop]
  1556.  
  1557.  
  1558. [saveFormSubroutine]   'the subroutine portion of the save routine
  1559.     open formName$ for output as #formOut
  1560.     print #formOut, newControlNumber
  1561.     print #formOut, windowLabel$
  1562.     print #formOut, windowType$
  1563.     print #formOut, objectCount
  1564.     print #formOut, winHandle$
  1565.     print #formOut, snapOn
  1566.     print #formOut, xInterval
  1567.     print #formOut, yInterval
  1568.     print #formOut, menuCount
  1569.     print #formOut, windowXExtent
  1570.     print #formOut, windowYExtent
  1571.     if lower$(right$(formName$,3))="fr2" then print #formOut, font$(1)
  1572.  
  1573.     for i = 2 to objectCount
  1574.         print #formOut, type$(i)
  1575.         print #formOut, label$(i)
  1576.         print #formOut, names$(i)
  1577.         print #formOut, xOrg(i)
  1578.         print #formOut, yOrg(i)
  1579.         print #formOut, width(i)
  1580.         print #formOut, height(i)
  1581.         print #formOut, corner$(i)
  1582.         print #formOut, branchLabel$(i)
  1583.         print #formOut, segment(i)
  1584.         print #formOut, handle$(i)
  1585.         print #formOut, bmpName$(i)
  1586.         print #formOut, arrayName$(i)
  1587.     next i
  1588.  
  1589.     'Now write the menu information
  1590.     if menuCount = 0 then [noMenusToSave]
  1591.  
  1592.     for i = 0 to menuCount - 1
  1593.         print #formOut, menu$(i)
  1594.         print #formOut, menuItemCount(i)
  1595.         if menuItemCount(i) = 0 then [noMenuItemsToSave]
  1596.         for j = 0 to menuItemCount(i) - 1
  1597.             print #formOut, menuItem$(i, j)
  1598.         next j
  1599.       [noMenuItemsToSave]
  1600.     next i
  1601.  
  1602.  
  1603. [noMenusToSave]
  1604.     close #formOut
  1605.     return
  1606.  
  1607.  
  1608. [openFile]
  1609.     'load the form from a *.fr2 file
  1610.  
  1611.     if isModified = 1 then gosub [formIsModified]
  1612.  
  1613.     filedialog "Load form", "*.fr2;*.fre", formName$
  1614.     if formName$ = "" then [inputLoop]
  1615.  
  1616.     gosub [clearMenuData]
  1617.     objectCount = 0
  1618.     gosub [addWindowFrame]
  1619.  
  1620.     open formName$ for input as #formIn
  1621.     input #formIn, newControlNumber
  1622.     input #formIn, windowLabel$
  1623.     input #formIn, windowType$
  1624.     input #formIn, objectCount
  1625.     input #formIn, winHandle$
  1626.     input #formIn, snapOn
  1627.     input #formIn, xInterval
  1628.     input #formIn, yInterval
  1629.     input #formIn, menuCount
  1630.     input #formIn, windowXExtent
  1631.     input #formIn, windowYExtent
  1632.  
  1633.     if lower$(right$(formName$,3))="fr2" then
  1634.         input #formIn, fontChosen$
  1635.         if fontChosen$<>"" then font$(1)=fontChosen$ 
  1636.     end if
  1637.  
  1638.     width(1) = windowXExtent
  1639.     height(1) = windowYExtent
  1640.  
  1641.     for i = 2 to objectCount
  1642.         input #formIn, tmp$ : type$(i) = tmp$
  1643.         input #formIn, tmp$ : label$(i) = tmp$
  1644.         input #formIn, tmp$ : names$(i) = tmp$
  1645.         input #formIn, tmp  : xOrg(i) = tmp
  1646.         input #formIn, tmp  : yOrg(i) = tmp
  1647.         input #formIn, tmp  : width(i) = tmp
  1648.         input #formIn, tmp  : height(i) = tmp
  1649.         input #formIn, tmp$ : corner$(i) = tmp$
  1650.         input #formIn, tmp$ : branchLabel$(i) = tmp$
  1651.         input #formIn, tmp  : segment(i) = tmp
  1652.         input #formIn, tmp$ : handle$(i) = tmp$
  1653.         input #formIn, tmp$ : bmpName$(i) = tmp$
  1654.         if trim$(tmp$) > "" then loadbmp tmp$, tmp$
  1655.         input #formIn, tmp$ : arrayName$(i) = tmp$
  1656.     next i
  1657.  
  1658.     if menuCount = 0 then [noMenusToRead]
  1659.  
  1660.     for i = 0 to menuCount - 1
  1661.         input #formIn, tmp$ : menu$(i)=tmp$
  1662.         input #formIn, tmp : menuItemCount(i) = tmp
  1663.         if menuItemCount(i) = 0 then [noMenuItemsToRead]
  1664.         for j = 0 to menuItemCount(i) - 1
  1665.             input #formIn, tmp$ : menuItem$(i, j) = tmp$
  1666.         next j
  1667.       [noMenuItemsToRead]
  1668.     next i
  1669.  
  1670. [noMenusToRead]
  1671.     close #formIn
  1672.     gosub [redrawAll]
  1673.  
  1674.     isModified = 0
  1675.  
  1676.     goto [inputLoop]
  1677.  
  1678.  
  1679.  
  1680.  
  1681. [gridDialog]  'open a dialog box for selecting & adjusting snap to grid
  1682.     WindowWidth = 250
  1683.     WindowHeight = 250
  1684.  
  1685.     if gridDialogIsOpen = 1 then close #gridDialog
  1686.  
  1687.     statictext #gridDialog.statictext2, "Select here whether control positions will", 26, 16, 336, 20
  1688.     statictext #gridDialog.statictext5, "automatically snap to gridded positions,", 26, 35, 320, 20
  1689.     statictext #gridDialog.statictext6, "and what the interval will be.", 26, 54, 240, 20
  1690.     checkbox #gridDialog.snapOnOff, "Snap to Grid", [snapOn], [snapOff], 26, 85, 120, 20
  1691.     statictext #gridDialog.statictext7, "X interval:", 34, 112, 70, 20
  1692.     textbox #gridDialog.xIntrvl, 34, 136, 38, 25
  1693.     statictext #gridDialog.statictext9, "Y interval:", 124, 112, 70, 20
  1694.     textbox #gridDialog.yIntrvl, 124, 136, 38, 25
  1695.     button #gridDialog, "OK", [acceptGridDialog], UL, 119, 175,80,24
  1696.     button #gridDialog, "Cancel", [cancelGridDialog], UL, 29, 175,80,24
  1697.     open "Snap to Grid" for dialog_modal as #gridDialog
  1698.     print #gridDialog, "trapclose [cancelGridDialog]"
  1699.     gridDialogIsOpen = 1
  1700.  
  1701.     if snapOn = 1 then snapOnSelected = 1 : print #gridDialog.snapOnOff, "set"
  1702.     print #gridDialog.xIntrvl, xInterval
  1703.     print #gridDialog.yIntrvl, yInterval
  1704.  
  1705.     goto [inputLoop]
  1706.  
  1707.  
  1708. [snapOn]   'Perform on action for the checkbox named 'snapOnOff'
  1709.     snapOnSelected = 1
  1710.     goto [inputLoop]
  1711.  
  1712.  
  1713. [snapOff]   'Perform off action for the checkbox named 'snapOnOff'
  1714.     snapOnSelected = 0
  1715.     goto [inputLoop]
  1716.  
  1717.  
  1718. [acceptGridDialog]
  1719.     snapOn = snapOnSelected
  1720.     print #gridDialog.xIntrvl, "!contents?"
  1721.     input #gridDialog.xIntrvl, xInterval
  1722.     print #gridDialog.yIntrvl, "!contents?"
  1723.     input #gridDialog.yIntrvl, yInterval
  1724.  
  1725.  
  1726. [cancelGridDialog]
  1727.     gridDialogIsOpen = 0
  1728.     close #gridDialog
  1729.     goto [inputLoop]
  1730.  
  1731.  
  1732. [addAMenu]    'add a new menu item
  1733.     WindowWidth = 300
  1734.     WindowHeight = 200
  1735.     listbox #newMenu.menuNames, menu$(, [inputLoop], 14, 38, 120, 120
  1736.     statictext #newMenu.statictext2, "Defined Menus", 14, 16, 104, 20
  1737.     statictext #newMenu.statictext3, "Enter new menu name:", 150, 16, 200, 20
  1738.     textbox #newMenu.newMenuName, 150, 38, 130, 25
  1739.     button #newMenu, "Accept", [acceptNewMenu], UL, 150,75,130,24
  1740.     button #newMenu, "Cancel", [cancelNewMenu], UL, 150,101,130,24
  1741.     open "Add a Menu" for dialog_modal as #newMenu
  1742.     print #newMenu, "trapclose [cancelNewMenu]";
  1743.     goto [inputLoop]
  1744.  
  1745.  
  1746. [cancelNewMenu]   'Perform action for the button named 'cancelNewMenu'
  1747.     'close the dialog box
  1748.     close #newMenu
  1749.     goto [inputLoop]
  1750.  
  1751.  
  1752. [clearMenuData]     'reset menu data arrays and indices
  1753.     for x = 0 to 20
  1754.         menu$(x) = ""
  1755.         for y = 0 to 30
  1756.             menuItem$(x, y) = ""
  1757.         next y
  1758.     next x
  1759.     menuCount = 0
  1760.     return
  1761.  
  1762.  
  1763. [acceptNewMenu]   'Perform action for the button named 'acceptNewMenu'
  1764.     'add this menu onto the list of menus, and update the display as needed
  1765.     print #newMenu.newMenuName, "!contents?";
  1766.     input #newMenu.newMenuName, result$
  1767.     if result$ = "" then notice "Please type a name for a new menu." : goto [inputLoop]
  1768.     close #newMenu
  1769.     menu$(menuCount) = result$
  1770.     menuCount = menuCount + 1
  1771.     if menuCount > 1 then gosub [redrawAll] : goto [inputLoop]
  1772.  
  1773.     'since this is the first menu added, reposition all controls 20 pixels down
  1774.     if objectCount < 2 then gosub [redrawAll] : goto [inputLoop]
  1775.     for x = 2 to objectCount
  1776.         yOrg(x) = yOrg(x) + 20
  1777.     next x
  1778.     gosub [redrawAll]
  1779.     goto [inputLoop]
  1780.  
  1781.  
  1782.  
  1783. [removeMenu]   'remove a menu from the list of menus
  1784.     if menuCount = 0 then notice "No menus to remove." : goto [inputLoop]
  1785.  
  1786.     if removeMenuIsOpen = 1 then close #removeMenu
  1787.  
  1788.     WindowWidth = 330
  1789.     WindowHeight = 195
  1790.     statictext #removeMenu.statictext1, "Select a menu to remove:", 26, 16, 192, 20
  1791.     listbox #removeMenu.menusToRemove, menu$(, [acceptRemoveMenu], 22, 41, 180, 100
  1792.     button #removeMenu, "Accept", [acceptRemoveMenu], UL, 216, 81,80,24
  1793.     button #removeMenu, "Cancel", [cancelRemoveMenu], UL, 216, 111,80,24
  1794.     open "Remove a Menu" for dialog_modal as #removeMenu
  1795.     print #removeMenu, "trapclose [cancelRemoveMenu]";
  1796.     removeMenuIsOpen = 1
  1797.  
  1798.     goto [inputLoop]
  1799.  
  1800.  
  1801. [acceptRemoveMenu]   'get the name of the selected item, and remove it
  1802.     print #removeMenu.menusToRemove, "selectionIndex?"
  1803.     input #removeMenu.menusToRemove, result
  1804.     close #removeMenu
  1805.     removeMenuIsOpen = 0
  1806.     if result = 0 then notice "No item selected.  Menu not removed." : goto [inputLoop]
  1807.  
  1808.     menuCount = menuCount - 1
  1809.     result = result - 1
  1810.  
  1811.     if result = menuCount then menu$(result) = "" : goto [checkForEmptyMenuBar]
  1812.  
  1813.     for x = result to menuCount
  1814.         menu$(x) = menu$(x+1)
  1815.     next x
  1816.  
  1817.   [checkForEmptyMenuBar]  'if there are no more menus, shift controls up 20 pixels
  1818.  
  1819.     if menuCount > 0 then gosub [redrawAll] : goto [inputLoop]
  1820.  
  1821.     for x = 2 to objectCount
  1822.         yOrg(x) = yOrg(x) - 20
  1823.     next x
  1824.  
  1825.     gosub [redrawAll]
  1826.     goto [inputLoop]
  1827.  
  1828.  
  1829. [cancelRemoveMenu]   'close the remove menu dialog
  1830.     close #removeMenu
  1831.     removeMenuIsOpen = 0
  1832.     goto [inputLoop]
  1833.  
  1834.  
  1835. [editMenus]     'edit menu order and menu contents
  1836.     if menuCount = 0 then notice "No menus to edit." : goto [inputLoop]
  1837.  
  1838.     if editMenuIsOpen = 1 then close #editMenu
  1839.  
  1840.     WindowWidth = 435
  1841.     WindowHeight = 360
  1842.  
  1843.     listbox #editMenu.menuList, menu$(, [selectMenuToEdit], 14, 31, 288, 105
  1844.     listbox #editMenu.menuItems, menuItemLocal$(, [selectMenuItemToEdit], 14, 166, 288, 145
  1845.     statictext #editMenu.statictext6, "Menus:", 14, 9, 48, 20
  1846.     statictext #editMenu.statictext14, "Menu line items -> Branch labels:", 14, 144, 240, 20
  1847.     button #editMenu, "&Close", [closeMenuEdit], UL, 310, 4,100,24
  1848.     button #editMenu, "&New Item", [addNewMenuItem], UL, 310, 166,100,24
  1849.     button #editMenu, "&Edit", [editMenuItem], UL, 310, 196,100,24
  1850.     button #editMenu, "Move &Up", [moveMenuItemUp], UL, 310, 226,100,24
  1851.     button #editMenu, "&Move Dn", [moveMenuItemDown], UL, 310, 256,100,24
  1852.     button #editMenu, "&Delete", [deleteMenuItem], UL, 310, 286,100,24
  1853.     button #editMenu, "&To Top", [moveMenuToTop], UL, 310, 60,100,24
  1854.     open "Edit Menus" for dialog_modal as #editMenu
  1855.     print #editMenu, "trapclose [closeMenuEdit]";
  1856.     print #editMenu.menuList, "singleclickselect";
  1857.     print #editMenu.menuItems, "singleclickselect";
  1858.  
  1859.     editMenuIsOpen = 1
  1860.     menuItemIndex = 0
  1861.     result = 0
  1862.  
  1863.     goto [inputLoop]
  1864.  
  1865.  
  1866. [selectMenuToEdit]   'Perform action for the listbox named 'menuList'
  1867.     'populate the listbox named menuItems
  1868.     print #editMenu.menuList, "selectionIndex?"
  1869.     input #editMenu.menuList, result
  1870.  
  1871.     for x = 0 to 29
  1872.         mil$ = menuItem$(result - 1, x)
  1873.         if mil$ <> "" then mil$ = left$(mil$, instr(mil$, chr$(0)) - 1) + " -> " + mid$(mil$, instr(mil$, chr$(0)) + 1)
  1874.         menuItemLocal$(x) = mil$
  1875.     next x
  1876.     print #editMenu.menuItems, "reload"
  1877.  
  1878.     menuItemIndex = 0
  1879.  
  1880.     goto [inputLoop]
  1881.  
  1882.  
  1883. [moveMenuToTop]   'move the selected menu to the top of the list
  1884.     'if there is no selection, or if the selected item is already on top, do nothing
  1885.     if result = 0 or result = 1 then [inputLoop]
  1886.  
  1887.     menu$(20) = menu$(result - 1)
  1888.     for x = 0 to 29
  1889.         menuItem$(20, x) = menuItem$(result - 1, x)
  1890.     next x
  1891.  
  1892.     for x = result - 1 to 1 step -1
  1893.         menu$(x) = menu$(x - 1)
  1894.         for y = 0 to 29
  1895.             menuItem$(x, y) = menuItem$(x - 1, y)
  1896.         next y
  1897.     next x
  1898.  
  1899.     menu$(0) = menu$(20)
  1900.     menu$(20) = ""
  1901.     for x = 0 to 29
  1902.         menuItem$(0, x) = menuItem$(20, x)
  1903.         menuItem$(20, x) = ""
  1904.     next x
  1905.  
  1906.     print #editMenu.menuList, "reload"
  1907.     print #editMenu.menuList, "selectIndex 1"
  1908.     result = 1
  1909.  
  1910.     'now continue on to the next routine!
  1911.  
  1912.  
  1913. [selectMenuItemToEdit]   'Perform action for the listbox named 'menuItems'
  1914.     'set the selection index for the menu item to edit
  1915.     print #editMenu.menuItems, "selectionIndex?"
  1916.     input #editMenu.menuItems, menuItemIndex
  1917.     goto [inputLoop]
  1918.  
  1919.  
  1920. [addNewMenuItem]   'Perform action for the button named 'newItemButton'
  1921.     if result = 0 then [inputLoop]
  1922.  
  1923.     if editMenuItemIsOpen = 1 then gosub [closeEditMenuItem]
  1924.  
  1925.     menuItemCount(result - 1) = menuItemCount(result - 1) + 1
  1926.     menuItemIndex = menuItemCount(result - 1)
  1927.     editMenuItemAction$ = "ADD"
  1928.     goto [editMenuItemProperties]
  1929.  
  1930.  
  1931. [editMenuItem]   'Perform action for the button named 'editMenuItem'
  1932.     if menuItemIndex = 0 then [inputLoop]
  1933.  
  1934.     if editMenuItemIsOpen = 1 then gosub [closeEditMenuItem]
  1935.  
  1936.     editMenuItemAction$ = "EDIT"
  1937.     goto [editMenuItemProperties]
  1938.  
  1939.  
  1940. [moveMenuItemUp]   'Perform action for the button named 'moveMenuItemUp'
  1941.     if menuItemIndex = 1 or menuItemIndex = 0 then [inputLoop]
  1942.  
  1943.     tmpMi$ = menuItem$(result - 1, menuItemIndex - 1)
  1944.     menuItem$(result - 1, menuItemIndex - 1) = menuItem$(result - 1, menuItemIndex - 2)
  1945.     menuItem$(result - 1, menuItemIndex - 2) = tmpMi$
  1946.  
  1947.     gosub [reloadLocalMenuItems]
  1948.  
  1949.     menuItemIndex = menuItemIndex - 1
  1950.     print #editMenu.menuItems, "selectIndex "; menuItemIndex
  1951.  
  1952.     goto [inputLoop]
  1953.  
  1954.  
  1955. [moveMenuItemDown]   'Perform action for the button named 'moveMenuItemDown'
  1956.     'Insert your own code here
  1957.     if result = 0 then [inputLoop]
  1958.     if menuItemIndex = menuItemCount(result - 1) or menuItemIndex = 0 then [inputLoop]
  1959.  
  1960.     tmpMi$ = menuItem$(result - 1, menuItemIndex - 1)
  1961.     menuItem$(result - 1, menuItemIndex - 1) = menuItem$(result - 1, menuItemIndex)
  1962.     menuItem$(result - 1, menuItemIndex) = tmpMi$
  1963.  
  1964.     gosub [reloadLocalMenuItems]
  1965.  
  1966.     menuItemIndex = menuItemIndex + 1
  1967.     print #editMenu.menuItems, "selectIndex "; menuItemIndex
  1968.  
  1969.     goto [inputLoop]
  1970.  
  1971.  
  1972. [deleteMenuItem]   'Perform action for the button named 'deleteMenuItem'
  1973.     'Insert your own code here
  1974.     if result = 0 then [inputLoop]
  1975.     if menuItemCount(result - 1) = 0 or menuItemIndex = 0 then [inputLoop]
  1976.  
  1977.     for x = menuItemIndex to 30
  1978.         menuItem$(result - 1, x - 1) = menuItem$(result - 1, x)
  1979.     next x
  1980.  
  1981.     gosub [reloadLocalMenuItems]
  1982.  
  1983.     menuItemIndex = 0
  1984.  
  1985.     return
  1986.  
  1987.  
  1988. [reloadLocalMenuItems]  'reload the contents of the menu items listbox
  1989.     for x = 0 to 29
  1990.         mil$ = menuItem$(result - 1, x)
  1991.         if mil$ <> "" then mil$ = left$(mil$, instr(mil$, chr$(0)) - 1) + " -> " + mid$(mil$, instr(mil$, chr$(0)) + 1)
  1992.         menuItemLocal$(x) = mil$
  1993.     next x
  1994.     print #editMenu.menuItems, "reload"
  1995.  
  1996.     return
  1997.  
  1998.  
  1999. [closeMenuEdit]   'Perform action for the button named 'closeMenuEdit'
  2000.     'close the menu editing dialog and redraw the form
  2001.     for x = 0 to 29 : menuItemLocal$(x) = "" : next x
  2002.     close #editMenu
  2003.     editMenuIsOpen = 0
  2004.     'gosub [redrawAll]
  2005.  
  2006.     goto [inputLoop]
  2007.  
  2008.  
  2009. [editMenuItemProperties]    'open a dialog for editing menu item properties
  2010.     WindowWidth = 350
  2011.     WindowHeight = 150
  2012.  
  2013.     textbox #menuItems.name, 134, 16, 184, 25
  2014.     textbox #menuItems.branchLabel, 134, 51, 184, 25
  2015.     statictext #menuItems.statictext6, "Name:", 22, 21, 40, 20
  2016.     statictext #menuItems.statictext7, "Branch Label:", 22, 56, 104, 20
  2017.     button #menuItems, "Accept", [acceptMenuItemProps], UL, 198, 86, 100, 24
  2018.     button #menuItems, "Cancel", [cancelMenuItemProps], UL, 48, 86, 100, 24
  2019.     open "Menu Item Properties" for dialog_modal as #menuItems
  2020.     editMenuItemIsOpen = 1
  2021.  
  2022.     print #menuItems.name, "???"
  2023.     print #menuItems.branchLabel, "[???]"
  2024.  
  2025.     if menuItem$(result - 1, menuItemIndex - 1) = "" then [inputLoop]
  2026.  
  2027.     mi$ = menuItem$(result - 1, menuItemIndex - 1)
  2028.     print #menuItems.name, left$(mi$, instr(mi$, chr$(0)) - 1)
  2029.     print #menuItems.branchLabel, mid$(mi$, instr(mi$, chr$(0)) + 1)
  2030.  
  2031.     goto [inputLoop]
  2032.  
  2033.  
  2034. [acceptMenuItemProps]   'Perform action for the button named 'acceptMenuItemProps'
  2035.     'accept the edited menu item
  2036.     print #menuItems.name, "!contents?";
  2037.     input #menuItems.name, nResult$
  2038.     print #menuItems.branchLabel, "!contents?";
  2039.     input #menuItems.branchLabel, blResult$
  2040.  
  2041.     if nResult$ = "" or blResult$ = "" then notice "Bad menu item properties." : goto [inputLoop]
  2042.  
  2043.     blr$ = blResult$
  2044.     if left$(blResult$, 1) <> "[" then blResult$ = "[" + blResult$
  2045.     if right$(blResult$, 1) <> "]" then blResult$ = blResult$ + "]"
  2046.  
  2047.     if blr$ <> blResult$ then notice "Branch Label was " + blr$ + ", defaulting to " + blResult$
  2048.  
  2049.     menuItem$(result - 1, menuItemIndex - 1) = nResult$ + chr$(0) + blResult$
  2050.     menuItemLocal$(menuItemIndex - 1) = nResult$ + " -> " + blResult$
  2051.  
  2052.     close #menuItems
  2053.     editMenuItemIsOpen = 0
  2054.  
  2055.     print #editMenu.menuItems, "reload"
  2056.  
  2057.     goto [inputLoop]
  2058.  
  2059.  
  2060. [cancelMenuItemProps]   'Perform action for the button named 'cancelMenuItemProps'
  2061.     'close the window
  2062.     gosub [closeEditMenuItem]
  2063.     goto [inputLoop]
  2064.  
  2065.  
  2066. [closeEditMenuItem]   'close the window before opening it again
  2067.     'close the window
  2068.     close #menuItems
  2069.     if editMenuItemAction$ = "ADD" then menuItemCount(result - 1) = menuItemCount(result - 1) - 1
  2070.     editMenuItemIsOpen = 0
  2071.     return
  2072.  
  2073.  
  2074. [formIsModified]    'the form has been modified, offer to save
  2075.     isModified = 0 ' set the isModified flag to be 0
  2076.     if objectCount < 2 then return  ' if there are no objects, don't offer to save form
  2077.     confirm "Save changes to " + formName$ + "?"; answer$
  2078.     if answer$ = "yes" then gosub [saveFormSubroutine]
  2079.     return
  2080.  
  2081.  
  2082. [settingsDialog]    'edit the settings for FreeForm
  2083.     WindowWidth = 300
  2084.     WindowHeight = 170
  2085.  
  2086.     checkbox #settings.creationInspect, "Inspect each control when created", [creationInspectSet], [creationInspectClear], 22, 16, 280, 19
  2087.     checkbox #settings.displayOrdering, "Display control ordering", [displayOrderingSet], [displayOrderingReset], 22, 36, 208, 19
  2088.     checkbox #settings.displayFormat, "Screen Layout Displayed for Win95 Format", [displayFormatSet], [displayFormatReset], 22, 56, 300, 19
  2089.     button #settings, "Accept", [settingsAccept], UL, 154, 101,80,24
  2090.     button #settings, "Cancel", [settingsCancel], UL, 24, 101,80,24
  2091.     open "Settings" for dialog_modal as #settings
  2092.     print #settings, "trapclose [settingsCancel]"
  2093.  
  2094.     createInspectValue = createInspect
  2095.     if createInspect > 0 then print #settings.creationInspect, "set"
  2096.     displayOrderingValue = displayOrdering
  2097.     if displayOrdering > 0 then print #settings.displayOrdering, "set"
  2098.     displayFormatValue = displayFormat
  2099.     if displayFormat > 0 then print #settings.displayFormat, "set"
  2100.  
  2101. [settings.inputLoop]   'wait here for input event
  2102.     input aVar$
  2103.     goto [settings.inputLoop]
  2104.  
  2105.  
  2106.  
  2107. [creationInspectSet]   'set value for inspect on create
  2108.     createInspectValue = 1
  2109.     goto [settings.inputLoop]
  2110.  
  2111.  
  2112. [creationInspectClear]   'set value for no inspect on create
  2113.     createInspectValue = 0
  2114.     goto [settings.inputLoop]
  2115.  
  2116.  
  2117. [displayOrderingSet]   'set value for displaying of control ordering
  2118.     displayOrderingValue = 1
  2119.     goto [settings.inputLoop]
  2120.  
  2121.  
  2122. [displayOrderingReset]   'set value for non-displaying of control ordering
  2123.     displayOrderingValue = 0
  2124.     goto [settings.inputLoop]
  2125.  
  2126. [displayFormatSet]
  2127.     displayFormatValue = 1
  2128.     goto [settings.inputLoop]
  2129.  
  2130. [displayFormatReset]
  2131.     displayFormatValue = 0
  2132.     goto [settings.inputLoop]
  2133.  
  2134.  
  2135. [settingsAccept]   'accept the settings
  2136.  
  2137.     createInspect = createInspectValue
  2138.     displayOrdering = displayOrderingValue
  2139.     displayFormat = displayFormatValue
  2140.     close #settings
  2141.     if displayFormat = 0 then loadbmp "systemBox", "bmp\systembx.bmp"
  2142.     if displayFormat = 1 and left$(windowType$, 6) = "dialog" then loadbmp "systemBox", "bmp\95sysbxd.bmp"
  2143.     if displayFormat = 1 and left$(windowType$, 6) <> "dialog" then loadbmp "systemBox", "bmp\95sysbx.bmp"
  2144.     if displayFormat = 0 then loadbmp "minBox", "bmp\minbx.bmp" else loadbmp "minBox", "bmp\95minbx.bmp"
  2145.     if displayFormat = 0 then loadbmp "maxBox", "bmp\maxbx.bmp" else loadbmp "maxBox", "bmp\95maxbx.bmp"
  2146.     print #form, "font ";font$(1)
  2147.     gosub [redrawAll]
  2148.  
  2149.     goto [inputLoop]
  2150.  
  2151.  
  2152. [settingsCancel]   'discard any settings changes
  2153.     close #settings
  2154.     goto [settings.inputLoop]
  2155.  
  2156.  
  2157.  
  2158. [loadIniFile]   'load the user preferences
  2159.     if fileExists(DefaultDir$, "fflite.ini") then
  2160.         open "fflite.ini" for input as #ini
  2161.         input #ini, xInterval   'snap to x
  2162.         input #ini, yInterval   'snap to y
  2163.         input #ini, snapOn      'snap to on/off
  2164.         input #ini, createInspect 'inspect each control when created
  2165.         input #ini, displayOrdering 'display control ordering
  2166.         input #ini, displayFormat
  2167.         close #ini
  2168.     else
  2169.         gosub [saveIniFile]
  2170.     end if
  2171.  
  2172.     return
  2173.  
  2174.  
  2175. [saveIniFile]   'save the user preferences
  2176.     open "fflite.ini" for output as #ini
  2177.  
  2178.     print #ini, xInterval
  2179.     print #ini, yInterval
  2180.     print #ini, snapOn
  2181.     print #ini, createInspect
  2182.     print #ini, displayOrdering
  2183.     print #ini, displayFormat
  2184.  
  2185.     close #ini
  2186.  
  2187.     return
  2188.  
  2189.  
  2190. [popupMenu]
  2191.     PopupMenu "&New", [newFile], "&Open", [openFile], "&Save", [saveFile], |,"Q&uit", [quit],|, _
  2192.         "&Inspect", [inspectControl], "&Delete", [deleteControl], |, "Move to &front", [moveToFront], "Move to &back", [moveToBack],_
  2193.         "&Produce Code", [produceCode], "Produce Code + Outline", [produceCodeAndOutline],|,_
  2194.         "&Title", [changeTitle], "T&ype", [changeWindowType], "&Handle", [changeHandle], "&Window Colour", [changeColorType], "&Box Colour", [changeBoxColorType], "&Font for controls",[changeControlFont],|,_
  2195.         "&Auto Snap to Grid", [gridDialog], "&Settings", [settingsDialog],|,_
  2196.         "&Add a Menu", [addAMenu], "&Remove a Menu", [removeMenu], "&Edit Menus", [editMenus]
  2197.     goto [inputLoop]
  2198.  
  2199.  
  2200.  
  2201. [quit]   'exit Freeform
  2202.     if isModified = 1 then gosub [formIsModified]
  2203.  
  2204.     'quit freeform
  2205.     confirm "Are you sure?"; answer$
  2206.     if answer$ = "no" then [inputLoop]
  2207.     gosub [saveIniFile]
  2208.     close #form
  2209.     if codeIsOpen then close #code
  2210.  
  2211. end
  2212.  
  2213. function fileExists(path$, filename$)
  2214.  
  2215.     files path$, filename$, info$(
  2216.     fileExists = val(info$(0, 0)) > 0
  2217.  
  2218. end function
  2219.  
  2220.  
  2221. [addTooltips]
  2222.     GWW = _GWW_HINSTANCE or 0
  2223.     style           = 0
  2224.     CW.USEDEFAULT   = hexdec("8000")
  2225.     TTF.IDISHWND    = hexdec("0001")
  2226.     TTF.SUBCLASS    = hexdec("0010")
  2227.     TTM.ADDTOOL     = _WM_USER+4
  2228.  
  2229.     h=hwnd(#form)
  2230.     open "user" for dll as #user
  2231.     open "commctrl.dll" for dll as #cctl
  2232.  
  2233.     calldll #cctl, "InitCommonControls", re as void
  2234.     calldll #user, "GetWindowWord", h as word,_
  2235.         GWW as word, hInstance as word
  2236.  
  2237.     calldll #user, "CreateWindow", _
  2238.         "tooltips_class" as ptr, _
  2239.         "" as ptr, _
  2240.         style as long, _
  2241.         CW.USEDEFAULT as word, _
  2242.         CW.USEDEFAULT as word, _
  2243.         CW.USEDEFAULT as word, _
  2244.         CW.USEDEFAULT as word, _
  2245.         h as word, _
  2246.         0 as word, _
  2247.         hInstance as word, _
  2248.         "" as ptr, _
  2249.         hwndTT as word
  2250.  
  2251.     '** MAKE A STRUCT FOR EACH TOOL
  2252.     struct toolinfo1, cbSize as word, uFlags as word,_
  2253.         hwnd as word, uId as word, x as word, y as word,_
  2254.         w as word, h as word, _
  2255.         hInst as word, lpstrText$ as ptr
  2256.  
  2257.     struct toolinfo2, cbSize as word, uFlags as word,_
  2258.         hwnd as word, uId as word, x as word, y as word,_
  2259.         w as word, h as word, _
  2260.         hInst as word, lpstrText$ as ptr
  2261.  
  2262.     struct toolinfo3, cbSize as word, uFlags as word,_
  2263.         hwnd as word, uId as word, x as word, y as word,_
  2264.         w as word, h as word, _
  2265.         hInst as word, lpstrText$ as ptr
  2266.  
  2267.     struct toolinfo4, cbSize as word, uFlags as word,_
  2268.         hwnd as word, uId as word, x as word, y as word,_
  2269.         w as word, h as word, _
  2270.         hInst as word, lpstrText$ as ptr
  2271.  
  2272.     struct toolinfo5, cbSize as word, uFlags as word,_
  2273.         hwnd as word, uId as word, x as word, y as word,_
  2274.         w as word, h as word, _
  2275.         hInst as word, lpstrText$ as ptr
  2276.  
  2277.     struct toolinfo6, cbSize as word, uFlags as word,_
  2278.         hwnd as word, uId as word, x as word, y as word,_
  2279.         w as word, h as word, _
  2280.         hInst as word, lpstrText$ as ptr
  2281.  
  2282.     struct toolinfo7, cbSize as word, uFlags as word,_
  2283.         hwnd as word, uId as word, x as word, y as word,_
  2284.         w as word, h as word, _
  2285.         hInst as word, lpstrText$ as ptr
  2286.  
  2287.     struct toolinfo8, cbSize as word, uFlags as word,_
  2288.         hwnd as word, uId as word, x as word, y as word,_
  2289.         w as word, h as word, _
  2290.         hInst as word, lpstrText$ as ptr
  2291.  
  2292.     struct toolinfo9, cbSize as word, uFlags as word,_
  2293.         hwnd as word, uId as word, x as word, y as word,_
  2294.         w as word, h as word, _
  2295.         hInst as word, lpstrText$ as ptr
  2296.  
  2297.     struct toolinfo10, cbSize as word, uFlags as word,_
  2298.         hwnd as word, uId as word, x as word, y as word,_
  2299.         w as word, h as word, _
  2300.         hInst as word, lpstrText$ as ptr
  2301.  
  2302.     struct toolinfo11, cbSize as word, uFlags as word,_
  2303.         hwnd as word, uId as word, x as word, y as word,_
  2304.         w as word, h as word, _
  2305.         hInst as word, lpstrText$ as ptr
  2306.  
  2307.     struct toolinfo12, cbSize as word, uFlags as word,_
  2308.         hwnd as word, uId as word, x as word, y as word,_
  2309.         w as word, h as word, _
  2310.         hInst as word, lpstrText$ as ptr
  2311.  
  2312.     struct toolinfo13, cbSize as word, uFlags as word,_
  2313.         hwnd as word, uId as word, x as word, y as word,_
  2314.         w as word, h as word, _
  2315.         hInst as word, lpstrText$ as ptr
  2316.  
  2317.     struct toolinfo14, cbSize as word, uFlags as word,_
  2318.         hwnd as word, uId as word, x as word, y as word,_
  2319.         w as word, h as word, _
  2320.         hInst as word, lpstrText$ as ptr
  2321.  
  2322.     struct toolinfo15, cbSize as word, uFlags as word,_
  2323.         hwnd as word, uId as word, x as word, y as word,_
  2324.         w as word, h as word, _
  2325.         hInst as word, lpstrText$ as ptr
  2326.  
  2327.     struct toolinfo16, cbSize as word, uFlags as word,_
  2328.         hwnd as word, uId as word, x as word, y as word,_
  2329.         w as word, h as word, _
  2330.         hInst as word, lpstrText$ as ptr
  2331.  
  2332.     struct toolinfo17, cbSize as word, uFlags as word,_
  2333.         hwnd as word, uId as word, x as word, y as word,_
  2334.         w as word, h as word, _
  2335.         hInst as word, lpstrText$ as ptr
  2336.  
  2337.     struct toolinfo18, cbSize as word, uFlags as word,_
  2338.         hwnd as word, uId as word, x as word, y as word,_
  2339.         w as word, h as word, _
  2340.         hInst as word, lpstrText$ as ptr
  2341.  
  2342.     struct toolinfo19, cbSize as word, uFlags as word,_
  2343.         hwnd as word, uId as word, x as word, y as word,_
  2344.         w as word, h as word, _
  2345.         hInst as word, lpstrText$ as ptr
  2346.  
  2347.     struct toolinfo20, cbSize as word, uFlags as word,_
  2348.         hwnd as word, uId as word, x as word, y as word,_
  2349.         w as word, h as word, _
  2350.         hInst as word, lpstrText$ as ptr
  2351.  
  2352.     struct toolinfo21, cbSize as word, uFlags as word,_
  2353.         hwnd as word, uId as word, x as word, y as word,_
  2354.         w as word, h as word, _
  2355.         hInst as word, lpstrText$ as ptr
  2356.  
  2357.  
  2358.     toolinfo1.cbSize.struct = 22
  2359.     toolinfo1.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2360.     toolinfo1.hwnd.struct = h
  2361.     toolinfo1.uId.struct = hwnd(#form.load)
  2362.     toolinfo1.hInst.struct = hInstance
  2363.     toolinfo1.lpstrText$.struct = "Open File"
  2364.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2365.     0 as word, toolinfo1 as struct, re as long
  2366.  
  2367.     toolinfo2.cbSize.struct = 22
  2368.     toolinfo2.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2369.     toolinfo2.hwnd.struct = h
  2370.     toolinfo2.uId.struct = hwnd(#form.save)
  2371.     toolinfo2.hInst.struct = hInstance
  2372.     toolinfo2.lpstrText$.struct = "Save File"
  2373.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2374.     0 as word, toolinfo2 as struct, re as long
  2375.  
  2376.     toolinfo3.cbSize.struct = 22
  2377.     toolinfo3.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2378.     toolinfo3.hwnd.struct = h
  2379.     toolinfo3.uId.struct = hwnd(#form.static)
  2380.     toolinfo3.hInst.struct = hInstance
  2381.     toolinfo3.lpstrText$.struct = "Static Text"
  2382.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2383.     0 as word, toolinfo3 as struct, re as long
  2384.  
  2385.     toolinfo4.cbSize.struct = 22
  2386.     toolinfo4.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2387.     toolinfo4.hwnd.struct = h
  2388.     toolinfo4.uId.struct = hwnd(#form.field)
  2389.     toolinfo4.hInst.struct = hInstance
  2390.     toolinfo4.lpstrText$.struct = "Text Box"
  2391.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2392.     0 as word, toolinfo4 as struct, re as long
  2393.  
  2394.     toolinfo5.cbSize.struct = 22
  2395.     toolinfo5.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2396.     toolinfo5.hwnd.struct = h
  2397.     toolinfo5.uId.struct = hwnd(#form.button)
  2398.     toolinfo5.hInst.struct = hInstance
  2399.     toolinfo5.lpstrText$.struct = "Button"
  2400.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2401.     0 as word, toolinfo5 as struct, re as long
  2402.  
  2403.     toolinfo6.cbSize.struct = 22
  2404.     toolinfo6.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2405.     toolinfo6.hwnd.struct = h
  2406.     toolinfo6.uId.struct = hwnd(#form.bmp)
  2407.     toolinfo6.hInst.struct = hInstance
  2408.     toolinfo6.lpstrText$.struct = "BmpButton"
  2409.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2410.     0 as word, toolinfo6 as struct, re as long
  2411.  
  2412.     toolinfo7.cbSize.struct = 22
  2413.     toolinfo7.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2414.     toolinfo7.hwnd.struct = h
  2415.     toolinfo7.uId.struct = hwnd(#form.list)
  2416.     toolinfo7.hInst.struct = hInstance
  2417.     toolinfo7.lpstrText$.struct = "Listbox"
  2418.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2419.     0 as word, toolinfo7 as struct, re as long
  2420.  
  2421.     toolinfo8.cbSize.struct = 22
  2422.     toolinfo8.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2423.     toolinfo8.hwnd.struct = h
  2424.     toolinfo8.uId.struct = hwnd(#form.combo)
  2425.     toolinfo8.hInst.struct = hInstance
  2426.     toolinfo8.lpstrText$.struct = "Combobox"
  2427.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2428.     0 as word, toolinfo8 as struct, re as long
  2429.  
  2430.     toolinfo9.cbSize.struct = 22
  2431.     toolinfo9.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2432.     toolinfo9.hwnd.struct = h
  2433.     toolinfo9.uId.struct = hwnd(#form.radio)
  2434.     toolinfo9.hInst.struct = hInstance
  2435.     toolinfo9.lpstrText$.struct = "Radiobutton"
  2436.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2437.     0 as word, toolinfo9 as struct, re as long
  2438.  
  2439.     toolinfo10.cbSize.struct = 22
  2440.     toolinfo10.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2441.     toolinfo10.hwnd.struct = h
  2442.     toolinfo10.uId.struct = hwnd(#form.check)
  2443.     toolinfo10.hInst.struct = hInstance
  2444.     toolinfo10.lpstrText$.struct = "Checkbox"
  2445.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2446.     0 as word, toolinfo10 as struct, re as long
  2447.  
  2448.     toolinfo11.cbSize.struct = 22
  2449.     toolinfo11.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2450.     toolinfo11.hwnd.struct = h
  2451.     toolinfo11.uId.struct = hwnd(#form.group)
  2452.     toolinfo11.hInst.struct = hInstance
  2453.     toolinfo11.lpstrText$.struct = "Groupbox"
  2454.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2455.     0 as word, toolinfo11 as struct, re as long
  2456.  
  2457.     toolinfo12.cbSize.struct = 22
  2458.     toolinfo12.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2459.     toolinfo12.hwnd.struct = h
  2460.     toolinfo12.uId.struct = hwnd(#form.edit)
  2461.     toolinfo12.hInst.struct = hInstance
  2462.     toolinfo12.lpstrText$.struct = "Texteditor"
  2463.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2464.     0 as word, toolinfo12 as struct, re as long
  2465.  
  2466.     toolinfo13.cbSize.struct = 22
  2467.     toolinfo13.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2468.     toolinfo13.hwnd.struct = h
  2469.     toolinfo13.uId.struct = hwnd(#form.graphic)
  2470.     toolinfo13.hInst.struct = hInstance
  2471.     toolinfo13.lpstrText$.struct = "Graphicbox"
  2472.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2473.     0 as word, toolinfo13 as struct, re as long
  2474.  
  2475.     toolinfo14.cbSize.struct = 22
  2476.     toolinfo14.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2477.     toolinfo14.hwnd.struct = h
  2478.     toolinfo14.uId.struct = hwnd(#form.fill)
  2479.     toolinfo14.hInst.struct = hInstance
  2480.     toolinfo14.lpstrText$.struct = "Fill Color"
  2481.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2482.     0 as word, toolinfo14 as struct, re as long
  2483.  
  2484.     toolinfo15.cbSize.struct = 22
  2485.     toolinfo15.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2486.     toolinfo15.hwnd.struct = h
  2487.     toolinfo15.uId.struct = hwnd(#form.inspect)
  2488.     toolinfo15.hInst.struct = hInstance
  2489.     toolinfo15.lpstrText$.struct = "Inspect Control"
  2490.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2491.     0 as word, toolinfo15 as struct, re as long
  2492.  
  2493.     toolinfo16.cbSize.struct = 22
  2494.     toolinfo16.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2495.     toolinfo16.hwnd.struct = h
  2496.     toolinfo16.uId.struct = hwnd(#form.delete)
  2497.     toolinfo16.hInst.struct = hInstance
  2498.     toolinfo16.lpstrText$.struct = "Delete Control"
  2499.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2500.     0 as word, toolinfo16 as struct, re as long
  2501.  
  2502.     toolinfo17.cbSize.struct = 22
  2503.     toolinfo17.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2504.     toolinfo17.hwnd.struct = h
  2505.     toolinfo17.uId.struct = hwnd(#form.infront)
  2506.     toolinfo17.hInst.struct = hInstance
  2507.     toolinfo17.lpstrText$.struct = "Bring to Front"
  2508.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2509.     0 as word, toolinfo17 as struct, re as long
  2510.  
  2511.     toolinfo18.cbSize.struct = 22
  2512.     toolinfo18.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2513.     toolinfo18.hwnd.struct = h
  2514.     toolinfo18.uId.struct = hwnd(#form.inback)
  2515.     toolinfo18.hInst.struct = hInstance
  2516.     toolinfo18.lpstrText$.struct = "Send to Back"
  2517.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2518.     0 as word, toolinfo18 as struct, re as long
  2519.  
  2520.     toolinfo19.cbSize.struct = 22
  2521.     toolinfo19.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2522.     toolinfo19.hwnd.struct = h
  2523.     toolinfo19.uId.struct = hwnd(#form.code)
  2524.     toolinfo19.hInst.struct = hInstance
  2525.     toolinfo19.lpstrText$.struct = "Produce Code"
  2526.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2527.     0 as word, toolinfo19 as struct, re as long
  2528.  
  2529.     toolinfo20.cbSize.struct = 22
  2530.     toolinfo20.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2531.     toolinfo20.hwnd.struct = h
  2532.     toolinfo20.uId.struct = hwnd(#form.outline)
  2533.     toolinfo20.hInst.struct = hInstance
  2534.     toolinfo20.lpstrText$.struct = "Produce Code and Outline"
  2535.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2536.     0 as word, toolinfo20 as struct, re as long
  2537.  
  2538.     toolinfo21.cbSize.struct = 22
  2539.     toolinfo21.uFlags.struct = TTF.IDISHWND or TTF.SUBCLASS
  2540.     toolinfo21.hwnd.struct = h
  2541.     toolinfo21.uId.struct = hwnd(#form)
  2542.     toolinfo21.hInst.struct = hInstance
  2543.     toolinfo21.lpstrText$.struct = "Right Click for Menu"
  2544.     calldll #user, "SendMessage", hwndTT as word, TTM.ADDTOOL as word, _
  2545.     0 as word, toolinfo21 as struct, re as long
  2546.  
  2547.     close #cctl:close #user
  2548.  
  2549.     RETURN
  2550.  
  2551.  
  2552.  
  2553.