{*************************************************************************
                Copyright (c) PilotLogic Software House

  Package pl_ORCA
  This file is part of CodeTyphon Studio (https://www.pilotlogic.com/)

 ***** BEGIN LICENSE BLOCK *****
 * Version: LGPL-2.1 with link exception (Modified LGPL)
 *
 * The contents of this file are subject to the 
 * GNU LIBRARY GENERAL PUBLIC LICENSE Version 2.1 (the "License")
 * with the following modification:
 * 
 * As a special exception, the copyright holders of this library give you
 * permission to link this library with independent modules to produce an
 * executable, regardless of the license terms of these independent modules,
 * and to copy and distribute the resulting executable under terms of your choice,
 * provided that you also meet, for each linked independent module, the terms
 * and conditions of the license of that module. An independent module is a
 * module which is not derived from or based on this library. If you modify this
 * library, you may extend this exception to your version of the library, but
 * you are not obligated to do so. If you do not wish to do so, delete this
 * exception statement from your version.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * ***** END LICENSE BLOCK *****
 
***************************************************************************}

Unit orca_editor_imagelist;

{$mode objfpc}{$H+}

Interface

Uses
   LCLProc, LCLIntf, LCLType, LMessages, LResources, LazUtf8,
   Math, typinfo, IntfGraphics,
   Classes, Variants, SysUtils, Contnrs, Forms, Controls, Dialogs, Graphics,
   StdCtrls, DB, DBCtrls, ExtCtrls, Menus, Clipbrd, ActnList, ImgList,
   orca_scene2d;

Type

   TfrmDsgnImageList = Class(TForm)
      d2Scene1: TD2Scene;
      Root1: TD2Background;
      HudWindow1: TD2HudWindow;
      ImageList: TD2ImageListBox;
      btnAddFiles: TD2HudButton;
      OpenDialog1: TOpenDialog;
      HudButton1: TD2HudButton;
      btnDelete: TD2HudButton;
      btnClear: TD2HudButton;
      btnCancel: TD2HudButton;
      Procedure btnAddFilesClick(Sender: TObject);
      Procedure btnClearClick(Sender: TObject);
      Procedure btnDeleteClick(Sender: TObject);
   Private
   End;

Procedure ShowDsgnImageList(ImgList: TD2ImageList);

Var
   GvarD2frmDsgnImageList: TfrmDsgnImageList;

Implementation

{$R *.lfm}

//=========================================================================

Procedure ShowDsgnImageList(ImgList: TD2ImageList);
Var
   i: Integer;
Begin
   GvarD2frmDsgnImageList := TfrmDsgnImageList.Create(Application);
   With GvarD2frmDsgnImageList Do
   Begin
      For i := 0 To ImgList.Count - 1 Do
         ImageList.AddBitmap('', ImgList.Images[i]);
      ImageList.ItemWidth := ImgList.Width;
      ImageList.ItemHeight := ImgList.Height;
      If ShowModal = mrOk Then
      Begin
         ImgList.Clear;
         For i := 0 To ImageList.Count - 1 Do
            If ImageList.Images[i] <> nil Then
            Begin
               ImgList.Add(ImageList.Images[i].Bitmap);
            End;
      End;
   End;
   GvarD2frmDsgnImageList.Free;
End;
//==================== TfrmDsgnImageList ==================================

Procedure TfrmDsgnImageList.btnClearClick(Sender: TObject);
Begin
   ImageList.Clear;
End;

Procedure TfrmDsgnImageList.btnDeleteClick(Sender: TObject);
Begin
   If ImageList.Selected <> nil Then
      ImageList.Selected.Free;
End;

Procedure TfrmDsgnImageList.btnAddFilesClick(Sender: TObject);
Var
   i: Integer;
Begin
   OpenDialog1.Filter := GvarD2DefaultFilterClass.GetFileTypes;
   If OpenDialog1.Execute Then
   Begin
      For i := 0 To OpenDialog1.Files.Count - 1 Do
         ImageList.AddFile(OpenDialog1.Files[i]);
   End;
End;


End.
