Check-in [cb7edf9d28]
Not logged in

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

Overview
Comment:Moved handling of ZTreeWin shortcut keys to preview engine manager. Also process Ctrl+Shift+Alt shortcuts.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | develop
Files: files | file ages | folders
SHA1:cb7edf9d281156bc52c9acc2724140d812b5936d
User & Date: Martijn 2015-03-19 20:20:52
Context
2015-07-13
12:15
Added new project 'ZTMsToHst', which copies all `*.ztm` files present in the `#ZTHome` directory, as entries in ZTW.HST for the `F12` macro entry history list. check-in: cf608713de user: tinus tags: develop
2015-03-19
20:20
Moved handling of ZTreeWin shortcut keys to preview engine manager. Also process Ctrl+Shift+Alt shortcuts. check-in: cb7edf9d28 user: Martijn tags: develop
2015-03-09
12:35
When showing a different file, first try the current renderer -- unless the current renderer is capable of showing any file (because that would mean we would always see that renderer). check-in: 0a0d004876 user: Martijn tags: develop
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    TabOrder = 1
    Visible = False
    OnDblClick = pnlErrorDblClick
    object lblError: TLabel
      AlignWithMargins = True
      Left = 4
      Top = 4
      Width = 808
      Height = 33
      Align = alClient
      Alignment = taCenter
      ShowAccelChar = False
      WordWrap = True
      ExplicitWidth = 3
      ExplicitHeight = 13
    end
  end
  object acttbMain: TActionToolBar
    Left = 0
    Top = 0
    Width = 816
    Height = 26







|
|




<
<







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


53
54
55
56
57
58
59
    TabOrder = 1
    Visible = False
    OnDblClick = pnlErrorDblClick
    object lblError: TLabel
      AlignWithMargins = True
      Left = 4
      Top = 4
      Width = 3
      Height = 13
      Align = alClient
      Alignment = taCenter
      ShowAccelChar = False
      WordWrap = True


    end
  end
  object acttbMain: TActionToolBar
    Left = 0
    Top = 0
    Width = 816
    Height = 26

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

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
...
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423



424
425
426
427
428
429
430
  frmInfoSentinel.Visible := actViewSentinel.Checked;
  if frmInfoSentinel.Visible and Assigned(FSentinel) then
    frmInfoSentinel.Populate(FSentinel);
end {TfrmMain.actViewSentinelExecute};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.actViewTopmostExecute(Sender: TObject);
var
  i: integer;
begin
  if actViewTopmost.Checked then begin
    Self.FormStyle := fsStayOnTop;
    ApplicationDeactivate(Application);
  end else begin
    Self.FormStyle := fsNormal;
  end;
................................................................................
end {TfrmMain.actPreviewEngineExecute};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.ProcessPamphlet;
var
  Buffer: array[0..1023] of Char;
  BufferSize: integer;
  i: Integer;
  Shortcut: TShortcut;
begin
  Caption := FSentinel.ThisPath + ' - ' + Application.Title;

  Screen.Cursor := crHourGlass;
  try
    Application.ProcessMessages;

................................................................................
            Close;
          end;
          'R': begin
            FSentinel.Reset;
            FInitialized := False;
          end;
          else begin
            Shortcut := scCtrl or scShift or Ord(FSentinel.Pamphlet.CommandChar);
            for i := 0 to ActionManager.ActionCount - 1 do begin
              OutputDebugString(PChar(Format('%s %d', [ActionManager.Actions[i].Name, ActionManager.Actions[i].ShortCut and not (scCtrl or scShift)])));
              if (ActionManager.Actions[i].ShortCut = Shortcut) or (ActionManager.Actions[i].SecondaryShortCuts.IndexOfShortCut(Shortcut) > -1) then begin
                ActionManager.Actions[i].Execute;
                // DIRTY HACK: a HelpContext of -1 means we shouldn't process the pamphlet after having processed this action
//                if ActionManager.Actions[i].HelpContext = -1 then
                  Exit
//                else
//                  Break;
              end;
            end {for};
          end {else};
        end {case CommandChar};



      end {if};
    end {if};

    tbcPreview.Tabs[tbcPreview.TabIndex] := ExtractFileName(FSentinel.ThisPath);

    pnlError.Hide;
    try







<
<







 







<
<







 







|
<
<
<
<
<
<
|
<
<
<
<


>
>
>







277
278
279
280
281
282
283


284
285
286
287
288
289
290
...
375
376
377
378
379
380
381


382
383
384
385
386
387
388
...
399
400
401
402
403
404
405
406






407




408
409
410
411
412
413
414
415
416
417
418
419
  frmInfoSentinel.Visible := actViewSentinel.Checked;
  if frmInfoSentinel.Visible and Assigned(FSentinel) then
    frmInfoSentinel.Populate(FSentinel);
end {TfrmMain.actViewSentinelExecute};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.actViewTopmostExecute(Sender: TObject);


begin
  if actViewTopmost.Checked then begin
    Self.FormStyle := fsStayOnTop;
    ApplicationDeactivate(Application);
  end else begin
    Self.FormStyle := fsNormal;
  end;
................................................................................
end {TfrmMain.actPreviewEngineExecute};

{ ------------------------------------------------------------------------------------------------ }
procedure TfrmMain.ProcessPamphlet;
var
  Buffer: array[0..1023] of Char;
  BufferSize: integer;


begin
  Caption := FSentinel.ThisPath + ' - ' + Application.Title;

  Screen.Cursor := crHourGlass;
  try
    Application.ProcessMessages;

................................................................................
            Close;
          end;
          'R': begin
            FSentinel.Reset;
            FInitialized := False;
          end;
          else begin
            if FEngineManager.ProcessShortcut(Char(FSentinel.Pamphlet.CommandChar), [ssShift, ssCtrl]) then






              Exit;




          end {else};
        end {case CommandChar};
      end else if FSentinel.Pamphlet.Command = '~' then begin
        if FEngineManager.ProcessShortcut(Char(FSentinel.Pamphlet.CommandChar), [ssShift, ssCtrl, ssAlt]) then
          Exit;
      end {if};
    end {if};

    tbcPreview.Tabs[tbcPreview.TabIndex] := ExtractFileName(FSentinel.ThisPath);

    pnlError.Hide;
    try

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

43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
...
244
245
246
247
248
249
250

251
252
253
254
255
256
257
...
300
301
302
303
304
305
306






















307
308
309
310
311
312
313
    procedure DoRendererSelected;
  public
    constructor Create(const ActionManager: TActionManager;
                       const PreviewContainer: TWinControl;
                       const ActionPreviewEngine: TAction);
    destructor  Destroy; override;

    function ShowFile(const FileName: string): TRenderer;
    function NextRenderer: TRenderer;


    property ActionManager: TActionManager    read FActionMgr;
    property Container: TWinControl           read FContainer;
    property Engines: TEngineList             read FEngineForms;

    property Filename: string                 read FFileName;
    property SelectedRenderer: TRenderer      read FSelectedRenderer;
................................................................................

    Result := nil;
    for Form in FEngineForms do begin
      {$MESSAGE WARN 'TODO: improve error handling'}
      if (Result = nil) and Form.Enabled and Form.TryShowFile(Filename, Result) then begin
        Form.Show;
        SetSelectedRenderer(Result);

      end;
    end {for};
  end;

  // Only hide the forms after we've found a good one, to prevent unnecessary flickering
  for Form in FEngineForms do begin
    if (Result = nil) or (Form <> Result.Form) then begin
................................................................................
      SelectedForm.Hide;
      SelectedForm.Clear;
    end;
  end else begin
    Result := ShowFile(FFileName);
  end;
end {TPreviewEngineUIManager.NextRenderer};























{ ------------------------------------------------------------------------------------------------ }
procedure TPreviewEngineUIManager.CreateRendererSelector(const Renderer: TRenderer;
                                                         const ParentItem: TActionClientItem);
var
  actSelectRenderer: TAction;
begin







|
|
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
    procedure DoRendererSelected;
  public
    constructor Create(const ActionManager: TActionManager;
                       const PreviewContainer: TWinControl;
                       const ActionPreviewEngine: TAction);
    destructor  Destroy; override;

    function  ShowFile(const FileName: string): TRenderer;
    function  NextRenderer: TRenderer;
    function  ProcessShortcut(const Key: Char; const Shift: TShiftState): boolean;

    property ActionManager: TActionManager    read FActionMgr;
    property Container: TWinControl           read FContainer;
    property Engines: TEngineList             read FEngineForms;

    property Filename: string                 read FFileName;
    property SelectedRenderer: TRenderer      read FSelectedRenderer;
................................................................................

    Result := nil;
    for Form in FEngineForms do begin
      {$MESSAGE WARN 'TODO: improve error handling'}
      if (Result = nil) and Form.Enabled and Form.TryShowFile(Filename, Result) then begin
        Form.Show;
        SetSelectedRenderer(Result);
        Break;
      end;
    end {for};
  end;

  // Only hide the forms after we've found a good one, to prevent unnecessary flickering
  for Form in FEngineForms do begin
    if (Result = nil) or (Form <> Result.Form) then begin
................................................................................
      SelectedForm.Hide;
      SelectedForm.Clear;
    end;
  end else begin
    Result := ShowFile(FFileName);
  end;
end {TPreviewEngineUIManager.NextRenderer};

{ ------------------------------------------------------------------------------------------------ }
function TPreviewEngineUIManager.ProcessShortcut(const Key: Char; const Shift: TShiftState): boolean;
var
  Shortcut: TShortcut;
  i: integer;
begin
  Result := False;

  Shortcut := Ord(Key);
  if ssShift in Shift then  Shortcut := Shortcut or scShift;
  if ssCtrl in Shift then   Shortcut := Shortcut or scCtrl;
  if ssAlt in Shift then    Shortcut := Shortcut or scAlt;

  for i := 0 to ActionManager.ActionCount - 1 do begin
    OutputDebugString(PChar(Format('%s %d', [ActionManager.Actions[i].Name, ActionManager.Actions[i].ShortCut and not (scShift or scCtrl or scAlt)])));
    if (ActionManager.Actions[i].ShortCut = Shortcut) or (ActionManager.Actions[i].SecondaryShortCuts.IndexOfShortCut(Shortcut) > -1) then begin
      ActionManager.Actions[i].Execute;
      Exit(True);
    end;
  end {for};
end {TPreviewEngineUIManager.ProcessShortcut};

{ ------------------------------------------------------------------------------------------------ }
procedure TPreviewEngineUIManager.CreateRendererSelector(const Renderer: TRenderer;
                                                         const ParentItem: TActionClientItem);
var
  actSelectRenderer: TAction;
begin