ImageEn, unit imageenview

TImageEnView.ShowButtons

TImageEnView.ShowButtons


Declaration

property ShowButtons: TIEVButtons;


Description

Display Previous and/or Next buttons on the sides of the control (white chevrons).
Hovering over the left/right of the image will show a hint. Clicking will call OnButtonClick or perform a standard function.
You can specify the button color and size using ButtonParams.



Note:
The hover/clickable button area is the full height of the control, but the width of the button and offset
Use OnButtonState to specify an enabled/disabled state
You can use OnButtonClick to handle the click. If OnButtonClick is not specified, a default action will occur depending on the button type
To show buttons only when hovering over the click area, enable ImageEnView1.ButtonParams.OnlyOnHover
Hover hints can be disabled using EnableInteractionHints
iebtZoomIn and iebtZoomOut do not display at the same time. If both are specified, current zoom will determine which is shown
Before loading a new image, the OnBeforeLoadImage event will fire
If a new image is loaded due to a button click, the OnImageLoaded event will fire
Buttons will show automatically for the PdfViewer if iepoAutoButtons is specified for Options (enabled by default)

Default: [] (No buttons)


Available Buttons

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)
iebtMultiZoom Displays a zoom icon at the top right of the control. Clicking with the left key will zoom into the image, the right key zooms out and Ctrl + click toggles zooming to fit Zoom the image
iebtZoomIn Displays outward pointing arrows at the bottom right of the control Zoom into the image (make image fit to screen or show 100% whichever is larger)
iebtZoomOut Displays inward pointing arrows at the bottom right of the control Zoom out of the image (make it fit to screen or show 100% whichever is smaller)


Keyboard Shortcuts

If vkiScrollView is enabled, the following shortcuts are supported:
Shortcut Description
PageUp Same effect as clicking iebtPrevious
PageDown Same effect as clicking iebtNext
Home Same effect as clicking iebtPrevious holding the Shift key
End Same effect as clicking iebtNext holding the Shift key


Demos

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


Examples

// EXAMPLE 1: Show a multi-functional zoom icon
ImageEnView1.ShowButtons := [ iebtMultiZoom ];


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


// EXAMPLE 3: 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;
    iebtMultiZoom: begin
                     if MouseButton = mbLeft then
                       ImageEnView1.ZoomIn()
                     else
                     if MouseButton = mbLeft then
                       ImageEnView1.ZoomOut();
                   end;
  end;
end;


// EXAMPLE 4: 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

ButtonParams
TIEButtonInteraction
AttachedImageEnView
MouseWheelParams