diff --git a/components/rx/trunk/Demos/RxDBGrid/RxDBGridDemo.lpi b/components/rx/trunk/Demos/RxDBGrid/RxDBGridDemo.lpi index 89ac28034..a4a9ab241 100644 --- a/components/rx/trunk/Demos/RxDBGrid/RxDBGridDemo.lpi +++ b/components/rx/trunk/Demos/RxDBGrid/RxDBGridDemo.lpi @@ -11,7 +11,6 @@ - @@ -71,10 +70,7 @@ - - - - + @@ -99,15 +95,13 @@ - - - + - - + + @@ -437,7 +431,6 @@ - @@ -447,7 +440,6 @@ - @@ -572,7 +564,6 @@ - @@ -737,7 +728,6 @@ - @@ -858,11 +848,11 @@ - + - + @@ -887,9 +877,6 @@ - - - @@ -918,5 +905,4 @@ - diff --git a/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.lfm b/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.lfm index ea2c320ca..470cacb87 100644 --- a/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.lfm +++ b/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.lfm @@ -11,7 +11,7 @@ object RxDBGridMainForm: TRxDBGridMainForm OnCreate = FormCreate SessionProperties = 'RxDBGridExportSpreadSheet1.FileName;RxDBGridExportSpreadSheet1.OpenAfterExport;RxDBGridExportSpreadSheet1.Options;RxDBGridExportSpreadSheet1.PageName;RxDBGridPrint1.Options;RxDBGridPrint1.Orientation;RxDBGridPrint1.PageMargin;RxDBGridPrint1.ReportTitle;RxDBGridPrint1.ShowColumnHeaderOnAllPage' ShowHint = True - LCLVersion = '1.2.4.0' + LCLVersion = '1.5' object RxDBGrid1: TRxDBGrid Left = 0 Height = 624 @@ -23,10 +23,10 @@ object RxDBGridMainForm: TRxDBGridMainForm Columns = < item Title.Alignment = taCenter - Title.Caption = '...' Title.Orientation = toHorizontal Title.Hint = 'DEVELOPER' Title.ShowHint = True + Title.Caption = '...' Width = 50 FieldName = 'DEVELOPER_ID' Constraints.MinWidth = 50 @@ -47,10 +47,10 @@ object RxDBGridMainForm: TRxDBGridMainForm item Color = clSkyBlue Title.Alignment = taCenter - Title.Caption = 'Code - ID' Title.Orientation = toVertical90 Title.Hint = 'Code - ID' Title.ShowHint = True + Title.Caption = 'Code - ID' Width = 100 FieldName = 'ID' EditButtons = <> @@ -66,10 +66,10 @@ object RxDBGridMainForm: TRxDBGridMainForm end item Title.Alignment = taCenter - Title.Caption = 'Developer' Title.Orientation = toHorizontal Title.Hint = 'Developer full name' Title.ShowHint = True + Title.Caption = 'Developer' Width = 136 FieldName = 'Developer' Constraints.MinWidth = 10 @@ -89,10 +89,10 @@ object RxDBGridMainForm: TRxDBGridMainForm end item Title.Alignment = taCenter - Title.Caption = 'Computer software (all info) - Программное обеспечение|Name' Title.Orientation = toHorizontal Title.Hint = 'Product name' Title.ShowHint = True + Title.Caption = 'Computer software (all info) - Программное обеспечение|Name' Width = 110 FieldName = 'NAME' EditButtons = <> @@ -106,10 +106,10 @@ object RxDBGridMainForm: TRxDBGridMainForm end item Title.Alignment = taCenter - Title.Caption = 'Computer software (all info) - Программное обеспечение|Cost' Title.Orientation = toHorizontal Title.Hint = 'Product price' Title.ShowHint = True + Title.Caption = 'Computer software (all info) - Программное обеспечение|Cost' Width = 136 FieldName = 'PRICE' DisplayFormat = '#,##0.00' @@ -142,10 +142,10 @@ object RxDBGridMainForm: TRxDBGridMainForm end item Title.Alignment = taCenter - Title.Caption = 'Computer software (all info) - Программное обеспечение|Date Present' Title.Orientation = toHorizontal Title.Hint = 'Soft date present...' Title.ShowHint = True + Title.Caption = 'Computer software (all info) - Программное обеспечение|Date Present' Width = 136 FieldName = 'Date_Present' EditButtons = <> @@ -157,10 +157,10 @@ object RxDBGridMainForm: TRxDBGridMainForm end item Title.Alignment = taCenter - Title.Caption = 'DEVELOPER_ID' Title.Orientation = toHorizontal Title.Hint = 'DEVELOPER' Title.ShowHint = True + Title.Caption = 'DEVELOPER_ID' Width = 141 FieldName = 'DEVELOPER_ID' EditButtons = <> @@ -178,8 +178,8 @@ object RxDBGridMainForm: TRxDBGridMainForm 'Negative' ) Title.Alignment = taCenter - Title.Caption = 'Rait' Title.Orientation = toHorizontal + Title.Caption = 'Rait' FieldName = 'RAIT' DirectInput = False EditButtons = < @@ -317,7 +317,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = Button2 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Panel1 - Left = 274 + Left = 270 Height = 21 Top = 7 Width = 36 @@ -331,7 +331,7 @@ object RxDBGridMainForm: TRxDBGridMainForm Left = 7 Height = 33 Top = 7 - Width = 89 + Width = 87 Action = actCalcTotal AutoSize = True BorderSpacing.Around = 6 @@ -341,10 +341,10 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = Button1 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Panel1 - Left = 102 + Left = 100 Height = 33 Top = 7 - Width = 166 + Width = 164 Action = actOptimizeColumnsWidthAll AutoSize = True BorderSpacing.Around = 6 @@ -355,7 +355,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = CheckBox2 AnchorSideTop.Side = asrBottom - Left = 503 + Left = 499 Height = 25 Hint = 'Use filter line' Top = 38 @@ -369,7 +369,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = Label1 AnchorSideTop.Control = Label1 AnchorSideTop.Side = asrBottom - Left = 280 + Left = 276 Height = 29 Top = 34 Width = 217 @@ -389,7 +389,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = ComboBox1 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Panel1 - Left = 503 + Left = 499 Height = 25 Hint = 'Auto fill column width' Top = 7 @@ -403,7 +403,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = CheckBox2 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Panel1 - Left = 643 + Left = 639 Height = 25 Top = 7 Width = 122 @@ -419,7 +419,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = CheckBox3 AnchorSideTop.Side = asrBottom - Left = 643 + Left = 639 Height = 25 Top = 38 Width = 118 @@ -434,7 +434,7 @@ object RxDBGridMainForm: TRxDBGridMainForm AnchorSideLeft.Control = CheckBox3 AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = Panel1 - Left = 771 + Left = 767 Height = 25 Top = 7 Width = 97 @@ -480,19 +480,14 @@ object RxDBGridMainForm: TRxDBGridMainForm item Name = 'Date_Present' DataType = ftDate - Precision = 0 - Size = 0 end item Name = 'DEVELOPER_ID' DataType = ftInteger - Precision = 0 - Size = 0 end item Name = 'RAIT' DataType = ftString - Precision = 0 Size = 15 end> PacketRecords = 0 @@ -655,13 +650,10 @@ object RxDBGridMainForm: TRxDBGridMainForm item Name = 'DEVELOPER_ID' DataType = ftInteger - Precision = 0 - Size = 0 end item Name = 'DEVELOPER_NAME' DataType = ftString - Precision = 0 Size = 130 end> PacketRecords = 0 @@ -1370,4 +1362,10 @@ object RxDBGridMainForm: TRxDBGridMainForm left = 548 top = 269 end + object RxDBGridFooterTools1: TRxDBGridFooterTools + RxDBGrid = RxDBGrid1 + Caption = 'Totals row' + left = 591 + top = 270 + end end diff --git a/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.pas b/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.pas index fd0200a72..27f83846a 100644 --- a/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.pas +++ b/components/rx/trunk/Demos/RxDBGrid/rxdbgridmainunit.pas @@ -7,8 +7,8 @@ interface uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, rxmemds, DB, rxdbgrid, RxAboutDialog, RxIniPropStorage, RxDBGridPrintGrid, - RxDBGridExportSpreadSheet, ExtCtrls, Buttons, Menus, ActnList, StdCtrls, - DBGrids, types; + RxDBGridExportSpreadSheet, RxDBGridFooterTools, ExtCtrls, Buttons, Menus, + ActnList, StdCtrls, DBGrids, types; type @@ -23,6 +23,7 @@ type MenuItem9: TMenuItem; RxAboutDialog1: TRxAboutDialog; RxDBGridExportSpreadSheet1: TRxDBGridExportSpreadSheet; + RxDBGridFooterTools1: TRxDBGridFooterTools; RxDBGridPrint1: TRxDBGridPrint; RxIniPropStorage1: TRxIniPropStorage; RxMemoryData1RAIT: TStringField; diff --git a/components/rx/trunk/languages/rxdconst.es.po b/components/rx/trunk/languages/rxdconst.es.po index d23a44240..819782817 100644 --- a/components/rx/trunk/languages/rxdconst.es.po +++ b/components/rx/trunk/languages/rxdconst.es.po @@ -29,6 +29,10 @@ msgstr "Cambiar clave" msgid "SCircularDataLink" msgstr "SCircularEnlaceDato" +#: rxdconst.scollumnname +msgid "Collumn name" +msgstr "" + #: rxdconst.sconfirmpasswordlabel msgid "&Confirm:" msgstr "&Confirmar:" @@ -143,6 +147,46 @@ msgstr "Campo '%s' debe tener un valor" msgid "Type mismatch for field '%s', expecting: %s actual: %s" msgstr "Tipo no corresponde para el campo '%s', se esperaba: %s actual: %s" +#: rxdconst.sfunction +msgid "Function" +msgstr "" + +#: rxdconst.sfvtavg +msgid "AVG" +msgstr "" + +#: rxdconst.sfvtcount +msgid "Count" +msgstr "" + +#: rxdconst.sfvtfieldvalue +msgid "Field value" +msgstr "" + +#: rxdconst.sfvtmax +msgid "Max value" +msgstr "" + +#: rxdconst.sfvtmin +msgid "Min value" +msgstr "" + +#: rxdconst.sfvtnon +msgid "None" +msgstr "" + +#: rxdconst.sfvtrecno +msgid "Record no" +msgstr "" + +#: rxdconst.sfvtstatictext +msgid "Static text" +msgstr "" + +#: rxdconst.sfvtsum +msgid "Sum" +msgstr "" + #: rxdconst.shidezerovalues msgid "Hide zero values" msgstr "" @@ -400,6 +444,10 @@ msgstr "Seleccionar Columnas Visibles" msgid "Sort data for collumns" msgstr "Ordenar por Columnas" +#: rxdconst.srxdbgridtoolscaption +msgid "Totals row" +msgstr "" + #: rxdconst.srxdescending msgid "Descending" msgstr "Descendente" @@ -521,6 +569,10 @@ msgstr "Error del Servidor" msgid "find" msgstr "buscar" +#: rxdconst.ssetuptotalrow +msgid "Setup total row" +msgstr "" + #: rxdconst.sshowcolumnheaderonallpage msgid "Show column header on all page" msgstr "" diff --git a/components/rx/trunk/languages/rxdconst.po b/components/rx/trunk/languages/rxdconst.po index 6e7c01d91..10782b731 100644 --- a/components/rx/trunk/languages/rxdconst.po +++ b/components/rx/trunk/languages/rxdconst.po @@ -29,6 +29,10 @@ msgstr "" msgid "SCircularDataLink" msgstr "" +#: rxdconst.scollumnname +msgid "Collumn name" +msgstr "" + #: rxdconst.sconfirmpasswordlabel msgid "&Confirm:" msgstr "" @@ -141,6 +145,46 @@ msgstr "" msgid "Type mismatch for field '%s', expecting: %s actual: %s" msgstr "" +#: rxdconst.sfunction +msgid "Function" +msgstr "" + +#: rxdconst.sfvtavg +msgid "AVG" +msgstr "" + +#: rxdconst.sfvtcount +msgid "Count" +msgstr "" + +#: rxdconst.sfvtfieldvalue +msgid "Field value" +msgstr "" + +#: rxdconst.sfvtmax +msgid "Max value" +msgstr "" + +#: rxdconst.sfvtmin +msgid "Min value" +msgstr "" + +#: rxdconst.sfvtnon +msgid "None" +msgstr "" + +#: rxdconst.sfvtrecno +msgid "Record no" +msgstr "" + +#: rxdconst.sfvtstatictext +msgid "Static text" +msgstr "" + +#: rxdconst.sfvtsum +msgid "Sum" +msgstr "" + #: rxdconst.shidezerovalues msgid "Hide zero values" msgstr "" @@ -397,6 +441,10 @@ msgstr "" msgid "Sort data for collumns" msgstr "" +#: rxdconst.srxdbgridtoolscaption +msgid "Totals row" +msgstr "" + #: rxdconst.srxdescending msgid "Descending" msgstr "" @@ -515,6 +563,10 @@ msgstr "" msgid "find" msgstr "" +#: rxdconst.ssetuptotalrow +msgid "Setup total row" +msgstr "" + #: rxdconst.sshowcolumnheaderonallpage msgid "Show column header on all page" msgstr "" diff --git a/components/rx/trunk/languages/rxdconst.ru.po b/components/rx/trunk/languages/rxdconst.ru.po index d47c3f8a4..792421dd2 100644 --- a/components/rx/trunk/languages/rxdconst.ru.po +++ b/components/rx/trunk/languages/rxdconst.ru.po @@ -29,6 +29,10 @@ msgstr "Изменить пароль" msgid "SCircularDataLink" msgstr "Перекрёстная ссылка данных" +#: rxdconst.scollumnname +msgid "Collumn name" +msgstr "" + #: rxdconst.sconfirmpasswordlabel msgid "&Confirm:" msgstr "&Подтверждение:" @@ -143,6 +147,46 @@ msgstr "Поле '%s' ожидает значение" msgid "Type mismatch for field '%s', expecting: %s actual: %s" msgstr "Несоответсвие типов для поля '%s', необходимо: %s введено: %s" +#: rxdconst.sfunction +msgid "Function" +msgstr "" + +#: rxdconst.sfvtavg +msgid "AVG" +msgstr "" + +#: rxdconst.sfvtcount +msgid "Count" +msgstr "" + +#: rxdconst.sfvtfieldvalue +msgid "Field value" +msgstr "" + +#: rxdconst.sfvtmax +msgid "Max value" +msgstr "" + +#: rxdconst.sfvtmin +msgid "Min value" +msgstr "" + +#: rxdconst.sfvtnon +msgid "None" +msgstr "" + +#: rxdconst.sfvtrecno +msgid "Record no" +msgstr "" + +#: rxdconst.sfvtstatictext +msgid "Static text" +msgstr "" + +#: rxdconst.sfvtsum +msgid "Sum" +msgstr "" + #: rxdconst.shidezerovalues msgid "Hide zero values" msgstr "" @@ -400,6 +444,10 @@ msgstr "Выбор столбцов для отображения" msgid "Sort data for collumns" msgstr "Сортировать данные по колонкам" +#: rxdconst.srxdbgridtoolscaption +msgid "Totals row" +msgstr "" + #: rxdconst.srxdescending msgid "Descending" msgstr "По убыванию" @@ -519,6 +567,10 @@ msgstr "Ошибка сервера" msgid "find" msgstr "поиск" +#: rxdconst.ssetuptotalrow +msgid "Setup total row" +msgstr "" + #: rxdconst.sshowcolumnheaderonallpage msgid "Show column header on all page" msgstr "" diff --git a/components/rx/trunk/languages/rxdconst.uk.po b/components/rx/trunk/languages/rxdconst.uk.po index 5ae57f6a5..5d2748baf 100644 --- a/components/rx/trunk/languages/rxdconst.uk.po +++ b/components/rx/trunk/languages/rxdconst.uk.po @@ -38,6 +38,10 @@ msgstr "Змінити пароль" msgid "SCircularDataLink" msgstr "Перехресне посилання даних" +#: rxdconst.scollumnname +msgid "Collumn name" +msgstr "" + #: rxdconst.sconfirmpasswordlabel msgid "&Confirm:" msgstr "&Підтвердження:" @@ -152,6 +156,46 @@ msgstr "Поле '%s' очікує значення" msgid "Type mismatch for field '%s', expecting: %s actual: %s" msgstr "Несоответсвие типов для поля '%s', необходимо: %s введено: %s" +#: rxdconst.sfunction +msgid "Function" +msgstr "" + +#: rxdconst.sfvtavg +msgid "AVG" +msgstr "" + +#: rxdconst.sfvtcount +msgid "Count" +msgstr "" + +#: rxdconst.sfvtfieldvalue +msgid "Field value" +msgstr "" + +#: rxdconst.sfvtmax +msgid "Max value" +msgstr "" + +#: rxdconst.sfvtmin +msgid "Min value" +msgstr "" + +#: rxdconst.sfvtnon +msgid "None" +msgstr "" + +#: rxdconst.sfvtrecno +msgid "Record no" +msgstr "" + +#: rxdconst.sfvtstatictext +msgid "Static text" +msgstr "" + +#: rxdconst.sfvtsum +msgid "Sum" +msgstr "" + #: rxdconst.shidezerovalues msgid "Hide zero values" msgstr "" @@ -409,6 +453,10 @@ msgstr "Вибір стовпців для відображення" msgid "Sort data for collumns" msgstr "Сортувати дані по колонках" +#: rxdconst.srxdbgridtoolscaption +msgid "Totals row" +msgstr "" + #: rxdconst.srxdescending msgid "Descending" msgstr "За зменшенням" @@ -528,6 +576,10 @@ msgstr "Помилка сервера" msgid "find" msgstr "Пошук" +#: rxdconst.ssetuptotalrow +msgid "Setup total row" +msgstr "" + #: rxdconst.sshowcolumnheaderonallpage msgid "Show column header on all page" msgstr "" diff --git a/components/rx/trunk/registerrxdb.pas b/components/rx/trunk/registerrxdb.pas index dbf0bfe90..162a94448 100644 --- a/components/rx/trunk/registerrxdb.pas +++ b/components/rx/trunk/registerrxdb.pas @@ -42,7 +42,7 @@ procedure Register; implementation uses DB, DBPropEdits, rxdbgrid, RxDBSpinEdit, RxDBTimeEdit, RxDBCtrls, rxmemds, ComponentEditors, seldsfrm, PropEdits, RxDBColorBox, dbdateedit, rxdbcomb, - rxlookup, dbcurredit; + rxlookup, dbcurredit, RxDBGridFooterTools; type @@ -113,6 +113,11 @@ begin RegisterComponents('RX DBAware',[TRxDBGrid]); end; +procedure RegisterRxDbGridFooterTools; +begin + RegisterComponents('RX DBAware',[TRxDBGridFooterTools]); +end; + procedure RegisterRxMemDS; begin RegisterComponents('RX DBAware',[TRxMemoryData]); @@ -151,6 +156,7 @@ begin RegisterUnit('rxdbgrid', @RegisterRxDbGrid); RegisterUnit('rxmemds', @RegisterRxMemDS); RegisterUnit('RxDBColorBox', @RegisterRxDBColorBox); + RegisterUnit('RxDBGridFooterTools', @RegisterRxDbGridFooterTools); //Component Editors RegisterComponentEditor(TRxMemoryData, TMemDataSetEditor); diff --git a/components/rx/trunk/rxdbgrid.pas b/components/rx/trunk/rxdbgrid.pas index 034aebb65..4eab863ac 100644 --- a/components/rx/trunk/rxdbgrid.pas +++ b/components/rx/trunk/rxdbgrid.pas @@ -474,10 +474,14 @@ type { TRxDbGridColumns } TRxDbGridColumns = class(TDbGridColumns) + private + function GetColumn(Index: Integer): TRxColumn; + procedure SetColumn(Index: Integer; AValue: TRxColumn); protected procedure Notify(Item: TCollectionItem;Action: TCollectionNotification); override; public function Add: TRxColumn; + property Items[Index: Integer]: TRxColumn read GetColumn write SetColumn; default; end; { TRxDbGridColumnsSortList } @@ -569,6 +573,7 @@ type FBeforeQuickSearch: TRxQuickSearchNotifyEvent; FQuickUTF8Search: string; FOldDataSetState:TDataSetState; + FToolsList:TFPList; FOnSortChanged: TNotifyEvent; @@ -886,6 +891,8 @@ type end; { TRxDBGridAbstractTools } + TRxDBGridToolsEvent = (rxteMouseDown, rxteMouseUp, rxteMouseMove, rxteKeyDown, rxteKeyUp); + TRxDBGridToolsEvents = set of TRxDBGridToolsEvent; TRxDBGridAbstractTools = class(TComponent) private @@ -896,11 +903,14 @@ type protected FRxDBGrid: TRxDBGrid; FCaption:string; + FToolsEvents:TRxDBGridToolsEvents; procedure SetRxDBGrid(AValue: TRxDBGrid); function DoExecTools:boolean; virtual; function DoSetupTools:boolean; virtual; + function MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer):boolean; virtual; public constructor Create(AOwner: TComponent); override; + destructor Destroy; override; function Execute:boolean; published property RxDBGrid:TRxDBGrid read FRxDBGrid write SetRxDBGrid; @@ -1029,6 +1039,12 @@ begin Result:=true; end; +function TRxDBGridAbstractTools.MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: integer): boolean; +begin + Result:=false; +end; + procedure TRxDBGridAbstractTools.ExecTools(Sender: TObject); begin Execute; @@ -1037,10 +1053,17 @@ end; constructor TRxDBGridAbstractTools.Create(AOwner: TComponent); begin inherited Create(AOwner); + FToolsEvents:=[]; FCaption:=Name; FShowSetupForm:=false; end; +destructor TRxDBGridAbstractTools.Destroy; +begin + SetRxDBGrid(nil); + inherited Destroy; +end; + function TRxDBGridAbstractTools.Execute: boolean; begin Result:=true; @@ -1345,6 +1368,8 @@ begin else FOwner.FOptionsRx:=FOwner.FOptionsRx - [rdgFooterRows]; + if FActive then + FOwner.CalcStatTotals; FOwner.VisualChange; end; @@ -2900,6 +2925,9 @@ begin R.Caption := ATools.FCaption; R.OnClick := @(ATools.ExecTools); R.Tag:=IntPtr(ATools); + + if Assigned(FToolsList) and (FToolsList.IndexOf(ATools)<0) then + FToolsList.Add(ATools); end; procedure TRxDBGrid.RemoveTools(ATools: TRxDBGridAbstractTools); @@ -2915,6 +2943,9 @@ begin R.Free; exit; end; + + if Assigned(FToolsList) then + FToolsList.Remove(ATools); end; { @@ -3606,6 +3637,7 @@ var Cell: TGridCoord; Rect: TRect; C:TRxColumn; + i: Integer; begin QuickUTF8Search := ''; @@ -3690,13 +3722,22 @@ begin end; end else + begin inherited MouseDown(Button, Shift, X, Y); + end; end else + begin inherited MouseDown(Button, Shift, X, Y); + end; end else begin + for i:=0 to FToolsList.Count-1 do + if (rxteMouseDown in TRxDBGridAbstractTools(FToolsList[i]).FToolsEvents) then + if TRxDBGridAbstractTools(FToolsList[i]).MouseDown(Button, Shift, X, Y) then + exit; + if rdgMrOkOnDblClik in FOptionsRx then begin if (Cell.Y > 0) and (Cell.X >= Ord(dgIndicator in Options)) and @@ -5001,6 +5042,7 @@ begin {$IFDEF RXDBGRID_OPTIONS_WO_CANCEL_ON_EXIT} Options := Options - [dgCancelOnExit]; {$ENDIF} + FToolsList:=TFPList.Create; FSortColumns:=TRxDbGridColumnsSortList.Create; @@ -5074,6 +5116,7 @@ begin FreeAndNil(F_LastFilter); FreeAndNil(FKeyStrokes); + FreeAndNil(FToolsList); inherited Destroy; FreeAndNil(FSortColumns); end; @@ -5150,6 +5193,16 @@ begin // The correct implementation is doing nothing end; +function TRxDbGridColumns.GetColumn(Index: Integer): TRxColumn; +begin + Result:=TRxColumn( inherited Items[Index] ); +end; + +procedure TRxDbGridColumns.SetColumn(Index: Integer; AValue: TRxColumn); +begin + Items[Index].Assign( AValue ); +end; + procedure TRxDbGridColumns.Notify(Item: TCollectionItem; Action: TCollectionNotification); begin diff --git a/components/rx/trunk/rxdbgridfootertools.pas b/components/rx/trunk/rxdbgridfootertools.pas new file mode 100644 index 000000000..729fd5741 --- /dev/null +++ b/components/rx/trunk/rxdbgridfootertools.pas @@ -0,0 +1,147 @@ +{ RxDBGridPrintGrid unit + + Copyright (C) 2005-2015 Lagunov Aleksey alexs@yandex.ru and Lazarus team + original conception from rx library for Delphi (c) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} + +unit RxDBGridFooterTools; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, rxdbgrid, Graphics, Grids, Controls; + +type + + { TRxDBGridFooterTools } + + TRxDBGridFooterTools = class(TRxDBGridAbstractTools) + private + FFooterColor: TColor; + FFooterRowCount: integer; + procedure SetFooterColor(AValue: TColor); + procedure SetFooterRowCount(AValue: integer); + protected + function DoExecTools:boolean;override; + function DoSetupTools:boolean; override; + function MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer):boolean; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + property FooterRowCount:integer read FFooterRowCount write SetFooterRowCount default 1; + property FooterColor:TColor read FFooterColor write SetFooterColor default clYellow; + end; + +implementation +uses Forms, Dialogs, rxdbgridfootertools_setup, rxdconst; + +{ TRxDBGridFooterTools } + +procedure TRxDBGridFooterTools.SetFooterRowCount(AValue: integer); +begin + if FFooterRowCount=AValue then Exit; + FFooterRowCount:=AValue; +end; + +procedure TRxDBGridFooterTools.SetFooterColor(AValue: TColor); +begin + if FFooterColor=AValue then Exit; + FFooterColor:=AValue; +end; + +function TRxDBGridFooterTools.DoExecTools: boolean; +begin + Result:=false; + if (RxDBGrid = nil) or (RxDBGrid.DataSource = nil) or (RxDBGrid.DataSource.Dataset = nil) then + Exit; + + if RxDBGrid.FooterOptions.Active then + RxDBGrid.FooterOptions.Active:=false + else + begin + if RxDBGrid.FooterOptions.RowCount = 0 then + RxDBGrid.FooterOptions.RowCount:=FFooterRowCount; + + if RxDBGrid.FooterOptions.Color = clNone then + RxDBGrid.FooterOptions.Color:=FFooterColor; + RxDBGrid.FooterOptions.Active:=true + end; +end; + +function TRxDBGridFooterTools.DoSetupTools: boolean; +begin + RxDBGridFooterTools_SetupForm:=TRxDBGridFooterTools_SetupForm.Create(Application); + RxDBGridFooterTools_SetupForm.InitData(RxDBGrid); + Result:=RxDBGridFooterTools_SetupForm.ShowModal = mrOk; + if Result then + begin + RxDBGridFooterTools_SetupForm.SetData; + RxDBGrid.CalcStatTotals; + end; + RxDBGridFooterTools_SetupForm.Free; +end; + +type + THackRxDBGrid = class(TRxDBGrid); + +function TRxDBGridFooterTools.MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: integer): boolean; +var + Cell: TGridCoord; +begin + if (Y > THackRxDBGrid(RxDBGrid).GCache.ClientHeight - (RxDBGrid.DefaultRowHeight * RxDBGrid.FooterOptions.RowCount)) then + begin + Result:=true; + Cell := RxDBGrid.MouseCoord(X, Y); + if (ssDouble in Shift) then + DoSetupTools; + end + else + Result:=false; +end; + +constructor TRxDBGridFooterTools.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FCaption:=sRxDBGridToolsCaption; + FToolsEvents:=[rxteMouseDown]; + ShowSetupForm:=false; + FFooterColor:=clYellow; + FFooterRowCount:=1; +end; + +destructor TRxDBGridFooterTools.Destroy; +begin + inherited Destroy; +end; + +end. + diff --git a/components/rx/trunk/rxdbgridfootertools_setup.lfm b/components/rx/trunk/rxdbgridfootertools_setup.lfm new file mode 100644 index 000000000..be791e2c3 --- /dev/null +++ b/components/rx/trunk/rxdbgridfootertools_setup.lfm @@ -0,0 +1,68 @@ +object RxDBGridFooterTools_SetupForm: TRxDBGridFooterTools_SetupForm + Left = 789 + Height = 254 + Top = 366 + Width = 333 + Caption = 'Setup footer row' + ClientHeight = 254 + ClientWidth = 333 + OnCreate = FormCreate + Position = poScreenCenter + LCLVersion = '1.5' + object StringGrid1: TStringGrid + Left = 0 + Height = 200 + Top = 0 + Width = 333 + Align = alClient + AutoFillColumns = True + ColCount = 2 + Columns = < + item + ReadOnly = True + Title.Alignment = taCenter + Title.Caption = 'Collumn name' + Width = 165 + end + item + PickList.Strings = ( + 'fvtNon' + 'fvtSum' + 'fvtAvg' + 'fvtCount' + 'fvtFieldValue' + 'fvtStaticText' + 'fvtMax' + 'fvtMin' + 'fvtRecNo' + ) + Title.Alignment = taCenter + Title.Caption = 'Function' + Width = 166 + end> + FixedCols = 0 + Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll] + TabOrder = 0 + TitleStyle = tsNative + ColWidths = ( + 165 + 166 + ) + end + object ButtonPanel1: TButtonPanel + Left = 6 + Height = 42 + Top = 206 + Width = 321 + OKButton.Name = 'OKButton' + OKButton.DefaultCaption = True + HelpButton.Name = 'HelpButton' + HelpButton.DefaultCaption = True + CloseButton.Name = 'CloseButton' + CloseButton.DefaultCaption = True + CancelButton.Name = 'CancelButton' + CancelButton.DefaultCaption = True + TabOrder = 1 + ShowButtons = [pbOK, pbCancel, pbHelp] + end +end diff --git a/components/rx/trunk/rxdbgridfootertools_setup.pas b/components/rx/trunk/rxdbgridfootertools_setup.pas new file mode 100644 index 000000000..b72b97a18 --- /dev/null +++ b/components/rx/trunk/rxdbgridfootertools_setup.pas @@ -0,0 +1,137 @@ +{ RxDBGridPrintGrid unit + + Copyright (C) 2005-2014 Lagunov Aleksey alexs@yandex.ru and Lazarus team + original conception from rx library for Delphi (c) + + This library is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published by + the Free Software Foundation; either version 2 of the License, or (at your + option) any later version with the following modification: + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent modules,and + to copy and distribute the resulting executable under terms of your choice, + provided that you also meet, for each linked independent module, the terms + and conditions of the license of that module. An independent module is a + module which is not derived from or based on this library. If you modify + this library, you may extend this exception to your version of the library, + but you are not obligated to do so. If you do not wish to do so, delete this + exception statement from your version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License + for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +} + +unit rxdbgridfootertools_setup; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids, + ButtonPanel, rxdbgrid, rxdconst; + +type + + { TRxDBGridFooterTools_SetupForm } + + TRxDBGridFooterTools_SetupForm = class(TForm) + ButtonPanel1: TButtonPanel; + StringGrid1: TStringGrid; + procedure FormCreate(Sender: TObject); + private + FRxDBGrid:TRxDBGrid; + public + procedure InitData(ARxDBGrid:TRxDBGrid); + procedure SetData; + end; + +var + RxDBGridFooterTools_SetupForm: TRxDBGridFooterTools_SetupForm; + +const + rxFooterFunctionNames : array [TFooterValueType] of string = + (sfvtNon, sfvtSum, sfvtAvg, sfvtCount, sfvtFieldValue, sfvtStaticText, sfvtMax, sfvtMin, sfvtRecNo); +implementation +uses dbutils; + +{$R *.lfm} + +{ TRxDBGridFooterTools_SetupForm } + +procedure TRxDBGridFooterTools_SetupForm.FormCreate(Sender: TObject); +begin + Caption:=sSetupTotalRow; + StringGrid1.Columns[0].Title.Caption:=sCollumnName; + StringGrid1.Columns[1].Title.Caption:=sFunction; +end; + +procedure TRxDBGridFooterTools_SetupForm.InitData(ARxDBGrid: TRxDBGrid); +var + i: Integer; + c: TFooterValueType; +begin + FRxDBGrid:=ARxDBGrid; + if not Assigned(FRxDBGrid) then exit; + StringGrid1.TitleStyle:=FRxDBGrid.TitleStyle; + + StringGrid1.Columns[1].PickList.Clear; + for c:=Low(TFooterValueType) to High(TFooterValueType) do + StringGrid1.Columns[1].PickList.Add(rxFooterFunctionNames[c]); + + + StringGrid1.RowCount:=FRxDBGrid.Columns.Count+1; + + for i:=0 to FRxDBGrid.Columns.Count-1 do + begin + StringGrid1.Cells[0, i+1]:=FRxDBGrid.Columns[i].Title.Caption; + if FRxDBGrid.Columns[i].Footer.ValueType <> fvtNon then + StringGrid1.Cells[1, i+1]:=rxFooterFunctionNames[FRxDBGrid.Columns[i].Footer.ValueType]; + end; +end; + +procedure TRxDBGridFooterTools_SetupForm.SetData; +var + B,C: TFooterValueType; + Col: TRxColumn; + i: Integer; +begin + for i:=1 to StringGrid1.RowCount-1 do + begin + Col:=FRxDBGrid.ColumnByCaption(StringGrid1.Cells[0, i]); + B:=fvtNon; + for c:=Low(TFooterValueType) to High(TFooterValueType) do + if StringGrid1.Cells[1, i] = rxFooterFunctionNames[c] then + begin + B:=C; + break; + end; + + if B<>fvtNon then + begin + if not (Col.Field.DataType in NumericDataTypes) then + if not (B in [fvtCount, fvtFieldValue, fvtStaticText, fvtRecNo]) then + B:=fvtNon; + + if B<>fvtNon then + begin + Col.Footer.FieldName:=Col.FieldName; + Col.Footer.Alignment:=Col.Alignment; + Col.Footer.DisplayFormat:=Col.DisplayFormat; + end; + end; + + Col.Footer.ValueType:=B; + end; +end; + +end. + diff --git a/components/rx/trunk/rxdconst.pas b/components/rx/trunk/rxdconst.pas index ce7532990..f3eac8cec 100644 --- a/components/rx/trunk/rxdconst.pas +++ b/components/rx/trunk/rxdconst.pas @@ -200,6 +200,19 @@ resourcestring sPrintGrid = 'Print grid'; sHideZeroValues = 'Hide zero values'; + sRxDBGridToolsCaption = 'Totals row'; + sfvtNon = 'None'; + sfvtSum = 'Sum'; + sfvtAvg = 'AVG'; + sfvtCount = 'Count'; + sfvtFieldValue = 'Field value'; + sfvtStaticText = 'Static text'; + sfvtMax = 'Max value'; + sfvtMin = 'Min value'; + sfvtRecNo = 'Record no'; + sSetupTotalRow = 'Setup total row'; + sCollumnName = 'Collumn name'; + sFunction = 'Function'; diff --git a/components/rx/trunk/rxnew.lpk b/components/rx/trunk/rxnew.lpk index 402aabb08..daa739203 100644 --- a/components/rx/trunk/rxnew.lpk +++ b/components/rx/trunk/rxnew.lpk @@ -25,7 +25,7 @@ translate to Lazarus by alexs in 2005 - 2015 "/> - + @@ -305,6 +305,18 @@ translate to Lazarus by alexs in 2005 - 2015 + + + + + + + + + + + + diff --git a/components/rx/trunk/rxnew.pas b/components/rx/trunk/rxnew.pas index fcddd2d8b..4f10f72d6 100644 --- a/components/rx/trunk/rxnew.pas +++ b/components/rx/trunk/rxnew.pas @@ -18,7 +18,8 @@ uses RxTimeEdit, rxtoolbar, RxVersInfo, RxViewsPanel, rxxpman, seldsfrm, tooledit, vclutils, RxCloseFormValidator, RxHistoryNavigator, ex_rx_bin_datapacket, ex_rx_datapacket, ex_rx_xml_datapacket, rxsortby, - RxMDI, RxIniPropStorage, rxDateRangeEditUnit, LazarusPackageIntf; + RxMDI, RxIniPropStorage, rxDateRangeEditUnit, RxDBGridFooterTools, + rxdbgridfootertools_setup, LazarusPackageIntf; implementation