Class TRbwRuler

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TRbwRuler = class(TPaintBox)

Description

TRbwRuler draws a ruler.

The orientation, scaling, number format, and position of the ruler can be controlled through properties.

Hierarchy

Overview

Fields

Private FDesiredSpacing: integer;
Private FDigits: integer;
Private FLinePosition: integer;
Private FMajorTickLength: integer;
Private FMinorTickLength: integer;
Private FPositions: TRulerPositions;
Private FPrecision: integer;
Private FRulerPosition: TRulerPosition;
Private FStart: TStart;
Private FTextOffset: integer;
Private FTextPosition: TTextPosition;
Private FValues: TRulerValues;

Methods

Private procedure DrawLabel(const CurPositionR, Increment: double; const CurPositionI: integer; var FirstLabel: boolean; var LastLabelLT, LastLabelRB: integer);
Private procedure DrawMainLine;
Private procedure DrawMinorTicks(const LowCoord, Increment: double; const Index, Spacing: integer);
Private procedure DrawTick(const CurPositionI: integer; const IsMajorTick: boolean);
Private procedure DrawRuler;
Private function GetCurrentPosition(const CurPositionR: double): integer;
Private function GetDrawingMajorTickLength: integer;
Private function GetDrawingMinorTickLength: integer;
Private function GetLineDrawingPosition: integer;
Private function GetOrientation: TOrientation;
Private function GetTextDrawingPosition: TStart;
Private procedure GetTickSpacingAndFactor( out Spacing: integer; out Factor: double);
Private function Multiplier: double;
Private function RoundNumber(Value, Increment: double): string;
Private procedure SetDesiredSpacing(const Value: integer);
Private procedure SetDigits(Value: integer);
Private procedure SetLinePosition(const Value: integer);
Private procedure SetMajorTickLength(const Value: integer);
Private procedure SetMinorTickLength(const Value: integer);
Private procedure SetPositions(const Value: TRulerPositions);
Private procedure SetPrecision(Value: integer);
Private procedure SetRulerPosition(const Value: TRulerPosition);
Private procedure SetStart(const Value: TStart);
Private procedure SetTextOffset(const Value: integer);
Private procedure SetTextPosition(const Value: TTextPosition);
Private procedure SetValues(const Value: TRulerValues);
Protected procedure Paint; override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure PaintRotated(const X, Y, Angle: double; const Text: string); virtual;

Properties

Protected property RulerOrientation: TOrientation read GetOrientation;
Published property RulerDesiredSpacing: integer read FDesiredSpacing write SetDesiredSpacing;
Published property RulerDigits: integer read FDigits write SetDigits;
Published property RulerEnds: TRulerPositions read FPositions write SetPositions;
Published property RulerLinePosition: integer read FLinePosition write SetLinePosition;
Published property RulerMajorTickLength: integer read FMajorTickLength write SetMajorTickLength;
Published property RulerMinorTickLength: integer read FMinorTickLength write SetMinorTickLength;
Published property RulerPosition: TRulerPosition read FRulerPosition write SetRulerPosition;
Published property RulerPrecision: integer read FPrecision write SetPrecision;
Published property RulerStart: TStart read FStart write SetStart;
Published property RulerTextOffset: integer read FTextOffset write SetTextOffset;
Published property RulerTextPosition: TTextPosition read FTextPosition write SetTextPosition;
Published property RulerValues: TRulerValues read FValues write SetValues;

Description

Fields

Private FDesiredSpacing: integer;

FDesiredSpacing: integer; See RulerDesiredSpacing.

Private FDigits: integer;

FDigits: integer; See RulerDigits.

Private FLinePosition: integer;

FLinePosition: integer; See RulerLinePosition.

Private FMajorTickLength: integer;

FMajorTickLength: integer; See RulerMajorTickLength.

Private FMinorTickLength: integer;

FMinorTickLength: integer; See RulerMinorTickLength.

Private FPositions: TRulerPositions;

FPositions: TRulerPositions; See RulerEnds.

Private FPrecision: integer;

FPrecision: integer; See RulerPrecision.

Private FRulerPosition: TRulerPosition;

FRulerPosition: TRulerPosition; See RulerPosition.

Private FStart: TStart;

FStart: TStart; See RulerStart.

Private FTextOffset: integer;

FTextOffset: integer; See RulerTextOffset.

Private FTextPosition: TTextPosition;

FTextPosition: TTextPosition; See RulerTextPosition.

Private FValues: TRulerValues;

FValues: TRulerValues; See RulerValues.

Methods

Private procedure DrawLabel(const CurPositionR, Increment: double; const CurPositionI: integer; var FirstLabel: boolean; var LastLabelLT, LastLabelRB: integer);

DrawLabel draws the numbers on the ruler.

Private procedure DrawMainLine;

DrawMainLine draws the main line of the ruler.

Private procedure DrawMinorTicks(const LowCoord, Increment: double; const Index, Spacing: integer);

DrawMinorTicks draws minor tick lines on the ruler

Private procedure DrawTick(const CurPositionI: integer; const IsMajorTick: boolean);

DrawTick draws a tick line

Private procedure DrawRuler;

DrawRuler draws the ruler.

Private function GetCurrentPosition(const CurPositionR: double): integer;

Get the pixel equivalent of the current number.

Private function GetDrawingMajorTickLength: integer;

GetDrawingMajorTickLength gets the length (which may be negative) of the major ticks during drawing.

Private function GetDrawingMinorTickLength: integer;

GetDrawingMinorTickLength gets the length (which may be negative) of the minor ticks during drawing.

Private function GetLineDrawingPosition: integer;

GetLineDrawingPosition gets the X or Y coordinate where the main line of the ruler should be drawn.

Private function GetOrientation: TOrientation;

See RulerOrientation.

Private function GetTextDrawingPosition: TStart;

GetTextDrawingPosition determines where the labels are drawn with respect to the main line of the ruler.

Private procedure GetTickSpacingAndFactor( out Spacing: integer; out Factor: double);

GetTickSpacingAndFactor get the spacing between tick marks and Factor.

Private function Multiplier: double;

Multiplier is the ratio between the length that the ruler represents and its length in pixels.

Private function RoundNumber(Value, Increment: double): string;

RoundNumber converts Value to a string using RulerPrecision and RulerDigits. However, if Value is within Increment/RoundFactor of 0, RoundNumber returns '0'.

Private procedure SetDesiredSpacing(const Value: integer);

See RulerDesiredSpacing.

Private procedure SetDigits(Value: integer);

See RulerDigits.

Private procedure SetLinePosition(const Value: integer);

See RulerLinePosition.

Private procedure SetMajorTickLength(const Value: integer);

See RulerMajorTickLength.

Private procedure SetMinorTickLength(const Value: integer);

See RulerMinorTickLength.

Private procedure SetPositions(const Value: TRulerPositions);

See RulerEnds.

Private procedure SetPrecision(Value: integer);

See RulerPrecision.

Private procedure SetRulerPosition(const Value: TRulerPosition);

See RulerPosition.

Private procedure SetStart(const Value: TStart);

See RulerStart.

Private procedure SetTextOffset(const Value: integer);

See RulerTextOffset.

Private procedure SetTextPosition(const Value: TTextPosition);

See RulerTextPosition.

Private procedure SetValues(const Value: TRulerValues);

See RulerValues.

Protected procedure Paint; override;

Paint calls inherited Paint and then draws the ruler.

Public constructor Create(AOwner: TComponent); override;

Create creates and instance of TRbwRuler

Public destructor Destroy; override;

Destroy destroys the current instance of TRbwRuler. Do not call Destroy directly. Call Free instead.

Public procedure PaintRotated(const X, Y, Angle: double; const Text: string); virtual;

PaintRotated draws Text at the position X,Y at the angle specified by Angle. X and Y are in pixels (despite being real numbers). Angle is measured in degrees in a clockwise direction.

Properties

Protected property RulerOrientation: TOrientation read GetOrientation;

RulerOrientation controls whether the ruler is drawn in a horizontal or vertical orientation. RulerOrientation is determined by RulerPosition.

Published property RulerDesiredSpacing: integer read FDesiredSpacing write SetDesiredSpacing;

RulerDesiredSpacing is the desired spacing between major ticks in pixels. The actual spacing will, in most cases, be slightly different from RulerDesiredSpacing.

Published property RulerDigits: integer read FDigits write SetDigits;

RulerDigits specifies how many digits will appear in the exponent portion of numbers on the ruler.

Published property RulerEnds: TRulerPositions read FPositions write SetPositions;

RulerEnds specifies the positions, in pixels, of the starting and ending ends of the main line of the ruler.

Published property RulerLinePosition: integer read FLinePosition write SetLinePosition;

RulerLinePosition specifies the distance of the main line of the ruler from the left, top, right, or bottom edge in pixels. Which one is determined by RulerPosition.

Published property RulerMajorTickLength: integer read FMajorTickLength write SetMajorTickLength;

RulerMajorTickLength is the length of the major ticks in pixels.

Published property RulerMinorTickLength: integer read FMinorTickLength write SetMinorTickLength;

RulerMinorTickLength is the length of the minor ticks in pixels.

Published property RulerPosition: TRulerPosition read FRulerPosition write SetRulerPosition;

RulerPosition specifies the orientation of the main line on the ruler. RulerPosition controls RulerOrientation.

Published property RulerPrecision: integer read FPrecision write SetPrecision;

RulerPrecision specifies how many digits appear in the number in the ruler.

Published property RulerStart: TStart read FStart write SetStart;

RulerStart specifies the end of the ruler that has the lower value of the ruler.

Published property RulerTextOffset: integer read FTextOffset write SetTextOffset;

RulerTextOffset specifies the distance from the main line of the ruler to the labels on the ruler.

Published property RulerTextPosition: TTextPosition read FTextPosition write SetTextPosition;

RulerTextPosition specifies whether the labels are inside or outside the ruler.

Published property RulerValues: TRulerValues read FValues write SetValues;

RulerValues specifies the values of the lower and upper end of the ruler line. Thus the ruler represents a length equal to TRulerValues.Upper minus TRulerValues.Lower


Generated by PasDoc 0.10.0 on 2006-10-31 09:56:44