Skip to content

Commit

Permalink
Version 0.3a
Browse files Browse the repository at this point in the history
- Form file separeted from source.

Signed-off-by: Nonki Takahashi <nobukit@jcom.home.ne.jp>
  • Loading branch information
Nonki Takahashi committed Apr 25, 2016
1 parent 178a8ae commit cf2d5f8
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 31 deletions.
125 changes: 94 additions & 31 deletions Form.sb
Original file line number Diff line number Diff line change
@@ -1,46 +1,94 @@
''' Form
''' Version 0.2a
''' Version 0.3a
''' Copyright © 2016 Nonki Takahashi. The MIT License.
''' Last update 2016-04-25
''' Challenge 2016-01/02
''' Repository https://github.com/nonkit/Form.git
''' Program ID KMT677-0
''' Program ID KMT677-1
'
GraphicsWindow.Title = "Form 0.2a"
title = "Form 0.3a"
CR = Text.GetCharacter(13)
LF = Text.GetCharacter(10)
filename = "Form.sb"
GetForm()
ShowForm()
DrawGrids()
filename = "Form1.sb"
grid = "True"
DrawForm()
' show form array
buf = ""
For i = 1 To nForm
buf = buf + "form[" + i + "]: " + form[i] + CR + LF
EndFor
Controls.SetTextBoxText(frm["obj"], buf)
While "True"
If buttonClicked Then
frm = form[5]
filename = Controls.GetTextBoxText(frm["obj"])
GraphicsWindow.Title = filename
GraphicsWindow.Clear()
DrawForm()
buttonClicked = "False"
Else
Program.Delay(200)
EndIf
EndWhile
Sub DrawForm
''' Draw form
Form_GetForm()
Form_ShowForm()
If grid Then
gap = 10
color = "#999999"
DrawGrids()
gap = 100
color = "#666666"
DrawGrids()
EndIf
EndSub
Sub DrawGrids
dy = 50
dx = 50
''' Draw grids
''' param gap
''' param color
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "#999999"
For y = dy To gh Step dy
GraphicsWindow.PenColor = color
For y = gap To gh Step gap
GraphicsWindow.DrawLine(0, y, gw, y)
EndFor
For x = dx To gw Step dx
For x = gap To gw Step gap
GraphicsWindow.DrawLine(x, 0, x, gh)
EndFor
EndSub
Sub ShowForm
Sub Form_ShowForm
''' Form | Show form
''' param form - array of the form
''' param nForm - number of objects in the form
''' return gw - width of the graphics window
''' return gh - height of the graphics window
For i = 1 To nForm
frm = form[i]
If frm["func"] = "form" Then
' func=form;bg=LightGray;gx=10;gy=10;gw=598;gh=428;
GraphicsWindow.BackgroundColor = frm["bg"]
GraphicsWindow.Left = frm["gx"]
GraphicsWindow.Top = frm["gy"]
gw = frm["gw"]
gh = frm["gh"]
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
' func=form;bg=LightGray;gx=10;gy=10;gw=598;gh=428;title=Form 0.3a;
If frm["bg"] <> "" Then
GraphicsWindow.BackgroundColor = frm["bg"]
EndIf
If frm["gx"] <> "" Then
GraphicsWindow.Left = frm["gx"]
EndIf
If frm["gx"] <> "" Then
GraphicsWindow.Top = frm["gy"]
EndIf
If frm["gw"] <> "" Then
GraphicsWindow.Width = frm["gw"]
EndIf
gw = GraphicsWindow.Width
If frm["gh"] <> "" Then
GraphicsWindow.Height = frm["gh"]
EndIf
gh = GraphicsWindow.Height
If frm["title"] <> "" Then
GraphicsWindow.Title = frm["title"]
EndIf
ElseIf frm["func"] = "text" Then
' func=text;text=Word;x=10;y=15;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=text;text=Folder;x=10;y=15;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=text;text=Filename;x=10;y=45;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
GraphicsWindow.FontName = frm["fn"]
GraphicsWindow.FontSize = frm["fs"]
GraphicsWindow.FontBold = frm["fb"]
Expand All @@ -49,23 +97,26 @@ Sub ShowForm
frm["obj"] = Shapes.AddText(frm["text"])
Shapes.Move(frm["obj"], frm["x"], frm["y"])
ElseIf frm["func"] = "tbox" Then
' func=tbox;x=50;y=12;width=140;height=22;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=tbox;x=70;y=12;width=460;height=22;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;text=.;
' func=tbox;x=70;y=42;width=140;height=22;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;text=Form.sb;
GraphicsWindow.FontName = frm["fn"]
GraphicsWindow.FontSize = frm["fs"]
GraphicsWindow.FontBold = frm["fb"]
GraphicsWindow.FontItalic = frm["fi"]
GraphicsWindow.BrushColor = frm["bc"]
frm["obj"] = Controls.AddTextBox(frm["x"], frm["y"])
Controls.SetSize(frm["obj"], frm["width"], frm["height"])
Controls.SetTextBoxText(frm["obj"], frm["text"])
ElseIf frm["func"] = "btn" Then
' func=btn;caption=OK;x=200;y=10;width=28;height=26;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=btn;caption=OK;x=220;y=40;width=28;height=26;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
GraphicsWindow.FontName = frm["fn"]
GraphicsWindow.FontSize = frm["fs"]
GraphicsWindow.FontBold = frm["fb"]
GraphicsWindow.FontItalic = frm["fi"]
GraphicsWindow.BrushColor = frm["bc"]
frm["obj"] = Controls.AddButton(frm["caption"], frm["x"], frm["y"])
Controls.SetSize(frm["obj"], frm["width"], frm["height"])
Controls.ButtonClicked = OnButtonClicked
ElseIf frm["func"] = "rect" Then
' func=rect;x=546;y=10;width=2;height=32;scale=2;pw=0;pc=Black;bc=#999999;
GraphicsWindow.PenWidth = frm["pw"]
Expand All @@ -74,12 +125,17 @@ Sub ShowForm
frm["obj"] = Shapes.AddRectangle(frm["width"], frm["height"])
Shapes.Move(frm["obj"], frm["x"], frm["y"])
ElseIf frm["func"] = "img" Then
' func=img;src=img/Form.png;x=556;y=10;width=16;height=16;scale=2;
frm["obj"] = Shapes.AddImage(Program.Directory + "/" + frm["src"])
Shapes.Move(frm["obj"], frm["x"] + frm["width"] * (frm["scale"] - 1) / 2, frm["y"] + frm["height"] * (frm["scale"] - 1) / 2)
Shapes.Zoom(frm["obj"], frm["scale"], frm["scale"])
' func=img;src=img/Form.png;x=556;y=10;width=32;height=32;
img = ImageList.LoadImage(Program.Directory + "/" + frm["src"])
ix = ImageList.GetWidthOfImage(img)
iy = ImageList.GetHeightOfImage(img)
scaleX = frm["width"] / ix
scaleY = frm["height"] / iy
frm["obj"] = Shapes.AddImage(img)
Shapes.Move(frm["obj"], frm["x"] + (frm["width"] - ix) / 2, frm["y"] + (frm["height"] - iy) / 2)
Shapes.Zoom(frm["obj"], scaleX, scaleY)
ElseIf frm["func"] = "mtbox" Then
' func=mtbox;x=10;y=52;width=578;height=366;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=mtbox;x=10;y=72;width=578;height=346;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
GraphicsWindow.FontName = frm["fn"]
GraphicsWindow.FontSize = frm["fs"]
GraphicsWindow.FontBold = frm["fb"]
Expand All @@ -88,13 +144,18 @@ Sub ShowForm
frm["obj"] = Controls.AddMultiLineTextBox(frm["x"], frm["y"])
Controls.SetSize(frm["obj"], frm["width"], frm["height"])
EndIf
form[i] = frm
EndFor
EndSub
Sub GetForm
Sub OnButtonClicked
buttonClicked = "True"
EndSub
Sub Form_GetForm
''' Form | Get form from file
''' param filename - file name
''' return form - array for the form
folder = Program.Directory
buf = File.ReadContents(folder + "\" + filename)
buf = File.ReadContents(folder + "/" + filename)
len = Text.GetLength(buf)
p = 1
nForm = 0
Expand All @@ -111,6 +172,7 @@ Sub GetForm
EndWhile
EndSub
Sub RemoveLeadingSpace
''' Remove leading space
''' param line - to remove leading space
''' return line - the result
Stack.PushValue("local", p)
Expand All @@ -122,6 +184,7 @@ Sub RemoveLeadingSpace
p = Stack.PopValue("local")
EndSub
Sub GetLine
''' Get line from buf
''' param p - pointer to buf
''' param buf - buffer
''' param len - length of the buffer
Expand Down
9 changes: 9 additions & 0 deletions Form1.sb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
' func=form;bg=LightGray;gx=10;gy=10;gw=598;gh=428;title=Form 0.3a;
' func=text;text=Folder;x=10;y=15;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=text;text=Filename;x=10;y=45;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=tbox;x=70;y=12;width=460;height=22;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;text=.;
' func=tbox;x=70;y=42;width=140;height=22;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;text=Form1.sb;
' func=btn;caption=OK;x=220;y=40;width=28;height=26;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
' func=rect;x=546;y=10;width=2;height=32;scale=2;pw=0;pc=Black;bc=#999999;
' func=img;src=img/Form32.png;x=556;y=10;width=32;height=32;
' func=mtbox;x=10;y=72;width=578;height=346;bc=Black;fn=Segoe UI;fs=12;fb=True;fi=False;
Binary file added img/Form32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cf2d5f8

Please sign in to comment.