XControl class (in XForms unit)XCanvas controlXGraphics.pas unit

     XGraphics unit of XCL is containing only definition of necessarily both for MFC-based and self-painted (using canvas) controls simple graphic objects - XPen, XBrush and XFont. All these three classes are direved from XGraphicObject, which is descendent of poor Pascal object TObject. So, if You create any of these objects, You are responsible for its freeing. This is made as well as it is in VCL.
    But using of XPen, XBrush and/or XFont in XCL classes does not require canvases as it is done in Delhi VCL. It is because XGraphicObject knows nothing about its owner, it is usual object of Delphi, which can own of handle of its appropriate windows GDI object (if it is actually created).
    Because XCL is intended to create small applets, it usually does not need in complex threads-oriented controlling of GDI objects. Therefore, there is exist add-on, which allows caching of GDI resources and avoid its duplicating. You may include it and use it if You create applet with very large painting (or with great number of controls) - to economy GDI resources.
    I'd like to notice You that XFont of XCL (vs TFont of VCL) has embedded property Orientation, which potentially allows painting of rotated text. But some additional conditions have to be met:

    Another difference is follow: if You want to set bitmap to XBrush object, use HBitmap type (Windows handle of bitmap object). This allows to XBrush and other XGraphicObject to know nothing about bitmap objects similar Delphi ones (having canvas, supporting load/save to/from stream, and other overbloats).

    Also, this unit contains definition of class XGraphicsManager and declaration of single global variable of that type GlobalGraphicsManager, which is used to provide interface with optional add-ons (e.g., with add-on XCanvasObjects.pas).


XGraphicObject = class( TObject );

Properties of XGraphicObject:

Methods of XGraphicObject:

Event of XGraphicObject:

 


XPen = class( XGraphicObject );

XPen properties:

 


XBrush = class( XGraphicObject );

XBrush properties:

All newly created XBrush objects have Color = clBtnFace.


XFont = class( XGraphicObject );

XFont properties:

When new XFont object is created, it obtains its value from several global variables:

You may change these values above to change default font parameters for all futher created fonts. This will have influence onto all controls of all forms of applet.

 


XGraphicsManager = class( TObject );

XGraphicsManager events:

A single global variable GlobalGraphicsManager : XGraphicsManager is declared here. It is only used to keep these two event above. These events are called by graphic objects. If add-on XCanvasObjects.pas is included, it uses these two events to extend XGraphics.pas unit with ability to avoid duplicating of GDI resources.


Also, all color constants (clBlack, clWhite, etc.) are defined here and a couple of useful functions to manipulate with colors:

 


    This module can be extended by using external optional add-on XCanvasObjects.pas. To use it, call UseCanvasObjectManager procedure (the best place to do it is dpr-file of your applet - before creating of first form). When used, this add-on keeps all graphic object handles, avoiding creating duplicated handles for GDI objects of the same type with the same property values. This allows to reduce needs in GDI resources of applet.
    This add-on is not necessary in very small applets. Use it only in larger applets wth great number of controls or with a lot of painting.

 

goto XCL page

goto home page