fpGUI Toolkit is intended for Open Source and Commercial applications. fpGUI uses the LGPL2 license with the static linking exception - the same as the Free Pascal Compiler's RTL.

fpGUI is an Object Pascal toolkit for cross-platform application development. It provides single-source portability across Linux, MS Windows, *BSD and embedded systems running Embedded Linux and Windows CE.

For more information, see the fpGUI Toolkit website at:

The base unit and starting point of fpGUI

This unit contains all the abstract classes for the CoreLib code of fpGUI. It also defines many types and constants used throughout the toolkit.

When implementing support for a completely new windowing system (eg: Carbon used in Mac OS-X) you would implement all the abstract methods defined in this unit.

A custom type used to represent X and Y coordinates. Internally TfpgCoord is actually a Integer type. We created a custom alias type for use in fpGUI in the event that we might want to change the underlying type in the future. Example to floating points. Represents a color in integer format.

TfpgColor is always in RRGGBB (Red, Green, Blue) format, no matter the operating system.

The fpg_base unit also contains definitions of many useful color constants. It defines the standard predefined Delphi colors (like clRed, clMagenta etc.), the 140 web safe colors using the defacto standard names as used by Netscape and Internet Explorer web browsers. As well as some internal color constants used by many GUI components (like clText, clWindowBackground etc.).

A record structure holding the RGBA values of a color . This is now marked as "deprecated". Please use TFPColor instead. Alpha support has not really been implemented in fpGUI yet. Enum type defining what types of windows can be created. The window being created is a child on another window. This normally means no titlebar or window borders are going to be created. This would specify a standard window with titlebar and window borders. This would specify a standard window with titlebar and window borders. It grabs input focus, and appears in the taskbar. This windows type is similar to wtWindow, but grabs focus. This windows is the same as wtWindow, but grabs the input focus until it has closed. This window normally doesn't appear in the taskbar. This window will normally not have a titlebar or window borders. This window will normally not have a titlebar or window borders and will appear above other windows. It is used for example in the dropdown window of a ComboBox or a tooltip window or popup menus. This type of window does not steal focus. An enum types defining extra attributes of a window. If this attribute is set, the window will be resizeable by the user. If this attribute is set, the underlying window manager will decide where the window will be placed on the screen, when it becomes visible for the first time. The window will have no border painted. This is used in windows like Tooltips, Splash screens etc. When set, this will tell the window manager to create the window in a full screen state. When set, the fpGUI framework will calculate the remaining desktop space (minus the window height), and then position the window one third of the way down (from the top of the screen). This is usually a more desired position than the screen center. If this attribute is set, the window will be centered on the screen when it is shown for the first time. If set, the window will always be above all other windows. This is used for example is Splash Screen windows. A set of TWindowAttribute types. TWindowAttribute Enum types of the available mouse cursor shapes. Normally the default arrow cursor. Normally a hourglass or watch representing a busy state. Enum types defining how a gradient must be painted Defines that the gradient must be painted vertically. Defines that the gradient must be painted horizontally. Represents the type of entry found on the filesystem. Denotes a File type Denotes a Directory type Represents the clipboard function being triggered by some keyboard key combination. No clipboard action detected Copy to clipboard action detected Paste to clipboard action detected Cut to clipboard action detected Constant representing the left mouse button. Constant representing the right mouse button. Constant representing the middle mouse button. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. Platform independent messages used by fpGUI. The default base font used in fpGUI A graphical (pixel based) rectangle structure used throughout fpGUI.

Note that this structure is not a class, so static allocations are allowed. This makes it much easier to use in Widgets and in fpGUI internal messages.

Think of the pixel screen/grid like the grid of a spreadsheet (or as a magnified look of the top corner of your screen).

.
     0   1
   +---+---+---
0  | x |   |
   +---+---+---
1  |   |   |
   +---+---+---
2  |   |   |
   +---+---+---
   |   |   |

x is at (0,0). A pixel is always 1x1, you don't get smaller (we are not using sub-pixels like on LCD screens, because they don't apply to all screens).

So with that example, Width = 1 pixel and Height = 1 pixel. In the case of Classes.Bounds() the Right and Bottom values are (1,1) which looking at the above image will be wrong, the pixel only covers one block, so in a screen/pixel environment, Right, Bottom is also (0,0), the same as Top/Left. This is what TfpgRect.Right and TfpgRect.Bottom will report.

.
     0   1
   +---+---+---
0  | x | x |
   +---+---+---
1  | x | x |
   +---+---+---
2  |   |   |
   +---+---+---
   |   |   |

In this example we have a rectangle. Top/Left = (0,0) and Bottom/Right = (1,1). This means Width = 2 pixels and Height = 2 pixels. Clearly visible in the image above.

But if we call Classes.Bounds(0,0,2,2) it reports Bottom/Right as (2,2) which is wrong (again looking at the image above as reference). This is my point. Bounds() cannot be used in this case in a graphical environment.

The reason I don't use a grid layout as shown below, is because if the mouse is over the rectangle containing x, the OS (graphics system) reports its position as (0,0). You don't have to have the mouse pointer over the intersecting lines at (0,0) as indicated in the image below. The whole square containing the x is referenced as (0,0), hence the grid layout as show in the images above, and what fpGUI uses. The same grid layout as used in TfpgStringGrid or any Spreadsheet program etc.

.
   0   1   2
0  +---+---+---
   | x |   |
1  +---+---+---
   |   |   |
2  +---+---+---
   |   |   |
3  +---+---+---
   |   |   |
A convenience function to quickly set a rectangle structure. Calculates and returns the bottom position of the rectangle. Calculates and returns the Right most position of the rectangle. Sets the bottom value and recalculates the Height value. Sets the Right value and recalculates the Width value. Abstract class use for representing a Window or Widget fpGUI is a Windowed toolkit. By that we mean that every widget has a window handle. Widgets are essentially embedded windows without titlebars or borders, inside a parent window. Forces fpGUI to act on window position and size properties

fpGUI implements what is called "delayed resource allocation". It delays some action until everything is ready to go. This delayed action applies to setting Widget or Form size and position. Why? Imagine you have a complex form with lots of anchors, alignments and OnResize event handlers. Now somewhere in there you change the size or position of a component.

MyWidget.Left := ... MyWidget.Top := ... MyWidget.Width := ... MyWidget.Height := ...

If fpGUI acted immediately, as every property is set, it means it would have to recalculate all those widget boundaries, and fire all OnResize event handlers of the whole form four times. Once for each property - as you set them. Not very efficient! To reduce such redundant calculations, fpGUI allows you to set all the properties, then act on it once you call UpdateWindowPosition. In most cases fpGUI can even reduce the API calls needed, because it could pass for example Width and Height via one API call. In the case of X11, it can actually do all four values in a single API call. Thus improving efficiency and reduces resize calculations and screen redraws.

Specifies the horizontal coordinate of the left edge of a component relative to its parent

. Use the Left property to determine where the left side of the control begins or to reposition the left side of the control.

fpGUI delays acting on the Top, Left, Width and Height properties of a control until the UpdateWindowPosition method is called. For more information on why this is so, see UpdateWindowPosition help.
TfpgWindowBase.UpdateWindowPosition
Specifies the vertical (X) coordinate of the top edge of a component relative to its parent

. Use the Top property to determine where the top side of the control begins or to reposition the top side of the control.

fpGUI delays acting on the Top, Left, Width and Height properties of a control until the UpdateWindowPosition method is called. For more information on why this is so, see UpdateWindowPosition help.
TfpgWindowBase.UpdateWindowPosition
Specifies the horizontal size of the control or form in pixels

. Use the Width property to read or change the width of the control. For TfpgTabSheet controls of for controls that have their Align property set to alTop, alBottom or alClient, changing this property at runtime has no effect.

fpGUI delays acting on the Top, Left, Width and Height properties of a control until the UpdateWindowPosition method is called. For more information on why this is so, see UpdateWindowPosition help.
TfpgWindowBase.UpdateWindowPosition
Specifies the vertical size of the control or form in pixels

. Use the Height property to read or change the height of the control. For TfpgTabSheet controls of for controls that have their Align property set to alLeft, alRight or alClient, changing this property at runtime has no effect.

fpGUI delays acting on the Top, Left, Width and Height properties of a control until the UpdateWindowPosition method is called. For more information on why this is so, see UpdateWindowPosition help.
TfpgWindowBase.UpdateWindowPosition
Abstract class used to represent a Canvas for painting Abstract class used to represent a Image Inverts the Image . This changes the actual data of the image. There is no undo function. So if you want to undo this action, you must keep copy of the original image before you call Invert. Allocates OS resources for the Image Allocates OS resources for the Image Mask Creates a mask based on the sample point presented by X and Y parameters Updates the internal image resources and OS resources from image data Width of the image Height of the image Color depth of the image. Currently 24/32-bit is all that is supported. Array property to access a specific color of the image based on X and Y co-ordinates Encapsulates the resources of a font A abstract class representing a base Interpolation filter. This is used as the base class to implement Interpolation filters like Gaussian, Sinc etc... These decendant filters are used in the Canvas.StretchDraw function. Canvas.StretchDraw Draws a rectangle. You can specify the size of the rectangle via X, Y, Width and Height parameters or via a TfpgRect parameter. Draws a line . This method draws a line from (x1,y1) to (x2,y2), but does not draw the last pixel. All supported backends follow the Microsoft API and doesn't draw the last pixel. This optimises consecutive lines being drawn without overlapping pixels. Returns the text representation of a keycode. This is mainly used for debugging, but could also be used for Menu Item keyboard shortcuts etc. Detects if the pressed keys represent a Clipboard key shortcut Detects if the pressed keys represent a Clipboard key shortcut. If it does, it returns the correct enum type detected. Converts the TfpgColor to TRGBTriple type This function converts the given TfpgColor into a TRGBTriple type. TRGBTriple Converts the TRGBTriple to TfpgColor type This function converts the given TRGBTriple into a TfpgColor type. TRGBTriple Returns the Red portion of a color value. Returns the Green portion of a color value. Returns the Blue portion of a color value. Returns the Alpha portion of a color value. Calculates the average color using the two supplied This function calculates and returns the average color by using AColor1 and AColor2. The Alpha value also gets taken into account. Returns true if APoint is inside ARect rectangle This function is used to detect if the point APoint is inside the given rectangle ARect. If it is, the function returns True, otherwise False. Fixes the Top, Bottom and Left, Right to always represent a valid rectangle This function fixes a rectangle so that the Left point is always smaller than the Right. And the Top is always smaller than the Bottom. Draws a line inside a clip rectangle

. This procedure clips a line to the AClipRect boundaries and then calls the DrawLine procedure with the clipped coordinates. If the line lies completely outside of the clip boundary, then the Line routine is not called. This procedure uses the well known Cohen-Sutherland line clipping algorithm to clip each coordinate.

Use this if you do not want to change the Canvas.ClipRegion for some reason. For a detailed explanation see: http://www.nondot.org/~sabre/graphpro/line6.html

Clips the line based on AClipRect boundaries. This does not do any drawing, in only clips the line coordinates. This method is used internally by . Paints a rectangle with a gradient . If the gradient direction is set to gdHorizontal, then it pains from left to right. If the gradient direction is set to gdVertical, then it paints from top to bottom. A simple data object representing a file . Some properties are OS dependant. Name of a file The extension of a file Size of a file in bytes Is this item a symbolic link (on unix-type OSes) If it is a symbolic link, LinkTarget is what it points too Last modified timestamp A record structure holding the RGBA values of a color. This is the same declaration as the one found in FPImage (included with the Free Pascal Compiler). In future when FPImage is integrated with fpGUI, this declaration will be removed. An extension of the FPC TPoint structure

. This structure is used inside the fpGUI framework, and includes some extra methods like calculating lengths between to points etc.

Quick calculation of the length between points

Returns the sum of the absolute values of X and Y, traditionally known as the "Manhattan length" of the vector from the origin to the point. For example:

var oldPosition: TfpgPoint; newPosition: TfpgPoint; begin newPosition := MousePosition - oldPosition; if (newPosition.ManhattanLength > 5) then begin // the mouse has moved more than 5 pixels since the oldPosition end; end;

Accuracy is traded for speed. This is a useful, and quick to calculate, approximation to the true length:

TrueLength := sqrt(power(X, 2) + power(Y, 2));

The tradition of "Manhattan length" arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.

For a further explanation of "Manhattan length" see the Wikipedia article on Taxicab geometry.