Re: [lazarus] Behavior of ClientToScreen in scrolling windows across different widget sets

2008-02-07 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:
While debugging scrolling bugs in LCL i found that ClientToScreen 
acts differently according to the widget set.


These are the behaviors:

1) The returned value is related to the actual position, i.e., it 
does not consider the scroll offset. If you pass Point(0,0) the value 
will be the same regardless of the scroll position. (Gtk1)


2) The returned value is related to the virtual position, i.e, it 
takes into account the scroll offset. If you pass Point(0, 0) the 
value changes inversely to scrollbar position. (Gtk2)  3)  The 
returned value is related to the virtual position, i.e, it takes into 
account the scroll offset. If you pass Point(0, 0) the value changes 
the same amount of scrollbar position. (Win32)


4) Nothing. Qt has no visible scrollbars so...

Notes:

Delphi does the same as (1)/Gtk1


Not really, internally Delphi does it like 2. All controls are moved.


I'm not referring to position of controls after scrolling. I'm referring 
to ClientToScreen return results. Say you query the ClientToScreen with 
0,0 will return value x, y. Now scroll vertically amount n. Under Delphi 
the returned value will still be x, y and not x, y-n that is the virtual 
position. The example shows this clearly. Move the window to position 
0,0. Get the ClientToScreen result of 0,0 = 0,0. Now scroll vertically 
10 (Notice that part of the client area is offscreen). Get again the 
value of 0,0. You will get


Win32: 0,10
Gtk1: 0,0
Gtk2: 0, -10
Delphi: 0,0
The patch makes win32 behaves like Gtk2 each makes more sense.




(3) is clearly buggy.

Between (1) and (2) is a design decision.


We started like delphi, move controls and report corrected values when 
asked. However this aproach is very inefficient on all widgetsets 
except win32. So the new approach is that controls stay at their 
position and only the virtual parent gets an offset.
This means that the top/left of a control on a say scrollbox are 
allways the same, an offset to the virtual parent top/left.

See above.


So now ClientToScreen.
The top/left of a scrolled control needs to get a scrolled offset, so 
that is reflects the real position relative to the real parent of 
the control.


The behavior described here is generic to any point, not control 
position related.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Behavior of ClientToScreen in scrolling windows across different widget sets

2008-02-06 Thread Luiz Americo Pereira Camara
While debugging scrolling bugs in LCL i found that ClientToScreen acts 
differently according to the widget set.


These are the behaviors:

1) The returned value is related to the actual position, i.e., it does 
not consider the scroll offset. If you pass Point(0,0) the value will be 
the same regardless of the scroll position. (Gtk1)


2) The returned value is related to the virtual position, i.e, it takes 
into account the scroll offset. If you pass Point(0, 0) the value 
changes inversely to scrollbar position. (Gtk2)   

3)  The returned value is related to the virtual position, i.e, it takes 
into account the scroll offset. If you pass Point(0, 0) the value 
changes the same amount of scrollbar position. (Win32)


4) Nothing. Qt has no visible scrollbars so...

Notes:

Delphi does the same as (1)/Gtk1

(3) is clearly buggy.

Between (1) and (2) is a design decision.


Attached is a patch that makes win32 acts like (2)/gtk2. It changes the 
offset signal when calculating the LCL bounds. With the change it 
becomes consistent with the TCustomGroupBox signal convention (LCL 
bounds at Right/Down  of win32 +, at Left/Up -).

It also fixes the scrolling paint and setcursor of non TWincontrol.

Luiz



Index: lcl/interfaces/win32/win32callback.inc
===
--- lcl/interfaces/win32/win32callback.inc  (revision 14008)
+++ lcl/interfaces/win32/win32callback.inc  (working copy)
@@ -471,12 +471,10 @@
   end;
   if ParentPaintWindow  0 then
 GetWin32ControlPos(Window, ParentPaintWindow, parLeft, parTop);
-  if not GetLCLClientBoundsOffset(lWinControl, ORect) then
-  begin
-ORect.Left := 0;
-ORect.Top := 0;
-{ we don't use ORect.Right and ORect.Bottom, initialize here if needed 
}
-  end;
+  //Is not necessary to check the result of GetLCLClientBoundsOffset since
+  //the false condition (lWincontrol = nil or lWincontrol  TWinControl) 
is never met
+  //The rect is always initialized with 0
+  GetLCLClientBoundsOffset(lWinControl, ORect);
   PaintMsg.Msg := LM_PAINT;
   PaintMsg.PaintStruct := @PS;
   if not useDoubleBuffer then
Index: lcl/interfaces/win32/win32proc.pp
===
--- lcl/interfaces/win32/win32proc.pp   (revision 14008)
+++ lcl/interfaces/win32/win32proc.pp   (working copy)
@@ -852,8 +852,8 @@
   if HorzScrollBar  nil then
   begin
 // left and right bounds are shifted by scroll position
-ORect.Left := HorzScrollBar.Position;
-ORect.Right := HorzScrollBar.Position;
+ORect.Left := -HorzScrollBar.Position;
+ORect.Right := -HorzScrollBar.Position;
   end;
   if VertScrollBar  nil then
   begin
@@ -858,8 +858,8 @@
   if VertScrollBar  nil then
   begin
 // top and bottom bounds are shifted by scroll position
-ORect.Top := VertScrollBar.Position;
-ORect.Bottom := VertScrollBar.Position;
+ORect.Top := -VertScrollBar.Position;
+ORect.Bottom := -VertScrollBar.Position;
   end;
 end;
   If (TheWinControl is TCustomGroupBox) Then


Re: [lazarus] Found serious bug in win32 interface #2

2008-01-30 Thread Luiz Americo Pereira Camara

Andrey Gusev wrote:
* Mattias G#228;rtner [EMAIL PROTECTED] [Wed, 30 Jan 2008 
18:45:57 +0100]:

Zitat von Andrey Gusev [EMAIL PROTECTED]:

 --- interfaces/win32/win32callback.inc (revision 13905)
 +++ interfaces/win32/win32callback.inc (working copy)
  @@ -504,7 +504,7 @@
 if (ControlDC = 0) or not needParentPaint then
  begin
  DCIndex := Windows.SaveDC(PaintMsg.DC);
  - MoveWindowOrgEx(PaintMsg.DC, ORect.Left, ORect.Top);
 + MoveWindowOrgEx(PaintMsg.DC, -ORect.Left, -ORect.Top);
  {$ifdef DEBUG_DOUBLEBUFFER}
  Windows.GetClipBox(PaintMsg.DC, ClipBox);
 DebugLn('LCL Drawing in DC ', IntToHex(PaintMsg.DC, 8), '
 with
 clipping rect (',

 I can provide application that's confirm my rightfulness.
 But i don't wish to do it, until all child-control negative effects
will
 debugged (by me), it need to LazReport designer functionality.
 If wished, try to place oversized TPaintBox on TScrollBox and try it
to
 scroll (with above patch applied).

It might improve the situation, but I guess it will not fix the whole
problem.
See here:
http://wiki.lazarus.freepascal.org/Win32/64_Interface


It was said, about intermeditate layer, earlier (by You).
Also, it implementation started in win32wsfrorms, rudimentary state.
But observed, with above correction, child controls scrolls correctly, 
except
page and line messages processing, which brings some negative shift, 
for childs.
Undoubtedly, we can force to work existing variant, a few various 
methods can be invented

(twice MoveWindowOrg for example).
But pointed bug is nice explaination (and chance to eliminate) the 
strange opposite scrolling behaviour.

see http://bugs.freepascal.org/view.php?id=10400,
also observation, described in my #16900 reply, 
http://bugs.freepascal.org/view.php?id=10471,

correspond to pointed bug presence.


Hi, do you have one or two small proof of concept LCL application that 
shows the problem? (works in gtk fails in win32).

If you have please send me or post in the bugtracker/here.
I will take a look.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] How to load aRGBA data from a bitmap file using TLazIntfImage

2008-01-24 Thread Luiz Americo Pereira Camara
I need to load the data of bitmap files into a buffer in the RGBA 
format, but i'm somewhat lost.


Reading the wiki and the source i got to the following code:

procedure DumpMem(Data: PCardinal; Size: Integer);
var
 i: Integer;
 Color: TRGBA;
begin
 for i := 0 to Size - 1 do
 begin
   Color := TRGBA(Data[i]);
   WriteLn('Red: ', Color.R, ' Green: ', Color.G,
 ' Blue: ',Color.B, ' Alpha: ', Color.A);
 end;
end;

var
 ImgReader: TLazReaderBMP;
 IntfImg: TLazIntfImage;
begin
 ImgReader := TLazReaderBMP.Create;
 IntfImg := TLazIntfImage.Create(0,0);
 IntfImg.DataDescription.Init_BPP32_B8G8R8A8_M1_BIO_TTB(0, 0);
 IntfImg.LoadFromFile('red.bmp', ImgReader);

 DumpMem(PCardinal(IntfImg.PixelData), IntfImg.DataDescription.Height * 
IntfImg.DataDescription.Width);


 ImgReader.Destroy;
 IntfImg.Destroy;
end;

red.bmp is a 2x2 bmp file filled with red. (attached)

the DumpMem leads to different results if the program is run in IDE or 
outside it (Probably PixelData is not pointing to the data).


What's wrong with this code? Should i pass the width, height when init 
datadescription?


Luiz




inline: red.bmp

Re: [lazarus] How to load aRGBA data from a bitmap file using TLazIntfImage

2008-01-24 Thread Luiz Americo Pereira Camara

Marco Alvarado wrote:

You could try using TLazIntfImage.GetDataLineStart() instead.

I think you can modify your code this way:

...
for y := 0 to IntfImg.DataDescription.Height-1 do
DumpMem(PCardinal(IntfImg.GetDataLineStart(y)), IntfImg.DataDescription.Width);
...
  


Thanks, but i still get random values. I would expect at least the same 
values for each pixel.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] How to load aRGBA data from a bitmap file using TLazIntfImage

2008-01-24 Thread Luiz Americo Pereira Camara

wile64 wrote:

Your image is in 24 bits, test load and then changing it to 32 bits

It seems the best description for what i want is 
Init_BPP32_B8G8R8_BIO_TTB that gives me a 24bit depth with a 32bits per 
pixel, but still getting random values.


Also tested Init_BPP24_B8G8R8_BIO_TTB.

No luck.

Thanks anyway.

Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] How to load aRGBA data from a bitmap file using TLazIntfImage

2008-01-24 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Should i pass the width, height when init datadescription?


This does not help. I hardcoded width and height to 2 and got the same 
result.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Lazarus compiled with GTK2 [part 1 of 2]

2008-01-23 Thread Luiz Americo Pereira Camara

Paul Ishenin wrote:

Luiz Americo Pereira Camara wrote:


Gtk2 is in fact slower than Gtk1, every one agree, but LCL/Gtk2 
application are much slower than other Gtk2 applications


Is it possible to profile gtk2 lcl application and find what cause 
this slowleness? Who can do?


I'll take a look.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Lazarus compiled with GTK2 [part 1 of 2]

2008-01-23 Thread Luiz Americo Pereira Camara

Damien Gerard wrote:


On Jan 22, 2008, at 10:20 PM, Marc Weustink wrote:


Luiz Americo Pereira Camara wrote:

Marc Weustink wrote:

Graeme Geldenhuys wrote:

On 22/01/2008, Giuliano Colla [EMAIL PROTECTED] wrote:
I gather that someone is already using GTK2, but I believe that 
he's not
much demanding in terms of graphic appearance. My customers would 
run
after me with a hammer if I'd dare to show them the current state 
of the

art. :-)


I've tried to use Lazarus/GTK2 for half a day now.  It's horribly 
slow

as well, compared to GTK1.  For now I switched back to GTK1 and will
try GTK2 in a few months again.


I fear that won't change much, gtk2 itself is slower than gtk1 due 
to all clientside graphic stuff
Gtk2 is in fact slower than Gtk1, every one agree, but LCL/Gtk2 
application are much slower than other Gtk2 applications


Compared to what apps ?




Personaly, I don't think the difference is so much. It is not like 
using a 3D engine to make transparent windows.

There is without a doubt.
We were speaking a few days ago the count of layers. As fpGUI, LCL is 
a layer as well, with its own overhead.
Additionally with Lazarus, we often naturally create more widgets than 
needed (enjoy nested panels) plus some arrangements which may not be 
lead to the best performance, done by the widgetset and all its 
policies to ensure its good work.




Other possible reasons for slowness:

- Some code is shared between gtk1 and gtk2. This leads to use of 
deprecated functions although this has improved a lot in the last times 
like using the new g_signal functions, use of pango instead of gdk 
functions.

- Double buffering is disabled by default

For sure, some of us are tired to read this ml and to see GTK2 is 
slower GTK2/LCL is slower with infinite threads.


It is a fact and we have to accept that. We have to choose for 
balance, according to our needs and philosophy.
Some of us think this is too slow for them ? They can use their own 
way if they want to and that's good. The future will tell if they were 
right. May day some day the different ways will lead to the same point.
I think others would like to focus on what really matters: To improve 
the great work done for Lazarus.


I'm fine to say that because this is what i do, i provide patches (when 
is in my knowledge/interest scope), make bug reports with full examples, 
and create third party controls.


And while all this threading is gone i already implemented two full 
working LCL controls, improved cairo binding, created a OOP wrapper for 
cairo integrating with LCL (gtk1, gtk2, win32), support for svg files. 
To be released soon.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Lazarus compiled with GTK2 [part 1 of 2]

2008-01-22 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Graeme Geldenhuys wrote:

On 22/01/2008, Giuliano Colla [EMAIL PROTECTED] wrote:
I gather that someone is already using GTK2, but I believe that he's 
not

much demanding in terms of graphic appearance. My customers would run
after me with a hammer if I'd dare to show them the current state of 
the

art. :-)


I've tried to use Lazarus/GTK2 for half a day now.  It's horribly slow
as well, compared to GTK1.  For now I switched back to GTK1 and will
try GTK2 in a few months again.


I fear that won't change much, gtk2 itself is slower than gtk1 due to 
all clientside graphic stuff


Gtk2 is in fact slower than Gtk1, every one agree, but LCL/Gtk2 
application are much slower than other Gtk2 applications


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Introduction

2008-01-20 Thread Luiz Americo Pereira Camara

Lord Satan wrote:

On Sun, 20 Jan 2008 22:33:53 +0200
Graeme Geldenhuys [EMAIL PROTECTED] wrote:

  

I still think having a
custom Object Pascal written toolkit for Lazarus is the way to go. The
LCL would have progressed and stabilized much faster if the Lazarus
developers did that from the start.



That's correct. And if they had used OpenGL for it, it would be hardware 
accelerated, cross plattform and good looking, too. And we would need no stupid 
Aero or Compiz or other composition managers. And we could do things other 
widgetsets could only dream of. And porting to OpenES would be easy, too.
Stupid Lazarus developers. Now we only get this sucking Win API, GTK1, GTK2, 
Carbon and QT. Nothing really works and all is full of bugs.
  


Take easy.

If you are not help with it you have three options:

- Don't use anymore
- Make patches
- Do a fork

For myself i have some differences with Lazarus developers vision, but i 
will never call them stupid. Instead, i make patches.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] why sometime TLHTTPClientComponent can not get data?

2008-01-14 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

ik wrote:

On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote:

thanks ido
wireshark is a great tool, i attach a log, found data is got, but
Component's status not change.


I've read your code again (and looked at the log), I noticed this:
strstream.WriteString(String(ABuffer))

You are casting a pointer as a string... The way to convert PChar to a
string is to use the function StrPas


Only if you use shortstrings. When using ansistrings you can cast a 
PChar in to a string like: String(SomePchar)

With ansistrings you seldom (or never) need StrPas



What about the length that is stored just before the memory location of 
ansistrings? Does PChar created with StrAlloc have this field?


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] why sometime TLHTTPClientComponent can not get data?

2008-01-14 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:


You are casting a pointer as a string... The way to convert PChar to a
string is to use the function StrPas


Only if you use shortstrings. When using ansistrings you can cast a 
PChar in to a string like: String(SomePchar)

With ansistrings you seldom (or never) need StrPas



What about the length that is stored just before the memory location 
of ansistrings? Does PChar created with StrAlloc have this field?


It is not really a cast. The compiler adds conversion code.


I'm interested in this since currently i use StrPas to convert from 
PChar to AnsiString.


Is this (String(PChar)) faster than StrPas?

Is safe that will not change to a simple pointer cast in future?

Does it copy the string content?

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] why sometime TLHTTPClientComponent can not get data?

2008-01-14 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Marc Weustink wrote:


You are casting a pointer as a string... The way to convert PChar 
to a

string is to use the function StrPas


Only if you use shortstrings. When using ansistrings you can cast 
a PChar in to a string like: String(SomePchar)

With ansistrings you seldom (or never) need StrPas



What about the length that is stored just before the memory 
location of ansistrings? Does PChar created with StrAlloc have this 
field?


It is not really a cast. The compiler adds conversion code.


I'm interested in this since currently i use StrPas to convert from 
PChar to AnsiString.


that is not needed.

the following app is valid:
program a;
{$mode objfpc}{$h+}
var
  p: PChar;
  s: String;
begin
  p := 'abcdef';
  s := p;
end.

PChars will be autoconverted to strings
The use of StrPas is from the shortstring times.



Is this (String(PChar)) faster than StrPas?


lets compale to assembler and comapre:
# [10] s := p;
leal-48(%ebp),%eax
callFPC_ANSISTR_DECR_REF
movl$0,-48(%ebp)
movlU_P$S_P,%eax
callfpc_pchar_to_ansistr
movl%eax,-48(%ebp)
movl-48(%ebp),%eax
callFPC_ANSISTR_INCR_REF
movl$U_P$S_A,%eax
callFPC_ANSISTR_DECR_REF
movl-48(%ebp),%eax
movl%eax,U_P$S_A

# [11] s := StrPas(p);
leal-48(%ebp),%eax
callFPC_ANSISTR_DECR_REF
movl$0,-48(%ebp)
leal-304(%ebp),%edx
movlU_P$S_P,%eax
callFPC_PCHAR_TO_SHORTSTR
leal-304(%ebp),%eax
callfpc_shortstr_to_ansistr
movl%eax,-48(%ebp)
movl-48(%ebp),%eax
callFPC_ANSISTR_INCR_REF
movl$U_P$S_A,%eax
callFPC_ANSISTR_DECR_REF
movl-48(%ebp),%eax
movl%eax,U_P$S_A

You see... with StrPas, the pchar is first converted to a short string.


Is safe that will not change to a simple pointer cast in future?


This will break compatebility.


Does it copy the string content?


Yes, its the same code as assigning directly

# [12] s := String(p);
leal-48(%ebp),%eax
callFPC_ANSISTR_DECR_REF
movl$0,-48(%ebp)
movlU_P$S_P,%eax
callfpc_pchar_to_ansistr
movl%eax,-48(%ebp)
movl-48(%ebp),%eax
callFPC_ANSISTR_INCR_REF
movl$U_P$S_A,%eax
callFPC_ANSISTR_DECR_REF
movl-48(%ebp),%eax
movl%eax,U_P$S_A



Thanks.

This info is useful

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] RSS for the subversion repository

2008-01-06 Thread Luiz Americo Pereira Camara

Damien Gerard wrote:


It seems the RSS for the subversion repository does not work anymore 
since the 07/12/26.

(http://www.freepascal.org/feeds/lazarussvn.rss)
I have got a 404 not found.

It is really usefull :)

May be has it been moved somewhere else ?



Try this link 
http://cia.vc/stats/project/lazarus/.rss?ver=2medium=xhtmllimit=100


It provides more useful headers for my taste.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New homepage and documentation for TSqlite3Dataset

2007-12-20 Thread Luiz Americo Pereira Camara

Damien Gerard wrote:


On Dec 20, 2007, at 12:14 AM, Luiz Americo Pereira Camara wrote:


Damien Gerard wrote:


On Dec 19, 2007, at 9:23 PM, Luiz Americo Pereira Camara wrote:

I updated the sqlite4fpc homepage adding documentation and some 
tutorials.


As a bonus i also added some features.

See http://www.geocities.com/camara_luiz/



Under Ubuntu :
 May be
 $ sudo apt-get install libsqlite3-dev
 is enough.

Under Mac OS X:
 There are several ways to do it. May be the most simple in a first 
time would be :

 $ sudo port install sqlite3


I forgot to mention : For this method MacPort is required 
(http://www.macports.org/)
For people who use fink under OS X I think sudo apt-get install 
libsqlite3-dev is good too but wait for a confirmation.


I will need to make a standalone app which use sqlite (without deps on 
MacPorts or Fink). At this moment I can send you the way to do it.




Please, when you get this info, send me a text explaining how to install 
sqlite on MacOSX, i will put in the page.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] New homepage and documentation for TSqlite3Dataset

2007-12-19 Thread Luiz Americo Pereira Camara

I updated the sqlite4fpc homepage adding documentation and some tutorials.

As a bonus i also added some features.

See http://www.geocities.com/camara_luiz/

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New homepage and documentation for TSqlite3Dataset

2007-12-19 Thread Luiz Americo Pereira Camara

Damien Gerard wrote:


On Dec 19, 2007, at 9:23 PM, Luiz Americo Pereira Camara wrote:

I updated the sqlite4fpc homepage adding documentation and some 
tutorials.


As a bonus i also added some features.

See http://www.geocities.com/camara_luiz/



Under Ubuntu :
  May be
  $ sudo apt-get install libsqlite3-dev
  is enough.

Under Mac OS X:
  There are several ways to do it. May be the most simple in a first 
time would be :

  $ sudo port install sqlite3



Thanks. I'll update this section.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Class to store pointer values indexed by pointers

2007-12-08 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Fri, 07 Dec 2007 22:52:29 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  
I need a class that stores a pointer value indexed by a pointer. It 
should provide a way to retrieve the value using the indexed value.

I know TMap from Maps unit.

There's another class that comes with fpc/lazarus?



unit avglvltree TPointerToPointerTree

  


BTW: i found the TAVLTree/AVL_Tree unit in fpc code base. It's similar 
to TAvgLvlTree/AvgLvlTree found in LCL (even the author is the same = 
Mattias)


Is there any reason to not use the fpc (TAVLTree) version like being 
buggy or with less performance?


I would prefer using fpc to avoid LCL dependency.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Class to store pointer values indexed by pointers

2007-12-07 Thread Luiz Americo Pereira Camara
I need a class that stores a pointer value indexed by a pointer. It 
should provide a way to retrieve the value using the indexed value.

I know TMap from Maps unit.

There's another class that comes with fpc/lazarus?

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Class to store pointer values indexed by pointers

2007-12-07 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Fri, 07 Dec 2007 22:52:29 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  
I need a class that stores a pointer value indexed by a pointer. It 
should provide a way to retrieve the value using the indexed value.

I know TMap from Maps unit.

There's another class that comes with fpc/lazarus?



unit avglvltree TPointerToPointerTree

  


Many thanks.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] New bitmap :-)

2007-12-06 Thread Luiz Americo Pereira Camara

Paul Ishenin wrote:

wile64 wrote:


I may be stupid but what is the difference between TPageControl and 
TNoteBook exactly ?
TNoteBook is some obsoleted win 3.1 control. In current lazarus 
implementation TNotebook has about the same implementation as 
TPageControl. All difference is in how pages can be accessed and in 
way of controlling visibility of Tabs. In TNoteBook tabs (top part of 
control) can be totally visible or invisible. In TPageControl you can 
control visibility of separate tabs.




I can make separated tabs invisible by using TPage.TabVisible when using 
TNotebook here. (At least in win32)


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 datetime and timestamp

2007-12-03 Thread Luiz Americo Pereira Camara

Luca Olivetti wrote:

En/na Roberto Padovani ha escrit:


When the project I'm working on is finished, I'll strip everything
from the source code and only leave a detailed tutorial for using
sqlite without visual components.


FWIW to do that you can also use sqlite3 directly (or with a thin 
wrapper), you don't have the convenience of a full dataset descendant 
but you have complete control on what you get from the database.




BTW: I wrote a thin wrapper to sqlite3. See 
https://luipack.bountysource.com/svn/!tree/185#svn0_4|svn0_4_9


Is not in a release state yet. I'll release together with the documentation.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 datetime and timestamp

2007-12-03 Thread Luiz Americo Pereira Camara

Roberto Padovani wrote:

Now, about assumptions.

in sqlite3ds there is the assumption that BOOLEAN fields are stored as
1 or 0. In fact, to recover a db that had TRUE and FALSE, I made a
new class where I changed ftBool to fString. In this way I could read
them, parse them and then write them back as 1 or 0.

With the dates, the problem is similar, because sqlite3ds understands
that the field is of type DATE, and so it makes the following
assumption in customsqliteds.pas line 603:

ftFloat,ftDateTime,ftTime,ftDate,ftCurrency:
  begin
Val(StrPas(FieldRow),Double(Buffer^),ValError);
Result:= ValError = 0;
  end;

  


True. It stores both in memory and in database the Double value.


In the database I have, the dates are in the ISO standard form
2007-12-03 12:11:10.1234
How do you suggest me to handle with them ?
1) by complicating the SQL queries with SELECT date(field_name) as
field_name FROM... which turns the field_name into a string in the
result set
  


Possible


2) by subclassing or anyway changing the TFieldType ?
  


Difficult


3) like with boolean, by making a special temporary class that parses
the whole database (not so big) and changes the dates into
Freepascal-style doubles (are they stored more efficiently ?)
  


I already started such tool. Not ready yet. Good if is one step eg you 
won't access that file every time.



4) other (please specify :-))

  


Modify the sqlite3ds or create a TSqlite3Dataset descendant that:

1) Recognize a TIMESTAMP field
2) Stores the field value as a string in the desired format
3) When the data is loaded convert from string to double
4) When do ApplyUpdates convert from Double to String


I can do that.


My brain-storming last night came up with the idea of adding a flag
that says force every field as a string: this would let someone who
doesn't know which convention was used in which field to inspect it.
Is it somewhat crazy ?

  


It's more difficult than above, but possible.


By the way, I really like sqlite and the unit you made to access it.
  


Good

When the project I'm working on is finished, I'll strip everything
from the source code and only leave a detailed tutorial for using
sqlite without visual components. 

Good.

Meanwhile, I read somewhere in the
mailing that you are writing a documentation for sqlite3ds; is it
ready or partially ready ?
  


Partially ready. This is really needed because there's a lot of 
undocumented features and some feature misuses (like using QuickQuery 
for execute a SQL)
I'll be busy until 15/12. After that i will work on a solution for this 
case, finish the documentation, work in improvements in sqliteds and 
release a new sqlite3 wrapper.

I'll contact you.

I'm studying the whole code at the moment and some documentation would
help a lot, especially to see the global structure, to get the large
picture of it. Moreover, I'm going to keep on working a lot with
sqlite, so if some contribution is needed somewhere, let me know.
  

Fine. The documentation is a place that needs work.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] SQLite 3 datetime and timestamp

2007-12-02 Thread Luiz Americo Pereira Camara

Roberto Padovani wrote:

Hi all!

two things: 1) a (possible) improvement to sqlite3ds; 2) the old
problem with dates and time

1) I found a sqlite database that uses the TIMESTAMP data type, but
this is not directly supported by the Tsqlite3Dataset written by Luiz.
I added the if-else checks in sqlite3ds.pas for this type, which
refers to ftTimestamp of TFieldType in db.pas. And I also added
db.DefaultFieldClasses[ftTimeStamp] := TDateTimeField at run-time,
because in db.pas it is defined as nil (and I didn't want to recompile
it).
So, now my app can understand a timestamp field as a TDateTime instead
of a string...

2)and here comes the problem! The code:

var d: TDateTime;
..
d := database.FieldByName('birthday').asDateTime;
...
will always store the zero date: 30 Dec 1899
why ?
  


It's necessary to see the changes you made.
To add a new type is necessary to modify InternalInitFieldDefs, 
GetFieldData and SetFieldData



Being urgent, at the moment I am reading the dates as strings by using
the date or datetime function of SQLite in the query, i.e.:

SELECT date(birthday) AS string_birthday FROM people;

and then parsing them with the powerful functions in the freepascal
RTL, but I would like to understand this once for all.
  


Here's how sqlite works (for good and bad):

- You can create tables with any field type: TIMESTAMP, TIME_STAMP, 
QWERTY etc
- In any of this field type you can store anything: a integer, a 
float, a string


Many sqlite managers make assumptions (each one create its own 
convention). Examples:

BOOLEAN will store TRUE or FALSE strings,
DATE will store 02-12-2007.
This is completely random.

So program X can store DATE as 02-12-2007 but program Y will store as 
02/12/2007. The program Z, worried with memory stores as 02122007 
but program W is more smart so will store as 021207.


Supporting these conventions it would lead to code bloat and performance 
issues and someone would always ask hey my DATE format is not 
supported, please do it.


In other words, sqliteds, as it was designed, has the objective of add a 
way to fpc programs to use sqlite as a database backend. So it does. It 
was not designed for access data files created with other managers or 
frameworks.
See as a balance between feature and code size/performance. Any design 
taken has advantages and disadvantages. In the sqliteds case, the 
decision was to trend to code simplicity, privilege the most common 
cases in detriment of not so common.


If you come until here, don't be pessimist. Some solutions:

- Don't forget is open source. You can modify to fill your needs. I can 
help with this. Send what you already did.
- If you don't want to modify sqliteds file directly you can write 
descendants.
- Try sqlitepass and sqldb/sqlite3. I vaguely remenber of sqlitepass to 
support timestamp. I don't know about sqldb.
- If you just want to import the data of a strange db file (you won't 
need to access directly this file all time) than convert to the sqliteds 
format (Double). I already started a program that does this but not 
finished. I can also help you.



Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Lazarus v0.9.25 r13078M with gtk 2 (screen flicker)

2007-11-30 Thread Luiz Americo Pereira Camara

Graeme Geldenhuys wrote:

Hi,

I haven't tried Lazarus compiled with GTK2 in months and thought I
would give it a go.  Compiling went fine.  Running Lazarus though, the
screens (any dialog windows I open) redraw quite slow.
Also scrolling the editor window up or down with the mouse causes
serious flicker on the text.

I double checked the About box to see if there is any newly added
epilepsy or seizure warning text. ;-)  Couldn't find any, so I guess
it's a software defect.  Other GTK2 based apps like Gimp, Thunderbird,
Firefox do not have this behaviour.
  


Maybe because double buffer is disabled?

Search for  gtk_widget_set_double_buffered in gtk intf folder

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Tips for lazarus projects and Subversion

2007-11-22 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Thu, 22 Nov 2007 11:51:36 +0100
Luca Olivetti [EMAIL PROTECTED] wrote:

  

En/na Mattias Gaertner ha escrit:



.lfm files: no
.lrs files: it depends. It is recommended to keep them.
  

Why? Cannot they be automatically generated from the lfm?



And I forgot:
lrs files are normally in the source directories, which can be
readonly, so the IDE can not create them.

  


In subversion case this is not valid since you assume its writeable.

I had some headaches after adding lrs to svn repositories. Definitely i 
don't add lrs and lps files to my svn repositories.


I created a bug report about the lpi file changes: 
http://www.freepascal.org/mantis/view.php?id=10238


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Tips for lazarus projects and Subversion

2007-11-22 Thread Luiz Americo Pereira Camara

Damien Gerard wrote:
I had some headaches after adding lrs to svn repositories. Definitely 
i don't add lrs and lps files to my svn repositories.




I agree with lps due to it contains about the session. So it should be 
added into a repository.

Like .res and now I have nice commits.
And I don't have any problems with lrs. 


If you are fine keeping them so there's no need to change.


What's wrong with them ?


I ended in a situation where i got streaming exceptions. I don't know 
how to reproduce it.


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Tips for lazarus projects and Subversion

2007-11-21 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Damien Gerard schreef:


I use SVn with my projects in lazarus.

I added the file project.lpi. This file is sent nearly at each commit 
and always provides conflicts with others team members.
However I believe the file is needed due to there are some settings 
for the project.


Is there a way to avoid this ?


Do you store session information in a different file (.lps). Don't add 
this file to svn. See project options - Session.


Another problem i face is that when you open a project saved in Win32 in 
a Linux machine the lpi file is changed because of the PathDelim even if 
you don't change the project options. The inverse (Linux  win32) is 
also true.

This leads to unnecessary file commits.

From some time i always check the changes in lpi files to see if worth 
commiting


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: Fw: Re[2]: [lazarus] Plots

2007-11-20 Thread Luiz Americo Pereira Camara

Vasily I. Volchenko wrote:

Thanks. This is a good start.

Luiz

-Original Message-
From: Vasily I. Volchenko [EMAIL PROTECTED]
To: Luiz Americo Pereira Camara [EMAIL PROTECTED]
Date: Tue, 20 Nov 2007 17:44:51 +0300
Subject: Re[2]: [lazarus] Plots

  

Hi,

Thanks, i got the packages and successfully compiled. But i did not find 
example of how to use it.


Can you post some small examples?

Luiz

  

Presently it is quite difficult for me (as I am at work). As far as I remember, 
there are the following rules:
1. TCustomPlot:
simple plotting control. You need to make a set of points, and them will be 
connected with line. Points should be set via Points property, which is a 
decendent of TStrings. So, in program you need to set points[i].x and points.y. 
In ObjectInspector you may edit it as a stringlist, each line is a point in 
format x:y, where x and y are float falues.
XMin,XMax,YMin,YMax - float properties for setting plot borders. Alternatively 
you may set AutoSizeX and/or AutoSizeY to true, so all points must be shown.
HasMarks means whether axes have a marks (float numbers). NMarksX and NMarksY 
shows how many such marks will be at the correspondend axis. XSpacer and 
YSpacer means how many space (in pixels) are left for float marks. XMarkDigits, 
YMarkDigits,XMarkDecimals, YMarkDecimals are about formatting the values.
2. TFunctionPlot:
Almost the same (it can work the such way), but a new event (OnFunctionCall) is 
defined. You should write a function body in it, like
begin
y=sin(x);
end;
Nothing more. Besides, AutoSizeX means nothing while plotting functions, you 
should set MinX and MaxX.
Property DividingTabs means how many points will be used to tabulate (and then 
draw) the function.

Wiki and examples will be tomorrow. Surface3d too.

Sorry for my terrible English. This is because all mathematical courses (from 
the beginning school's mathemathics to mathematical modelling in post graduate) 
were in Russian, and technical English doesn't include mathematics.




_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


  


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Recent gtk CreatePatternBrush implementation

2007-11-14 Thread Luiz Americo Pereira Camara

@Paul

Recently, landed in svn an implementation of CreatePatternBrush for gtk.
I'd like to point that for some time a patch fixing the creation of 
pattern brushes through CreateBrushIndirect is available in mantis (see: 
http://www.freepascal.org/mantis/view.php?id=8814)


It has some advantages over the recent addition:

1) Fix the more generic function (CreateBrushIndirect), so if the user 
try to create a bitmap pattern using a TBrushLog will not get an error. 
In fact, based in my tests, it seems that win32.CreatePatternBrush is 
just a wrapper around CreateBrushIndirect


2) Works both for monochrome as well to color bitmaps/pixmaps. In the 
svn will work only for monochrome


3) Implementing CreatePatternBrush is as simple as:

function CreatePatternBrush(hbmp:HBITMAP):HBRUSH;
var
 Log: TLogBrush;
begin
 with Log do
 begin
   lbColor := 0;
   lbHatch := hbmp;
   lbStyle := BS_PATTERN;
   Result := CreateBrushIndirect(Log);
 end;
end;

Obs: recently gtkobject.inc file got renamed, so the patch will not 
apply without manual edit. I will update it as soon as possible


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Recent gtk CreatePatternBrush implementation

2007-11-14 Thread Luiz Americo Pereira Camara

Paul Ishenin wrote:

Luiz Americo Pereira Camara wrote:

function CreatePatternBrush(hbmp:HBITMAP):HBRUSH;
var
 Log: TLogBrush;
begin
 with Log do
 begin
   lbColor := 0;
   lbHatch := hbmp;
   lbStyle := BS_PATTERN;
   Result := CreateBrushIndirect(Log);
 end;
end;
I warry in this case about DIBs, but for other widgetsets than windows 
I can use indeed CreateBrushIndirect.



Yes. In windows case there's a native CreatePatternBrush that already 
sets the lbHatch (BS_PATTERN/BS_DIBPATTERN) according to bitmap type. So 
no need to use this simplified version.


This example, in fact, was to be used by other widgetsets (similar to 
what i did in LCLExtensions package)


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] I need examples of SQLite

2007-11-04 Thread Luiz Americo Pereira Camara

Daniel Rincón García wrote:

I am trying to execute the examples but I obtain the next errors:

http://i12.tinypic.com/526id0j.jpg

http://i15.tinypic.com/2lmrm9t.jpg http://i15.tinypic.com/2lmrm9t.jpg

http://i2.tinypic.com/536k4l5.jpg

http://i9.tinypic.com/6g8t7ur.jpg

What is the problem?


This occurs when you try to open a non db file.

Do you translated to sqlite3ds?

Do you also changed dumpdata.pas to use sqlite3ds?

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] I need examples of SQLite

2007-11-04 Thread Luiz Americo Pereira Camara

Daniel Rincón García wrote:
Yes, I translated to sqlite3ds. The sqliteminimal example works 
correctly but the 3dcompare example do not works.


I did not change dumpdata.pas to use sqlite3ds.

How I do it?


replace TSqliteDataset  by TSqlite3Dataset and sqliteds by sqlite3ds

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Multiple targets

2007-11-02 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Fri, 02 Nov 2007 13:56:31 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  

2)Make units packages/projects optional according to widgetset.
Concrete situation: LCL extensions package has a unit (OleUtils) that 
implements TOLEStream. It only makes sense in win32. Currently the

unit is added in all widgetsets but all code is wrapped around a
ifdef Windows define so is seen as a dummy unit in other widgetsets.

Let me know the wiki address to add these cases



http://wiki.lazarus.freepascal.org/Conditional_Compiler_Options

  


Thanks.
You also saved me from adding these cases ;-) . Thanks again.

About the notes  you added in the second case:

# All units should be added to the package, independent if they are 
used. If they not always used, you can already check the flag.
If i uncheck the uses unit flag that unit will not be compiled in none 
cases. Nor in win32 (where is needed) neither in the other systems.


# The above example is about windows. That has nothing to do with the 
widgetset. The qt and gtk2 widgetsets are also running under windows.

Ok

# You can put units specific to targets into sub directories as 
demonstrated in the Lazarus and FPC sources.
I already did that. I created a units/win32 dir with OleUtils.pas inside 
and put units\$(TargetOS)\ in Other Units path but the unit is not 
compiled even in win32. See modified package source attached.


# There is no real need for conditional options for units
Maybe there's already a solution to this case and i'm missing something.

Luiz

?xml version=1.0?
CONFIG
  Package Version=3
PathDelim Value=\/
Name Value=lclextensions_package/
Author Value=Luiz Americo Pereira Camara/
CompilerOptions
  Version Value=5/
  PathDelim Value=\/
  SearchPaths
IncludeFiles Value=include\$(LCLWidgetType)\/
OtherUnitFiles Value=units\$(TargetOS)\/
UnitOutputDirectory Value=lib\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)/
  /SearchPaths
  CodeGeneration
Generate Value=Faster/
  /CodeGeneration
  Other
CompilerPath Value=$(CompPath)/
  /Other
/CompilerOptions
Description Value=LCL Extensions provides additional functions to be used together with LCL
/
License Value=Modified LGPL
/
Version Minor=2/
Files Count=2
  Item1
Filename Value=delphicompat.pas/
UnitName Value=DelphiCompat/
  /Item1
  Item2
Filename Value=lclext.pas/
UnitName Value=LclExt/
  /Item2
/Files
Type Value=RunAndDesignTime/
RequiredPkgs Count=1
  Item1
PackageName Value=LCL/
  /Item1
/RequiredPkgs
UsageOptions
  UnitPath Value=$(PkgOutDir)\/
/UsageOptions
PublishOptions
  Version Value=2/
  DestinationDirectory Value=$(TestDir)\publishedpackage\/
  IgnoreBinaries Value=False/
/PublishOptions
  /Package
/CONFIG


Re: [lazarus] Multiple targets

2007-11-02 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

# There is no real need for conditional options for units
Maybe there's already a solution to this case and i'm missing something.


In fact, i already found a workaround that i implemented in another 
package. I added a dummy unit to the package that  uses the required 
units by OS something like:


{$ifdef windows}
Uses
 WinUnits;
{$endif}
{$ifdef unix}
Uses
 UnixUnits;
{$endif}

WinUnits and UnixUnits are not used i the package but are i  the 
unit search path of the package


With this trick, WinUnits is compiled only under windows and 
UnixUnits under unixes.


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Multiple targets

2007-11-02 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Fri, 02 Nov 2007 18:59:26 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  

Luiz Americo Pereira Camara wrote:


# There is no real need for conditional options for units
Maybe there's already a solution to this case and i'm missing
something.
  
In fact, i already found a workaround that i implemented in another 
package. I added a dummy unit to the package that  uses the required 
units by OS something like:


{$ifdef windows}
Uses
  WinUnits;
{$endif}
{$ifdef unix}
Uses
  UnixUnits;
{$endif}

WinUnits and UnixUnits are not used i the package but are i  the 
unit search path of the package


With this trick, WinUnits is compiled only under windows and 
UnixUnits under unixes.



It's no trick - it's pascal.
The IDE will never get that flexible. That's why I think, this case
does not need any special IDE magic.
  
Yes. I'm fine with this workaround but this has a side effect (maybe 
just a bug in IDE/Debugger):

- I use a unit inside units\$(LCLWidgetType)\
- This unit is compiled for all widgetsets/oses (no problem here)
- The codetools find this file
- A breakpoint is set in that unit
- When the breakpoint is hit the debugger ask for the location of that unit

PS: The cited package is the virtualtreeview-unstable and the unit is 
virtualpanningwindow


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Multiple targets

2007-11-02 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Fri, 02 Nov 2007 21:53:52 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  

Luiz Americo Pereira Camara wrote:


 The VirtualTreeView package is a lot big, even when zipped. I'll
try to create a smaller dummy package and will send to you.
  

I managed to create a very small example (package + project). Here it
is.

The breakpoint is set inside the ChildUnitProc.



Thanks. Fixed.

  

Many thanks.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Drawing Strategy in Carbon Lazarus

2007-10-11 Thread Luiz Americo Pereira Camara

James Chandler Jr wrote:

Hi Giuliano

The Carbon Lazarus works great with invalidate and the OnPaint events, 
as far as I've been able to tell. Mac double-buffering on the screen 
well-guarantees no flicker. And it is true that invalidate can be 
called multiple times before the event loop gets around to calling 
OnPaint.


But there is an expense with the double-buffering and 'delayed 
flush'-- Sometimes this circuitous route involving many messages, can 
cause 'slightly slow' screen updates. If an OnPaint does a lot of 
drawing and calculating (which sometimes can't be done in advance), 
the new screen draw appears very quick and clean onscreen, but there 
is some latency where nothing happens on the screen, before this quick 
clean change suddenly appears.




You can invalidate only the area that needs update using 
LCLIntf.InvalidateRect. Then you can get the update rect using the 
TLMPaint message. With this you can speed the drawing but will require a 
more sophisticated algorithm  to define what to draw.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] IDE, start once, open files

2007-09-12 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

https://svn.bountysource.com/luipack/trunk/uniqueinstance

If someone knows a way to hook in LCL message loop to be called more 
frequently than OnIdle or wants to implement a separeted thread i'm 
accepting patches.



Contrary to windows there are far less messages under linux/gtk so the
OnIdle is not called for long periods, when you work in another program.
Unless you start a TTimer.
  


Thnks for the tip. This worked.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] IDE, start once, open files

2007-09-11 Thread Luiz Americo Pereira Camara

Luca Olivetti wrote:

En/na Mattias Gärtner ha escrit:
Is there already a cross platform component for applications to check 
if it is
already running and if yes then pass some commands to the already 
application?


For example clicking on files in the file browser should not open a 
second

instance, but tell the already running instance to open the files.


There's uniqueinstance
http://sourceforge.net/project/shownotes.php?group_id=92177release_id=471823 

(The wiki is down, so I cannot give you the wiki link) *but* it 
doesn't work here under Linux (I could launch more that one instance 
of my program).
Since I hadn't too much time to debug it, I slightly modified it to 
open and lock a file instead of using TSimpleIpc, but that makes it 
non-crossplatform.
Since it's short I'm including it here, it could be extended to write 
the pid in the file, so another instance can somewhat contact the 
first one.


It's working here both under win32 and linux (testraw and testcomponent 
programs). Using fpc 220, Ubuntu Feisty Faw, recent lazarus svn.


The only missing feature under linux is the parameter list passing:
Under windows the SimpleIpc mechanism is integrated with the win32 
message loop so the IPCServer.OnMessage is called without any further 
intervention.
Under unix, SimpleIpc is not integrated with any message loop so 
IPCServer.OnMessage is not called.

There are to ways of doing under unix:
 - Hook in the LCL message loop to call PeakMessage
 - Create a thread that will call PeakMessage at a time interval

In the below address you will find an updated component that hooks in 
Application.OnIdle to call PeakMessage. Its far from optimal because 
will prevent the use of OnIdle by the programmer and the parameter list 
will be peaked only when the app is idle/has focus.


https://svn.bountysource.com/luipack/trunk/uniqueinstance

If someone knows a way to hook in LCL message loop to be called more 
frequently than OnIdle or wants to implement a separeted thread i'm 
accepting patches.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] IDE, start once, open files

2007-09-11 Thread Luiz Americo Pereira Camara

Luca Olivetti wrote:

En/na Luiz Americo Pereira Camara ha escrit:

It's working here both under win32 and linux (testraw and 
testcomponent programs). Using fpc 220, Ubuntu Feisty Faw, recent 
lazarus svn.


I assure you that I could lauch various copies of my program. I used 
fpc 2.0.4, maybe that's the problem. I only used uniqueinstanceraw, 
since it's a daemon, not a gui app.


Did you tested the testraw program that comes bundled with the package? 
Although it uses a Lazarus app, the pattern usage can be transported to 
a non gui app straightforward.


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Lazarus on one window (aka SDI)

2007-09-11 Thread Luiz Americo Pereira Camara

Graeme Geldenhuys wrote:

It is SO bad that I have gotten in the habit of using a dedicated
virtual desktop just for Lazarus. I would definitely be in favor of a
single window design.



Someone else that thinks like I do. I actually use 4 virtual desktops.
One for Lazarus, Firefox, Mozilla and a spare for things like VMWare.
  


We are three. I also use one exclusive virtual desktop for Lazarus.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Advanced unit dependency tree tool

2007-09-10 Thread Luiz Americo Pereira Camara
I'm looking for a tool that builds a complete unit dependency tree for 
object pascal. By complete i mean that not only the info unit1 uses 
unit2 is given but also the functions used . Something like unit1 uses 
functions foo and bar from unit2.


The tool can be for Delphi or Lazarus

Any help is appreciated

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Performance of 24bit bitmap in 32bit color display

2007-09-02 Thread Luiz Americo Pereira Camara
In a recent thread i discussed with Marc the alpha bitmap design, and 
was pointed that would be no performance penalty if a 24bit bitmap is 
used in a 32bit color display since the number of bytes per pixel would 
be equal. Initially i agreed but i found that this info is incorrect.


A 24bit bitmap uses 4bytes/pixel (in average) in some sizes (1,2,3 
pixels) to fill the dword boundary. When the dword boundary is filled 
with 3bytes/pixel (4 pixels), it will use 3 bytes/pixel, in other 
situations (5 pixels) the bytes/pixel is not constant. So a bitmap with 
1,2,3 pixels will have the same size using 24bit or 32bit (4,8,12 
bytes), a 4 pixels bitmap will use 12 bytes and 16 bytes respectively, a 
5 pixels bitmap will have 16 and 20 bytes.


I also tested the performance of such issue.  A program that bitblt 1000 
times a 200x200 bitmap in a 32bit color display give the results below 
(an 77% overhead over 32bit bitmap). Attached is a program (used fpc 
214, XP SP2, celeron D 1.4 512MB). In the other side 24bit bitmaps use 
less memory.


Although i disagree with the design/solution (using a 24bit bitmap by 
default in 32bit color display), that has performance issues and other 
side effects, the bitmap support improved with recent changes and i wont 
question this issue anymore, as the current LCL code.


The info here is just for clarify a misconception.

PS: with the recent changes (using CreateDIBSection to create the 
bitmap) alpha blend in VTV under win32 i near ;-) .


Luiz


Bench24bit.rar
Description: Binary data

TChronoLog results - 2/9/2007 21:28:14
Session: 24bit first
Results (6):  microsec milisec seconds
-   ---   -   -
0 - 24bit   263.699 264   0
1 - 24bit   263.957 264   0
2 - 24bit   262.954 263   0
3 - 32bit   148.656 149   0
4 - 32bit   148.796 149   0
5 - 32bit   148.833 149   0

Accumulated (Miliseconds):1.237


TChronoLog results - 2/9/2007 21:28:30
Session: 32bit first
Results (6):  microsec milisec seconds
-   ---   -   -
0 - 32bit   149.329 149   0
1 - 32bit   149.110 149   0
2 - 32bit   148.376 148   0
3 - 24bit   263.509 264   0
4 - 24bit   263.677 264   0
5 - 24bit   264.157 264   0

Accumulated (Miliseconds):1.238


TChronoLog results - 2/9/2007 21:28:54
Session: Alternate
Results (6):  microsec milisec seconds
-   ---   -   -
0 - 24bit   264.219 264   0
1 - 32bit   148.475 148   0
2 - 24bit   264.444 264   0
3 - 32bit   148.353 148   0
4 - 24bit   264.141 264   0
5 - 32bit   149.036 149   0

Accumulated (Miliseconds):1.239


Re: [lazarus] TBitmap performance after alpha channel support (Was:Graphics dont work)

2007-08-30 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Luiz Americo Pereira Camara wrote:
The problem is that StretchMaskBlt is calling AlphaBlend and somehow 
this is not working.


It seems that TBitmap will have alpha channel by default (or at least 
LCL recognizes as having) when running in a display with 32bit color 
under win32.


Looking at StretchMaskBlt (the function used by TBitmap to draw) when 
a bitmap has alpha (checks if has 32bit depth), each time is draw an 
extra bitmap is created and also some other extra calls.


I don't think we need alpha channel by default when using TBitmap to 
e.g temporarily draw before sending to the canvas. Maybe a property 
could be added to enable alpha support at TBitmap level (when reading 
a file or when the user requires it). Another option is to split 
StretchMaskBlt



This will be fixed. By default a bitmap should be 24bpp when 32bpp is 
available. There was a fix, but at the wrong place. So I removed 
removed it when fixing 9501


This solution would bring another performance penalty, when using 32bit 
color display, since each time a BitBlt/StretchBlt is called a color 
conversion (three times when using mask) will be done.
It also breaks the PixelFormat = pfDevice (the default) idea of having 
the most suitable/faster pixel format depending of the display/device.


My idea is to let the higher levels (TBitmap/LazIntfImage) decides if 
will use Alpha or not:


- Create a StrechAlphaBlt function to use the alpha channel. Let 
StretchMaskBlt to handle masked and not transparent bitmaps.
- If an image with alpha channel is loaded or if the user explicitly 
requires, an UseAlpha flag is set
- When a draw is done if UseAlpha is set, use StretchAlphaBlt 
otherwise StretchMaskBlt


This has some advantages:

- The higher levels (TBitmap/LazIntfImage) will be flexible/able to 
handle any format

- TBitmap will use by default the faster pixel format in 32bit color display
- The lower levels functions will be optimized. This would reduce the 
size/complexity of StretchMaskBlt helping in the maintainability/code 
quality since it will not be a handle all function


What the core developers think?



BTW, a TBitmap has already such property. No need to add another one :)

Half of the way ;-)

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap performance after alpha channel support (Was:Graphics dont work)

2007-08-30 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:
This solution would bring another performance penalty, when using 
32bit color display, since each time a BitBlt/StretchBlt is called a 
color conversion (three times when using mask) will be done.
It also breaks the PixelFormat = pfDevice (the default) idea of 
having the most suitable/faster pixel format depending of the 
display/device.


yes there will be some differences. there is no penalty between 24 or 
32 bpp. (except what we introduce)



OK
My idea is to let the higher levels (TBitmap/LazIntfImage) decides if 
will use Alpha or not:

[..]


I don't want to use different functions between alpha and non alpha.
IMO, the current vcl/windows implementation is completely alpha 
unaware. I want to avoid that.
So blitting an alpha image will use alpha, blitting a non alpha image 
no alpha. The Usealpha flag is implicit. It has no meaning for 
nonalpha images.



[..]
- The lower levels functions will be optimized. This would reduce the 
size/complexity of StretchMaskBlt helping in the maintainability/code 
quality since it will not be a handle all function


Now there is one function, otherwise you have to maintain 2.



It will be two smaller functions with a more specific design dealing 
with fewer variables. Currently StretchMaskBlt handles Mask presence, 
Alpha presence, Stretch need giving 8 possiblites.


Bugs can be fixed independently. Today fixing a bug in mask support can 
break alpha support and vice versa.


It will increase granularity of the api keeping it really low level:
Think of a developer that wants to work with bitmaps in low level using 
32bit format but don't want/need to setup the alpha channel. If he calls 
StretchMaskBlt, currently, the alpha channel (with garbage data) will be 
always used leading to wrong display. There's no way to overcome this. 
With the two functions design he can chooses the appropriate functions.


In the end if a handle all function is desired in winapi level (i 
still think should be in higher levels and is not necessary in low 
level) create a function of type if haschannel do call channel function 
else call non channel function


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap performance after alpha channel support (Was:Graphics dont work)

2007-08-30 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:


- The lower levels functions will be optimized. This would reduce 
the size/complexity of StretchMaskBlt helping in the 
maintainability/code quality since it will not be a handle all function


Now there is one function, otherwise you have to maintain 2.





I forgot to say that it will not be necessary to add code to convert 
from 32bit - 24bit and not necessary to rework the 
CreateCompatibleBitmap and CreateDIBSection functions (with 
unpredictable  consequences/bugs). And maybe other changes should be 
necessary.


In the end, the one function handles all approach will need much more 
code to debug/maintain.


Also the old StretchMaskBlt function has already been tested widely, 
being necessary to debug mostly the alpha enabled function


It will be two smaller functions with a more specific design dealing 
with fewer variables. Currently StretchMaskBlt handles Mask presence, 
Alpha presence, Stretch need giving 8 possiblites.


Bugs can be fixed independently. Today fixing a bug in mask support 
can break alpha support and vice versa.


It will increase granularity of the api keeping it really low level:
Think of a developer that wants to work with bitmaps in low level 
using 32bit format but don't want/need to setup the alpha channel. If 
he calls StretchMaskBlt, currently, the alpha channel (with garbage 
data) will be always used leading to wrong display. There's no way to 
overcome this. With the two functions design he can chooses the 
appropriate functions.


In the end if a handle all function is desired in winapi level (i 
still think should be in higher levels and is not necessary in low 
level) create a function of type if haschannel do call channel 
function else call non channel function




Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Graphics dont work

2007-08-29 Thread Luiz Americo Pereira Camara

wile64 wrote:
2007/8/29, Luiz Americo Pereira Camara [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]:


wile64 wrote:
 example :

 FImagePaint is a TBitmap create with
 FImagePaint := TBitmap.Create;

Try to define the height and width of the bitmap



I repeat that all worked before the 27/08/2007, the size is well defined!


I'm just trying to help.

I isolated the problem.

The problem is that StretchMaskBlt is calling AlphaBlend and somehow 
this is not working.


Below is an excerpt of a LCL program with a TPaintBox, if BitBlt is 
called then works fine, StretchMaskBlt shows nothing:


var
 FImagePaint: TBitmap;
begin
 FImagePaint := TBitmap.Create;
 FImagePaint.Width := PaintBox1.Width;
 FImagePaint.Height := PaintBox1.Height;
 with FImagePaint.Canvas do
 begin
   Brush.Color := clWhite;
   Brush.Style := bsSolid;
   Pen.Color := clBlack;
   Rectangle(0, 0, FImagePaint.Width, FImagePaint.Height);
 end;
 with FImagePaint do
   //BitBlt(PaintBox1.Canvas.Handle, 0 ,0, Width, Height, 
Canvas.Handle, 0,0, SRCCOPY);
   StretchMaskBlt(PaintBox1.Canvas.Handle, 0 ,0, Width, Height, 
Canvas.Handle, 0,0,Width, Height,0,0,0,0);

 FImagePaint.Free;
end;


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap performance after alpha channel support (Was:Graphics dont work)

2007-08-29 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:
The problem is that StretchMaskBlt is calling AlphaBlend and somehow 
this is not working.


It seems that TBitmap will have alpha channel by default (or at least 
LCL recognizes as having) when running in a display with 32bit color 
under win32.


Looking at StretchMaskBlt (the function used by TBitmap to draw) when a 
bitmap has alpha (checks if has 32bit depth), each time is draw an extra 
bitmap is created and also some other extra calls.


I don't think we need alpha channel by default when using TBitmap to e.g 
temporarily draw before sending to the canvas. Maybe a property could be 
added to enable alpha support at TBitmap level (when reading a file or 
when the user requires it). Another option is to split StretchMaskBlt


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Graphics dont work

2007-08-28 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

wile64 wrote:

Hello,

I create an bitmap and draw with functions RoundRect, Rectangle, 
FillRect, TextRect, Ellipse, CopyRect.


After install snapshot Lazarus-0.9.23-fpc-2.0.4-20070827 dont work in 
win32, work in gtk and gtk2.

with Lazarus-0.9.23-fpc-2.0.4-20070809 work ok...


:(
This might be caused by the fix for 9501. I knew the original code 
fixed something, ANyway I'll have a look.


I dont think the problem is with the fix, unless if he is calling 
CreateBitmap directly (probably he is using TBitmap). An example is welcome.


WidgetSet.CreateBitmap, which was changed, is not used in LCL and 
TBitmap uses RawImage functions that in your time uses CreateDIBSection


Probably related to bug 9512

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Broken SVN

2007-08-26 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Christian U. wrote:
TLazInfImage dont support AutoCreateMask anymore in actual SVN wich 
breaks the Virtualtrees Support.


Also no transparency works in any Lazarus Image Type


I can confirm this.
I reported two bugs: 9501 and 9502


9501 is fixed in r11865.
This fix might have some sideeffect when drawing on a 32bpp bitmap.


Under Delphi and win32, CreateBitmap is used mainly for monochrome 
bitmaps (although is possible to create color bitmaps with it, the 
recommended functions are CreateCompatibleBitmap and CreateDIBSection). 
So no loss here, is a know limitation.


9502 is due to wrong detection of common contols version. When you add 
a manifest, yuor images will be drawn transparent.



Also the Build Lazarus dialog is broken


We (Vincent, Paul and I) cannot reproduce that, do you have a 
screenshot ?

Yes,  the radio buttons are not show.

Also i noticed that the identifier completion list is blank, when you 
scroll you can see some itens



Using fpc 214, XP SP2, lazarus svn 11865. Compiled with comand line 
(make clean all)


Luiz




inline: bitmap_bug.jpg

Re: [lazarus] Problem developing TCustomLabel descendant (and change proposition)

2007-08-16 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Tue, 07 Aug 2007 14:12:19 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  
As a change to a properly implementation i would propose to add a 
virtual method (DoMeasureTextPosition) to retrieve the TextLeft and 
TextTop values (see TCustomLabel.Paint). The default implementation

is equal to the current code in .Paint (I simplified a bit assuming
that R.Top and R.Left = 0, R.Bottom = Height)

The patch is attached.



Thanks. Applied.

  


Thanks for applying, Mattias.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Release of two new controls (TToggleLabel, TMenuButton)

2007-08-12 Thread Luiz Americo Pereira Camara

Today i released two open source LCL controls:

TToggleLabel: a label that can switch between two states with visual 
feedback (similar to what gtk has)
TMenuButton: a SpeedButton that integrates with a PopupMenu. I found 
similar controls in Firefox, Eclipse based apps (RSSOwl beta), camtasia 
studio


Screencast: http://www.geocities.com/camara_luiz/luicontrolsdemo.zip
More Info: http://wiki.lazarus.freepascal.org/Lui_Controls
Download: https://luipack.bountysource.com/

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Problems with TListView (Win32)

2007-08-04 Thread Luiz Americo Pereira Camara

Razvan Adrian Bogdan wrote:

I feel ListView isn't completed (other controls have issues too but
not that much), at least under gtk i get warnings about things, i was
wondering if VirtualTreeView might do the job, last time i checked it
had painting issues, like header not being painted. 


Try the version found in https://luipack.bountysource.com/. These 
problems are solved.


it's possible to mimetic a TListView setting some properties. See the 
dataarray demo or the grid example of the advanced demo. The later is 
found only in svn.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Problems with TListView (Win32)

2007-08-04 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Razvan Adrian Bogdan wrote:

I feel ListView isn't completed (other controls have issues too but
not that much), at least under gtk i get warnings about things, i was
wondering if VirtualTreeView might do the job, last time i checked it
had painting issues, like header not being painted. 


Try the version found in https://luipack.bountysource.com/. These 
problems are solved.


it's possible to mimetic a TListView setting some properties. See the 
dataarray demo or the grid example of the advanced demo. The later is 
found only in svn.


For owner draw examples see objects and images demos

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Working on my components again

2007-07-21 Thread Luiz Americo Pereira Camara

Tony Maro wrote:
I got a Google Alert that said someone was having trouble finding my 
components for Lazarus.  I changed my blog software and never finished 
migrating all my old links over.


I've just thrown up the first page that posts my tmpack of components:

http://tony.maro.net/ossramblings/tmpack.php

It's been slightly modified since the old version, mostly to be 
compatible with the latest Lazarus.  I have _not_ tested every 
component under the latest Lazarus yet, so there may be issues.


I'll be putting up the rest of my stuff soon.  The original files are 
all still there, but there's no links on my site for downloading them yet.



Hi, congratulations.

As a suggestion it would be fine if you put your components in 
Lazarus-CCR svn repository 
(http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/ ) 
or other svn repository. This help to keep track of the progress.


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Unicode support and fonts

2007-07-16 Thread Luiz Americo Pereira Camara

Felipe Monteiro de Carvalho wrote:

On 7/16/07, ik [EMAIL PROTECTED] wrote:

Have you set the font family to unicode ?
Default font families are usually latin1 (or your system setting).


And how can I set that? (never heard about this)
Use the Font dialog component to select a font and set its return value 
to the Font property of the control.


You must have a unicode font installed. I know MS Unicode arial that 
comes with office 2003, but there also some ones free. Search in google


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Working with XML: crosscompatibility

2007-07-04 Thread Luiz Americo Pereira Camara

Alvise Nicoletti wrote:

Luiz Americo Pereira Camara ha scritto:

Alvise Nicoletti wrote:

Hi...

I have to parse xml both with Lazarus on linux (server) and Delphi 
on Windows (client).


Actually, with Lazarus, I'm using the DOM, ReadXML, WriteXML units.

Is there something that I can use in Delphi with the same code? Or, 
otherwise, is there some XML component compatible for both Delphi 
and Lazarus?




Some time ago i ported the fpc dom unit to delphi. It was just a 
matter of changing the places of const sections, no change was made 
at all, if i remenber well. I can send to you but is a bit outdated. 
A better option is to try to compile the most recent fpc dom version, 
probably will be easy.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives




Hi, can you give me some tips about that cross compilation thing ?



It seems is not more necessary. See Sergei message.
Just get the source from svn or fpc 2.1.4 and compile the units with Delphi

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Virtual Treeview port preview release

2007-07-01 Thread Luiz Americo Pereira Camara
Today i released a preview release of the new port of Virtual Treeview 
based in version 4.5.1 for those that want to test it.


For info about the port, how install, know issues see 
https://luipack.bountysource.com/wiki/virtualtreeview .


Feel free to do bug reports.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Virtual Treeview port preview release

2007-07-01 Thread Luiz Americo Pereira Camara

zeljko wrote:

On Sunday 01 July 2007 13:56, Luiz Americo Pereira Camara wrote:
  

Today i released a preview release of the new port of Virtual Treeview
based in version 4.5.1 for those that want to test it.

For info about the port, how install, know issues see
https://luipack.bountysource.com/wiki/virtualtreeview .

Feel free to do bug reports.



what is exactly missing in qt interface to get qt port useable ? 
  
1) implement some functions of delphicompat unit (LCL extensions 
package) in qt. The utf-16 function (*W) should be pretty simple.  
GetBkColor, GetCurrentObject also should be simple. KillTimer and 
SetTimer can take more work. Anyway you can base on what is done in gtk. 
Others are really not necessary for basic work


2) test. i don't have a qt4 environment setup

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Working with XML: crosscompatibility

2007-06-28 Thread Luiz Americo Pereira Camara

Alvise Nicoletti wrote:

Hi...

I have to parse xml both with Lazarus on linux (server) and Delphi on 
Windows (client).


Actually, with Lazarus, I'm using the DOM, ReadXML, WriteXML units.

Is there something that I can use in Delphi with the same code? Or, 
otherwise, is there some XML component compatible for both Delphi and 
Lazarus?




Some time ago i ported the fpc dom unit to delphi. It was just a matter 
of changing the places of const sections, no change was made at all, if 
i remenber well. I can send to you but is a bit outdated. A better 
option is to try to compile the most recent fpc dom version, probably 
will be easy.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Useless code in win32intf?

2007-06-18 Thread Luiz Americo Pereira Camara
Maybe i missed something but what's the meaning of the following code, 
found in win32callback.inc:710


if lWinControl.ClassName = 'TPairSplitter' then
P := P;


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] win32 snapshots with gdb 6.6

2007-06-18 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Hi,

I want to inform you that since a couple of days, the lazarus snapshots come 
with gdb 6.6 instead of gdb 6.0.
  


Are you using the binary found in 
http://sourceforge.net/project/showfiles.php?group_id=2435package_id=82724release_id=190586 
?


I use the svn and would like to know if i am using the same binary as 
the snapshot/releases.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Combo.OnClick

2007-06-18 Thread Luiz Americo Pereira Camara

Joao Morais wrote:
OnClick doesn't mean exactly a click, you have OnMouseDown to 
accompish this. OnClick means that the user sent information to the 
control, and this doesn't happen when he open a combo (not usually).


Did you tried OnSelect?

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] sqlite components

2007-06-14 Thread Luiz Americo Pereira Camara

Luca Olivetti wrote:

En/na Luiz Americo Pereira Camara ha escrit:


See as a balance between features/code size.


Sure, that's a good trade off. One has just to know the peculiarities 
of this dataset and where it diverges from the standard dataset 
behaviour (btw: why did you implement a method RefetchData instead of 
using Refresh?)
It has a different meaning. The problem is the lack of documentation. I 
already started the documentation but is not finished yet.




Anyway, for more featured, you can use ZeosLib which is by far the 
most complete database layer in fpc or even SqlitePass that has more 
options.


No, I'm actually after something rather lightweight (I won't be using 
dbgrids, I won't even have a user interface), so for this project I'll 
probably use sqlite3ds now that I know what are its strengths and 
weaknesses.

Besides, zeoslib has a nasty memory leak with sqlite.

It seems that the leak is with all backends and a specific fpc version 
does not leak as i read in a fpc list post


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] sqlite components

2007-06-11 Thread Luiz Americo Pereira Camara

Luca Olivetti wrote:

Hello,
I'm writing an embedded application that will need a small database 
(no more than a couple thousand records), and  I though sqlite could 
do it.
It probably won't have any graphical interface, so I don't need all 
the goodies of a TDataset descendant, OTOH I like some other things a 
dataset will buy me.
Needless to say, the application must be rock solid, running 
unattended 24/7.
I made a quick test with the sqlite3ds component that's included in 
lazarus and with SQLitePass http://source.online.free.fr/
I dropped either dataset in a form with a datasource and a dbgrid (as 
suggested in the wiki).
My first impression (and as every first impression may just be wrong) 
is tha sqlite3ds doesn't work well with a dbgrid, because it doesn't 
automatically update the underlying database and so it doesn't catches 
exceptions when you, e.g, try to insert a duplicate. What's worse, 
when I call ApplyUpdates it silently discards the data (I would have 
expected at least an exception, but I see that there's no exception 
raised and neither an event is called in case of errors in 
TCustomSqliteDataset.ApplyUpdates).

The behavior is by design (follows KISS philosophy).

- Update on post: sqliteds keeps the records in memory, works with them 
(add,update,delete) and than send the changes to the database when the 
user decides (more or less like sqldb). To update the database each time 
a change occurs add ApplyUpdates in the OnPost event.


- ApplyUpdates error handling: Error is handled just does not follows 
the exception model. Check if ApplyUpdates is false. If so check 
ReturnCode (see sqlite docs for values) and ReturnString values.


- Primary key handling: sqliteds automatically handles primary key in 
two ways. First add a AutoInc field to the table (Using 
FieldDefs.Add/CreateTable) and sqliteds will ensure it will always be 
unique and not null without user intervention. Second, if you have a 
integer field as primary key set AutoIncrementKey to true and PrimaryKey 
to the field name.

If the primary key is not integer the user must handle it yourself.
SQLitePass seems more solid (again, only with this simple test), since 
it automatically updates the database and raises an exception 
immediately if I try to insert a duplicate key. OTOH it raises a 
RunError(204) when I close the form.


Pros of sqlite3ds:
- included in lazarus
- author active on this mailing list
- ...?

Cons of sqlite3ds:
- incomplete (?) implementation

Sure.

- doesn't really check errors

See above.

- ...?

- Undocumented features (to be fixed soon)

PS: I would recommend version from fpc 214 which has a lot of bug fixes.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Store a utf-16 file in a lazarus resource file

2007-05-25 Thread Luiz Americo Pereira Camara

Paul Ishenin wrote:

Luiz Americo Pereira Camara wrote:
I want to store a utf-16 encoded file in a Lazarus resource file and 
than load  as a Stream.


I already did the first step (create the lrs file with lazres) now i 
want to load the file in a stream.

Does someone know how i can do that?


maybe so:

function GetResourceStream(ResourceName: String): TStream;
var
  Res: TLResource;
begin
  Res := LazarusResources.Find(ResourceName);
  if (Res  nil) and (Res.Value  '') then
  begin
Result := TMemoryStream.Create;
ResultWrite(Res.Value[1], length(Res.Value));
ResultPosition := 0;
  end;
end;


Thanks.

Its working

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Store a utf-16 file in a lazarus resource file

2007-05-24 Thread Luiz Americo Pereira Camara
I want to store a utf-16 encoded file in a Lazarus resource file and 
than load  as a Stream.


I already did the first step (create the lrs file with lazres) now i 
want to load the file in a stream.

Does someone know how i can do that?

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] ANN: Release of ATBinHex port

2007-05-19 Thread Luiz Americo Pereira Camara

Today i released the first version of ATBinHex LCL port.

ATBinHex (see original component 
http://atorg.net.ru/delphi/atbinhex.htm) is a viewer that can be view a 
file in Ansi, Binary, HEX and Unicode (UTF-16LE) modes.


More info and download at https://luipack.bountysource.com/

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: Object Inspector crash, and other interesting stuff

2007-05-16 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:



I have tested this more thoroughly now. I have just had a complete
crash of IDE after bringing up the colors list in the OI and
scrolling from the last in the list (upon opening) to the first. The
screen froze momentarily and then the IDE closed.



Hmm. This works here.
  

Here also i got this same problem

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: Object Inspector crash, and other interesting stuff

2007-05-16 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Mattias Gaertner wrote:



I have tested this more thoroughly now. I have just had a complete
crash of IDE after bringing up the colors list in the OI and
scrolling from the last in the list (upon opening) to the first. The
screen froze momentarily and then the IDE closed.



Hmm. This works here.
  

Here also i got this same problem

Using kubuntu feist + fpc204 + recent svn

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Printer.Canvas.TextStyle.Alignment=taRightJustify = Argument can't be assigned to

2007-05-16 Thread Luiz Americo Pereira Camara

Burkhard Carstens wrote:

Am Mittwoch, 16. Mai 2007 16:35 schrieb fedorax:
  

Hello,

I just make a new svn update and i've a little problem:

using:
Printer.Canvas.TextStyle.Alignment=taRightJustify;
return this error:
cheques.pas(210,35) Error: Argument can't be assigned to

Did something change or is it a bug ?



This is not a bug. It is caused by a change in fpc. Assignments to 
fields of structured properties are not allowed anymore (since r7250). 
e.g.: 
property prop : trec read frec; 
instance.prop.a:=5;
  

I hope this will be optional at least

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] execute multiple sql statements

2007-05-14 Thread Luiz Americo Pereira Camara

tanila wrote:

hello all,
is it possible to execute multiple sql statement with TSQLite3Dataset ?
I tried to create a sqlite database with multiple tables.
The SQL File looks like this:

create table if not exists users
(USR_ID integer auto_increment primary key,
 USR_NAME VARCHAR(30) not null,
 USR_SURENAME VARCHAR(30) not null,
 USR_HEIGHT integer not null,
 USR_SEX varchar(1) not null,
 USR_BIRTHDATE date not null);

create table if not exists groups
(GRP_ID integer auto_increment primary key,
 GRP_NAME VARCHAR(30) not null);

create table if not exists activities
(ACT_ID integer auto_increment primary key,
 ACT_NAME VARCHAR(30) not null);

Only the first table has been created.
Do I have to create every table seperately ?
  
No. You can use the SQLList property (a TStringList). You can do 
something like:


 Sqlite3Dataset.SqlList.Clear;
 Sqlite3Dataset.SqlList.Add('Sql1');
 Sqlite3Dataset.SqlList.Add('Sql2');
 Sqlite3Dataset.ExecSqlList;

if the script is in a file do

 Sqlite3Dataset.SqlList.LoadFromFile('x');
 Sqlite3Dataset.ExecSqlList;

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Possible typo in GTKDialogRealizeCB

2007-04-13 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Luiz Americo Pereira Camara schreef:

In the cited function (gtkcallback.inc) there's a dead code:

 if (Data=nil) then ;   


I haven't looked at the code, but sometimes this constructs are used 
to suppress 'parameter Data not used' hints.


You are right. Such code is everywhere in this unit.

The long term solution would be a fpc option or directive to disable 
such hints.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Possible typo in GTKDialogRealizeCB

2007-04-13 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Felipe Monteiro de Carvalho schreef:

On 4/13/07, Vincent Snijders [EMAIL PROTECTED] wrote:

I haven't looked at the code, but sometimes this constructs are used to
suppress 'parameter Data not used' hints.


Is supressing a hint really that important that we need useless code?



Use svn blame to see who committed that code and ask the question to 
that persion.


Most of the code were committed by Mattias. Seeing the amount of such 
code i understand why it was done. In the other side makes the code bigger.


I added a feature wish to fpc bug tracker ( 
http://www.freepascal.org/mantis/view.php?id=8690 ), so maybe in the 
future this code can be removed.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Possible typo in GTKDialogRealizeCB

2007-04-12 Thread Luiz Americo Pereira Camara

In the cited function (gtkcallback.inc) there's a dead code:

 if (Data=nil) then ;


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] History of the widget set design?

2007-04-02 Thread Luiz Americo Pereira Camara

Micha Nelissen wrote:

Burkhard Carstens wrote:
  
However, with win32/gtk LCL this is even worse... seems like one never 
knows, whether an event was fired before or after ..



These are all bugs. The developer interface should be as consistent as
possible, yet the look and feel for the user as native as possible.
Problem is that the order of events is not documented (since they are
delphi internals), and we should do this as we go along; this requires
some discipline however.

The wiki could be a good place to store these events plus their
relationship to programmer and user actions. It would make porting to a
new platform a lot easier as well.

  
I agree that documenting the LCL behavior is a good thing and could 
improve the Lazarus quality. As a example if a Delphi feature  is not 
doable in LCL, just document  and show an alternative (like done for 
TBitmap.Scanline).


Another point is defining the set of features/controls provided by LCL:

- Is necessary TCListBox?
- Is already deprecated in GTK and TListView fills the function 
with advantages

- Is necessary TPairSplitter?
   - AFAIK it was introduced only because TSplitter was not available
   - It could be implemented as a package
- Should non visual code like *CriticalSection functions be in LCL?
  - SyncObjs already exists and can be used in a more elegant way
  - Imagine the pain to implement them in a crossplatform widgetset 
like QT, fpGUI, or even GTK2?


Removing the unnecessary, duplicate functions/components, not doable 
features would help in the development and maintenance of Lazarus, not 
to say the code size.


Of course this could not be done immediately, would be something after a 
1.0 release with 2.0 in mind.



Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] History of the widget set design?

2007-04-02 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

An example of a widgetset that looks good is eLiquid from Pixel editor.
In this interview ( 
http://www.linuxinterviews.com/index.php?option=com_contenttask=viewid=14Itemid=2 
) the Pixel developer considered Open Source eLiquid. The main concern 
was documentation. If this occurs would be of great value to fpc/Lazarus 
community.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Document editing (doc, rtf) and/or interfacing with external editors

2007-03-29 Thread Luiz Americo Pereira Camara

Razvan Adrian Bogdan wrote:

On 3/29/07, Florian Klaempfl [EMAIL PROTECTED] wrote:

Razvan Adrian Bogdan schrieb:
 Win only is enough for now but Lazarus doesn't support ActiveX (COM)

It does?


Florian i don't understand what you mean, does Laz have an ActiveX
importer of some sort that i don't know of ?
It's possible to use ActiveX under windows using fpc/Lazarus. I have an 
example app that does OLE drag and drop.


Some remarks:
 - Unlike Delphi, Lazarus does not provides ActiveX components so you 
have to import then at hand, using the ole32 functions (found in ActiveX 
unit)
 - The ActiveX unit that comes with fpc204 has wrong calling 
convention. Fixed in trunk/2.2


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Document editing (doc, rtf) and/or interfacing with external editors

2007-03-29 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Razvan Adrian Bogdan wrote:

On 3/29/07, Florian Klaempfl [EMAIL PROTECTED] wrote:

Razvan Adrian Bogdan schrieb:
 Win only is enough for now but Lazarus doesn't support ActiveX (COM)

It does?


Florian i don't understand what you mean, does Laz have an ActiveX
importer of some sort that i don't know of ?
It's possible to use ActiveX under windows using fpc/Lazarus. I have 
an example app that does OLE drag and drop.


Some remarks:
 - Unlike Delphi, Lazarus does not provides ActiveX components so you 
have to import then at hand, using the ole32 functions (found in 
ActiveX unit)
 - The ActiveX unit that comes with fpc204 has wrong calling 
convention. Fixed in trunk/2.2
You should be aware of some differences to Delphi unit also. See: 
http://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg07205.html


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] AllocateHWnd

2007-03-14 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Felipe Monteiro de Carvalho schreef:

On 3/13/07, Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:
Just one tip maybe would be better to dereference PMethod after 
assigned

check in the Callback proc


Ok, didn´t think about it.

Reattaching the patch, which this fixed. Now I tested with both nil
and non-nil methods.



IMHO Self.SetWindowLong is not so nice looking, SetWindowLong looks 
better.


To be on the safe side, I would always call SetWindowLong for 
GWL_USERDATA, if the method is nil, you can decide if you want to set 
it to 0 (nil) or to PMethod pointer referencing a nil method.



I would suggest this too.

In the current implementation would be 0.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] AllocateHWnd

2007-03-13 Thread Luiz Americo Pereira Camara

Felipe Monteiro de Carvalho wrote:

Forgot to attach the patch =)

Just one tip maybe would be better to dereference PMethod after assigned 
check in the Callback proc


 Method := PMethod^; //- if PMethod is nil there would be problems

 if Assigned(PMethod) then
   Method(Msg)


as alternative you can skip one assignment (Method copy):

// Method := PMethod^; delete this
 if Assigned(PMethod) then
   PMethod^(Msg)

PS: not tested.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] AllocateHWnd

2007-03-13 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

One thing I noted is that on Delphi, the WndProc will normally have a
call to DefWindowProc, and this is obviously Windows only. So, to keep
compatibility with Delphi, every WndProc used with AllocateHWnd would
need to have a IFDEF Windows, with a call to DefWindowProc inside.


Why? I think you have called DefWindowProc already in 
CallbackAllocateHWnd.

No, he is calling DefWindowProc only when Pmethod  is not assigned

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] AllocateHWnd

2007-03-13 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Felipe Monteiro de Carvalho wrote:

Forgot to attach the patch =)

Just one tip maybe would be better to dereference PMethod after 
assigned check in the Callback proc


 Method := PMethod^; //- if PMethod is nil there would be problems

 if Assigned(PMethod) then
   Method(Msg)

Did you tested passing Method as nil in AllocateHwnd ? In this case you 
can get an access violation here, since PMethod would point to nil.

Maybe was a typo and you mean Assigned(Method) instead of Assigned(PMethod)?

In this case the code below does not make sense

Luiz


as alternative you can skip one assignment (Method copy):

// Method := PMethod^; delete this
 if Assigned(PMethod) then
   PMethod^(Msg)

PS: not tested.

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives



_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Patch - Small Cleanup and Possible bug

2007-03-10 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

Probably should be like that:

 aStyle := gtk_widget_get_style(Widget);
 if aStyle=nil then
 begin
 aStyle := GetStyle(lgsButton);
 If aStyle = nil then
   aStyle := GetStyle(lgsGTK_Default);
end;



Applied for readability.
  

Thanks.

Speaking in readability, another thing that should be done is to follow 
a unique coding style for Lazarus source. Different capitalizations of 
reserved words (if, var etc), same times in the same code, is the most 
frequent issue. In the wiki points that we should follow the Borland 
Coding Styles but there's no link at all.


I found two: http://dn.codegear.com/article/10280 (original)  
http://homepages.borland.com/jedi/jvcl/StyleGuide.htm (jvcl)

I added the original to the wiki.

Maybe we can discuss here at least a minimum denominator so who 
contributes new or revised code can follow it


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Code Readability [Was: Patch - Small Cleanup and Possible bug]

2007-03-10 Thread Luiz Americo Pereira Camara

Luiz Americo Pereira Camara wrote:

Mattias Gaertner wrote:

Probably should be like that:

 aStyle := gtk_widget_get_style(Widget);
 if aStyle=nil then
 begin
 aStyle := GetStyle(lgsButton);
 If aStyle = nil then
   aStyle := GetStyle(lgsGTK_Default);
end;



Applied for readability.
  

Thanks.

Speaking in readability, another thing that should be done is to 
follow a unique coding style for Lazarus source. Different 
capitalizations of reserved words (if, var etc), same times in the 
same code, is the most frequent issue. In the wiki points that we 
should follow the Borland Coding Styles but there's no link at all.


I found two: http://dn.codegear.com/article/10280 (original)  
http://homepages.borland.com/jedi/jvcl/StyleGuide.htm (jvcl)

I added the original to the wiki.

Maybe we can discuss here at least a minimum denominator so who 
contributes new or revised code can follow it

To be more precise, define some critical points here like:

- Capitalization of reserved words
- space between =:=
- Capitalization of nil
- Capitalization of functions and variables

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Patch - Small Cleanup and Possible bug

2007-03-06 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Luiz Americo Pereira Camara schreef:

1 - Attached patch remove some redundant checks in gtk intf.

2 - Some lines above (in TGtkWidgetSet.DrawFrameControl)  there's 
this code:


  aStyle := gtk_widget_get_style(Widget);
   if aStyle=nil then
 aStyle := GetStyle(lgsButton);
   If aStyle = nil then
  aStyle := GetStyle(lgsGTK_Default);


aStyle is checked for nil twice. Maybe a typo. I would suggest 
something like that (based in what the other code does - not sure if 
is the correct sequence):


   if gtk_widget_get_style(Widget) = nil then
 aStyle := GetStyle(lgsButton)
  else
  aStyle := GetStyle(lgsGTK_Default);


There is an important difference:
Are you sure that GetStyle(lgsButton) always returns a non-nil value?
The code  below would be the equivalent without redundant checks.

if gtk_widget_get_style(Widget) = nil then
  begin
 aStyle := GetStyle(lgsButton)
 If aStyle = nil then
aStyle := GetStyle(lgsGTK_Default);
  end;
I was assuming the second check was aStyle  nil just like in DrawCheck 
(maybe the DrawCheck should be modified to behave like DrawButtonPush? 
or the contrary?). Assuming that is a equal check you are correct.


PS: I dont know what is the correct sequence. I just could not resist 
and refactored the code. (Note that the second point is not in the patch 
and that the changes in the patch does not alter the code flow - be 
buggy or not ;-))


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Patch - Small Cleanup and Possible bug

2007-03-06 Thread Luiz Americo Pereira Camara

Sergei Gorelkin wrote:

Tuesday, March 06, 2007, 10:14:10 PM, Luiz wrote:

LAPC Vincent Snijders wrote:
  

Luiz Americo Pereira Camara schreef:
  

1 - Attached patch remove some redundant checks in gtk intf.

2 - Some lines above (in TGtkWidgetSet.DrawFrameControl)  there's 
this code:


  aStyle := gtk_widget_get_style(Widget);
   if aStyle=nil then
 aStyle := GetStyle(lgsButton);
   If aStyle = nil then
  aStyle := GetStyle(lgsGTK_Default);


aStyle is checked for nil twice. Maybe a typo. I would suggest 
something like that (based in what the other code does - not sure if 
is the correct sequence):


   if gtk_widget_get_style(Widget) = nil then
 aStyle := GetStyle(lgsButton)
  else
  aStyle := GetStyle(lgsGTK_Default);


There is an important difference:
Are you sure that GetStyle(lgsButton) always returns a non-nil value?
The code  below would be the equivalent without redundant checks.

if gtk_widget_get_style(Widget) = nil then
  begin
 aStyle := GetStyle(lgsButton)
 If aStyle = nil then
aStyle := GetStyle(lgsGTK_Default);
  end;
  
LAPC I was assuming the second check was aStyle  nil just like in DrawCheck 
LAPC (maybe the DrawCheck should be modified to behave like DrawButtonPush? 
LAPC or the contrary?). Assuming that is a equal check you are correct.


LAPC PS: I dont know what is the correct sequence. I just could not resist 
LAPC and refactored the code. (Note that the second point is not in the patch 
LAPC and that the changes in the patch does not alter the code flow - be 
LAPC buggy or not ;-))


LAPC Luiz

Umm... It looks like the proposed change is even more significant. The
original code may be interpreted like this:
Try to use individual style assigned to the widget;
if that fails, use the default style for buttons;
if even that fails, use GTK default style for any widget.

Both versions of modified code, however, completely ignore widget's individual
style and always use a default style - for either button or for any widget.
  
You are correct. The pretext i used was wrong (I assumed there was a 
typo - and maybe the typo is in DrawCheck code). See above.


Probably should be like that:

aStyle := gtk_widget_get_style(Widget);
if aStyle=nil then
begin
aStyle := GetStyle(lgsButton);
If aStyle = nil then
  aStyle := GetStyle(lgsGTK_Default);
end;

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Deleting ListBox items

2007-03-05 Thread Luiz Americo Pereira Camara

Arí Ricardo Ody wrote:
I have a ListBox with four Items(for example). Suppose third item 
selected (ListBox1.Items [2]).



When I run the method showed below program has different behavior:


In windows it deletes the ListBox1.Items [2] (as expected). After the 
end of method execution, ListBox1 has three Items;



In Linux it deletes the ListBox1.Items [2], ListBox1.Items [1] and

ListBox1.Items [0]. After the end of method execution, ListBox1 will 
have one Item;



Should this be a bug? Or am I doing something wrong in the linux version?


The method mentioned above is:


procedure TForm1.ListBox1(Sender: TObject; var Key: char);

var i : integer;

begin

  if (Key  #13) and (Key  #32) then
 Exit;

  if ListBox1.SelCount = 0 then // No ítens selected
 Exit;

  For i := ListBox1.Items.Count - 1 downto 0 do
if ListBox1.Selected [i] then
 ListBox1.Items.Delete (i);
end;
What version are you using? After 0.9.20 there was a change that should 
fix this.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] compiling sqlite3laz package

2007-03-02 Thread Luiz Americo Pereira Camara

tanila wrote:

hello all,

i have the following message compiling sqlite3laz-package:

/home/tanila/lazarus/components/sqlite/sqlitecomponenteditor.pas(179,52)
Error: Illegal type conversion: enumeration type to TObject

  

This code is ugly and i plan to rewrite ASAP.

As a workaround try to do the following (not tested):

TObject(PtrInt(FieldDefs[i].DataType))

The source looks good, but the type-casting seems not to work, I think.

I am using lazarus SVN (rev. 10703) and fpc 2.1.1 (svn)
  

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] [lazarus-dev] TCanvas.Rectangle

2007-02-15 Thread Luiz Americo Pereira Camara

Vicnent Snijders wrote:

Hi,

A bug was reported that TCanvas.Rectangle is incompatible to Delphi, but
somebody suggested that this was rather a Delphi bug.

For the complete story see:
http://www.freepascal.org/mantis/view.php?id=8342

In a note I wrote:
The canvas routines in Delphi are inspired by the winapi for device
contexts. See http://msdn2.microsoft.com/en-gb/library/ms533879.aspx [^]
for the winapi documentation. It states that The rectangle that is
drawn excludes the bottom and right edges.

Somewhere else this is explained as nRightRect-nLeftRect should be
considered as width.

It is an easy to make this method work Delphi compatible by removing the
+1 in TWin32WidgetSet.Rectangle. But I hesitate to do, because I don't
know how many Lazarus code depends on the Delphi incompatibility.

The questions to be answered are:
Should LCLIntf.Rectangle do the same as Windows.Rectangle?
Should TCanvas.Rectangle(0,0,1,1) draw an 1x1 (as Windows.Rectangle
does) rectangle or a 2x2 rectangle (as Lazarus does currently)?
What is the current behavior for other widget sets?

So what do you think?
I'm the person who reported the supposed bug. But after the explanation 
of a peer, i agreed that was a bug/misbehavior of Delphi. So i'm 
favorable as not considerating as a bug but as a difference that 
should be considered when porting a Delphi app. I think that we should 
follow Delphi as close as possible (I'm porting a rather complex Delphi 
software) but when we found that _clearly_ is a bug or misbehavior, or 
cannot be done in a cross platform way, we should be free to do our way 
(what we think is the best way).


As an example, i can cite that i would like to see an GetObject 
crossplatform implemented, but after some research i found that is not 
feasible and there's a need to  do it in another way.


So, in resume, i think that more important than getting the LCL to work 
_exactly_/bit per bit as Delphi/win32 is to document the differences 
between them.


Luiz


_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


[lazarus] Problem to add a component at design time

2007-02-08 Thread Luiz Americo Pereira Camara
I am creating a package that has a design time component. It originally 
used the Resize method to paint the window. After the component is 
dropped an error is given and the component is not added to the form. I 
tried to change from Resize to DoOnResize without success. See callstack 
below:


ERROR in LCL: TWinControl.CreateWnd: no parent :TATBinHex
Creating gdb catchable error:
 $0040EE88  RAISEGDBEXCEPTION,  line 779 of LCLProc.pas
 $0048B418  TWINCONTROL__CREATEWND,  line 5173 of ./include/wincontrol.inc
 $0048B0FF  TWINCONTROL__CREATEHANDLE,  line 5113 of 
./include/wincontrol.inc
 $0048BF48  TWINCONTROL__HANDLENEEDED,  line 5469 of 
./include/wincontrol.inc

 $0048A419  TWINCONTROL__GETHANDLE,  line 4463 of ./include/wincontrol.inc
 $009A1D1F  TATBINHEX__HIDESCROLLBAR,  line 1280 of ATBinHex.pas
 $009A0660  TATBINHEX__REDRAW,  line 1026 of ATBinHex.pas
 $009A22D1  TATBINHEX__DOONRESIZE,  line 1427 of ATBinHex.pas
 $00492718  TCONTROL__RESIZE,  line 2560 of ./include/control.inc
 $009A20A5  TATBINHEX__RESIZE,  line 1369 of ATBinHex.pas 
//TABINHEX.Resize does nothing

 $0048E699  TCONTROL__CHANGEBOUNDS,  line 406 of ./include/control.inc
 $00492ADE  TCONTROL__SETBOUNDS,  line 2662 of ./include/control.inc
 $0048C796  TWINCONTROL__SETBOUNDS,  line 5724 of ./include/wincontrol.inc
 $00495F27  TCONTROL__SETINITIALBOUNDS,  line 3915 of ./include/control.inc
 $004AB0B2  TCUSTOMPANEL__CREATE,  line 44 of ./include/custompanel.inc
 $0099FDC0  TATBINHEX__CREATE,  line 797 of ATBinHex.pas
 $00596C2B  TCUSTOMFORMEDITOR__CREATECOMPONENT,  line 1348 of 
CustomFormEditor.pp
 $0058F856  ADDCOMPONENT,  line 1469 of 
E:/repositories/lazarus/designer/Designer.pp



Since TControl.Resize checks the ComponentState before calling 
DoOnResize, i think that would resolve the problem but is not true. It 
seems that csLoading is not in component state at that time.


So the question is there's a way to check if a TComponent is being 
Created? What the ComponentState just after the call to the constructor?


Thanks in advance

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Behavior of ContextMenu

2007-02-07 Thread Luiz Americo Pereira Camara

Vincent Snijders wrote:

Marc Weustink schreef:
If it was a message we created to handle something ourselves, then I 
see, but in this case an existing, then there is no problem




Thanks, Luiz. I applied the (slightly modified) patch.
Thanks. I was aware of the problem sending a lager record through 
Perform and was waiting for the apply to fix.


I sent a patch (see in bugtracker) that fixes a potential infinite loop, 
see note.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Behavior of ContextMenu

2007-02-06 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:
 

I fixed the double fire of MouseUp event when using right mouse button
under win32. See http://www.freepascal.org/mantis/view.php?id=8276. 
But

one issue remained. If the Shift-F10 key is used both events will be
called: MouseUp and DoContextMenu. I can fix it in two ways:

1) Implementing LM_CONTEXTMENU
2) Using the Dummy field of TLMMouse as a flag (Maybe renaming it?)

What do you think is the better?
Anyone can think of another way?



3) similar to 1, add a IntfContextMenu, which gets called form the
widgetset. IIRC I was discussing this issue with Boguslaw a while ago
The widgetset itself knows best when a contextmenu is shown, so the LCL
doesn't have to figure out which key/mouse combo is responsible for it.
  
Implementing 1 the key handling will be handled by the widgetset and 
not by LCL


Anyway i did not understand how it should work.
What are the advantages over 1?


Only that it skips sending a message. If possible we prefer direct 
calls unless needed for compatibility. 
I can not see another way to the WidgetSet notify the LCL. This message 
is sent from WidgetSet to LCL and not the contrary. The LCL will not 
call the widgetset asking for a response. It's up to the widgetset 
determine when to call the contextmenu. Win32 has hardcorded the 
Shift-F10 key. I don't know the if gtk/qt has one, but it can be easily 
added.


Anyway, i already implemented LM_CONTEXTMENU. It was quite simple, non 
intrusive patch and also compatible with delphi. See my previous email.


Luiz




_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap.ScanLine - API Propose

2007-02-06 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Mon, 05 Feb 2007 09:52:50 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  

Mattias Gaertner wrote:


  - Should i implement GetCurrentObject?



IMO it would be better to improve TBitmap.
  
  

Currently TBitmap uses GetObject, so implementing it will also
benefit TBitmap. I'll take a look and keep you informed.



It uses it, but contrary to the VCL the LCL TBitmap leaves all
implementation details to the widgetset. It uses only parts of the
header information like width and height - the minimum set that works on
all platforms.
We have to extend the tagBitmap record, or replace the GetObject call
in TBitmap with a more platform independent one. IMO the latter would
be better.
  
I did some research in gtk side and found that is not viable to 
implement GetObject for Bitmaps in a crossplatform way.
I found that gtk1  does not provides a direct pointer for a bitmap since 
it fetches the data from the X server (not surprise due to its design). 
I dont know if gtk2, qt does some buffering or whatever


Currently, GetRawImage does copy a image in a buffer. To minimize this i 
think in introduce some functions (the names are dummy) to get the 
direct pointer or the nearest possible:


TBitmapRecord: Info of the Bitmap necessary to process the image + 
Bitmap Data Pointer + Pointer To Private Resource


function GetBitmapData(HBITMAP;var TBitMapRecord, Whatever);
function ReleaseBitmapData(TBitMapRecord);

Under Win32:
  GetBitmapData: will get the Direct pointer through GetObject
  ReleaseBitmapData: Does nothing

Under Gtk
 GetBitmapData: will get the Data Pointer from a PGdKImage created 
through gdk_image_get (No copy to buffer here). Stores the GdkImage in 
Private Resource Field

 ReleaseBitmapData: Releases the GdkImage

With this abstraction we avoid the current copy in gtk (the possible) 
and get a direct pointer in win32 in a transparent way.


Is necessary to define what informations should be fetched (the minimal 
necessary to process the image and also common between the interfaces), 
the functions parameters, returnvalues, see the other interfaces, etc.


BTW: I found a way to simplify/optimize the code  of GetRawImage* under 
win32. I will do some testing and post a patch later.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] Behavior of ContextMenu

2007-02-06 Thread Luiz Americo Pereira Camara

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:

Marc Weustink wrote:

Luiz Americo Pereira Camara wrote:
 
I fixed the double fire of MouseUp event when using right mouse 
button
under win32. See 
http://www.freepascal.org/mantis/view.php?id=8276. But

one issue remained. If the Shift-F10 key is used both events will be
called: MouseUp and DoContextMenu. I can fix it in two ways:

1) Implementing LM_CONTEXTMENU
2) Using the Dummy field of TLMMouse as a flag (Maybe renaming it?)

What do you think is the better?
Anyone can think of another way?



3) similar to 1, add a IntfContextMenu, which gets called form the
widgetset. IIRC I was discussing this issue with Boguslaw a while ago
The widgetset itself knows best when a contextmenu is shown, so 
the LCL
doesn't have to figure out which key/mouse combo is responsible 
for it.
  
Implementing 1 the key handling will be handled by the widgetset 
and not by LCL


Anyway i did not understand how it should work.
What are the advantages over 1?


Only that it skips sending a message. If possible we prefer direct 
calls unless needed for compatibility. 
I can not see another way to the WidgetSet notify the LCL. 


Wincontrol.IntfContextMenu(some_params...)

So it is not a message, but a call

This message is sent from WidgetSet to LCL and not the contrary. The 
LCL will not call the widgetset asking for a response. 


I didn't suggest that.

It's up to the widgetset determine when to call the contextmenu. 
Win32 has hardcorded the Shift-F10 key. I don't know the if gtk/qt 
has one, but it can be easily added.


Anyway, i already implemented LM_CONTEXTMENU. It was quite simple, 
non intrusive patch and also compatible with delphi. See my previous 
email.


Thats not the point, but to repeat:

 Only that it skips sending a message. If possible we prefer direct
 calls unless needed for compatibility.
It was exactly what i said. Implementing the Message you gain Delphi 
compatibility at a low cost. Some components use it. If  for 
compatibility a big LCL change would be necessary i was against also but 
in this case the changes are minimal (in fact there's no new code, it 
was just a refactoring). Its a matter of see if the Delphi compatiblity 
outweigth the additional message. I think yes.


PS: If the majority of the Lazarus developers decide i will implement 
the other way.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap.ScanLine

2007-02-05 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Sun, 04 Feb 2007 22:28:19 -0200
Luiz Americo [EMAIL PROTECTED] wrote:

  

Mattias Gaertner escreveu:


I started a new thread, because this has nothing to do with the
decision QuickDraw or Quartz.


On Sun, 4 Feb 2007 21:21:15 +0100
Pieter Valentijn [EMAIL PROTECTED] wrote:

  
  

Is there is no scanline function in the bitmap object of Lazarus.



No. At the moment you have to use a TLazIntfImage. See below.


  
  

Is there no way we can get access to the raw data?


Short answer: 
Yes, but not platform independent, so it is not part of

TBitmap.

Long answer:
1. The TBitmap properties describe only the WinAPI formats. They are
not enough sufficient for the various image formats of the other
widgetsets. TBitmap needs a TRawImageDescription or a TLazIntfImage.
So, Delphi code using TBitmap.ScanLine must still be extended to
work with the LCL in general.
2. Not every widgetset supports a direct pointer to the image. Some
could be hacked to get it. Some images are not stored in the memory
of the application (e.g. on graphic card or on a remote machine).
Sometimes you can tell the widgetset to move the image into local
memory, but this costs performance.

So, it is possible to add a LCL function to return if a direct image
pointer is available and a second function to return the direct
image pointer plus a TRawImageDescription.
Then we could extend TLazIntfImage: At the moment it always fetches
a copy, which is expensive if you do only small changes. With the
above two functions, it could be extended to work directly on the
original image.

Conclusion: I guess, the LCL TBitmap will never have a ScanLine
function that is Delphi compatible, but we could/should provide more
functions for direct access.
  
  

This leads for some questions:

I am porting a Delphi component that uses the follwowing sequence:

 - Get a HBITMAP with GetCurrentObject(DC, OBJ_BITMAP);
 - Get a TDIBSection with GetObject
 - Uses TDIBSection.dsBm.bmBits to manipulate the image



Use
http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Taking_a_screenshot_of_the_screen

  

Thanks
 
  
The missing function in LCL is GetCurrentObject. Under windows the 
implementation is straighforward. Under gtk is also simple and i was 
thinking of implementing it. 



How do you want to implement it under gtk?


  


Getting TDeviceContext.Current* fields of the DC.

Something like.

 case uObjectType of
 OBJ_BITMAP: Result:= TDeviceContext(DC).CurrentBitmap
etc

Of  course with the usual checks.
But the problem is that under gtk, 
GetObject (for a bitmap) always returns nil in

TDIBSection.dsBm.bmBits not to say that other fields are also not set.

So questions are:
  - Is viable to get this information (TDIBSection) under gtk? and 
others widgetsets?



Every platform has something like it, but incompatible to WinAPI. For
example TDIBSection uses tagBITMAP, which lacks information about
endianess and orientation.

  
But even if TDIBSection does not have complete information i think it 
should be implemented (at least tried) because the LCL provides the 
GetObject function, and if not it should be clearly marked as deprecated 
to avoid problems when converting Delphi code. Anyway, I will look if is 
viable to get the TDIBSection of a bitmap under gtk.


  
  - Should LCL programs rely in GetObject, SelectObject functions for 
cross platform?



No.
  

  - Should i implement GetCurrentObject?



IMO it would be better to improve TBitmap.
  

Ok. But i'd like at least try to find a correct implementation of GetObject

Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap.ScanLine

2007-02-05 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

  - Should i implement GetCurrentObject?



IMO it would be better to improve TBitmap.
  
Currently TBitmap uses GetObject, so implementing it will also benefit 
TBitmap. I'll take a look and keep you informed.


Luiz

_
To unsubscribe: mail [EMAIL PROTECTED] with
   unsubscribe as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TBitmap.ScanLine

2007-02-05 Thread Luiz Americo Pereira Camara

Mattias Gaertner wrote:

On Mon, 05 Feb 2007 09:19:28 -0300
Luiz Americo Pereira Camara [EMAIL PROTECTED] wrote:

  

Mattias Gaertner wrote:


On Sun, 04 Feb 2007 22:28:19 -0200
Luiz Americo [EMAIL PROTECTED] wrote:

  
  

Mattias Gaertner escreveu:



I started a new thread, because this has nothing to do with the
decision QuickDraw or Quartz.


On Sun, 4 Feb 2007 21:21:15 +0100
Pieter Valentijn [EMAIL PROTECTED] wrote:

  
  
  

Is there is no scanline function in the bitmap object of Lazarus.




No. At the moment you have to use a TLazIntfImage. See below.


  
  
  

Is there no way we can get access to the raw data?



Short answer: 
Yes, but not platform independent, so it is not part of

TBitmap.

Long answer:
1. The TBitmap properties describe only the WinAPI formats. They
are not enough sufficient for the various image formats of the
other widgetsets. TBitmap needs a TRawImageDescription or a
TLazIntfImage. So, Delphi code using TBitmap.ScanLine must still
be extended to work with the LCL in general.
2. Not every widgetset supports a direct pointer to the image.
Some could be hacked to get it. Some images are not stored in the
memory of the application (e.g. on graphic card or on a remote
machine). Sometimes you can tell the widgetset to move the image
into local memory, but this costs performance.

So, it is possible to add a LCL function to return if a direct
image pointer is available and a second function to return the
direct image pointer plus a TRawImageDescription.
Then we could extend TLazIntfImage: At the moment it always
fetches a copy, which is expensive if you do only small changes.
With the above two functions, it could be extended to work
directly on the original image.

Conclusion: I guess, the LCL TBitmap will never have a ScanLine
function that is Delphi compatible, but we could/should provide
more functions for direct access.
  
  
  

This leads for some questions:

I am porting a Delphi component that uses the follwowing sequence:

 - Get a HBITMAP with GetCurrentObject(DC, OBJ_BITMAP);
 - Get a TDIBSection with GetObject
 - Uses TDIBSection.dsBm.bmBits to manipulate the image



Use
http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Taking_a_screenshot_of_the_screen

  
  

Thanks

 
  
  
The missing function in LCL is GetCurrentObject. Under windows the 
implementation is straighforward. Under gtk is also simple and i
was thinking of implementing it. 



How do you want to implement it under gtk?


  
  

Getting TDeviceContext.Current* fields of the DC.

Something like.

  case uObjectType of
  OBJ_BITMAP: Result:= TDeviceContext(DC).CurrentBitmap
etc

Of  course with the usual checks.



This gives you the gdk bitmap/image, but how do you get bmBits?


  
bmBits is get in GetObject function. This is the sequence the api is 
supposed to work: you get the the Obj handle through GetCurrentObject 
and than use this handle in GetObject to retrieve the info .  
Implementing GetCurrentObject is not the problem. The problem is find a 
way to implement GetObject.
But the problem is that under gtk, 
GetObject (for a bitmap) always returns nil in

TDIBSection.dsBm.bmBits not to say that other fields are also not
set.

So questions are:
  - Is viable to get this information (TDIBSection) under gtk? and 
others widgetsets?



Every platform has something like it, but incompatible to WinAPI.
For example TDIBSection uses tagBITMAP, which lacks information
about endianess and orientation.

  
  
But even if TDIBSection does not have complete information i think it 
should be implemented (at least tried) because the LCL provides the 
GetObject function, and if not it should be clearly marked as

deprecated to avoid problems when converting Delphi code. Anyway, I
will look if is viable to get the TDIBSection of a bitmap under gtk.



In general: all LCLIntf functions exists only to make porting
Delphi code easier, not to emulate WinAPI. The Wiki mentions several
times, that those functions do not work completely the same as the
WinAPI functions and that they depend on the widgetset.
It is not recommended to use them. We must document for each function,
which parameters are supported.

  
I want to make clear that i dont think that the winapi should be 
emulated in a strict way. What i think that has to be done is 1) Try to 
find a reasonable way to implement the api. 2) If there's no reasonable 
cross platform way of doing so, document it 3) provides a alternate api 
to do the same or at least similar.


In this way, i'm documenting all the differences/problems i'm finding 
while porting from Delphi and making a database of it.

About TDIBSection:
AFAIK this is almost only used by speed optimized code. If we emulate
TDIBSection under other widgetsets, they will be slow and hence not
usable.
  
Agree. I still

  1   2   >