diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 60f6568..b640ae7 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -2237,7 +2237,7 @@ type TListBox = class(TcustomListBox) return array("name","caption","anchors","align","enabled", "font","visible","border","color", "height","width","left","top","items", - "multisel","popupmenu","wsdlgmodalframe", + "multisel","checkbox","popupmenu","wsdlgmodalframe", "onmousedown","onmouseup", "onselectionchange" ); diff --git a/funcext/tvclib/utslvclstdctl.tsf b/funcext/tvclib/utslvclstdctl.tsf index 9aa986b..5d1c436 100644 --- a/funcext/tvclib/utslvclstdctl.tsf +++ b/funcext/tvclib/utslvclstdctl.tsf @@ -3134,6 +3134,7 @@ type TcustomListBox=class(TCustomListBoxbase) FSelBegin :=-1; FSelEnd :=-1; FMultisel := false; + fcheckbox := false; end function MouseUp(o,e);override; begin @@ -3233,8 +3234,19 @@ type TcustomListBox=class(TCustomListBoxbase) @param(rc)(array) »æÖÆÇøÓò%% @param(cvs)(tcustomcanvas) »­²¼ %% **} - PaintIdxBkg(idx,rc,cvs); - PaintIdexText(idx,rc,cvs); + r := PaintIdxBkg(idx,rc,cvs); + rc1 := rc; + if fcheckbox then + begin + + h := rc[3]-rc[1]; + nh := min(h,16); + nnh := integer((h-nh)/2); + rc2 := array(rc[0]+2,rc[1]+nnh,rc[0]+nh+2,rc[3]-nnh); + cvs.Draw("framecontrol",array(rc2[0:1],rc2[2:3]),DFC_BUTTON,(r)?DFCS_CHECKED:DFCS_BUTTONCHECK); + rc1[0]+=nh+5; + end + PaintIdexText(idx,rc1,cvs); end function PaintIdexText(idx,rc,cvs);virtual; begin @@ -3264,7 +3276,7 @@ type TcustomListBox=class(TCustomListBoxbase) FSelBegin := FSelEnd := n; InvalidateRect(nil,false); end else - if ifarray(n)and isValidIndex(n[1])and isValidIndex(n[0])then + if ifarray(n) and isValidIndex(n[1])and isValidIndex(n[0])then begin FSelBegin := MinValue(n); FSelEnd := MaxValue(n); @@ -3296,7 +3308,7 @@ type TcustomListBox=class(TCustomListBoxbase) SelRange(true); SetYpos(n); if FselectionChange then - CallMessgeFunction(FselectionChange,self(true),new tuieventbase(0,0,0,0)); + CallMessgeFunction(FselectionChange,self(true),new tuieventbase(0,0,0,0)); end function getItemSelectedState(n); begin @@ -3331,11 +3343,14 @@ type TcustomListBox=class(TCustomListBoxbase) @param(state)(bool)״̬%% **} b := state?1:0; - if FMultisel <> 2 or not isValidIndex(n)or b=getItemSelectedState(n)then return; + if (FMultisel <> 2) or not(isValidIndex(n)) or (b=getItemSelectedState(n)) then return; if b then FMultisel3Data[n]:= b; - else reindex(FMultisel3Data,array(n:nil)); + else + begin + reindex(FMultisel3Data,array(n:nil)); + end if FselectionChange then - CallMessgeFunction(FselectionChange,self(true),new tuieventbase(0,0,0,0)); + CallMessgeFunction(FselectionChange,self(true),new tuieventbase(0,0,0,0)); InvalidateIdxRect(n); end function appendItem(item);virtual; @@ -3562,6 +3577,7 @@ type TcustomListBox=class(TCustomListBoxbase) end property ItemCount read GetItemCount; property Multisel:bool read FMultisel write SetMultisel; + property checkbox:bool read fcheckbox write setcheckbox; property onSelectionChange:eventhandler read FselectionChange write FselectionChange; property Items:strings read GetData write setData; protected @@ -3598,11 +3614,22 @@ type TcustomListBox=class(TCustomListBoxbase) begin if(idx >= min(FSelBegin,FSelEnd)and idx <= max(FSelBegin,FSelEnd))or(FMultisel=2 and FMultisel3Data[idx])then begin + r := true; cvs.brush.Color := rgb(204,231,255); end else - cvs.Brush.Color := Color; + cvs.Brush.Color := Color; cvs.FillRect(rc); + return r; end + function setcheckbox(c); + begin + nc := c?true:false; + if nc<>fcheckbox then + begin + fcheckbox := nc; + InvalidateRect(nil,false); + end + end function SetMultisel(n); begin if n <> FMultisel and(n in array(0,1,2))then @@ -3736,6 +3763,7 @@ type TcustomListBox=class(TCustomListBoxbase) FSelEnd; FIsMouseDown; FMultisel; + fcheckbox; FMultisel3Data; FFormerSelBegin; FFormerSelEnd;