Check-in [c4b41ad964]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enable changing order of renderers (changes are not stored yet).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | develop
Files: files | file ages | folders
SHA1:c4b41ad964eea7453d3022cbcbbaa9a200b5766d
User & Date: tinus 2015-02-17 16:32:02
Original Comment: Enable changing order of renderers (not stored yet).
Context
2015-02-18
14:20
Started on a hex viewer. check-in: c4b54c40b6 user: tinus tags: develop
2015-02-17
16:32
Enable changing order of renderers (changes are not stored yet). check-in: c4b41ad964 user: tinus tags: develop
16:31
Show file size and dates of file (and of eventual reparse point target). Keep showing the appropriate info windows when switching to 'stay on top' or to a different application. check-in: a21c185f65 user: tinus tags: develop
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ZPreview/src/Delphi/F_ManageEnginesAndRenderers.dfm.

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39

40


41
42
43
44
45
46
47



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
object frmManagePreviewEngines: TfrmManagePreviewEngines
  Left = 0
  Top = 0
  Caption = 'Manage Preview Engines and Renderers'
  ClientHeight = 453
  ClientWidth = 599
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter

  DesignSize = (
    599

    453)
  PixelsPerInch = 96
  TextHeight = 13
  object lvwRenderers: TListView
    Left = 8
    Top = 8
    Width = 502
    Height = 406
    Anchors = [akLeft, akTop, akRight, akBottom]
    Checkboxes = True
    Columns = <
      item
        Caption = 'Engine'
        Width = 100
      end
      item
        Caption = 'Renderer'
        Width = 100
      end
      item

        Caption = 'File(s)'
        Width = 100
      end>

    DoubleBuffered = True


    GroupHeaderImages = modMain.imlMain
    ReadOnly = True
    RowSelect = True
    ParentDoubleBuffered = False
    SmallImages = modMain.imlMain
    TabOrder = 0
    ViewStyle = vsReport



    ExplicitWidth = 321
    ExplicitHeight = 235
  end
  object btnOK: TButton
    Left = 435
    Top = 420
    Width = 75
    Height = 25
    Anchors = [akRight, akBottom]
    Caption = 'OK'
    Default = True
    ModalResult = 1
    TabOrder = 1
    ExplicitLeft = 254
    ExplicitTop = 249
  end
  object btnCancel: TButton
    Left = 516
    Top = 420
    Width = 75
    Height = 25
    Anchors = [akRight, akBottom]
    Cancel = True
    Caption = 'Cancel'
    ModalResult = 2
    TabOrder = 2
    ExplicitLeft = 335
    ExplicitTop = 249
  end
  object btnMoveUp: TButton
    Left = 516
    Top = 8
    Width = 75
    Height = 25
    Anchors = [akTop, akRight]
    Caption = 'Up'
    ImageIndex = 20
    Images = modMain.imlMain
    TabOrder = 3
    OnClick = btnMoveUpClick
    ExplicitLeft = 335
  end
  object btnMoveDown: TButton
    Left = 516
    Top = 39
    Width = 75
    Height = 25
    Anchors = [akTop, akRight]
    Caption = 'Down'
    ImageIndex = 21
    Images = modMain.imlMain
    TabOrder = 4
    OnClick = btnMoveDownClick
    ExplicitLeft = 335
  end
end





|








>

<
>






|













>
|
<

>

>
>







>
>
>
|
<


|








|
<


|








|
<


|









|


|









|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

56
57
58
59
60
61
62
63
64
65
66
67

68
69
70
71
72
73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
object frmManagePreviewEngines: TfrmManagePreviewEngines
  Left = 0
  Top = 0
  Caption = 'Manage Preview Engines and Renderers'
  ClientHeight = 453
  ClientWidth = 689
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  OnClose = FormClose
  DesignSize = (

    689
    453)
  PixelsPerInch = 96
  TextHeight = 13
  object lvwRenderers: TListView
    Left = 8
    Top = 8
    Width = 592
    Height = 406
    Anchors = [akLeft, akTop, akRight, akBottom]
    Checkboxes = True
    Columns = <
      item
        Caption = 'Engine'
        Width = 100
      end
      item
        Caption = 'Renderer'
        Width = 100
      end
      item
        AutoSize = True
        Caption = 'File type(s)'

      end>
    ColumnClick = False
    DoubleBuffered = True
    DragMode = dmAutomatic
    MultiSelect = True
    GroupHeaderImages = modMain.imlMain
    ReadOnly = True
    RowSelect = True
    ParentDoubleBuffered = False
    SmallImages = modMain.imlMain
    TabOrder = 0
    ViewStyle = vsReport
    OnDragDrop = lvwRenderersDragDrop
    OnDragOver = lvwRenderersDragOver
    OnItemChecked = lvwRenderersItemChecked
    ExplicitWidth = 502

  end
  object btnOK: TButton
    Left = 525
    Top = 420
    Width = 75
    Height = 25
    Anchors = [akRight, akBottom]
    Caption = 'OK'
    Default = True
    ModalResult = 1
    TabOrder = 1
    ExplicitLeft = 435

  end
  object btnCancel: TButton
    Left = 606
    Top = 420
    Width = 75
    Height = 25
    Anchors = [akRight, akBottom]
    Cancel = True
    Caption = 'Cancel'
    ModalResult = 2
    TabOrder = 2
    ExplicitLeft = 516

  end
  object btnMoveUp: TButton
    Left = 606
    Top = 8
    Width = 75
    Height = 25
    Anchors = [akTop, akRight]
    Caption = 'Up'
    ImageIndex = 20
    Images = modMain.imlMain
    TabOrder = 3
    OnClick = btnMoveUpClick
    ExplicitLeft = 516
  end
  object btnMoveDown: TButton
    Left = 606
    Top = 39
    Width = 75
    Height = 25
    Anchors = [akTop, akRight]
    Caption = 'Down'
    ImageIndex = 21
    Images = modMain.imlMain
    TabOrder = 4
    OnClick = btnMoveDownClick
    ExplicitLeft = 516
  end
end

Changes to ZPreview/src/Delphi/F_ManageEnginesAndRenderers.pas.

14
15
16
17
18
19
20





21
22
23
24
25
26
27
..
33
34
35
36
37
38
39







40
41
42
43
44
45
46
..
54
55
56
57
58
59
60
61
62
63

64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84



































85
86

87
88
89
90

91
92

93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
114
115





















116


117
118






119









120







121
    lvwRenderers: TListView;
    btnOK: TButton;
    btnCancel: TButton;
    btnMoveUp: TButton;
    btnMoveDown: TButton;
    procedure btnMoveUpClick(Sender: TObject);
    procedure btnMoveDownClick(Sender: TObject);





  private
    { Private declarations }
    FEngineMgr: TPreviewEngineUIManager;
  public
    { Public declarations }
    procedure Populate(const EngineMgr: TPreviewEngineUIManager);
  end;
................................................................................
uses
  M_Main;

{$R *.dfm}

{ ================================================================================================ }
{ TfrmManagePreviewEngines }








{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.Populate(const EngineMgr: TPreviewEngineUIManager);
var
  EngineForm: TCustomPreviewEngineForm;
  Group: TListGroup;
  Renderer: TRenderer;
................................................................................
    lvwRenderers.Items.Clear;
    lvwRenderers.Groups.Clear;

    for EngineForm in EngineMgr.Engines do begin
      Group := lvwRenderers.Groups.Add;
      Group.Header := EngineForm.Caption;
      Group.TitleImage := EngineForm.ImageIndex;
      Group.State := [lgsCollapsible];
      for Renderer in EngineForm.Renderers do begin
        Item := lvwRenderers.Items.Add;

        Item.Data := Renderer;
        Item.Caption := EngineForm.Caption;
        Item.ImageIndex := EngineForm.ImageIndex;
        Item.Checked := EngineForm.Enabled;
        Item.SubItems.Add(Renderer.DisplayName);

        Item.SubItems.Add(''); // TODO
      end;
    end;
    for Column in lvwRenderers.Columns do
      TListColumn(Column).Width := -2;
  finally
    lvwRenderers.Items.EndUpdate;
  end;
end {TfrmManagePreviewEngines.Populate};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.btnMoveUpClick(Sender: TObject);
var
  NewItem: TListItem;
begin
  if not Assigned(lvwRenderers.Selected) then



































    Exit;
  if lvwRenderers.Selected.Index > 0 then begin

    lvwRenderers.Items.BeginUpdate;
    try
      NewItem := lvwRenderers.Items.Insert(lvwRenderers.Selected.Index - 1);
      NewItem.Assign(lvwRenderers.Selected);

      lvwRenderers.Selected.Delete;
      lvwRenderers.ItemIndex := NewItem.Index;

    finally
      lvwRenderers.Items.EndUpdate;
    end;
  end;
end {TfrmManagePreviewEngines.btnMoveUpClick};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.btnMoveDownClick(Sender: TObject);
var
  NewItem: TListItem;
begin
  if not Assigned(lvwRenderers.Selected) then
    Exit;
  if lvwRenderers.Selected.Index < lvwRenderers.Items.Count - 1 then begin

    lvwRenderers.Items.BeginUpdate;
    try
      NewItem := lvwRenderers.Items.Insert(lvwRenderers.Selected.Index + 2);
      NewItem.Assign(lvwRenderers.Selected);
      lvwRenderers.Selected.Delete;
      lvwRenderers.ItemIndex := NewItem.Index;
    finally
      lvwRenderers.Items.EndUpdate;
    end;





















  end;


end {TfrmManagePreviewEngines.btnMoveDownClick};

























end.







>
>
>
>
>







 







>
>
>
>
>
>
>







 







|


>





>
|










|



|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

<
>
|
|
<
<
>
|
|
>
|
|
<






|

|

<
>
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
|

>
>
>
>
>
>

>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134

135
136
137


138
139
140
141
142
143

144
145
146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
    lvwRenderers: TListView;
    btnOK: TButton;
    btnCancel: TButton;
    btnMoveUp: TButton;
    btnMoveDown: TButton;
    procedure btnMoveUpClick(Sender: TObject);
    procedure btnMoveDownClick(Sender: TObject);
    procedure lvwRenderersDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure lvwRenderersDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure lvwRenderersItemChecked(Sender: TObject; Item: TListItem);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    FEngineMgr: TPreviewEngineUIManager;
  public
    { Public declarations }
    procedure Populate(const EngineMgr: TPreviewEngineUIManager);
  end;
................................................................................
uses
  M_Main;

{$R *.dfm}

{ ================================================================================================ }
{ TfrmManagePreviewEngines }

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caHide;
end {TfrmManagePreviewEngines.FormClose};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.Populate(const EngineMgr: TPreviewEngineUIManager);
var
  EngineForm: TCustomPreviewEngineForm;
  Group: TListGroup;
  Renderer: TRenderer;
................................................................................
    lvwRenderers.Items.Clear;
    lvwRenderers.Groups.Clear;

    for EngineForm in EngineMgr.Engines do begin
      Group := lvwRenderers.Groups.Add;
      Group.Header := EngineForm.Caption;
      Group.TitleImage := EngineForm.ImageIndex;
      Group.State := [lgsNormal, lgsCollapsible];
      for Renderer in EngineForm.Renderers do begin
        Item := lvwRenderers.Items.Add;
        Item.GroupID := Group.GroupID;
        Item.Data := Renderer;
        Item.Caption := EngineForm.Caption;
        Item.ImageIndex := EngineForm.ImageIndex;
        Item.Checked := EngineForm.Enabled;
        Item.SubItems.Add(Renderer.DisplayName);
        {$MESSAGE HINT 'TODO: show the custom assigned file extensions here  MCO 17-02-2015'}
        Item.SubItems.Add('');
      end;
    end;
    for Column in lvwRenderers.Columns do
      TListColumn(Column).Width := -2;
  finally
    lvwRenderers.Items.EndUpdate;
  end;
end {TfrmManagePreviewEngines.Populate};

{ ------------------------------------------------------------------------------------------------ }
procedure MoveItemTo(var Item: TListItem; const NewIndex: integer; const Select: boolean);
var
  NewItem: TListItem;
begin
  NewItem := Item.ListView.Items.Insert(NewIndex);
  NewItem.Assign(Item);
  NewItem.Selected := True;
  Item.Delete;
  Item := NewItem;
  if Select then
    Item.ListView.ItemIndex := Item.Index;
end {MoveItemTo};

{ ------------------------------------------------------------------------------------------------ }
function MoveItemBy(Item: TListItem; const Positions: integer; const Select: boolean): TListItem;
var
  NewIndex: integer;
begin
  if Item = nil then
    Exit(Item);
  NewIndex := Item.Index + Positions;
  if NewIndex < 0 then begin
    NewIndex := 0;
  end else if NewIndex > Item.ListView.Items.Count - 1 then begin
    NewIndex := Item.ListView.Items.Count - 1;
  end else if Positions > 0 then begin
    Inc(NewIndex);
  end;
  if NewIndex = Item.Index then
    Exit(Item);
  MoveItemTo(Item, NewIndex, Select);
  Result := Item;
end {MoveItemBy};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.btnMoveUpClick(Sender: TObject);
var
  i: Integer;
begin
  if (lvwRenderers.Items.Count <= 0) or (lvwRenderers.Items[0].Selected) then
    Exit;


  lvwRenderers.Items.BeginUpdate;
  try


    for i := 0 to lvwRenderers.Items.Count - 1 do begin
      if lvwRenderers.Items[i].Selected then
        MoveItemBy(lvwRenderers.Items[i], -1, False);
    end;
  finally
    lvwRenderers.Items.EndUpdate;

  end;
end {TfrmManagePreviewEngines.btnMoveUpClick};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.btnMoveDownClick(Sender: TObject);
var
  i: Integer;
begin
  if (lvwRenderers.Items.Count <= 0) or (lvwRenderers.Items[lvwRenderers.Items.Count - 1].Selected) then
    Exit;


  lvwRenderers.Items.BeginUpdate;
  try
    for i := lvwRenderers.Items.Count - 1 downto 0 do begin
      if lvwRenderers.Items[i].Selected then
        MoveItemBy(lvwRenderers.Items[i], +1, False);
    end;
  finally
    lvwRenderers.Items.EndUpdate;
  end;
end {TfrmManagePreviewEngines.btnMoveDownClick};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.lvwRenderersDragDrop(Sender, Source: TObject;
  X, Y: Integer);
var
  DragItem, DropItem, CurrentItem, NextItem: TListItem;
begin
  if Sender = Source then begin
    with TListView(Sender) do begin
      DropItem    := GetItemAt(X, Y);
      CurrentItem := Selected;
      while CurrentItem <> nil do begin
        NextItem := GetNextItem(CurrentItem, SdAll, [IsSelected]);
        if DropItem = nil then
          DragItem := Items.Add
        else
          DragItem := Items.Insert(DropItem.Index);
        DragItem.Assign(CurrentItem);
        CurrentItem.Free;
        CurrentItem := NextItem;
      end;
    end;
  end;
end {TfrmManagePreviewEngines.lvwRenderersDragDrop};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.lvwRenderersDragOver(Sender, Source: TObject;
  X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
  Accept := (Sender = Source);
end {TfrmManagePreviewEngines.lvwRenderersDragOver};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmManagePreviewEngines.lvwRenderersItemChecked(Sender: TObject;
  Item: TListItem);
var
  Engine: TCustomPreviewEngineForm;
  li: TListItem;
begin
  if Item.Data = nil then
    Exit;

  Engine := TRenderer(Item.Data).Form;
  for li in Item.ListView.Items do begin
    if (li <> Item) and (TRenderer(li.Data).Form = Engine) then
      li.Checked := Item.Checked;
  end;
end {TfrmManagePreviewEngines.lvwRenderersItemChecked};

end.