Jump to content

Vandrovnik

Members
  • Content Count

    523
  • Joined

  • Last visited

  • Days Won

    6

Posts posted by Vandrovnik


  1. Bitmap1.ScanLine[Bitmap1.Height-1] is start of the image buffer (raw image data, it is bottom up).

    Buffer size is not so easy; in VCL.Graphics, they have this function (Alignment=32; you need to multiply its result by Bitmap1.Height; look at TBitmap.GetScanLine in VCL.Graphics).

    function BytesPerScanline(PixelsPerScanline, BitsPerPixel, Alignment: Longint): Longint;
    begin
      Dec(Alignment);
      Result := ((PixelsPerScanline * BitsPerPixel) + Alignment) and not Alignment;
      Result := Result div 8;
    end;

     


  2. Hello,

     

    I wanted to call tDictionary<>.SetCapacity prior to adding items to it, so that there is no need to re-hash items. Unfortunatelly, tDictionary<>.SetCapacity is private member. Why? Is it an intention, or a bug? Probably there is a way how to access even a private method...?

     

    Kind regards,

     

    Karel

     


  3. When you are up-to-date with Delphi, it is easier to accomodate the software to new demands (such as was UTF or HDPI in the past, may be 64 bit in the future - hard to say how many years 32bit apps will be supported, new encryptions etc).

     

    Move software to another language will cost a lot of money and time (and new bugs and old features missing in the beginning).

    • Like 1

  4. So, partial solution... Works with field names (does not depend on headers), works when columns are moved. Works, when data is reloaded from database. But does not keep column width, when user changes the width in runtime (I did not find any event for column width change).

     

    // defined as private member in form:
    grZasobaLink: TLinkGridToDataSource;
    
    // I do not know how to obtain BindingsList directly from the StringGrid, so I am passing it as param
    function GetLinkToDataSource(aBindingsList: tBindingsList;
             aGrid: tStringGrid): TLinkGridToDataSource;
     var a: integer;
         BindComponent: tContainedBindComponent;
     begin
     result:=nil;
     if (aBindingsList=nil)or(aGrid=nil) then exit;
     for a:=0 to aBindingsList.BindCompCount-1 do begin
      BindComponent:=aBindingsList.BindComps[a];
      if (BindComponent.ControlComponent=aGrid)and(BindComponent is tLinkGridToDatasource) then begin
       result:=tLinkGridToDatasource(BindComponent);
       exit;
      end;
     end;
    end;
    
    // keep the link, since I will need it often
    procedure TZasobaForm.FormCreate(Sender: TObject);
     ...
     grZasobaLink:=GetLinkToDataSource(BindingsList1, grZasoba);
    end;
    
    procedure TZasobaForm.grZasobaDrawColumnCell(Sender: TObject;
              const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF;
              const Row: Integer; const Value: TValue; const State: TGridDrawStates);
     var FieldName: string;
     begin
     Canvas.Font.Size:=grZasoba.TextSettings.Font.Size;
     if Assigned(grZasobaLink)
      then FieldName:=UpperCase(grZasobaLink.Columns[Column.Index].MemberName) // Field name! :-)
      else FieldName:='';
     if (FieldName='FYZICKA') then begin
      Canvas.Font.Style:=[tFontStyle.fsBold];
     end;
     Canvas.Fill.Color:=TAlphaColorRec.Black;
     Canvas.FillText(Bounds, (Value.AsString), false, 1, [], TTextAlign.Leading, TTextAlign.Center);
    end;
    
    // handle column move
    procedure TZasobaForm.grZasobaColumnMoved(Column: TColumn;
              FromIndex, ToIndex: Integer);
     begin
     if Assigned(grZasobaLink) then grZasobaLink.Columns[FromIndex].Index:=ToIndex;
    end;
    

     


  5. I suppose this information already is stored somewhere, so I would like to find it and use it. I cannot rely on the header, but of course I could use tag, build my own list or something like that.

     

    It seems that this connection between tStringGrid and data is also partly broken - well, in runtime I can move columns and set their width with mouse, but when the grid is filled again, order and width of columns are lost (this happens in my case when user selects another master record - data for details in the grid has to reload from database, columns where supposed to keep their position and width).


  6. 51 minutes ago, dummzeuch said:

    You must keep in mind that Embarcadero only occasionally syncs the public jira with their internal one. Usually just before a new release lots of entries get closed. Unfortunately that does not always mean that they have been fixed.

    I know, but from these graphs it is still pretty well visible, that issues stay in the queue/stack/whatever longer and longer and that new issues come faster then old issues are resolved. 800 days and increasing, that is a terrible value.

     

    I understand they they want to keep up to date with new Android, new iOS etc., but still I believe that they should have a team, which will resolve reported bugs.


  7. 8 minutes ago, FredS said:

     

    There are of course other things to consider. Bugs converted to Feature Requests, and then there is that Dark Pool of internal Bugs that get resolved by the hundreds..

     

    I know... And bugs resolved as "will not repair" (ie Translation Manager), bugs marked as duplicate... But the tendency in the graph is the same as my internal feeling in last years.


  8. 3 hours ago, Anders Melander said:

    3) People assuming they know how and why Embarcadero prioritize as they do.

     

    It's easy to sit here and bitch about this and that, when you're not the one responsible for these things. IMO it's just noise.

    May be Embarcadero could explain how they decide what to do and what to postpone... and postpone...? Because when I compare Embarcadero with TMS or Fastreport (or you), it is often reaction several years vs. several days, which I really do not like. Even https://quality.embarcadero.com/browse/RSP-24548, which should take +- 2 minutes to repair, will probably be there open for years. And please do not argument that it will take much more time because of testing, because the "testing" I can see each day in Object Inspector, which is not showing last letters in text (reported more than a year ago, but did they notice by themselves when testing?), and in Projects (which stops to show its content in 10.3.3 sometimes), and in Toolbars, which are moved randomly each day...

     

    I would like to see a statistic, how reported and solved issues develop over years. May be it is somewhere on the web, I do not know.


  9. Hello,

     

    I have a tStringGrid linked to tIBQuery. In tStringGrid.OnDrawColumnCell, I would like to change font color or style in dependence of data in that column.

    Now I am able to do something like this:

    procedure TZasobaForm.grZasobaDrawColumnCell(Sender: TObject;
              const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF;
              const Row: Integer; const Value: TValue; const State: TGridDrawStates);
     begin
     Canvas.Font.Size:=grZasoba.TextSettings.Font.Size;
     if (Column<>nil)and(Column.Index=1) then begin
      Canvas.Font.Style:=[tFontStyle.fsBold];
     end;
     Canvas.Fill.Color:=TAlphaColorRec.Black;
     Canvas.FillText(Bounds, (Value.AsString), false, 1, [], TTextAlign.taLeading, TTextAlign.taCenter);
    end;

    But instead of using if Column.Index=..., I would like to use something like if Column.DataField='PRICE'... How can I obtain field name for the Column? Columns can be moved on runtime, so I cannot expect that Price is always second column in the grid.

    In .fmx, there is:

             object grZasoba: TStringGrid
                Align = Client
                CanFocus = True
                ClipChildren = True
                Size.Width = 391.000000000000000000
                Size.Height = 208.000000000000000000
                Size.PlatformDefault = False
                TextSettings.Trimming = None
                StyledSettings = [Family, Style, FontColor]
                TabOrder = 1
                RowCount = 0
                Options = [ColumnResize, ColumnMove, ColLines, RowLines, RowSelect, AlwaysShowSelection, Tabs, Header, HeaderClick]
                DefaultDrawing = False
                OnDrawColumnCell = grZasobaDrawColumnCell
                Viewport.Width = 387.000000000000000000
                Viewport.Height = 183.000000000000000000
              end
    
      object BindSourceZasoba: TBindSourceDB
        DataSet = qZasoba
        ScopeMappings = <>
        Left = 88
        Top = 240
      end
    
      object BindingsList1: TBindingsList
        Methods = <>
        OutputConverters = <>
        Left = 20
        Top = 5
        object LinkGridToDataSourceBindSourceDB12: TLinkGridToDataSource
          Category = 'Quick Bindings'
          DataSource = BindSourceZasoba
          GridControl = grZasoba
          Columns = <
            item
              MemberName = 'PRICE'
              Width = 40
            end
            ...

     

    Kind regards,

     

    Karel

     

     

     

     


  10. uses Direct2D;
    
    procedure TMainForm.PaintBox1Paint(Sender: TObject);
     var D2Canvas: TDirect2DCanvas;
     begin
     D2Canvas:=TDirect2DCanvas.Create(PaintBox1.Canvas, PaintBox1.ClientRect);
     try
      D2Canvas.BeginDraw;
      try
       D2Canvas.Brush.Style:=bsSolid;
       D2Canvas.Brush.Color:=clFuchsia;
       D2Canvas.FillRect(PaintBox1.ClientRect);
       D2Canvas.Font.Size:=32;
       D2Canvas.Font.Color:=clBlack;
       D2Canvas.TextOut(100, 100, 'Delphi 25th');
      finally
       D2Canvas.EndDraw;
      end;
     finally
      FreeAndNil(D2Canvas);
     end;
    end;

    This is not OK?

    d2d.png


  11. 2 hours ago, Steve Maughan said:

    Hi Vandrovnik — I'm aware of the basics of Difect2D, but how could I merge two Direct2D canvases and preserve the anti-aliasing of the text? If I'm not mistaken this isn't easy using Direct2D (but I'm far from being an expert on this).

     

    Thanks again, Steve

    Hello, as David already wrote - just render the text on the map, there is no need to render it to a bitmap and then merge bitmaps.

    Do you need to print the result? Because that was a pain with Direct2D and Delphi 😕

×