|
Post by Rod on Apr 12, 2023 15:32:54 GMT
Well the file is not meant to be human readable or to be amended directly, anyways it would be even longer with line breaks:) But tell me why you want to read it perhaps we do need to amend the format.
I have been working on it all day as it is wet and cold here. I have it now writing the .bas, a very satisfying moment, I am struggling to get it to auto run the .bas. Any help with that would be good.
I know I need a Save as well as Save As. It may be automatic. I think that is why lastsession.ffu is annoying folks. I know I have a bug with the button text placement. I know I have color to implement, not looking forwards to that.
I have changed the screen layout and you can now have a very large form. However for testing I would advise you to keep it small. There are bugs with the scrollbar drawing. You can place a control at 2000,2000 but it is torturous. I will need a new strategy for drawing at those scales.
please have a play, create a small form and write it, currently it writes to test.bas so just keep overwriting that for early tests. All bugs, comments, thoughts and criticism welcome.
'freeform ultra lite v1.1 '11/04/2023 by rodbird@hotmail.com 'Best start with a New project 'Best set the grid size, width and height at the start 'Best set the project font at the start 'Best set the control font before adding the control 'all of the above can be reset mid project but control 'position and height may need adjusted, easy but avoidable 'Under File you can Write, Save As, Load and New 'Under Add New you can insert any control and it will appear on form 'The control will remain highlighted. 'Left button click on any other control to highlight it instead 'Use left button drag to move the control it will jump to the nearest 'grid point but will remain in the bounds of the form 'Use left button drag to expand or shrink the control 'left click towards the right hand edge. it will then expand or shrink 'to nearest grid point, text controls will not shrink beyonf font height 'While a control is highlighted you can CtrlC and ctrlV to copy it 'or Del to delete it. 'Use right button click to summon the Properties window. If a contol 'is highlighted its properties will show. Amend control name,text and 'resource data if required. 'Currently the project name is on the Properties window and can be amended 'The Properties window can be moved. Right mouse click anywhere to summon or 'hide the Properties window, only when it is hidden will keyboard shortcuts 'work. So it dissappears often 'you can change the width and height of the form at any time 'once you select a new control font it will persist till you reset it 'Do save your project, the last session is always restored but that does not 'save as a named project
'The whole point of this project is to provide a tool that allows precise 'and easy placement of controls and subsequent adjustment.
'Write mostly works. I would like to autostart the new .bas but struggle 'The form can now be small or large but will be shown in the work area graphicbox 'you can expand the work area but it all gets slow and buggy so more testing needed
'bugs and complaints welcome.
'I know I have a bug with text placement on buttons. 'I know I need a Save as well as Save As Might be automated.
nomainwin dim info$(10,10) dim form$(10) form$(1)="File" form$(2)="Write" form$(3)="Save as" form$(4)="Load" form$(5)="New" dim tool$(12) tool$(1)="StatictText" tool$(2)="TextBox" tool$(3)="ListBox" tool$(5)="ComboBox" tool$(6)="Button" tool$(7)="BmpButton" tool$(8)="GraphicBox" tool$(9)="RadioButton" tool$(10)="CheckBox" tool$(11)="GroupBox" tool$(12)="Add New" dim grid$(20) g=1 for n= 5 to 30 step 5 grid$(g)=str$(n) g=g+1 next grid$(g)="Set Grid" grid=10 projectctrh=25 ctrh=25 dim font$(10) font$(1)="Set Control" font$(2)="Reset Ctrl" font$(3)="Set Project" font$(4)="Set Font"'default is Consolas 9" dim v$(100) for n= 1 to 20 v$(n)=str$(n*100) next dim obj(100,6) 'x,y,width/height,type,textheight dim obj$(100,4) 'name,text content,resource,font obj=0 'open the last session file if it exists. files "", "lastsession.ffu", info$() If val(info$(0, 0)) > 0 then open "lastsession.ffu" for input as #ses 'on error goto [fail] input #ses, projectname$ input #ses, projectfont$ if projectfont$="" then projectfont$="Consolas 9" input #ses, c$ input #ses, g$ input #ses, w$ input #ses, h$ projectctrh=val(c$) projectgrid=val(g$) grid=projectgrid projectw=val(w$) projecth=val(h$) obj=0 while eof(#ses) = 0 obj=obj+1 obj(obj,1)=val(inputto$(#ses,",")) obj(obj,2)=val(inputto$(#ses,",")) obj(obj,3)=val(inputto$(#ses,",")) obj(obj,4)=val(inputto$(#ses,",")) obj(obj,5)=val(inputto$(#ses,",")) obj(obj,6)=val(inputto$(#ses,",")) obj$(obj,1)=inputto$(#ses,",") obj$(obj,2)=inputto$(#ses,",") obj$(obj,3)=inputto$(#ses,",") obj$(obj,4)=inputto$(#ses,",") if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) wend goto [success] [fail] projectname$="Untitled" projectfont$="Consolas 9" projectctrh=25 projectgrid=10 projectw=800 projecth=600 redim obj(100,6) 'x,y,width/height,type,textheight redim obj$(100,4) 'name,text content,resource,font obj=0 [success] close #ses else projectname$="Untitled" projectfont$="Consolas 9" projectctrh=25 projectgrid=10 projectw=800 projecth=600 end if
'open a small properties window and hide it WindowWidth=230 WindowHeight=180 UpperLeftX=(DisplayWidth-230)/2 UpperLeftY=(DisplayHeight-180)/2 statictext #2.st1 "Proj",5,10,30,25 textbox #2.tbproj,45,5,150,25 statictext #2.st2 "Ctrl",5,32,30,25 textbox #2.tbname,45,27,150,25 statictext #2.st3 "Text",5,54,30,25 textbox #2.tbtext,45,49,150,25 statictext #2.st4 "Reso",5,76,30,25 textbox #2.tbreso,45,71,150,25 statictext #2.st5 "Wxyh",5,98,30,25 textbox #2.tbxywh,45,93,150,25 statictext #2.st6 "Font",5,120,30,25 textbox #2.tbfont,45,115,150,25 open "Properties" for window_nf as #2 #2 "font Consolas 9" #2 "trapclose [quit2]" #2.tbproj projectname$ #2.tbxywh "!disable" #2.tbfont "!disable" #2 "hide"
'open the main form window 'if projectw>DisplayWidth then WindowWidth=DisplayWidth else WindowWidth=projectw 'if projectw<650 then WindowWidth=650 else WindowWidth=projectw 'if projecth>DisplayHeight then WindowHeight=DisplayHeight else WindowHeight=projecth 'if projecth<500 then WindowHeight=500 else WindowHeight=projecth WindowWidth=825 WindowHeight=670 UpperLeftX=(DisplayWidth-WindowWidth)/2 UpperLeftY=(DisplayHeight-WindowHeight)/2 combobox #1.tool,tool$(,[tool],5,0,90,30 combobox #1.form,form$(,[form],100,0,90,30 combobox #1.w,v$(,[formsize],445,0,60,30 combobox #1.h,v$(,[formsize],510,0,60,30 combobox #1.grid,grid$(,[grid],575,0,90,30 combobox #1.font,font$(,[font],670,0,90,30 graphicbox #1.gb,5,25,800,600 open "Freeform Ultra v1" for window as #1 #1 "trapclose [quit]" #1 "font Consolas 9" #1.gb "font ";projectfont$ #1.tool "select Add New" #1.form "select File" #1.grid "select Set Grid" #1.font "select Set Font" #1.w "select ";projectw #1.h "select ";projecth #1.gb "autoresize" #1.gb "vertscrollbar on 0 ";projectw #1.gb "horizscrollbar on 0 ";projecth #1.gb "down ; fill white" #1.gb "place 0 0 ; color 192 255 255 ; backcolor 192 255 255 ; boxfilled ";projectw;" ";projecth #1.gb "color black ; backcolor white" for x= 0 to projectw step grid for y= 0 to projecth step grid #1.gb "set ";x;" ";y next next #1.gb "flush bak" gosub [draw] #1.gb "when rightButtonDown [show]" #1.gb "when leftButtonDown [select]" #1.gb "when characterInput [keys]" #1.gb "setfocus" #2 "show" show=1 wait
[show] if show then #2.tbproj "!contents? t$" projectname$=t$ #2 "hide" show=0 else #2 "show" show=1 end if wait
'the user clicked on the form design window 'either to chose a control or to deselect a control [select] if show then #2 "hide" show=0 #2.tbproj "!contents? t$" projectname$=t$ end if x=MouseX y=MouseY 'before we move on update the currently selected control from properties #2.tbname "!contents? t$" : obj$(selected,1)=lower$(t$) #2.tbtext "!contents? t$" : obj$(selected,2)=t$ #2.tbreso "!contents? t$" : obj$(selected,3)=lower$(t$) 'find the object selected selected=0 action=1 'move 2=expand for n=obj to 1 step -1 if x>obj(n,1) and x<(obj(n,1)+obj(n,3)) and y>obj(n,2) and y<(obj(n,2)+obj(n,4)) then if x>(obj(n,1)+obj(n,3))-grid*2 then action=2 selected=n exit for end if next if selected=0 then #2.tbname "" #2.tbtext "" #2.tbreso "" #2.tbxywh "" #2.tbfont "" end if if selected>0 and action=1 then #1.gb "when leftButtonMove [track]" #1.gb "when leftButtonUp [stop]" offsetX=x-obj(selected,1) offsetY=y-obj(selected,2) end if if selected>0 and action=2 then #1.gb "when leftButtonMove [tracksize]" #1.gb "when leftButtonUp [stopsize]" offsetX=x-(obj(n,1)+obj(n,3)) offsetY=y-(obj(n,2)+obj(n,4)) end if gosub [draw] wait
[track] x=int((MouseX-offsetX+5)/grid)*grid if x<grid then x=grid if x+obj(selected,3)>projectw-grid then x=projectw-grid-obj(selected,3) obj(selected,1)=x y=int((MouseY-offsetY+5)/grid)*grid if y<grid then y=grid if y+obj(selected,4)>projecth-grid then y=projecth-grid-obj(selected,4) obj(selected,2)=y gosub [draw] wait
[stop] #1.gb "when leftButtonMove" #1.gb "when leftButtonUp" 'selected=0 gosub [draw] wait
[tracksize] x=int((MouseX-offsetX+5)/grid)*grid if x>projectw-grid then x=projectw-grid if x<obj(selected,1)+grid then x=obj(selected,1)+grid y=int((MouseY-offsetY+5)/grid)*grid if y>projecth-grid then y=projecth-grid if y<obj(selected,2)+ctrh then y=obj(selected,2)+ctrh obj(selected,3)=x-obj(selected,1)'width obj(selected,4)=y-obj(selected,2)'height gosub [draw] wait
[stopsize] #1.gb "when leftButtonMove" #1.gb "when leftButtonUp" action=1 'selected=0 gosub [draw] wait
[keys] k1=asc(right$(Inkey$,1)) k2=asc(left$(Inkey$,1)) print k1,k2 if k1=46 then 'delete selected obj(selected,5)=0 #2.tbname "" #2.tbtext "" #2.tbreso "" #2.tbxywh "" #2.tbfont "" selected=0 gosub [draw] end if if k1=3 then 'copy cpy(1)=obj(selected,1) 'x cpy(2)=obj(selected,2) 'y cpy(3)=obj(selected,3) 'w cpy(4)=obj(selected,4) 'h cpy(5)=obj(selected,5) 'type cpy(6)=obj(selected,6) 'textheight cpy$(1)=obj$(selected,1)'name cpy$(2)=obj$(selected,2)'text content cpy$(3)=obj$(selected,3)'resource array or file path cpy$(4)=obj$(selected,4)'ctrl specific font or "" selected=0 gosub [draw] end if if k1=22 then 'paste if cpy(5)<>0 then obj=obj+1 obj(obj,1)=cpy(1) obj(obj,2)=cpy(2)+cpy(4)+grid cpy(2)=obj(obj,2) obj(obj,3)=cpy(3) obj(obj,4)=cpy(4) obj(obj,5)=cpy(5) obj(obj,6)=cpy(6) obj$(obj,1)=left$(cpy$(1),2);obj obj$(obj,2)=cpy$(2) obj$(obj,3)=cpy$(3) if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) obj$(obj,4)=cpy$(4) selected=obj gosub [draw] end if end if #1.gb "setfocus" wait
[tool] #1.tool "selectionindex? i" cpy(5)=0 select case i case 1 'statictext obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=1 obj$(obj,1)="st";obj obj$(obj,2)="Static text?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 2 'textbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh obj(obj,5)=2 obj$(obj,1)="tb";obj obj$(obj,2)="I am a textbox" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 3 'listbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh*5 obj(obj,5)=3 obj$(obj,1)="lb";obj obj$(obj,2)="Listbox \item2\item3\item4\item5" obj$(obj,3)=obj$(obj,1);"$(10)" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 4 'combobox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=200 obj(obj,4)=ctrh obj(obj,5)=4 obj$(obj,1)="cb";obj obj$(obj,2)="Combobox \item2\item3\item4\item5" obj$(obj,3)=obj$(obj,1);"$(" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 5 'button obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=5 obj$(obj,1)="bt";obj obj$(obj,2)="Button?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 6 'bmp button obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=50 obj(obj,4)=50 obj(obj,5)=6 obj$(obj,1)="bb";obj filedialog "Choose an image","*.bmp",file$ if file$<>"" then open file$ for input as #bmp 'the bmpfileheader bmp$ = Input$(#bmp,lof(#bmp)) obj(obj,3)=value(mid$(bmp$,19,4))'width obj(obj,4)=value(mid$(bmp$,23,4))'height close #bmp loadbmp obj$(obj,1),file$ end if obj$(obj,2)="bmp" obj$(obj,3)=file$ case 7 'graphicbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=100 obj(obj,5)=7 obj$(obj,1)="gb";obj obj$(obj,2)="I am a graphicbox" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if
case 8 'radiobutton obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=8 obj$(obj,1)="rb";obj obj$(obj,2)="(o) radio?" obj$(obj,3)="" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if case 9 'checkbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=ctrh obj(obj,5)=9 obj$(obj,1)="cb";obj obj$(obj,2)="[x] check?" obj$(obj,3)="" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if
case 10 'groupbox obj=obj+1 obj(obj,1)=grid obj(obj,2)=grid obj(obj,3)=100 obj(obj,4)=100 obj(obj,5)=10 obj$(obj,1)="gr";obj obj$(obj,2)="Group name?" if ctrf$<>projectfont$ then obj$(obj,4)=ctrf$ obj(obj,6))=ctrh end if end select selected=obj gosub [draw] #1.tool "select Add New" #1.gb "setfocus" wait
[form] #1.form "selectionindex? i" select case i case 2 'write gosub [write] case 3 'save as gosub [saveas] case 4 'load goto [load] case 5 'new gosub [new] end select #1.form "select File" gosub [draw] #1.gb "setfocus" wait
[draw] 'clear background to grid image '#1.gb "discard ; drawbmp bak 0 0" #1.gb "discard ; redraw bak" 'redraw the controls for n= 1 to obj 'skip if deleted if obj(n,5)=0 then goto [deleted] 'select which font the control will be drawn with increase control height if necessary if obj$(n,4)="" then #1.gb "font ";projectfont$ ch=projectctrh if obj(n,4)<ch then obj(n,4)=ch else #1.gb "font ";obj$(n,4) ch=obj(n,6) if obj(n,4)<ch then obj(n,4)=ch end if #1.gb "color black ; backcolor white" 'if it is selected control change drawing color if n=selected then if action=1 then #1.gb "color red" if action=2 then #1.gb "color green" 'update the properties textboxes #2.tbname obj$(n,1) #2.tbtext obj$(n,2) #2.tbreso obj$(n,3) #2.tbxywh obj(n,1);" ";obj(n,2);" ";obj(n,3);" ";obj(n,4) if obj$(n,4)="" then #2.tbfont projectfont$;":";obj(n,6) else #2.tbfont obj$(n,4);":";obj(n,6) end if 'if it is a checkbox radiobox or static text make background color transparent if obj(n,5)=1 or obj(n,5)=8 or obj(n,5)=9 or obj(n,5)=10 then 'if we are expanding make outline color green if n=selected and action=2 then #1.gb "color 0 255 0 ; backcolor 192 255 255" else #1.gb "color 192 192 192 ; backcolor 192 255 255" end if 'now draw the object at desired location #1.gb "place ";obj(n,1);" ";obj(n,2) 'if it is a bmp just draw that if obj(n,5)=6 then #1.gb "drawbmp ";obj$(n,1) else 'draw outline if it is a groupbox all else filled if obj(n,5)=10 then #1.gb "box ";obj(n,1)+obj(n,3);" ";obj(n,2)+obj(n,4) else #1.gb "boxfilled ";obj(n,1)+obj(n,3);" ";obj(n,2)+obj(n,4) end if 'now draw the text in black, or red if control is selected #1.gb "color black " if n=selected then #1.gb "color red" select case obj(n,5) case 5 'centre button text #1.gb "stringwidth? ";obj$(n,2);" width" xp=(obj(n,3)-width*len(obj$(n,2)))/2 #1.gb "place ";obj(n,1)+xp;" ";obj(n,2)+ch/1.33;" ;\";obj$(n,2) case 10 'groupbox text is offset #1.gb "place ";obj(n,1)+5;" ";obj(n,2)+ch/1.33-ch/2;" ;\";obj$(n,2) case else 'woa! normal left justified text #1.gb "place ";obj(n,1)+5;" ";obj(n,2)+ch/1.33;" ;\";obj$(n,2) end select end if [deleted] next return
[write] 'filedialog "Create .bas",projectname$;".bas",filename$ filename$="test.bas" if filename$<>"" then open filename$ for output as #op 'the header #op "'Project ";projectname$ #op "'Created with Freeform Ultra Lite v1.2 on ";date$() #op "" #op "'switch off mainwin debugging window" #op "nomainwin" #op "" #op "'Create arrays needed for controls listbox,combobox" for n= 1 to obj if obj(n,5)=3 or obj(n,5)=4 then #op "dim ";obj$(n,3);"10)" #op "for n = 1 to 10" #op " ";obj$(n,3);"n)= str$(n)" #op "next" end if next #op "'Window and control creation" #op "WindowWidth = ";projectw #op "WindowHeight = ";projecth #op "UpperLeftX = int((DisplayWidth-WindowWidth)/2)" #op "UpperLeftY = int((DisplayHeight-WindowHeight)/2)" for n=1 to obj select case obj(n,5) case 1 'statictext #op "statictext #1.";obj$(n,1);" ";chr$(34);trim$(obj$(n,2));chr$(34);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 2 'textbox #op "textbox #1.";obj$(n,1);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 3 'list box #op "listbox #1.";obj$(n,1);",";obj$(n,3);",[";obj$(n,1);"click],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 4 'combobox #op "combobox #1.";obj$(n,1);",";obj$(n,3);",[";obj$(n,1);"click],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 5 'button #op "button #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[";obj$(n,1);"click], UL, ";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 6 'bmpbutton #op "bmpbutton #1.";obj$(n,1);",";chr$(34);obj$(n,3);chr$(34);",[";obj$(n,1);"click], UL, ";obj(n,1);",";obj(n,2) case 7 'graphicbox #op "graphicbox #1.";obj$(n,1);",";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 8 'radiobutton #op "radiobutton #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[radio],[radio],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 9 'checkbox #op "checkbox #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",[check],[check],";obj(n,1);",";obj(n,2);",";obj(n,3);",";obj(n,4) case 10 'group box #op "groupbox #1.";obj$(n,1);",";chr$(34);obj$(n,2);chr$(34);",";obj(n,1);",";obj(n,2)-5;",";obj(n,3);",";obj(n,4) end select next #op "open ";chr$(34);projectname$;chr$(34);" for window_nf as #1" 'apply any control specific fonts for n= 1 to obj if obj(n,5)<>0 and obj$(n,4)<>"" then #op "#1.";obj$(n,1);" ";chr$(34);"!font ";obj$(n,4);chr$(34) end if next #op "wait" #op "" #op "'Create the required handlers for each control" #op "'Radiobutton and Checkboxes are given a single handler" check=0 radio=0 for n=1 to obj select case obj(n,5) case 3 'listbox #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 4 'combobox #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 5 'button #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 6 'bmpbutton #op "[";obj$(n,1);"click]" #op "'Your handler code here" #op "wait" #op "" case 8 'radiobutton if radio=0 then #op "[radio]" #op "'Your handler code here" #op "wait" #op "" radio=1 end if case 9 'checkbox if check=0 then #op "[check]" #op "'Your handler code here" #op "wait" #op "" check=1 end if end select next #op "[quit]" #op "close #1" #op "end" close #op end if 'run StartupDir$;"lbpro.exe ";chr$(34);" LIBERTY -R -M ";DefaultDir$;"\";filename$;chr$(34) return
[saveas] filedialog "Save As...",projectname$;".ffu",filename$ if filename$<>"" then open filename$ for output as #op filename$=right$(filename$,len(filename$)-len(DefaultDir$)-1) #op left$(filename$,len(filename$)-4) #op projectfont$ #op projectctrh #op projectgrid #op projectw #op projecth for n=1 to obj if obj(n,5)<>0 then #op obj(n,1);","; #op obj(n,2);","; #op obj(n,3);","; #op obj(n,4);","; #op obj(n,5);","; #op obj(n,6);","; #op obj$(n,1);","; #op obj$(n,2);","; #op obj$(n,3);","; #op obj$(n,4);","; end if next close #op end if return
[load] filedialog "Open Project...","*.ffu",filename$ if filename$<>"" then open filename$ for input as #ses input #ses, projectname$ #2.tbproj projectname$ input #ses, projectfont$ if projectfont$="" then projectfont$="Consolas 9" #1.gb "font ";projectfont$ input #ses, c$ input #ses, g$ input #ses, w$ input #ses, h$ projectctrh=val(c$) projectgrid=val(g$) grid=projectgrid projectw=val(w$) projecth=val(h$) #1.grid "select ";grid #1.w "select ";projectw #1.h "select ";projecth obj=0 while eof(#ses) = 0 obj=obj+1 obj(obj,1)=val(inputto$(#ses,",")) obj(obj,2)=val(inputto$(#ses,",")) obj(obj,3)=val(inputto$(#ses,",")) obj(obj,4)=val(inputto$(#ses,",")) obj(obj,5)=val(inputto$(#ses,",")) obj(obj,6)=val(inputto$(#ses,",")) obj$(obj,1)=inputto$(#ses,",") obj$(obj,2)=inputto$(#ses,",") obj$(obj,3)=inputto$(#ses,",") obj$(obj,4)=inputto$(#ses,",") if obj(obj,5)=6 then loadbmp obj$(obj,1),obj$(obj,3) wend close #ses end if #1.form "select File" goto [grid]
[new] redim obj(100,6) 'x,y,width/height,type,textheight redim obj$(100,4) 'name,text content,resource,font obj=0 projectname$="Untitled" #2.tbproj projectname$ return
[formsize] #1.w "contents? w$" #1.h "contents? h$" w=val(w$) h=val(h$) if w=0 or h=0 or (w=projectw and h=projecth) then wait projectw=w projecth=h goto [drawgrid]
[grid] 'resize the grid according to user choice, default is 10 #1.grid "contents? g$" grid=val(g$)
[drawgrid] if grid>0 then projectgrid=grid #1.gb "discard ; fill white" #1.gb "place 0 0 ; color 192 255 255 ; backcolor 192 255 255 ; boxfilled ";projectw;" ";projecth #1.gb "color black ; backcolor white" for x= 0 to projectw step grid for y= 0 to projecth step grid #1.gb "set ";x;" ";y next next #1.gb "flush bak" end if #1.grid "select Set Grid" gosub [draw] #1.gb "setfocus" wait
[font] #1.font "contents? f$" if f$="Set Project" then fontdialog projectfont$,f$ if f$<>"" then projectfont$=f$ #1.gb "font ";projectfont$ #1.gb "place 100 100 ;\Q\Q" #1.gb "posxy x y" projectctrh=(y-100)/2+7 ctrf$=projectfont$ ctrh=projectctrh end if end if if f$="Set Control" then fontdialog projectfont$,f$ if f$<>"" then ctrf$=f$ #1.gb "font ";ctrf$ #1.gb "place 100 100 ;\Q\Q" #1.gb "posxy x y" ctrh=(y-100)/2+7 end if end if if f$="Reset Ctrl" then ctrf$=projectfont$ ctrh=projectctrh end if gosub [draw] #1.font "select Set Font" #1.gb "setfocus" wait
[quit2] playwave "beep" #1.gb "setfocus" 'prevent properties window closing by user wait
[quit] 'save away current session to lastsession.ffu open "lastsession.ffu" for output as #ses #ses projectname$ #ses projectfont$ #ses projectctrh #ses projectgrid #ses projectw #ses projecth for n=1 to obj if obj(n,5)<>0 then #ses obj(n,1);","; #ses obj(n,2);","; #ses obj(n,3);","; #ses obj(n,4);","; #ses obj(n,5);","; #ses obj(n,6);","; #ses obj$(n,1);","; #ses obj$(n,2);","; #ses obj$(n,3);","; #ses obj$(n,4);","; end if next close #ses close #2 close #1 end
function value(x$) select case len(x$) case 1 value = asc(x$) case 2 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) case 3 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) value=value+(asc(mid$(x$,3,1))*65536) case 4 value=asc(mid$(x$,1,1)) value=value+(asc(mid$(x$,2,1))*256) value=value+(asc(mid$(x$,3,1))*65536) value=value+(asc(mid$(x$,4,1))*16777216) end select end function
|
|