1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
{ Compiletime Controls support }
unit uPSC_controls;
{$I PascalScript.inc}
interface
uses
uPSCompiler, uPSUtils;
{
Will register files from:
Controls
Register the STD, Classes (at least the types&consts) and Graphics libraries first
}
procedure SIRegister_Controls_TypesAndConsts(Cl: TPSPascalCompiler);
procedure SIRegisterTControl(Cl: TPSPascalCompiler);
procedure SIRegisterTWinControl(Cl: TPSPascalCompiler);
procedure SIRegisterTGraphicControl(cl: TPSPascalCompiler);
procedure SIRegisterTCustomControl(cl: TPSPascalCompiler);
procedure SIRegisterTDragObject(cl: TPSPascalCompiler);
procedure SIRegister_Controls(Cl: TPSPascalCompiler);
implementation
procedure SIRegisterTControl(Cl: TPSPascalCompiler);
begin
with Cl.AddClassN(cl.FindClass('TComponent'), 'TControl') do
begin
RegisterMethod('constructor Create(AOwner: TComponent);');
RegisterMethod('procedure BringToFront;');
RegisterMethod('procedure Hide;');
RegisterMethod('procedure Invalidate; virtual;');
RegisterMethod('procedure Refresh;');
RegisterMethod('procedure Repaint; virtual;');
RegisterMethod('procedure SendToBack;');
RegisterMethod('procedure Show;');
RegisterMethod('procedure Update; virtual;');
RegisterMethod('procedure SetBounds(X,Y,w,h: Integer); virtual;');
RegisterProperty('Left', 'Integer', iptRW);
RegisterProperty('Top', 'Integer', iptRW);
RegisterProperty('Width', 'Integer', iptRW);
RegisterProperty('Height', 'Integer', iptRW);
RegisterProperty('Hint', 'string', iptRW);
RegisterProperty('Align', 'TAlign', iptRW);
RegisterProperty('ClientHeight', 'LongInt', iptRW);
RegisterProperty('ClientWidth', 'LongInt', iptRW);
RegisterProperty('ShowHint', 'Boolean', iptRW);
RegisterProperty('Visible', 'Boolean', iptRW);
RegisterProperty('Enabled', 'Boolean', iptrw);
RegisterProperty('Cursor', 'TCursor', iptrw);
{$IFNDEF PS_MINIVCL}
RegisterMethod('function Dragging: Boolean;');
RegisterMethod('function HasParent: Boolean');
RegisterMethod('procedure BeginDrag(Immediate: Boolean)');
RegisterMethod('function ClientToScreen(Point: TPoint): TPoint');
RegisterMethod('procedure EndDrag(Drop: Boolean)');
{$IFNDEF CLX}
RegisterMethod('function GetTextBuf(Buffer: PChar; BufSize: Integer): Integer');
RegisterMethod('function GetTextLen: Integer');
RegisterMethod('procedure SetTextBuf(Buffer: PChar)');
RegisterMethod('function Perform(Msg: Cardinal; WPARAM,LPARAM: LongInt): LongInt');
{$ENDIF}
RegisterMethod('function ScreenToClient(Point: TPoint): TPoint');
{$ENDIF}
end;
end;
procedure SIRegisterTWinControl(Cl: TPSPascalCompiler); // requires TControl
begin
with Cl.AddClassN(cl.FindClass('TControl'), 'TWinControl') do
begin
with Cl.FindClass('TControl') do
begin
RegisterProperty('Parent', 'TWinControl', iptRW);
end;
{$IFNDEF CLX}
RegisterProperty('Handle', 'LongInt', iptR);
{$ENDIF}
RegisterProperty('Showing', 'Boolean', iptR);
RegisterProperty('TabOrder', 'Integer', iptRW);
RegisterProperty('TabStop', 'Boolean', iptRW);
RegisterMethod('function CanFocus: Boolean');
RegisterMethod('function Focused: Boolean');
RegisterProperty('Controls', 'TControl Integer', iptr);
RegisterProperty('ControlCount', 'Integer', iptr);
{$IFNDEF PS_MINIVCL}
RegisterMethod('function HandleAllocated: Boolean;');
RegisterMethod('procedure HandleNeeded;');
RegisterMethod('procedure EnableAlign;');
RegisterMethod('procedure RemoveControl(AControl: TControl);');
RegisterMethod('procedure InsertControl(AControl: TControl);');
RegisterMethod('procedure Realign;');
RegisterMethod('procedure ScaleBy(M, D: Integer);');
RegisterMethod('procedure ScrollBy(DeltaX, DeltaY: Integer);');
RegisterMethod('procedure SetFocus; virtual;');
{$IFNDEF CLX}
RegisterMethod('procedure PaintTo(DC: LongInt; X,Y: Integer)');
{$ENDIF}
RegisterMethod('function ContainsControl(Control: TControl): Boolean');
RegisterMethod('procedure DisableAlign');
RegisterMethod('procedure UpdateControlState');
RegisterProperty('Brush', 'TBrush', iptr);
RegisterProperty('HelpContext', 'LongInt', iptrw);
{$ENDIF}
end;
end;
procedure SIRegisterTGraphicControl(cl: TPSPascalCompiler); // requires TControl
begin
Cl.AddClassN(cl.FindClass('TControl'), 'TGraphicControl');
end;
procedure SIRegisterTCustomControl(cl: TPSPascalCompiler); // requires TWinControl
begin
Cl.AddClassN(cl.FindClass('TWinControl'), 'TCustomControl');
end;
procedure SIRegister_Controls_TypesAndConsts(Cl: TPSPascalCompiler);
begin
{$IFNDEF FPC}
Cl.addTypeS('TEShiftState','(ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble)');
{$ELSE}
Cl.addTypeS('TEShiftState','(ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble,' +
'ssMeta, ssSuper, ssHyper, ssAltGr, ssCaps, ssNum,ssScroll,ssTriple,ssQuad)');
{$ENDIF}
Cl.addTypeS('TShiftState','set of TEShiftState');
cl.AddTypeS('TMouseButton', '(mbLeft, mbRight, mbMiddle)');
cl.AddTypeS('TDragMode', '(dmManual, dmAutomatic)');
cl.AddTypeS('TDragState', '(dsDragEnter, dsDragLeave, dsDragMove)');
cl.AddTypeS('TDragKind', '(dkDrag, dkDock)');
cl.AddTypeS('TMouseEvent', 'procedure (Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);');
cl.AddTypeS('TMouseMoveEvent', 'procedure(Sender: TObject; Shift: TShiftState; X, Y: Integer);');
cl.AddTypeS('TKeyEvent', 'procedure (Sender: TObject; var Key: Word; Shift: TShiftState);');
cl.AddTypeS('TKeyPressEvent', 'procedure(Sender: TObject; var Key: Char);');
cl.AddTypeS('TDragOverEvent', 'procedure(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean)');
cl.AddTypeS('TDragDropEvent', 'procedure(Sender, Source: TObject; X, Y: Integer)');
cl.AddTypeS('HWND', 'LongInt');
cl.AddTypeS('TEndDragEvent', 'procedure(Sender, Target: TObject; X, Y: Integer)');
cl.addTypeS('TAlign', '(alNone, alTop, alBottom, alLeft, alRight, alClient)');
cl.addTypeS('TAnchorKind', '(akTop, akLeft, akRight, akBottom)');
cl.addTypeS('TAnchors','set of TAnchorKind');
cl.AddTypeS('TModalResult', 'Integer');
cl.AddTypeS('TCursor', 'Integer');
cl.AddTypeS('TPoint', 'record X,Y: LongInt; end;');
cl.AddConstantN('mrNone', 'Integer').Value.ts32 := 0;
cl.AddConstantN('mrOk', 'Integer').Value.ts32 := 1;
cl.AddConstantN('mrCancel', 'Integer').Value.ts32 := 2;
cl.AddConstantN('mrAbort', 'Integer').Value.ts32 := 3;
cl.AddConstantN('mrRetry', 'Integer').Value.ts32 := 4;
cl.AddConstantN('mrIgnore', 'Integer').Value.ts32 := 5;
cl.AddConstantN('mrYes', 'Integer').Value.ts32 := 6;
cl.AddConstantN('mrNo', 'Integer').Value.ts32 := 7;
cl.AddConstantN('mrAll', 'Integer').Value.ts32 := 8;
cl.AddConstantN('mrNoToAll', 'Integer').Value.ts32 := 9;
cl.AddConstantN('mrYesToAll', 'Integer').Value.ts32 := 10;
cl.AddConstantN('crDefault', 'Integer').Value.ts32 := 0;
cl.AddConstantN('crNone', 'Integer').Value.ts32 := -1;
cl.AddConstantN('crArrow', 'Integer').Value.ts32 := -2;
cl.AddConstantN('crCross', 'Integer').Value.ts32 := -3;
cl.AddConstantN('crIBeam', 'Integer').Value.ts32 := -4;
cl.AddConstantN('crSizeNESW', 'Integer').Value.ts32 := -6;
cl.AddConstantN('crSizeNS', 'Integer').Value.ts32 := -7;
cl.AddConstantN('crSizeNWSE', 'Integer').Value.ts32 := -8;
cl.AddConstantN('crSizeWE', 'Integer').Value.ts32 := -9;
cl.AddConstantN('crUpArrow', 'Integer').Value.ts32 := -10;
cl.AddConstantN('crHourGlass', 'Integer').Value.ts32 := -11;
cl.AddConstantN('crDrag', 'Integer').Value.ts32 := -12;
cl.AddConstantN('crNoDrop', 'Integer').Value.ts32 := -13;
cl.AddConstantN('crHSplit', 'Integer').Value.ts32 := -14;
cl.AddConstantN('crVSplit', 'Integer').Value.ts32 := -15;
cl.AddConstantN('crMultiDrag', 'Integer').Value.ts32 := -16;
cl.AddConstantN('crSQLWait', 'Integer').Value.ts32 := -17;
cl.AddConstantN('crNo', 'Integer').Value.ts32 := -18;
cl.AddConstantN('crAppStart', 'Integer').Value.ts32 := -19;
cl.AddConstantN('crHelp', 'Integer').Value.ts32 := -20;
{$IFDEF DELPHI3UP}
cl.AddConstantN('crHandPoint', 'Integer').Value.ts32 := -21;
{$ENDIF}
{$IFDEF DELPHI4UP}
cl.AddConstantN('crSizeAll', 'Integer').Value.ts32 := -22;
{$ENDIF}
end;
procedure SIRegisterTDragObject(cl: TPSPascalCompiler);
begin
with CL.AddClassN(CL.FindClass('TObject'),'TDragObject') do
begin
{$IFNDEF PS_MINIVCL}
{$IFDEF DELPHI4UP}
RegisterMethod('procedure Assign(Source: TDragObject)');
{$ENDIF}
{$IFNDEF FPC}
RegisterMethod('function GetName: string');
RegisterMethod('function Instance: LongInt');
{$ENDIF}
RegisterMethod('procedure HideDragImage');
RegisterMethod('procedure ShowDragImage');
{$IFDEF DELPHI4UP}
RegisterProperty('Cancelling', 'Boolean', iptrw);
RegisterProperty('DragHandle', 'LongInt', iptrw);
RegisterProperty('DragPos', 'TPoint', iptrw);
RegisterProperty('DragTargetPos', 'TPoint', iptrw);
RegisterProperty('MouseDeltaX', 'Double', iptr);
RegisterProperty('MouseDeltaY', 'Double', iptr);
{$ENDIF}
{$ENDIF}
end;
Cl.AddTypeS('TStartDragEvent', 'procedure (Sender: TObject; var DragObject: TDragObject)');
end;
procedure SIRegister_Controls(Cl: TPSPascalCompiler);
begin
SIRegister_Controls_TypesAndConsts(cl);
SIRegisterTDragObject(cl);
SIRegisterTControl(Cl);
SIRegisterTWinControl(Cl);
SIRegisterTGraphicControl(cl);
SIRegisterTCustomControl(cl);
end;
// PS_MINIVCL changes by Martijn Laan (mlaan at wintax _dot_ nl)
end.
|