News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Linux GUI programming

Started by DarkWolf, January 10, 2011, 09:20:20 PM

Previous topic - Next topic

DarkWolf

I have bben looking for docs for calling X functions to make a window (like the linux equivalent of the win32 api)

However there appears to be no such case I haven't found anything like the Iczelion tutorials or similar. Even Google Linux results lead me to windows code or the AOA site.

Has anyone here used HLA with X ?
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

Sevag.K

#1
briefly, many years ago.  i did a simple gui library that works with both windows and x.
documentation was a real pain to find back then, i would imagine it should be easier today?

here it is, maybe it will help you get started.

guilibtest.exe <<< TR/Crypt.XPACK.Gen ; trojan ; Is the Trojan horse TR/Crypt.XPACK.Gen

Please do not provide .EXE (use ZIP and /or  Source files if possible) ...

Let's hope that it is a false positive but better safe than sorry.

Synfire

I can't really help you with HLA aspect as I can't honestly say I've ever used it (read a little about it but couldn't get into the "feel" of it). As for GUI/ASM, I have an X11 demo in my examples.tar.gz file on my homepage and not long ago I wrote a cute little tool called Glade2NASM which lets you design .glade files in the Glade3 editor and have the tool generate a .asm file which does the initialization and sets up your signals. Although both the examples and the code generated by Glade2Nasm are targed for the Netwide Assembler, I would assume that using the HLA documentation you could fairly easily port the code over to HLA. Also, keep in mind when using Glade2Nasm that it was designed as a tool to jumpstart development and I didn't focus much on optimizing so you might think about cleaning up the C source if you plan to port it, it's fairly simplisitic.

Beyond my stuff, once you learn to use LibC from your preferred assembler and design structures, it's just a matter of looking through the libraries documentation and use those skills learned to port the code over. GTK+ and Glade documentation is overly complete and there are literally thousands of examples available on the net. XLib itself is fairly well documented. I do suggest that if you are just starting out, learn XLib first cause it'll introduce you to XEvents and how things work underneath. Later on, you can move on to things like Glade/GTK or wxWidgets if you want something to increase your productivity.

Links
http://assembly.ath.cx/  - For Glade2Nasm and my GNU/Linux Assembly Examples
http://tronche.com/gui/x/xlib/
http://www.unix-manuals.com/tutorials/xlib/xlib.html
http://www.math.msu.su/~vvb/2course/Borisenko/CppProjects/GWindow/xintro.html
http://live.gnome.org/Glade/Tutorials
http://library.gnome.org/devel/gladeui/3.6/
http://www.fifi.org/doc/libgtk1.2-doc/gtk-tutorial-html/gtk_tut.html
http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/HighLevelAsm/HLADoc/HLARef/HLARef_html/HLAReference.htm#50401400_pgfId-998318

redskull

Quote from: DarkWolf on January 10, 2011, 09:20:20 PM
I have bben looking for docs for calling X functions to make a window (like the linux equivalent of the win32 api)

However there appears to be no such case I haven't found anything like the Iczelion tutorials or similar. Even Google Linux results lead me to windows code or the AOA site.

Has anyone here used HLA with X ?

The thing with Linux is that X is several layers lower than what the equivlent win32 API would be; what you probably want is the appropriate desktop manager API; if you are writing for Gnome, then google for "GTK", and if you use KDE, look for "QT".  Both are built 'on top' of X, so to speak.  One of the things to get used to is that GUI applications built for one distro won't necessarily work with another, unlike (most) text-mode applications.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Synfire

Quote from: redskull on January 11, 2011, 12:04:51 AM
The thing with Linux is that X is several layers lower than what the equivlent win32 API would be; what you probably want is the appropriate desktop manager API; if you are writing for Gnome, then google for "GTK", and if you use KDE, look for "QT".  Both are built 'on top' of X, so to speak.  One of the things to get used to is that GUI applications built for one distro won't necessarily work with another, unlike (most) text-mode applications.

-r

That's not quite right. You can run GTK apps under KDE and QT apps under Gnome just fine. They just require core dependencies of the other. GTK itself can be ran on Windows, Gnome, KDE, FVMW, etc. Qt has just about the same portability. libgtk and kdelibs are available in just about every repo and can work within other window managers. There is no actual restriction, although I do admit it adds a lot of overhead to your install having both core libraries when only one would suffice.

But yea, like you said, GTK and Qt are built on top of Xlib and are "targeted" towards specific WM's.. kinda like Motif is targeted towards CDE/Mwm but can be used for development on any system which has Motif or Lesstif installed.

Regards,
Bryant Keller

latte

Quote from: Sevag.K on January 10, 2011, 11:28:59 PM
briefly, many years ago.  i did a simple gui library that works with both windows and x.
documentation was a real pain to find back then, i would imagine it should be easier today?
here it is, maybe it will help you get started.

That library looks very cool, Sevag - thanks for posting it! 
Just a couple of questions -
- The docs mention that khla is required.  What is that, and is it still a requirement? 
- Is the lib public-domain? 
Cheers -
- latte

redskull

Gotta love that Linux idea of compatibility: "This is completely compatible with That as long as you separately install and configure the programs to support This alongside that".  I remember a time when compatibility meant not having to download something else.
Strange women, lying in ponds, distributing swords, is no basis for a system of government

brethren

randall has made a gui library called howl for win32, but in the stdlib source code there are folders for howl linux,howl mac, howl freebsd and whatever other computers hla supports. these folders are empty at the moment but i believe he will complete a cross platform howl for all these platforms just like his cross platfrom hla standard library

Synfire

Linux is modular by design, just like Windows. :U  And just like Windows, most apps are going to be built against dynamic libraries. Really, you don't have to install GTK to run a GTK application! Just build your application with the -static option and the parts of GTK that you use are compiled into your application. Same goes for Qt. The reason users tend to build against dynamic libraries is the same reason the Windows API is written as a set of dynamic libraries; updates. Say for example a security flaw is found in GTK, the GTK developers patch this and redistribute, and finally all the users of GTK download this update. Your application, built with the -static option, is still vulnerable. Your users would not only have to download the GTK update, but your software update as well. If you simply link dynamically, you as a developer don't have to worry about updating, that will be taken care on the library side. So yea, it is compatible. Build it on your dev machine with the -static option and copy it over to your KDE box without any GTK libs and it'll run just fine. But as the developer, expect to have to rebuild and release you software each time there is an update to GTK.  :wink

Sevag.K

Quote from: latte on January 11, 2011, 08:51:25 AM
Quote from: Sevag.K on January 10, 2011, 11:28:59 PM
briefly, many years ago.  i did a simple gui library that works with both windows and x.
documentation was a real pain to find back then, i would imagine it should be easier today?
here it is, maybe it will help you get started.

That library looks very cool, Sevag - thanks for posting it! 
Just a couple of questions -
- The docs mention that khla is required.  What is that, and is it still a requirement? 
- Is the lib public-domain? 
Cheers -
- latte

khla was abandoned some years ago, it won't even build anymore.  for widows, all you need to do is open the project in HIDE and it will build.

for linux, you'll have to write a personal function for the "mem2.fillMem," (unless you want to figure out how to build hidelib.lib on linux!) which is basically a memory zeroing function, get the macros from the HIDE package ( HIDE/hlainc/macros ), and write a makefile to build guilib_events.hla, guilib_frameControl.hla, and root_objects.hla into a library (compile to objects and link to library).
then build guilibtest.hla and link with the library.

it may need further tweaking, i haven't built this on linux for some years now.

the code is public domain.

latte

Hi Sevag - thanks for your reply. 
Quote from: Sevag.K
khla was abandoned some years ago, it won't even build anymore.  for widows, all you need to do is open the project in HIDE and it will build.
Ok. 
Quote from: Sevag.K
for linux, you'll have to write a personal function for the "mem2.fillMem," (unless you want to figure out how to build hidelib.lib on linux!) which is basically a memory zeroing function, get the macros from the HIDE package ( HIDE/hlainc/macros ), and write a makefile to build guilib_events.hla, guilib_frameControl.hla, and root_objects.hla into a library (compile to objects and link to library).
then build guilibtest.hla and link with the library.
it may need further tweaking, i haven't built this on linux for some years now.
Ahh..... sounds like that could take some doing.  A bit beyond my ability, I'd say.....
Quote from: Sevag.K
the code is public domain.
Great!  Thanks again - bye for now -
- latte 

DarkWolf

I just got my head bit off on a linux newsgroup for asking this question.

Appearantly you "have" to use all the interevening layers if you want even a simple message box. Nevermind the fact that X has a function XCreateSimpleWindow();
He was saying how you have to use all the wrappers (GTK/QT/Gnome/KDE) and libraries (TCL/TK/X/Whatever) and then went on about the different arch types.

Oh well, looks like you may have to use Perl and Python yet (PyQT).  Can't keep nothing simple can we.

I need to learn to stop asking questions that rock the fundemental foundation upon which all things are developed.

Any way I have tried compiling the hidelib on linux before but it never worked because it kept giving me errors that something was undefined.

I hadn't tried with the most recent version, I downloaded another copy a little ago but hadn't tried yet.

mem2.fillMem function is in the library right ? so get hidelib to compile and then we wouldn't have to rewrite that function ?
Hidelib doesn't have anything windows speciifc does it ? I think the problem I always have in trying to compile is that either HLA can't find the necessary headers (maybe cause linux is case sensitive) or that there is a difference between the headers and the source.

HOWL for the other versions of HLA would be nice but I don't expect that anytime soon ( like 64bit support :P ) Randall doesn't release anything till it's how he wants it or it is working correctly and I wish some Linux devs had that attitude.

I was thinking how it would be easier (in the long run) if wForm was wrapped inside an object called uiForm which would be wForm on winodws as it is now; xForm for Linux/BSD and aForm for MacOS (Aqua is default right ? X needs installed on Macs) That way like HLA is now HOWL could be supported on multiple platforms with just a recompile.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

latte

Hi DarkWolf -
Quote from: DarkWolf
I just got my head bit off on a linux newsgroup for asking this question.

Appearantly you "have" to use all the interevening layers if you want even a simple message box. Nevermind the fact that X has a function XCreateSimpleWindow(); 
 
That's unfortunate, ay.  There's no need for the person in that newsgroup to be aggressive. 
Quote from: DarkWolf
He was saying how you have to use all the wrappers (GTK/QT/Gnome/KDE) and libraries (TCL/TK/X/Whatever) and then went on about the different arch types.
Oh well, looks like you may have to use Perl and Python yet (PyQT).  Can't keep nothing simple can we.
 
Yeah - so it seems!  Actually, although I'm still very much a newbie at asm coding, I'm beginning to like it.
When you're coding in such a low-level language, there's nothing to get in the way.
Quote from: DarkWolf
I need to learn to stop asking questions that rock the fundemental foundation upon which all things are developed.
Well..... maybe put on a fireproof suit.... ;)   

Quote from: DarkWolf
Any way I have tried compiling the hidelib on linux before but it never worked because it kept giving me errors that something was undefined.
Ah.... ok.  That's a pity. 
Yeah - what I would *love* to find somewhere is a simple public-domain example of Linux GUI coding in assembly.  There seem to be very few of them around.  The two things I want to be able to do most are -
a) How to create a window (preferably with window controls on it - maximise and close)
b) How to create menus in that window. 
My preference is to be able to do this using only public-domain code (I don;t know if hidelib is P.D. - I think it is freeware).  Anyway, I think it may be possible using HLA itself and nothing else. 
- latte 
Quote

DarkWolf

I thought I have seen in the about dialog in HIDE that sevag states HIDE is PD (don't quote me I haven't fired my windows machine in a while and HIDE doesn't run under WINE). I would assume that means the lib is also PD.  But I don't recall what the source code says if at all (I usually put that in my source)

Nevermind looked into archive I had; it is freeware.

For a) and b) (which is the only docs I have yet to find) :
http://tronche.com/gui/x/

With this very encouraging tutorial :
http://tronche.com/gui/x/xlib-tutorial/

In short you :
1. open client/server connection
2. create window
3. map window to screen
4. display window to screen
5. Have window do something or sleep for a few seconds (X doesn't like a window that doesn't do anything)
6. When done destroy window
7. close client/server connection

Still not sure where GTK/others fit here.
--
Where's there's smoke, There are mirrors.
Give me Free as in Freedom not Speech or Beer.
Thank You and Welcome to the Internet.

Sevag.K


HIDE is released as copyrighted opensource freeware (cannot released under a different license)
HIDELIB is public domain opensource.