Code : Tout sélectionner
; ************************************************************************************************************************
; AUTHOR : MicrodevWeb
; PROJECT : Pb POO
; REQUIERED : PB 5.60
; ************************************************************************************************************************
DeclareModule RECT
;=======================================================================================================================
;-* PUBLIC INTERFACE
; ----------------------------------------------------------------------------------------------------------------------
Interface _RECT
Draw()
Free()
EndInterface
;}----------------------------------------------------------------------------------------------------------------------
;=======================================================================================================================
;-* PUBLIC PROTOTYPE
; ----------------------------------------------------------------------------------------------------------------------
Declare New(idCanvas,x,y,w,h,color)
;}----------------------------------------------------------------------------------------------------------------------
EndDeclareModule
Module RECT
EnableExplicit
;=======================================================================================================================
;-* PRIVATE STRUCTURES
; ----------------------------------------------------------------------------------------------------------------------
Structure sRec
*VPRO
idCanvas.l
x.l
y.l
w.l
h.l
color.l
EndStructure
;}----------------------------------------------------------------------------------------------------------------------
;=======================================================================================================================
;=======================================================================================================================
;-* PRIVATE FUNCTION
; ----------------------------------------------------------------------------------------------------------------------
Procedure Draw(*this.sRec)
With *this
StartVectorDrawing(CanvasVectorOutput(\idCanvas))
VectorSourceColor(\color)
AddPathBox(\x,\y,\w,\h)
FillPath()
StopVectorDrawing()
EndWith
EndProcedure
Procedure Free(*this.sRec)
ClearStructure(*this,sRec)
EndProcedure
;}----------------------------------------------------------------------------------------------------------------------
;=======================================================================================================================
;-* PUBLIC FUNCTION
; ----------------------------------------------------------------------------------------------------------------------
Procedure New(idCanvas,x,y,w,h,color)
Protected *Rec.sRec
*Rec=AllocateMemory(SizeOf(sRec))
With *Rec
\idCanvas=idCanvas
\x=x
\y=y
\w=w
\h=h
\color=color
\VPRO=?VPRO
EndWith
ProcedureReturn *Rec
EndProcedure
;}----------------------------------------------------------------------------------------------------------------------
;=======================================================================================================================
;-* DATA SECTION
; ----------------------------------------------------------------------------------------------------------------------
;}----------------------------------------------------------------------------------------------------------------------
DataSection
VPRO:
Data.i @Draw()
Data.i @Free()
EndDataSection
EndModule
Procedure OpenMainForm()
Protected.RECT::_RECT rec1,rec2,rec3,rec4
Protected TimeDelay=400
OpenWindow(0,0,0,800,600,"Teste POO",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CanvasGadget(0,0,0,800,600)
rec1=RECT::New(0,0,0,60,60,$FF2FFFAD)
rec2=RECT::New(0,70,0,60,60,$FF0000FF)
rec3=RECT::New(0,140,0,60,60,$FFFF0000)
rec4=RECT::New(0,0,70,60,60,$FFFF00FF)
rec1\Draw()
Delay(TimeDelay)
rec2\Draw()
Delay(TimeDelay)
rec3\Draw()
Delay(TimeDelay)
rec4\Draw()
rec1\Free()
rec2\Free()
rec3\Free()
rec4\Free()
EndProcedure
OpenMainForm()
Repeat
WaitWindowEvent()
Until Event()=#PB_Event_CloseWindow