Changeset 15 for trunk/Packages/Common


Ignore:
Timestamp:
Feb 27, 2018, 6:11:44 PM (7 years ago)
Author:
chronos
Message:
  • Added: Partial support for color theming.
  • Added: Allow to edit contact properties in the list of all.
Location:
trunk/Packages/Common
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Common.lpk

    r1 r15  
    1111      <PathDelim Value="\"/>
    1212      <SearchPaths>
    13         <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     13        <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    1414      </SearchPaths>
     15      <Parsing>
     16        <SyntaxOptions>
     17          <SyntaxMode Value="Delphi"/>
     18          <CStyleOperator Value="False"/>
     19          <AllowLabel Value="False"/>
     20          <CPPInline Value="False"/>
     21        </SyntaxOptions>
     22      </Parsing>
     23      <CodeGeneration>
     24        <Optimizations>
     25          <OptimizationLevel Value="0"/>
     26        </Optimizations>
     27      </CodeGeneration>
     28      <Linking>
     29        <Debugging>
     30          <GenerateDebugInfo Value="False"/>
     31        </Debugging>
     32      </Linking>
     33      <Other>
     34        <CompilerMessages>
     35          <IgnoredMessages idx5024="True"/>
     36        </CompilerMessages>
     37      </Other>
    1538    </CompilerOptions>
    1639    <Description Value="Various libraries"/>
    1740    <License Value="GNU/GPL"/>
    1841    <Version Minor="7"/>
    19     <Files Count="20">
     42    <Files Count="21">
    2043      <Item1>
    2144        <Filename Value="StopWatch.pas"/>
     
    106129        <UnitName Value="UScaleDPI"/>
    107130      </Item20>
     131      <Item21>
     132        <Filename Value="UTheme.pas"/>
     133        <HasRegisterProc Value="True"/>
     134        <UnitName Value="UTheme"/>
     135      </Item21>
    108136    </Files>
    109137    <i18n>
  • trunk/Packages/Common/Common.pas

    r1 r15  
    88
    99uses
    10   StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 
    11   UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 
    12   UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 
    13   UPersistentForm, UFindFile, UScaleDPI, LazarusPackageIntf;
     10  StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading,
     11  UMemory, UResetableThread, UPool, ULastOpenedList, URegistry,
     12  UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort,
     13  UPersistentForm, UFindFile, UScaleDPI, UTheme, LazarusPackageIntf;
    1414
    1515implementation
     
    2525  RegisterUnit('UFindFile', @UFindFile.Register);
    2626  RegisterUnit('UScaleDPI', @UScaleDPI.Register);
     27  RegisterUnit('UTheme', @UTheme.Register);
    2728end;
    2829
  • trunk/Packages/Common/UCommon.pas

    r1 r15  
    2828    unfDNSDomainName = 11);
    2929
     30  TFilterMethodMethod = function (FileName: string): Boolean of object;
    3031var
    3132  ExceptionHandler: TExceptionEvent;
     
    6364procedure OpenWebPage(URL: string);
    6465procedure OpenFileInShell(FileName: string);
    65 procedure ExecuteProgram(CommandLine: string);
     66procedure ExecuteProgram(Executable: string; Parameters: array of string);
    6667procedure FreeThenNil(var Obj);
    6768function RemoveQuotes(Text: string): string;
     
    7071function GetDirCount(Dir: string): Integer;
    7172function MergeArray(A, B: array of string): TArrayOfString;
     73function LoadFileToStr(const FileName: TFileName): AnsiString;
     74procedure SearchFiles(AList: TStrings; Dir: string;
     75  FilterMethod: TFilterMethodMethod);
    7276
    7377
     
    111115  Path := IncludeTrailingPathDelimiter(APath);
    112116
    113   Find := FindFirst(UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec);
     117  Find := FindFirst(Path + AFileSpec, faAnyFile xor faDirectory, SearchRec);
    114118  while Find = 0 do begin
    115     DeleteFile(Path + UTF8Encode(SearchRec.Name));
     119    DeleteFile(Path + SearchRec.Name);
    116120
    117121    Find := SysUtils.FindNext(SearchRec);
     
    428432end;
    429433
    430 procedure ExecuteProgram(CommandLine: string);
     434procedure ExecuteProgram(Executable: string; Parameters: array of string);
    431435var
    432436  Process: TProcess;
     437  I: Integer;
    433438begin
    434439  try
    435440    Process := TProcess.Create(nil);
    436     Process.CommandLine := CommandLine;
     441    Process.Executable := Executable;
     442    for I := 0 to Length(Parameters) - 1 do
     443      Process.Parameters.Add(Parameters[I]);
    437444    Process.Options := [poNoConsole];
    438445    Process.Execute;
     
    455462procedure OpenFileInShell(FileName: string);
    456463begin
    457   ExecuteProgram('cmd.exe /c start "' + FileName + '"');
     464  ExecuteProgram('cmd.exe', ['/c', 'start', FileName]);
    458465end;
    459466
     
    492499end;
    493500
     501function LoadFileToStr(const FileName: TFileName): AnsiString;
     502var
     503  FileStream: TFileStream;
     504  Read: Integer;
     505begin
     506  Result := '';
     507  FileStream := TFileStream.Create(FileName, fmOpenRead);
     508  try
     509    if FileStream.Size > 0 then begin
     510      SetLength(Result, FileStream.Size);
     511      Read := FileStream.Read(Pointer(Result)^, FileStream.Size);
     512      SetLength(Result, Read);
     513    end;
     514  finally
     515    FileStream.Free;
     516  end;
     517end;
     518
     519function DefaultSearchFilter(const FileName: string): Boolean;
     520begin
     521  Result := True;
     522end;
     523
     524procedure SearchFiles(AList: TStrings; Dir: string;
     525  FilterMethod: TFilterMethodMethod);
     526var
     527  SR: TSearchRec;
     528begin
     529  Dir := IncludeTrailingPathDelimiter(Dir);
     530  if FindFirst(Dir + '*', faAnyFile, SR) = 0 then
     531    try
     532      repeat
     533        if (SR.Name = '.') or (SR.Name = '..') or not FilterMethod(SR.Name) then Continue;
     534        AList.Add(Dir + SR.Name);
     535        if (SR.Attr and faDirectory) <> 0 then
     536          SearchFiles(AList, Dir + SR.Name, FilterMethod);
     537      until FindNext(SR) <> 0;
     538    finally
     539      FindClose(SR);
     540    end;
     541end;
    494542
    495543
  • trunk/Packages/Common/UListViewSort.pas

    r1 r15  
    8181    FOnChange: TNotifyEvent;
    8282    FStringGrid1: TStringGrid;
    83     procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    84     procedure DoOnResize(Sender: TObject);
     83    procedure GridDoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     84    procedure GridDoOnResize(Sender: TObject);
    8585  public
    8686    constructor Create(AOwner: TComponent); override;
     
    110110{ TListViewFilter }
    111111
    112 procedure TListViewFilter.DoOnKeyUp(Sender: TObject; var Key: Word;
     112procedure TListViewFilter.GridDoOnKeyUp(Sender: TObject; var Key: Word;
    113113  Shift: TShiftState);
    114114begin
     
    117117end;
    118118
    119 procedure TListViewFilter.DoOnResize(Sender: TObject);
     119procedure TListViewFilter.GridDoOnResize(Sender: TObject);
    120120begin
    121121  FStringGrid1.DefaultRowHeight := FStringGrid1.Height;
     
    135135  FStringGrid1.Options := [goFixedHorzLine, goFixedVertLine, goVertLine,
    136136    goHorzLine, goRangeSelect, goEditing, goAlwaysShowEditor, goSmoothScroll];
    137   FStringGrid1.OnKeyUp := DoOnKeyUp;
    138   FStringGrid1.OnResize := DoOnResize;
     137  FStringGrid1.OnKeyUp := GridDoOnKeyUp;
     138  FStringGrid1.OnResize := GridDoOnResize;
    139139end;
    140140
     
    144144begin
    145145  with FStringGrid1 do begin
     146    Options := Options - [goEditing, goAlwaysShowEditor];
    146147    //Columns.Clear;
    147148    while Columns.Count > ListView.Columns.Count do Columns.Delete(Columns.Count - 1);
     
    150151      Columns[I].Width := ListView.Columns[I].Width;
    151152    end;
     153    Options := Options + [goEditing, goAlwaysShowEditor];
    152154  end;
    153155end;
     
    197199  if AMsg.Msg = WM_NOTIFY then
    198200  begin
    199     Code := PHDNotify(vMsgNotify.NMHdr)^.Hdr.Code;
     201    Code := NMHDR(PHDNotify(vMsgNotify.NMHdr)^.Hdr).Code;
    200202    case Code of
    201203      HDN_ENDTRACKA, HDN_ENDTRACKW:
     
    353355  TP1: TPoint;
    354356  XBias, YBias: Integer;
    355   OldColor: TColor;
     357  PenColor: TColor;
     358  BrushColor: TColor;
    356359  BiasTop, BiasLeft: Integer;
    357360  Rect1: TRect;
     
    365368  Item.Left := 0;
    366369  GetCheckBias(XBias, YBias, BiasTop, BiasLeft, ListView);
    367   OldColor := ListView.Canvas.Pen.Color;
     370  PenColor := ListView.Canvas.Pen.Color;
     371  BrushColor := ListView.Canvas.Brush.Color;
    368372  //TP1 := Item.GetPosition;
    369373  lRect := Item.DisplayRect(drBounds); // Windows 7 workaround
     
    408412  end;
    409413  //ListView.Canvas.Brush.Color := ListView.Color;
    410   ListView.Canvas.Brush.Color := clWindow;
    411   ListView.Canvas.Pen.Color := OldColor;
     414  ListView.Canvas.Brush.Color := BrushColor;
     415  ListView.Canvas.Pen.Color := PenColor;
    412416end;
    413417
Note: See TracChangeset for help on using the changeset viewer.