1 |
+ |
|
2 |
|
{ |
3 |
|
/*************************************************************************** |
4 |
|
DBControlGrid.pas |
286 |
|
|
287 |
|
implementation |
288 |
|
|
289 |
< |
uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue; |
289 |
> |
uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue, EditBtn, MaskEdit; |
290 |
|
|
291 |
|
{ TDBControlGridDataLink } |
292 |
|
|
301 |
|
|
302 |
|
function TRowCache.Render(Control: TWinControl): TBitmap; |
303 |
|
var Container: TBitmap; |
303 |
– |
Msg: TLMPaint; |
304 |
|
begin |
305 |
|
Container := TBitmap.Create; |
306 |
|
try |
366 |
|
for i := StartIndex to Length(FList) - 1 do |
367 |
|
begin |
368 |
|
FList[i].FState := rcEmpty; |
369 |
+ |
FList[i].FBitmap := nil; |
370 |
|
FList[i].FAlternateColor := altColor; |
371 |
|
if UseAlternateColors then |
372 |
|
altColor := not altColor; |
423 |
|
Dec(RecNo); {Adust to zero base} |
424 |
|
ExtendCache(RecNo + 1); |
425 |
|
FList[RecNo].FState := rcPresent; |
426 |
+ |
if FList[RecNo].FBitmap <> nil then |
427 |
+ |
FList[RecNo].FBitmap.Free; |
428 |
|
FList[RecNo].FBitmap := Render(Control); |
429 |
|
Result := FList[RecNo].FBitmap; |
430 |
|
end; |
481 |
|
if FList[RecNo].FState = rcPresent then |
482 |
|
begin |
483 |
|
FList[RecNo].FBitmap.Free; |
484 |
+ |
FList[RecNo].FBitmap := nil; |
485 |
|
FList[RecNo].FState := rcEmpty; |
486 |
|
end; |
487 |
|
end; |
598 |
|
and ValidDataSet and FDatalink.DataSet.CanModify; |
599 |
|
end; |
600 |
|
|
597 |
– |
|
601 |
|
procedure TDBControlGrid.DoDrawRow(aRow: integer; aRect: TRect; |
602 |
|
aState: TGridDrawState); |
603 |
|
var CachedRow: TBitmap; |
610 |
|
begin |
611 |
|
FCacheRefreshQueued := true; |
612 |
|
Application.QueueAsyncCall(@DoMoveRecord,PtrInt(aRow)); |
613 |
< |
end |
613 |
> |
end; |
614 |
> |
Canvas.FillRect(aRect); |
615 |
|
end |
616 |
|
else |
617 |
|
Canvas.Draw(aRect.Left,aRect.Top,CachedRow) |
676 |
|
if (AControl <> nil) and (AControl is TCustomMemo) |
677 |
|
and (Key in [VK_RETURN,VK_UP,VK_DOWN]) then Exit; {Ignore Return in a CustomMemo} |
678 |
|
|
679 |
+ |
if (AControl <> nil) and (AControl is TCustomGrid) |
680 |
+ |
and (Key in [VK_RETURN,VK_UP,VK_DOWN,VK_TAB]) then Exit; {Ignore Return in a CustomMemo} |
681 |
+ |
|
682 |
+ |
if (AControl <> nil) and ((AControl is TDateEdit) or (AControl is TCustomMaskedit)) |
683 |
+ |
and (Key in [VK_RETURN,VK_UP,VK_DOWN, |
684 |
+ |
VK_ESCAPE,VK_LEFT,VK_RIGHT]) then Exit; {Ignore Return in a CustomMemo} |
685 |
|
Done := false; |
686 |
|
if assigned(FOnKeyDownHander) then |
687 |
|
OnKeyDownHander(Sender,Key,Shift,Done); |
703 |
|
and (FModified or (FRowCache.IsEmpty(aDataSet.RecNo))) then |
704 |
|
begin |
705 |
|
RecNo := aDataSet.RecNo; |
696 |
– |
Application.ProcessMessages; {A couple of trips round the message loop seems to be necessary} |
706 |
|
Application.ProcessMessages; |
707 |
|
if RecNo = aDataSet.RecNo then {Guard against sudden changes} |
708 |
< |
FRowCache.Add2Cache(aDataSet.RecNo,FDrawPanel); |
708 |
> |
FRowCache.Add2Cache(RecNo,FDrawPanel); |
709 |
|
end; |
710 |
|
end; |
711 |
|
|
864 |
|
|
865 |
|
procedure TDBControlGrid.SetupDrawPanel(aRow: integer); |
866 |
|
begin |
867 |
+ |
if FDrawPanel = nil then Exit; |
868 |
|
if ValidDataSet and FRowCache.AlternateColor[FDataLink.DataSet.RecNo] then |
869 |
|
FDrawPanel.Color := AlternateColor |
870 |
|
else |
1184 |
|
if aCol < FixedCols then |
1185 |
|
DrawIndicator(Canvas,aRow, aRect,GetDataSetState,false) |
1186 |
|
else |
1187 |
< |
if FDrawPanel = nil then |
1188 |
< |
DrawFillRect(Canvas,aRect) else |
1187 |
> |
if (FDrawPanel = nil) or not FDataLink.Active then |
1188 |
> |
DrawFillRect(Canvas,aRect) |
1189 |
> |
else |
1190 |
|
if not FDrawingActiveRecord and FDataLink.Active then |
1191 |
|
DoDrawRow(aRow,aRect,aState); |
1192 |
|
{if we are drawing the active record then this is rendered by the Draw Panel |
1691 |
|
FDataLink.Free; |
1692 |
|
end; |
1693 |
|
if assigned(FRowCache) then FRowCache.Free; |
1694 |
+ |
Application.RemoveAsyncCalls(self); |
1695 |
|
inherited Destroy; |
1696 |
|
end; |
1697 |
|
|
1730 |
|
end; |
1731 |
|
|
1732 |
|
end. |
1733 |
+ |
|