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
|
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, Types,
LCLType, LclIntf, Forms, Controls, Graphics, StdCtrls, ExtCtrls, Themes;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
PB: TPaintBox;
RG: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure PBPaint(Sender: TObject);
procedure RGClick(Sender: TObject);
private
public
FImage: TBitmap;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
FImage := TBitmap.Create;
FImage.LoadFromFile('./buy_64.bmp');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FImage.Free;
end;
procedure TForm1.PBPaint(Sender: TObject);
var
R: TRect;
P: TSize;
begin
with PB.Canvas do
begin
Brush.Color := clWhite;
FillRect(ClientRect);
Font.Color := clGreen;
Font.Height := 20;
Pen.Width := 2;
TextOut(20,300, 'Unmapped!'); // check if font size OK
case RG.ItemIndex of
0:
begin
SetMapMode(Handle, MM_ANISOTROPIC);
SetWindowExtEx(Handle, 400, 300, nil);
SetViewPortExtEx(Handle, PB.ClientWidth, PB.ClientHeight, nil);
SetViewPortOrgEx(Handle, 0, 0, nil);
end;
1:
begin
SetMapMode(Handle, MM_ISOTROPIC);
SetWindowExtEx(Handle, 400, 300, nil);
SetViewPortExtEx(Handle, PB.ClientWidth, PB.ClientHeight, nil);
SetViewPortOrgEx(Handle, 0, 0, nil);
end;
2:
begin
SetMapMode(Handle, MM_LOENGLISH);
SetViewPortOrgEx(Handle, 0, 300, nil);
end;
3:
begin
SetMapMode(Handle, MM_HIENGLISH);
SetViewPortOrgEx(Handle, 0, 300, nil);
end;
4:
begin
SetMapMode(Handle, MM_LOMETRIC);
SetViewPortOrgEx(Handle, 0, 300, nil);
end;
5:
begin
SetMapMode(Handle, MM_HIMETRIC);
SetViewPortOrgEx(Handle, 0, 300, nil);
end;
6:
begin
SetMapMode(Handle, MM_TWIPS);
SetViewPortOrgEx(Handle, 0, 300, nil);
end;
7:
begin
SetMapMode(Handle, MM_ANISOTROPIC);
SetWindowExtEx(Handle, -400, 300, nil);
SetViewPortExtEx(Handle, PB.ClientWidth, PB.ClientHeight, nil);
SetViewPortOrgEx(Handle, PB.ClientWidth, 0, nil);
end;
end;
GetWindowExtEx(Handle, @P);
GetViewPortExtEx(Handle, @P);
Brush.Color := clRed;
FillRect(10, 10, 200, 200);
Brush.Color := clYellow;
Arc(200,10,400,200,20,0,400,300);
Chord(10,10,200,200, 0,0,300,300);
Brush.Color := clGreen;
Ellipse(50,200,250,260);
Brush.Color := clWhite;
TextOut(50,50, 'Hello!');
TextRect(Rect(50,80,200,120), 50,80, 'Clipped!');
DrawFocusRect(Rect(10,200,400,220)); // normally quite slow on GTK2, disable for the test
MoveTo(300, 200);
LineTo(390, 290);
R := Rect(10,200,100,250);
Frame3D(R, 3, bvRaised);
Frame(200,250,250,260);
FrameRect(200,220,250,240);
Rectangle(320,20,380,100);
RoundRect(320,110,380,150,6,6);
ThemeServices.DrawElement(Handle, ThemeServices.GetElementDetails(tbPushButtonNormal), Rect(80,50,100,75), nil);
DrawFrameControl(Handle, Rect(50,50,70,75), DFC_BUTTON, DFCS_BUTTONPUSH);
R := Rect(110,50,140,75);
DrawEdge(Handle, R, BDR_RAISEDINNER, BF_RECT);
StretchDraw(Rect(230,100, 304, 164), FImage);
SetMapMode(Handle, MM_TEXT);
TextOut(20,20, 'Unmapped!'); // check if font size OK
end;
end;
procedure TForm1.RGClick(Sender: TObject);
begin
PB.Invalidate;
end;
end.
|