jvcllaz: New features in JvThumbnail: ThumbColor, ThumbTitleColor, Margin. Fix TitleHeight.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6273 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-03-23 23:59:33 +00:00
parent cd5e168a20
commit 12949c5965
9 changed files with 263 additions and 171 deletions

View File

@ -14,7 +14,7 @@ implementation
{$R ../../resource/jvcustomreg.res}
uses
Classes, ImgList, Controls, PropEdits, GraphPropEdits, ComponentEditors,
Classes, ImgList, Controls, LResources, PropEdits, GraphPropEdits, ComponentEditors,
JvDsgnConsts,
JvOutlookBar, JvOutlookBarEditors,
JvTabBar, JvTabBarXPPainter,
@ -49,6 +49,10 @@ begin
RegisterPropertyEditor(TypeInfo(TImageIndex), TJvOutlookBarPage,
'ImageIndex', TJvOutlookBarPageImageIndexProperty);
// Thumbnails
RegisterPropertyToSkip(TJvThumbnail, 'ClientWidth', 'Redundant', '');
RegisterPropertyToSkip(TJvThumbnail, 'ClientHeight', 'Redundant', '');
end;
end.

View File

@ -338,7 +338,6 @@ object JvThumbnailChildForm: TJvThumbnailChildForm
Top = 5
Width = 577
Align = alTop
AutoSize = True
BorderSpacing.Around = 4
BevelOuter = bvNone
ClientHeight = 159
@ -443,23 +442,14 @@ object JvThumbnailChildForm: TJvThumbnailChildForm
Anchors = [akTop, akBottom]
BorderSpacing.Left = 2
BorderSpacing.Right = 8
ClientHeight = 136
ClientWidth = 144
ClientHeight = 159
ClientWidth = 152
Constraints.MinWidth = 152
TabOrder = 2
OnClick = ThumbNailClick
TitleColor = clBtnFace
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
AsButton = False
MinimizeMemory = True
StreamFileType = grBMP
ShowTitle = False
TitlePlacement = tpUp
AutoLoad = True
ShadowColor = clSilver
ShowShadow = False
end
object Panel1: TPanel
AnchorSideLeft.Control = ThumbNail
@ -610,6 +600,14 @@ object JvThumbnailChildForm: TJvThumbnailChildForm
Caption = 'Thumbnails Title'
ParentColor = False
end
object SpinEdit1: TSpinEdit
Left = 2
Height = 23
Top = 80
Width = 86
OnChange = SpinEdit1Change
TabOrder = 6
end
end
end
end

View File

@ -32,7 +32,7 @@ interface
uses
Classes, SysUtils, Controls, Forms,
StdCtrls, ExtCtrls, FileCtrl, ComCtrls, ShellCtrls,
StdCtrls, ExtCtrls, FileCtrl, ComCtrls, ShellCtrls, Spin,
JvThumbImage, JvThumbNails, JvBaseThumbnail, JvExExtCtrls;
type
@ -42,6 +42,7 @@ type
TJvThumbnailChildForm = class(TForm)
Bevel2: TBevel;
Panel1: TPanel;
SpinEdit1: TSpinEdit;
Splitter2: TSplitter;
Panel6: TPanel;
Splitter4: TSplitter;
@ -86,6 +87,7 @@ type
procedure BtnInvertClick(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode);
procedure SpinEdit1Change(Sender: TObject);
procedure ThumbNailClick(Sender: TObject);
procedure Panel10Resize(Sender: TObject);
procedure FormShow(Sender: TObject);
@ -137,6 +139,11 @@ begin
Node.ImageIndex := 1;
end;
procedure TJvThumbnailChildForm.SpinEdit1Change(Sender: TObject);
begin
Thumbnail.Margin := SpinEdit1.Value;
end;
procedure TJvThumbnailChildForm.CbAsButtonClick(Sender: TObject);
begin
ThumbNail.Asbutton := CbAsButton.Checked;
@ -189,6 +196,7 @@ begin
//ThumbImage.Picture.Free;
GbTitlePlacement.ItemIndex := integer(ThumbNail.titlePlacement);
GbAngle.ItemIndex := integer(ThumbImage.angle);
SpinEdit1.Value := Thumbnail.Margin;
end;
procedure TJvThumbnailChildForm.GbAngleClick(Sender: TObject);

View File

@ -1,7 +1,7 @@
object JvThumbnailMainForm: TJvThumbnailMainForm
Left = 295
Left = 296
Height = 656
Top = 100
Top = 126
Width = 878
Caption = 'JvThumbView Demo'
ClientHeight = 656
@ -261,6 +261,34 @@ object JvThumbnailMainForm: TJvThumbnailMainForm
OnClick = BtnEditSelThumbClick
TabOrder = 7
end
object CbThumbColor: TColorButton
AnchorSideLeft.Control = SpinEdit2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = SpinEdit2
Left = 760
Height = 25
Top = 27
Width = 27
BorderSpacing.Left = 16
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
OnColorChanged = CbThumbColorColorChanged
end
object CbTitleColor: TColorButton
AnchorSideLeft.Control = CbThumbColor
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CbThumbColor
Left = 789
Height = 25
Top = 27
Width = 27
BorderSpacing.Left = 2
BorderWidth = 2
ButtonColorSize = 16
ButtonColor = clBlack
OnColorChanged = CbTitleColorColorChanged
end
end
object Panel2: TPanel
Left = 0

View File

@ -31,8 +31,9 @@ unit JvThumbnailMainFormU;
interface
uses
Classes, Controls, Forms, StdCtrls, ExtCtrls, FileCtrl, ComCtrls, Spin, ShellCtrls,
JvThumbNails, JvThumbViews, JvBaseThumbnail, JvThumbnailDatamodule;
Classes, Controls, Graphics, Forms, StdCtrls, ExtCtrls, FileCtrl, ComCtrls, Spin,
ShellCtrls, ColorBox, Dialogs, JvThumbNails, JvThumbViews, JvBaseThumbnail,
JvThumbnailDatamodule;
{JvSpecialProgress,
JvListBox, JvDriveCtrls, JvCombobox, JvExControls, JvComponent,
JvExStdCtrls, JvExForms; }
@ -42,6 +43,8 @@ type
{ TJvThumbnailMainForm }
TJvThumbnailMainForm = class(TForm)
CbThumbColor: TColorButton;
CbTitleColor: TColorButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Splitter1: TSplitter;
@ -68,6 +71,8 @@ type
Panel5: TPanel;
ProgressBar: TProgressBar;
Bevel1: TBevel;
procedure CbThumbColorColorChanged(Sender: TObject);
procedure CbTitleColorColorChanged(Sender: TObject);
procedure ShellTreeViewChange(Sender: TObject; Node: TTreeNode);
procedure ShellTreeViewGetImageIndex(Sender: TObject; Node: TTreeNode);
procedure ThumbViewKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
@ -164,6 +169,16 @@ begin
ThumbView.MinMemory := CbMinMemory.Checked;
end;
procedure TJvThumbnailMainForm.CbThumbColorColorChanged(Sender: TObject);
begin
ThumbView.ThumbColor := CbThumbColor.ButtonColor;
end;
procedure TJvThumbnailMainForm.CbTitleColorColorChanged(Sender: TObject);
begin
ThumbView.ThumbTitleColor := CbTitleColor.ButtonColor;
end;
procedure TJvThumbnailMainForm.SpinEdit1Change(Sender: TObject);
begin
if spinedit1.Text <> '' then ThumbView.ThumbGap := spinedit1.Value;
@ -207,6 +222,8 @@ end;
procedure TJvThumbnailMainForm.FormShow(Sender: TObject);
begin
CbThumbColor.ButtonColor := ColorToRGB(ThumbVIew.ThumbColor);
CbTitleColor.ButtonColor := ColorToRGB(ThumbVIew.ThumbColor);
CbAutoScrolling.Checked := ThumbView.AutoScrolling;
CbAutoHandleKeyboard.Checked := ThumbView.AutoHandleKeyb;
CbSorted.Checked := ThumbView.Sorted;

View File

@ -428,6 +428,7 @@ begin
inherited KeyPress(Key);
end;
//=== { TJvBaseThumbImage } ==================================================
constructor TJvBaseThumbImage.Create(AOwner: TComponent);

View File

@ -74,7 +74,6 @@ type
FClass: TGraphicClass;
FOnInvalidImage: TInvalidImageEvent;
procedure Rotate90;
//procedure Rotate180;
procedure Rotate270;
procedure SetAngle(AAngle: TAngle);
function GetModify: Boolean;
@ -749,88 +748,11 @@ procedure TJvThumbImage.SetAngle(AAngle: TAngle);
end;
begin
if not Assigned(Picture.Graphic) then
exit;
if not CanModify then
exit;
if AAngle = FAngle then
exit;
RotateByDelta(ord(AAngle) - ord(FAngle));
(*
case FAngle of
AT0:
case AAngle of
AT90:
begin
Rotate90;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
AT180:
Mirror(mtBoth);
AT270:
begin
Rotate270;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
end;
AT90:
case AAngle of
AT180:
begin
Rotate90;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
AT270:
Mirror(mtBoth);
AT0:
begin
Rotate270;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
end;
AT180:
case AAngle of
AT270:
begin
Rotate90;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
AT0:
Mirror(mtBoth);
AT90:
begin
Rotate270;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
end;
AT270:
case AAngle of
AT0:
begin
Rotate90;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
AT90:
Mirror(mtBoth);
AT180:
begin
Rotate270;
if Parent is TJvThumbnail then
SendMessage(TJvThumbnail(Parent).Handle, TH_IMAGESIZECHANGED, 0, 0);
end;
end;
if Assigned(Picture.Graphic) and CanModify and (AAngle <> FAngle) then begin
RotateByDelta(ord(AAngle) - ord(FAngle));
FAngle := AAngle;
FModified := FAngle <> AT0;
end;
*)
FAngle := AAngle;
FModified := FAngle <> AT0;
end;
(*
@ -927,10 +849,9 @@ end;
procedure TJvThumbImage.Rotate270;
var
Row, Col: Integer;
MemBmp: TBitmap;
IntfImg: TLazIntfImage;
RotIntfImg: TLazIntfImage;
ImgHandle, ImgMaskHandle: HBitmap;
MemBmp, RotBmp: TBitmap;
IntfImg, RotIntfImg: TLazIntfImage;
RotImgHandle, RotImgMaskHandle: HBitmap;
clr: TColor;
w, h: Integer;
begin
@ -942,32 +863,44 @@ begin
IntfImg := TLazIntfImage.Create(0, 0);
RotIntfImg := TLazIntfImage.Create(0, 0);
MemBmp := TBitmap.Create;
RotBmp := TBitmap.Create;
try
MemBmp.PixelFormat := pf32bit;
MemBmp.SetSize(w, h);
MemBmp.Canvas.Brush.Color := clWhite;
MemBmp.Canvas.FillRect(0, 0, w, h);
MemBmp.Assign(Picture);
RotBmp.PixelFormat := pf32Bit;
RotBmp.SetSize(h, w);
IntfImg.LoadFromBitmap(MemBmp.Handle, MemBmp.MaskHandle);
RotIntfImg.LoadFromBitmap(MemBmp.Handle, MemBmp.MaskHandle);
RotIntfImg.SetSize(h, w);
RotIntfImg.LoadFromBitmap(RotBmp.Handle, RotBmp.MaskHandle);
(*
for Row := 0 to h - 1 do
for Col := 0 to w - 1 do begin
clr := IntfImg.TColors[Col, Row];
RotIntfImg.TColors[h - 1 - Row , w - 1 - Col] := clr;
end;
RotIntfImg.CreateBitmaps(ImgHandle, ImgMaskHandle);
MemBmp.Handle := ImgHandle;
MemBmp.MaskHandle := ImgMaskHandle;
*)
for Row := h - 1 downto 0 do
for Col := 0 to w - 1 do begin
clr := IntfImg.TColors[Col, Row];
RotIntfImg.TColors[h - 1 - Row, w - 1 - Col] := clr;
end;
RotIntfImg.CreateBitmaps(RotImgHandle, RotImgMaskHandle);
RotBmp.Handle := RotImgHandle;
RotBmp.MaskHandle := RotImgMaskHandle;
Picture.Graphic.Clear;
if Picture.Graphic is TJpegImage then
TJpegImage(Picture.Graphic).Assign(MemBmp)
TJpegImage(Picture.Graphic).Assign(RotBmp)
else if Picture.Graphic is Graphics.TBitmap then
Picture.Bitmap.Assign(MemBmp);
Picture.Bitmap.Assign(RotBmp);
Invalidate;
finally
MemBmp.Free;
RotBmp.Free;
IntfImg.Free;
RotIntfImg.Free;
end;
end;
end;
@ -1031,10 +964,9 @@ end;
procedure TJvThumbImage.Rotate90;
var
Row, Col: Integer;
MemBmp: TBitmap;
IntfImg: TLazIntfImage;
RotIntfImg: TLazIntfImage;
ImgHandle, ImgMaskHandle: HBitmap;
MemBmp, RotBmp: TBitmap;
IntfImg, RotIntfImg: TLazIntfImage;
RotImgHandle, RotImgMaskHandle: HBitmap;
clr: TColor;
w, h: Integer;
begin
@ -1046,32 +978,37 @@ begin
IntfImg := TLazIntfImage.Create(0, 0);
RotIntfImg := TLazIntfImage.Create(0, 0);
MemBmp := TBitmap.Create;
RotBmp := TBitmap.Create;
try
MemBmp.PixelFormat := pf32bit;
MemBmp.SetSize(w, h);
MemBmp.Canvas.Brush.Color := clWhite;
MemBmp.Canvas.FillRect(0, 0, w, h);
MemBmp.Assign(Picture);
RotBmp.PixelFormat := pf32Bit;
RotBmp.SetSize(h, w);
IntfImg.LoadFromBitmap(MemBmp.Handle, MemBmp.MaskHandle);
RotIntfImg.LoadFromBitmap(MemBmp.Handle, MemBmp.MaskHandle);
RotIntfImg.SetSize(h, w);
RotIntfImg.LoadFromBitmap(RotBmp.Handle, RotBmp.MaskHandle);
for Row := 0 to h - 1 do
for Col := 0 to w - 1 do begin
clr := IntfImg.TColors[Col, Row];
RotIntfImg.TColors[Row, Col] := clr;
end;
RotIntfImg.CreateBitmaps(ImgHandle, ImgMaskHandle);
MemBmp.Handle := ImgHandle;
MemBmp.MaskHandle := ImgMaskHandle;
RotIntfImg.CreateBitmaps(RotImgHandle, RotImgMaskHandle);
RotBmp.Handle := RotImgHandle;
RotBmp.MaskHandle := RotImgMaskHandle;
Picture.Graphic.Clear;
if Picture.Graphic is TJpegImage then
TJpegImage(Picture.Graphic).Assign(MemBmp)
TJpegImage(Picture.Graphic).Assign(RotBmp)
else if Picture.Graphic is Graphics.TBitmap then
Picture.Bitmap.Assign(MemBmp);
Picture.Bitmap.Assign(RotBmp);
Invalidate;
finally
MemBmp.Free;
RotBmp.Free;
IntfImg.Free;
RotIntfImg.Free;
end;
end;
end;

View File

@ -84,6 +84,7 @@ type
FFilter: string;
// FBufferFile: string;
FThumbColor: TColor;
FThumbTitleColor: TColor;
FAsButtons: Boolean;
FTitlePlacement: TTitlePos;
FOnKeyDown: TKeyEvent;
@ -112,6 +113,8 @@ type
procedure GoDown;
procedure GoUp;
procedure SetAsButton(const NewVal: Boolean);
procedure SetThumbColor(const AValue: TColor);
procedure SetThumbTitleColor(const AValue: TColor);
procedure SetTitlePos(const NewVal: TTitlePos);
function CreateFilter: string;
procedure SetFilters;
@ -185,7 +188,8 @@ type
property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePos default tpUp;
property Filter: string read FFilter write FFilter;
// Property BufferFile : String Read FBufferFile write SetBufferFile;
property ThumbColor: TColor read FThumbColor write FThumbColor;
property ThumbColor: TColor read FThumbColor write SetThumbColor default clDefault;
property ThumbTitleColor: TColor read FThumbTitleColor write SetThumbTitleColor default clDefault;
property ShowShadow: Boolean read FShowShadow write FShowShadow;
property ShadowColor: TColor read FShadowColor write FShadowColor;
property AutoScroll;
@ -243,7 +247,8 @@ begin
FFileList.Clear;
FFileListSorted := TStringList.Create;
FFileListSorted.Clear;
FThumbColor := clNone;
FThumbColor := clDefault;
FThumbTitlecolor := clDefault;
end;
destructor TJvThumbView.Destroy;
@ -286,16 +291,18 @@ begin
Thb.OnDblClick := OnDblClick;
Thb.Photo.OnDblClick := OnDblClick;
Thb.MinimizeMemory := MinMemory;
Thb.Color := Self.Color;
Thb.Title := ATitle;
if FThumbColor = clNone then
if FThumbColor = clDefault then
begin
Thb.Color := Self.Color;
Thb.ParentColor := True;
Thb.TitleColor := Self.Color;
end
else
Thb.Color := FThumbColor;
if FThumbTitleColor = clDefault then
Thb.TitleColor := Self.Color
else
Thb.TitleColor := FThumbTitleColor;
FThumbList.AddObject(Thb.Title, Thb);
Thb.Parent := Self;
if Redraw then
@ -783,6 +790,16 @@ begin
Thb.OnDblClick := OnDblClick;
Thb.Title := aTitle;
Thb.Photo.OnDblClick := OnDblClick;
if FThumbColor = clDefault then
begin
Thb.Color := Self.Color;
Thb.ParentColor := True;
end else
Thb.Color := FThumbColor;
if FThumbTitleColor = clDefault then
Thb.TitleColor := Self.Color
else
Thb.TitleColor := FThumbTitleColor;
// Thb.Buffer := Vbuffer;
Thb.Photo.LoadFromStream(AStream, Thb.StreamFileType);
Result := FThumbList.AddObject(Thb.Title, Thb);
@ -814,6 +831,18 @@ begin
Thb.OnDblClick := OnDblClick;
Thb.Photo.OnDblClick := OnDblClick;
Thb.MinimizeMemory := MinMemory;
if FThumbColor = clDefault then
begin
Thb.Color := Self.Color;
Thb.ParentColor := True;
end
else
Thb.Color := FThumbColor;
if FThumbTitleColor = clDefault then
Thb.TitleColor := Self.Color
else
Thb.TitleColor := FThumbTitleColor;
// Thb.Buffer := VBuffer;
FThumbList.AddObject(AFile, Thb);
InsertControl(Thb);
@ -1103,6 +1132,26 @@ begin
end;
end;
procedure TJvThumbView.SetThumbColor(const AValue: TColor);
var
i: Integer;
begin
if AValue = FThumbColor then exit;
FThumbColor := AValue;
for i:=0 to FThumbList.Count-1 do
FThumbList.Thumbnail[i].Color := FThumbColor;
end;
procedure TJvThumbView.SetThumbTitleColor(const AValue: TColor);
var
i: Integer;
begin
if AValue = FThumbTitleColor then exit;
FThumbTitleColor := AValue;
for i:=0 to FThumbList.Count-1 do
FThumbList.Thumbnail[i].TitleColor := FThumbTitleColor;
end;
procedure TJvThumbView.SetTitlePos(const NewVal: TTitlePos);
var
I: Longint;

View File

@ -79,8 +79,8 @@ type
FStream: TStream;
FImageWidth: Longint;
FImageHeight: Longint;
FClientHeight: Word;
FClientWidth: Word;
FThumbHeight: Word;
FThumbWidth: Word;
FShadowObj: TShape;
FUpdated: Boolean;
FImageReady: Boolean;
@ -97,6 +97,7 @@ type
FShowShadow: Boolean;
FHShadowOffset: Word;
FVShadowOffset: Word;
FMargin: Integer;
procedure WMPaint(var Msg: TLMPaint); message LM_PAINT;
(************** NOT CONVERTED ***
procedure PhotoOnProgress(Sender: TObject; Stage: TProgressStage;
@ -108,11 +109,9 @@ type
function LoadFile(AFile: string): string;
function GetFileName: string;
procedure CalculateImageSize; virtual;
procedure SetClientWidth(AWidth: Word);
procedure SetDummyStr(AStr: string);
procedure SetMinimizeMemory(Min: Boolean);
procedure SetDummyCard(AInt: Longint);
procedure SetClientHeight(AHeight: Word);
procedure SetShowTitle(const AState: Boolean);
procedure SetTitlePlacement(const AState: TTitlePos);
procedure SetTitle(const Value: string);
@ -121,8 +120,15 @@ type
procedure SetTitleFont(const Value: TFont);
procedure GetFileInfo(AName: string);
procedure SetShowShadow(AShow: Boolean);
procedure SetMargin(AValue: Integer);
// procedure SetShadowColor(aColor: TColor);
procedure UpdateThumbHeight;
procedure UpdateThumbWidth;
procedure UpdateTitlePanelHeight;
function IsTitleFontStored: Boolean;
protected
procedure CreateHandle; override;
procedure THSizeChanged(var Msg: TLMessage); message TH_IMAGESIZECHANGED;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
@ -140,12 +146,10 @@ type
published
property FileName: string read GetFileName write SetFileName;
property Title: string read FTitle write SetTitle;
property TitleColor: TColor read FTitleColor write SetTitleColor;
property TitleFont: TFont read FTitleFont write SetTitleFont;
property TitleColor: TColor read FTitleColor write SetTitleColor default clDefault;
property TitleFont: TFont read FTitleFont write SetTitleFont stored IsTitleFontStored;
property ImageReady: Boolean read FImageReady;
property OnGetTitle: TTitleNotify read FOnGetTitle write FOnGetTitle;
property ClientWidth: Word read FClientWidth write SetClientWidth;
property ClientHeight: Word read FClientHeight write SetClientHeight;
{ Do not store dummies }
property FileSize: Longint read FDFileSize write SetDummyCard stored False;
property FileAccessed: string read FDFileAccessed write SetDummyStr stored False;
@ -153,14 +157,15 @@ type
property FileChanged: string read FDFileChanged write SetDummyStr stored False;
property ImageWidth: Longint read FImageWidth default 0;
property ImageHeight: Longint read FImageHeight default 0;
property AsButton: Boolean read FAsButton write FAsButton;
property MinimizeMemory: Boolean read FMinimizeMemory write SetMinimizeMemory;
property StreamFileType: TGRFKind read FStreamFileKind write FStreamFileKind;
property ShowTitle: Boolean read FShowTitle write SetShowTitle;
property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePlacement;
property AutoLoad: Boolean read FAutoLoad write FAutoLoad;
property AsButton: Boolean read FAsButton write FAsButton default false;
property Margin: Integer read FMargin write SetMargin default 8;
property MinimizeMemory: Boolean read FMinimizeMemory write SetMinimizeMemory default true;
property StreamFileType: TGRFKind read FStreamFileKind write FStreamFileKind default grBMP;
property ShowTitle: Boolean read FShowTitle write SetShowTitle default true;
property TitlePlacement: TTitlePos read FTitlePlacement write SetTitlePlacement default tpUp;
property AutoLoad: Boolean read FAutoLoad write FAutoLoad default true;
property ShadowColor: TColor read FShadowColor write FShadowColor;
property ShowShadow: Boolean read FShowShadow write SetShowShadow;
property ShowShadow: Boolean read FShowShadow write SetShowShadow default false;
end;
@ -173,16 +178,19 @@ uses
constructor TJvThumbnail.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FPhotoName := TJvFileName.Create;
FShowTitle := True;
FMargin := 8;
FHShadowOffset := 3;
FVShadowOffset := 3;
FShowShadow := False;
FShadowColor := clSilver;
FShadowObj := TShape.Create(Self);
FShadowObj.Visible := FShowShadow;
FShadowObj.Brush.Color := FShadowColor;
FShadowObj.Parent := Self;
FShadowObj.Pen.Style := psClear;
FTitleColor := clDefault; //clBtnFace;
FTitlePlacement := tpUp;
FTitle := '';
FUpdated := False;
FPhotoName := TJvFileName.Create;
Photo := TJvThumbImage.Create(Self);
Photo.AutoSize := False;
Photo.Align := alNone;
@ -191,25 +199,31 @@ begin
Photo.OnProgress := PhotoOnProgress;
**************)
FShadowObj := TShape.Create(Self);
FShadowObj.Visible := FShowShadow;
FShadowObj.Brush.Color := FShadowColor;
FShadowObj.Parent := Self;
FShadowObj.Pen.Style := psClear;
FShadowObj.Width := Photo.Width;
FShadowObj.Height := Photo.Height;
FShadowObj.Left := Photo.Left + FHShadowOffset;
FShadowObj.Top := Photo.Top + FVShadowOffset;
FTitleFont := TFont.Create;
FTitleFont.Name := 'default';
FTitleFont.Size := 0;
FTitleFont.OnChange := @RefreshFont;
FTitlePanel := TJvThumbTitle.Create(Self);
FTitlePanel.Align := alTop;
FTitlePanel.Height := 15;
FTitlePanel.Alignment := taCenter;
FTitleColor := clBtnFace;
FTitlePanel.Color := FTitleColor;
FTitleFont := TFont.Create;
FTitleFont.OnChange := @RefreshFont;
FTitlePanel.BevelOuter := bvLowered;
FTitlePanel.ParentColor := True;
FTitlePanel.Color := Self.Color;
if FTitlePlacement = tpNone then
FTitlePanel.Visible := False;
FTitle := '';
FUpdated := False;
// FTitlePanel.Color := Self.Color;
FTitlePanel.Visible := (FTitlePlacement <> tpNone) and FShowTitle;
InsertControl(Photo);
InsertControl(FTitlePanel);
Align := alNone;
@ -260,6 +274,31 @@ begin
inherited BoundsChanged;
end;
procedure TJvThumbnail.CreateHandle;
begin
inherited;
if not (csDesigning in ComponentState) and (FTitleColor = clDefault) then
FTitleColor := Color;
UpdateTitlePanelHeight;
end;
function TJvThumbnail.IsTitleFontStored: Boolean;
begin
Result := not FTitleFont.IsDefault;
end;
procedure TJvThumbnail.UpdateTitlePanelHeight;
var
fd: TFontData;
begin
fd := GetFontData(FTitleFont.Handle);
Canvas.Font.Name := fd.Name;
Canvas.Font.Style := fd.Style;
Canvas.Font.Height := fd.Height;
FTitlePanel.Height := Canvas.TextHeight('Tg') + 4;
CalculateImageSize;
end;
procedure TJvThumbnail.SetStream(const AStream: TStream);
var
Bmp: Graphics.TBitmap;
@ -304,17 +343,17 @@ begin
end;
end;
procedure TJvThumbnail.SetClientWidth(AWidth: Word);
procedure TJvThumbnail.UpdateThumbWidth;
begin
FClientWidth := (Width - (BorderWidth * 2)) - 8;
FThumbWidth := ClientWidth - 2 * FMargin;
end;
procedure TJvThumbnail.SetClientHeight(AHeight: Word);
procedure TJvThumbnail.UpdateThumbHeight;
begin
if Assigned(FTitlePanel) then
FClientHeight := Height - (FTitlePanel.Height + 8)
if Assigned(FTitlePanel) and FTitlePanel.Visible then
FThumbHeight := ClientHeight - FTitlePanel.Height - FMargin
else
FClientHeight := Height - 8;
FThumbHeight := ClientHeight - FMargin;
end;
// dummy property functions to allow the object inspector to
@ -355,6 +394,17 @@ begin
FShowShadow := AShow;
end;
procedure TJvThumbnail.SetMargin(AValue: Integer);
begin
if AValue <> FMargin then begin
FMargin := AValue;
CalculateImageSize;
// UpdateThumbWidth;
// UpdateThumbHeight;
Invalidate;
end;
end;
{procedure TJvThumbnail.SetShadowColor(aColor: TColor);
begin
FShadowObj.Brush.Color := aColor;
@ -466,7 +516,7 @@ begin
if Owner is TJvThumbView then
Photo.ScaleDown(TJvThumbView(Owner).MaxWidth, TJvThumbView(Owner).MaxHeight)
else
Photo.ScaleDown(Width, Height);
Photo.ScaleDown(FThumbWidth, FThumbHeight);
end;
Result := FName;
end;
@ -499,12 +549,12 @@ var
begin
if (Photo = nil) or (Photo.Picture = nil) then
exit;
SetClientHeight(15);
SetClientWidth(15);
if (Photo.Picture.Width > ClientWidth) or (Photo.Picture.Height > ClientHeight) then
UpdateThumbHeight;
UpdateThumbWidth;
if (Photo.Picture.Width > FThumbWidth) or (Photo.Picture.Height > FThumbHeight) then
begin
TempX := ((ClientWidth) / Photo.Picture.Width) * 100;
TempY := ((ClientHeight) / Photo.Picture.Height) * 100;
TempX := (FThumbWidth / Photo.Picture.Width) * 100;
TempY := (FThumbHeight / Photo.Picture.Height) * 100;
end
else
begin
@ -584,6 +634,7 @@ end;
procedure TJvThumbnail.RefreshFont(Sender: TObject);
begin
FTitlePanel.Font.Assign(FTitleFont);
UpdateTitlePanelHeight;
end;
procedure TJvThumbnail.SetTitlePanel(ATitle: string; AFont: TFont;
@ -606,7 +657,7 @@ begin
tpNone:
FTitlePanel.Visible := False;
end;
if FTitlePlacement = tpNone then
if FTitlePlacement <> tpNone then
FTitlePanel.Visible := True;
FTitlePlacement := AState;
CalculateImageSize;
@ -641,5 +692,4 @@ begin
inherited Refresh;
end;
end.