Copyright: MathCtrl Help.   Copyright (c) 1996 by Dimak.


MathCtrl
MathCtrl unit (version 1.7)

The MathCtrl unit contains declarations for the components that appear on the Math tab of the Component palette. When you add a component declared in this unit to a form, the unit name automatically added to the uses clause of that form's unit.

The following items are declared in the MathCtrls unit.

Components

 TMathGrid

 TMathCurve

 TIntEdit

 TFloatEdit

Types

 TMathGridOption

 TMathGridOptions

Author:

  Dmitry S. Kaschenko

  e-mail:  dimak@uniyar.ac.ru

  home page: www.uniyar.ac.ru/~vlads/dpage.htm

             www.chat.ru/~dimak


TMathGrid
 TMathGrid component

 Properties    Methods     Events    Example

Unit

  MathCtrl

Description

TMathGrid component is a direct descendent of TGraphicControl. It is used mainly to help mathematicans to display such objects as curves, lines, graphs, etc. TMathGrid represents a rectangular region of Des-Cartes' coordinate system. The bottom-left corner corresponds to (MinX,MinY) point and the top-right corner corresponds to (MaxX,MaxY). To output a single point use PutPixel method; to draw a line use Line method.

If Legend property is not empty it's contents appears at the bottom of control.

Options property defines how output is performed.

In addition this component also has the properties and methods that apply to all controls.


MathCurve
 TMathCurve component

 Properties    Methods    Example

Unit

  MathCtrl

TMathCurve component is designed to help draw curves on a TMathGrid. Property Grid determines on witch grid drawings occurs.


TMathGridOptions
TMathGridOptions type

Unit

  MathCtrl

Declaration

 TMathGridOption = (mgBorder, mgInstantRepaint, mgMemoryDraw, mgWeb);

 TMathGridOptions = set of TMathGridOption;

Description

TMathGridOptions is the set of values the Options property of a TMahGrid component can have.


Options
Options  property

Applies to

  TMathGrid component

Declaration

  property Options: TMathGridOptions;

Description

  These are the possible values that can be contained in the Options set:

Value	Meaning
mgBorder	When True borders appears on the Grid
mgInstantRepaint	When True every time
mgMemoryDraw	When True output performed only to internal cache. To make drawings visible call Invalidate or Refresh method.
mgWeb	When True a web appears on the grid


TIntEdit
 TIntEdit component

Properties

Unit

  MathCtrl

TIntEdit component is an indirect descendent of TWinControl. Use a TIntEdit component to put integer-value-edit-box control on your form. When users enter data into an edit box or the application displays information to the user in the edit box, the  property Value changes. In addition this component also has the properties, methods, and events that apply to TCustomEdit control.


TFloatEdit
 TFloatEdit component

Properties

Unit

  MathCtrl

TFloatEdit component is an indirect descendent of TWinControl. Use a TFloatEdit component to put extended-value-edit-box control on your form. When users enter data into an edit box or the application displays information to the user in the edit box, the property Value changes. In addition this component also has the properties, methods, and events that apply to TCustomEdit control.


TMathGrid limits
MinX, MinY, MaxX, MaxY, SizeX, SizeY properties

Applies to

  TMathGrid component

Declaration

  property MinX: Extended;

  property MinY: Extended;

  property MaxX: Extended;

  property MaxY: Extended;

  property SizeX: Extended;

  property SizeY: Extended;

Description

The bottom-left corner of work area of  component corresponds to (MinX, MinY) point and the top-right corner corresponds to (MaxX, MaxY) point of Des-Cartes' coordinate system. SizeX and SizeY are simply difference between MaxX and MinX or MaxY and MinYrespectively.


Line
Line method

Applies to

  TMathGrid component

Declaration

  procedure Line(AX, AY, BX, BY: Extended; AC: TColor);

Description

The Line method draws a line on the component from the (AX, AY) point to (BX, BY) point using color given in AC.


PointAtPos
PointAtPos method

Applies to

  TMathGrid component

Declaration

  procedure PointAtPos(Pos: TPoint; var X, Y: Extended);

Description

The PointAtPos method sets Des-Cartes coordinates of  the point given in Pos to  X and Y. The Pos parameter is the point in the control in window coordinates.


SetLimits
SetLimits method

Applies to

  TMathGrid component

Declaration

  procedure SetLimits(AMinX, AMinY, AMaxX, AMaxY: Extended);

Description

SetLimits method set MinX, MinY, MaxX, MaxY properties at once.


SaveToFile (TMathGrid)
SaveToFile method

Applies to

  TMathGrid component

Declaration

  procedure SaveToFile(const FileName: String; Colored: Boolean);

Description

The SaveToFile method saves component in BMP format to the file specified by FileName. If the specified file already exists, SaveToFile overwrites it. Colored parameter determines whether output color bitmap or monochrome.


CopyToClipboard (TMathGrid)
CopyToClipboard method

Applies to

  TMathGrid component

Declaration

  procedure CopyToClipboard(Colored: Boolean);

Description

The CopyToClipboard method copies component image to Clipboard. The Colored parameter determines whether output color bitmap or monochrome.


Clear
Clear method

Applies to

  TMathGrid component

Declaration

  procedure Clear;

Description

Clear method performs clearing of  work area of the component.


PutPixel (TMathGrid)
PutPixel method

Applies to

  TMathGrid component

Declaration

  procedure PutPixel(AX, AY: Extended; AC: TColor);

Description

The PutPixel method outputs a single point in position (AX, AY)  using color given in AC.


Legend
Legend property

Applies to

  TMathGrid component

Declaration

    property Legend: string;

Description

If  Legend property is not empty it's contents appears at the bottom of control.


Parts
PartsX, PartsY property

Applies to

  TMathGrid component

Declaration

    property PartsX: Word;

  property PartsY: Word;

Description

If PartsX property is greater than zero scale appears at the bottom of the component. If PartsY property is greater than zero scale appears at the left of the component.


GridColor
GridColor property

Obsolete in Delphi 3.

Applies to

  TMathGrid component

Declaration

    property GridColor: TColor;

Description

GridColor property determines the color of a work area of component.


Decimals
Decimals property

Applies to

  TMathGrid component

Declaration

    property Decimals: Word;

Description

Decimals property determines an output format of numbers that appears at the left and at the bottom of component.


MapSize
MapSize property

Applies to

  TMathGrid component

Declaration

    property MapSize: TPoint;

Description

Run-time and read only. MapSize property is the size of work area of  the component in pixels.


Color (TMathGrid)
Color property

Applies to

  TMathGrid component

Declaration

    property Color: TColor;

Description

Color property determines the background color of a control.

If a control's ParentColor property is True, then changing the Color property of the control's parent automatically changes the Color property of the control. When you assign a value to a control's Color property, the control's ParentColor propertyis automatically set to False.


TMathGrid properties
Key properties

Canvas    Color    Decimals   GridColor    Legend    LogBaseX     LogBaseY LogScaleX     LogScaleY       MapSize     MinX     MinY     MaxX     MaxY    PartsX    PartsY    SizeX     SizeY     Options


TMathGrid methods
Key methods

Clear     CopyToClipboard     Line      PointAtPos     PutPixel     SaveToFile    SetLimits


TMathGrid events
Key events

OnClick    OnDblClick      OnMouseDown     OnMouseMove     OnMouseUp      OnResize


PutPixel (TMathCurve)
PutPixel method

Applies to

  TMathCurve component

Declaration

  procedure PutPixel(AX, AY: Extended);

Description

If Used property is set to False a call to PutPixel method causes output of a single point, in other case a line from priveous point to (AX, AY) is drawn.


Used
Used property

Applies to

  TMathCurve component.

Declaration

    property Used: Boolean;

Description

Run-time only. If Used property is set to False a call to PutPixel method causes output of a single point, in other case a line from priveous point to current one is drawn.


Color (TMathCurve)
Color property

Applies to

  TMathCurve component

Declaration

  property Color: TColor;

Description

The Color property determines color of pixels and lines.


Grid
Grid property

Applies to

  TMathCurve component

Declaration

  property Grid: TMathGrid;

Description

Grid property determines on witch grid drawings occurs.


TMathCurve properties
Key properties

Color    Grid    Used


TMathCurve methods
Key methods

PutPixel     Reset


Reset
Reset method

Applies to

  TMathCurve component

Declaration

  procedure Reset;

Description

Reset switches Used property to False;


TIntEdit properties
Key properties

DefaultValue    Increment          MaxValue     MinValueValue


TFloatEdit properties
Key properties

DefaultValue     IncludeBouns Increment          MaxValue     MinValue      Value


Example

This example shows how to use TMathGrid and TMathCurve components in your programs.

type

  TForm1 = class(TForm)

    MathGrid1: TMathGrid;

    MathCurve1: TMathCurve;

    Button1: TButton;

  private

    { Private declarations }

  public

    procedure Button1Click(Sender: TObject);

  end;

var

  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

var

  t, ht: Extended;

begin

  ht := 1 / MathGrid1.MapSize.X;

  t := MathGrid1.MinX;

  MathGrid1.Line(MinX, MinX, MaxX, MaxX);

  while t <= MathGrid1.MaxX do

  begin

    MathGrid1.PutPixel(t, cos(t), clBlue);

    MathCurve.PutPixel(t, sin(t));

    t := t + ht;

  end;

end;

end.


Value (TIntEdit)
Value property

Applies to

  TIntEdit component

Declaration

  property Value: Integer;

Description

Value property is the actual data in the component.


Value (TFloatEdit)
Value property

Applies to

  TFloatEdit component

Declaration

  property Value: Extended;

Description

Value property is the actual data in the component.


MaxValue (TFloatEdit)
MaxValue property

Applies to

  TFloatEdit component

Declaration

  property MaxValue: Extended;

Description

The MaxValue property limits the maximum value can be entered. If You enter  a value greater than MaxValue it will be changed to MaxValue.


MinValue (TFloatEdit)
MinValue property

Applies to

  TFloatEdit component

Declaration

  property MinValue: Extended;

Description

The MinValue property limits the minimum value can be entered. If You enter  a value less than MinValue it will be changed to MinValue.


DefaultValue (TFloatEdit)
DefaultValue property

Applies to

  TFloatEdit component

Declaration

  property DefaultValue: Extended;

Description

DefaultValue property determines what Value equal to when no value is entered.


IncludeBounds
IncludeBounds property

Applies to

  TFloatEdit component

Declaration

  property IncludeBounds: Boolean;

Description

IncludeBounds property determines whether values equal to MinValue or MaxValue are acceptable.


MaxValue (TIntEdit)
MaxValue property

Applies to

  TIntEdit component

Declaration

  property MaxValue: Integer;

Description

The MaxValue property limits the maximum value can be entered. If You enter  a value greater than MaxValue it will be changed to MaxValue.


MinValue (TIntEdit)
MinValue property

Applies to

  TIntEdit component

Declaration

  property MinValue: Integer;

Description

The MinValue property limits the maximum value can be entered. If You enter  a value greater than MinValue it will be changed to MinValue.


DefaultValue (TIntEdit)
DefaultValue property

Applies to

  TIntEdit component

Declaration

  property DefaultValue: Integer;

Description

DefaultValue property determines what Value equal to when no value is entered.


Increment (TIntEdit)
Increment property

Applies to

  TIntEdit component

Declaration

  property Increment: Integer;

Description

Increment property determines the integer value which is added to or subtracted from the Value when vk_UP or vk_Down keys are pressed.


Increment (TFloatEdit)
Increment property

Applies to

  TFloatEdit component

Declaration

  property Increment: Extended;

Description

Increment property determines the extended value which is added to or subtracted from the Value when vk_UP or vk_Down keys are pressed.


OnResize
OnResize event

Applies to

  TMathGrid component

Declaration

  property OnResize: TNotifyEvent;

Description

OnResize event is initiated when work  area of the component needs to be resized. Raising an exception inside event-handling method can avoid resizing.

Work area of the component needs to be resized when

•	component changed its bounds,

•	component changed its limits (MinX , MinY ,  MaxX , MaxY , SizeX , SizeY ),

•	Decimals property changed

•	Font changed

•	PartsX or PartsY propertiy changed.


LogBase
LogBaseX, LogBaseY property

Applies to

  TMathGrid component

Declaration

    property LogBaseX: Extended;

  property LogBaseY: Extended;

Description

If LogBaseX and LogBaseY properties determine the logarithm base used in axis logarithm scaling when appropriate LogScale property is True. Note: LogBaseX and LogBaseY must be greater than 1.


LogScale
LogScaleX, LogScaleY property

Applies to

  TMathGrid component

Declaration

    property LogScaleX: Boolean;

  property LogScaleY: Boolean;

Description

If LogScaleX and/or LogScaleY property is True than appropriate axis is represented in logarithmic scale.