Changeset 463 for Common


Ignore:
Timestamp:
Feb 10, 2014, 5:18:38 PM (11 years ago)
Author:
chronos
Message:
  • Modified: All components from Common package are registered to component pallete to group Common.
  • Modified: TListViewSort is now component.
  • Added: Class TListViewFilter for entering filtering text for TListViewSort.
Location:
Common
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • Common/Common.lpk

    r456 r463  
    1 <?xml version="1.0"?>
     1<?xml version="1.0" encoding="UTF-8"?>
    22<CONFIG>
    33  <Package Version="4">
     
    2222    <License Value="GNU/GPL"/>
    2323    <Version Minor="7"/>
    24     <Files Count="18">
     24    <Files Count="19">
    2525      <Item1>
    2626        <Filename Value="StopWatch.pas"/>
     
    9393      <Item17>
    9494        <Filename Value="UListViewSort.pas"/>
     95        <HasRegisterProc Value="True"/>
    9596        <UnitName Value="UListViewSort"/>
    9697      </Item17>
     
    100101        <UnitName Value="UPersistentForm"/>
    101102      </Item18>
     103      <Item19>
     104        <Filename Value="UFindFile.pas"/>
     105        <HasRegisterProc Value="True"/>
     106        <UnitName Value="UFindFile"/>
     107      </Item19>
    102108    </Files>
    103109    <i18n>
  • Common/Common.pas

    r456 r463  
    1111  UMemory, UResetableThread, UPool, ULastOpenedList, URegistry,
    1212  UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort,
    13   UPersistentForm, LazarusPackageIntf;
     13  UPersistentForm, UFindFile, LazarusPackageIntf;
    1414
    1515implementation
     
    2121  RegisterUnit('UJobProgressView', @UJobProgressView.Register);
    2222  RegisterUnit('UApplicationInfo', @UApplicationInfo.Register);
     23  RegisterUnit('UListViewSort', @UListViewSort.Register);
    2324  RegisterUnit('UPersistentForm', @UPersistentForm.Register);
     25  RegisterUnit('UFindFile', @UFindFile.Register);
    2426end;
    2527
  • Common/UApplicationInfo.pas

    r393 r463  
    5555procedure Register;
    5656begin
    57   RegisterComponents('Samples', [TApplicationInfo]);
     57  RegisterComponents('Common', [TApplicationInfo]);
    5858end;
    5959
  • Common/UDebugLog.pas

    r456 r463  
    5252procedure Register;
    5353begin
    54   RegisterComponents('Samples', [TDebugLog]);
     54  RegisterComponents('Common', [TDebugLog]);
    5555end;
    5656
  • Common/UFindFile.pas

    r269 r463  
    6464procedure Register;
    6565begin
    66   RegisterComponents('Samples', [TFindFile]);
     66  RegisterComponents('Common', [TFindFile]);
    6767end;
    6868
  • Common/UJobProgressView.pas

    r432 r463  
    169169procedure Register;
    170170begin
    171   RegisterComponents('Samples', [TJobProgressView]);
     171  RegisterComponents('Common', [TJobProgressView]);
    172172end;
    173173
  • Common/ULastOpenedList.pas

    r432 r463  
    4040procedure Register;
    4141begin
    42   RegisterComponents('Samples', [TLastOpenedList]);
     42  RegisterComponents('Common', [TLastOpenedList]);
    4343end;
    4444
  • Common/UListViewSort.pas

    r432 r463  
    99uses
    1010  {$IFDEF Windows}Windows, CommCtrl, {$ENDIF}Classes, Graphics, ComCtrls, SysUtils,
    11   Controls, DateUtils, Dialogs, SpecializedList;
     11  Controls, DateUtils, Dialogs, SpecializedList, Forms, Grids, StdCtrls, ExtCtrls;
    1212
    1313type
     
    1919  TListFilterEvent = procedure (ListViewSort: TListViewSort) of object;
    2020
    21   TListViewSort = class
     21  TListViewSort = class(TComponent)
    2222  private
    2323    FListView: TListView;
     
    4343    List: TListObject;
    4444    Source: TListObject;
    45     constructor Create;
     45    constructor Create(AOwner: TComponent); override;
    4646    destructor Destroy; override;
    4747    function CompareTime(Time1, Time2: TDateTime): Integer;
     
    5050    function CompareBoolean(Value1, Value2: Boolean): Integer;
    5151    procedure Refresh;
     52  published
    5253    property ListView: TListView read FListView write SetListView;
    5354    property OnCompareItem: TCompareEvent read FOnCompareItem
     
    6162  end;
    6263
     64  { TListViewFilter }
     65
     66  TListViewFilter = class(TWinControl)
     67  private
     68    FOnChange: TNotifyEvent;
     69    FStringGrid1: TStringGrid;
     70    procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     71  public
     72    constructor Create(AOwner: TComponent); override;
     73    procedure UpdateFromListView(ListView: TListView);
     74    function TextEntered: Boolean;
     75    function GetColValue(Index: Integer): string;
     76    property StringGrid: TStringGrid read FStringGrid1 write FStringGrid1;
     77  published
     78    property OnChange: TNotifyEvent read FOnChange write FOnChange;
     79    property Align;
     80    property Anchors;
     81  end;
     82
     83procedure Register;
     84
     85
    6386implementation
     87
     88procedure Register;
     89begin
     90  RegisterComponents('Common', [TListViewSort, TListViewFilter]);
     91end;
     92
     93{ TListViewFilter }
     94
     95procedure TListViewFilter.DoOnKeyUp(Sender: TObject; var Key: Word;
     96  Shift: TShiftState);
     97begin
     98  if Assigned(FOnChange) then
     99    FOnChange(Self);
     100end;
     101
     102constructor TListViewFilter.Create(AOwner: TComponent);
     103begin
     104  inherited Create(AOwner);
     105  FStringGrid1 := TStringGrid.Create(Self);
     106  FStringGrid1.Align := alClient;
     107  FStringGrid1.Parent := Self;
     108  FStringGrid1.Visible := True;
     109  FStringGrid1.ScrollBars := ssNone;
     110  FStringGrid1.FixedCols := 0;
     111  FStringGrid1.FixedRows := 0;
     112  FStringGrid1.RowCount := 1;
     113  FStringGrid1.Options := [goFixedHorzLine, goFixedVertLine, goVertLine,
     114    goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll];
     115  FStringGrid1.OnKeyUp := DoOnKeyUp;
     116end;
     117
     118procedure TListViewFilter.UpdateFromListView(ListView: TListView);
     119var
     120  I: Integer;
     121  NewColumn: TGridColumn;
     122begin
     123  with FStringGrid1 do begin
     124    Columns.Clear;
     125    while Columns.Count > ListView.Columns.Count do Columns.Delete(Columns.Count - 1);
     126    while Columns.Count < ListView.Columns.Count do NewColumn := Columns.Add;
     127    for I := 0 to ListView.Columns.Count - 1 do begin
     128      Columns[I].Width := ListView.Columns[I].Width;
     129    end;
     130  end;
     131end;
     132
     133function TListViewFilter.TextEntered: Boolean;
     134var
     135  I: Integer;
     136begin
     137  Result := False;
     138  for I := 0 to FStringGrid1.ColCount - 1 do begin
     139    if FStringGrid1.Cells[I, 0] <> '' then begin
     140      Result := True;
     141      Break;
     142    end;
     143  end;
     144end;
     145
     146function TListViewFilter.GetColValue(Index: Integer): string;
     147begin
     148  if (Index >= 0) and (Index < StringGrid.Columns.Count) then
     149    Result := StringGrid.Cells[Index, 0]
     150    else Result := '';
     151end;
    64152
    65153{ TListViewSort }
     
    160248end;
    161249
    162 constructor TListViewSort.Create;
    163 begin
     250constructor TListViewSort.Create(AOwner: TComponent);
     251begin
     252  inherited;
    164253  List := TListObject.Create;
    165254  List.OwnsObjects := False;
  • Common/UPersistentForm.pas

    r460 r463  
    3939procedure Register;
    4040begin
    41   RegisterComponents('Samples', [TPersistentForm]);
     41  RegisterComponents('Common', [TPersistentForm]);
    4242end;
    4343
Note: See TracChangeset for help on using the changeset viewer.