Commit 0d6c30d8 authored by Martin Schreiber's avatar Martin Schreiber

+ Autosize support for tcustomgrid.

+ dragoptionty(do_nocursorshape).
+ tdrawgrid cell drag events.
parent f50451cc
......@@ -72,7 +72,7 @@ type
// expiretime: longword;
end;
dragoptionty = (do_child);
dragoptionty = (do_child,do_nocursorshape);
dragoptionsty = set of dragoptionty;
tcustomdragcontroller = class(tlinkedpersistent,ievent)
......@@ -231,7 +231,9 @@ begin
end;
end;
if ds_haddragobject in fstate then begin
application.cursorshape:= cr_default;
if not (do_nocursorshape in foptions) then begin
application.cursorshape:= cr_default;
end;
end;
application.unregisteronkeypress(@dokeypress);
fstate:= fstate - dragstates;
......@@ -363,12 +365,16 @@ begin
tdragobject1(fdragobject).feventintf:= ievent(self);
include(info.eventstate,es_processed);
if checkcandragdrop(info.pos,bo1) <> nil then begin
application.cursorshape:= cr_drag;
if not (do_nocursorshape in foptions) then begin
application.cursorshape:= cr_drag;
end;
fdragobject.acepted(translateclientpoint(info.pos,owner,nil));
end
else begin
if not bo1 then begin
application.cursorshape:= cr_forbidden;
if not (do_nocursorshape in foptions) then begin
application.cursorshape:= cr_forbidden;
end;
fdragobject.refused(translateclientpoint(info.pos,owner,nil));
end;
end;
......@@ -411,11 +417,13 @@ begin
if (fdragobject <> nil) and (aevent is tsysdndstatusevent) then begin
with tsysdndstatusevent(aevent) do begin
if ds_beginchecked in fstate then begin
if accept then begin
application.cursorshape:= cr_drag;
end
else begin
application.cursorshape:= cr_forbidden;
if not (do_nocursorshape in foptions) then begin
if accept then begin
application.cursorshape:= cr_drag;
end
else begin
application.cursorshape:= cr_forbidden;
end;
end;
end;
end;
......
......@@ -74,8 +74,10 @@ constructor tdragobject.create(const asender: tobject; var instance: tdragobject
begin
fsender:= asender;
finstancepo:= @instance;
instance.Free;
instance:= self;
if finstancepo <> nil then begin
instance.Free;
instance:= self;
end;
fpickpos:= apickpos;
factions:= aactions;
tguiapplication1(application).dragstarted;
......
......@@ -64,6 +64,7 @@ type
coloptions1ty = set of coloption1ty;
const
gridautosizetag = 86375927;
deprecatedcoloptions = [{co_rowfont,co_rowcolor,co_zebracolor,
co_rowcoloractive}];
invisiblecoloptions = [{ord(co_rowfont),ord(co_rowcolor),ord(co_zebracolor),
......@@ -240,6 +241,7 @@ type
gs1_sortmoving,gs1_sortchangelock,gs1_rowinserted,
gs1_gridsorted,gs1_dbsorted,gs1_customsort,
gs1_rowdeleting,gs1_autoappending,gs1_autoremoving,
gs1_autosizepending,
gs1_focuscellonenterlock,gs1_mousecaptureendlock,
gs1_forcenullcheck,
gs1_cellsizesyncing,gs1_userinput,gs1_autoappendlock,
......@@ -762,15 +764,34 @@ type
datacolaty = array[0..0] of tdatacol;
pdatacolaty = ^datacolaty;
tcelldragobject = class(tdragobject)
public
constructor create(const draginfo: draginfoty; const cellinfo: cellinfoty);
end;
celldrageventty = procedure(const cellinfo: cellinfoty;
var draginfo: draginfoty; var dragobject: tcelldragobject;
var accept: boolean; var processed: boolean) of object;
tdrawcol = class(tdatacol)
private
fondrawcell: drawcelleventty;
fonbeforedragevent: celldrageventty;
fonafterdragevent: celldrageventty;
protected
procedure drawcell(const canvas: tcanvas); override;
procedure beforedragevent(var ainfo: draginfoty; const arow: integer;
var processed: boolean) override;
procedure afterdragevent(var ainfo: draginfoty; const arow: integer;
var processed: boolean) override;
published
property focusrectdist;
property ondrawcell: drawcelleventty read fondrawcell write fondrawcell;
property onbeforedragevent: celldrageventty read fonbeforedragevent
write fonbeforedragevent;
property onafterdragevent: celldrageventty read fonafterdragevent
write fonafterdragevent;
property font;
end;
......@@ -2164,12 +2185,14 @@ type
procedure objectevent(const sender: tobject;
const event: objecteventty); override;
procedure doasyncevent(var atag: integer) override;
procedure loaded; override;
procedure doexit; override;
procedure doenter; override;
procedure doactivate; override;
procedure dodeactivate; override;
procedure activechanged; override;
procedure getautopaintsize(var asize: sizety) override;
procedure mouseevent(var info: mouseeventinfoty); override;
procedure clientmouseevent(var info: mouseeventinfoty); override;
procedure domousewheelevent(var info: mousewheeleventinfoty); override;
......@@ -5798,18 +5821,6 @@ begin
ftotsize:= ftotsize + int2;
end
else begin //datacols
{
for int1:= count - 1 downto count - foppositecount do begin
with tgridprop(fitems[int1]) do begin
fend:= int3;
dec(int3,step);
inc(int2,step);
fstart:= int3;
end;
end;
ftotsize:= int2;
int2:= 0;
}
with tdatacols(self) do begin
int2:= 0;
fscrollsize:= 0;
......@@ -6980,6 +6991,32 @@ begin
end;
end;
procedure tdrawcol.beforedragevent(var ainfo: draginfoty; const arow: integer;
var processed: boolean);
begin
if not processed and assigned(fonbeforedragevent) then begin
fcellinfo.cell.row:= arow;
fonbeforedragevent(fcellinfo,ainfo,tcelldragobject(ainfo.dragobjectpo^),
ainfo.accept,processed);
end;
if not processed then begin
inherited;
end;
end;
procedure tdrawcol.afterdragevent(var ainfo: draginfoty; const arow: integer;
var processed: boolean);
begin
if not processed and assigned(fonafterdragevent) then begin
fcellinfo.cell.row:= arow;
fonafterdragevent(fcellinfo,ainfo,tcelldragobject(ainfo.dragobjectpo^),
ainfo.accept,processed);
end;
if not processed then begin
inherited;
end;
end;
{ tstringcoldatalist }
constructor tstringcoldatalist.create(const agrid: tcustomgrid);
......@@ -13878,6 +13915,37 @@ begin
end;
end;
procedure tcustomgrid.doasyncevent(var atag: integer);
begin
if atag = gridautosizetag then begin
exclude(fstate1,gs1_autosizepending);
checkautosize();
designchanged;
end
else begin
inherited;
end;
end;
procedure tcustomgrid.getautopaintsize(var asize: sizety);
begin
if foptionswidget1 * [ow1_autowidth,ow1_autoheight] = [] then begin
inherited;
end
else begin
if fstate*[gs_updatelocked,gs_layoutupdating] <> [] then begin
if not (gs1_autosizepending in fstate1) then begin
include(fstate1,gs1_autosizepending);
asyncevent(gridautosizetag,[peo_local]);
end;
end
else begin
asize:= calcminscrollsize();
end;
inherited;
end;
end;
procedure tcustomgrid.getpickobjects(const sender: tobjectpicker;
var objects: integerarty);
var
......@@ -19319,5 +19387,13 @@ begin
optionsgrid:= optionsgrid + newcomponentoptionsgridadd;
end;
{ tcelldragobject }
constructor tcelldragobject.create(const draginfo: draginfoty;
const cellinfo: cellinfoty);
begin
inherited create(cellinfo.grid,draginfo.dragobjectpo^,draginfo.pickpos);
end;
end.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment