Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
the Ministry of education and science of the Re...docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
50.87 Кб
Скачать

Example

// Demonstration of the use of the TextWidth and TextHeight

uses GraphABC;

const s = 'Width & Height';

begin

Window.Title := 'Текст по центру';

Window.IsFixedSize := True;

SetWindowSize(700,300);

Window.Center;

Font.Name := 'Times';

Font.Size := 50;

var tw := TextWidth(s);

var th := TextHeight(s);

TextOut((Window.Width-tw) div 2,(Window.Height-th) div 2,s);

end.

Routines for working with graphic window

Access to the properties of the graphics window can be carried out both in procedural and object-oriented style.

Procedures and functions for accessing the properties window are grouped in pairs: if the Prop - the name of the brush properties, the function PenProp returns the value of this property and the procedure SetPenProp(p) sets this property:

function WindowWidth: integer;

Returns the width of the client part of the graphics window in pixels

function WindowHeight: integer;

Returns the height of the client part of the graphics window in pixels

function WindowLeft: integer;

Returns the indent of the graphics window from the left edge of the screen in pixels

function WindowTop: integer;

Returns the indent of the graphics window from the top edge of the screen in pixels

function WindowIsFixedSize: boolean;

Returns True if the graphics window has a fixed size, and False otherwise

procedure SetWindowWidth(w: integer);

Sets the width of the client part of the graphics window in pixels

procedure SetWindowHeight(h: integer);

Sets the height of the client part of the graphics window in pixels

procedure SetWindowLeft(l: integer);

Sets the indentation of the graphics window from the left edge of the screen in pixels

procedure SetWindowTop(t: integer);

Sets the indentation of the graphics window from the top edge of the screen in pixels

procedure SetWindowIsFixedSize(b: boolean);

Sets whether the graphical window to a fixed size

function WindowCaption: string;

Returns the title of the graphics window

function WindowTitle: string;

Returns the title of the graphics window

procedure SetWindowCaption(s: string);

Sets the header graphic window

procedure SetWindowTitle(s: string);

Sets the header graphic window

procedure SetWindowSize(w,h: integer);

Sets the size of the client part of the graphics window in pixels

procedure SetWindowPos(l,t: integer);

Sets the indentation of the graphics window from the left and top edges of the screen in pixels

procedure ClearWindow;

Clears the graphics window in white

procedure ClearWindow(c: Color);

Clears the graphics window color c

procedure InitWindow(Left,Top,Width,Height: integer; BackColor: Color := clWhite);

Sets the width and height of the client part of the graphics window in pixels

procedure SaveWindow(fname: string);

Saves the contents of the graphics window to a file named fname

procedure LoadWindow(fname: string);

Restores the contents of the graphics window from the file named fname

procedure FillWindow(fname: string);

Fills the contents of the graphics window Wallpapers from file with name fname

procedure CloseWindow;

Closes the graphical window and terminates the application

procedure CenterWindow;

Centers the graphic center window on screen

function WindowCenter: Point;

Returns the center of the graphics window

procedure MaximizeWindow;

Maximizes the graphics window

procedure MinimizeWindow;

Collapses the graphics window

procedure NormalizeWindow;

Returns the graphic window to normal size

You can also return the dimensions of the screen, as well as the size and position of the graphical components GraphBox the drawing:function GraphBoxWidth: integer;

Returns the width of the graphical components in pixels (default coincides with WindowWidth)

function GraphBoxHeight: integer;

Returns the height of the graphical components in pixels (default coincides with WindowHeight)

function GraphBoxLeft: integer;

Returns the indent of graphical components from the left edge of the window in pixels

function GraphBoxTop: integer;

Returns the indent graphical component from the top edge of the window in pixels

function ScreenWidth: integer;

Returns the width of the screen in pixels

function ScreenHeight: integer;

Returns the height of the screen in pixels

Class GraphABCWindow the graphics window

Class GraphABCWindow is a graphical window. Function

function Window: GraphABCWindow;

returns an object of the current viewport.

Class properties GraphABCWindow

property Left: integer;

Indent the graphics window from the left edge of the screen in pixels

property Top: integer;

Indent the graphics window from the top edge of the screen in pixels

property Width: integer; The width of the client part of the graphics window in pixels

property Height: integer; The height of the client part of the graphics window in pixels

property Caption: string; Header graphic window

property Title: string; Header graphic window

property IsFixedSize: boolean;

Does the graphics window to a fixed size

Class methods GraphABCWindow

procedure Clear;

Clears the graphics window in white

procedure Clear(c: Color);

Clears the graphics window color c

procedure SetSize(w,h: integer);

Sets the size of the client part of the graphics window in pixels

procedure SetPos(l,t: integer);

Sets the indentation of the graphics window from the left and top edges of the screen in pixels

procedure Init(Left,Top,Width,Height: integer; BackColor: Color := clWhite);

Sets the position, size and color of the graphics window

procedure Save(fname: string);

Saves the contents of the graphics window to a file named fname

procedure Load(fname: string);

Restores the contents of the graphics window from the file named fname

procedure Fill(fname: string);

Fills the contents of the graphics window Wallpapers from file with name fname

procedure Close;

Closes the graphical window and terminates the application

procedure Minimize;

Collapses graphical window

procedure Maximize;

Maximizes the graphics window

procedure Normalize;

Returns the graphic window to normal size

procedure CenterOnScreen;

Centers the graphic center window on screen

function Center: Point;

Returns the center of the graphics window

Routines for working with the coordinates of the graphics window

Access to the properties of the coordinates of a graphical window can be carried out both in procedural and object-oriented style.

Procedures and functions for changing the system window coordinates are given below:

procedure SetCoordinateOrigin(x0,y0: integer);

Establishes the origin to the point (x0,y0)

procedure SetCoordinateScale(sx,sy: real);

Scales the coordinate system

procedure SetCoordinateAngle(a: real);

Sets the rotation of the coordinate system

Class GraphABCCoordinate the graphics window

The object of the current system of coordinates returned by the Function and is of type GraphABCCoordinate:

function Coordinate: GraphABCCoordinate;

Class GraphABCCoordinate represents the type of coordinate system to the graphics window.

Class properties GraphABCCoordinate

property OriginX: integer;

X-coordinate of the origin of the coordinates relative to the upper left corner of the window

property OriginY: integer;

Y-coordinate of the origin of the coordinates relative to the upper left corner of the window

property Origin: Point;

The coordinates of the beginning of the coordinates relative to the left the upper corner of the window

property Angle: real;

Angle of rotation of the coordinate system

property ScaleX: real;

The scale of the system of coordinates on the X-axis

property ScaleY: real;

The scale of the system of coordinates along the Y axis

property Scale: real;

The scale of the coordinate system on both axes

property Matrix: System.Drawing.Drawing2D.Matrix;

Matrix 3x3 coordinate transformations

Class methods GraphABCCoordinate

procedure SetTransform(x0,y0,angle,sx,sy: real);

Establishes the coordinate system's parameters

procedure SetOrigin(x0,y0: integer);

Sets the beginning of a system of coordinates

procedure SetScale(sx,sy: real);

Scales the coordinate system

procedure SetScale(scale: real);

Scales the coordinate system

procedure SetMathematic;

Establishes a right-handed coordinate system (the OY axis is directed upwards, the OX axis to the right)

procedure SetStandard;

Sets the left coordinate system (the OY axis is directed downward, the OX axis to the right) Subroutine locks drawing

procedure Redraw;

Redraws the contents of the graphics window. Called paired with LockDrawing

procedure LockDrawing;

Blocks drawing on the graphical window. Redraw the graphics window is performed using Redraw

procedure UnlockDrawing;

Removes the lock, drawing on the graphical window and shall overdraw

Lock output in graphical window LockDrawing with a subsequent call Redraw is used to create a simple animation flicker-free.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]