Lazarus

Programming => Widgetset => GTK => Topic started by: howardpc on November 13, 2017, 10:52:02 pm

Title: GTK2 Pen.Style hardly supported?
Post by: howardpc on November 13, 2017, 10:52:02 pm
Trying to use Canvas.Pen.Style:=psDot on GTK2 has no apparent effect.
Is this a widgetset limitation, or is it just that on GTK2 no pen styles have been implemented apart from psSolid and psClear?
Title: Re: GTK2 Pen.Style hardly supported?
Post by: soerensen3 on November 13, 2017, 11:44:32 pm
For me this is working on Linux:

Code: Pascal  [Select][+][-]
  1. ...
  2. procedure TForm1.FormPaint(Sender: TObject);
  3. begin
  4.   Canvas.Pen.Style:= psDash;
  5.   Canvas.Pen.Width:= 5;
  6.   Canvas.Line( 0, 0, 100, 100 );
  7. end;
  8. ...  
  9.  
Title: Re: GTK2 Pen.Style hardly supported?
Post by: Mike.Cornflake on November 14, 2017, 02:44:37 am
Trying to use Canvas.Pen.Style:=psDot on GTK2 has no apparent effect.
Is this a widgetset limitation, or is it just that on GTK2 no pen styles have been implemented apart from psSolid and psClear?

Ug :-)   Using Mark I eyeballs only (ie no debugger), it looks to me like multiple pen styles are supported.  Or at least, it looks to me like they *should* be supported. Inside Gtk2DeviceContext.inc, TGtkDeviceContext.SelectPenProps for instance there is this code:
Code: [Select]
  // Paul Ishenin: I compared patterns with windows
  case PenStyle of
    PS_DASH:       SetDashes([3,1]);
    PS_DOT:        SetDashes([1,1]);
    PS_DASHDOT:    SetDashes([3,1,1,1]);
    PS_DASHDOTDOT: SetDashes([3,1,1,1,1,1]);
    PS_USERSTYLE:  laz_gdk_gc_set_dashes(GC, 0, CurrentPen^.GDIPenDashes, CurrentPen^.GDIPenDashesCount);
  end; 

This and @soerensen3's code (where he checked a different pen style, but still got an expected result) makes me think you could be staring at a bug.
TinyPortal © 2005-2018