66
77BEGIN NAMESPACE FabPaintLib.Control
88
9- //Implicit CLIPPER Calling convention : Off
10-
11- class FabPaintLib_Control inherit System.Windows.Forms.ScrollableControl
12- // Fields
13- Private oImg as FabPaintLib
14- private r8Zoom as real8
15-
16- // Methods
17- constructor ()
18- super ()
19- //
20- self :r8Zoom := 1
21- self :SetStyle ((System.Windows.Forms.ControlStyles.DoubleBuffer | (System.Windows.Forms.ControlStyles.AllPaintingInWmPaint | (System.Windows.Forms.ControlStyles.ResizeRedraw | System.Windows.Forms.ControlStyles.UserPaint))), true)
22- self :AutoScroll := true
23-
24- ACCESS Image AS FabPaintLib
25- //r Give access to the FabPaintLib object linked to the control
26- RETURN self :oImg
27-
28- ASSIGN Image ( oNewImg AS FabPaintLib )
29- //p Set a new FabPaintLib object to be linked to the control
30- IF ( oNewImg != NULL_OBJECT )
31- //
32- IF ( oNewImg :IsValid )
33- IF ( SELF :oImg != NULL_OBJECT )
34- SELF :oImg :Destroy ()
35- ENDIF
36- //
37- SELF :oImg := oNewImg
38- Self :UpdateZoom ()
39- SELF :Invalidate ()
40- ENDIF
41- ENDIF
42- RETURN
43-
44-
45- // Drawing the Image
46- protected virtual method OnPaint (e as System.Windows.Forms.PaintEventArgs) as void
47- local matrix as System.Drawing.Drawing2D.Matrix
48- local tmpRect as System.Drawing.Rectangle
49- Local img as System.Drawing.Image
50- //
51- if ((self :oImg == null) .OR. ( Self :oImg :IsValid != True ) )
52- //
53- Super :OnPaintBackground(e)
54- else
55- // Retrieve the underlying System.Drawing.Bitmap object
56- img := Self :oImg :Image
57- //
58- matrix := Matrix{ (single)self :r8Zoom, 0 , 0 , (single)self :r8Zoom, 0 , 0 }
59- matrix :Translate( (single)((real8)self :AutoScrollPosition :X / self :r8Zoom), (single)((real8)self :AutoScrollPosition :Y / self :r8Zoom))
60- e :Graphics :Transform := matrix
61- e :Graphics :InterpolationMode := System.Drawing.Drawing2D.InterpolationMode.High
62- tmpRect := Rectangle{0 , 0 , img :Width , img :Height }
63- e :Graphics :DrawImage (img, tmpRect, 0 , 0 , img :Width , img :Height , System.Drawing.GraphicsUnit.Pixel)
64- //
65- Super :OnPaint(e)
66- endif
67-
68- protected virtual method OnPaintBackground ( e as System.Windows.Forms.PaintEventArgs) as void
69- return
70-
71-
72-
73- access Zoom as real8
74- //
75- return self :r8Zoom
76-
77- assign Zoom (value as real8)
78- //
79- if (IIF (((value < 0 ) .or. (value < 1.0e-5 )),1 ,0 ) != 0 )
80- //
81- value := 1.0E-5
82- endif
83- self :r8Zoom := value
84- self :UpdateZoom ()
85- self :Invalidate ()
86-
87-
88- private method UpdateZoom () as void
89- local tmpSize as System.Drawing.Size
90- Local img as Image
91- //
92- if ((self :oImg == null) .OR. ( Self :oImg :IsValid != True ) )
93- //
94- self :AutoScrollMargin := self :Size
95- else
96- img := Self :oImg :Image
97- //
98- tmpSize := Size{(Long)System.Math.Round ((real8)((img :Width * self :r8Zoom) + 0.5 ) ) , (Long)System.Math.Round ((real8)((img :Height * self :r8Zoom) + 0.5 ) ) }
99- self :AutoScrollMinSize := tmpSize
100- endif
101-
102- end class
103-
9+ //Implicit CLIPPER Calling convention : Off
10+
11+ class FabPaintLib_Control inherit System.Windows.Forms.ScrollableControl
12+ // Fields
13+ Private oImg as FabPaintLib
14+ private r8Zoom as real8
15+
16+ // Methods
17+ constructor ()
18+ super ()
19+ //
20+ self :r8Zoom := 1
21+ self :SetStyle ((System.Windows.Forms.ControlStyles.DoubleBuffer | (System.Windows.Forms.ControlStyles.AllPaintingInWmPaint | (System.Windows.Forms.ControlStyles.ResizeRedraw | System.Windows.Forms.ControlStyles.UserPaint))), true)
22+ self :AutoScroll := true
23+
24+ ACCESS Image AS FabPaintLib
25+ //r Give access to the FabPaintLib object linked to the control
26+ RETURN self :oImg
27+
28+ ASSIGN Image ( oNewImg AS FabPaintLib )
29+ //p Set a new FabPaintLib object to be linked to the control
30+ IF ( oNewImg != NULL_OBJECT )
31+ //
32+ IF ( oNewImg :IsValid )
33+ IF ( SELF :oImg != NULL_OBJECT )
34+ SELF :oImg :Destroy ()
35+ ENDIF
36+ //
37+ SELF :oImg := oNewImg
38+ Self :UpdateZoom ()
39+ SELF :Invalidate ()
40+ ENDIF
41+ ENDIF
42+ RETURN
43+
44+
45+ // Drawing the Image
46+ protected virtual method OnPaint (e as System.Windows.Forms.PaintEventArgs) as void
47+ local matrix as System.Drawing.Drawing2D.Matrix
48+ local tmpRect as System.Drawing.Rectangle
49+ Local img as System.Drawing.Image
50+ //
51+ if ((self :oImg == null) .OR. ( Self :oImg :IsValid != True ) )
52+ //
53+ Super :OnPaintBackground(e)
54+ else
55+ // Retrieve the underlying System.Drawing.Bitmap object
56+ img := Self :oImg :Image
57+ //
58+ matrix := Matrix{ (single)self :r8Zoom, 0 , 0 , (single)self :r8Zoom, 0 , 0 }
59+ matrix :Translate( (single)((real8)self :AutoScrollPosition :X / self :r8Zoom), (single)((real8)self :AutoScrollPosition :Y / self :r8Zoom))
60+ e :Graphics :Transform := matrix
61+ e :Graphics :InterpolationMode := System.Drawing.Drawing2D.InterpolationMode.High
62+ tmpRect := Rectangle{0 , 0 , img :Width , img :Height }
63+ e :Graphics :DrawImage (img, tmpRect, 0 , 0 , img :Width , img :Height , System.Drawing.GraphicsUnit.Pixel)
64+ //
65+ Super :OnPaint(e)
66+ endif
67+
68+ protected virtual method OnPaintBackground ( e as System.Windows.Forms.PaintEventArgs) as void
69+ return
70+
71+
72+
73+ access Zoom as real8
74+ //
75+ return self :r8Zoom
76+
77+ assign Zoom (value as real8)
78+ //
79+ if (IIF (((value < 0 ) .or. (value < 1.0e-5 )),1 ,0 ) != 0 )
80+ //
81+ value := 1.0E-5
82+ endif
83+ self :r8Zoom := value
84+ self :UpdateZoom ()
85+ self :Invalidate ()
86+
87+
88+ private method UpdateZoom () as void
89+ local tmpSize as System.Drawing.Size
90+ Local img as Image
91+ //
92+ if ((self :oImg == null) .OR. ( Self :oImg :IsValid != True ) )
93+ //
94+ self :AutoScrollMargin := self :Size
95+ else
96+ img := Self :oImg :Image
97+ //
98+ tmpSize := Size{(Long)System.Math.Round ((real8)((img :Width * self :r8Zoom) + 0.5 ) ) , (Long)System.Math.Round ((real8)((img :Height * self :r8Zoom) + 0.5 ) ) }
99+ self :AutoScrollMinSize := tmpSize
100+ endif
101+
102+ end class
103+
104104END NAMESPACE
0 commit comments