Mac GUI source?

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Mac GUI source?

Post by lucasart »

sje wrote: The thing here that's very different between Mac OS/X and Linux is that the Macs use the Quartz image engine and window manager while Linux uses X Windows and one of several different window managers.

While Mac OS/X can run X Windows, (and this is necessary to run xboard on a Mac), not every Mac user has X Windows installed.
You're only confusing him with these complicated details. At the level we're interested in, it's just some basic UNIX system calls (ie. POSIX). Nothing in the explanations or code above refers to windowing system, it's just the usual pipe(), fork(), exec(), dup2() stuff.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Mac GUI source?

Post by zullil »

sje wrote: ... X Windows, (and this is necessary to run xboard on a Mac)
No longer true. Please see http://talkchess.com/forum/viewtopic.ph ... ght=quartz
MikeAtBookup
Posts: 8
Joined: Fri Jun 14, 2013 7:45 pm

Re: Mac GUI source?

Post by MikeAtBookup »

Thanks to everyone who is chipping in to give me a leg up here.

I've never heard the term "POSIX" before. I orphaned the Macintosh version of Bookup shortly after Apple introduced color Macs, a long time ago. I've been doing only Windows coding since then, and only in Delphi, so I have a bit of a learning curve ahead of me as I take on Mac and iOS.

Most of my Mac effort is going well, but things like spawning chess engines and communicating with them is not well documented in the Delphi world.
Mike Leahy
www.bookup.com
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Delphi

Post by sje »

If by "Delphi", you mean "Pascal", then Free Pascal is the way to go on a Mac. I used it to write CookieCat which runs on a bunch of different machines as Free Pascal is supported on a bunch of different machines.

http://www.freepascal.org/
User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

Re: Mac GUI source?

Post by JuLieN »

MikeAtBookup wrote:Is there any sample source of a Macintosh GUI available showing how to crank up an engine and start the UCI conversation?
Green Chess's Objective C code is downloadable from the website:
http://www.greenchess.com/apps/index.html
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
MikeAtBookup
Posts: 8
Joined: Fri Jun 14, 2013 7:45 pm

Re: Delphi

Post by MikeAtBookup »

Yes, I meant Delphi. I've been using it since before it was... Delphi. :)

The latest version generates Win, Mac and iOS from the same codebase so I'm giving it a whirl. I abandoned the old Bookup for Mac program many years ago when Turbo Pascal for Mac and Think Pascal for Mac each were abandoned, but this new Delphi XE4 looks like it may generate decent native code for all three platforms along with the promise of Android later this year.
Mike Leahy
www.bookup.com
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Mac GUI source?

Post by lucasart »

MikeAtBookup wrote:Thanks to everyone who is chipping in to give me a leg up here.

I've never heard the term "POSIX" before. I orphaned the Macintosh version of Bookup shortly after Apple introduced color Macs, a long time ago. I've been doing only Windows coding since then, and only in Delphi, so I have a bit of a learning curve ahead of me as I take on Mac and iOS.

Most of my Mac effort is going well, but things like spawning chess engines and communicating with them is not well documented in the Delphi world.
Looks like you still need to decide which programming language and toolkit you are going to use. I don't know the MacOS world much, but you should consider this:
(i) for a GUI, which in itself is not time critical, it's better to use a high level language.
(ii) built-ion support for sub-process management and pipe communication is a bonus.
(ii) you need a good toolkit, where it's easy to create windows and buttons, and link them to functions, etc.

For the reasons (i) and (ii), it seems that Python is the right choice. Spawning subprocesses, threads, communicating via pipes with the sub-processes, and all that stuff is dead easy in Python, and it's portable as it uses the standard library of the language. So your code would easily be ported to any platform.

If support for (ii) is not in the language you use or the libraries of the language, then you are going to have to do it yourself by using UNIX system calls (POSIX to be exact), which is exactly the code I posted previously.

The toolkit is a tricky part. I remember the one from Delphi, which was really nice and easy to use. I'm sure there are many possibilities out there, but be careful not to be emprisonned by a toolkit that is vendor and platform dependant. That's why I would choose GTK, but I don't know much about the alternatives, so I can't really say what's best.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Delphi

Post by sje »

Free Pascal has a Delphi compatibility mode which may be helpful. I have used the thread management routines in Free Pascal on both Mac OS/X and Linux without problems.

For graphics, save yourself much headache and use this:

http://www.freepascal.org/packages/gtk.html
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Mac GUI source?

Post by lucasart »

MikeAtBookup wrote:Thanks to everyone who is chipping in to give me a leg up here.

I've never heard the term "POSIX" before. I orphaned the Macintosh version of Bookup shortly after Apple introduced color Macs, a long time ago. I've been doing only Windows coding since then, and only in Delphi, so I have a bit of a learning curve ahead of me as I take on Mac and iOS.

Most of my Mac effort is going well, but things like spawning chess engines and communicating with them is not well documented in the Delphi world.
A modern operating system like Mac OSX is a gigantic stack of different software. And most of that is not really OS related, but rather a bunch of applications that comes installed on your mac, and without which people wouldn't be happy (a kernel with a nerdy terminal is not what most mac users want...)

Think of it like an onion:
* remove lots of layers, and you get Darwin
* remove more layers, and you get the XNU kernel

Process management, as well as pipe I/O, is the domain of the kernel, XNU.

XNU is largely based on BSD, and the BSD part provides the POSIX API. In practice, that contains the above mentionned functions: pipe(), fork(), execlp(), dup2(), kill().

For documentation on system calls, you can look at the Linux kernel manual. For example fork():
http://linux.die.net/man/2/fork

Anyway, that's for the hard way, as used by C/C++ programmers. The easy way is to use a high level programming language that has some good library, that allows you to do all this effortlessly and without even caring about which operating system you are using. That's why I suggested Python, and I am strongly convinced that it's a much better choice than C++ or Pascal, for developping a GUI.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Delphi

Post by sje »