4 Â mckCtrls y TKOLButton,TKOLLabel,TEditbox,TCheckBox è TRadioBox íyæíî
7 TKOL#####=class(TKOLControl)
10 procedure Paint;override;
16 procedure TKOL#####.Paint;
18 Draw#####(self,canvas);
26 windows
, graphics
, mirror
, mckctrls
, extctrls
, classes
;
28 procedure DrawButton(_Button
:TKOLButton
; Canvas
:TCanvas
);
29 procedure DrawLabel(_Label
:TKOLLabel
; Canvas
:TCanvas
);
30 procedure DrawEditbox(_Editbox
:TKOLEditbox
; Canvas
:TCanvas
);
31 procedure DrawCheckbox(_Checkbox
:TKOLCheckbox
; Canvas
:TCanvas
);
32 procedure DrawRadiobox(_Radiobox
:TKOLRadiobox
; Canvas
:TCanvas
);
33 procedure DrawCombobox(_Combobox
:TKOLCombobox
; Canvas
:TCanvas
);
38 TextHFlags
:array[TTextAlign
] of dword
=(DT_LEFT
,DT_RIGHT
,DT_CENTER
);
39 TextVFlags
:array[TVerticalAlign
] of dword
=(DT_TOP
,DT_VCENTER
,DT_BOTTOM
);
40 WordWrapFlags
:array[Boolean] of dword
=(DT_SINGLELINE
,0);
41 CheckFlags
:array[Boolean] of dword
=(0,DFCS_CHECKED
);
43 procedure DrawButton(_Button
:TKOLButton
; Canvas
:TCanvas
);
48 with _button
,canvas
do
52 drawframecontrol(handle
,r
,DFC_BUTTON
,DFCS_BUTTONPUSH
);
54 setbkmode(handle
,windows
.TRANSPARENT
);
55 drawtext(handle
,pchar(s
),length(s
),r
,texthflags
[textalign
] or
56 textvflags
[verticalalign
] or DT_SINGLELINE
);
60 procedure DrawLabel(_Label
:TKOLLabel
; Canvas
:TCanvas
);
69 brush
.color
:=clbtnshadow
;
71 setbkmode(handle
,windows
.TRANSPARENT
);
72 drawtext(handle
,pchar(s
),length(s
),r
,texthflags
[textalign
] or
73 textvflags
[verticalalign
] or wordwrapflags
[wordwrap
]);
77 procedure DrawEditbox(_Editbox
:TKOLEditbox
; Canvas
:TCanvas
);
82 with _editbox
,canvas
do
88 frame3d(canvas
,r
,clbtnshadow
,clbtnhighlight
,1);
89 frame3d(canvas
,r
,clblack
,cl3dlight
,1);
91 setbkmode(handle
,windows
.TRANSPARENT
);
92 drawtext(handle
,pchar(s
),length(s
),r
,
93 texthflags
[textalign
] or DT_SINGLELINE
);
97 procedure DrawCheckbox(_Checkbox
:TKOLCheckbox
; Canvas
:TCanvas
);
102 with _checkbox
,canvas
do
107 {brush.color:=clbtnshadow;
109 if _Checkbox
.HasBorder
then
110 DrawEdge( Canvas
.Handle
, r
, EDGE_RAISED
, BF_RECT
or BF_MIDDLE
);
112 rr
:=bounds(r
.left
+2,(r
.bottom
+r
.top
-13) div 2,13,13);
113 drawframecontrol(handle
,rr
,DFC_BUTTON
,
114 DFCS_BUTTONCHECK
or checkflags
[checked
]);
116 setbkmode(handle
,windows
.TRANSPARENT
);
117 drawtext(handle
,pchar(s
),length(s
),r
,DT_VCENTER
or DT_SINGLELINE
);
121 procedure DrawRadiobox(_Radiobox
:TKOLRadiobox
; Canvas
:TCanvas
);
126 with _radiobox
,canvas
do
131 {brush.color:=clbtnshadow;
133 if _Radiobox
.HasBorder
then
134 DrawEdge( Canvas
.Handle
, r
, EDGE_RAISED
, BF_RECT
or BF_MIDDLE
);
136 rr
:=bounds(r
.left
+2,(r
.bottom
+r
.top
-13) div 2,13,13);
137 drawframecontrol(handle
,rr
,DFC_BUTTON
,
138 DFCS_BUTTONRADIO
or checkflags
[checked
]);
140 setbkmode(handle
,windows
.TRANSPARENT
);
141 drawtext(handle
,pchar(s
),length(s
),r
,DT_VCENTER
or DT_SINGLELINE
);
145 procedure DrawCombobox1(_Combobox
:TKOLCombobox
; Canvas
:TCanvas
;
151 with _Combobox
,canvas
do
153 if (curindex
>=0) and (curindex
<items
.count
) then s
:=items
[curindex
] else
157 frame3d(canvas
,r
,clbtnshadow
,clbtnhighlight
,1);
158 frame3d(canvas
,r
,clblack
,cl3dlight
,1);
160 if not( coSimple
in _Combobox
.Options
) then
162 w
:=getsystemmetrics(SM_CXVSCROLL
);
163 drawframecontrol(handle
,rect(r
.right
-w
,r
.top
,r
.right
,r
.bottom
),DFC_SCROLL
,
164 DFCS_SCROLLCOMBOBOX
);
167 setbkmode(handle
,windows
.TRANSPARENT
);
168 if s
<>'' then drawtext(handle
,pchar(s
),length(s
),r
,DT_VCENTER
or
173 procedure DrawCombobox(_Combobox
:TKOLCombobox
; Canvas
:TCanvas
);
179 if coSimple
in _Combobox
.Options
then
181 R
:= _Combobox
.ClientRect
;
183 R
.Bottom
:= R
.Top
+ Canvas
.TextHeight( 'A' ) + 8;
184 DrawCombobox1( _Combobox
, Canvas
, R
);
187 frame3d(Canvas
,R
,clbtnshadow
,clbtnhighlight
,1);
188 frame3d(Canvas
,R
,clblack
,cl3dlight
,1);
190 setbkmode(Canvas
.Handle
,windows
.TRANSPARENT
);
192 for I
:= 0 to _Combobox
.Items
.Count
-1 do
194 S
:= _Combobox
.Items
[ I
];
195 R1
.Bottom
:= R1
.Top
+ Canvas
.TextHeight( 'A' ) + 4;
196 if R1
.Bottom
> R
.Bottom
then
197 R1
.Bottom
:= R
.Bottom
;
198 drawtext(Canvas
.Handle
,pchar(S
),length(s
),r1
,
199 {DT_VCENTER or} DT_SINGLELINE
);
201 if R1
.Top
>= R
.Bottom
then
203 R
.Left
:= R
.Right
- getsystemmetrics( SM_CXVSCROLL
);
204 //DrawScrollBar_Vertical( Canvas.Handle, R );
211 DrawCombobox1( _Combobox
, Canvas
, _Combobox
.ClientRect
);