Re: [Lazarus] mbox mail format conversion to SQL database

2009-04-06 Thread David W Noon
On Mon, 2009-04-06 at 16:26 +0200, Graeme Geldenhuys wrote:

> I'm about to tackle this project. It seems that the mbox mail format
> is quite simple. But to save myself some time... if anybody knows of a
> tool that can convert mbox mail into SQL database tables that would be
> great.

There is a MDA called dbmail that uses PostgreSQL or MySQL as its
storage back-end. You can import messages into it using your favourite
MUA (e.g. KMail, Evolution, M$ Lookout) and it will store them using
dbmail's POP3 or IMAP4 interface.

In fact, dbmail is so good I use it as my main mailserver. I use a
PostgreSQL database for the back-end.

[AFAIAA, dbmail runs only on POSIX platforms (Linux, FreeBSD, etc.), so
if you need to run it on Windows you could be SOL.]

Of course, other RDBMS's could pose a problem, as only PostgreSQL and
MySQL are supported. However, you could use some generic export tool to
extract the data from dbmail's tables to transfer the data to another
DBMS.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Controlling DPI

2009-03-28 Thread David W Noon
On Sat, 2009-03-28 at 23:30 +0100, Hans-Peter Diettrich wrote:

> David W Noon schrieb:
> 
> >> Windows allows to change the font size (DPI) at any time, and most other 
> >> systems have similar capabilities. Since Delphi has its roots in 
> >> Windows, this definition also should apply to FPC/Lazarus.
> > 
> > The *point size* of the font has nothing whatsoever to do with the DPI
> > of the screen or printer, other than the rendering engine querying the
> > DPI of the device in order to render the text to the appropriate size in
> > pica points.
> 
> Right. The application provides a font size, and the system translates 
> it into pixels, based on the Screen.DPI value.

Specifically, the font engine uses the DPI provided by the video (or
printer) driver. The application doesn't need to consider the DPI value,
as fonts are specified in points and the font engine renders them
appropriately. For example, a 12-point font should render to 1/6th of an
inch high, regardless of the device's DPI.

>  Pixel based sizes, as 
> used in the LCL for the origin and extent of the forms and controls, are 
> not affected by the DPI settings.

I am not sure about this. I think they could well be affected by DPI,
but the Lazarus developers could say for sure.

> If you want to change that DPI factor, your application can scale the 
> size of every used font accordingly.

No, this is wrong. The fonts do not need to be rescaled.

The point size required for a font to render to a particular size on
screen or paper is independent of the DPI of the device. Point sizes are
based on 1/72nd of an inch, regardless of how many device dots are in
that inch. It is the American inch (slightly larger than the traditional
Imperial inch, which it has largely supplanted) that is the defining
factor, and this is fixed.

> Please specify if you have something else in mind, like an zoom factor 
> for *all* elements of your application.

It's not my application, so I presume this is intended for the o.p.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Controlling DPI

2009-03-28 Thread David W Noon
On Sat, 2009-03-28 at 19:17 +0100, Hans-Peter Diettrich wrote:

> David W Noon schrieb:
> 
> >> I prefer the latter, but the zoon factor can also do the trick.
> > 
> > The DPI is controlled by the hardware driver for the video card.
> 
> That's a matter of definition of "DPI".

There is only one definition of DPI for any given device. Moreover, what
you have written below isn't it -- for any device.

> Windows allows to change the font size (DPI) at any time, and most other 
> systems have similar capabilities. Since Delphi has its roots in 
> Windows, this definition also should apply to FPC/Lazarus.

The *point size* of the font has nothing whatsoever to do with the DPI
of the screen or printer, other than the rendering engine querying the
DPI of the device in order to render the text to the appropriate size in
pica points. There are approximately 72 pica points to an inch,
regardless of the DPI of the device on which the text is being rendered.

See:
http://en.wikipedia.org/wiki/Pica_(unit_of_measure)

[The pica has also been "Americanized" to be exactly 1/72nd of an inch
within the computer industry, but the classic definition if picas/didots
and ciceros does not fit easily in Imperial Measures.]

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Controlling DPI

2009-03-28 Thread David W Noon
On Sat, 2009-03-28 at 18:41 +0300, ik wrote:
> 
> I prefer the latter, but the zoon factor can also do the trick.

The DPI is controlled by the hardware driver for the video card. It
applies to the entire screen and cannot be changed for a particular
window on the screen. The only way to alter it is to restart the video
driver with different initialization parameters. [For a UNIX-like system
(e.g. Linux, FreeBSD), this means altering the X11 configuration and
restarting the X11 daemon.]

A zoom factor applies to an image, either pictorial or rendered text.
You can do whatever you want with that within your application.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] About try blocks

2009-03-17 Thread David W Noon
On Tue, 2009-03-17 at 19:16 +0100, svaa wrote:

> A little off-topic and probably just a stupid idea.

Not a stupid idea. It is what the Python grammar permits for exception
handling.

It seems to be a limitation of the Object Pascal grammar -- and a wholly
unnecessary one at that.

Since introducing such a change to Object Pascal would require a
compiler change, it is probably better to discuss it in the development
mailing list, rather than the Lazarus list.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Adding units to a project

2009-03-04 Thread David W Noon
On Wed, 2009-03-04 at 17:01 +, Antonio Sanguigni wrote:

> I know I'm lost in a glass of water but I cannot be able to use some units.
> I'm building a new lazarus project and I would like to re-use other
> units in my file system. So I added them to this new project with
> Project inspector - Add - Add Files - Add file to packages and this
> operation add the units on .lpr files of project and that's fine. Now,
> I need to use this added unit also in other unit's use clause of the
> project but Lazarus complains that it cannot find it when I try to
> build it.
> 
> Adding requirements of .lpk files is fine and works smooth.
> 
> My question is: Do I need to create a package to use that units or I'm
> missing something ?

The way I approach reusing common code is to have my common units in
local directories:

   ~/units   -- for code that is not yet considered stable
   /usr/local/units  -- for code that is considered stable

The first of these is added with a -Fu option in my ~/.fpc.cfg file, and
the second is added with a -Fu option in my /etc/fpc.cfg file. These
directories can also be added to your Lazarus compilation options.

Whenever I need to incorporate a unit I simply add its name to the
"uses" clause of the unit that needs to invoke code from the shared
unit. Lazarus seems to find the code when tracing, so it all just seems
to work.

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Examples of IniPropStorage?

2009-02-22 Thread David W Noon
On Sun, 2009-02-22 at 13:39 +0100, Michael Van Canneyt wrote:

> On Sat, 21 Feb 2009, David W Noon wrote:
> 
> >Name_field.Text := Ini_props.ReadString('Name', '');
> > 
> > The second approach has much neater syntax, plus it allows me to specify
> > a default value if the required section of the .INI file lacks a value
> > for that key. But I get access violations when the .INI file is empty.
> 
> Attached is a patch for propertystorage; Could you please test if
> you still get the access violation when the patch was applied ?

That patch fixes the problem.   Many thanks!

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Examples of IniPropStorage?

2009-02-21 Thread David W Noon
On Sat, 2009-02-21 at 19:06 +0100, Luca Olivetti wrote:

> En/na David W Noon ha escrit:
[snip]
> > If there are none, could somebody please give me a quick sample they
> > have knocked up for their own use? Thanks in advance.
>
> Drop a TIniPropStorage on the form, let's call it FormStorage.
> Put all properties you want to preserve in the form SessionProperties 
> (there's a nice dialog to add what you want).
> If you know beforehand the location of the .ini file, just set it in the 
> TIniPropstorage at design time, otherwise assign it in FormCreate.
> Also in FormCreate call restore.
> When you want to save, just call save, e.g.:
> 
> procedure TSettingsForm.FormCreate(Sender: TObject);
> begin
>FormStorage.IniFileName:=SettingsFilename;
>FormStorage.Restore;
> end;
> 
> procedure TFormAjustes.SaveButtonClick(Sender: TObject);
> begin
>FormStorage.Save;
> end;

Thanks for that, Luca. The code is putting me in the right direction.

Now, how do I actually extract key/value pairs from it and store
key/value pairs into it? The only property I have found that looks
likely is the StoredValues collection, but this is too kludgey to be
true, e.g.:

   Name_field.Text := Ini_props.StoredValues['Name'].Value;

That seems to be the sequence required to get a string, and it seems to
segfault if the .INI file is empty. Moreover, the ReadString() method
also segfaults if I use that method instead of the property, e.g.:

   Name_field.Text := Ini_props.ReadString('Name', '');

The second approach has much neater syntax, plus it allows me to specify
a default value if the required section of the .INI file lacks a value
for that key. But I get access violations when the .INI file is empty.

So, any more tips down at the key/value pair level?

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Examples of IniPropStorage?

2009-02-21 Thread David W Noon
Hi all,

Are there any examples of the usage of TIniPropStorage objects? I have
searched the examples supplied with Lazarus, but could find none.

If there are none, could somebody please give me a quick sample they
have knocked up for their own use? Thanks in advance.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SQLdb tab

2009-02-19 Thread David W Noon
On Wed, 2009-02-18 at 13:22 +, David W Noon wrote:

> On Wed, 2009-02-18 at 10:43 +0200, Graeme Geldenhuys wrote:
> 
> > On Tue, Feb 17, 2009 at 11:33 PM, David W Noon
> >  wrote:
> > > experimentation I managed to get the "bigidecomponents" target built.
> > > This caused the SQLDBlaz package in the "Installed Packages" dialogue to
> > 
> > What I do is as follows:
> > 
> > *  Packages | "Open package file (*.lpk)"
> > * Then browse to the components/sqldb/ directory
> > * select "sqldblaz.lpk"
> > * In the new dialog,  click "Compile"
> > * Then click "Install"
> > * Lazarus should now restart and you should see the SqlDB tab.
> 
> That worked a treat. Many thanks, Graeme.

Just as an FYI:

The above method installed the updated Lazarus under my home directory.
To make the SQLdb tab universally accessible, one can build (as root)
the main Lazarus program using:

   cd /usr/share/lazarus
   make clean bigide LCL_PLATFORM=gtk2 {or qt, or whatever}

This will also make the RTTI and IPro tools available.

It would be nice if this were documented in the README.txt file that is
included in the Lazarus bundle.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] SQLdb tab

2009-02-18 Thread David W Noon
On Wed, 2009-02-18 at 10:43 +0200, Graeme Geldenhuys wrote:

> On Tue, Feb 17, 2009 at 11:33 PM, David W Noon
>  wrote:
> > experimentation I managed to get the "bigidecomponents" target built.
> > This caused the SQLDBlaz package in the "Installed Packages" dialogue to
> 
> What I do is as follows:
> 
> *  Packages | "Open package file (*.lpk)"
> * Then browse to the components/sqldb/ directory
> * select "sqldblaz.lpk"
> * In the new dialog,  click "Compile"
> * Then click "Install"
> * Lazarus should now restart and you should see the SqlDB tab.

That worked a treat. Many thanks, Graeme.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] SQLdb tab

2009-02-17 Thread David W Noon
I am running Lazarus 0.9.26 under Gentoo Linux 2.6.27 using gtk2
widgets.

The Lazarus IDE did not have a SQLdb tab when I first installed it
(using a Gentoo ebuild). I looked in /usr/share/lazarus[/components,
etc.] and found that the units had not been built; after some
experimentation I managed to get the "bigidecomponents" target built.
This caused the SQLDBlaz package in the "Installed Packages" dialogue to
change from a version of 0.0 to 1.0.1, so I had hoped that installing it
from the dialogue and restarting Lazarus would cause the SQLdb tab to
appear. It didn't.

I noticed that the .o & .ppu files built by the "make bigidecomponents"
were not copied or moved to /usr/share/lazarus/units/i386-linux. Since
the IDE picked up the version change correctly, I have assumed that it
was not necessary to copy them there.

So, what have I missed?

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Dispatching GUI messages from background threads

2009-01-11 Thread David W Noon
On Sun, 2009-01-11 at 09:59 +0700, Paul Ishenin wrote:

> David W Noon wrote:
> 
> > The only function like that I could find was SimpleSendMessage(), which
> > produced the same result as Dispatch() and DeliverMessage(), but without
> > supplying any message data. In which unit is SendMessage() defined?
> 
> add LCLIntf unit to your uses section and you'll get SendMessage and 
> PostMessage.

Both methods of message transfer! Many thanks.

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Does Lazarus have "sizer" or "layout" objects?

2009-01-11 Thread David W Noon
On Sun, 2009-01-11 at 03:52 +0100, Lord Satan wrote:

> On Sat, 10 Jan 2009 21:37:28 +
> David W Noon  wrote:
> 
> > What you are ultimately saying is that Lazarus's form designer is easier
> > to use than Qt designer.
> No, I am not. I am saying that with the Qt layouts we don't achieve the look 
> we want and that the Qt-Designer (as a bonus) is a major PITA, too. Doing it 
> by hand does not fix the shortcomings of layouts and spacers and just adds 
> ugly code.
> I am not talking about one form with some memos, buttons, etc here and there. 
> We have a highly dynamical GUI in our application, with lots of plugins 
> adding/removing their own GUI-elements at runtime or extending existing 
> GUI-elements.
> We switched from hand coded GUI to ui-files as the old system just became 
> unmanageable. Once again, this is not about Qt-Designer vs Lazarus' form 
> designer.
> Layouts are a nice and easy way for simple GUIs, but too restricted for more 
> complex tasks.
> I would post screen shots of the problems, but I am unfortunately not allowed 
> to do this.
> 
> But you did not answer my question. Do you have experience with developing 
> complex layouts in Qt or are you just talking about simple stuff?

By my standards they were reasonably complex. However, all the dialogues
are statically populated with controls, so the layouts are for resizing
and/or repositioning controls whose initial positions are known at
compile time -- i.e. no dynamic plugins.

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Dispatching GUI messages from background threads

2009-01-10 Thread David W Noon
On Sun, 2009-01-11 at 01:17 +0100, Hans-Peter Diettrich wrote:

> David W Noon schrieb:
> 
> > This looks rather like some sort of deadlock on something like a mutex
> > semaphore -- but that's just a guess. Is there some "knack" to calling
> > Dispatch() that avoids this problem?
> 
> The solution is simple: don't use Dispatch() from a thread, use the 
> thread-safe SendMessage instead.

The only function like that I could find was SimpleSendMessage(), which
produced the same result as Dispatch() and DeliverMessage(), but without
supplying any message data. In which unit is SendMessage() defined?

I finally resolved the issue by changing the pointer to the form into an
object reference to a TObject. After that, Dispatch() worked as
documented (such as it is documented).

Moreover, the action I needed was a "post", not a "send". It is the
"send" style of message transfer that causes deadlocks between the
worker thread and the user interface thread. This is because "send"
waits for a return code from the message handler, whereas "post" just
places the message on the queue and proceeds regardless.

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Does Lazarus have "sizer" or "layout" objects?

2009-01-10 Thread David W Noon
On Sat, 2009-01-10 at 22:05 +0100, Lord Satan wrote:

> On Sat, 10 Jan 2009 19:49:43 +
> David W Noon  wrote:
> 
> > If it's only half as good a Qt's layout classes it will be very good
> > indeed.
> Did you ever do a 'more complex' GUI with Qt? I am working with Qt in my job 
> and I would gladly trade Qt's layouts for Lazarus' anchoring and friends?
> It takes ages to align Qt's layouts and spacers in a way that they work at 
> least a little bit like you wish. The Qt-Designer is more hindering than 
> helping and very often I have more space between my GUI elements than I want 
> to have.
> Perhaps me and my colleagues are just too stupid to use Qt, but our GUI 
> design is most of the time 'just good enough' and not like we imagined to do 
> it.
> Sorry for ranting, but I can't let a chance to bash Qt's layouts just pass.

I do the coding by hand for Qt layouts and wxWidgets sizers. It's far
easier that way.

What you are ultimately saying is that Lazarus's form designer is easier
to use than Qt designer. I won't dispute that.

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Does Lazarus have "sizer" or "layout" objects?

2009-01-10 Thread David W Noon
On Sat, 2009-01-10 at 10:01 +0200, Graeme Geldenhuys wrote:

> On Wed, Jan 7, 2009 at 5:09 PM, David W Noon  
> wrote:
> >
> > So, as the subject line says, does Lazarus have such classes?
> 
> No, but it has anchoring, alignment etc...

This has proven to be completely adequate for the modest requirements of
the application I am writing.

> I am working on such a layout manager class though. I am porting the
> MiG Layout from Java to Free Pascal. It's mainly for use with fpGUI,
> but most of the core code is GUI toolkit independent, so it should be
> easy to support LCL as well.  I will definitely post a notice here
> once I have completed the port - somewhere in the first half of this
> year.  MiG Layout is simply fantastic!! Google for it's website and
> try the demo.

If it's only half as good a Qt's layout classes it will be very good
indeed.

-- 
Regards,

Dave  [RLU #314465]
=======
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Dispatching GUI messages from background threads

2009-01-10 Thread David W Noon
Hi,

I have declared a couple of procedures with the message attribute in a
form class, descended from TForm, like so:

procedure Log_message(var msg: UserMsg); Message LM_USER;
procedure Thread_complete(var msg: UserMsg); Message LM_USER+1;

The structure UserMsg has a Cardinal in the first position to hold the
message id. This is always set correctly to one of the two values based
on LM_USER, as above.

The background thread's class, descended from TThread, contains a
pointer to the form that invoked the thread in a field named
Parent_form.

When the background thread comes to post a message to the parent form,
it uses the Dispatch() method of TObject, inherited through TForm to the
form's class. However, the call never returns and the application hangs.
I have also tried the DeliverMessage() function, but the results are
identical.

This looks rather like some sort of deadlock on something like a mutex
semaphore -- but that's just a guess. Is there some "knack" to calling
Dispatch() that avoids this problem?

-- 
Regards,

Dave  [RLU #314465]
======
dwn...@ntlworld.com (David W Noon)
==
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Does Lazarus have "sizer" or "layout" objects?

2009-01-07 Thread David W Noon
On Wed, 2009-01-07 at 16:29 +0100, Vincent Snijders wrote:

> 2009/1/7 David W Noon :
> > Some C++ class libraries have object classes that automatically resize
> > widgets when a form is resized by the user. For example, wxWidgets calls
> > them sizers, and Qt calls them layouts.
[snip]
> No, there are no such classes. A control has anchors, and a number of
> a controls can autosize (i.e. adjust size accoding to their contents).

This gives me exactly the functionality I need. Many thanks!

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Does Lazarus have "sizer" or "layout" objects?

2009-01-07 Thread David W Noon
Hi,

Some C++ class libraries have object classes that automatically resize
widgets when a form is resized by the user. For example, wxWidgets calls
them sizers, and Qt calls them layouts. I have perused the LCL
documentation and have found nothing that quite meets the bill. I tried
a TPanel object, but it did not have anywhere near that functionality;
in fact, it seemed to do very little.

So, as the subject line says, does Lazarus have such classes?

-- 
Regards,

Dave  [RLU #314465]
===
david.w.n...@ntlworld.com (David W Noon)
===
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus