| By Joe Barr | Article Rating: |
|
| September 9, 2002 12:00 AM EDT | Reads: |
9,457 |
(LinuxWorld) — Last week I wrote about problems getting Kylix 3 Open Edition (K3OE) working on Red Hat 7.3. This week, I'll be describing my experiences actually using K3OE, particularly its brand-spanking-new C++ IDE. Previous versions of Kylix have been for Delphi only.
I know, I know — true Linux geeks never use RAD tools, or even IDEs. Not unless you consider Emacs to be an IDE, that is. For the rest of the world, RADs and IDEs are very handy tools that provide real productivity gains. Management likes that.
Kylix 3 is a truly visual development tool. You use its components and design tools to create a visual representation of the window(s) you want to create, and it generates the code required for you. Now that C++ code can be produced as well as Delphi, Kylix is going to become even more important for Linux-development efforts. Whether you use it or not — and whether you like it or not — its success will mean more applications more quickly for Linux.
Choosing a small project with which to exercise K3OE wasn't hard. I've done very little C++ coding, and I worried I might get in over my head quickly. I decided on an approach that would allow me (hopefully) to create a small GUI app in the shortest time possible.
The project
The itch I decided to scratch was one I've had for some time: create a real-time display of active TCP/IP sessions. For the under-the-hood code I turned to Freshmeat, looking for a GPL'd app that does something similar. I found a program to cannibalilze almost immediately. It's called LCDnetstat. Its sole purpose being to display filtered netstat output on an LCD.
After downloading the LCDnetstat-2.0.1 tarball and decompressing it, I set to work. I hacked and simplified the code considerably until I got it doing only what I wanted to see in the GUI. Then I set that source code aside and entered K3OE.
Shown below are the four primary windows you see when you start Kylix 3:
- The bright blue window is the form, which provides you with a view of the application appearance as you work.
- The wide and narrow gray window across the top is the main Kylix toolbar.
- The gray window in the bottom left is the Object Inspector.
- The large white (mostly hidden by the others) window is what holds the source code that Kylix has created for you or that you've entered yourself.

Editor's note: The above image is reduced in size and color palette to allow it to load quickly. Click on the above image to see the original.
I began by starting the IDE and then clicking on the form. The Object Inspector follows your focus, so when I clicked on the form, the form appeared in it. The Object Inspector contains a column for all the properties of the object and another column for all the events which may interact with it. Now that I had the Object Inspector's attention where I wanted it, I clicked on the Color property and selected clBlue. The form changed color as soon as I entered the change. I clicked on Caption and entered "VisNetstat." The form immediately reflected the new property. Changes you make to the form itself are reflected by the Object Inspector just as quickly.
After dragging the form around a bit, I resized it by tugging at its corners. Since I'm running on an unsupported platform, I decided to save what I had before going too far. On the toolbar, I clicked on File-->SaveProjectAs and followed the dialog. That saved my new project in the directory I wanted it. From that point on, getting back to the project when restarting Kylix was always as easy as clicking File-->Reopen and selecting my project from the list.
The toolbar hides the real power of Kylix. Along the bottom, you can choose all sorts of goodies to work with. Standard components include frames, menus, edit (text entry) boxes, labels and all manner of controls. You can choose from buttons, checkboxes, radio buttons, list boxes, and more. In fact, there are more tabs than just the Standard one. There is one for additional components, another for common controls, and yet another for dialogs to handle ordinary tasks such as selecting a file from a directory.
Time and space prevent me from exploring all the tabs completely in this column. Keep in mind that this is the free (as in price) version. The Kylix Pro edition contains considerably more components than the Open Edition, and the Enterprise edition still more.
Back to my project!
I clicked on Label from the Standard components tab on the tool bar, then clicked somewhere on the form. The label appeared, and, using the Object Inspector, I changed its color, selected a font, font size, and font style, then entered a caption. But that's eye candy. I needed a container in which to display netstat results.
From the Additional components tab, I selected a StringGrid, which, according to the documentation, "Creates a grid that you can use to display string data in columns and rows." It sounded perfect for my needs. Clicking on the form gave me the starting point for the grid. Using the Object Inspector, I set the number of columns and rows. I left one fixed row to use for column headings and did away with the fixed column.
After wasting some time trying to find a way to set the text for the column headings using the Object Inspector, I learned that column headings would need to be set in the code. I searched the net looking for sample code and finally found something that did exactly what I needed.
I double-clicked "OnEntry" in the Events column of the Object Inspector. Kylix created an empty function (or is that method?) in the code window for me. I clicked inside of it and entered the following code:
AnsiString sPort = "Port"; AnsiString sAddr = "Remote"; AnsiString sProg = "Program"; AnsiString sStat = "State";StringGrid1->Font->Height = 18; StringGrid1->Font->Color = clBlack;
StringGrid1->Cells[0][0] = sPort; StringGrid1->Cells[1][0] = sAddr; StringGrid1->Cells[2][0] = sProg; StringGrid1->Cells[3][0] = sStat;
Back on the toolbar, I clicked on Run-->Run and watched the nearly empty application compile and come to life. Sure enough, there was my application window, including the column headings, exactly as advertised.
Getting down and dirty
Now it was time to get my hands dirty. No more of that wimpy "click this, click that" stuff. We're talking code ugly code at that, by the time I got finished with it. I had left my barebones C source code as a module of its own. Now I had to cut-and-paste the essential code from its main() and assorted functions and put it all together in the OnEntry function I created above. It went from about 300 lines of code to about half of that.
The Kylix IDE was quick to find and point out errors for me as I tried to compile the mix of code from Kylix and the C module. It only took me 10 or 15 minutes to get almost all the errors resolved. All but one, that is.
I ran into a problem getting the pipe between the netstat program and my module working and had to ask Borland for help. The cure was simply to add #include <stdio.h> to my Kylix program. Then I was back on track and in no time at all the first version of VisNetstat was done.
Later versions of VisNetstat may refine the process, but in the initial release I am only displaying tcp session data. When the user clicks "Do It" (see the screen image below) netstat is executed with -tapn as the arguments.

Editor's note: The above image is reduced in size and color palette to allow it to load quickly. Click on the above image to see the original.
I said earlier the real power of Kylix was in the tool bar, but that may not be right. It may be in the Object Inspector. In my case, it soon became clear my grid for displaying netstat output would have to be larger than a single screen. I would need to make it scrollable.
Remember, I've never written a GUI for X without Kylix. Adding a functional scroll bar could be more work for me than all the rest of the program combined. But not with Kylix. I select the grid so that it appears in the Object Inspector, click on Scroll Bars, then on vertical. That's it. It's done. Now the app displays ten rows in the application window and the user can scroll as needed through all 100 rows in the grid.
In short, Kylix 3 has allowed me to develop this simple C++ GUI app for X in just a few days. Given how little C++ and X development experience I have, and the fact that I've never worked with pipes except from the command line, that's pretty good time. Kylix has demonstrated to me it deserves its RAD label.
Published September 9, 2002 Reads 9,457
Copyright © 2002 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Joe Barr
Joe Barr is a freelance journalist covering Linux, open source and network security. His 'Version Control' column has been a regular feature of Linux.SYS-CON.com since its inception. As far as we know, he is the only living journalist whose works have appeared both in phrack, the legendary underground zine, and IBM Personal Systems Magazine.
- Kindle 2 vs Nook
- Is Cloud Computing Like Teenage Sex?
- GovIT Expo Highlights Cloud Computing
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Cloud Computing Can Revitalize Your Career as Software Developer
- Ubuntu-based Open Source Linux Mint Tests KDE Version
- Yahoo! SVP Shelton Shugar to Discuss Innovation at Cloud Computing Expo
- Virtualization Journal "Readers' Choice Awards" Voting Is Now Open
- Einstein, Sharks and Clouds: IT Security in the Cloud
- Adobe Flex Developer Earns $100K in New York City
- Virtualization Expo Call for Papers Deadline December 15
- Amazon Web Services Database in the Cloud
- Kindle 2 vs Nook
- Cloud CEOs, CTOs & SVPs to Speak at 4th International Cloud Computing Expo
- Is Cloud Computing Like Teenage Sex?
- 1st Annual GovIT Expo: Letter from the Technical Chair
- Ulitzer News: Search vs New Media
- The Difference Between Web Hosting and Cloud Computing
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- Confessions of a Ulitzer Addict
- GovIT Expo Highlights Cloud Computing
- Twitter, Linked In, Ning and Ulitzer: Easy Personal Branding Strategy
- My Thoughts on Ulitzer
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- The i-Technology Right Stuff
- Linux.SYS-CON.com Exclusive: Linus Discloses *Real* Fathers of Linux
- After Ubuntu, Windows Looks Increasingly Bad, Increasingly Archaic, Increasingly Unfriendly
- Linus' Top Ten SCO Barbs
- A Closer Look at Damn Small Linux
- Netscape Co-Founder's 12 Reasons for Growth of Open Source
- Introducing "Cooperative Linux" - Linux for Windows, No Less
- *POINT - COUNTERPOINT SPECIAL* What's Wrong with the Open Source Community?
- Where Are RIA Technologies Headed in 2008?
- Linux.SYS-CON.com Exclusive: What Would UserLinux Look Like?
- i-Technology Viewpoint: The New Paradigm of IT Buying
- Is Linux Desktop-Ready Yet...or Not?































