RxFPC:RxDBGrid - add new event OnDataHintShow. Tnx naum_off from freepascal.ru

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5106 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-08-26 19:26:05 +00:00
parent 0ea05db2ba
commit 4a5bef15db
5 changed files with 198 additions and 92 deletions

View File

@@ -3,14 +3,13 @@
<ProjectSession>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="9">
<Units Count="11">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<CursorPos Y="20"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
@@ -19,8 +18,9 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
<TopLine Value="3"/>
<CursorPos X="16" Y="18"/>
<IsVisibleTab Value="True"/>
<TopLine Value="57"/>
<CursorPos X="9" Y="73"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@@ -43,22 +43,25 @@
<Unit4>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<UnitName Value="RxDBGridExportSpreadSheet"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="345"/>
<CursorPos X="40" Y="358"/>
<UsageCount Value="15"/>
<Bookmarks Count="1">
<Item0 Y="404" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../../rxdbgrid.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="913"/>
<CursorPos X="3" Y="914"/>
<EditorIndex Value="1"/>
<TopLine Value="4701"/>
<CursorPos Y="4725"/>
<UsageCount Value="15"/>
<Bookmarks Count="2">
<Item0 X="14" Y="822" ID="1"/>
<Item1 X="48" Y="622" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="../../../fpspreadsheet/fpsstrings.pas"/>
@@ -73,135 +76,168 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridExportSpreadSheet_ParamsUnit"/>
<EditorIndex Value="3"/>
<TopLine Value="45"/>
<EditorIndex Value="-1"/>
<TopLine Value="53"/>
<CursorPos X="43" Y="82"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit7>
<Unit8>
<Filename Value="../../rxdconst.pas"/>
<EditorIndex Value="4"/>
<EditorIndex Value="-1"/>
<TopLine Value="163"/>
<CursorPos X="17" Y="182"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit8>
<Unit9>
<Filename Value="../../../../lcl/include/control.inc"/>
<EditorIndex Value="3"/>
<TopLine Value="1075"/>
<CursorPos Y="1091"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="../../../../lcl/controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="2"/>
<TopLine Value="316"/>
<CursorPos X="5" Y="330"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit10>
</Units>
<JumpHistory Count="28" HistoryIndex="27">
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="375" Column="3" TopLine="355"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4727" TopLine="4689"/>
</Position1>
<Position2>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="337" Column="83" TopLine="311"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4698" TopLine="4689"/>
</Position2>
<Position3>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="329" Column="31" TopLine="322"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4700" TopLine="4689"/>
</Position3>
<Position4>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="343" Column="9" TopLine="324"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4702" TopLine="4689"/>
</Position4>
<Position5>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="345" TopLine="327"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4703" TopLine="4689"/>
</Position5>
<Position6>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="61" Column="14" TopLine="42"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4704" TopLine="4689"/>
</Position6>
<Position7>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="368" TopLine="348"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4712" TopLine="4689"/>
</Position7>
<Position8>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="365" TopLine="331"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4713" TopLine="4689"/>
</Position8>
<Position9>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="345" Column="7" TopLine="325"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4714" TopLine="4691"/>
</Position9>
<Position10>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="391" Column="7" TopLine="374"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4716" TopLine="4692"/>
</Position10>
<Position11>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="346" Column="15" TopLine="328"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4717" TopLine="4693"/>
</Position11>
<Position12>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="347" Column="46" TopLine="329"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4718" TopLine="4697"/>
</Position12>
<Position13>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="349" Column="14" TopLine="332"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4719" TopLine="4697"/>
</Position13>
<Position14>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="351" TopLine="333"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4721" TopLine="4703"/>
</Position14>
<Position15>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="356" Column="50" TopLine="338"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4723" TopLine="4703"/>
</Position15>
<Position16>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="359" Column="50" TopLine="341"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4724" TopLine="4703"/>
</Position16>
<Position17>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="345" Column="38" TopLine="331"/>
<Filename Value="unit1.pas"/>
<Caret Line="73" TopLine="57"/>
</Position17>
<Position18>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="358" Column="96" TopLine="341"/>
<Filename Value="unit1.pas"/>
<Caret Line="78" TopLine="57"/>
</Position18>
<Position19>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="138" TopLine="122"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4725" TopLine="4703"/>
</Position19>
<Position20>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="139" TopLine="122"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4731" TopLine="4707"/>
</Position20>
<Position21>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="140" TopLine="122"/>
<Filename Value="../../../../lcl/include/control.inc"/>
<Caret Line="1090" TopLine="1075"/>
</Position21>
<Position22>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="141" TopLine="122"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4708" Column="16" TopLine="4688"/>
</Position22>
<Position23>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="142" TopLine="122"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4726" Column="20" TopLine="4707"/>
</Position23>
<Position24>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="144" TopLine="122"/>
<Filename Value="unit1.pas"/>
<Caret Line="78" TopLine="57"/>
</Position24>
<Position25>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="199" TopLine="181"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4719" Column="49" TopLine="4699"/>
</Position25>
<Position26>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="200" Column="34" TopLine="181"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4718" TopLine="4699"/>
</Position26>
<Position27>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="211" TopLine="181"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4719" TopLine="4699"/>
</Position27>
<Position28>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="96" Column="69" TopLine="39"/>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4721" TopLine="4699"/>
</Position28>
<Position29>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4723" TopLine="4699"/>
</Position29>
<Position30>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4724" TopLine="4700"/>
</Position30>
</JumpHistory>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="../../rxdbgrid.pas"/>
<Line Value="4718"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>

View File

@@ -1,20 +1,23 @@
object Form1: TForm1
Left = 609
Left = 381
Height = 527
Top = 272
Top = 195
Width = 746
Caption = 'Form1'
ClientHeight = 527
ClientWidth = 746
OnCreate = FormCreate
Position = poScreenCenter
ShowHint = True
LCLVersion = '1.7'
object RxDBGrid1: TRxDBGrid
Left = 0
Height = 457
Top = 70
Height = 463
Hint = 'Список данных'
Top = 64
Width = 746
ColumnDefValues.BlobText = '(blob)'
TitleButtons = False
TitleButtons = True
AutoSort = True
Columns = <
item
@@ -150,9 +153,11 @@ object Form1: TForm1
FooterOptions.Active = True
FooterOptions.Color = clYellow
FooterOptions.RowCount = 3
FooterOptions.DrawFullLine = False
OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgFooterRows, rdgAllowToolMenu]
FooterColor = clYellow
FooterRowCount = 3
OnDataHintShow = RxDBGrid1DataHintShow
Align = alClient
Color = clWindow
DrawFullLine = False
@@ -160,28 +165,28 @@ object Form1: TForm1
SelectedColor = clHighlight
GridLineStyle = psSolid
DataSource = DataSource1
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit]
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgHeaderPushedLook]
ParentColor = False
TabOrder = 0
TitleStyle = tsNative
end
object Panel1: TPanel
Left = 0
Height = 70
Height = 64
Top = 0
Width = 746
Align = alTop
AutoSize = True
ClientHeight = 70
ClientHeight = 64
ClientWidth = 746
TabOrder = 1
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 7
Height = 20
Height = 17
Top = 7
Width = 146
Width = 132
BorderSpacing.Around = 6
Caption = 'SpeadSheet file name '
ParentColor = False
@@ -191,8 +196,9 @@ object Form1: TForm1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
Left = 13
Height = 30
Top = 33
Height = 27
Hint = 'Укажите имя файла'
Top = 30
Width = 275
FilterIndex = 0
HideDirectories = False
@@ -209,7 +215,8 @@ object Form1: TForm1
AnchorSideTop.Side = asrCenter
Left = 294
Height = 33
Top = 32
Hint = 'Начать выгрузку'
Top = 27
Width = 87
Caption = 'Export data'
OnClick = Button1Click

View File

@@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils, FileUtil, rxdbgrid, rxmemds, RxDBGridExportSpreadSheet,
Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, EditBtn, db;
Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, EditBtn, db, Types, Grids;
type
@@ -26,6 +26,9 @@ type
RxMemoryData1PRICE: TCurrencyField;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RxDBGrid1DataHintShow(Sender: TObject; CursorPos: TPoint;
Cell: TGridCoord; Column: TRxColumn; var HintStr: string;
var Processed: boolean);
procedure RxDBGridExportSpreadSheet1BeforeExecute(Sender: TObject);
private
{ private declarations }
@@ -50,7 +53,7 @@ var
begin
RxMemoryData1.Open;
//fill test values
for i:=1 to 20 do
for i:=1 to 50 do
begin
RxMemoryData1.Append;
RxMemoryData1CODE.AsInteger:=i;
@@ -58,11 +61,19 @@ begin
RxMemoryData1PRICE.AsFloat:=Random * 100 + 5;
RxMemoryData1.Post;
end;
RxMemoryData1.Open;
RxMemoryData1.First;
FileNameEdit1.Text:='test1.ods';
end;
procedure TForm1.RxDBGrid1DataHintShow(Sender: TObject; CursorPos: TPoint;
Cell: TGridCoord; Column: TRxColumn; var HintStr: string;
var Processed: boolean);
begin
HintStr:='Это очень чётная строка! ' + HintStr;
Processed:=true;
end;
procedure TForm1.RxDBGridExportSpreadSheet1BeforeExecute(Sender: TObject);
begin
RxDBGridExportSpreadSheet1.FileName:=FileNameEdit1.Text;

View File

@@ -684,3 +684,4 @@ msgstr "Использовать сырой JPEG"
#: rxdconst.susernamelabel
msgid "&User name:"
msgstr "&Имя пользователя"

View File

@@ -67,7 +67,11 @@ type
TGetCellPropsEvent = procedure(Sender: TObject; Field: TField;
AFont: TFont; var Background: TColor) of object;
//Freeman35 added
TRxDBGridDataHintShowEvent = procedure(Sender: TObject; CursorPos: TPoint;
Cell: TGridCoord; Column: TRxColumn; var HintStr: string;
var Processed: boolean) of object;
//Freeman35 added
TOnRxCalcFooterValues = procedure(Sender: TObject; Column: TRxColumn; var AValue : Variant) of object;
TOnRxColumnFooterDraw = procedure(Sender: TObject; ABrush: TBrush; AFont : TFont;
const Rect: TRect; Column: TRxColumn; var AText :String) of object;
@@ -615,6 +619,7 @@ type
FToolsList:TFPList;
FOnSortChanged: TNotifyEvent;
FOnDataHintShow:TRxDBGridDataHintShowEvent;
procedure DoCreateJMenu;
function GetColumns: TRxDbGridColumns;
@@ -814,6 +819,7 @@ type
property OnFiltred: TNotifyEvent read FOnFiltred write FOnFiltred;
property OnSortChanged: TNotifyEvent read FOnSortChanged write FOnSortChanged;
property OnDataHintShow: TRxDBGridDataHintShowEvent read FOnDataHintShow write FOnDataHintShow;
//from DBGrid
property Align;
@@ -4658,7 +4664,7 @@ begin
// result := (ClientHeight - GCache.FixedHeight - DefaultRowHeight) div DefaultRowHeight;
end;
procedure TRxDBGrid.CMHintShow(var Message: TLMessage);
{procedure TRxDBGrid.CMHintShow(var Message: TLMessage);
var
Cell: TGridCoord;
tCol: TRxColumn;
@@ -4678,6 +4684,51 @@ begin
end;
end;
inherited CMHintShow(Message);
end;}
procedure TRxDBGrid.CMHintShow(var Message: TLMessage);
var
Cell: TGridCoord;
tCol: TRxColumn;
HintStr_: string;
Processed: boolean;
rec: integer;
CellRect_: TRect;
begin
if Assigned(TCMHintShow(Message).HintInfo) then
begin
with TCMHintShow(Message).HintInfo^ do
begin
Cell := MouseCoord(CursorPos.X, CursorPos.Y);
tCol := TRxColumn(ColumnFromGridColumn(Cell.X));
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) then
begin
if Assigned(tCol) and (TRxColumnTitle(tCol.Title).Hint <> '') and
(TRxColumnTitle(tCol.Title).FShowHint) then
HintStr := TRxColumnTitle(tCol.Title).Hint;
end
else
begin
CellRect_ := CellRect(Cell.X, Cell.Y);
if (CellRect_.Bottom > CursorPos.Y) and (CellRect_.Right > CursorPos.X) then
if Assigned(FOnDataHintShow) then
begin
rec := DataLink.ActiveRecord;
try
DataLink.ActiveRecord := Cell.y - 1;
HintStr_ := tCol.Field.DisplayText;
finally
DataLink.ActiveRecord := rec;
end;
Processed := False;
FOnDataHintShow(Self, CursorPos, Cell, tCol, HintStr_, Processed);
if Processed then
HintStr := HintStr_;
end;
end;
end;
end;
inherited CMHintShow(Message);
end;
procedure TRxDBGrid.FFilterListEditorOnChange(Sender: TObject);