2018-03-23 00:10:05 +00:00
|
|
|
{******************************************************************
|
|
|
|
|
|
|
|
JEDI-VCL Demo
|
|
|
|
|
|
|
|
Copyright (C) 2002 Project JEDI
|
|
|
|
|
|
|
|
Original author:
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
|
|
|
You may retrieve the latest version of this file at the JEDI-JVCL
|
|
|
|
home page, located at http://jvcl.delphi-jedi.org
|
|
|
|
|
|
|
|
The contents of this file are used with permission, subject to
|
|
|
|
the Mozilla Public License Version 1.1 (the "License"); you may
|
|
|
|
not use this file except in compliance with the License. You may
|
|
|
|
obtain a copy of the License at
|
|
|
|
http://www.mozilla.org/MPL/MPL-1_1Final.html
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************}
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
unit JvThumbnailChildFormU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, Controls, Forms,
|
2018-03-23 23:59:33 +00:00
|
|
|
StdCtrls, ExtCtrls, FileCtrl, ComCtrls, ShellCtrls, Spin,
|
2018-03-23 00:10:05 +00:00
|
|
|
JvThumbImage, JvThumbNails, JvBaseThumbnail, JvExExtCtrls;
|
|
|
|
|
|
|
|
type
|
2018-03-23 18:57:52 +00:00
|
|
|
|
|
|
|
{ TJvThumbnailChildForm }
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
TJvThumbnailChildForm = class(TForm)
|
2018-04-22 11:30:20 +00:00
|
|
|
BtnSave: TButton;
|
2018-04-21 17:26:53 +00:00
|
|
|
CenterBevel: TBevel;
|
2018-04-22 11:30:20 +00:00
|
|
|
CbTransform: TComboBox;
|
|
|
|
LblMargin: TLabel;
|
2018-03-23 19:44:39 +00:00
|
|
|
Panel1: TPanel;
|
2018-03-25 00:05:20 +00:00
|
|
|
Panel2: TPanel;
|
2018-03-23 23:59:33 +00:00
|
|
|
SpinEdit1: TSpinEdit;
|
2018-03-23 00:10:05 +00:00
|
|
|
Splitter2: TSplitter;
|
|
|
|
Panel6: TPanel;
|
|
|
|
Splitter4: TSplitter;
|
|
|
|
ShellTreeView: TShellTreeView;
|
|
|
|
ShellListView: TShellListView;
|
|
|
|
Panel8: TPanel;
|
2018-03-23 19:44:39 +00:00
|
|
|
LblRed: TLabel;
|
|
|
|
LblGreen: TLabel;
|
|
|
|
LblBlue: TLabel;
|
|
|
|
LblContrast: TLabel;
|
2018-03-23 00:10:05 +00:00
|
|
|
REDBar: TTrackBar;
|
|
|
|
GreenBar: TTrackBar;
|
|
|
|
BlueBar: TTrackBar;
|
2018-03-23 19:44:39 +00:00
|
|
|
ContrastBar: TTrackBar;
|
|
|
|
BtnApply: TButton;
|
2018-03-23 00:10:05 +00:00
|
|
|
Panel10: TPanel;
|
2018-03-25 00:05:20 +00:00
|
|
|
FilterComboBox: TFilterComboBox;
|
2018-03-23 00:10:05 +00:00
|
|
|
Panel7: TPanel;
|
|
|
|
Panel5: TPanel;
|
2018-03-23 19:44:39 +00:00
|
|
|
LblThumbTitle: TLabel;
|
2018-03-23 00:10:05 +00:00
|
|
|
CbAsButton: TCheckBox;
|
|
|
|
CbAutoLoad: TCheckBox;
|
|
|
|
CbMinimizeMem: TCheckBox;
|
|
|
|
GbTitlePlacement: TRadioGroup;
|
2018-03-23 19:44:39 +00:00
|
|
|
EdThumbTitle: TEdit;
|
|
|
|
GbThumbImage: TGroupBox;
|
2018-03-23 00:10:05 +00:00
|
|
|
BtnInvert: TButton;
|
2018-03-25 00:05:20 +00:00
|
|
|
BtnGrayScale: TButton;
|
2018-03-23 19:44:39 +00:00
|
|
|
LblLightness: TLabel;
|
2018-03-23 00:10:05 +00:00
|
|
|
LightnessBar: TTrackBar;
|
|
|
|
BtnExit: TButton;
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbNail: TJVThumbNail;
|
|
|
|
ThumbImage: TJvThumbImage;
|
|
|
|
procedure BtnApplyClick(Sender: TObject);
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure BtnInvertClick(Sender: TObject);
|
|
|
|
procedure BtnGrayScaleClick(Sender: TObject);
|
2018-04-22 11:30:20 +00:00
|
|
|
procedure BtnSaveClick(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure CbAsButtonClick(Sender: TObject);
|
|
|
|
procedure CbAutoLoadClick(Sender: TObject);
|
|
|
|
procedure CbMinimizeMemClick(Sender: TObject);
|
2018-04-22 11:30:20 +00:00
|
|
|
procedure CbTransformChange(Sender: TObject);
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure FormShow(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure GbTitlePlacementClick(Sender: TObject);
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure Panel10Resize(Sender: TObject);
|
|
|
|
procedure Panel2Resize(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure Panel8Resize(Sender: TObject);
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure ShellListViewChange(Sender: TObject);
|
2018-03-23 18:57:52 +00:00
|
|
|
procedure ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode);
|
2018-04-21 23:25:49 +00:00
|
|
|
procedure ShellTreeViewGetSelectedIndex(Sender: TObject; Node: TTreeNode);
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure SpinEdit1Change(Sender: TObject);
|
2018-03-23 19:44:39 +00:00
|
|
|
procedure ThumbNailClick(Sender: TObject);
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure ThumbImageMouseDown(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
procedure ThumbImageMouseMove(Sender: TObject;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
procedure ThumbImageMouseUp(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
private
|
|
|
|
FMousePt: TPoint;
|
|
|
|
procedure LoadFile(const AFileName: String);
|
2018-03-23 00:10:05 +00:00
|
|
|
public
|
|
|
|
function GetFileName: String;
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure SetFileName(AFileName: String);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
JvThumbnailChildForm: TJvThumbnailChildForm;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
2018-03-23 18:57:52 +00:00
|
|
|
uses
|
|
|
|
JvThumbnailDatamodule;
|
|
|
|
|
2018-03-23 19:44:39 +00:00
|
|
|
procedure TJvThumbnailChildForm.BtnApplyClick(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-25 00:05:20 +00:00
|
|
|
ThumbImage.ChangeRGB(RedBar.Position, GreenBar.Position, BlueBar.Position);
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbImage.Contrast(ContrastBar.Position);
|
|
|
|
ThumbImage.Lightness(LightnessBar.Position);
|
2018-03-23 00:10:05 +00:00
|
|
|
RedBar.Position := 0;
|
|
|
|
GreenBar.Position :=0;
|
|
|
|
BlueBar.Position := 0;
|
|
|
|
ContrastBar.Position := 0;
|
|
|
|
LightnessBar.Position := 0;
|
2018-04-22 11:30:20 +00:00
|
|
|
BtnSave.Enabled := true;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure TJvThumbnailChildForm.LoadFile(const AFileName: String);
|
|
|
|
var
|
|
|
|
crs: TCursor;
|
|
|
|
begin
|
|
|
|
crs := Screen.Cursor;
|
|
|
|
Screen.Cursor := crHourglass;
|
|
|
|
Application.ProcessMessages;
|
|
|
|
try
|
|
|
|
ThumbNail.FileName := AFileName;
|
|
|
|
ThumbImage.LoadFromFile(AFileName);
|
|
|
|
ThumbImage.Width := ThumbImage.Picture.Width;
|
|
|
|
ThumbImage.Height := ThumbImage.Picture.Height;
|
|
|
|
ThumbImage.Left := 0;
|
|
|
|
ThumbImage.Top := 0;
|
|
|
|
finally
|
|
|
|
Screen.Cursor := crs;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure TJvThumbnailChildForm.ShellListViewChange(Sender: TObject);
|
|
|
|
var
|
|
|
|
fn: String;
|
|
|
|
begin
|
|
|
|
if ShellListView.Selected <> nil then begin
|
|
|
|
fn := ShellListView.GetPathFromItem(ShellListView.Selected);
|
2018-03-25 00:05:20 +00:00
|
|
|
Loadfile(fn);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 18:57:52 +00:00
|
|
|
procedure TJvThumbnailChildForm.ShellTreeViewGetImageIndex(Sender: TObject;
|
|
|
|
Node: TTreeNode);
|
|
|
|
begin
|
|
|
|
if Node.Level = 0 then
|
|
|
|
Node.ImageIndex := 0
|
|
|
|
else
|
|
|
|
Node.ImageIndex := 1;
|
2018-04-21 17:26:53 +00:00
|
|
|
Node.SelectedIndex := Node.ImageIndex;
|
2018-03-23 18:57:52 +00:00
|
|
|
end;
|
|
|
|
|
2018-04-21 23:25:49 +00:00
|
|
|
procedure TJvThumbnailChildForm.ShellTreeViewGetSelectedIndex(Sender: TObject;
|
|
|
|
Node: TTreeNode);
|
|
|
|
begin
|
|
|
|
if Node.Level = 0 then
|
|
|
|
Node.SelectedIndex := 0
|
|
|
|
else
|
|
|
|
Node.SelectedIndex := 1;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 23:59:33 +00:00
|
|
|
procedure TJvThumbnailChildForm.SpinEdit1Change(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Thumbnail.Margin := SpinEdit1.Value;
|
|
|
|
end;
|
|
|
|
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure TJvThumbnailChildForm.ThumbImageMouseDown(Sender: TObject;
|
|
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
2018-04-21 17:26:53 +00:00
|
|
|
var
|
|
|
|
W, H: Integer;
|
2018-03-25 00:05:20 +00:00
|
|
|
begin
|
|
|
|
FMousePt := Point(X, Y);
|
2018-04-21 17:26:53 +00:00
|
|
|
W := ThumbImage.Parent.Width;
|
|
|
|
H := ThumbImage.Parent.Height;
|
|
|
|
if (ThumbImage.Width > W) or (ThumbImage.Height > H) then
|
|
|
|
ThumbImage.Cursor := crDrag;
|
2018-03-25 00:05:20 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.ThumbImageMouseMove(Sender: TObject;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
var
|
|
|
|
L, T: Integer;
|
2018-04-21 17:26:53 +00:00
|
|
|
W, H: Integer;
|
2018-03-25 00:05:20 +00:00
|
|
|
begin
|
|
|
|
if ssLeft in Shift then begin
|
2018-04-21 17:26:53 +00:00
|
|
|
W := ThumbImage.Parent.Width;
|
|
|
|
H := ThumbImage.Parent.Height;
|
|
|
|
if (ThumbImage.Width <= W) and (ThumbImage.Height <= H) then
|
|
|
|
exit;
|
2018-03-25 00:05:20 +00:00
|
|
|
L := ThumbImage.Left + (X - FMousePt.X);
|
|
|
|
T := ThumbImage.Top + (Y - FMousePt.Y);
|
2018-04-21 17:26:53 +00:00
|
|
|
{
|
|
|
|
if L < 0 then L := 0;
|
2018-03-25 00:05:20 +00:00
|
|
|
if T > 0 then T := 0;
|
2018-04-21 17:26:53 +00:00
|
|
|
if L + ThumbImage.Width > W then L := W - ThumbImage.Width;
|
|
|
|
if T + ThumbImage.Height > H then T := H - ThumbImage.Height;
|
|
|
|
}
|
2018-03-25 00:05:20 +00:00
|
|
|
ThumbImage.SetBounds(L, T, ThumbImage.Width, ThumbImage.Height);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.ThumbImageMouseUp(Sender: TObject;
|
|
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
|
|
|
ThumbImage.Cursor := crDefault;
|
|
|
|
end;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure TJvThumbnailChildForm.CbAsButtonClick(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbNail.Asbutton := CbAsButton.Checked;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.CbAutoLoadClick(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbNail.AutoLoad := CbAutoLoad.Checked;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.CbMinimizeMemClick(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbNail.MinimizeMemory := CbMinimizeMem.Checked;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-04-22 11:30:20 +00:00
|
|
|
procedure TJvThumbnailChildForm.CbTransformChange(Sender: TObject);
|
|
|
|
var
|
|
|
|
w, h: Integer;
|
|
|
|
begin
|
|
|
|
w := ThumbImage.Picture.Width;
|
|
|
|
h := ThumbImage.Picture.Height;
|
|
|
|
case CbTransform.ItemIndex of
|
|
|
|
0: ThumbImage.Angle := AT0;
|
|
|
|
1: ThumbImage.Angle := AT90;
|
|
|
|
2: ThumbImage.Angle := AT180;
|
|
|
|
3: ThumbImage.Angle := AT270;
|
|
|
|
4: ThumbImage.Mirror(mtHorizontal);
|
|
|
|
5: ThumbImage.Mirror(mtVertical);
|
|
|
|
end;
|
|
|
|
if (w <> ThumbImage.Picture.Width) or (h <> ThumbImage.Picture.Height) then
|
|
|
|
with ThumbImage do SetBounds(0, 0, Picture.Width, Picture.Height);
|
|
|
|
BtnSave.Enabled := true;
|
|
|
|
end;
|
|
|
|
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure TJvThumbnailChildForm.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
{$IFDEF WINDOWS}
|
|
|
|
ThumbImage.Parent.DoubleBuffered := true;
|
|
|
|
ShellListView.DoubleBuffered := true;
|
|
|
|
{$ENDIF}
|
2018-04-21 17:47:53 +00:00
|
|
|
FilterCombobox.ItemIndex := 0;
|
|
|
|
ShellListView.Mask := FilterCombobox.Mask;
|
2018-04-22 11:30:20 +00:00
|
|
|
BtnSave.Enabled := false;
|
2018-03-25 00:05:20 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-23 00:10:05 +00:00
|
|
|
procedure TJvThumbnailChildForm.GbTitlePlacementClick(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbNail.TitlePlacement := TTitlePos(GbTitlePlacement.ItemIndex);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.Panel8Resize(Sender: TObject);
|
|
|
|
begin
|
|
|
|
RedBar.Width := panel8.ClientWidth;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.BtnInvertClick(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbImage.Invert;
|
2018-04-22 11:30:20 +00:00
|
|
|
BtnSave.Enabled := true;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-25 00:05:20 +00:00
|
|
|
procedure TJvThumbnailChildForm.BtnGrayScaleClick(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
ThumbImage.GrayScale;
|
2018-04-22 11:30:20 +00:00
|
|
|
BtnSave.Enabled := true;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.BtnSaveClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
fn: String;
|
|
|
|
begin
|
|
|
|
if ThumbImage.Modified then begin
|
|
|
|
fn := ChangeFileExt(ThumbImage.FileName, '') + '_modified' + ExtractFileExt(ThumbImage.FileName);
|
|
|
|
ThumbImage.SaveToFile(fn);
|
|
|
|
end;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
2018-03-23 19:44:39 +00:00
|
|
|
procedure TJvThumbnailChildForm.ThumbNailClick(Sender: TObject);
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
if ThumbNail.FileName<>'' then
|
|
|
|
ThumbImage.Loadfromfile(ThumbNail.FileName);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.Panel10Resize(Sender: TObject);
|
|
|
|
begin
|
2018-03-25 00:05:20 +00:00
|
|
|
FilterComboBox.Width := panel10.ClientWidth;
|
|
|
|
FilterComboBox.Height:= panel10.ClientHeight;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.Panel2Resize(Sender: TObject);
|
|
|
|
var
|
|
|
|
L, T: Integer;
|
|
|
|
begin
|
|
|
|
L := ThumbImage.Left;
|
|
|
|
T := ThumbImage.Top;
|
|
|
|
if (L < 0) and (L + ThumbImage.Width < Width) then
|
|
|
|
L := Width - ThumbImage.Width;
|
|
|
|
if (T < 0) and (T + ThumbImage.Height < Height) then
|
|
|
|
T := Height - ThumbImage.Height;
|
|
|
|
if (L <> ThumbImage.Left) or (T <> ThumbImage.Top) then
|
|
|
|
ThumbImage.SetBounds(L, T, ThumbImage.Width, ThumbImage.Height);
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.FormShow(Sender: TObject);
|
|
|
|
begin
|
2018-03-23 19:44:39 +00:00
|
|
|
GbTitlePlacement.ItemIndex := integer(ThumbNail.titlePlacement);
|
2018-04-22 11:30:20 +00:00
|
|
|
CbTransform.ItemIndex := 0;
|
2018-03-23 23:59:33 +00:00
|
|
|
SpinEdit1.Value := Thumbnail.Margin;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TJvThumbnailChildForm.GetfileName: String;
|
|
|
|
begin
|
|
|
|
Result := ShellListView.GetPathFromItem(ShellListView.Selected);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TJvThumbnailChildForm.SetFileName(AFileName: String);
|
|
|
|
var
|
|
|
|
dir, fn: String;
|
2018-03-23 18:43:14 +00:00
|
|
|
item: TListItem;
|
2018-03-23 00:10:05 +00:00
|
|
|
begin
|
|
|
|
dir := ExtractFilePath(AFileName);
|
|
|
|
fn := ExtractFileName(AFileName);
|
|
|
|
if dir <> ShellListView.Root then
|
|
|
|
ShellTreeView.Path := dir;
|
2018-03-23 18:43:14 +00:00
|
|
|
item := ShellListView.Items.FindCaption(-0, fn, false, true, false);
|
|
|
|
ShellListView.Selected := item;
|
2018-03-23 00:10:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|