📄 flexcontrols.int
字号:
FDC: HDC;
function GetCharABC(AChar: Char): TABC;
function GetCharWidth(AChar: Char): integer;
protected
FLineSize: TSize;
FLineLeftSpace: integer;
FLineRightSpace: integer;
function CheckFontIdentical(DC: HDC): boolean;
function SkipWhite(var Line: TTextLine; var NeedBreak: boolean): boolean;
procedure GetWord(var Line: TTextLine);
function GetLine(var Line: TTextLine; LineWidth: integer;
var LineBegin, LineEnd: integer; WordWrap: boolean): boolean;
procedure LineExtent(ALine: PChar; ACount: integer);
public
function Setup(DC: HDC; const PixelSize: double;
DivideOnEMSquare: boolean = false; RoundHeight: boolean = true): boolean;
function CharExtent(Text: PChar; CharCount: integer;
LineBreaks: boolean = false; WordWrap: boolean = false;
PaintWidth: integer = 0; InLogicalUnits: boolean = false;
LineCount: PInteger = Nil): TSize;
procedure CharWordInfos(Text: PChar; CharCount: integer;
var WordInfos: TTextWordInfoArray; var WordCount, WordWidth: integer;
InLogicalUnits: boolean = false);
function TextExtent(const Text: string): TSize;
function TextHeight(const Text: string): integer;
function TextWidth(const Text: string): integer;
procedure TextOut(X, Y: Integer; const Text: string);
procedure CharOut(X, Y: Integer; Text: PChar; CharCount: integer);
procedure TextRect(Rect: TRect; const Text: string; WordWrap: boolean;
Align: TAlignment = taLeftJustify; ALayout: TTextLayout = tlTop;
WidthJustify: boolean = false; LogicalWidth: integer = 0;
Rotation: integer = 0);
property Height: integer read FHeight;
property LineSpace: integer read FLineSpace;
property EMSquare: integer read FEMSquare;
property PixelSize: double read FPixelSize;
property CharABC[AChar: Char]: TABC read GetCharABC;
property CharWidth[AChar: Char]: integer read GetCharWidth;
end;
TFlexText = class(TFlexBox)
private
FAutoSizeProp: TBoolProp;
FTextProp: TStrListProp;
FFontProp: TFontProp;
FWordWrapProp: TBoolProp;
FGrayedProp: TBoolProp;
FAlignmentProp: TEnumProp;
FLayoutProp: TEnumProp;
FAngleProp: TIntProp;
FPreciseProp: TBoolProp;
FPreciseJustifyProp: TBoolProp;
FAutoScaleFontSizeProp: TBoolProp;
FMaxFontSizeProp: TIntProp;
FAutoSizeChanging: boolean;
function GetAlignment: TAlignment;
function GetLayout: TTextLayout;
function GetWordWrap: boolean;
procedure SetAlignment(const Value: TAlignment);
procedure SetLayout(const Value: TTextLayout);
procedure SetWordWrap(const Value: boolean);
function GetGrayed: boolean;
procedure SetGrayed(const Value: boolean);
function GetTextSize: TSize;
protected
FFormator: TTextFormator;
FRefreshRect: TRect;
FRefreshScale: integer;
procedure GetLeftRightExtra(DC: HDC; var Left, Right: integer);
procedure DoDrawText(Canvas: TCanvas; var Rect: TRect; Flags: Longint;
const Text: string);
procedure CreateProperties; override;
procedure ControlCreate; override;
procedure ControlDestroy; override;
procedure ControlTranslate(const TranslateInfo: TTranslateInfo); override;
function CreateCurveControl: TFlexControl; override;
procedure Paint(Canvas: TCanvas; var PaintRect: TRect); override;
procedure PropChanged(Sender: TObject; Prop: TCustomProp); override;
procedure PropStored(Sender: TObject; Prop: TCustomProp;
var IsStored: boolean; const PropName: string = ''); override;
function GetRefreshRect(RefreshX, RefreshY: integer): TRect; override;
procedure AutoSizeChanged;
property TextSize: TSize read GetTextSize;
public
class function CursorInCreate: TCursor; override;
procedure DrawTextEx(Canvas: TCanvas; var R: TRect; CalcOnly, Scaled: boolean;
const AText: string; AAlignment: TAlignment; ALayout: TTextLayout;
AWordWrap: boolean; APrecise, APreciseJustify: boolean;
LogSize: integer = 0; AFontHeight: integer = 0);
procedure {$IFDEF FG_CBUILDER}DrawTextCpp{$ELSE}DrawText{$ENDIF}(
Canvas: TCanvas; var R: TRect; CalcOnly, Scaled: boolean); virtual;
//function IsPointInside(PaintX, PaintY: integer): boolean; override;
property Formator: TTextFormator read FFormator;
property AutoSizeProp: TBoolProp read FAutoSizeProp;
property TextProp: TStrListProp read FTextProp;
property FontProp: TFontProp read FFontProp;
property WordWrapProp: TBoolProp read FWordWrapProp;
property AlignmentProp: TEnumProp read FAlignmentProp;
property LayoutProp: TEnumProp read FLayoutProp;
property AngleProp: TIntProp read FAngleProp;
property PreciseProp: TBoolProp read FPreciseProp;
property PreciseJustifyProp: TBoolProp read FPreciseJustifyProp;
property AutoScaleFontSizeProp: TBoolProp read FAutoScaleFontSizeProp;
property MaxFontSizeProp: TIntProp read FMaxFontSizeProp;
property Grayed: boolean read GetGrayed write SetGrayed;
property WordWrap: boolean read GetWordWrap write SetWordWrap;
property Alignment: TAlignment read GetAlignment write SetAlignment;
property Layout: TTextLayout read GetLayout write SetLayout;
end;
TFlexConnector = class(TFlexCurve)
private
FLinkAProp: TLinkPointProp;
FLinkBProp: TLinkPointProp;
FRerouteModeProp: TEnumProp;
FOrtogonalProp: TBoolProp;
FMinimalGapProp: TIntProp;
FBlocked: boolean;
FLinkUpdateCount: integer;
FLinkPointsIniting: boolean;
procedure SetBlocked(Value: boolean);
function GetLinked: boolean;
function GetOrtogonal: boolean;
procedure SetOrtogonal(const Value: boolean);
function GetRerouteMode: TRerouteMode;
procedure SetRerouteMode(const Value: TRerouteMode);
protected
FDesignMoving: boolean;
FDesignMovedFirst: integer;
FDesignMovedNext: integer;
FInTransformation: boolean;
procedure CreateProperties; override;
procedure ControlCreate; override;
procedure ControlDestroy; override;
procedure CreateInDesign(var Info: TFlexCreateInDesignInfo); override;
procedure BeginSelectionTransformation; override;
procedure EndSelectionTransformation; override;
procedure ControlTranslate(const TranslateInfo: TTranslateInfo); override;
procedure CreateCurveGuide(const NewPoint: TPoint;
var Guide: TFlexEditPointGuide); override;
procedure SetDocRect(Value: TRect); override;
procedure MirrorInResize(HMirror, VMirror: boolean); override;
function MovePathPoints(PointIndex: integer; var Delta: TPoint;
Selected: TSelectedArray; Smooth: boolean = false;
Symmetric: boolean = false): boolean; override;
function MovePathSegment(FirstIndex, NextIndex: integer;
var Delta: TPoint; const SegmentCurvePos: double): boolean; override;
procedure PointsChanged; override;
procedure DoNotify(Notify: TFlexNotify); override;
procedure LinkedNotify(Sender: TObject; Source: TNotifyLink;
const Info: TNotifyLinkInfo);
procedure GetLinkProps(var LinkFirst, LinkLast: TLinkPointProp); override;
procedure PropChanged(Sender: TObject; Prop: TCustomProp); override;
procedure PropStored(Sender: TObject; Prop: TCustomProp;
var IsStored: boolean; const PropName: string = ''); override;
procedure ConnectorMinGapChanged; override;
procedure Reroute;
property Blocked: boolean read FBlocked write SetBlocked;
property LinkUpdateCount: integer read FLinkUpdateCount;
property Linked: boolean read GetLinked;
public
class function IsConnectorControl: boolean; override;
function InsertPoint(Index: integer;
const Point: TPoint): integer; override;
function InsertNearestPoint(const Point: TPoint): integer; override;
procedure DeletePoint(Index: integer); override;
procedure EndPointsDesigning; override;
procedure BeginLinkUpdate;
procedure EndLinkUpdate;
property LinkAProp: TLinkPointProp read FLinkAProp;
property LinkBProp: TLinkPointProp read FLinkBProp;
property RerouteModeProp: TEnumProp read FRerouteModeProp;
property OrtogonalProp: TBoolProp read FOrtogonalProp;
property MinimalGapProp: TIntProp read FMinimalGapProp;
property RerouteMode: TRerouteMode read GetRerouteMode write SetRerouteMode;
property Ortogonal: boolean read GetOrtogonal write SetOrtogonal;
end;
TFlexRegularPolygon = class(TFlexControl)
private
FBrushProp: TBrushProp;
FPenProp: TPenProp;
FAngleProp: TIntProp;
FSidesProp: TIntProp;
protected
FEtalon: array of record X, Y: double; end;
FEtalonDX: double;
FEtalonDY: double;
FEtalonDXDY: double;
FPoints: TPointArray;
FPointTypes: TPointTypeArray;
procedure CreateProperties; override;
procedure ControlCreate; override;
procedure ControlTranslate(const TranslateInfo: TTranslateInfo); override;
function CreateCurveControl: TFlexControl; override;
procedure Paint(Canvas: TCanvas; var PaintRect: TRect); override;
function GetAnchorPoint: TPoint; override;
procedure PropChanged(Sender: TObject; Prop: TCustomProp); override;
procedure PropStored(Sender: TObject; Prop: TCustomProp;
var IsStored: boolean; const PropName: string = ''); override;
function CreatePolygonRegion(const PaintRect: TRect; Inflate: boolean = false): HRGN;
function GetRefreshRect(RefreshX, RefreshY: integer): TRect; override;
function GetDefaultLinkPoint(Index: integer): TPoint; override;
function GetDefaultLinkPointCount: integer; override;
procedure RebuildEtalon;
procedure BuildPoints(var Points: TPointArray; const R: TRect);
public
function IsPointInside(PaintX, PaintY: integer): boolean; override;
property BrushProp: TBrushProp read FBrushProp;
property PenProp: TPenProp read FPenProp;
property AngleProp: TIntProp read FAngleProp;
property SidesProp: TIntProp read FSidesProp;
end;
PLineCapInfo = ^TLineCapInfo;
TLineCapInfo = record
Size: integer;
LineLength: integer;
Bounds: TRect;
end;
PLineCapData = ^TLineCapData;
TLineCapData = record
Info: TLineCapInfo;
p0: TPoint;
p1: TPoint;
Points: TPointArray;
PointTypes: TPointTypeArray;
end;
PRenderCapParams = ^TRenderCapParams;
TRenderCapParams = record
Style: integer;
OutlineColor: TColor;
FillColor: TColor;
CapSize: integer;
end;
TLineCapStyleResolve = procedure(LineCap: integer; const p0, p1: TPoint;
var Data: TLineCapData; CapSize: integer; var Resolved: boolean);
var
ResolveLineCapStyle: TLineCapStyleResolve;
function GetLineCapInfo(LineCap: integer; var Info: TLineCapInfo;
CapSize: integer): boolean;
function GetLineCapData(LineCap: integer; const p0, p1: TPoint;
var Data: TLineCapData; CapSize: integer): boolean;
procedure RenderCap(DC: HDC; LineCap: integer; const p0, p1: TPoint;
CapSize: integer);
procedure RenderCaps(DC: HDC; PenWidth: integer;
const BeginCap, EndCap: TRenderCapParams; const Points: TPointArray;
const PointTypes: TPointTypeArray; Info: PPathInfo = Nil);
procedure RegisterStdControls;
implementation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -