source: trunk/Packages/bgracontrols/testbgracontrols/uallofthem.pas

Last change on this file was 2, checked in by chronos, 5 years ago
File size: 3.6 KB
Line 
1unit uallofthem;
2
3{$mode objfpc}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, BGRAButton,
9 BGRAFlashProgressBar, BGRAGraphicControl, BGRAImageButton, BGRAKnob,
10 BGRALabel, BGRALabelFX, BCPanel, BGRAShape, BGRASpeedButton,
11 BGRAVirtualScreen, BGRAWin7ToolBar, BGRABitmap,
12 BGRABitmapThemeUtils, BGRAImageList, BGRABitmapTypes;
13
14type
15
16 { TfrmAllOfThem }
17
18 TfrmAllOfThem = class(TForm)
19 BGRAButton1: TBGRAButton;
20 BGRAFlashProgressBar1: TBGRAFlashProgressBar;
21 BGRAGraphicControl1: TBGRAGraphicControl;
22 BGRAImageButton1: TBGRAImageButton;
23 BGRAImageList1: TBGRAImageList;
24 BGRAKnob1: TBGRAKnob;
25 BGRALabel1: TBGRALabel;
26 BGRALabelFX1: TBGRALabelFX;
27 BCPanel1: TBCPanel;
28 BGRAShape1: TBGRAShape;
29 BGRASpeedButton1: TBGRASpeedButton;
30 BGRAVirtualScreen1: TBGRAVirtualScreen;
31 BGRAWin7ToolBar1: TBGRAWin7ToolBar;
32 procedure BGRAGraphicControl1Click(Sender: TObject);
33 procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
34 procedure BGRAKnob1ValueChanged(Sender: TObject; Value: single);
35 procedure BGRAVirtualScreen1MouseDown(Sender: TObject;
36 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
37 procedure BGRAVirtualScreen1MouseMove(Sender: TObject; Shift: TShiftState;
38 X, Y: Integer);
39 procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
40 procedure FormCreate(Sender: TObject);
41 procedure FormDestroy(Sender: TObject);
42 private
43 { private declarations }
44 public
45 { public declarations }
46 PrevPos: TPoint;
47 image: TBGRABitmapThemeUtil;
48 number: integer;
49 end;
50
51var
52 frmAllOfThem: TfrmAllOfThem;
53
54implementation
55
56{$R *.lfm}
57
58{ TfrmAllOfThem }
59
60procedure TfrmAllOfThem.FormCreate(Sender: TObject);
61begin
62 BGRAImageButton1.BitmapLoadFromFile(BGRAImageButton1.BitmapFile);
63
64 image := TBGRABitmapThemeUtil.Create('sample_4.png',
65 4, // the number of images in the bitmap vertically
66 6, // the number of horizontal pixels used as border
67 6 // the number of vertical pixels used as border
68 );
69
70 number := 0; // the default image
71
72 BGRAGraphicControl1.Align := alLeft;
73
74 BGRAImageList1.GetBitmap(0, BGRAButton1.Glyph);
75 BGRAImageList1.GetBitmap(0, BGRASpeedButton1.Glyph);
76end;
77
78procedure TfrmAllOfThem.FormDestroy(Sender: TObject);
79begin
80 image.Free;
81end;
82
83procedure TfrmAllOfThem.BGRAKnob1ValueChanged(Sender: TObject; Value: single);
84begin
85 BGRAFlashProgressBar1.Value := Trunc(BGRAKnob1.Value);
86end;
87
88procedure TfrmAllOfThem.BGRAGraphicControl1Redraw(Sender: TObject;
89 Bitmap: TBGRABitmap);
90begin
91 bitmap.Fill(BGRAPixelTransparent);
92 image.Draw(bitmap, 0, 0, bitmap.Width, bitmap.Height, number);
93end;
94
95procedure TfrmAllOfThem.BGRAGraphicControl1Click(Sender: TObject);
96begin
97 if number = 3 then
98 number := 0
99 else
100 Inc(number, +1);
101
102 BGRAGraphicControl1.DiscardBitmap;
103end;
104
105procedure TfrmAllOfThem.BGRAVirtualScreen1MouseDown(Sender: TObject;
106 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
107begin
108 if Button = mbLeft then
109 begin
110 BGRAVirtualScreen1.Bitmap.SetPixel(X, Y, BGRABlack);
111 PrevPos := Point(X, Y);
112 BGRAVirtualScreen1.Repaint;
113 end;
114end;
115
116procedure TfrmAllOfThem.BGRAVirtualScreen1MouseMove(Sender: TObject;
117 Shift: TShiftState; X, Y: Integer);
118begin
119 if ssLeft in Shift then
120 begin
121 BGRAVirtualScreen1.Bitmap.DrawLineAntialias(X, Y, PrevPos.X,
122 PrevPos.Y, BGRABlack, False);
123 PrevPos := Point(X, Y);
124 BGRAVirtualScreen1.Repaint;
125 end;
126end;
127
128procedure TfrmAllOfThem.BGRAVirtualScreen1Redraw(Sender: TObject;
129 Bitmap: TBGRABitmap);
130begin
131 Bitmap.DrawLineAntialias(0, 0, Bitmap.Width - 1, Bitmap.Height - 1, BGRABlack, 1);
132end;
133
134end.
135
Note: See TracBrowser for help on using the repository browser.