You've already forked lazarus-ccr
Sudoku: use OnPrepareCanvas instead of OnDrawCell. Adjust background-color, so text is readable.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7221 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -31,7 +31,7 @@ object Form1: TForm1
|
|||||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||||
RowCount = 9
|
RowCount = 9
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
OnDrawCell = StringGrid1DrawCell
|
OnPrepareCanvas = StringGrid1PrepareCanvas
|
||||||
OnSetEditText = StringGrid1SetEditText
|
OnSetEditText = StringGrid1SetEditText
|
||||||
end
|
end
|
||||||
object ButtonFill: TButton
|
object ButtonFill: TButton
|
||||||
|
@ -41,8 +41,8 @@ type
|
|||||||
StringGrid1: TStringGrid;
|
StringGrid1: TStringGrid;
|
||||||
procedure ButtonFillClick(Sender: TObject);
|
procedure ButtonFillClick(Sender: TObject);
|
||||||
procedure ButtonSolveClick(Sender: TObject);
|
procedure ButtonSolveClick(Sender: TObject);
|
||||||
procedure StringGrid1DrawCell(Sender: TObject; Col, Row: Integer;
|
procedure StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
||||||
aRect: TRect; aState: TGridDrawState);
|
aState: TGridDrawState);
|
||||||
procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
|
procedure StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
|
||||||
const Value: string);
|
const Value: string);
|
||||||
private
|
private
|
||||||
@ -89,31 +89,29 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Integer;
|
|
||||||
aRect: TRect; aState: TGridDrawState);
|
procedure TForm1.StringGrid1PrepareCanvas(sender: TObject; aCol, aRow: Integer;
|
||||||
|
aState: TGridDrawState);
|
||||||
var
|
var
|
||||||
Kleur: Boolean;
|
NeedsColor: Boolean;
|
||||||
begin
|
begin
|
||||||
Kleur := False;
|
NeedsColor := False;
|
||||||
if Col in [0..2, 6..8] then begin
|
if aCol in [0..2, 6..8] then
|
||||||
if Row in [0..2, 6..8] then begin
|
begin
|
||||||
Kleur := True;
|
if aRow in [0..2, 6..8] then
|
||||||
|
begin
|
||||||
|
NeedsColor := True;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end
|
||||||
if Row in [3..5] then begin
|
else
|
||||||
Kleur := True;
|
begin
|
||||||
|
if aRow in [3..5] then
|
||||||
|
begin
|
||||||
|
NeedsColor := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if Kleur then begin
|
if NeedsColor then
|
||||||
inc(aRect.Top, 1);
|
(Sender as TStringGrid).Canvas.Brush.Color := $00EEEEEE;
|
||||||
inc(aRect.Left, 1);
|
|
||||||
dec(aRect.Bottom, 1);
|
|
||||||
dec(aRect.Right, 1);
|
|
||||||
StringGrid1.Canvas.Brush.Color := clLtGray;
|
|
||||||
StringGrid1.Canvas.FillRect(aRect);
|
|
||||||
// Volgende regel is alleen in Delphi noodzakelijk.
|
|
||||||
// StringGrid1.Canvas.TextOut(aRect.Left, aRect.Top, StringGrid1.Cells[Col, Row]);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
|
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
|
||||||
|
Reference in New Issue
Block a user