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 to the vcl's graphics model.
- its classes look very much like vcl components.
- it introduces many standard widgets, and handles the message loop.
this begs two questions: does this mean that kylix supports only kde, and no other desktops, such as gnome? and how does using qt as the basis of clx affect me? the answer to the first question is that kylix applications will run under any linux desktop - particularly gnome and kde. the rest of this article answers the second question.
don't want you back
the goal is to make it easy for developers to port their applications to linux with the least amount of trouble. most of the component names are the same, and most of the properties are the same. although a few properties will be missing from some components, and a few new ones will be added, for the most part, it should be fairly painless to port your applications.
for component writers, it's a different story. for starters, there is no windows.pas, nor windows api (see figure 1). you can say good-bye to the message directive, and all of the cn and cm notifications. these have been changed to dynamics. there is also no docking, bi-directional (bidi) methods/properties, input method editor (ime), or asian support in the first release. of course, there's no activex, com, or ole support. windows 3.1 components are also out, as i write this.
|
methods |
|
createparams |
|
createsubclass |
|
createwindowhandle |
|
createwnd |
|
destroywindowhandle |
|
destroywnd |
|
doadddockclient |
|
dockover |
|
dodockover |
|
doremovedockclient |
|
doundock
本文关键:Kylix预览
相关方案
|