Microsoft Small Basic

Program Listing: QSC915
' GraphicsWindow Colors 0.1
' Copyright (c) 2014 Nonki Takahashi. All rights reserved.
'
' History:
' 0.1 2014-02-24 Created.
'
GraphicsWindow.Title = "GraphicsWindow Colors 0.1"
Init()
Controls.TextTyped = OnTextTyped
Controls.ButtonClicked = OnButtonClicked
Sub OnTextTyped
last = Controls.LastTypedTextBox
If last = bgBox Then
bg = Controls.GetTextBoxText(bgBox)
GraphicsWindow.BackgroundColor = bg
ElseIf last = bcBox Then
bc = Controls.GetTextBoxText(bcBox)
GraphicsWindow.BrushColor = bc
ElseIf last = pcBox Then
pc = Controls.GetTextBoxText(pcBox)
GraphicsWindow.PenColor = pc
EndIf
EndSub
Sub OnButtonClicked
last = Controls.LastClickedButton
If last = ellBtn Then
If ellObj <> "" Then
Shapes.Remove(ellObj)
EndIf
ellObj = Shapes.AddEllipse(100, 100)
Shapes.Move(ellObj, 60, 200)
ElseIf last = rectBtn Then
GraphicsWindow.FillRectangle(240, 200, 100, 100)
ElseIf last = triBtn Then
GraphicsWindow.DrawTriangle(470, 200, 420, 300, 520, 300)
EndIf
EndSub
Sub Init
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
bg = GraphicsWindow.BackgroundColor
bc = GraphicsWindow.BrushColor
pc = GraphicsWindow.PenColor
GraphicsWindow.BrushColor = "LightGray"
GraphicsWindow.PenColor = "Transparent"
Shapes.AddRectangle(gw, 100)
GraphicsWindow.BrushColor = "Black"
caption = Shapes.AddText("GraphicsWindow.BackgroundColor")
Shapes.Move(caption, 10, 10)
bgBox = Controls.AddTextBox(240, 10)
Controls.SetTextBoxText(bgBox, bg)
Controls.SetSize(bgBox, 80, 22)
caption = Shapes.AddText("GraphicsWindow.BrushColor")
Shapes.Move(caption, 10, 40)
bcBox = Controls.AddTextBox(240, 40)
Controls.SetTextBoxText(bcBox, bc)
Controls.SetSize(bcBox, 80, 22)
caption = Shapes.AddText("GraphicsWindow.PenColor")
Shapes.Move(caption, 10, 70)
pcBox = Controls.AddTextBox(240, 70)
Controls.SetTextBoxText(pcBox, pc)
Controls.SetSize(pcBox, 80, 22)
ellBtn = Controls.AddButton("Shapes.AddEllipse", 380, 10)
rectBtn = Controls.AddButton("GraphicsWindow.FillRectangle", 380, 40)
triBtn = Controls.AddButton("GraphicsWindow.DrawTriangle", 380, 70)
GraphicsWindow.BrushColor = bc
GraphicsWindow.PenColor = pc
EndSub