Commit cd3d2aedb2878ff8c01e5d4121e8c8b57add0eb8
0 parents
Exists in
master
simple database test and lacs matrix graphics
Showing
5 changed files
with
376 additions
and
0 deletions
Show diff stats
1 | +++ a/README.md | |
... | ... | @@ -0,0 +1,22 @@ |
1 | +# install instructions | |
2 | + | |
3 | +# make sure system is up to date | |
4 | +sudo apt-get update | |
5 | +sudo apt-get upgrade | |
6 | + | |
7 | +# install database dependencies | |
8 | +mysql-server | |
9 | +mysql-client | |
10 | +mysql-workbench | |
11 | + | |
12 | +# check if database version is compatible with lazarus SQLdb connection component | |
13 | + | |
14 | +TMySQLXXConnection | |
15 | + | |
16 | +# downgrade if necessary. SQLdb component version must match mysql-client version. | |
17 | + | |
18 | +mysql -V # client version | |
19 | + | |
20 | +# on windows, check if libMySQL.dll is necessary... | |
21 | + | |
22 | + | ... | ... |
1 | +++ a/cultural_matrix.lpi | |
... | ... | @@ -0,0 +1,96 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<CONFIG> | |
3 | + <ProjectOptions> | |
4 | + <Version Value="9"/> | |
5 | + <General> | |
6 | + <SessionStorage Value="InProjectDir"/> | |
7 | + <MainUnit Value="0"/> | |
8 | + <Title Value="cultural_matrix"/> | |
9 | + <ResourceType Value="res"/> | |
10 | + <UseXPManifest Value="True"/> | |
11 | + <Icon Value="0"/> | |
12 | + </General> | |
13 | + <i18n> | |
14 | + <EnableI18N LFM="False"/> | |
15 | + </i18n> | |
16 | + <VersionInfo> | |
17 | + <StringTable ProductVersion=""/> | |
18 | + </VersionInfo> | |
19 | + <BuildModes Count="1"> | |
20 | + <Item1 Name="Default" Default="True"/> | |
21 | + </BuildModes> | |
22 | + <PublishOptions> | |
23 | + <Version Value="2"/> | |
24 | + </PublishOptions> | |
25 | + <RunParams> | |
26 | + <local> | |
27 | + <FormatVersion Value="1"/> | |
28 | + </local> | |
29 | + </RunParams> | |
30 | + <RequiredPackages Count="3"> | |
31 | + <Item1> | |
32 | + <PackageName Value="FCL"/> | |
33 | + </Item1> | |
34 | + <Item2> | |
35 | + <PackageName Value="SQLDBLaz"/> | |
36 | + </Item2> | |
37 | + <Item3> | |
38 | + <PackageName Value="LCL"/> | |
39 | + </Item3> | |
40 | + </RequiredPackages> | |
41 | + <Units Count="4"> | |
42 | + <Unit0> | |
43 | + <Filename Value="cultural_matrix.lpr"/> | |
44 | + <IsPartOfProject Value="True"/> | |
45 | + </Unit0> | |
46 | + <Unit1> | |
47 | + <Filename Value="form_participant.pas"/> | |
48 | + <IsPartOfProject Value="True"/> | |
49 | + <ComponentName Value="Form1"/> | |
50 | + <HasResources Value="True"/> | |
51 | + <ResourceBaseClass Value="Form"/> | |
52 | + </Unit1> | |
53 | + <Unit2> | |
54 | + <Filename Value="datamodule.pas"/> | |
55 | + <IsPartOfProject Value="True"/> | |
56 | + <ComponentName Value="DataModule1"/> | |
57 | + <HasResources Value="True"/> | |
58 | + <ResourceBaseClass Value="DataModule"/> | |
59 | + </Unit2> | |
60 | + <Unit3> | |
61 | + <Filename Value="README.md"/> | |
62 | + <IsPartOfProject Value="True"/> | |
63 | + </Unit3> | |
64 | + </Units> | |
65 | + </ProjectOptions> | |
66 | + <CompilerOptions> | |
67 | + <Version Value="11"/> | |
68 | + <Target> | |
69 | + <Filename Value="cultural_matrix"/> | |
70 | + </Target> | |
71 | + <SearchPaths> | |
72 | + <IncludeFiles Value="$(ProjOutDir)"/> | |
73 | + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | |
74 | + </SearchPaths> | |
75 | + <Linking> | |
76 | + <Options> | |
77 | + <Win32> | |
78 | + <GraphicApplication Value="True"/> | |
79 | + </Win32> | |
80 | + </Options> | |
81 | + </Linking> | |
82 | + </CompilerOptions> | |
83 | + <Debugging> | |
84 | + <Exceptions Count="3"> | |
85 | + <Item1> | |
86 | + <Name Value="EAbort"/> | |
87 | + </Item1> | |
88 | + <Item2> | |
89 | + <Name Value="ECodetoolError"/> | |
90 | + </Item2> | |
91 | + <Item3> | |
92 | + <Name Value="EFOpenError"/> | |
93 | + </Item3> | |
94 | + </Exceptions> | |
95 | + </Debugging> | |
96 | +</CONFIG> | ... | ... |
1 | +++ a/cultural_matrix.lpr | |
... | ... | @@ -0,0 +1,22 @@ |
1 | +program cultural_matrix; | |
2 | + | |
3 | +{$mode objfpc}{$H+} | |
4 | + | |
5 | +uses | |
6 | + {$IFDEF UNIX}{$IFDEF UseCThreads} | |
7 | + cthreads, | |
8 | + {$ENDIF}{$ENDIF} | |
9 | + Interfaces, // this includes the LCL widgetset | |
10 | + Forms, form_participant, datamodule | |
11 | + { you can add units after this }; | |
12 | + | |
13 | +{$R *.res} | |
14 | + | |
15 | +begin | |
16 | + RequireDerivedFormResource := True; | |
17 | + Application.Initialize; | |
18 | + Application.CreateForm(TForm1, Form1); | |
19 | + Application.CreateForm(TDataModule1, DataModule1); | |
20 | + Application.Run; | |
21 | +end. | |
22 | + | ... | ... |
1 | +++ a/form_participant.lfm | |
... | ... | @@ -0,0 +1,93 @@ |
1 | +object Form1: TForm1 | |
2 | + Left = 242 | |
3 | + Height = 505 | |
4 | + Top = 149 | |
5 | + Width = 913 | |
6 | + Caption = 'Form1' | |
7 | + ClientHeight = 505 | |
8 | + ClientWidth = 913 | |
9 | + LCLVersion = '1.6.0.4' | |
10 | + object StringGrid1: TStringGrid | |
11 | + AnchorSideLeft.Control = Owner | |
12 | + AnchorSideTop.Control = Owner | |
13 | + AnchorSideRight.Control = Owner | |
14 | + AnchorSideRight.Side = asrBottom | |
15 | + AnchorSideBottom.Control = Owner | |
16 | + AnchorSideBottom.Side = asrBottom | |
17 | + Left = 0 | |
18 | + Height = 344 | |
19 | + Top = 0 | |
20 | + Width = 715 | |
21 | + BorderSpacing.Right = 150 | |
22 | + BorderSpacing.Bottom = 197 | |
23 | + ColCount = 11 | |
24 | + DefaultRowHeight = 30 | |
25 | + FixedRows = 0 | |
26 | + Flat = True | |
27 | + Options = [goFixedHorzLine, goVertLine, goHorzLine, goDrawFocusSelected, goRowSelect, goSmoothScroll] | |
28 | + RowCount = 10 | |
29 | + TabOrder = 0 | |
30 | + OnDrawCell = StringGrid1DrawCell | |
31 | + Cells = ( | |
32 | + 10 | |
33 | + 0 | |
34 | + 0 | |
35 | + '1' | |
36 | + 0 | |
37 | + 1 | |
38 | + '2' | |
39 | + 0 | |
40 | + 2 | |
41 | + '3' | |
42 | + 0 | |
43 | + 3 | |
44 | + '4' | |
45 | + 0 | |
46 | + 4 | |
47 | + '5' | |
48 | + 0 | |
49 | + 5 | |
50 | + '6' | |
51 | + 0 | |
52 | + 6 | |
53 | + '7' | |
54 | + 0 | |
55 | + 7 | |
56 | + '8' | |
57 | + 0 | |
58 | + 8 | |
59 | + '9' | |
60 | + 0 | |
61 | + 9 | |
62 | + '10' | |
63 | + ) | |
64 | + end | |
65 | + object CheckBoxDrawDots: TCheckBox | |
66 | + Left = 728 | |
67 | + Height = 21 | |
68 | + Top = 16 | |
69 | + Width = 79 | |
70 | + Caption = 'DrawDots' | |
71 | + OnChange = CheckBoxDrawDotsChange | |
72 | + TabOrder = 1 | |
73 | + end | |
74 | + object DBGrid1: TDBGrid | |
75 | + Left = 32 | |
76 | + Height = 100 | |
77 | + Top = 368 | |
78 | + Width = 200 | |
79 | + Color = clWindow | |
80 | + Columns = <> | |
81 | + DataSource = DataModule1.DataSource1 | |
82 | + TabOrder = 2 | |
83 | + end | |
84 | + object Button1: TButton | |
85 | + Left = 736 | |
86 | + Height = 25 | |
87 | + Top = 96 | |
88 | + Width = 75 | |
89 | + Caption = 'Button1' | |
90 | + OnClick = Button1Click | |
91 | + TabOrder = 3 | |
92 | + end | |
93 | +end | ... | ... |
1 | +++ a/form_participant.pas | |
... | ... | @@ -0,0 +1,143 @@ |
1 | +unit form_participant; | |
2 | + | |
3 | +{$mode objfpc}{$H+} | |
4 | + | |
5 | +interface | |
6 | + | |
7 | +uses | |
8 | + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids, | |
9 | + StdCtrls, DBGrids; | |
10 | + | |
11 | +type | |
12 | + | |
13 | + { TForm1 } | |
14 | + | |
15 | + TForm1 = class(TForm) | |
16 | + Button1: TButton; | |
17 | + CheckBoxDrawDots: TCheckBox; | |
18 | + DBGrid1: TDBGrid; | |
19 | + StringGrid1: TStringGrid; | |
20 | + procedure Button1Click(Sender: TObject); | |
21 | + procedure CheckBoxDrawDotsChange(Sender: TObject); | |
22 | + procedure StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer; | |
23 | + aRect: TRect; aState: TGridDrawState); | |
24 | + private | |
25 | + { private declarations } | |
26 | + public | |
27 | + { public declarations } | |
28 | + end; | |
29 | + | |
30 | +var | |
31 | + Form1: TForm1; | |
32 | + | |
33 | +implementation | |
34 | + | |
35 | +uses datamodule; | |
36 | + | |
37 | +{$R *.lfm} | |
38 | + | |
39 | +{ TForm1 } | |
40 | + | |
41 | +procedure TForm1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer; | |
42 | + aRect: TRect; aState: TGridDrawState); | |
43 | +var | |
44 | + OldCanvas : TCanvas; | |
45 | + | |
46 | + procedure SaveOldCanvas; | |
47 | + begin | |
48 | + OldCanvas.Brush.Style := StringGrid1.Canvas.Brush.Style; | |
49 | + OldCanvas.Brush.Color := StringGrid1.Canvas.Brush.Color; | |
50 | + OldCanvas.Pen.Width := StringGrid1.Canvas.Pen.Width; | |
51 | + OldCanvas.Pen.Color := StringGrid1.Canvas.Pen.Color; | |
52 | + OldCanvas.Pen.Mode := StringGrid1.Canvas.Pen.Mode; | |
53 | + | |
54 | + end; | |
55 | + | |
56 | + procedure LoadOldCanvas; | |
57 | + begin | |
58 | + StringGrid1.Canvas.Brush.Style := OldCanvas.Brush.Style; | |
59 | + StringGrid1.Canvas.Brush.Color := OldCanvas.Brush.Color; | |
60 | + StringGrid1.Canvas.Pen.Width := OldCanvas.Pen.Width; | |
61 | + StringGrid1.Canvas.Pen.Color := OldCanvas.Pen.Color; | |
62 | + StringGrid1.Canvas.Pen.Mode := OldCanvas.Pen.Mode; | |
63 | + end; | |
64 | + | |
65 | + procedure DrawLines(Color : TColor; Selected : Boolean = False); | |
66 | + var LColor : TColor; | |
67 | + | |
68 | + function HalfDarker(Color : TColor) : TColor; | |
69 | + begin | |
70 | + Result := ((Blue(Color) and $7F) shl 16) or ((Green(Color) and $7F) shl 8 ) or (Red(Color) and $7F) | |
71 | + end; | |
72 | + | |
73 | + begin | |
74 | + StringGrid1.Canvas.Brush.Style := bsSolid; | |
75 | + StringGrid1.Canvas.Pen.Width:= 1; | |
76 | + if Selected then LColor := HalfDarker(Color) else LColor := Color; | |
77 | + StringGrid1.Canvas.Brush.Color := LColor; | |
78 | + StringGrid1.Canvas.Pen.Color := LColor; | |
79 | + StringGrid1.Canvas.Rectangle(aRect); | |
80 | + end; | |
81 | + | |
82 | + procedure DrawDots; | |
83 | + var LColor : TColor; | |
84 | + LFix, | |
85 | + LLeft, | |
86 | + LRight, | |
87 | + LHSize, | |
88 | + LVSize : longint; | |
89 | + begin | |
90 | + LFix := 2; | |
91 | + LVSize := ((aRect.Bottom - aRect.Top) div 2); | |
92 | + LHSize := aRect.Left + (aRect.Right - aRect.Left) div 2; | |
93 | + LLeft := LHSize - LVSize; | |
94 | + LRight := LHSize + LVSize; | |
95 | + | |
96 | + if gdSelected in aState then | |
97 | + LColor := clGray | |
98 | + else | |
99 | + LColor := clBlack; | |
100 | + | |
101 | + StringGrid1.Canvas.Brush.Style := bsClear; | |
102 | + StringGrid1.Canvas.Brush.Color := LColor; | |
103 | + StringGrid1.Canvas.Pen.Width:= 1; | |
104 | + StringGrid1.Canvas.Pen.Color := LColor; | |
105 | + StringGrid1.Canvas.Ellipse(LLeft+LFix,aRect.Top+LFix,LRight-LFix,aRect.Bottom-LFix); | |
106 | + end; | |
107 | + | |
108 | +begin | |
109 | + OldCanvas := TCanvas.Create; | |
110 | + SaveOldCanvas; | |
111 | + try | |
112 | + if (aCol <> 0) and (aRow <> 0) then | |
113 | + begin | |
114 | + if (aRow = 1) or (aRow = 8) then DrawLines(clYellow,gdSelected in aState); | |
115 | + if (aRow = 2) or (aRow = 7) then DrawLines($00FF00,gdSelected in aState); | |
116 | + if (aRow = 3) or (aRow = 6) then DrawLines(clRed,gdSelected in aState); | |
117 | + if (aRow = 4) or (aRow = 9) then DrawLines(clBlue,gdSelected in aState); | |
118 | + if (aRow = 5) or (aRow = 10) then DrawLines($FF00FF,gdSelected in aState); | |
119 | + | |
120 | + if CheckBoxDrawDots.Checked then | |
121 | + if (Odd(aRow) and Odd(aCol)) or | |
122 | + (not Odd(aRow) and not Odd(aCol)) then | |
123 | + DrawDots; | |
124 | + | |
125 | + LoadOldCanvas; | |
126 | + end; | |
127 | + finally | |
128 | + OldCanvas.Free; | |
129 | + end; | |
130 | +end; | |
131 | + | |
132 | +procedure TForm1.CheckBoxDrawDotsChange(Sender: TObject); | |
133 | +begin | |
134 | + StringGrid1.Invalidate; | |
135 | +end; | |
136 | + | |
137 | +procedure TForm1.Button1Click(Sender: TObject); | |
138 | +begin | |
139 | + ShowMessage('Hello world'); | |
140 | +end; | |
141 | + | |
142 | +end. | |
143 | + | ... | ... |