summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-01 09:26:19 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-04-01 09:26:19 +0000
commit2899709d66c5d72af84a9359d7cfb8402ab56b36 (patch)
tree4a25c43dbc4a9dcf58c795f0bd1da86f30c44c7d
parent432f82c4a7b44ef3a4a858b43c845e2df6148e66 (diff)
downloadfpGUI-2899709d66c5d72af84a9359d7cfb8402ab56b36.tar.xz
* Added a MouseToCell function to BaseGrid.
-rw-r--r--src/gui/gui_basegrid.pas43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/gui/gui_basegrid.pas b/src/gui/gui_basegrid.pas
index 39b9067a..ecccf8ef 100644
--- a/src/gui/gui_basegrid.pas
+++ b/src/gui/gui_basegrid.pas
@@ -147,6 +147,7 @@ type
procedure Update;
procedure BeginUpdate;
procedure EndUpdate;
+ procedure MouseToCell(X, Y: Integer; var ACol, ARow: Longword);
end;
implementation
@@ -992,19 +993,7 @@ begin
end
else
begin // Selecting a Cell via mouse
- FFocusRow := FFirstRow + Longword((y - FMargin - hh) div FDefaultRowHeight);
- if FFocusRow > RowCount then
- FFocusRow := RowCount;
- cw := 0;
- for n := FFirstCol to ColumnCount do
- begin
- inc(cw, ColumnWidth[n]);
- if FMargin+cw >= x then
- begin
- FFocusCol := n;
- Break;
- end;
- end;
+ MouseToCell(x, y, FFocusCol, FFocusRow);
end; { if/else }
if not CanSelectCell(FFocusRow, FFocusCol) then
@@ -1151,5 +1140,33 @@ begin
end;
end;
+procedure TfpgBaseGrid.MouseToCell(X, Y: Integer; var ACol, ARow: Longword);
+var
+ hh: integer;
+ cw: integer;
+ n: Longword;
+begin
+ if ShowHeader then
+ hh := FHeaderHeight+1
+ else
+ hh := 0;
+
+ ARow := FFirstRow + Longword((y - FMargin - hh) div FDefaultRowHeight);
+ if ARow > RowCount then
+ ARow := RowCount;
+
+ cw := 0;
+ for n := FFirstCol to ColumnCount do
+ begin
+ inc(cw, ColumnWidth[n]);
+ if FMargin+cw >= x then
+ begin
+ ACol := n;
+ Break;
+ end;
+ end;
+end;
+
+
end.