Re: [Lazarus] Examples of CairoCanvas usage

2015-02-10 Thread Petr Kristan
On Tue, Feb 10, 2015 at 10:43:34AM +0200, Juha Manninen wrote:
 On Tue, Feb 10, 2015 at 9:14 AM, Petr Kristan petr.kris...@epos.cz wrote:
  My commandline program version must be linked with gtk in linux.
  I use this construction:
 
  WidgetSet := TGtk2WidgetSet.Create;
  DrawingRoutine;
  FreeAndNil(WidgetSet);
 
 How to use the WidgetSet?
 Can you please test with TextOut(), and maybe send a simple example
 program or application. I still have not found any.
 I would be happy to add an example directory below
 components\cairocanvas if you want.

Here is an linux working example:

{$mode objfpc}{$H+}
uses
  Classes, SysUtils, Gtk2Int, InterfaceBase, CairoCanvas,
GdkCairoCanvas, Printers;
var
  c: TFilePrinterCanvas;
begin
  WidgetSet := TGtk2WidgetSet.Create;
  c := TCairoPdfCanvas.Create(nil);
  c.OutputFileName := '/tmp/a.pdf';
  c.XDPI := 75;
  c.YDPI := 75;
  c.PaperWidth := 100;
  c.PaperHeight := 100;
  c.Font.Name := 'Arial';
  c.Font.Height := 12;
  c.TextOut(0, 0, 'Hello word');
  FreeAndNil(c);
  FreeAndNil(WidgetSet);
end.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Examples of CairoCanvas usage

2015-02-10 Thread Petr Kristan
On Tue, Feb 10, 2015 at 03:53:16PM +0200, Juha Manninen wrote:
 On Tue, Feb 10, 2015 at 11:40 AM, Petr Kristan petr.kris...@epos.cz wrote:
c.Font.Name := 'Arial';
c.Font.Height := 12;
 
 Wow, my test code only needed the font definition, then it works.
 My bad, I should have tested that. Normal GUI canvas has some font by default.
 I added a simple program to components/cairocanvas/example which draws
 an ellipse and text.
 You can improve it if you want and send a patch.
 
 Your example adds a dependency for GTK2. It is logically wrong if you
 only want to demonstrate CairoCanvas.
 My understanding is that GTK2 depends on CairoCanvas, not the other way 
 around.
 What is the purpose of the WidgetSet variable? You create it but don't
 use it for anything. My prog works without it now that it has a font
 defined. The only dependency in the uses section of my program is
 CairoCanvas.
It is about two years when I used this last time. And it was neded.
It is good to hear, that I can remove this dependency.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Examples of CairoCanvas usage

2015-02-09 Thread Petr Kristan
On Mon, Feb 09, 2015 at 09:19:46PM +0200, Juha Manninen wrote:
 On Linux it does not throw an exception but it does not work either.
 There is no text.
 I tested other CairoCanvas variants, PS and PNG, and they behave the same.
 The code is in ancestor TCairoPrinterCanvas.TextOut.
 
 Has anybody tried text output with CairoCanvas? Maybe it only works
 with graphics.
I normaly use it with graphics.

My commandline program version must be linked with gtk in linux.
I use this construction:

WidgetSet := TGtk2WidgetSet.Create;
DrawingRoutine;
FreeAndNil(WidgetSet);

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Examples of CairoCanvas usage

2015-02-02 Thread Petr Kristan
On Tue, Feb 03, 2015 at 02:01:27AM +0200, Juha Manninen wrote:
 Does anybody have examples for the package CairoCanvas_pkg that comes
 with Lazarus?
 The package dir has none.
 
 I am most interested in textual data + PDF, thus TCairoPdfCanvas and
 TCairoPsCanvas, but other examples are welcome, too.
TCairoCanvas works as clasic TCanvas.

You can create TCairo*Canvas of your choice, set some specific properties as
OutputFileName, XDPI, YDPI, PaperWidth, PaperHeight, Orientation
and draw on it like on normal TCanvas.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Memo - scroll to caret position

2014-06-17 Thread Petr Kristan
Hi.

I set Memo.CaretPos and I want to scroll memo to be caret visible.

I found some solution in windows:
Perform(EM_SCROLLCARET, 0, 0);

But how to solve it in Linux and GTK2?

I tried:
Memo.VertScrollBar.Position := 
Round(Line*Memo.VertScrollBar.Range/Memo.Lines.Count);
but this scrolls only with ScrollBar and not with memo.

Thanks
Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Custom GraphicsControl - need Canvas to set Height outside OnPaint

2014-04-07 Thread Petr Kristan
Hi.

I'am creating an graphics control and I need Canvas to set control
Height. But I can draw (access to Canvas) only in OnPaint event.

How to solve this problem?

Thanks
Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Custom GraphicsControl - need Canvas to set Height outside OnPaint

2014-04-07 Thread Petr Kristan
On Mon, Apr 07, 2014 at 11:11:28AM +0200, zeljko wrote:
 On 04/07/2014 11:01 AM, Petr Kristan wrote:
 Hi.
 
 I'am creating an graphics control and I need Canvas to set control
 Height. But I can draw (access to Canvas) only in OnPaint event.
 
 How to solve this problem?
 
 You need to set height of control by calculating text height out of
 paint event ?  I'm using TBitmap for such measurements.
 Create bitmap, assign control font to bmp canvas, measure.

Tanks for fast helpfull responses.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Optimize DBGrid speed

2014-01-08 Thread Petr Kristan
On Mon, Jan 06, 2014 at 03:21:56PM +0200, Juha Manninen wrote:
 On Mon, Jan 6, 2014 at 2:29 PM, Petr Kristan petr.kris...@epos.cz wrote:
  I'am trying to minimize whole DBGrid redraw. Where I can discuss my
  steps to avoid my pointless work.
 
  Most of code what I plan to change was commited by jesus.
 
 The choices are this list or private mails with Jesus (jesus...@gmail.com).
 It depends on how interesting the discussion is for other people.
 (See the related thread about private communication :)
 
 You should send a private mail in any case because he may not notice this.
I tried it, but no response till now.

Then I try try send another question about grid speed opt. here.

In the beginning of Grid paint is Canvas.GetClipRect called to obtain area
which wee must redraw. This function directly calls WidgetSet.GetClipBox.
I find out difference betwen Win32 and gtk2 bahaviour of this func.

In gtk2 TGtk2WidgetSet.GetClipBox returns previously Invalidated area
(through DC.PaintRectangle = PS.rcPaint retrieved in BeginPaint)

But in win32 directly calls Windows.GetClipBox, but this func returns
whole grid area. Do not takes account on invalidated area retrieved in
BeginPaint.

Result of this difference is whole grid redraw in windows, even if only
one cell is invalidated.

Question si how to correct this?
Modify TWin32WidgetSet.GetClipBox to behave as TGtk2WidgetSet.GetClipBox?
I'am not sure, because GetClipBox should probably correspond to Win32
documentation.
How is this solved in another widgetsets?

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Optimize DBGrid speed

2014-01-08 Thread Petr Kristan
On Wed, Jan 08, 2014 at 02:35:08PM +0100, Hans-Peter Diettrich wrote:
 Petr Kristan schrieb:
 
 In the beginning of Grid paint is Canvas.GetClipRect called to obtain area
 which wee must redraw. This function directly calls WidgetSet.GetClipBox.
 I find out difference betwen Win32 and gtk2 bahaviour of this func.
 
 In gtk2 TGtk2WidgetSet.GetClipBox returns previously Invalidated area
 (through DC.PaintRectangle = PS.rcPaint retrieved in BeginPaint)
 
 But in win32 directly calls Windows.GetClipBox, but this func returns
 whole grid area. Do not takes account on invalidated area retrieved in
 BeginPaint.
 
 It may be a bug in the Win32 widgetset, invalidating the entire
 control area instead of only the affected cell, *or* some special
 handling of invalidated areas by Windows. I remember that Windows
 used to extend the UpdateRect to include *all* invalidated parts of
 the DC. This can lead to a big update area, when a single bit at the
 top left and at the bottom right of the DC was invalidated. This may
 have changed in the meantime, though.

My idea was wrong, I overlook something in debug logs.
Canvas.GetClipRect returns correct value.
Problem must be in another place.
First Paint has correct update rect, but then second Paint is called
on whole grid.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Optimize DBGrid speed

2014-01-06 Thread Petr Kristan
I'am trying to minimize whole DBGrid redraw. Where I can discuss my
steps to avoid my pointless work.

Most of code what I plan to change was commited by jesus.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to exec some gdb command on start in lazarus

2013-06-25 Thread Petr Kristan
On Mon, Jun 24, 2013 at 04:31:10PM +0100, martin wrote:
 On 24/06/13 16:11, Petr Kristan wrote:
 Hallo
 
 I want to send this command to gdb:
 
 handle SIGPIPE nostop noprint pass
 
 to ignore SIGPIPE.
 I set it in my ~/.gdbinit, but Lazarus ignores it.
 
 I tried write it to Debugger_Startup_Options, but without success.
 
 
 the  Debugger_Startup_Options, would be like
 
 --eval-command=handle SIGPIPE nostop noprint pass
 
 if you are on windows IIRC gdb does not take this option.
Thank you for the fast response. I try it, but I get this message:
Debugger: Initialization output: Undefined command: \\. Try \help\.\n

In processes i have
/usr/bin/gdb -silent -i mi -nx --eval-command=handle SIGPIPE nostop noprint 
pass

But gdb already stops on SIGPIPE.

If I try run
/usr/bin/gdb -silent -i mi -nx --eval-command=handle SIGPIPE nostop noprint 
pass
from bash, then it works ok.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to exec some gdb command on start in lazarus

2013-06-25 Thread Petr Kristan
On Tue, Jun 25, 2013 at 10:07:10AM +0100, martin wrote:
 On 25/06/13 07:49, Petr Kristan wrote:
 Thank you for the fast response. I try it, but I get this message:
 Debugger: Initialization output: Undefined command: \\. Try \help\.\n
 
 In processes i have
 /usr/bin/gdb -silent -i mi -nx --eval-command=handle SIGPIPE nostop noprint 
 pass
 
 But gdb already stops on SIGPIPE.
 
 If I try run
 /usr/bin/gdb -silent -i mi -nx --eval-command=handle SIGPIPE nostop noprint 
 pass
 from bash, then it works ok.
 
 Did you try single quotes ?
 looks like the parts of the command line are not correctly broken
 into individual args.
Yes. With the same result.

I try to debug Debugger_Startup_Options: --eval-command=handle SIGPIPE nostop 
noprint pass
with strace and here is execve line:

[pid 20053] execve(/usr/bin/gdb, [/usr/bin/gdb, -silent, -i,
mi, -nx, --eval-command=\handle SIGPIPE nostop noprint pass\],
[/* 52 vars */]) = 0

IMHO it looks ok.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] How to exec some gdb command on start in lazarus

2013-06-24 Thread Petr Kristan
Hallo

I want to send this command to gdb:

handle SIGPIPE nostop noprint pass

to ignore SIGPIPE.
I set it in my ~/.gdbinit, but Lazarus ignores it.

I tried write it to Debugger_Startup_Options, but without success.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice
tel: +420 461101401Czech Republic (Eastern Europe)
fax: +420 461101481

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Remove transparency

2011-11-21 Thread Petr Kristan
Hi all,

Is possible to remove transparency from loaded png?
Setting Transparent property to false does not work. It sets only Masked to
false.

I found problem with printing transparent images on some printers in
windows xp. Some printers does not print nothing in place of transparent
image. I use practically only 1bit transparency, but images has are now with
8bit alpha.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Portable way to get accurate timestamps?

2011-02-23 Thread Petr Kristan
On Sun, Feb 20, 2011 at 02:46:34PM +0100, Luca Olivetti wrote:
 Al 20/02/11 12:42, En/na Bo Berglund ha escrit:
 
  I wonder if GetTickCount will get me a better value to milliseconds
  than Now()?
 
 Not under linux:
 
 function GetTickCount: DWord;
 begin
   Result := DWord(Trunc(Now * 24 * 60 * 60 * 1000));
 end; 

My Linux version: 

function GetTickCount: Cardinal;
var
  ts: TTimeSpec;
  i: Int64;
begin
  if clock_gettime(CLOCK_MONOTONIC, @ts)  0 then begin //kernels 2.4.* does 
not support
Result := 0;
Exit;
  end;
  i := ts.tv_sec;
  i := i*1000 + ts.tv_nsec div 100;
  Result := i and $; //cut to unsig 32bit
end;

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] GetTextMetrics in TCanvas proposal

2010-04-06 Thread petr . kristan
On Sun, Apr 04, 2010 at 04:57:06PM -0700, Jesus Reyes wrote:
 
 
 --- El vie 26-mar-10, petr.kris...@epos.cz petr.kris...@epos.cz escribió:
 
  De:: petr.kris...@epos.cz petr.kris...@epos.cz
  Asunto: Re: [Lazarus] GetTextMetrics in TCanvas proposal
  A: Lazarus mailing list lazarus@lists.lazarus.freepascal.org
  Fecha: viernes, 26 de marzo de 2010, 6:58
  On Fri, Mar 26, 2010 at 12:19:07PM
  +0100, Marc Weustink wrote:
   Paul Ishenin wrote:
   26.03.2010 16:20, petr.kris...@epos.cz
  wrote:
   Thanks all for their reactions :(
  
   Developers sometimes are busy with their projects
  :(
  
   Is another place where I can discuss? Is
  another place where LCL core
   developers response
   my few questions?
  
   In the irc channel #lazarus-ide
  
   I have done my work on cairo canvas. It can be
  used as separate package.
   Where should I put it? Certainly if comunity
  have an interest.
  
   You idea is not bad to add GetTextMetrics. Create
  a patch and a test.
   Then add them to the bug tracker.
  
   The only thing we need to ask ourselves is, do we need
  the inner  
   TTextMetric or can we use some more userfriendly
  version ?
  How to imagine myself userfriendly?
  
  Petr
 
 In r24429, I added a initial version of the function GetTextMetrics to
 canvas, it works like standard winpi GetTextMetrics but it takes a
 TLCLTextMetrics record where we can add fields that can be implemented
 in all targets, currently only Ascender, Descender and Height are
 implemented in PostscriptCanvas which allows to fix a bug in
 TurboPower IPro print preview. Still waiting for you Cairo canvas
 stuff.
I merge GetTextMetrics and Cairo will be ready.

Where I should send it? Mantis has 2kB limit.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] GetTextMetrics in TCanvas proposal

2010-03-26 Thread petr . kristan
On Wed, Mar 24, 2010 at 10:32:31AM +0100, petr.kris...@epos.cz wrote:
 Hallo.
 
 I suggest to add function function GetTextMetrics(var TM: TTextMetric): 
 boolean; into TCanvas class.
 
 If user wants to work with text on Canvas and mix different fonts on one
 line, he needs minimally to know Ascent and Descent metrics of the font.
 But TCanvas has only TextExtent function. If user renders text on the
 screen (or printer in Win), then uses lclintf.GetTextMetrics.
 But if renders on TPoscriptCanvas or upcoming TCairoCanvas he must use 
 some TCairoCanvas.GetTextMetrics or still non existing
 TPoscriptCanvas.GetTextMetrics.
 
 It cause ugly non oop construction like:
 
 {$IFDEF USE_CAIRO}
 if Canvas is TCairoCanvas then 
   (Canvas as TCairoCanvas).GetTextMetrics(tm)
 else
   GetTextMetrics(tm);
 {$ELSE}
   GetTextMetrics(tm);
 {$ENDIF}
 
 For that reason I propose to add virtual function GetTextMetrics into
 TCanvas.
 
 Is this proposal acceptable?
 
 If it is, how to move ahead to reach this goal.

Thanks all for their reactions :(

Is another place where I can discuss? Is another place where LCL core 
developers response
my few questions?

I have done my work on cairo canvas. It can be used as separate package.
Where should I put it? Certainly if comunity have an interest.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] GetTextMetrics in TCanvas proposal

2010-03-26 Thread petr . kristan
On Fri, Mar 26, 2010 at 04:35:28PM +0700, Paul Ishenin wrote:
 26.03.2010 16:20, petr.kris...@epos.cz wrote:
 Thanks all for their reactions :(

 Developers sometimes are busy with their projects :(
I suppose it :)

 Is another place where I can discuss? Is another place where LCL core 
 developers response
 my few questions?

 In the irc channel #lazarus-ide

 I have done my work on cairo canvas. It can be used as separate package.
 Where should I put it? Certainly if comunity have an interest.

 You idea is not bad to add GetTextMetrics. Create a patch and a test.  
 Then add them to the bug tracker.
I'l try it.

And what to do with finished cairo canvas package? 
Send tarball to the list?

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] GetTextMetrics in TCanvas proposal

2010-03-26 Thread petr . kristan
On Fri, Mar 26, 2010 at 12:19:07PM +0100, Marc Weustink wrote:
 Paul Ishenin wrote:
 26.03.2010 16:20, petr.kris...@epos.cz wrote:
 Thanks all for their reactions :(

 Developers sometimes are busy with their projects :(

 Is another place where I can discuss? Is another place where LCL core
 developers response
 my few questions?

 In the irc channel #lazarus-ide

 I have done my work on cairo canvas. It can be used as separate package.
 Where should I put it? Certainly if comunity have an interest.

 You idea is not bad to add GetTextMetrics. Create a patch and a test.
 Then add them to the bug tracker.

 The only thing we need to ask ourselves is, do we need the inner  
 TTextMetric or can we use some more userfriendly version ?
How to imagine myself userfriendly?

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] GetTextMetrics in TCanvas proposal

2010-03-24 Thread petr . kristan
Hallo.

I suggest to add function function GetTextMetrics(var TM: TTextMetric): 
boolean; into TCanvas class.

If user wants to work with text on Canvas and mix different fonts on one
line, he needs minimally to know Ascent and Descent metrics of the font.
But TCanvas has only TextExtent function. If user renders text on the
screen (or printer in Win), then uses lclintf.GetTextMetrics.
But if renders on TPoscriptCanvas or upcoming TCairoCanvas he must use 
some TCairoCanvas.GetTextMetrics or still non existing
TPoscriptCanvas.GetTextMetrics.

It cause ugly non oop construction like:

{$IFDEF USE_CAIRO}
if Canvas is TCairoCanvas then 
  (Canvas as TCairoCanvas).GetTextMetrics(tm)
else
  GetTextMetrics(tm);
{$ELSE}
  GetTextMetrics(tm);
{$ENDIF}

For that reason I propose to add virtual function GetTextMetrics into
TCanvas.

Is this proposal acceptable?

If it is, how to move ahead to reach this goal.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Wed, Mar 10, 2010 at 03:22:31PM +0100, petr.kris...@epos.cz wrote:
 Hi.
 
 Main work on TCairoCanvas = class(TPrinterCanvas) is almost done.
 
 My question is how to integrate it into LCL?
 IMHO user should have a choice which TPrinterCanvas implementation use. 
 Now in TCUPSPrinter is hard coded TPostscriptPrinterCanvas:
 
 function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
 begin
   Result:=TPostscriptPrinterCanvas;
 end;
 
 Petr
 
Nobody here, who can halp me to integrate TCairoCanvas into LCL?

Were in LCL directory structure place cairocanvas.pas (depends only on
libcairo) and gdkcairocanvas.pas (depends extra on libgdk).

How should programer select which implementation of TPrinterCanvas will
be created in TPrinter.GetCanvas.

Now TCUPSPrinter implementation use hard coded TPostscriptPrinterCanvas
and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
My TCairoCanvas implementation has the same needs. 

I do not want to waste my time if comunity do not have an interest to 
include CairoCanvas into lcl.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 02:20:46PM +0100, zeljko wrote:
 On Thursday 11 March 2010 14:08, petr.kris...@epos.cz wrote:
 
 
  Nobody here, who can halp me to integrate TCairoCanvas into LCL?
 
  Were in LCL directory structure place cairocanvas.pas (depends only on
  libcairo) and gdkcairocanvas.pas (depends extra on libgdk).
 
  How should programer select which implementation of TPrinterCanvas will
  be created in TPrinter.GetCanvas.
 
  Now TCUPSPrinter implementation use hard coded TPostscriptPrinterCanvas
  and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
  My TCairoCanvas implementation has the same needs.
 
  I do not want to waste my time if comunity do not have an interest to
  include CairoCanvas into lcl.
 
 Well, nobody said that it will not be included, but probably developers don't 
 have enough spare time to review your work at the moment.
 Probably best way would be  to open mantis issue about this and attach your 
 changes as patch.
Now I do not ask to review my work, I only need a little help with a few
questions. In order to prepare complete include patch.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 02:23:15PM +0100, Michael Van Canneyt wrote:


 On Thu, 11 Mar 2010, petr.kris...@epos.cz wrote:

 On Wed, Mar 10, 2010 at 03:22:31PM +0100, petr.kris...@epos.cz wrote:
 Hi.

 Main work on TCairoCanvas = class(TPrinterCanvas) is almost done.

 My question is how to integrate it into LCL?
 IMHO user should have a choice which TPrinterCanvas implementation use.
 Now in TCUPSPrinter is hard coded TPostscriptPrinterCanvas:

 function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
 begin
   Result:=TPostscriptPrinterCanvas;
 end;

 Petr

 Nobody here, who can halp me to integrate TCairoCanvas into LCL?

 Were in LCL directory structure place cairocanvas.pas (depends only on
 libcairo) and gdkcairocanvas.pas (depends extra on libgdk).

 How should programer select which implementation of TPrinterCanvas will
 be created in TPrinter.GetCanvas.

 Now TCUPSPrinter implementation use hard coded TPostscriptPrinterCanvas
 and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
 My TCairoCanvas implementation has the same needs.

 I do not want to waste my time if comunity do not have an interest to
 include CairoCanvas into lcl.

 I think you should create an abstract TFilePrinterCanvas descendent of
 TPrinterCanvas (with the needed FileName property) and define a variable

 Type
   TFilePrinterCanvas = Class of TFilePrinterCanvas;

 Var
   CupsCanvasClass : TFilePrinterCanvas = TPostscriptPrinterCanvas;

 which the programmer can set, if so desired. then the
 TCUPSPrinter.GetCanvasRef
 implementation checks the CupsCanvasClass variable. If it is set,
 it uses the class defined there, and if not, it uses
 TPostscriptPrinterCanvas.
Thanks.

This corresponds with my idea. 

Where is recommeded place for cairocanvas.pas and gdkcairocanvas.pas in
lcl? CairoCanvas can work on Windows, Linux and Mac OS X. 

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 02:50:04PM +0100, Mattias Gaertner wrote:
 On Thu, 11 Mar 2010 14:41:18 +0100
 petr.kris...@epos.cz wrote:
 
  On Thu, Mar 11, 2010 at 02:23:15PM +0100, Michael Van Canneyt wrote:
  
  
   On Thu, 11 Mar 2010, petr.kris...@epos.cz wrote:
  
   On Wed, Mar 10, 2010 at 03:22:31PM +0100, petr.kris...@epos.cz wrote:
   Hi.
  
   Main work on TCairoCanvas = class(TPrinterCanvas) is almost done.
  
   My question is how to integrate it into LCL?
   IMHO user should have a choice which TPrinterCanvas implementation use.
   Now in TCUPSPrinter is hard coded TPostscriptPrinterCanvas:
  
   function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
   begin
 Result:=TPostscriptPrinterCanvas;
   end;
  
   Petr
  
   Nobody here, who can halp me to integrate TCairoCanvas into LCL?
  
   Were in LCL directory structure place cairocanvas.pas (depends only on
   libcairo) and gdkcairocanvas.pas (depends extra on libgdk).
  
   How should programer select which implementation of TPrinterCanvas will
   be created in TPrinter.GetCanvas.
  
   Now TCUPSPrinter implementation use hard coded TPostscriptPrinterCanvas
   and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
   My TCairoCanvas implementation has the same needs.
  
   I do not want to waste my time if comunity do not have an interest to
   include CairoCanvas into lcl.
  
   I think you should create an abstract TFilePrinterCanvas descendent of
   TPrinterCanvas (with the needed FileName property) and define a variable
  
   Type
 TFilePrinterCanvas = Class of TFilePrinterCanvas;
  
   Var
 CupsCanvasClass : TFilePrinterCanvas = TPostscriptPrinterCanvas;
  
   which the programmer can set, if so desired. then the
   TCUPSPrinter.GetCanvasRef
   implementation checks the CupsCanvasClass variable. If it is set,
   it uses the class defined there, and if not, it uses
   TPostscriptPrinterCanvas.
  Thanks.
  
  This corresponds with my idea. 
  
  Where is recommeded place for cairocanvas.pas and gdkcairocanvas.pas in
  lcl? CairoCanvas can work on Windows, Linux and Mac OS X. 
 
 lcl/interfaces/gtk2
I think this is good place for gdkcairocanvas.pas. But cairocanvas.pas
needs only libcairo. It do not needs gtk. 

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 03:01:18PM +0100, Mattias Gaertner wrote:
 On Thu, 11 Mar 2010 14:54:48 +0100
 petr.kris...@epos.cz wrote:
 
  On Thu, Mar 11, 2010 at 02:50:04PM +0100, Mattias Gaertner wrote:
   On Thu, 11 Mar 2010 14:41:18 +0100
   petr.kris...@epos.cz wrote:
   
On Thu, Mar 11, 2010 at 02:23:15PM +0100, Michael Van Canneyt wrote:


 On Thu, 11 Mar 2010, petr.kris...@epos.cz wrote:

 On Wed, Mar 10, 2010 at 03:22:31PM +0100, petr.kris...@epos.cz wrote:
 Hi.

 Main work on TCairoCanvas = class(TPrinterCanvas) is almost done.

 My question is how to integrate it into LCL?
 IMHO user should have a choice which TPrinterCanvas implementation 
 use.
 Now in TCUPSPrinter is hard coded TPostscriptPrinterCanvas:

 function TCUPSPrinter.GetCanvasRef: TPrinterCanvasRef;
 begin
   Result:=TPostscriptPrinterCanvas;
 end;

 Petr

 Nobody here, who can halp me to integrate TCairoCanvas into LCL?

 Were in LCL directory structure place cairocanvas.pas (depends only 
 on
 libcairo) and gdkcairocanvas.pas (depends extra on libgdk).

 How should programer select which implementation of TPrinterCanvas 
 will
 be created in TPrinter.GetCanvas.

 Now TCUPSPrinter implementation use hard coded 
 TPostscriptPrinterCanvas
 and needs access to TPostscriptPrinterCanvas(Canvas).OutputFileName.
 My TCairoCanvas implementation has the same needs.

 I do not want to waste my time if comunity do not have an interest to
 include CairoCanvas into lcl.

 I think you should create an abstract TFilePrinterCanvas descendent of
 TPrinterCanvas (with the needed FileName property) and define a 
 variable

 Type
   TFilePrinterCanvas = Class of TFilePrinterCanvas;

 Var
   CupsCanvasClass : TFilePrinterCanvas = TPostscriptPrinterCanvas;

 which the programmer can set, if so desired. then the
 TCUPSPrinter.GetCanvasRef
 implementation checks the CupsCanvasClass variable. If it is set,
 it uses the class defined there, and if not, it uses
 TPostscriptPrinterCanvas.
Thanks.

This corresponds with my idea. 

Where is recommeded place for cairocanvas.pas and gdkcairocanvas.pas in
lcl? CairoCanvas can work on Windows, Linux and Mac OS X. 
   
   lcl/interfaces/gtk2
  I think this is good place for gdkcairocanvas.pas. But cairocanvas.pas
  needs only libcairo. It do not needs gtk. 
 
 Well, it should be added to the fpc sources, but till this is in a
 release we have to add this unit to the lazarus sources too.
Ok. 

I place it into lcl/ along poscriptcanvas.pas.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 03:16:24PM +0100, Mattias Gaertner wrote:
 On Thu, 11 Mar 2010 15:08:57 +0100
 petr.kris...@epos.cz wrote:
 
  On Thu, Mar 11, 2010 at 03:01:18PM +0100, Mattias Gaertner wrote:
 [...]
  Where is recommeded place for cairocanvas.pas and 
  gdkcairocanvas.pas in
  lcl? CairoCanvas can work on Windows, Linux and Mac OS X. 
 
 lcl/interfaces/gtk2
I think this is good place for gdkcairocanvas.pas. But cairocanvas.pas
needs only libcairo. It do not needs gtk. 
   
   Well, it should be added to the fpc sources, but till this is in a
   release we have to add this unit to the lazarus sources too.
  Ok. 
  
  I place it into lcl/ along poscriptcanvas.pas.
 
 lcl/ only contains platform independent sources (they must use a
 minimum of external libraries). Platform dependent things should be
 placed in lcl/interfaces/...
 I think that non gtk users won't use cairo, so better place it in
 lcl/interfaces/gtk2.
Windows or MacOSX user can use TCairoCanvas for export to pdf, ps, svg or png.
He only needs libcairo which do not depends on gtk. Dependency is
reversed, libgtk depends on libcairo.

For example Firefox 3 (gecko) uses Cairo on all platforms.

If will be interest we can easily make TWin32CairoCanvas,
TX11CairoCanvas or TQuartzCairoCanvas (OSX) and render on screen.
This should establish quite correct multiplatform WYSIWYG.

I myself think about to use it on Linux/gtk2 and Win32 for screen and
printing in our DTP like project.

But if you still prefer lcl/interfaces/gtk2, I place it there.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TCairoCanvas integration

2010-03-11 Thread petr . kristan
On Thu, Mar 11, 2010 at 07:37:12AM -0800, Jesus Reyes wrote:
 
   I place it into lcl/ along poscriptcanvas.pas.
  
  lcl/ only contains platform independent sources (they must
  use a
  minimum of external libraries). Platform dependent things
  should be
  placed in lcl/interfaces/...
  I think that non gtk users won't use cairo, so better place
  it in
  lcl/interfaces/gtk2.
  
  
  Mattias
  
  --
 
 I think it would be good to make it an independent package available in 
 Lazarus, not necessarily linked to the LCL or FPC and at the same time 
 available to users from different OS and widgetsets, the quality and the 
 multi backend ability is certainly something that not only gtk users want.

It sounds good.

I make CUPSPrinter switch:

Var
  CupsCanvasClass : TFilePrinterCanvas = TPostscriptPrinterCanvas;

and remaining can be easily independent.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Raster image data in RGB24 or ARGB32

2010-03-02 Thread petr . kristan
Hi.

I'am working on Cairo Canvas implementation 
and for implementing StretchDraw function I need 
to get RasterImage data in format RGB24 or ARGB32.

CAIRO_FORMAT_ARGB32
  each pixel is a 32-bit quantity, with alpha in the upper 8 bits, then
red, then green, then blue. The 32-bit quantities are stored
native-endian. Pre-multiplied alpha is used. (That is, 50% transparent
red is 0x8080, not 0x80ff.)

CAIRO_FORMAT_RGB24
  each pixel is a 32-bit quantity, with the upper 8 bits unused. Red,
Green, and Blue are stored in the remaining 24 bits in that order. 

Can I use TLazIntfImage for this task and how?

Thanks.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] lazarus as normal user

2010-02-18 Thread petr . kristan
On Thu, Feb 18, 2010 at 10:48:17AM -0300, Pino Zollo wrote:
 Hi to the list,
 I am just a beginner with lazarus
 
 I have installed it on my Debian 5.01first fpc an then I have compiled 
 lazarus from sources copied in /usr/src/lazarus.

Easiest way, but any user on your machine can modify /usr/src/lazarus
Run as root:
cd /usr/src/lazarus
find -type d -print0 | xargs -0 chmod 777
find -type d -print0 | xargs -0 chmod 666

or 

Only USER and root can work with Lazarus:
cd /usr/src/lazarus
chown USER * -R(USER means your normal login name)

Then do not work with lazarus as root.
/usr/src/lazarus/startlazarus should work.

 It happens that all goes fine if I run lazarus as root (deprecated by Debian) 
 from /usr/src/lazarus...I can compile examples and run them. 
 I can even install new components and they appear into the IDE.
 
 The problem rises if I run lazarus as normal user.
 
 Having made make install now I have /usr/local/bin/lazarus-ide
 available to all users .
 
 If I run /usr/local/bin/lazarus-ide I have a hell of problems:
 
 Units are not found anymore when compiling examples:
 For any subdir I have to add into fpc.cfg a new entry -uF 
 
 When lazarus rebuilds for a new components it does it to the 
 original /usr/src/lazarus but then it is /usr/local/bin/lazarus-ide
 that is restartedso I do not see any change into the IDE.
 
 I have tried to compile lazarus as a normal user having the sources 
 in /home/myuser/lazarus but this does not succeed. 
 
 Please some advise
 
 Regards
 
 Pino   
 
 pinozollo at gmail dot com 
 http://www.qsl.net/zp4kfx/Linux
 
 

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] lazarus as normal user

2010-02-18 Thread petr . kristan
On Thu, Feb 18, 2010 at 09:41:38AM -0500, waldo kitty wrote:
 On 2/18/2010 09:10, petr.kris...@epos.cz wrote:
 On Thu, Feb 18, 2010 at 10:48:17AM -0300, Pino Zollo wrote:
 Hi to the list,
 I am just a beginner with lazarus

 I have installed it on my Debian 5.01first fpc an then I have compiled
 lazarus from sources copied in /usr/src/lazarus.

 Easiest way, but any user on your machine can modify /usr/src/lazarus
 Run as root:
 cd /usr/src/lazarus
 find -type d -print0 | xargs -0 chmod 777
 find -type d -print0 | xargs -0 chmod 666

 is the above a typo? first it set mode 777 and then sets the same things 
 to 666?? i think there's a booboo there...
Yes, sorry 

find -type f -print0 | xargs -0 chmod 666

But Mattias sends better and complex solution.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Printing in Linux

2010-02-15 Thread petr . kristan
Hi.

I'am working on multiplatform Win/Lin app whose main job is graphics printing.
In Windows all works ok, but in Linux output postscript is wrong. 
After little digging I found that TPoscriptCanvas is responsible for it.

I have a question about Lazarus future plans in rendering graphics output to
postscript.

Shouldn't be better to use for example Cairo than make poscript output
yourself?

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Printing in Linux

2010-02-15 Thread petr . kristan
On Mon, Feb 15, 2010 at 11:13:12AM -0200, Felipe Monteiro de Carvalho wrote:
 On Mon, Feb 15, 2010 at 6:23 AM,  petr.kris...@epos.cz wrote:
  Shouldn't be better to use for example Cairo than make poscript output
  yourself?
 
 The printing package is implemented by operating system rather then by
 widgetset, so if you use Cairo it would only work with LCL-Gtk2 and a
 new code would need to be written for LCL-Qt.
I maybe don`t understand your answer. In Windows is rendering for
printer implemented by operating system WinAPI. But in Unix we need to render
into postscript. Now it is realised by TPoscriptCanvas which do not use
any library, but output is erroneous.

As I know, Qt has its own rendering engine (screen and printer).
For example Kylix uses it.
And I now do not know if in LCL exists TQtCanvas used by LCL-Qt.

Cairo library is multiplatform and renders into X11, Win32, PS, PDF, ... 
It do not depends on gtk. 
Dependency is reversed -- new Gtk2 uses Cairo to render widgets.
For example WebKit and Firefox3 uses this library on all platforms.
http://en.wikipedia.org/wiki/Cairo_(graphics)

What about to make TCairoCanvas and use it by default in LCL-Gtk2.
IMHO generated postscript output should be better then TPoscriptCanvas
makes.

TCairoCanvas (certainly with corresponding library) can be useful in other 
platforms. 
Rendering into PDF, SVG or PNG may be convenience to anybody.

Petr

-- 
Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223Czech Republic (Eastern Europe) 
fax: +420 466510709

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus