Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-09

How to write GUI programs?

18 messages · 12 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Hantsch

Hello, all!

Until now, I kept away from GUI programming because it always appeared to me very complicated. But I see the time coming close and closer, where I will have no choice, so I want to have a first look inside.

What I want:
o Writing FPC programs, primarily for LINUX.
o I prefer SIMPLE solutions and no "super-duper" things which cause a lot of problems
o Basically I am lookung for some kind of a "graphical ncurses" or something on this level.
o I do not want changes to my normal SuSE Linux. It should be possible to use standard libraries which are shipped with SuSE Linux 7.x/8.0. o If I can see some code for a simple "Hello World" in GUI, it will be a good start.

If somebody can give me some advice, I will be happy, because I am an 100% novice here.

mfg

Ing. Rainer Hantsch

\\|// Ing. Rainer HANTSCH - Hardware + Software (o o) Forget Windoze! -- We focus on L-I-N-U-X... --oOOo-(_)-oOOo-------------------------------------------------- Ing. Rainer HANTSCH | e-Mail: Khunngasse 21/20 | www : http://www.hantsch.co.at A-1030 Vienna | Tel. : ++43 - 1 - 7988538 0 ---------------------| Fax : ++43 - 1 - 7988538 18 ** AUSTRIA ** | Mobile: ++43 - 664 - 9194382 -----------------------------------------------------------------
Fernando Lozano

Hi Rainer,

Show quoted text 9 lines
o Writing FPC programs, primarily for LINUX. o I prefer SIMPLE solutions and no "super-duper" things which cause a lot of problems o Basically I am lookung for some kind of a "graphical ncurses" or something on this level. o I do not want changes to my normal SuSE Linux. It should be possible to use standard libraries which are shipped with SuSE Linux 7.x/8.0. o If I can see some code for a simple "Hello World" in GUI, it will be a good start.

Use the gtk unit which is standard on FPC, and see the examples provided. You also get the advantage that GTK+ apps can be compiled using FPC for Windows.

Ive send some samples of my own attached. Written por Brazillian people, so the messages are in portuguese. :-)

[]s, Fernando Lozano

Johann Glaser
to Fernando Lozano

Hi Rainer!

Show quoted text 15 lines
> o Writing FPC programs, primarily for LINUX. > o I prefer SIMPLE solutions and no "super-duper" things which cause a lot > of problems > o Basically I am lookung for some kind of a "graphical ncurses" or something > on this level. > o I do not want changes to my normal SuSE Linux. It should be possible to > use standard libraries which are shipped with SuSE Linux 7.x/8.0. > o If I can see some code for a simple "Hello World" in GUI, it will be a > good start. Use the gtk unit which is standard on FPC, and see the examples provided. You also get the advantage that GTK+ apps can be compiled using FPC for Windows. Ive send some samples of my own attached. Written por Brazillian people, so the messages are in portuguese. :-)

When GTK is said, I've to advertise GTKpas
http://gtkpas.sourceforge.net/

It is an object oriented wrapper around GTK. This beautifies programming a lot. The disadvantage is a little speed decrease and that GTKpas is not really ready. But I've written a program to display 3D electromagnetic waves with it, so, it is usefull enough.

Bye
Hansi

Johann Glaser Vienna University of Technology Electrical Engineering ____ http://www.johann-glaser.at/ ____
Holger Peters

Hi,
a Tutorial (I think there are five parts in *.pdf Format) about GTK programming in FreePascal.

Holger

Rainer Hantsch
to Fernando Lozano: Use the gtk unit which is standard on FPC, and see the examples provided. You also get…

Hi, Fernando!

Thanks a lot for the samples. I compiled them without any problem with my FPC 1.0.4 and they appeared to work.

I find it also very impressive that the code size is relatively small. I saw samples for Qt, where such things required much more commands! - And this is exactly what kept me away from GUI coding all the time: Writing half a 'book' to open a stupid window...

But now, a big problem arises to me:
------------------------------------
Basically, your examples made me doing the decision to use GTK. -> :-) But WHEN I start with GTK, I will have to get something like a 'User guide' for all this GTK related stuff, if possible with simple examples, as Michael V. Kenneyt did with his "FreePascal Book".
-> Because I have absolutely no knowledge about GUI programming, I must learn this from scratch. I only experienced that here everything goes otherwise round: While a normal text application is controlled by keystrokes and you have to read them within you program, it seems that GUI programs have an external handler in the GUI library and this one does callbacks - I never programmed this way any time in my life, and I am programming now more than 25 years, so this is a big change to me...

ANY SUGGESTIONS ABOUT BOOKS WHICH ARE EXPLICITELY FITTING TO THE FPC-GTK UNITS?

Fernando Lozano wrote 10 lines
Hi Rainer, Use the gtk unit which is standard on FPC, and see the examples provided. You also get the advantage that GTK+ apps can be compiled using FPC for Windows. Ive send some samples of my own attached. Written for Brazillian people, so the messages are in portuguese. :-) []s, Fernando Lozano

mfg

Ing. Rainer Hantsch

\\|// Ing. Rainer HANTSCH - Hardware + Software (o o) Forget Windoze! -- We focus on L-I-N-U-X... --oOOo-(_)-oOOo-------------------------------------------------- Ing. Rainer HANTSCH | e-Mail: Khunngasse 21/20 | www : http://www.hantsch.co.at A-1030 Vienna | Tel. : ++43 - 1 - 7988538 0 ---------------------| Fax : ++43 - 1 - 7988538 18 ** AUSTRIA ** | Mobile: ++43 - 664 - 9194382 -----------------------------------------------------------------
amorel
to Rainer Hantsch
Rainer Hantsch wrote 5 lines
-> Because I have absolutely no knowledge about GUI programming, I must learn this from scratch. I only experienced that here everything goes otherwise round: While a normal text application is controlled by keystrokes and you have to read them within you program, it seems that GUI programs have an external handler in the GUI library and this one does callbacks - I never

It depends on the gui api you are using. Some require you to run your own (delayed)event loop checking for gui events, or using a wait alike command which waits for an event, within a loop. Then you check what caused the event and start the function according to that. After that it returns to the wait command after it completed the loop.

Regards

Fernando Lozano

Hi Rainer,

Show quoted text 10 lines
I find it also very impressive that the code size is relatively small. I saw samples for Qt, where such things required much more commands! - And this is exactly what kept me away from GUI coding all the time: Writing half a 'book' to open a stupid window... But now, a big problem arises to me: Basically, your examples made me doing the decision to use GTK. -> :-) But WHEN I start with GTK, I will have to get something like a 'User guide' for all this GTK related stuff, if possible with simple examples, as Michael V. Kenneyt did with his "FreePascal Book".

Somewhere inside the Free Pascal site you'll find a link to a GTK+ on FPC tutorial which is very good. Actually you can use any GTK+ tutorial you find on the net, because although they are written in C the GTK+ API is the same on Pascal.

Look into www.freepascal.org and www.gtk.org and if you cannot find nothing write me again I'll try to give you some more specific pointers.

[]s, Fernando Lozano

Fernando Lozano

Amorel,

Show quoted text 12 lines
On Tue, Sep 10, 2002 at 07:44:28AM +0200, Rainer Hantsch wrote: > -> Because I have absolutely no knowledge about GUI programming, I must learn > this from scratch. I only experienced that here everything goes otherwise > round: While a normal text application is controlled by keystrokes and you > have to read them within you program, it seems that GUI programs have an > external handler in the GUI library and this one does callbacks - I never It depends on the gui api you are using. Some require you to run your own (delayed)event loop checking for gui events, or using a wait alike command which waits for an event, within a loop. Then you check what caused the event and start the function according to that. After that it returns to the wait command after it completed the loop.

If you use GTK+ this is the gtk_main procedure. It'll do an event loop (until gtk_main_quit sets a flag that ends the loop) and call the event handler routines defined by previous calls to gtk_signal_connect. Anytime on your app (that is, inside any event handler) you can call gtk_signal_connect to define new event handlers, say for windows you've just created like dialog boxes.

[]s, Fernando Lozano

Christophe

Hello Rainer

You can take a look to GTKPas which is a object encapsulation of the GTK API functions available in FPC. It's more easy to write GUI app with it and your code will be shorter and cleaner.

http://gtkpas.sourceforge.net

Note to all :

I'm thinking of doing the same thing as GTkPas but for GTK2forPascal, the wrapper for GTK2 available at SourceForge and maintained by Mattias Gaertner. I would like to write a tool which takes all the external functions and encapsulate them in object structure. Does someone work on a similar project ? Does someone is interested to help ?

Cheers,

Christophe

Mattias Gaertner
to Christophe
Show quoted text 13 lines
Hello Rainer You can take a look to GTKPas which is a object encapsulation of the GTK API functions available in FPC. It's more easy to write GUI app with it and your code will be shorter and cleaner. http://gtkpas.sourceforge.net Note to all : I'm thinking of doing the same thing as GTkPas but for GTK2forPascal, the wrapper for GTK2 available at SourceForge and maintained by Mattias Gaertner.

And Olaf Leidinger and Tomas Bzatek.

Mattias

Michael Van Canneyt
to Christophe: Hello Rainer You can take a look to GTKPas which is a object encapsulation of the GTK API…
Christophe wrote 15 lines
Hello Rainer You can take a look to GTKPas which is a object encapsulation of the GTK API functions available in FPC. It's more easy to write GUI app with it and your code will be shorter and cleaner. http://gtkpas.sourceforge.net Note to all : I'm thinking of doing the same thing as GTkPas but for GTK2forPascal, the wrapper for GTK2 available at SourceForge and maintained by Mattias Gaertner. I would like to write a tool which takes all the external functions and encapsulate them in object structure. Does someone work on a similar project ? Does someone is interested to help ?
Yes. I'm cooperating with someone on this already;
The intention is to put this in the standard packages of FPC, as 'fpgtk'

It is nearly finished; Most components have been converted. There are a few components left to do.
Programs work under Linux and Windows.
I am writing a GUI fpdoc documentation editor with it.

Originally, the GUI conversion tool used to do this was written in Delphi. It is now being converted to use the classes it generates.

It is currently written for GTK 1; but as everything is generated from templates, the expectation is that switching to GTK 2 will be quite easy and should not take much work as it is a simple change of the templates.

Michael.

Christophe

Michael,

Yes. I'm cooperating with someone on this already; The intention is to put this in the standard packages of FPC, as 'fpgtk'

Yeah ! It sounds great. Is it availaible for download ? Do you need some help ?

I'm planning to write a XML programmer editor using GTK and Sablopas, my wrapper for Sablotron. I currently use the shedit component but I'm thinking of creating a source code editor widget. I took a look to the new GTK text widget and it seems great. In the Glib2, there are also some functions to scan token which may help for syntax highlighting.

I send some new widgets encapsulation (text, tree, paned, notebook) to the maintainer of GTKPas and he will add them soon. But as I just startes I'm thinking of using directly GTK2. On the other hand, I can enhance the SHEdit component to add missing features. What do you think is the best ?

Thanks

Christophe

Fernando Lozano

Christophe,

Show quoted text 5 lines
I'm planning to write a XML programmer editor using GTK and Sablopas, my wrapper for Sablotron. I currently use the shedit component but I'm thinking of creating a source code editor widget. I took a look to the new GTK text widget and it seems great. In the Glib2, there are also some functions to scan token which may help for syntax highlighting.

Have you seen the Scintilla Widget? It´s used by Moleskine and a number of ther Programmers Editors and IDEs. www.scintilla.org

[]s, Fernando Lozano

Michael Van Canneyt
to Christophe: Yeah ! It sounds great. Is it availaible for download ? Do you need some help ? I'm…
Christophe wrote 8 lines
Michael, >Yes. I'm cooperating with someone on this already; >The intention is to put this in the standard packages of FPC, as 'fpgtk' Yeah ! It sounds great. Is it availaible for download ? Do you need some help ?

I will forward your mail to the person who writes it. (he works on less than 5 meter of where I sit, but nevertheless :) )

I'm planning to write a XML programmer editor using GTK and Sablopas, my wrapper for Sablotron.

Actually, the documentation editor I'm making with the toolkit, must edit XML files with some xhtml in it. So cooperation may be very fruitful =-)

I currently use the shedit component but I'm thinking of creating a source code editor widget. I took a look to the new GTK text widget and it seems great. In the Glib2, there are also some functions to scan token which may help for syntax highlighting.

Yes.
We'd have to look at converting to GTK2 but I don't think this should be a big problem.

I send some new widgets encapsulation (text, tree, paned, notebook) to the maintainer of GTKPas and he will add them soon.

These are already functioning in the toolkit I use. Like I said, there are very little things left to do.

But as I just startes I'm thinking of using directly GTK2. On the other hand, I can enhance the SHEdit component to add missing features. What do you think is the best ?

I think it it better to enhance the shedit component. it's made by Sebastian Guenther. ()

I'm forwarding this mail to the author of fpgtk.

Michael.

Christophe Espern
to Michael Van Canneyt
Michael Van Canneyt wrote
I will forward your mail to the person who writes it.

Thanks

Actually, the documentation editor I'm making with the toolkit, must edit XML files with some xhtml in it. So cooperation may be very fruitful =-)

Maybe you can take a look to Sablopas it may be helpful for your documentation tasks. You can transfom XML files in RTF, advanced XHTML or even PDF via XSL-FO. I already used it to create Pascal files from XML :-) It is now quite complete and stable and I use it in production apps. It can be used with Iconv and SpiderMonkey, a javascript engine.

http://www.tekool.com/sablopas

howto : http://www.tekool.com/sablopas/howto.htm

I think it it better to enhance the shedit component. it's made by Sebastian Guenther. ()

I will contact him.

Christophe

Sebastian Günther
to Christophe Espern
Show quoted text 5 lines
>I think it it better to enhance the shedit component. it's made by >Sebastian Guenther. () I will contact him.

ehm I think it's just ;)

- Sebastian

Unknown author
to Sebastian Günther
Show quoted text 9 lines
Christophe Espern schrieb: >>I think it it better to enhance the shedit component. it's made by >>Sebastian Guenther. () > > > I will contact him. ehm I think it's just ;)

Both should be correct. All core members have

as an alias.

Michael.

Stefan Ziegenbalg
to Christophe: Yeah ! It sounds great. Is it availaible for download ? Do you need some help ? I'm…
Christophe wrote 10 lines
I'm planning to write a XML programmer editor using GTK and Sablopas, my wrapper for Sablotron. I currently use the shedit component but I'm thinking of creating a source code editor widget. I took a look to the new GTK text widget and it seems great. In the Glib2, there are also some functions to scan token which may help for syntax highlighting. I send some new widgets encapsulation (text, tree, paned, notebook) to the maintainer of GTKPas and he will add them soon. But as I just startes I'm thinking of using directly GTK2. On the other hand, I can enhance the SHEdit component to add missing features. What do you think is the best ?

If you like cooledit/mcedit behavior:

I'm porting mcedit, which was ported from cooledit, to GTK2. I do that in C because a lot of the old code can be reused, and I don't want to rewrite it all. Of course a Pascal bindings will exist.

The most critical things are done: removing/replacing depencies from gnome and mc, porting from gtk to gtk2, pango rendering nearly finished, started porting cooledit commands to signals (that allows to configure the keybindings with rc files), ... A lot of boring writing work has to be done.

The editor will support unicode and can do everything that mcedit/ cooledit can (inclusive proportional font support).

If someone has special whishes: please contact me. So I can consider them in an early stage.

Regards Stefan

----------------------------------------------

http://www.sziegenbalg.de
http://www.simage.org