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 31 by tony, Tue Jul 14 15:31:25 2015 UTC vs.
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC

# Line 285 | Line 285 | end;
285  
286   implementation
287  
288 < uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue;
288 > uses LCLType, Math, LCLIntf, Forms, LCLMessageGlue, EditBtn, MaskEdit;
289  
290   { TDBControlGridDataLink }
291  
# Line 300 | Line 300 | end;
300  
301   function TRowCache.Render(Control: TWinControl): TBitmap;
302   var Container: TBitmap;
303     Msg: TLMPaint;
303   begin
304    Container := TBitmap.Create;
305    try
# Line 366 | Line 365 | begin
365      for i := StartIndex to Length(FList) - 1 do
366      begin
367        FList[i].FState := rcEmpty;
368 +      FList[i].FBitmap := nil;
369        FList[i].FAlternateColor := altColor;
370        if UseAlternateColors then
371          altColor := not altColor;
# Line 413 | Line 413 | end;
413   procedure TRowCache.ClearCache;
414   begin
415    FreeImages(true);
416 +  SetLength(FList,0);
417   end;
418  
419   function TRowCache.Add2Cache(RecNo: Longint; Control: TWinControl): TBitmap;
# Line 421 | Line 422 | 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 477 | 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 540 | Line 544 | var
544   begin
545    OldFixedRows := FixedRows;
546    Clear;
547 +  FRowCache.ClearCache;
548    RowCount := OldFixedRows + 1;
549    if dgpIndicator in FOptions then
550      ColWidths[0]:=12;
# Line 592 | Line 597 | begin
597      and ValidDataSet and FDatalink.DataSet.CanModify;
598   end;
599  
595
600   procedure TDBControlGrid.DoDrawRow(aRow: integer; aRect: TRect;
601    aState: TGridDrawState);
602   var CachedRow: TBitmap;
# Line 620 | Line 624 | begin
624    aRow := integer(Data);
625    FInCacheRefresh := true;
626    if assigned(FDataLink.DataSet) then
627 <    FDatalink.DataSet.MoveBy(aRow - FDrawRow)
627 >    FDatalink.DataSet.MoveBy(aRow - FDrawRow);
628   end;
629  
630   procedure TDBControlGrid.DoSetupDrawPanel(Data: PtrInt);
# Line 668 | Line 672 | begin
672        Exit; {ignore these keys if we are in a  combobox}
673  
674      if (AControl <> nil) and (AControl is TCustomMemo)
675 <                         and (Key = VK_RETURN) then Exit; {Ignore Return in a CustomMemo}
675 >                         and (Key in [VK_RETURN,VK_UP,VK_DOWN]) then Exit; {Ignore Return in a CustomMemo}
676 >
677 >    if (AControl <> nil) and (AControl is TCustomGrid)
678 >                         and (Key in [VK_RETURN,VK_UP,VK_DOWN,VK_TAB]) then Exit; {Ignore Return in a CustomMemo}
679  
680 +    if (AControl <> nil) and ((AControl is TDateEdit) or (AControl is TCustomMaskedit))
681 +                         and (Key in [VK_RETURN,VK_UP,VK_DOWN,
682 +                               VK_ESCAPE,VK_LEFT,VK_RIGHT]) then Exit; {Ignore Return in a CustomMemo}
683      Done := false;
684      if assigned(FOnKeyDownHander) then
685        OnKeyDownHander(Sender,Key,Shift,Done);
# Line 691 | Line 701 | begin
701        and (FModified or (FRowCache.IsEmpty(aDataSet.RecNo))) then
702    begin
703      RecNo := aDataSet.RecNo;
694    Application.ProcessMessages;  {A couple of trips round the message loop seems to be necessary}
704      Application.ProcessMessages;
705      if RecNo = aDataSet.RecNo then   {Guard against sudden changes}
706 <      FRowCache.Add2Cache(aDataSet.RecNo,FDrawPanel);
706 >      FRowCache.Add2Cache(RecNo,FDrawPanel);
707    end;
708   end;
709  
710   procedure TDBControlGrid.OnDataSetChanged(aDataSet: TDataSet);
711   begin
712 <  if (aDataSet.State = dsBrowse) and (FLastRecordCount >  GetRecordCount) then
712 >  if aDataSet.State = dsBrowse then
713    begin
714 <    {must be delete}
715 <    FRowCache.MarkAsDeleted(FSelectedRecNo);
716 <    Dec(FSelectedRow);
714 >    if GetRecordCount = 0 then
715 >    begin
716 >      {Must be closed/reopened}
717 >      FRowCache.ClearCache;
718 >      FSelectedRow := 0;
719 >    end
720 >    else
721 >    if FLastRecordCount >  GetRecordCount then
722 >    begin
723 >      {must be delete}
724 >      FRowCache.MarkAsDeleted(FSelectedRecNo);
725 >      Dec(FSelectedRow);
726 >    end;
727      LayoutChanged;
728    end;
729    FLastRecordCount := GetRecordCount;
# Line 843 | Line 862 | end;
862  
863   procedure TDBControlGrid.SetupDrawPanel(aRow: integer);
864   begin
865 +  if FDrawPanel = nil then Exit;
866    if ValidDataSet and FRowCache.AlternateColor[FDataLink.DataSet.RecNo] then
867      FDrawPanel.Color := AlternateColor
868    else
# Line 1162 | Line 1182 | begin
1182    if aCol < FixedCols then
1183       DrawIndicator(Canvas,aRow, aRect,GetDataSetState,false)
1184    else
1185 <  if FDrawPanel = nil then
1186 <    DrawFillRect(Canvas,aRect)    else
1185 >  if (FDrawPanel = nil) or not FDataLink.Active then
1186 >    DrawFillRect(Canvas,aRect)
1187 >  else
1188    if not FDrawingActiveRecord and FDataLink.Active then
1189        DoDrawRow(aRow,aRect,aState);
1190    {if we are drawing the active record then this is rendered by the Draw Panel
# Line 1409 | Line 1430 | begin
1430      FInCacheRefresh := false;
1431      FCacheRefreshQueued := false;
1432      Row := FixedRows;
1433 +    FDrawingActiveRecord := false;
1434 +    FSelectedRecNo := 0;
1435 +    FSelectedRow := 0;
1436 +    FRequiredRecNo := 0;
1437    end;
1438    FRowCache.UseAlternateColors := AlternateColor <> Color;
1439    FRowCache.AltColorStartNormal := AltColorStartNormal;
# Line 1702 | Line 1727 | begin
1727   end;
1728  
1729   end.
1730 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines