Welcome to my personal web page
Most of you probably at least heard about the Haiku operating system. For those who didn't or just know the name, Haiku is the open source recreation and spiritual-successor of BeOS - an alternative multimedia-oriented operating system discontinued some time ago. Today's post will be a short collection of brief, random informations regarding its application programming interface (known as HaikuAPI). An API that I consider very consistent and intuitive to use.
It's just an overview of all the interesting issues though, since sadly I have many work related things on my head right now. Just to say it this way - wish me luck! But now back to the topic at hand.
In the past, BeOS was relatively popular in the personal computer world. Even long after it was no longer developed, I used it quite frequently (during my university days), writing small BeOS applications, learning the insides of the BeAPI during these processes. History aside, the operating system lives till this day in the form of the still developed Haiku operating system.
The API stays more or less consistent with the original, with a few very interesting additions. It would be useless writing an introductory tutorial right now, since there are many other places where the basics of the Haiku API can be learned from. For instance, Learning to Program with Haiku by DarkWyrm, The Haiku Book and the good old - but still very informative - legacy Be Book.
What does the HaikuAPI have to offer? A short overview of its structure: the API is divided into a variety of so called kits - sets of classes and object types for given purposes. For instance, the Interface Kit contains all the widgets and view specific classes, while the Storage Kit defines file system access primitives.
The Haiku modifications of the BeAPI include the addition of the so called Layout API. This was the one thing missing in the old BeOS system, as all layouting had to be done manually by the programmer. Which was, as everywhere, very tedious. The Layout API is still in the development, so its API might change in the nearest future, but here is a very good article written by my past GSoC mentor Ryan Leavengood explaining its basic usage - Laying It All Out, Part 1 available on the Haiku Blog-O-Sphere.
But quite recently I found another new interesting feature in the Haiku API. The BLayoutBuilder class also offers the functionality of easily building menu contents! Similarly to building the layout, we can also create a menu with all its respective BMenuItem's in a fast and easy way. Consider the following BPopUpMenu below:
// This piece of code is actually part of the new Toku Toku development source BPopUpMenu *menu = new BPopUpMenu("contact_menu", false, false); BLayoutBuilder::Menu<>(menu) .AddItem("Informacje", CONTACTMENU_INFO) .AddItem("Rozmowa", BEGG_PERSON_ACTION) .AddItem("Dziennik rozmów", CONTACTMENU_LOGS) .SetEnabled(false) .AddSeparator() .AddItem("Usuń z listy", CONTACTMENU_REMOVE) .SetEnabled(false) .AddItem("Ignoruj", CONTACTMENU_IGNORE) .SetEnabled(false) ;
The newly created BPopUpMenu, a pop-up context menu displayed after a right-click mouse action, is filled with menu items - each with a different message with a different identifier (like CONTACTMENU_INFO, a constant identifier defined elsewhere). Every item is enabled by default, but we can easily change that on the run using the SetEnabled() method, during menu construction. We can add separating elements and also sub-menus - everything in one sequence. Check here for more details.
What I like about the HaikuAPI? It's consistent. Its internal data structures are easy to use, without the complexity of the usual high-shelf C++ code. It uses classes and object-oriented design, but in the same time it still feels like writing standard C code. Just with classes. The messaging is well designed, and the API allows for much freedom. It's nicely bonded with the operating system.
With all the other, various cross-platform application frameworks around, like Qt, GTK+ or XULRunner, it's sad that no one succeeded on nicely detaching the HaikuAPI or BeAPI into an external toolkit to be used on other, more popular systems. I knew of some initiatives with similar ideas in the past, but from what I know, none of them survived. Or maybe some did, but I just don't know about it? Nevertheless, as an old BeAPI fan, I would certainly like to write a few multi-platform applications using the Haiku API!
Might consider writing a new post to my Haiku Blog-O-Sphere. It's been a while!