-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMS_CtrlDrawings.~pas
116 lines (92 loc) · 2.53 KB
/
SMS_CtrlDrawings.~pas
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
unit SMS_CtrlDrawings;
interface
uses
Classes, StdCtrls, Controls, Windows, Graphics, Grids;
procedure GridDrawCell(Grid : TStringGrid; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure PenStyleComboDrawItem(Control : TWinControl; Index : Integer;
Rect : TRect; State : TOwnerDrawState);
implementation
uses
SMS_Graphics;
procedure GridDrawCell(Grid : TStringGrid; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
const
SPACE = 10;
var
aAlignment : TAlignment;
iX, iY : Integer;
aSize : TSize;
stText : String;
begin
with Grid.Canvas do
begin
Font.Name := Grid.Font.Name;
Font.Size := Grid.Font.Size;
//
stText := Grid.Cells[ACol, ARow];
if gdFixed in State then
begin
Brush.Color := FIXED_COLOR;
Font.Color := clBlack;
aAlignment := taLeftJustify;
end else
begin
if stText = '' then
Brush.Color := NODATA_COLOR
else
Brush.Color := clWhite;
Font.Color := clBlack;
aAlignment := taRightJustify;
end;
//-- background
FillRect(Rect);
//-- text
if stText = '' then Exit;
//-- calc position
aSize := TextExtent(stText);
iY := Rect.Top + (Rect.Bottom - Rect.Top - aSize.cy) div 2;
iX := Rect.Left + (Rect.Right-Rect.Left-aSize.cx) div 2;
//-- put text
case aAlignment of
taLeftJustify : iX := Rect.Left + SPACE;
taCenter : iX := Rect.Left + (Rect.Right-Rect.Left-aSize.cx) div 2;
taRightJustify : iX := Rect.Left + Rect.Right-Rect.Left - SPACE - aSize.cx;
end;
TextRect(Rect, iX, iY, stText);
end;
end;
procedure PenStyleComboDrawItem(Control : TWinControl; Index : Integer;
Rect : TRect; State : TOwnerDrawState);
var
aCombo : TComboBox;
aPenStyle: TPenStyle;
begin
aCombo := Control as TComboBox;
aPenStyle := aCombo.Canvas.Pen.Style;
with aCombo.Canvas do
begin
Brush.Color := clWhite;
Pen.Mode := pmCopy;
if odSelected in State then
begin
Pen.Color := clBlue;
Rectangle(Rect);
end else
FillRect(Rect);
Pen.Width := 1;
Brush.Color := clWhite;
Pen.Color := clBlack;
case Index of
0 : Pen.Style := psSolid;
1 : Pen.Style := psDash;
2 : Pen.Style := psDot;
3 : Pen.Style := psDashDot;
4 : Pen.Style := psDashDotDot;
end;
MoveTo(Rect.Left+3, (Rect.Bottom + Rect.Top) div 2);
LineTo(Rect.Right-3, (Rect.Bottom + Rect.Top) div 2);
end;
aCombo.Canvas.Pen.Style := aPenStyle;
end;
end.