Changeset 109


Ignore:
Timestamp:
Jul 26, 2016, 11:22:43 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Update new packages files.
Location:
trunk/Packages
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UCommon.pas

    r43 r109  
    6464procedure ExecuteProgram(CommandLine: string);
    6565procedure FreeThenNil(var Obj);
     66function RemoveQuotes(Text: string): string;
    6667
    6768
     
    440441end;
    441442
     443function RemoveQuotes(Text: string): string;
     444begin
     445  Result := Text;
     446  if (Pos('"', Text) = 1) and (Text[Length(Text)] = '"') then
     447    Result := Copy(Text, 2, Length(Text) - 2);
     448end;
     449
     450
    442451initialization
    443452
  • trunk/Packages/Common/UFindFile.pas

    r43 r109  
    5555  end;
    5656
     57const
     58{$IFDEF WINDOWS}
     59  FilterAll = '*.*';
     60{$ENDIF}
     61{$IFDEF LINUX}
     62  FilterAll = '*';
     63{$ENDIF}
     64
    5765procedure Register;
    5866
     
    7179  inherited Create(AOwner);
    7280  Path := IncludeTrailingBackslash(UTF8Encode(GetCurrentDir));
    73   FileMask := '*.*';
     81  FileMask := FilterAll;
    7482  FileAttr := [ffaAnyFile];
    7583  s := TStringList.Create;
     
    127135  If not InSubFolders then Exit;
    128136
    129   if SysUtils.FindFirst(UTF8Decode(inPath + '*.*'), faDirectory, Rec) = 0 then
     137  if SysUtils.FindFirst(UTF8Decode(inPath + FilterAll), faDirectory, Rec) = 0 then
    130138  try
    131139    repeat
  • trunk/Packages/Common/UListViewSort.pas

    r43 r109  
    7373    procedure UpdateFromListView(ListView: TListView);
    7474    function TextEntered: Boolean;
     75    function TextEnteredColumn(Index: Integer): Boolean;
    7576    function GetColValue(Index: Integer): string;
    7677    property StringGrid: TStringGrid read FStringGrid1 write FStringGrid1;
     
    142143    end;
    143144  end;
     145end;
     146
     147function TListViewFilter.TextEnteredColumn(Index: Integer): Boolean;
     148begin
     149  Result := FStringGrid1.Cells[Index, 0] <> '';
    144150end;
    145151
  • trunk/Packages/Common/UPersistentForm.pas

    r43 r109  
    33{$mode delphi}
    44
    5 // Date: 2010-06-01
     5// Date: 2015-04-18
    66
    77interface
     
    2020    FRegistryContext: TRegistryContext;
    2121  public
     22    FormNormalSize: TRect;
     23    FormRestoredSize: TRect;
     24    FormWindowState: TWindowState;
     25    Form: TForm;
     26    procedure LoadFromRegistry(RegistryContext: TRegistryContext);
     27    procedure SaveToRegistry(RegistryContext: TRegistryContext);
    2228    function CheckEntireVisible(Rect: TRect): TRect;
    2329    function CheckPartVisible(Rect: TRect; Part: Integer): TRect;
     
    4450{ TPersistentForm }
    4551
     52procedure TPersistentForm.LoadFromRegistry(RegistryContext: TRegistryContext);
     53begin
     54  with TRegistryEx.Create do
     55  try
     56    RootKey := RegistryContext.RootKey;
     57    OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True);
     58    // Normal size
     59    FormNormalSize.Left := ReadIntegerWithDefault('NormalLeft', FormNormalSize.Left);
     60    FormNormalSize.Top := ReadIntegerWithDefault('NormalTop', FormNormalSize.Top);
     61    FormNormalSize.Right := ReadIntegerWithDefault('NormalWidth', FormNormalSize.Right - FormNormalSize.Left)
     62      + FormNormalSize.Left;
     63    FormNormalSize.Bottom := ReadIntegerWithDefault('NormalHeight', FormNormalSize.Bottom - FormNormalSize.Top)
     64      + FormNormalSize.Top;
     65    // Restored size
     66    FormRestoredSize.Left := ReadIntegerWithDefault('RestoredLeft', FormRestoredSize.Left);
     67    FormRestoredSize.Top := ReadIntegerWithDefault('RestoredTop', FormRestoredSize.Top);
     68    FormRestoredSize.Right := ReadIntegerWithDefault('RestoredWidth', FormRestoredSize.Right - FormRestoredSize.Left)
     69      + FormRestoredSize.Left;
     70    FormRestoredSize.Bottom := ReadIntegerWithDefault('RestoredHeight', FormRestoredSize.Bottom - FormRestoredSize.Top)
     71      + FormRestoredSize.Top;
     72    // Other state
     73    FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal)));
     74  finally
     75    Free;
     76  end;
     77end;
     78
     79procedure TPersistentForm.SaveToRegistry(RegistryContext: TRegistryContext);
     80begin
     81  with Form, TRegistryEx.Create do
     82  try
     83    RootKey := RegistryContext.RootKey;
     84    OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True);
     85    // Normal state
     86    WriteInteger('NormalWidth', FormNormalSize.Right - FormNormalSize.Left);
     87    WriteInteger('NormalHeight', FormNormalSize.Bottom - FormNormalSize.Top);
     88    WriteInteger('NormalTop', FormNormalSize.Top);
     89    WriteInteger('NormalLeft', FormNormalSize.Left);
     90    // Restored state
     91    WriteInteger('RestoredWidth', FormRestoredSize.Right - FormRestoredSize.Left);
     92    WriteInteger('RestoredHeight', FormRestoredSize.Bottom - FormRestoredSize.Top);
     93    WriteInteger('RestoredTop', FormRestoredSize.Top);
     94    WriteInteger('RestoredLeft', FormRestoredSize.Left);
     95    // Other state
     96    WriteInteger('WindowState', Integer(FormWindowState));
     97  finally
     98    Free;
     99  end;
     100end;
     101
    46102function TPersistentForm.CheckEntireVisible(Rect: TRect): TRect;
    47103var
     
    98154procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False);
    99155var
    100   Normal: TRect;
    101   Restored: TRect;
    102156  LoadDefaults: Boolean;
    103157begin
    104   with TRegistryEx.Create do
    105     try
    106       RootKey := RegistryContext.RootKey;
    107       OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True);
    108 
    109       //RestoredWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(Form.WindowState)));
    110       //if RestoredWindowState = wsMinimized then
    111       //  RestoredWindowState := wsNormal;
    112       //Form.WindowState := RestoredWindowState;
    113       LoadDefaults := not ValueExists('NormalLeft');
    114       Normal := Bounds(ReadIntegerWithDefault('NormalLeft', (Screen.Width - Form.Width) div 2),
    115         ReadIntegerWithDefault('NormalTop', (Screen.Height - Form.Height) div 2),
    116         ReadIntegerWithDefault('NormalWidth', Form.Width),
    117         ReadIntegerWithDefault('NormalHeight', Form.Height));
    118       Restored := Bounds(ReadIntegerWithDefault('RestoredLeft', (Screen.Width - Form.Width) div 2),
    119         ReadIntegerWithDefault('RestoredTop', (Screen.Height - Form.Height) div 2),
    120         ReadIntegerWithDefault('RestoredWidth', Form.Width),
    121         ReadIntegerWithDefault('RestoredHeight', Form.Height));
    122 
    123       if not EqualRect(Normal, Restored) or
    124         (LoadDefaults and DefaultMaximized) then begin
    125         // Restore to maximized state
    126         Form.WindowState := wsNormal;
    127         if not EqualRect(Restored, Form.BoundsRect) then
    128           Form.BoundsRect := Restored;
    129         Form.WindowState := wsMaximized;
    130       end else begin
    131         // Restore to normal state
    132         Form.WindowState := wsNormal;
    133         if FEntireVisible then Normal := CheckEntireVisible(Normal)
    134           else if FMinVisiblePart > 0 then
    135         Normal := CheckPartVisible(Normal, FMinVisiblePart);
    136         if not EqualRect(Normal, Form.BoundsRect) then
    137           Form.BoundsRect := Normal;
    138       end;
    139 
    140       //if ReadBoolWithDefault('Visible', False) then Form.Show;
    141     finally
    142       Free;
    143     end;
     158  Self.Form := Form;
     159  // Set default
     160  FormNormalSize := Bounds((Screen.Width - Form.Width) div 2,
     161    (Screen.Height - Form.Height) div 2, Form.Width, Form.Height);
     162  FormRestoredSize := Bounds((Screen.Width - Form.Width) div 2,
     163    (Screen.Height - Form.Height) div 2, Form.Width, Form.Height);
     164
     165  LoadFromRegistry(RegistryContext);
     166
     167  if not EqualRect(FormNormalSize, FormRestoredSize) or
     168    (LoadDefaults and DefaultMaximized) then begin
     169    // Restore to maximized state
     170    Form.WindowState := wsNormal;
     171    if not EqualRect(FormRestoredSize, Form.BoundsRect) then
     172      Form.BoundsRect := FormRestoredSize;
     173    Form.WindowState := wsMaximized;
     174  end else begin
     175    // Restore to normal state
     176    Form.WindowState := wsNormal;
     177    if FEntireVisible then FormNormalSize := CheckEntireVisible(FormNormalSize)
     178      else if FMinVisiblePart > 0 then
     179    FormNormalSize := CheckPartVisible(FormNormalSize, FMinVisiblePart);
     180    if not EqualRect(FormNormalSize, Form.BoundsRect) then
     181      Form.BoundsRect := FormNormalSize;
     182  end;
    144183end;
    145184
    146185procedure TPersistentForm.Save(Form: TForm);
    147186begin
    148   with Form, TRegistryEx.Create do
    149     try
    150       RootKey := RegistryContext.RootKey;
    151       OpenKey(RegistryContext.Key + '\Forms\' + Form.Name, True);
    152       WriteInteger('NormalWidth', Form.Width);
    153       WriteInteger('NormalHeight', Form.Height);
    154       WriteInteger('NormalTop', Form.Top);
    155       WriteInteger('NormalLeft', Form.Left);
    156       WriteInteger('RestoredWidth', Form.RestoredWidth);
    157       WriteInteger('RestoredHeight', Form.RestoredHeight);
    158       WriteInteger('RestoredTop', Form.RestoredTop);
    159       WriteInteger('RestoredLeft', Form.RestoredLeft);
    160       //WriteInteger('WindowState', Integer(Form.WindowState));
    161       //WriteBool('Visible', Form.Visible);
    162     finally
    163       Free;
    164     end;
     187  Self.Form := Form;
     188  FormNormalSize := Bounds(Form.Left, Form.Top, Form.Width, Form.Height);
     189  FormRestoredSize := Bounds(Form.RestoredLeft, Form.RestoredTop, Form.RestoredWidth,
     190    Form.RestoredHeight);
     191  FormWindowState := Form.WindowState;
     192  SaveToRegistry(RegistryContext);
    165193end;
    166194
     
    168196begin
    169197  inherited;
     198  if AOwner is TForm then Form := TForm(AOwner)
     199    else Form := nil;
    170200  FMinVisiblePart := 50;
    171201  FRegistryContext.RootKey := HKEY_CURRENT_USER;
  • trunk/Packages/Common/UXMLUtils.pas

    r64 r109  
    1212function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;
    1313procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer);
     14procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64);
    1415procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
    1516procedure WriteString(Node: TDOMNode; Name: string; Value: string);
     17procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime);
    1618function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
     19function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64;
    1720function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
    1821function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
     22function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime;
    1923
    2024
     
    7276  Minute: Integer;
    7377  Second: Integer;
     78  SecondFraction: Double;
    7479  Millisecond: Integer;
    7580begin
     
    9499      if Pos('Z', XMLDateTime) > 0 then
    95100        LeftCutString(XMLDateTime, Part, 'Z');
    96       Millisecond := StrToInt(Part);
     101      SecondFraction := StrToFloat('0' + DecimalSeparator + Part);
     102      Millisecond := Trunc(SecondFraction * 1000);
    97103    end else begin
    98104      if Pos('+', XMLDateTime) > 0 then
     
    138144end;
    139145
     146procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64);
     147var
     148  NewNode: TDOMNode;
     149begin
     150  NewNode := Node.OwnerDocument.CreateElement(Name);
     151  NewNode.TextContent := IntToStr(Value);
     152  Node.AppendChild(NewNode);
     153end;
     154
    140155procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
    141156var
     
    156171end;
    157172
     173procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime);
     174var
     175  NewNode: TDOMNode;
     176begin
     177  NewNode := Node.OwnerDocument.CreateElement(Name);
     178  NewNode.TextContent := DateTimeToXMLTime(Value);
     179  Node.AppendChild(NewNode);
     180end;
     181
    158182function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
    159183var
     
    166190end;
    167191
     192function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64;
     193var
     194  NewNode: TDOMNode;
     195begin
     196  Result := DefaultValue;
     197  NewNode := Node.FindNode(Name);
     198  if Assigned(NewNode) then
     199    Result := StrToInt64(NewNode.TextContent);
     200end;
     201
    168202function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
    169203var
     
    186220end;
    187221
     222function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime
     223  ): TDateTime;
     224var
     225  NewNode: TDOMNode;
     226begin
     227  Result := DefaultValue;
     228  NewNode := Node.FindNode(Name);
     229  if Assigned(NewNode) then
     230    Result := XMLTimeToDateTime(NewNode.TextContent);
     231end;
     232
    188233end.
    189234
  • trunk/Packages/TemplateGenerics/Generic/GenericMatrix.inc

    r57 r109  
    5050    function Implode(RowSeparator, ColSeparator: string; Converter: TToStringConverter): string;
    5151    procedure Explode(Text, Separator: string; Converter: TFromStringConverter; SlicesCount: Integer = -1);
    52     function IndexOf(Item: TGMatrixItem; Start: TIndex = 0): TIndex;
    53     function IndexOfList(List: TGMatrix; Start: TIndex = 0): TIndex;
     52    function IndexOf(Item: TGMatrixItem; Start: TIndex): TIndex;
     53    function IndexOfList(List: TGMatrix; Start: TIndex): TIndex;
    5454    procedure Insert(Index: TIndex; Item: TGMatrixItem);
    5555    procedure InsertList(Index: TIndex; List: TGMatrix);
Note: See TracChangeset for help on using the changeset viewer.