One part
The draw of the grid
Code: Select all
; Name: DrawGrid
; Author: MicrodevWeb
EnableExplicit
Enumeration
#MainForm
#MainCanvas
EndEnumeration
Global gGridSpace=10 ;The space between the dots
Global gGridColor=$2D52A0 ; The backgroud coloe
Global gBgColor=$B3DEF5
Procedure Exit()
End
EndProcedure
Procedure OpenMainForm()
Protected Flag=#PB_Window_SystemMenu|#PB_Window_Maximize
; Open Window
OpenWindow(#MainForm,0,0,800,600,"Dssin d'une grille",Flag)
; Make canvas
CanvasGadget(#MainCanvas,0,0,WindowWidth(#MainForm),WindowHeight(#MainForm))
; Callback with close window
BindEvent(#PB_Event_CloseWindow,@Exit(),#MainForm)
EndProcedure
Procedure DrawGrid()
Protected X=gGridSpace,Y=gGridSpace
While X<GadgetWidth(#MainCanvas)
Y=gGridSpace ; Restart Up
While Y<GadgetHeight(#MainCanvas)
Plot(X,Y,gGridColor)
Y+gGridSpace ; Move the Dot of Y
Wend
X+gGridSpace ; Move the Dot of X
Wend
EndProcedure
Procedure DrawCanvas()
StartDrawing(CanvasOutput(#MainCanvas))
; Eraze the canvas
Box(0,0,GadgetWidth(#MainCanvas),GadgetHeight(#MainCanvas),gBgColor)
; Draw the grd
DrawGrid()
StopDrawing()
EndProcedure
;-* Run programme
; --> List of procedures who must run of started software
; Open window
OpenMainForm()
; Draw canvas
DrawCanvas()
;}
;-* Main loop
; --> The main loop empty but i manage the event with BindEvent etc...
Repeat :WaitWindowEvent():ForEver
;}