mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 12:39:29 +02:00
examples: add bitmap pattern brush to pen and brush example
git-svn-id: trunk@16780 -
This commit is contained in:
parent
e3a48da832
commit
34fcc43209
@ -45,13 +45,23 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<ResourceFilename Value="unit1.lrs"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="19" Y="46"/>
|
||||
<TopLine Value="42"/>
|
||||
<CursorPos X="43" Y="79"/>
|
||||
<TopLine Value="49"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="23"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
<JumpHistory Count="2" HistoryIndex="1">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="23" Column="43" TopLine="21"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="24" Column="44" TopLine="22"/>
|
||||
</Position2>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
|
@ -6,6 +6,8 @@ object Form1: TForm1
|
||||
Caption = 'Pen & Brush'
|
||||
ClientHeight = 425
|
||||
ClientWidth = 400
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
ParentFont = False
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '0.9.27'
|
||||
|
@ -3,31 +3,32 @@
|
||||
LazarusResources.Add('TForm1','FORMDATA',[
|
||||
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'^'#1#6'Height'#3#169#1#3'Top'#3#215#0#5'W'
|
||||
+'idth'#3#144#1#7'Caption'#6#11'Pen & Brush'#12'ClientHeight'#3#169#1#11'Clie'
|
||||
+'ntWidth'#3#144#1#10'ParentFont'#8#8'Position'#7#14'poScreenCenter'#10'LCLVe'
|
||||
+'rsion'#6#6'0.9.27'#0#6'TLabel'#6'Label1'#22'AnchorSideLeft.Control'#7#5'Own'
|
||||
+'er'#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#2#11#6'Height'#2#14#3'Top'
|
||||
+#2#11#5'Width'#2#28#18'BorderSpacing.Left'#2#11#17'BorderSpacing.Top'#2#11#7
|
||||
+'Caption'#6#5'Pens:'#11'ParentColor'#8#0#0#9'TPaintBox'#6'PenBox'#22'AnchorS'
|
||||
+'ideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#6'Label1'#18'Anchor'
|
||||
+'SideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'Anch'
|
||||
+'orSideRight.Side'#7#9'asrBottom'#4'Left'#2#11#6'Height'#2'i'#3'Top'#2' '#5
|
||||
+'Width'#3'z'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'BorderSpacin'
|
||||
+'g.Left'#2#11#17'BorderSpacing.Top'#2#7#19'BorderSpacing.Right'#2#11#7'OnPai'
|
||||
+'nt'#7#11'PenBoxPaint'#0#0#6'TLabel'#6'Label2'#22'AnchorSideLeft.Control'#7#5
|
||||
+'Owner'#21'AnchorSideTop.Control'#7#6'PenBox'#18'AnchorSideTop.Side'#7#9'asr'
|
||||
+'Bottom'#4'Left'#2#11#6'Height'#2#14#3'Top'#3#148#0#5'Width'#2'+'#18'BorderS'
|
||||
+'pacing.Left'#2#11#17'BorderSpacing.Top'#2#11#7'Caption'#6#8'Brushes:'#11'Pa'
|
||||
+'rentColor'#8#0#0#9'TPaintBox'#8'BrushBox'#22'AnchorSideLeft.Control'#7#5'Ow'
|
||||
+'ner'#21'AnchorSideTop.Control'#7#6'Label2'#18'AnchorSideTop.Side'#7#9'asrBo'
|
||||
+'ttom'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'a'
|
||||
+'srBottom'#4'Left'#2#11#6'Height'#3#207#0#3'Top'#3#169#0#5'Width'#3'z'#1#7'A'
|
||||
+'nchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'BorderSpacing.Left'#2#11#17'B'
|
||||
+'orderSpacing.Top'#2#7#19'BorderSpacing.Right'#2#11#7'OnPaint'#7#13'BrushBox'
|
||||
+'Paint'#0#0#7'TBitBtn'#7'Button1'#21'AnchorSideTop.Control'#7#8'BrushBox'#18
|
||||
+'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20
|
||||
+'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3'3'#1#6'Height'#2#26#3'Top'#3
|
||||
+#131#1#5'Width'#2'R'#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoSiz'
|
||||
+'e'#9#17'BorderSpacing.Top'#2#11#19'BorderSpacing.Right'#2#11#7'Caption'#6#15
|
||||
+'&'#208#151#208#176#208#186#209#128#209#139#209#130#209#140#4'Kind'#7#7'bkCl'
|
||||
+'ose'#9'NumGlyphs'#2#0#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0
|
||||
+'ntWidth'#3#144#1#8'OnCreate'#7#10'FormCreate'#9'OnDestroy'#7#11'FormDestroy'
|
||||
+#10'ParentFont'#8#8'Position'#7#14'poScreenCenter'#10'LCLVersion'#6#6'0.9.27'
|
||||
+#0#6'TLabel'#6'Label1'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTo'
|
||||
+'p.Control'#7#5'Owner'#4'Left'#2#11#6'Height'#2#14#3'Top'#2#11#5'Width'#2#28
|
||||
+#18'BorderSpacing.Left'#2#11#17'BorderSpacing.Top'#2#11#7'Caption'#6#5'Pens:'
|
||||
+#11'ParentColor'#8#0#0#9'TPaintBox'#6'PenBox'#22'AnchorSideLeft.Control'#7#5
|
||||
+'Owner'#21'AnchorSideTop.Control'#7#6'Label1'#18'AnchorSideTop.Side'#7#9'asr'
|
||||
+'Bottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9
|
||||
+'asrBottom'#4'Left'#2#11#6'Height'#2'i'#3'Top'#2' '#5'Width'#3'z'#1#7'Anchor'
|
||||
+'s'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'BorderSpacing.Left'#2#11#17'Border'
|
||||
+'Spacing.Top'#2#7#19'BorderSpacing.Right'#2#11#7'OnPaint'#7#11'PenBoxPaint'#0
|
||||
+#0#6'TLabel'#6'Label2'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTo'
|
||||
+'p.Control'#7#6'PenBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#11#6
|
||||
+'Height'#2#14#3'Top'#3#148#0#5'Width'#2'+'#18'BorderSpacing.Left'#2#11#17'Bo'
|
||||
+'rderSpacing.Top'#2#11#7'Caption'#6#8'Brushes:'#11'ParentColor'#8#0#0#9'TPai'
|
||||
+'ntBox'#8'BrushBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.C'
|
||||
+'ontrol'#7#6'Label2'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRigh'
|
||||
+'t.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#11#6
|
||||
+'Height'#3#207#0#3'Top'#3#169#0#5'Width'#3'z'#1#7'Anchors'#11#5'akTop'#6'akL'
|
||||
+'eft'#7'akRight'#0#18'BorderSpacing.Left'#2#11#17'BorderSpacing.Top'#2#7#19
|
||||
+'BorderSpacing.Right'#2#11#7'OnPaint'#7#13'BrushBoxPaint'#0#0#7'TBitBtn'#7'B'
|
||||
+'utton1'#21'AnchorSideTop.Control'#7#8'BrushBox'#18'AnchorSideTop.Side'#7#9
|
||||
+'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7
|
||||
+#9'asrBottom'#4'Left'#3'3'#1#6'Height'#2#26#3'Top'#3#131#1#5'Width'#2'R'#7'A'
|
||||
+'nchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#8'AutoSize'#9#17'BorderSpacing.T'
|
||||
+'op'#2#11#19'BorderSpacing.Right'#2#11#7'Caption'#6#15'&'#208#151#208#176#208
|
||||
+#186#209#128#209#139#209#130#209#140#4'Kind'#7#7'bkClose'#9'NumGlyphs'#2#0#7
|
||||
+'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0
|
||||
]);
|
||||
|
@ -20,9 +20,11 @@ type
|
||||
BrushBox: TPaintBox;
|
||||
procedure BrushBoxPaint(Sender: TObject);
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure PenBoxPaint(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
FPattern: TBitmap;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
@ -42,20 +44,40 @@ begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
const
|
||||
LineBitsDotted: array[0..7] of Word = ($55, $AA, $55, $AA, $55, $AA, $55, $AA);
|
||||
begin
|
||||
FPattern := TBitmap.Create;
|
||||
FPattern.SetHandles(CreateBitmap(8, 8, 1, 1, @LineBitsDotted), 0);
|
||||
end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
FPattern.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.BrushBoxPaint(Sender: TObject);
|
||||
var
|
||||
bs: TBrushStyle;
|
||||
y: integer;
|
||||
begin
|
||||
y := 15;
|
||||
for bs := bsSolid to bsDiagCross do
|
||||
begin
|
||||
y := 15 * (Ord(bs) + 1);
|
||||
BrushBox.Canvas.Brush.Color := clBtnFace;
|
||||
BrushBox.Canvas.TextOut(10, y - 7, GetEnumName(TypeInfo(TBrushStyle), Ord(bs)));
|
||||
BrushBox.Canvas.Brush.Color := clRed;
|
||||
BrushBox.Canvas.Brush.Style := bs;
|
||||
BrushBox.Canvas.FillRect(120, y - 5, PenBox.Width - 10, y + 5);
|
||||
inc(y, 15);
|
||||
end;
|
||||
|
||||
BrushBox.Canvas.Brush.Color := clBtnFace;
|
||||
BrushBox.Canvas.TextOut(10, y - 7, 'Pattern');
|
||||
BrushBox.Canvas.Brush.Color := clRed;
|
||||
BrushBox.Canvas.Brush.Bitmap := FPattern;
|
||||
BrushBox.Canvas.FillRect(120, y - 5, PenBox.Width - 10, y + 5);
|
||||
end;
|
||||
|
||||
procedure TForm1.PenBoxPaint(Sender: TObject);
|
||||
|
Loading…
Reference in New Issue
Block a user