RxFPC:cleanup code

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4647 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-05-12 07:25:00 +00:00
parent adf78c2a5f
commit e2921c7a65
6 changed files with 218 additions and 115 deletions

View File

@ -55,7 +55,7 @@
<MinVersion Major="1" Release="18" Build="56" Valid="True"/>
</Item5>
</RequiredPackages>
<Units Count="126">
<Units Count="128">
<Unit0>
<Filename Value="RxDBGridDemo.lpr"/>
<IsPartOfProject Value="True"/>
@ -70,11 +70,11 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridMainUnit"/>
<IsVisibleTab Value="True"/>
<TopLine Value="68"/>
<CursorPos X="133" Y="85"/>
<UsageCount Value="107"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../../fpcsrc/fcl/db/db.pp"/>
@ -96,15 +96,16 @@
</Unit4>
<Unit5>
<Filename Value="../../rxdbgrid.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="773"/>
<CursorPos Y="797"/>
<EditorIndex Value="1"/>
<TopLine Value="734"/>
<CursorPos Y="756"/>
<UsageCount Value="21"/>
<Bookmarks Count="3">
<Item0 X="37" Y="1740" ID="1"/>
<Item0 X="37" Y="1738" ID="1"/>
<Item1 Y="588" ID="2"/>
<Item2 Y="5651" ID="3"/>
<Item2 Y="5619" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="../../../lcl/lresources.pp"/>
@ -435,17 +436,18 @@
<Filename Value="../../../../lcl/dbgrids.pas"/>
<UnitName Value="DBGrids"/>
<EditorIndex Value="-1"/>
<TopLine Value="201"/>
<CursorPos X="3" Y="218"/>
<TopLine Value="1339"/>
<CursorPos X="3" Y="1339"/>
<UsageCount Value="22"/>
</Unit58>
<Unit59>
<Filename Value="../../../../lcl/grids.pas"/>
<UnitName Value="Grids"/>
<EditorIndex Value="-1"/>
<TopLine Value="12049"/>
<CursorPos X="3" Y="12052"/>
<EditorIndex Value="3"/>
<TopLine Value="1185"/>
<CursorPos X="15" Y="1215"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit59>
<Unit60>
<Filename Value="../../../../../../install/fpcsrc/rtl/objpas/classes/classesh.inc"/>
@ -505,9 +507,13 @@
<ComponentName Value="rxSortByForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="50"/>
<CursorPos X="14" Y="65"/>
<UsageCount Value="9"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="123"/>
<CursorPos X="5" Y="137"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit68>
<Unit69>
<Filename Value="../../rxfilterby.pas"/>
@ -871,8 +877,145 @@
<CursorPos X="37" Y="501"/>
<UsageCount Value="11"/>
</Unit125>
<Unit126>
<Filename Value="../../../../lcl/lclproc.pas"/>
<UnitName Value="LCLProc"/>
<EditorIndex Value="-1"/>
<TopLine Value="321"/>
<CursorPos X="10" Y="338"/>
<UsageCount Value="10"/>
</Unit126>
<Unit127>
<Filename Value="../../rxdbgridfootertools.pas"/>
<UnitName Value="RxDBGridFooterTools"/>
<EditorIndex Value="-1"/>
<TopLine Value="97"/>
<CursorPos X="64" Y="119"/>
<UsageCount Value="10"/>
</Unit127>
</Units>
<JumpHistory HistoryIndex="-1"/>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="5305" TopLine="5288"/>
</Position1>
<Position2>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="5303" TopLine="5287"/>
</Position2>
<Position3>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4882" TopLine="4901"/>
</Position3>
<Position4>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4880" Column="9" TopLine="4863"/>
</Position4>
<Position5>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4954" Column="8" TopLine="4937"/>
</Position5>
<Position6>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="721" Column="7" TopLine="706"/>
</Position6>
<Position7>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="716" Column="7" TopLine="700"/>
</Position7>
<Position8>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4445" Column="3" TopLine="4429"/>
</Position8>
<Position9>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="3518" Column="16" TopLine="3501"/>
</Position9>
<Position10>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="3282" Column="5" TopLine="3265"/>
</Position10>
<Position11>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="3248" Column="9" TopLine="3238"/>
</Position11>
<Position12>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2919" Column="3" TopLine="2905"/>
</Position12>
<Position13>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2705" Column="3" TopLine="2718"/>
</Position13>
<Position14>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2699" Column="18" TopLine="2682"/>
</Position14>
<Position15>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2833" Column="61" TopLine="2816"/>
</Position15>
<Position16>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="956" Column="80" TopLine="938"/>
</Position16>
<Position17>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2705" TopLine="2686"/>
</Position17>
<Position18>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="4648" TopLine="4631"/>
</Position18>
<Position19>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="5016" Column="5" TopLine="5019"/>
</Position19>
<Position20>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="721" TopLine="707"/>
</Position20>
<Position21>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="750" Column="31" TopLine="734"/>
</Position21>
<Position22>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2722" TopLine="2768"/>
</Position22>
<Position23>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2703" Column="5" TopLine="2686"/>
</Position23>
<Position24>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2818" Column="17" TopLine="2818"/>
</Position24>
<Position25>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2443" Column="13" TopLine="2408"/>
</Position25>
<Position26>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="2403" Column="13" TopLine="2385"/>
</Position26>
<Position27>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="1841" TopLine="1822"/>
</Position27>
<Position28>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="1536" Column="16" TopLine="1534"/>
</Position28>
<Position29>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="750" Column="15" TopLine="735"/>
</Position29>
<Position30>
<Filename Value="../../rxsortby.pas"/>
<Caret Line="65" Column="14" TopLine="50"/>
</Position30>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>

View File

@ -113,7 +113,7 @@ type
);
TRxDSState = (rxdsInactive, rxdsActive);
//TRxDSState = (rxdsInactive, rxdsActive);
TRxFilterOpCode = (fopEQ, fopNotEQ, fopStartFrom, fopEndTo, fopLike, fopNotLike);
{ TRxDBGridKeyStroke }
@ -548,7 +548,7 @@ type
TRxDBGrid = class(TCustomDBGrid)
private
FColumnDefValues: TRxDBGridColumnDefValues;
FrxDSState:TRxDSState;
//FrxDSState:TRxDSState;
FFooterOptions: TRxDBGridFooterOptions;
FSortColumns: TRxDbGridColumnsSortList;
FSortingNow:Boolean;
@ -718,8 +718,6 @@ type
procedure ColRowMoved(IsColumn: boolean; FromIndex, ToIndex: integer); override;
procedure Paint; override;
procedure UpdateActive; override;
procedure UpdateData; override;
procedure MoveSelection; override;
function GetBufferCount: integer; override;
procedure CMHintShow(var Message: TLMessage); message CM_HINTSHOW;
@ -749,12 +747,12 @@ type
procedure DoEditorHide; override;
procedure DoEditorShow; override;
procedure EraseBackground(DC: HDC); override;
property Editor;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure EraseBackground(DC: HDC); override;
procedure FilterRec(DataSet: TDataSet; var Accept: boolean);
function EditorByStyle(Style: TColumnButtonStyle): TWinControl; override;
procedure LayoutChanged; override;
@ -953,7 +951,7 @@ procedure RegisterRxDBGridSortEngine(RxDBGridSortEngineClass: TRxDBGridSortEngin
implementation
uses Math, rxdconst, rxstrutils, strutils, rxdbgrid_findunit, rxdbgrid_columsunit,
rxlookup, tooledit, LCLProc, Clipbrd, rxfilterby, rxsortby, variants;
rxlookup, tooledit, LCLProc, Clipbrd, rxfilterby, rxsortby, variants, LazUTF8;
{$R rxdbgrid.res}
@ -1535,7 +1533,7 @@ end;
function TRxDBGridAbstractTools.DoExecTools: boolean;
begin
//
Result:=false;
end;
function TRxDBGridAbstractTools.DoSetupTools: boolean;
@ -1837,15 +1835,9 @@ begin
end;
constructor TRxColumnEditButton.Create(ACollection: TCollection);
var
P: TBitmap;
begin
inherited Create(ACollection);
FButton:=TSpeedButton.Create(nil);
//FButton.Glyph:=LoadLazResBitmapImage('rx_markerdown');
{ P:=CreateResBitmap('rx_markerdown');
FButton.Glyph:=P;
P.Free;}
FSpinBtn:=TRxSpinButton.Create(nil);
FSpinBtn.OnBottomClick:=@DoBottomClick;
@ -2304,12 +2296,13 @@ begin
end;
{ TRxDBGrid }
(*
const
ALIGN_FLAGS: array[TAlignment] of integer =
(DT_LEFT or DT_SINGLELINE {or DT_EXPANDTABS} or DT_NOPREFIX,
DT_RIGHT or DT_SINGLELINE {or DT_EXPANDTABS} or DT_NOPREFIX,
DT_CENTER or DT_SINGLELINE {or DT_EXPANDTABS} or DT_NOPREFIX);
*)
const
ALIGN_FLAGS_HEADER: array[TAlignment] of integer =
(DT_LEFT or {DT_EXPANDTABS or} DT_NOPREFIX,
@ -2391,7 +2384,7 @@ procedure TRxDBGrid.WMVScroll(var Message: TLMVScroll);
var
IsSeq: boolean;
aPos, aRange, aPage: Integer;
DeltaRec: integer;
//DeltaRec: integer;
function MaxPos: Integer;
begin
@ -2441,6 +2434,7 @@ begin
if EditorMode then
RestoreEditor;
inherited;
{$ifdef dbgDBGrid}
DebugLn('---- Diff=',dbgs(DeltaRec), ' FinalPos=',dbgs(aPos));
{$endif}
@ -2695,13 +2689,13 @@ end;
procedure TRxDBGrid.CalcTitle;
var
i, j: integer;
H, H1, W, H2, W1: integer;
H, H1, W, {H2,} W1: integer;
rxCol, rxColNext: TRxColumn;
rxTit, rxTitleNext: TRxColumnTitle;
MLRec1, P: TMLCaptionItem;
MLRec2: TMLCaptionItem;
tmpCanvas: TCanvas;
S: string;
//S: string;
begin
{ TODO -oalexs : need rewrite code - split to 2 step:
1. make links between column
@ -2710,7 +2704,6 @@ begin
exit;
tmpCanvas := GetWorkingCanvas(Canvas);
try
// H := 1;
ClearMLCaptionPointers;
for i := 0 to Columns.Count - 1 do
begin
@ -2817,7 +2810,7 @@ begin
for j := 0 to rxTit.CaptionLinesCount - 1 do
begin
MLRec1 := rxTit.CaptionLine(j);
S := MLRec1.Caption;
//S := MLRec1.Caption;
if not Assigned(MLRec1.Prior) then
begin
W := rxCol.Width;
@ -2914,8 +2907,8 @@ end;
procedure TRxDBGrid.OutCaptionCellText(aCol, aRow: integer; const aRect: TRect;
aState: TGridDrawState; const ACaption: string);
var
T1, T2: TTextStyle;
//var
// T1, T2: TTextStyle;
begin
if (TitleStyle = tsNative) then
DrawThemedCell(aCol, aRow, aRect, aState)
@ -3244,6 +3237,7 @@ var
Asc:array of boolean;
begin
if (FSortColumns.Count = 0) then exit;
S:='';
FSortingNow:=true;
if (FSortColumns.Count>1) or (Pos(';', FSortColumns[0].GetSortFields)>0) then
begin
@ -3278,7 +3272,7 @@ end;
function TRxDBGrid.UpdateRowsHeight: integer;
var
i, J, H, H1, H2:integer;
B:boolean;
//B:boolean;
F:TField;
S:string;
CurActiveRecord: Integer;
@ -3514,7 +3508,7 @@ var
FTitle: TRxColumnTitle;
GrdCol: TRxColumn;
MLI, MLINext, MLI1: TMLCaptionItem;
MLI{, MLINext, MLI1}: TMLCaptionItem;
begin
if (dgIndicator in Options) and (aCol = 0) then
@ -4440,8 +4434,8 @@ begin
end;
procedure TRxDBGrid.KeyDown(var Key: word; Shift: TShiftState);
var
FTmpReadOnly: boolean;
//var
// FTmpReadOnly: boolean;
procedure DoShowFindDlg;
begin
@ -4643,28 +4637,6 @@ begin
Dec(FInProcessCalc);
end;
procedure TRxDBGrid.UpdateActive;
begin
{ if FInProcessCalc > 0 then
exit;}
inherited UpdateActive;
{ if FInProcessCalc < 0 then
begin
FInProcessCalc := 0;
UpdateFooterRowOnUpdateActive;
end
{ else
if FFooterOptions.Active and (FFooterOptions.RowCount > 0) then
UpdateFooterRowOnUpdateActive;}
}
// UpdateRowsHeight;
end;
procedure TRxDBGrid.UpdateData;
begin
inherited UpdateData;
end;
procedure TRxDBGrid.MoveSelection;
begin
inherited MoveSelection;
@ -4876,9 +4848,8 @@ var
P_26: TBookmark;
{$ENDIF}
P: TBookmark;
i, cnt, K: integer;
i, cnt: integer;
APresent: boolean;
BB:Double;
DHL:THackDataLink;
DHS:THackDataSet;
@ -5034,7 +5005,7 @@ begin
if Min(DHL.RecordCount + SavePos - 1, DHS.RecNo) > 0 then
DHS.RecNo := Min(DHL.RecordCount + SavePos - 1, DHS.RecNo);
K:=DHS.RecNo;
//K:=DHS.RecNo;
while not DHS.BOF do
begin
@ -5299,9 +5270,6 @@ begin
end;
procedure TRxDBGrid.OnFilterClose(Sender: TObject);
var
C: TRxColumn;
i: integer;
begin
OptionsRx := OptionsRx - [rdgFilter];
DataSource.DataSet.Filtered := False;
@ -5461,7 +5429,7 @@ end;
procedure TRxDBGrid.DoEditorHide;
var
R:TRxColumn;
i, w:integer;
i:integer;
begin
inherited DoEditorHide;
R:=SelectedColumn as TRxColumn;

View File

@ -114,18 +114,10 @@ type
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
Result:=(Y > THackRxDBGrid(RxDBGrid).GCache.ClientHeight - (RxDBGrid.DefaultRowHeight * RxDBGrid.FooterOptions.RowCount));
if Result and (ssDouble in Shift) then
DoSetupTools;
end
else
Result:=false;
end;
constructor TRxDBGridFooterTools.Create(AOwner: TComponent);

View File

@ -24,7 +24,7 @@ Copyright (c) 1998 Master-Bank
translate to Lazarus by alexs in 2005 - 2016
"/>
<License Value="LGPL"/>
<Version Major="2" Minor="9" Release="1" Build="183"/>
<Version Major="2" Minor="9" Release="2" Build="190"/>
<Files Count="68">
<Item1>
<Filename Value="autopanel.pas"/>

View File

@ -9,15 +9,15 @@ object rxSortByForm: TrxSortByForm
ClientWidth = 684
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '1.1'
LCLVersion = '1.7'
object Label1: TLabel
AnchorSideLeft.Control = AddBtn
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 417
Height = 15
Left = 421
Height = 20
Top = 6
Width = 105
Width = 113
BorderSpacing.Around = 6
Caption = '&Fields for sorting:'
FocusControl = ListBox1
@ -27,9 +27,9 @@ object rxSortByForm: TrxSortByForm
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Left = 6
Height = 15
Height = 20
Top = 6
Width = 55
Width = 60
BorderSpacing.Around = 6
Caption = '&All fields:'
FocusControl = ListBox2
@ -42,14 +42,14 @@ object rxSortByForm: TrxSortByForm
AnchorSideRight.Control = AddBtn
AnchorSideBottom.Control = CheckBox1
Left = 6
Height = 289
Top = 27
Width = 262
Height = 282
Top = 32
Width = 258
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
OnDblClick = ListBox2DblClick
ScrollWidth = 260
ScrollWidth = 256
TabOrder = 0
TopIndex = -1
end
@ -59,10 +59,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom
Left = 274
Left = 270
Height = 35
Top = 68
Width = 137
Top = 73
Width = 145
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
@ -91,10 +91,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom
Left = 274
Left = 270
Height = 36
Top = 109
Width = 137
Top = 114
Width = 145
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
@ -123,10 +123,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = AddBtn
AnchorSideRight.Side = asrBottom
Left = 274
Left = 270
Height = 36
Top = 151
Width = 137
Top = 156
Width = 145
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 6
@ -157,16 +157,16 @@ object rxSortByForm: TrxSortByForm
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = CheckBox1
Left = 417
Height = 289
Top = 27
Width = 261
Left = 421
Height = 282
Top = 32
Width = 257
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
ItemHeight = 0
OnDblClick = SpeedButton1Click
OnDrawItem = ListBox1DrawItem
ScrollWidth = 259
ScrollWidth = 255
Style = lbOwnerDrawFixed
TabOrder = 5
TopIndex = -1
@ -175,10 +175,10 @@ object rxSortByForm: TrxSortByForm
AnchorSideLeft.Control = Owner
AnchorSideLeft.Side = asrCenter
AnchorSideTop.Control = ListBox1
Left = 274
Left = 270
Height = 35
Top = 27
Width = 137
Top = 32
Width = 145
AutoSize = True
Caption = '&Add field to sort'
Glyph.Data = {
@ -221,9 +221,9 @@ object rxSortByForm: TrxSortByForm
AnchorSideTop.Side = asrBottom
AnchorSideBottom.Control = ButtonPanel1
Left = 6
Height = 22
Top = 322
Width = 151
Height = 24
Top = 320
Width = 158
Anchors = [akLeft, akBottom]
BorderSpacing.Around = 6
Caption = 'Case insensitive sort'

View File

@ -128,13 +128,13 @@ procedure TrxSortByForm.ListBox1DrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
var
X, Y:integer;
P:TRxColumn;
//P:TRxColumn;
S1, S2:string;
Cnv:TCanvas;
begin
Cnv:=ListBox1.Canvas;
Cnv.FillRect(ARect); { clear the rectangle }
P:=TRxColumn(ListBox1.Items.Objects[Index]);
//P:=TRxColumn(ListBox1.Items.Objects[Index]);
S1:=ListBox1.Items[Index];
S2:=Copy(S1, 1, 1);
Delete(S1, 1, 1);
@ -222,7 +222,7 @@ end;
function TrxSortByForm.Execute(ADBGrid: TRxDBGrid; SortNames: TStringList
): Boolean;
var
i, j : Integer;
i : Integer;
S : String;
C:TRxColumn;
begin