UnixDirViewColProperties.pas 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. unit UnixDirViewColProperties;
  2. interface
  3. uses
  4. Classes, ComCtrls, DirViewColProperties;
  5. resourcestring
  6. SUnixDirViewRightsCol = 'Rights';
  7. SUnixDirViewOwnerCol = 'Owner';
  8. SUnixDirViewGroupCol = 'Group';
  9. SUnixDirViewLinkTargetCol = 'Link target';
  10. SUnixDirViewTypeCol = 'Type';
  11. const
  12. UnixDirViewColumns = 9;
  13. DefaultUnixDirViewCaptions: array[0..UnixDirViewColumns-1] of Pointer =
  14. (@SDirViewNameCol, @SDirViewSizeCol, @SDirViewChangedCol2,
  15. @SUnixDirViewRightsCol, @SUnixDirViewOwnerCol, @SUnixDirViewGroupCol,
  16. @SDirViewExtCol, @SUnixDirViewLinkTargetCol, @SUnixDirViewTypeCol);
  17. DefaultUnixDirViewWidths: array[0..UnixDirViewColumns-1] of Integer =
  18. (150, 80, 130, 100, 130, 130, 0, 150, 125);
  19. DefaultUnixDirViewAlignments: array[0..UnixDirViewColumns-1] of TAlignment =
  20. (taLeftJustify, taRightJustify, taLeftJustify, taLeftJustify,
  21. taLeftJustify, taLeftJustify, taLeftJustify, taLeftJustify, taLeftJustify);
  22. DefaultUnixDirViewVisible: array[0..UnixDirViewColumns-1] of Boolean =
  23. (True, True, True, True, True, True, False, False, False);
  24. type
  25. TUnixDirViewCol = (uvName, uvSize, uvChanged, uvRights, uvOwner, uvGroup, uvExt,
  26. uvLinkTarget, uvType);
  27. TUnixDirViewColProperties = class(TCustomDirViewColProperties)
  28. private
  29. function StoreAlignment(Index: Integer): Boolean;
  30. function StoreCaption(Index: Integer): Boolean;
  31. function StoreWidth(Index: Integer): Boolean;
  32. function GetSortDirColumn: TUnixDirViewCol;
  33. procedure SetSortDirColumn(Value: TUnixDirViewCol);
  34. protected
  35. public
  36. constructor Create(DirView: TCustomListView);
  37. published
  38. property SortAscending;
  39. property SortDirColumn: TUnixDirViewCol read GetSortDirColumn write SetSortDirColumn default uvName;
  40. property NameCaption: string index uvName read GetCaptions write SetCaptions stored StoreCaption;
  41. property NameWidth: Integer index uvName read GetWidths write SetWidths stored StoreWidth;
  42. property NameVisible: Boolean index uvName read GetVisible write SetVisible default True;
  43. property NameAlignment: TAlignment index uvName read GetAlignments write SetAlignments stored StoreAlignment;
  44. property SizeCaption: string index uvSize read GetCaptions write SetCaptions stored StoreCaption;
  45. property SizeWidth: Integer index uvSize read GetWidths write SetWidths stored StoreWidth;
  46. property SizeVisible: Boolean index uvSize read GetVisible write SetVisible default True;
  47. property SizeAlignment: TAlignment index uvSize read GetAlignments write SetAlignments stored StoreAlignment;
  48. property ChangedCaption: string index uvChanged read GetCaptions write SetCaptions stored StoreCaption;
  49. property ChangedWidth: Integer index uvChanged read GetWidths write SetWidths stored StoreWidth;
  50. property ChangedVisible: Boolean index uvChanged read GetVisible write SetVisible default True;
  51. property ChangedAlignment: TAlignment index uvChanged read GetAlignments write SetAlignments stored StoreAlignment;
  52. property RightsCaption: string index uvRights read GetCaptions write SetCaptions stored StoreCaption;
  53. property RightsWidth: Integer index uvRights read GetWidths write SetWidths stored StoreWidth;
  54. property RightsVisible: Boolean index uvRights read GetVisible write SetVisible default True;
  55. property RightsAlignment: TAlignment index uvRights read GetAlignments write SetAlignments stored StoreAlignment;
  56. property OwnerCaption: string index uvOwner read GetCaptions write SetCaptions stored StoreCaption;
  57. property OwnerWidth: Integer index uvOwner read GetWidths write SetWidths stored StoreWidth;
  58. property OwnerVisible: Boolean index uvOwner read GetVisible write SetVisible default True;
  59. property OwnerAlignment: TAlignment index uvOwner read GetAlignments write SetAlignments stored StoreAlignment;
  60. property GroupCaption: string index uvGroup read GetCaptions write SetCaptions stored StoreCaption;
  61. property GroupWidth: Integer index uvGroup read GetWidths write SetWidths stored StoreWidth;
  62. property GroupVisible: Boolean index uvGroup read GetVisible write SetVisible default True;
  63. property GroupAlignment: TAlignment index uvGroup read GetAlignments write SetAlignments stored StoreAlignment;
  64. property ExtCaption: string index uvExt read GetCaptions write SetCaptions stored StoreCaption;
  65. property ExtWidth: Integer index uvExt read GetWidths write SetWidths stored StoreWidth;
  66. property ExtVisible: Boolean index uvExt read GetVisible write SetVisible default False;
  67. property ExtAlignment: TAlignment index uvExt read GetAlignments write SetAlignments stored StoreAlignment;
  68. property LinkTargetCaption: string index uvLinkTarget read GetCaptions write SetCaptions stored StoreCaption;
  69. property LinkTargetWidth: Integer index uvLinkTarget read GetWidths write SetWidths stored StoreWidth;
  70. property LinkTargetVisible: Boolean index uvLinkTarget read GetVisible write SetVisible default False;
  71. property LinkTargetAlignment: TAlignment index uvLinkTarget read GetAlignments write SetAlignments stored StoreAlignment;
  72. property TypeCaption: string index uvType read GetCaptions write SetCaptions stored StoreCaption;
  73. property TypeWidth: Integer index uvType read GetWidths write SetWidths stored StoreWidth;
  74. property TypeVisible: Boolean index uvType read GetVisible write SetVisible default True;
  75. property TypeAlignment: TAlignment index uvType read GetAlignments write SetAlignments stored StoreAlignment;
  76. end; { TUnixDirViewColProperties }
  77. implementation
  78. uses
  79. SysUtils;
  80. { TUnixDirViewColProperties }
  81. constructor TUnixDirViewColProperties.Create(DirView: TCustomListView);
  82. var
  83. Index: Integer;
  84. begin
  85. inherited Create(DirView, UnixDirViewColumns);
  86. for Index := 0 to Count-1 do
  87. begin
  88. Captions[Index] := LoadResString(DefaultUnixDirViewCaptions[Index]);
  89. Visible[Index] := DefaultUnixDirViewVisible[Index];
  90. Widths[Index] := DefaultUnixDirViewWidths[Index];
  91. Alignments[Index] := DefaultUnixDirViewAlignments[Index];
  92. end;
  93. end;
  94. procedure TUnixDirViewColProperties.SetSortDirColumn(Value: TUnixDirViewCol);
  95. begin
  96. SortColumn := Integer(Value);
  97. end;
  98. function TUnixDirViewColProperties.GetSortDirColumn: TUnixDirViewCol;
  99. begin
  100. Result := TUnixDirViewCol(SortColumn);
  101. end;
  102. function TUnixDirViewColProperties.StoreAlignment(Index: Integer): Boolean;
  103. begin
  104. Result := (Alignments[Index] <> DefaultUnixDirViewAlignments[Index]);
  105. end;
  106. function TUnixDirViewColProperties.StoreCaption(Index: Integer): Boolean;
  107. begin
  108. Result := (Captions[Index] <> LoadResString(DefaultUnixDirViewCaptions[Index]));
  109. end;
  110. function TUnixDirViewColProperties.StoreWidth(Index: Integer): Boolean;
  111. begin
  112. Result := (Widths[Index] <> DefaultUnixDirViewWidths[Index]);
  113. end;
  114. end.