Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux...

43
Linux RAD/GUI Development Kylix Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software [email protected]

Transcript of Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux...

Page 1: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux RAD/GUI Development

Kylix – Rapid Application Development (RAD),

GUI Development for Linux from Borland

by Leland Brode

ELB Software

[email protected]

Page 2: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux GUI Development

Presentation Outline

– Background on GUI Development– Overview of Kylix– Demo GUI Tools– Demo Delphi– Demo Kylix

by Leland Brode

ELB Software

[email protected]

Page 3: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux GUI Development

Kylix– RAD/GUI tool for Linux– Port of Delphi for Windows – Runs on Linux– Builds, compiles native Linux

applications– Cross platform – Windows/Linux

Page 4: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

GUI Dev Background

Windows 3.0 – 1990– Generates Messages

Basic, COBOL, C– All Text

Visual Basic – 1991– First GUI Dev Tool– Event Handlers – code that runs

before or after an Event– Draw window instead of code it– Most widely used language

“Visual Basic 6 Bible” - Smith Whistler, & Marquis

Page 5: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

GUI Dev Background

Other GUI Dev Tools– PowerBuilder– Visual Age– Digitalk, ParcPlace Smalltalk– Forte ( now at Sun)– Visual C++– Borland C++– Borland Delphi– Borland C++Builder– --------------------------– Visual Café - Java– JBuilder - Java

Page 6: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux Developement

GNU Linux Toolkit– GCC– Compiles C, C++, Objective C,

Fortran– Handles Front-ends for Pascal,

Modula-3, Ada– Distributed with Linux

Perl, Shell scripting

Page 7: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux Developement

Qt Class Library– C++– Cross Platform

Qt/Windows Qt/X11 (Linux, Solaris, HPUX,

AIX, etc) Qt/Mac

– GPL – Free for non-commercial apps

– Qt was used to build KDE– from Trolltech in Norway– www.trolltech.com

Page 8: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux Development

Qt Class Libray Qwidget base class

– Event Handlers mousePressEvent (QMouseEvent &); mouseMove Event (… mousePressEvent (… enterEvent (… Class QMouseEvent : public Qevent { public: int x(); int y(); int button(); int state();

“Linux Programming Unleashed” – Kurt Wall - SAMS

Page 9: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Linux Development

Open Source IDE’s– KDevelop – www.kdevelop.org– KDE Studio –

www.thekompany.com/projects/kdestudio– Code Crusader – www.newplanetsoftware.com– VDK Builder – vdkbuilder.sourceforge.net– Source-Navigator –

sources.redhat.com/sourcenav

“C/C++ Users Journal”, March 2001 – www.cuj.com

Page 10: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Delphi Background

Borland’s Delphi =– Pascal, plus– Borland’s implementation of OO in

Pascal, plus– GUI IDE, plus– Visual Component Library (VCL) - encapsulates Windows controls

Page 11: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Delphi

Pascal– Pascal dev by Niklas Wirth (Swiss,

1970)– Versions: U of C San Diego, Borland– Borland’s Turbo Pascal 1.0 - ?– Turbo Pascal 3.0 for DOS - 1985– Object Extensions to Pascal 5.5 - ?– Turbo Pascal for Windows - 1991– Delphi - OO Pascal – 1995

polymorphism, inheritance, encapsulationhttp://www.engin.umd.umich.edu/CIS/course.des/cis400/index.htmlhttp://www.emsps.com/oldtools/borpasv.htm

Page 12: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Delphi

GUI Integrated Development Environment– Based on Visual Basic model

Page 13: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Delphi

IDE– project manager

keeps track of all source files for a project

– code editor code completion

– GUI form designer– integrated debugger

watch variables change variables breakpoints step through code

Page 14: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Port of Delphi to Linux– OO Pascal– Delphi IDE– native Linux compiler– Class Library - CLX

Object wrappers for Qt widgets– Borland chose Qt over GTK+

Delphi’s VCL re-engineered to CLX

Page 15: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Class Libraries– CLX is to Kylix– VCL is to Delphi, C++Builder– MFC is to Visual C++– Qt is to KDE– GTK is to GNOME– CLX runs on Linux and Windows

Page 16: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Delphi

VCL Class Library– Object wrappers for Windows Controls

TObject

|

TControl __

| |

TForm TButton

Page 17: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

CLX Class Library– Object wrappers for Qt Widgets

TObject |TControl __ | |TForm Tbutton

– CLX also in Delphi 6, and C++Bldr for cross platform

Page 18: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language– Source File = Unit– Units -> compile, link -> executable

code - .pas file form - .dfm file

( each form has a .pas file )

Page 19: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language– Data types

Integer – 2147483648 to 2147483647 Cardinal 0 to 4,294,967,785 Byte 0 to 255 Double floating point Currency

– Arrays – MyArray : array[0..10] of Integer; // fixed MyArray : array of Integer; // dynamic SetLength(MyArray, length); // allocates memory for

dynamic array MyArray[length-1] := 1,024 // assignment

Page 20: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language– String – dynamic

Concat, Copy, Delete, Insert, Length, Pos, SetLength

– Pointers– Exceptions

Try-except (same as try-catch in java, c++)

– File IO– function – returns value– procedure – no return value

Page 21: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language - function

function Factorial(Number : Cardinal): Int64;

var

N : Cardinal;

begin

Result := 1;

for N := 2 to Number do

Result := Result * N;

end;

Page 22: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – class definitiontype TAccount = class private fNumber : Cardinal; fBalance : Currency; public procedure WithDraw(Amount : Currency); end;

TSavingsAccount = class (TAccount) private fReturnCheck : Boolean end;TCertificateof Deposit = class(TSavingsAccount) private fTerm : Cardinal; end;

Page 23: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – use classes

var CD1, CD2 : TAccount;begin CD1 := TCertificateofDeposit.Create; CD2 := TCertificateofDeposit.Create; … CD1.WithDraw(100.00); … …

CD1.Free; CD2.Free;end;

Page 24: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – Records and Arraystype PersonType = record LastName : String[10]; FirstName : String[10]; EmployeeNumber : Integer; end; { Persontype }

MyArrayType = array [1..5] of PersonType;

var PersonArray : MyArrayType;begin PersonArray[1].FirstName := ‘Donald’; PersonArray[1].LastName := ‘Duck’; …

Page 25: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – Components and Arrays

var ButtonArray : array of TButton; i, Num : integer;begin Num :=0; for i := 0 to Self.ComponentCount –1 do // ‘Self’ same as ‘this’ in C++ if Self.Components[i] is TButton then begin Inc(Num); SetLength(ButtonArray, Num); ButtonArray[Num-1] := TButton(Components[i]); end;end;

Page 26: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – ComparisonPascal…var i : Integer;begin i := 1;

C++… int i; i = 1;

Perl…my $i;$i = 1;

Page 27: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – Comparison

Pascal…

var

i : Integer;

name String[20];

begin

if i = 1 then

begin

name := ‘Leland’;

i := i + 1;

end;

end;

C++…

int i;

char name[20];

if(i == 1) {

strcpy(name, “Leland”);

i = i + 1;

}

Perl…

my $i;

my $name;

if($i == 1) { $name = ‘Leland’; $i = $i + 1; }

Page 28: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – Comparison

Pascal…

while i < 100 do Inc(i);

C++…

while (i < 100) i++;

Perl…

while ($i < 100) { $i++;}

Page 29: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Pascal Language – ComparisonPascal…

for i := 0 to 100 do begin

if i = 50 then Break;

end;

C++…

for( i = 0; i <= 100; i++)

if( i == 50) break;

Perl…

for( $i = 0; $ i <= 100; $i++) {

if( $i == 50) last;

}

Page 30: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Qt– access to all Qt Widget public Events

and Properties

Libc– access to all ‘libc’ functions

Page 31: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

GUI Applications Database Applications Console Applications Web Server Applications

Page 32: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Linux Multiprocessing apps– separate memory, communicate via file

system

Linux Multithreading apps– same memory, share resources– TThread base class

Page 33: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

GUI Applications - (CLX TForm class)– Form1.Canvas.Brush.Color := clRed;

– or := RGB(255, 0, 0);

– Form1.Canvas.Rectangle(10, 10, 100, 100);– Form1.Canvas.Pen.color := clBlack;– Form1.Canvas.Pen.Width := 2;– Form1.Canvas.MoveTo(0, 20); // draw line– Form1.Canvas.LineTo(60, 20); // draw line– Form1.Canvas.Font.Name := ‘Arial’;– Form1.Canvas.Font.Size := 24;– Form1.Canvas.TextOut(30,1, ‘Hello World’); // write text

Page 34: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Database Applications– db : TClientDataSet– db.FileName := ‘/xxx/nnn/yyy’;– db.Open;– db.Locate(‘EmpNum’, ‘124433’, []);– mystring := db.FieldValues[‘LastName’];

Page 35: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Database Applications– db : TSQLDataSet– db.CommandText := ‘select * from ….’;– db.Open;

Page 36: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Database Applications– data aware controls– automatically fill in data value from

database– automatically update data value to

database– controls can be ‘Active’ while building

form

Page 37: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Web Applications

- raw CGI

or

- TWebApplication

|

TCGIApplication

Page 38: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Kylix Versions– Kylix 1, 2, 3 (I am using 2)

– Kylix 1, 2 – Delphi (Pascal)

– Kylix 3 – add C++ Builder (C++)

– Kylix Enterprise - Web, Middleware objects, Database objects

– Kylix Professional - Database objects

– Kylix Open Edition – Build open source apps licensed under GNU General Public License

Page 39: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Technical Requirements – Kylix 2– Pentium 400 Mhz ( I am using 366 Mhz)– 128MB RAM ( I am using 192MB)– 175MB disk space– Red Hat 6.2 or higher (I am using 7.2, Kernel

2.4.7)– SuSE 7.0 or higher

Page 40: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Kylix Download– http://www.borland.com/products/download

s/download_kylix.html#

– Kylix 3 currently available– Kylix 2 ??

Page 41: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

FreeCLX Project• Open Source CLX Class Library

• available at SourceForge.net

• includes BaseCLX, VisualCLX, and DataCLX classes (brings full functionality to Kylix Open Edition ?)

• lack of detailed information on FreeCLX

Page 42: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

Bibliography• “Visual Basic Bible”, Smith, Whistler, & Marquis• “Delphi in a Nutshell”, Ray Lischer, O’Reilly• “Linux Programming Unleashed”, Kurt Wall, SAMS• “Object Pascal Language Guide”, Borland Delphi 3 Documentation• “Teach Yourself Delphi in 21 Days”, Osier, Grobman, & Batson, SAMS• “Kylix: The Professional Developer’s Guide and Reference”, Jon Shemitz, Apress• “Mastering Kylix 2”, Cantu & Barbini, SYBEX• “Borland Kylix Developer’s Guide”, Calvert, Calvert, Kaster, & Swart, SAMS• “In the Trenches”, by Dale Fuller, LINUX Magazine, January 2002• Product Review of Kylix 2, LINUX Magazine, May 2002• “Kylix vs. gcc Development” http://community.borland.com/article/0,1410,28555,00.html• “Technical Overview of the Kylix Compiler”

http://community.borland.com/article/0,1410,28561,00.html• “Apache Development with Kylix” http://community.borland.com/article/0,1410,28556,00.html • Kylix and Qt, excerpts form Kylix newsgroup

http://community.borland.com/article/0,1410,21850,00.html• Kylix newsgroup – “borland.public.kylix,non-technical”

Page 43: Linux RAD/GUI Development Kylix – Rapid Application Development (RAD), GUI Development for Linux from Borland by Leland Brode ELB Software elbrode2@attbi.com.

Kylix

product demo…