You've already forked lazarus-ccr
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:
@ -428,6 +428,7 @@ begin
|
||||
inherited KeyPress(Key);
|
||||
end;
|
||||
|
||||
|
||||
//=== { TJvBaseThumbImage } ==================================================
|
||||
|
||||
constructor TJvBaseThumbImage.Create(AOwner: TComponent);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user