LPTK Core Reference

Authors:

Viktor Nagy <nvitya@freemail.hu>

This document is related to the LPTK project at lptk.sourceforge.net

Table of Contents

General types	3

Simple types	3

TWinHandle	3

TGfxCoord	3

TGfxColor	3

TGfxRect	3

TSizeParams	3

TOrientation	3

TAlignment	3

TAnchor	3

TAnchors	3

TClipboardKeyType	3

Classes	3

TGfxFont	3

TGfxCanvas	3

TGfxImage	3

Event handler procedure types	3

TNotifyEvent	3

TKeyPressNotifyEvent	3

TMouseNotifyEvent	3

Unicode (16 bit format) string handling	4

Types	4

String8	4

String16	4

Char16	4

Conversion functions	4

Str8to16	4

Str16to8	4

u8	4

u8u16	4

u8noesc	4

u16u8	4

u16u8safe	5

u16u8trunc	5

16 bit string handling functions	5

Length16	5

SetLength16	5

Pos16	5

UpCase16	5

Upper16	5

Copy16	5

Insert16	5

Delete16	5

AddChar16	5

AddChar16	5

Constants	6

Keyboard Constants	6

Keyboard Modifier Keys (Shift State Bits)	6

Mouse cursor shape codes	6

Message Subsystem	7

Message record	7

Message delivering	7

Message destination validation	7

Messages	8

MSG_PAINT	8

MSG_KEYPRESS	8

MSG_KEYRELEASE	8

MSG_ACTIVATE	8

MSG_MOUSEDOWN	8

MSG_MOUSEUP	8

MSG_MOUSEMOVE	8

MSG_CLOSE	8

MSG_LPTKINT	8

MSG_SCROLL	8

MSG_RESIZE	8

MSG_POPUPCLOSE	8

MSG_MOUSEENTER	8

MSG_MOUSEEXIT	8

MSG_DEACTIVATE	8

MSG_MOVE	8

MSG_DOUBLECLICK	8

Global functions	9

General	9

GfxOpenDisplay	9

GfxCloseDisplay	9

GfxColorToRGB	9

GfxGetFont	9

GfxGetFontFaceList	9

GfxProcessMessages	9

WaitWindowMessage	9

GfxDoMessageLoop	9

GfxFlush	9

GfxActivateWindow	9

GfxGetAbsolutePosition	9

GfxSetMouseCursor	9

GfxCheckClipboardKey	9

GfxIsAlphaNum16	9

GfxHideConsoleWindow	9

Image Handling	10

CreateBMPImage	10

GfxLibAddImage	10

GfxLibDeleteImage	10

GfxLibGetImage	10

GfxLibAddBMP	10

GfxLibAddMaskedBMP	10

GfxStyle: GUI Look And Feel	11

Named Colors	11

Named Fonts	11

Global Font Objects	12

Drawing functions	12

DrawButtonFace	12

DrawControlFrame	12

DrawDirectionArrow	12

Base classes	13

TWidget	13

TGfxForm	13

General types

Simple types

TWinHandle

TGfxCoord

TGfxColor

Unit:	gfxbase

TGfxRect

TSizeParams

TSizeParams = record

min_width, max_width,

min_height, max_height : TGfxCoord;

end;

TOrientation

TOrientation = (orVertical, orHorizontal);

TAlignment

TAlignment = (alLeft, alRight, alCenter, alJustify);

TAnchor

TAnchor = (anLeft,anRight,anTop,anBottom);

TAnchors

TAnchors = set of TAnchor;

TClipboardKeyType

TClipboardKeyType = (ckNone, ckCopy, ckPaste, ckCut);

Classes

TGfxFont

TGfxCanvas

TGfxImage

Event handler procedure types

TNotifyEvent

TNotifyEvent = procedure(Sender : TObject) of object;

TKeyPressNotifyEvent

TKeyPressNotifyEvent = procedure(Sender: TObject; var keycode: word; var shiftstate: word; var consumed : boolean) of object;

TMouseNotifyEvent

TMouseNotifyEvent = procedure(Sender: TObject; x,y : integer; var button : word; var shiftstate : word) of object;

Unicode (16 bit format) string handling

The LPTK uses 16 bit unicode strings internally to store the texts that can be displayed on the screen. LTPK stores these strings in normal 8-bit ansi strings. The LPTK programmer should know the string is 16-bit or not. There are (loseless) conversion functions for both directions. LTPK uses the ^ character as escape in 8-bit string encoding to mark special characters. For example “t^369r^337;6” means ”tűrő6”.

8-bit encoding is very important, for example when store unicode strings in pascal source files. The 8-bit encoding can be inportant also when storeing unicode texts into database fields.

All 16 bit string handling functions and types reside in the schar16 unit.

Types

String8

Alias to string. LPTK uses this alias to show the programmers that this string value is 8-bit encoded.

String16

Alias to string. LPTK uses this alias to show the programmers that this string value is 16-bit encoded.

Char16

Char16 = packed record

char1 : char;

char2 : char;

end;

Defines the 16-bit character. This type is rarely used.

Conversion functions

Str8to16

function Str8to16(s : String8) : string16;

Same as u8. Converts the 8 bit argument into 16 bit string. Converts escapes into real unicode characters. Invalid escapes (^ characters) will be ignored.

Str16to8

function Str16to8(s : String16) : string8;

Alias to u16u8. This function escapes only 256..65535.

u8

function u8(s : String8) : string16;

Converts the 8 bit argument into 16 bit string. Converts escapes into real unicode characters. Invalid escapes (^ characters) will be ignored.

u8u16

function u8u16(s : String8) : string16;

Same as u8. Converts the argument into 16 bit string. Decodes the escapes also.

u8noesc

function u8noesc(s : String8) : string16;

Inserts only #0 characters, doesn't handle escapes.

u16u8

function u16u8(s : string16) : string8;

Converts the 16-bit argument into 8-bit escaped form. This function escapes only 256..65535.

u16u8safe

function u16u8safe(s : string16) : string8;

Converts the 16-bit argument into 8-bit escaped form. This function escapes 0.31 and 255..65535 characters.

u16u8trunc

function u16u8trunc(s : string16) : string8;

Converts the 16-bit argument into 8-bit non-escaped form. Truncates hi byte, doesn't use escapes. Later it will support the language code page for the conversion. It can cause loss of information.

16 bit string handling functions

Length16

function Length16(s : String16) : integer;

Return the length of the 16-bit string. The result is the length of the 8-bit length ot the argument divided by 2.

SetLength16

procedure SetLength16(var s : String16; len : integer);

Sets the 16-bit length of the argument string variable. Same as SetLength(s,len*2).

Pos16

function Pos16(const s : string16; const searched : string16) : integer;

This is the 16 bit version of the pos function. All arguments are 16-bit strings.

UpCase16

function UpCase16(const s : string16) : string16;

Converts the first 16-bit character of the argument string into uppercase.

Upper16

function Upper16(const s : string16) : string16;

Converts the argument into uppercase.

Copy16

function Copy16(s : String16; ind,len : integer) : String16;

This is the 16 bit version of the copy function.

Insert16

procedure Insert16(s : String16; var dest : string16; ind : integer);

This is the 16 bit version of the insert function.

Delete16

procedure Delete16(var s : String16; ind, count : integer);

This is the 16 bit version of the delete function.

AddChar16

procedure AddChar16(var s : String16; ch16 : Char16); overload;

Appends the ch16 16-bit character to the s 16-bit string argument.

AddChar16

procedure AddChar16(var s : String16; w : word); overload;

Appends the 16-bit character w to the s 16-bit string argument.

Constants

Keyboard Constants

The following key codes are predefined currently in LPTK:

KEY_LEFT

KEY_RIGHT

KEY_DOWN

KEY_UP

KEY_END

KEY_HOME

KEY_PGUP

KEY_PGDN

KEY_INSERT

KEY_DELETE

KEY_ENTER

KEY_ESC

KEY_BACKSPACE

KEY_TAB

KEY_STAB

KEY_F1

KEY_F2

KEY_F3

KEY_F4

KEY_F5

KEY_F6

KEY_F7

KEY_F8

KEY_F9

KEY_F10

KEY_F11

KEY_F12

For these keys you must use these contants because they can be different on the different platforms.

Keyboard Modifier Keys (Shift State Bits)

Identifier	Value
ss_Shift	$0001
ss_Control	$0004
ss_Alt	$0008
ss_CapsLock	$0002
ss_NumLock	$0010
ss_ScrollLock	$0080

Mouse cursor shape codes

Constant name	Description
CUR_DEFAULT	Arrow cursor
CUR_DIR_EW	East-West direction resizer cursor
CUR_DIR_NS	North-South direction resizer cursor
CUR_EDIT	Text edit cursor
CUR_DIR_NWSE	North-West – South-East direction resizer cursor
CUR_DIR_NESW	North-East – South-West direction resizer cursor
CUR_MOVE	Move cursor
CUR_CROSSHAIR	Crosshair cursor

Message Subsystem

LPTK has an internal message queue. This is strongly used in Linux and less in Windows.

Message record

TMessageRec = record

MsgCode : integer;

Sender : TObject;

Dest : TObject;

Param1 : integer;

Param2 : integer;

Param3 : integer;

end;

PMessageRec = ^TMessageRec;

Message delivering

procedure PostMessage(Sender, Dest : TObject; MsgCode : integer; Param1, Param2, Param3 : integer);

procedure SendMessage(Sender, Dest : TObject; MsgCode : integer; Param1, Param2, Param3 : integer);

procedure DeliverMessage(var msg : TMessageRec);

procedure DeliverMessages;

function GetFirstMessage : PMessageRec;

procedure DeleteFirstMessage;

Message destination validation

var

ValidateMessageDest : boolean;

// Destination address validation:

procedure RegisterValidDest(obj : TObject);

procedure UnRegisterValidDest(obj : TObject);

Messages

MSG_PAINT

MSG_KEYPRESS

MSG_KEYRELEASE

MSG_ACTIVATE

MSG_MOUSEDOWN

MSG_MOUSEUP

MSG_MOUSEMOVE

MSG_CLOSE

MSG_LPTKINT

MSG_SCROLL

MSG_RESIZE

MSG_POPUPCLOSE

MSG_MOUSEENTER

MSG_MOUSEEXIT

MSG_DEACTIVATE

MSG_MOVE

MSG_DOUBLECLICK

Global functions

General

GfxOpenDisplay

function GfxOpenDisplay(DisplayName : string) : boolean;

GfxCloseDisplay

procedure GfxCloseDisplay;

GfxColorToRGB

function GfxColorToRGB(col : TGfxColor) : TGfxColor;

GfxGetFont

function GfxGetFont(desc : string) : TGfxFont;

GfxGetFontFaceList

function GfxGetFontFaceList : TStringList;

GfxProcessMessages

procedure GfxProcessMessages;

WaitWindowMessage

procedure WaitWindowMessage;

GfxDoMessageLoop

procedure GfxDoMessageLoop;

GfxFlush

procedure GfxFlush;

GfxActivateWindow

procedure GfxActivateWindow(wh : TWinHandle);

GfxGetAbsolutePosition

procedure GfxGetAbsolutePosition(wh : TWinHandle; x,y : TGfxCoord; var xap, yap : TGfxCoord);

GfxSetMouseCursor

procedure GfxSetMouseCursor(wh : TWinHandle; cur : integer);

GfxCheckClipboardKey

function GfxCheckClipboardKey(key, shiftstate : word) : TClipboardKeyType;

GfxIsAlphaNum16

function GfxIsAlphaNum16(s : string16) : boolean;

GfxHideConsoleWindow

procedure GfxHideConsoleWindow;

Image Handling

CreateBMPImage

function CreateBMPImage(bmp : pointer; bmpsize: longword) : TGfxImage;

GfxLibAddImage

function GfxLibAddImage(const imgid : string; img : TGfxImage) : boolean;

GfxLibDeleteImage

function GfxLibDeleteImage(const imgid : string; freeimg : boolean) : boolean;

GfxLibGetImage

function GfxLibGetImage(const imgid : string) : TGfxImage;

GfxLibAddBMP

function GfxLibAddBMP(const imgid : string; bmpdata : pointer; bmpsize : integer) : TGfxImage;

GfxLibAddMaskedBMP

function GfxLibAddMaskedBMP(const imgid : string; bmpdata : pointer; bmpsize : integer; mcx, mcy : integer) : TGfxImage;

GfxStyle: GUI Look And Feel

Named Colors

Color Constant	Default RGB	Description
clWindowBackground	D4D0C8	
clBoxColor	FFFFFF	
clShadow1	808080	
clShadow2	404040	
clHilite1	E0E0E0	
clHilite2	FFFFFF	
clText1	000000	
clText2	000040	
clText3	800000	
clText4	404000	
clSelection	000080	
clSelectionText	FFFFFF	
clInactiveSel	D0D0FF	
clInactiveSelText	000000	
clScrollBar	E8E4DB	
clButtonFace	D4D0C8	
clListBox	FFFFFF	
clGridLines	A0A0A0	
clGridHeader	E0E0E0	
clWidgetFrame	000000	
clInactiveWgFrame	A0A0A0	
clTextCursor	000000	
clChoiceListBox	E8E8E8	
clUnset	D0D0FF	
clMenuText	000000	
clMenuDisabled	909090	

Named Fonts

Font Identifier	Default value	Description
Label1	Arial-10	
Label2	Arial-10:bold	
Edit1	Arial-10	
Edit2	Courier New-10	
List	Arial-10	
Grid	Arial-9:antialias=false	
GridHeader	Arial-9:bold:antialias=false	
Menu	Arial-10	
MenuAccel	Arial-10:bold	
MenuDisabled	Arial-10:italic	

Global Font Objects

These object help to lazy programmers. You can use the guistyle.DefaultFont if you need urgently a valid font object. These are created using named fonts.

Font Object Variable	Named Font ID
DefaultFont	Label1
MenuFont	Menu
MenuAccelFont	MenuAccel
MenuDisabledFont	MenuDisabled

Drawing functions

DrawButtonFace

procedure DrawButtonFace(canvas : TGfxCanvas; x,y,w,h : TGfxCoord);

DrawControlFrame

procedure DrawControlFrame(canvas : TGfxCanvas; x, y, w, h : TGfxCoord);

DrawDirectionArrow

procedure DrawDirectionArrow(canvas : TGfxCanvas; x,y,w,h : TGfxCoord; direction : integer);

Base classes

TWidget

TGfxForm

Database handling

TSqlDBConnection

TSqlResult

TDBuis

LPTK Core Reference - 11

LPTK Core Reference

2004-04-17T23:02:08