Cross-platform Controls
From Windows to Linux, and Back
These are exciting times for Borland. Not since the first whisper of Delphi has there been this much excitement about a Borland product. I''m talking, of course, about Kylix, the project to bring C++Builder and Delphi to the Linux operating system. The Delphi version will be available first, so for the rest of this article, Kylix refers to Delphi for Linux.
We''re developing a new VCL that will work with the Windows and Linux versions of Delphi. This means you can write an application in Windows, then move the source to a Linux box and recompile it - or vice versa. This new VCL is named CLX, for Component Library Cross-Platform. CLX encompasses the entire cross-platform library distributed with Kylix. There are a few sub-categories, which, as of this writing, break down as follows:
- BaseCLX is the RTL, up to, and including, Classes.pas.
- VisualCLX includes the user interface classes, i.e. the usual controls.
- DataCLX comprises the cross-platform database components.
- NetCLX includes the Internet stuff, e.g. Apache, etc.
At the time of this writing [early May 2000], the first Field Test for Kylix is just beginning. By the time you read this, there will be a big difference between the Kylix I''m using and working on, and the version you''ll see when it''s available. This makes my job all that more difficult. It would be easy to talk in generalities, waxing eloquent about the underlying architecture. I''d much rather discuss the details, however, so you can get a head start producing CLX controls. Just keep in mind that it''s likely some of the particulars discussed in this article will have changed by the time you read it.
No One Else Comes Close
This article is a primer on writing custom VisualCLX controls. Essentially, the VisualCLX is what you know and love about the VCL. When you think about it, Visual Component Library is a bit of a misnomer; there''s a lot more to it than the visual components. In this article, however, I''m only going to write about the visual controls. The Button, Edit, ListBox, PageControl, StatusBar, ProgressBar, etc. controls, have all been re-implemented to be cross-platform. How did we do this when the current VCL relies so much on Windows? In brief, we ripped out all the Windows stuff, and replaced it with another toolkit.
In Linux, there are a number of toolkits that contain the standard windowing controls, such as Buttons. They''re called widgets, and GTK and Qt (pronounced "cute") are two of the more popular. Qt is a Linux widget toolkit that works on Windows and Linux. Because it aligned most closely with our goals, Qt was chosen as the basis for CLX. In other words, Qt is to CLX what the Windows API and common controls are to the VCL. Qt has some definite positives for the Delphi custom component developer on Linux:
- It''s a prevalent Linux widget set, used by the popular KDE desktop.
- It''s similar to the Windows API style of development.
- Its graphics model is close
