ImageEn, unit ieview

TIEVButton


Declaration

TIEVButton = (iebtPrevious, iebtNext, iebtZoomIn, iebtZoomOut);


Description

Buttons that can be displayed when using ShowButtons:
Item Description Default Click Action
iebtPrevious Displays a left pointing chevron on the left side of the control Seek prior frame of the current multi-frame file (or navigate to the previous image if attached to a TImageEnMView)
iebtNext Displays a right pointing chevron on the right side of the control Seek next frame of the current multi-frame file (or navigate to the next image if attached to a TImageEnMView)
iebtZoomIn Displays outward pointing arrows at the bottom right of the control Zoom zoom into the image (make it fit to screen)
iebtZoomOut Displays inward pointing arrows at the bottom right of the control Zoom zoom out of the image (make it fit to screen)

Note:
iebtZoomIn and iebtZoomOut do not display at the same time. If both are specified, current zoom will determine which is shown
Use OnImageSeek to control image loading behavior




Demos

Demo  Demos\Multi\MViewPreview\MViewPreview.dpr
Demo  Demos\Multi\MView_AttachedViewer\MViewPreview.dpr
Demo  Demos\InputOutput\IEViewMulti\IEViewMulti.dpr


Examples

// EXAMPLE 1: Show either Zoom In or Zoom Out depending on which is most relevant
ImageEnView1.ShowButtons := [ iebtZoomIn, iebtZoomOut ];


// EXAMPLE 2: Using buttons to navigate images in a TImageEnMView

// Select event of our TImageEnMView
procedure TForm1.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
  ImageEnView1.LockUpdate();

    // Show either Zoom In or Zoom Out depending on which is most relevant
    ImageEnView1.ShowButtons := [ iebtZoomIn, iebtZoomOut ];

    // Have previous image?
    if ImageEnMView1.SelectedImage > 0 then
      ImageEnView1.ShowButtons := ImageEnView1.ShowButtons + [ iebtPrevious ];

    // Have next image?
    if ImageEnMView1.SelectedImage < ImageEnMView1.ImageCount - 1 then
      ImageEnView1.ShowButtons := ImageEnView1.ShowButtons + [ iebtNext ];

  // Load Image
  if ImageEnMView1.SelectedFilename <> '' then
    ImageEnView1.IO.LoadFromFile( ImageEnMView1.SelectedFilename )
  else
    ImageEnView1.Blank;
  ImageEnView1.Fit( False );

  ImageEnView1.UnlockUpdate();
end;

// Button Click event of our TImageEnView
procedure TForm1.ImageEnView1ButtonClick(Sender: TObject; Button: TIEVButton;
    MouseButton: TMouseButton; Shift: TShiftState; var Handled: Boolean);
begin
  case Button of
    iebtPrevious : begin
                     if ssShift in Shift then
                       ImageEnMView1.Seek( ieioSeekFirst )
                     else
                       ImageEnMView1.Seek( ieioSeekPrior );
                     ImageEnMView1ImageSelect(nil, 0); // Update preview and buttons
                   end;
    iebtNext     : begin
                     if ssShift in Shift then
                       ImageEnMView1.Seek( ieioSeekLast )
                     else
                       ImageEnMView1.Seek( ieioSeekNext );
                     ImageEnMView1ImageSelect(nil, 0); // Update preview and buttons
                   end;
    iebtZoomIn   : begin
                     if ImageEnView1.Zoom < ImageEnView1.GetIdealZoom() then
                       ImageEnView1.Zoom := ImageEnView1.GetIdealZoom()
                     else
                     if ImageEnView1.Zoom < 100 then
                       ImageEnView1.Zoom := 100;
                   end;
    iebtZoomOut  : begin
                     if ImageEnView1.Zoom > ImageEnView1.GetIdealZoom() then
                       ImageEnView1.Zoom := ImageEnView1.GetIdealZoom()
                     else
                     if ImageEnView1.Zoom > 100 then
                       ImageEnView1.Zoom := 100;
                   end;
  end;
end;


// EXAMPLE 3: Using buttons to navigate pages of a multi-frame image, such as TIFF or GIF

procedure TMainForm.btnLoadClick(Sender: TObject);
begin
  if OpenImageEnDialog1.Execute then
  begin
    ImageEnView1.IO.Params.ImageIndex := 0;
    ImageEnView1.IO.LoadFromFile( OpenImageEnDialog1.FileName );
    UpdateStatus();
  end;
end;

procedure TMainForm.UpdateStatus();
var
  havePrev, haveNext: Boolean;
begin
  ImageEnView1.ButtonParams.Color := clSilver;
  ImageEnView1.ButtonParams.Size  := 30;

  havePrev := ( ImageEnView1.IO.Params.Filename <> '' ) and ( ImageEnView1.IO.Params.ImageIndex > 0 );
  haveNext := ( ImageEnView1.IO.Params.Filename <> '' ) and ( ImageEnView1.IO.Params.ImageIndex < ImageEnView1.IO.Params.ImageCount - 1 );

  if havePrev and haveNext then
    ImageEnView1.ShowButtons := [ iebtPrevious, iebtNext ]
  else
  if havePrev then
    ImageEnView1.ShowButtons := [ iebtPrevious ]
  else
  if haveNext then
    ImageEnView1.ShowButtons := [ iebtNext ]
  else
    ImageEnView1.ShowButtons := [];
end;

procedure TMainForm.ImageEnView1ButtonClick(Sender: TObject; Button: TIEVButton;
    MouseButton: TMouseButton; Shift: TShiftState; var Handled: Boolean);
begin
  Handled := False; // Let ImageEnView handle the navigation and zooming
  UpdateStatus();
end;


See Also

ShowButtons
TIEButtonInteraction
OnButtonClick
OnButtonState