Menu

[r2039]: / trunk / Src / FmCompilersDlg.FrLog.pas  Maximize  Restore  History

Download this file

204 lines (182 with data), 6.6 kB

  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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
{
* FmCompilersDlg.FrLog.pas
*
* Implements a frame used to change log file prefixes used for a compiler being
* edited in TCompilersDlg.
*
* $Rev$
* $Date$
*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is FmCompilersDlg.FrLog.pas
*
* The Initial Developer of the Original Code is Peter Johnson
* (http://www.delphidabbler.com/).
*
* Portions created by the Initial Developer are Copyright (C) 2011 Peter
* Johnson. All Rights Reserved.
*
* Contributor(s)
* NONE
*
* ***** END LICENSE BLOCK *****
}
unit FmCompilersDlg.FrLog;
interface
uses
// Delphi
Controls, Grids, ValEdit, Classes, StdCtrls, Types,
// Project
FmCompilersDlg.FrBase;
type
/// <summary>
/// Frame used to change log file prefixes used for a compiler being edited
/// in TCompilersDlg.
/// </summary>
TCompilersDlgLogFrame = class(TCompilersDlgBaseFrame)
lblLogPrefixes: TLabel;
vleLogPrefixes: TValueListEditor;
/// <summary>Handles event triggered when cell is to be drawn in owner draw
/// value editor that displays compiler log prefix. Display an arrow that
/// points to selected cell.</summary>
/// <param name="Sender">TObject [in] Reference to control being drawn.
/// </param>
/// <param name="ACol">Integer [in] Column of cell being drawn.</param>
/// <param name="ARow">Integer [in] Row of cell being drawn.</param>
/// <param name="Rect">TRect [in] Bounding rectangle of cell being drawn.
/// </param>
/// <param name="State">TGridDrawState [in] State of control.</param>
procedure vleLogPrefixesDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
/// <summary>Handles event triggered when a cell is selected in value
/// editor. Redraws display to show changed location of highlight arrow.
/// </summary>
/// <remarks>No parameters other than Sender are used.</remarks>
procedure vleLogPrefixesSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
strict protected
/// <summary>Initialises frame to display details of current compiler.
/// </summary>
procedure Initialise; override;
public
/// <summary>Arranges controls in frame.</summary>
procedure ArrangeControls; override;
/// <summary>Updates current compiler object with edited information.
/// </summary>
procedure UpdateCompiler; override;
end;
implementation
uses
// Delphi
Graphics, GraphUtil,
// Project
Compilers.UGlobals, UCtrlArranger, UGraphicUtils;
{$R *.dfm}
{ TCompilersDlgLogFrame }
procedure TCompilersDlgLogFrame.ArrangeControls;
var
RowIdx: Integer; // loops through rows of vleLogPrefixes
CellSize: TSize; // size of left hand cell in vleLogPrefixes
begin
TCtrlArranger.SetLabelHeights(Self);
vleLogPrefixes.Top := TCtrlArranger.BottomOf(lblLogPrefixes, 4);
// size rows and columns in value editor
for RowIdx := 0 to Pred(vleLogPrefixes.RowCount) do
begin
CellSize := StringExtent(vleLogPrefixes.Keys[RowIdx], vleLogPrefixes.Font);
if CellSize.cx > vleLogPrefixes.ColWidths[0] then
vleLogPrefixes.ColWidths[0] := CellSize.cx;
if CellSize.cy > vleLogPrefixes.RowHeights[RowIdx] then
vleLogPrefixes.RowHeights[RowIdx] := CellSize.cy;
end;
vleLogPrefixes.ColWidths[0] := vleLogPrefixes.ColWidths[0] + 16;
vleLogPrefixes.ColWidths[1] :=
vleLogPrefixes.Width - vleLogPrefixes.ColWidths[0];
end;
procedure TCompilersDlgLogFrame.Initialise;
var
Prefixes: TCompLogPrefixes; // log file prefixes for selected compiler
PrefixKind: TCompLogPrefixID; // loops thru log file prefixes
begin
Prefixes := Compiler.GetLogFilePrefixes;
for PrefixKind := Low(TCompLogPrefixID) to High(TCompLogPrefixID) do
vleLogPrefixes.Cells[1, Ord(PrefixKind)] := Prefixes[PrefixKind];
end;
procedure TCompilersDlgLogFrame.UpdateCompiler;
var
Prefixes: TCompLogPrefixes; // log file prefixes for selected compiler
PrefixKind: TCompLogPrefixID; // loops thru log file prefixes
begin
// NOTE: code assumes ordinal value of prefixes ids map to value edit index
for PrefixKind := Low(TCompLogPrefixID) to High(TCompLogPrefixID) do
Prefixes[PrefixKind] := vleLogPrefixes.Cells[1, Ord(PrefixKind)];
Compiler.SetLogFilePrefixes(Prefixes);
end;
procedure TCompilersDlgLogFrame.vleLogPrefixesDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
ValEd: TValueListEditor; // reference to value editor being displayed
begin
// Get reference to value editor
ValEd := Sender as TValueListEditor;
ValEd.Canvas.Font := ValEd.Font;
with ValEd.Canvas do
begin
if gdFixed in State then
begin
// Set colours for fixed cells (non-editable)
Brush.Color := clBtnFace;
Font.Color := ValEd.Font.Color;
end
else
begin
// Set colours for editable cell
Brush.Color := ValEd.Color;
Font.Color := ValEd.Font.Color;
end;
// Colour the current cell
FillRect(Rect);
if gdFixed in State then
begin
// draw vertical line at right edge of fixed cell to act as border
Pen.Color := clBtnShadow;
MoveTo(Rect.Right - 1, Rect.Top);
LineTo(Rect.Right - 1, Rect.Bottom);
end;
// Display required text
TextOut(
Rect.Left + 2 ,
Rect.Top + (ValEd.RowHeights[ARow] - TextHeight('X')) div 2,
ValEd.Cells[ACol, ARow]
);
if (ACol = 0) and (ValEd.Selection.Top = ARow) then
begin
// This is a fixed cell which has selected editable cell adjacent to it
// draw an arrow at the RHS of this cell that points to selected cell
Pen.Color := clHighlight;
GraphUtil.DrawArrow(
ValEd.Canvas,
sdRight,
Point(Rect.Right - 8, (Rect.Top + Rect.Bottom) div 2 - 4), 4
);
end;
end;
end;
procedure TCompilersDlgLogFrame.vleLogPrefixesSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
begin
// Redraw display to ensure indicator arrows updated
(Sender as TValueListEditor).Invalidate;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.