Recent

Author Topic: GTK2 Pen.Style hardly supported?  (Read 4317 times)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
GTK2 Pen.Style hardly supported?
« 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?

soerensen3

  • Full Member
  • ***
  • Posts: 213
Re: GTK2 Pen.Style hardly supported?
« Reply #1 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.  
Lazarus 1.9 with FPC 3.0.4
Target: Manjaro Linux 64 Bit (4.9.68-1-MANJARO)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: GTK2 Pen.Style hardly supported?
« Reply #2 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.
« Last Edit: November 14, 2017, 02:47:37 am by Mike.Cornflake »
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

 

TinyPortal © 2005-2018