DECLARE SUB CanvasPaint (Sender AS QCanvas)
DECLARE SUB ButtonClick (Sender AS QButton)
' Create bitmap for off-screen use
DIM BitMap AS QBITMAP
BitMap.Height = 100
BitMap.Width = 100
BitMap.Paint(0,0,0,0)
CREATE Form AS QForm
Center
Caption = "Simple graphics demonstration"
CREATE Canvas AS QCanvas
OnPaint = CanvasPaint
END CREATE
CREATE SquareButton AS QButton
Caption = "Draw Square"
OnClick = ButtonClick
Left = 150
END CREATE
CREATE CircleButton AS QButton
Caption = "Draw Circle"
OnClick = ButtonClick
Left = 150
Top = 50
END CREATE
CREATE LineButton AS QButton
Caption = "Draw Line"
OnClick = ButtonClick
Left = 150
Top = 100
END CREATE
ShowModal
END CREATE
SUB CanvasPaint (Sender AS QCanvas)
Sender.Draw(0,0,Bitmap.BMP)
END SUB
SUB ButtonClick (Sender AS QButton)
SELECT CASE Sender.Caption
CASE "Draw Square"
Bitmap.FillRect(10,10,50,50,&HFF0000)
CASE "Draw Circle"
Bitmap.Circle(10,60,50,110,&H0000FF,&H0000FF)
CASE "Draw Line"
Bitmap.Line(50,50,90,90,&H00FF00)
END SELECT
Canvas.Repaint '-- Tell Canvas to repaint itself.
END SUB
|