ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/journaling/ibcontrols/DBControlGrid.pas
(Generate patch)

Comparing ibx/trunk/ibcontrols/DBControlGrid.pas (file contents):
Revision 35 by tony, Tue Jan 26 14:38:47 2016 UTC vs.
Revision 217 by tony, Fri Mar 16 10:27:26 2018 UTC

# Line 1 | Line 1
1 +  
2   {
3   /***************************************************************************
4                                 DBControlGrid.pas
# Line 285 | Line 286 | end;
286  
287   implementation
288  
289 < uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue;
289 > uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue, EditBtn, MaskEdit;
290  
291   { TDBControlGridDataLink }
292  
# Line 300 | Line 301 | end;
301  
302   function TRowCache.Render(Control: TWinControl): TBitmap;
303   var Container: TBitmap;
303     Msg: TLMPaint;
304   begin
305    Container := TBitmap.Create;
306    try
# Line 366 | Line 366 | begin
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;
# Line 417 | Line 418 | begin
418   end;
419  
420   function TRowCache.Add2Cache(RecNo: Longint; Control: TWinControl): TBitmap;
420 var i: integer;
421   begin
422    Dec(RecNo); {Adust to zero base}
423    ExtendCache(RecNo + 1);
424    FList[RecNo].FState := rcPresent;
425 +  if FList[RecNo].FBitmap <> nil then
426 +    FList[RecNo].FBitmap.Free;
427    FList[RecNo].FBitmap := Render(Control);
428    Result := FList[RecNo].FBitmap;
429   end;
# Line 478 | Line 480 | begin
480    if FList[RecNo].FState = rcPresent then
481    begin
482      FList[RecNo].FBitmap.Free;
483 +    FList[RecNo].FBitmap := nil;
484      FList[RecNo].FState := rcEmpty;
485    end;
486   end;
# Line 594 | Line 597 | begin
597      and ValidDataSet and FDatalink.DataSet.CanModify;
598   end;
599  
597
600   procedure TDBControlGrid.DoDrawRow(aRow: integer; aRect: TRect;
601    aState: TGridDrawState);
602   var CachedRow: TBitmap;
# Line 607 | Line 609 | begin
609      begin
610        FCacheRefreshQueued := true;
611        Application.QueueAsyncCall(@DoMoveRecord,PtrInt(aRow));
612 <    end
612 >    end;
613 >    Canvas.FillRect(aRect);
614    end
615    else
616       Canvas.Draw(aRect.Left,aRect.Top,CachedRow)
# Line 672 | Line 675 | begin
675      if (AControl <> nil) and (AControl is TCustomMemo)
676                           and (Key in [VK_RETURN,VK_UP,VK_DOWN]) then Exit; {Ignore Return in a CustomMemo}
677  
678 +    if (AControl <> nil) and (AControl is TCustomGrid)
679 +                         and (Key in [VK_RETURN,VK_UP,VK_DOWN,VK_TAB]) then Exit; {Ignore Return in a CustomMemo}
680 +
681 +    if (AControl <> nil) and ((AControl is TDateEdit) or (AControl is TCustomMaskedit))
682 +                         and (Key in [VK_RETURN,VK_UP,VK_DOWN,
683 +                               VK_ESCAPE,VK_LEFT,VK_RIGHT]) then Exit; {Ignore Return in a CustomMemo}
684      Done := false;
685      if assigned(FOnKeyDownHander) then
686        OnKeyDownHander(Sender,Key,Shift,Done);
# Line 693 | Line 702 | begin
702        and (FModified or (FRowCache.IsEmpty(aDataSet.RecNo))) then
703    begin
704      RecNo := aDataSet.RecNo;
696    Application.ProcessMessages;  {A couple of trips round the message loop seems to be necessary}
705      Application.ProcessMessages;
706      if RecNo = aDataSet.RecNo then   {Guard against sudden changes}
707 <      FRowCache.Add2Cache(aDataSet.RecNo,FDrawPanel);
707 >      FRowCache.Add2Cache(RecNo,FDrawPanel);
708    end;
709   end;
710  
# Line 855 | Line 863 | end;
863  
864   procedure TDBControlGrid.SetupDrawPanel(aRow: integer);
865   begin
866 +  if FDrawPanel = nil then Exit;
867    if ValidDataSet and FRowCache.AlternateColor[FDataLink.DataSet.RecNo] then
868      FDrawPanel.Color := AlternateColor
869    else
# Line 1166 | Line 1175 | begin
1175      result := dsInactive;
1176   end;
1177  
1169 var
1170  DataCol: Integer;
1178   begin
1179    PrepareCanvas(aCol, aRow, aState);
1180  
1181    if aCol < FixedCols then
1182       DrawIndicator(Canvas,aRow, aRect,GetDataSetState,false)
1183    else
1184 <  if FDrawPanel = nil then
1185 <    DrawFillRect(Canvas,aRect)    else
1184 >  if (FDrawPanel = nil) or not FDataLink.Active then
1185 >    DrawFillRect(Canvas,aRect)
1186 >  else
1187    if not FDrawingActiveRecord and FDataLink.Active then
1188        DoDrawRow(aRow,aRect,aState);
1189    {if we are drawing the active record then this is rendered by the Draw Panel
# Line 1277 | Line 1285 | end;
1285   procedure TDBControlGrid.KeyDown(var Key: Word; Shift: TShiftState);
1286   type
1287    TOperation=(opMoveBy,opCancel,opAppend,opInsert,opDelete);
1280 var
1281  DeltaCol,DeltaRow: Integer;
1288  
1289    procedure DoOnKeyDown;
1290    begin
# Line 1680 | Line 1686 | begin
1686      FDataLink.Free;
1687    end;
1688    if assigned(FRowCache) then FRowCache.Free;
1689 +  Application.RemoveAsyncCalls(self);
1690    inherited Destroy;
1691   end;
1692  
# Line 1718 | Line 1725 | begin
1725   end;
1726  
1727   end.
1728 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines