1
0

UnixDirViewColProperties.pas 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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, @SDirViewChangedCol,
  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 MaxWidth;
  39. property MinWidth;
  40. property SortAscending;
  41. property SortDirColumn: TUnixDirViewCol read GetSortDirColumn write SetSortDirColumn default uvName;
  42. property NameCaption: string index uvName read GetCaptions write SetCaptions stored StoreCaption;
  43. property NameWidth: Integer index uvName read GetWidths write SetWidths stored StoreWidth;
  44. property NameVisible: Boolean index uvName read GetVisible write SetVisible default True;
  45. property NameAlignment: TAlignment index uvName read GetAlignments write SetAlignments stored StoreAlignment;
  46. property SizeCaption: string index uvSize read GetCaptions write SetCaptions stored StoreCaption;
  47. property SizeWidth: Integer index uvSize read GetWidths write SetWidths stored StoreWidth;
  48. property SizeVisible: Boolean index uvSize read GetVisible write SetVisible default True;
  49. property SizeAlignment: TAlignment index uvSize read GetAlignments write SetAlignments stored StoreAlignment;
  50. property ChangedCaption: string index uvChanged read GetCaptions write SetCaptions stored StoreCaption;
  51. property ChangedWidth: Integer index uvChanged read GetWidths write SetWidths stored StoreWidth;
  52. property ChangedVisible: Boolean index uvChanged read GetVisible write SetVisible default True;
  53. property ChangedAlignment: TAlignment index uvChanged read GetAlignments write SetAlignments stored StoreAlignment;
  54. property RightsCaption: string index uvRights read GetCaptions write SetCaptions stored StoreCaption;
  55. property RightsWidth: Integer index uvRights read GetWidths write SetWidths stored StoreWidth;
  56. property RightsVisible: Boolean index uvRights read GetVisible write SetVisible default True;
  57. property RightsAlignment: TAlignment index uvRights read GetAlignments write SetAlignments stored StoreAlignment;
  58. property OwnerCaption: string index uvOwner read GetCaptions write SetCaptions stored StoreCaption;
  59. property OwnerWidth: Integer index uvOwner read GetWidths write SetWidths stored StoreWidth;
  60. property OwnerVisible: Boolean index uvOwner read GetVisible write SetVisible default True;
  61. property OwnerAlignment: TAlignment index uvOwner read GetAlignments write SetAlignments stored StoreAlignment;
  62. property GroupCaption: string index uvGroup read GetCaptions write SetCaptions stored StoreCaption;
  63. property GroupWidth: Integer index uvGroup read GetWidths write SetWidths stored StoreWidth;
  64. property GroupVisible: Boolean index uvGroup read GetVisible write SetVisible default True;
  65. property GroupAlignment: TAlignment index uvGroup read GetAlignments write SetAlignments stored StoreAlignment;
  66. property ExtCaption: string index uvExt read GetCaptions write SetCaptions stored StoreCaption;
  67. property ExtWidth: Integer index uvExt read GetWidths write SetWidths stored StoreWidth;
  68. property ExtVisible: Boolean index uvExt read GetVisible write SetVisible default False;
  69. property ExtAlignment: TAlignment index uvExt read GetAlignments write SetAlignments stored StoreAlignment;
  70. property LinkTargetCaption: string index uvLinkTarget read GetCaptions write SetCaptions stored StoreCaption;
  71. property LinkTargetWidth: Integer index uvLinkTarget read GetWidths write SetWidths stored StoreWidth;
  72. property LinkTargetVisible: Boolean index uvLinkTarget read GetVisible write SetVisible default False;
  73. property LinkTargetAlignment: TAlignment index uvLinkTarget read GetAlignments write SetAlignments stored StoreAlignment;
  74. property TypeCaption: string index uvType read GetCaptions write SetCaptions stored StoreCaption;
  75. property TypeWidth: Integer index uvType read GetWidths write SetWidths stored StoreWidth;
  76. property TypeVisible: Boolean index uvType read GetVisible write SetVisible default True;
  77. property TypeAlignment: TAlignment index uvType read GetAlignments write SetAlignments stored StoreAlignment;
  78. end; { TDirViewColProperties }
  79. implementation
  80. uses
  81. SysUtils;
  82. { TUnixDirViewColProperties }
  83. constructor TUnixDirViewColProperties.Create(DirView: TCustomListView);
  84. var
  85. Index: Integer;
  86. begin
  87. inherited Create(DirView, UnixDirViewColumns);
  88. for Index := 0 to Count-1 do
  89. begin
  90. Captions[Index] := LoadResString(DefaultUnixDirViewCaptions[Index]);
  91. Visible[Index] := DefaultUnixDirViewVisible[Index];
  92. Widths[Index] := DefaultUnixDirViewWidths[Index];
  93. Alignments[Index] := DefaultUnixDirViewAlignments[Index];
  94. end;
  95. end;
  96. procedure TUnixDirViewColProperties.SetSortDirColumn(Value: TUnixDirViewCol);
  97. begin
  98. SortColumn := Integer(Value);
  99. end;
  100. function TUnixDirViewColProperties.GetSortDirColumn: TUnixDirViewCol;
  101. begin
  102. Result := TUnixDirViewCol(SortColumn);
  103. end;
  104. function TUnixDirViewColProperties.StoreAlignment(Index: Integer): Boolean;
  105. begin
  106. Result := (Alignments[Index] <> DefaultUnixDirViewAlignments[Index]);
  107. end;
  108. function TUnixDirViewColProperties.StoreCaption(Index: Integer): Boolean;
  109. begin
  110. Result := (Captions[Index] <> LoadResString(DefaultUnixDirViewCaptions[Index]));
  111. end;
  112. function TUnixDirViewColProperties.StoreWidth(Index: Integer): Boolean;
  113. begin
  114. Result := (Widths[Index] <> DefaultUnixDirViewWidths[Index]);
  115. end;
  116. end.