examples: using pen and brush styles example

git-svn-id: trunk@16779 -
This commit is contained in:
paul 2008-09-29 05:08:20 +00:00
parent 7ea0dab8c9
commit e3a48da832
6 changed files with 298 additions and 0 deletions

5
.gitattributes vendored
View File

@ -1889,6 +1889,11 @@ examples/openglcontrol/data/texture3.bmp -text svneol=unset#image/bmp
examples/openglcontrol/exampleform.pp svneol=native#text/pascal
examples/openglcontrol/openglcontrol_demo.lpi svneol=native#text/plain
examples/openglcontrol/openglcontrol_demo.pas svneol=native#text/pascal
examples/pen_brush/project1.lpi svneol=native#text/plain
examples/pen_brush/project1.lpr svneol=native#text/pascal
examples/pen_brush/unit1.lfm svneol=native#text/plain
examples/pen_brush/unit1.lrs svneol=native#text/pascal
examples/pen_brush/unit1.pas svneol=native#text/pascal
examples/popupnotifier/popupnotifierdemo.lpi svneol=native#text/plain
examples/popupnotifier/popupnotifierdemo.lpr svneol=native#text/plain
examples/popupnotifier/unit1.lfm svneol=native#text/plain

View File

@ -0,0 +1,75 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="6"/>
<General>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="0"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
<Language Value=""/>
<CharSet Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<UsageCount Value="23"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<ComponentName Value="Form1"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Form"/>
<ResourceFilename Value="unit1.lrs"/>
<UnitName Value="Unit1"/>
<CursorPos X="19" Y="46"/>
<TopLine Value="42"/>
<EditorIndex Value="0"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<PathDelim Value="\"/>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,18 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms
{ you can add units after this }, Unit1;
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,88 @@
object Form1: TForm1
Left = 350
Height = 425
Top = 215
Width = 400
Caption = 'Pen & Brush'
ClientHeight = 425
ClientWidth = 400
ParentFont = False
Position = poScreenCenter
LCLVersion = '0.9.27'
object Label1: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 11
Height = 14
Top = 11
Width = 28
BorderSpacing.Left = 11
BorderSpacing.Top = 11
Caption = 'Pens:'
ParentColor = False
end
object PenBox: TPaintBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 11
Height = 105
Top = 32
Width = 378
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 11
BorderSpacing.Top = 7
BorderSpacing.Right = 11
OnPaint = PenBoxPaint
end
object Label2: TLabel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = PenBox
AnchorSideTop.Side = asrBottom
Left = 11
Height = 14
Top = 148
Width = 43
BorderSpacing.Left = 11
BorderSpacing.Top = 11
Caption = 'Brushes:'
ParentColor = False
end
object BrushBox: TPaintBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 11
Height = 207
Top = 169
Width = 378
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 11
BorderSpacing.Top = 7
BorderSpacing.Right = 11
OnPaint = BrushBoxPaint
end
object Button1: TBitBtn
AnchorSideTop.Control = BrushBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 307
Height = 26
Top = 387
Width = 82
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 11
BorderSpacing.Right = 11
Caption = '&Закрыть'
Kind = bkClose
NumGlyphs = 0
OnClick = Button1Click
TabOrder = 0
end
end

View File

@ -0,0 +1,33 @@
{ This is an automatically generated lazarus resource file }
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
]);

View File

@ -0,0 +1,79 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Buttons;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TBitBtn;
Label1: TLabel;
Label2: TLabel;
PenBox: TPaintBox;
BrushBox: TPaintBox;
procedure BrushBoxPaint(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure PenBoxPaint(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
uses
TypInfo;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.BrushBoxPaint(Sender: TObject);
var
bs: TBrushStyle;
y: integer;
begin
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);
end;
end;
procedure TForm1.PenBoxPaint(Sender: TObject);
var
ps: TPenStyle;
y: integer;
begin
for ps := psSolid to psDashDotDot do
begin
y := 15 * (Ord(ps) + 1);
PenBox.Canvas.TextOut(10, y - 7, GetEnumName(TypeInfo(TPenStyle), Ord(ps)));
PenBox.Canvas.Pen.Style := ps;
PenBox.Canvas.Line(120, y, PenBox.Width - 10, y);
end;
end;
initialization
{$I unit1.lrs}
end.