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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
unit base;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TFBase }
TFBase = class(TForm)
PlanningImg: TImage;
TitreImg: TImage;
procedure FormCreate(Sender: TObject);
private
const
CoulFonte = clBlack;
NbJours = 366; // Nombre de jours à afficher sur le planning
FdGite1 = $00DDDDFF; // Couleurs des fonds gîtes libres
FdGite2 = $00FFDDDD;
FdGite3 = $00C8FFC8;
DateOrg = 43229; // 9 mai 2018
var
longueurPlanning: integer;
fdTitre: TColor;
procedure CentreTexte(Canneva: TCanvas; Texte: string; OrgX, OrgY, L, H: Integer);
procedure DessineTitre;
procedure DessinePlanning;
public
end;
var
FBase: TFBase;
implementation
{$R *.lfm}
{ TFBase }
procedure TFBase.FormCreate(Sender: TObject);
begin
FBase.Width:=805;
FBase.DoubleBuffered:=True;
fdTitre := $00EEEEEE;
DessineTitre;
DessinePlanning;
end;
procedure TFBase.CentreTexte(Canneva: TCanvas; Texte: string;
OrgX, OrgY, L, H: Integer);
var
X, Y: Integer;
begin
X := OrgX + (L - Canneva.TextWidth(Texte)) div 2;
Y := OrgY + (H - Canneva.TextHeight(Texte)) div 2;
Canneva.TextOut(X,Y,Texte);
end;
procedure TFbase.DessineTitre;
begin
with TitreImg do
begin
Left := 0;
Top :=0;
Width := 805;
Height := 40;
with Canvas do
begin
//Lignes verticales
MoveTo(0,0);
LineTo(0,40);
MoveTo(201,0);
LineTo(201,40);
MoveTo(402,0);
LineTo(402,40);
MoveTo(603,0);
LineTo(603,40);
MoveTo(804,0);
LineTo(804,40);
//Lignes Horizontales
MoveTo(0,0);
LineTo(804,0);
MoveTo(0,40);
LineTo(804,40);
//Ecriture du titre
Brush.Color := fdTitre;
Font.Size := 20;
Brush.Color := $00EEEEEE;
FloodFill(5,5,clBlack,fsBorder); //Fond de la bande de titre qui apparemment ne fonctionne pas
Font.Color := $00000000;
CentreTexte(TitreImg.Canvas,'DATE',0,0,200,40);
FloodFill(205,5,clBlack,fsBorder);
Font.Color := $000066CC;
CentreTexte(TitreImg.Canvas,'GÎTE 1',201,0,200,40);
Font.Color := $00FF0000;
FloodFill(405,5,clBlack,fsBorder);
CentreTexte(TitreImg.Canvas,'GÎTE 2',402,0,200,40);
Font.Color := $0000AA00;
FloodFill(605,5,clBlack,fsBorder);
CentreTexte(TitreImg.Canvas,'GÎTE 3',603,0,200,40);
end;
end;
end;
procedure TFBase.DessinePlanning;
var
i: Integer;
chaine: string;
begin
with PlanningImg do
begin
Left := 0;
Top :=0;
Width := 805;
longueurPlanning := 40 + NbJours * 20;
Height := longueurPlanning;
with Canvas do
begin
// Lignes verticales
MoveTo(0,0);
LineTo(0,longueurPlanning);
MoveTo(201,0);
LineTo(201,longueurPlanning);
MoveTo(402,0);
LineTo(402,longueurPlanning);
MoveTo(603,0);
LineTo(603,longueurPlanning);
MoveTo(804,0);
LineTo(804,longueurPlanning);
// Lignes horizontales supérieure et inférieure
MoveTo(0,0);
LineTo(804,0);
MoveTo(0,longueurPlanning-1);
LineTo(804,longueurPlanning-1);
// Écriture du titre et coloration des colonnes
Font.Size := 20;
Brush.Color := fdTitre;
FloodFill(5,5,clBlack,fsBorder);
Font.Color := $00000000;
CentreTexte(PlanningImg.Canvas,'DATE',0,0,200,40);
Brush.Color := FdGite1;
FloodFill(205,5,clBlack,fsBorder);
Font.Color := $000000FF;
CentreTexte(PlanningImg.Canvas,'GÎTE 1',201,0,200,40);
Brush.Color := FdGite2;
Font.Color := $00FF0000;
FloodFill(405,5,clBlack,fsBorder);
CentreTexte(PlanningImg.Canvas,'GÎTE 2',402,0,200,40);
Brush.Color := FdGite3;
Font.Color := $0000AA00;
FloodFill(605,5,clBlack,fsBorder);
CentreTexte(PlanningImg.Canvas,'GÎTE 3',603,0,200,40);
// Ligne horizontale de fermeture du titre (après coloration des colonnes)
MoveTo(0,40);
LineTo(804,40);
// Écriture des dates
for i := 0 to (Trunc(Now)-DateOrg)+366 do
begin
Brush.Color := FdTitre;
Font.Size := 10;
Font.Color := CoulFonte;
MoveTo(0,(i+1)*20+40);
LineTo(804,(i+1)*20+40);
DateTimeToString(Chaine,'dddd d mmmm yyyy',DateOrg + i);
CentreTexte(PlanningImg.Canvas,Chaine,0,i*20+40,200,20);
end;
end;
end;
end;
end. |