Sub OnButtonClicked
buttonClicked = "True"
lastButton = Controls.LastClickedButton
EndSub
Sub SaveCaptionProgram
path = Program.Directory + "\" + caption + ".sb"
' The following line could be harmful and has been automatically commented.
' File.WriteContents(path, buf)
EndSub
Sub Font_GetTextWidth
' param fs - font size
' param fn - font name
' param fb - font bold
' param fi - font italic
' param txt - text to get width in px
' return width - text width
yc = 300
GraphicsWindow.BrushColor = "#FFFFFF"
GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
GraphicsWindow.FontSize = fs
GraphicsWindow.FontName = fn
GraphicsWindow.FontBold = fb
GraphicsWindow.FontItalic = fi
GraphicsWindow.BrushColor = "#FEFEFE"
GraphicsWindow.DrawText(0, yc, "||")
y0 = yc
y1 = yc + fs
x0 = 0
x1 = fs * 2
If gw < x1 Then
x1 = gw - 1
EndIf
Font_Measure()
px0 = px
GraphicsWindow.BrushColor = "#FFFFFF"
GraphicsWindow.FillRectangle(0, yc, gw, gh - yc)
str = "|" + txt + "|"
GraphicsWindow.BrushColor = "#FEFEFE"
GraphicsWindow.DrawText(0, yc, str)
x1 = fs * Text.GetLength(str)
If gw < x1 Then
x1 = gw - 1
EndIf
Font_Measure()
width = px - px0
EndSub
Sub Font_Measure
' return px - width in pixel (px)
_y = Math.Floor((y0 + y1) / 2)
For _x = x0 To x1
color = GraphicsWindow.GetPixel(_x, _y)
If Not[Text.EndsWith(color, "FFFFFF")] Then
left = _x
_x = x1 ' exit For
EndIf
EndFor
For _x = x1 To x0 Step -1
color = GraphicsWindow.GetPixel(_x, _y)
If Not[Text.EndsWith(color, "FFFFFF")] Then
right = _x
_x = x0 ' exit For
EndIf
EndFor
For _x = right To x0 Step -1
color = GraphicsWindow.GetPixel(_x, _y)
If Text.EndsWith(color, "FFFFFF") Then
right = _x + 1
_x = x0 ' exit For
EndIf
EndFor
px = right - left
EndSub
Sub Shapes_AddEllipse
' param x, y - top left position
' param width
' param height
Shapes_EntryClear()
Shapes_PenToEntry()
Shapes_BrushToEntry()
func = "ell"
Shapes_FuncToEntry()
Shapes_MoveToEntry()
Shapes_RotateToEntry()
Shapes_EntryToArray()
EndSub
Sub Shapes_AddLine
' param x1, y1 - first point
' param x2, y2 - second point
Shapes_EntryClear()
Shapes_PenToEntry()
func = "line"
Shapes_FuncToEntry()
Shapes_MoveToEntry()
Shapes_RotateToEntry()
Shapes_EntryToArray()
EndSub
Sub Shapes_AddRectangle
' param x, y - top left position
' param width
' param height
Shapes_EntryClear()
Shapes_PenToEntry()
Shapes_BrushToEntry()
func = "rect"
Shapes_FuncToEntry()
Shapes_MoveToEntry()
Shapes_RotateToEntry()
Shapes_EntryToArray()
EndSub
Sub Shapes_AddText
' param x, y - top left position
' param txt - text
Shapes_EntryClear()
Shapes_PenToEntry()
Shapes_BrushToEntry()
Shapes_FontToEntry()
func = "text"
Shapes_FuncToEntry()
Shapes_MoveToEntry()
Shapes_RotateToEntry()
Shapes_EntryToArray()
EndSub
Sub Shapes_AddTriangle
' param x1, y1 - first point
' param x2, y2 - second point
' param x3, y3 - third point
Shapes_EntryClear()
Shapes_PenToEntry()
Shapes_BrushToEntry()
func = "tri"
Shapes_FuncToEntry()
Shapes_MoveToEntry()
Shapes_RotateToEntry()
Shapes_EntryToArray()
EndSub
Sub Shapes_BrushToEntry
GraphicsWindow.BrushColor = bc
shp["bc"] = bc
EndSub
Sub Shapes_PenToEntry
GraphicsWindow.PenWidth = pw
shp["pw"] = pw
If 0 < pw Then
GraphicsWindow.PenColor = pc
shp["pc"] = pc
EndIf
EndSub
Sub Shapes_Remove
' Shapes | Remove shapes
' param iMin, iMax - shapes indices to remove
' param shape - array of shapes
Stack.PushValue("local", i)
For i = iMin To iMax
shp = shape[i]
Shapes.Remove(shp["obj"])
EndFor
i = Stack.PopValue("local")
EndSub
Sub Shapes_RotateToEntry
If angle <> 0 Then
Shapes.Rotate(obj, angle)
shp["angle"] = Math.Floor(angle * 100) / 100
EndIf
EndSub