diff --git a/Samples/Image/ImagesTest.dproj b/Samples/Image/ImagesTest.dproj index 20d1628..d020ab2 100644 --- a/Samples/Image/ImagesTest.dproj +++ b/Samples/Image/ImagesTest.dproj @@ -1,7 +1,7 @@  {2BB64C94-AACA-40C4-B562-C34CC63010C6} - 19.5 + 20.1 VCL ImagesTest.dpr True @@ -220,6 +220,16 @@ 1 + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + res\values @@ -240,6 +250,66 @@ 1 + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + res\values @@ -250,6 +320,16 @@ 1 + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + res\drawable @@ -420,6 +500,56 @@ 1 + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + 1 diff --git a/Samples/Image/ImagesTest.res b/Samples/Image/ImagesTest.res index a903c25..c6001b4 100644 Binary files a/Samples/Image/ImagesTest.res and b/Samples/Image/ImagesTest.res differ diff --git a/Samples/Image/Main.dfm b/Samples/Image/Main.dfm index d7684ed..a40ecd4 100644 --- a/Samples/Image/Main.dfm +++ b/Samples/Image/Main.dfm @@ -11,8 +11,6 @@ object MainForm: TMainForm Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] - OldCreateOrder = False - PixelsPerInch = 96 TextHeight = 13 object Image3: TImage Left = 336 @@ -2952,9 +2950,11 @@ object MainForm: TMainForm Top = 0 Width = 770 Height = 605 - ActivePage = TabSheet1 + ActivePage = TabSheet4 Align = alClient TabOrder = 0 + ExplicitWidth = 764 + ExplicitHeight = 586 object TabSheet1: TTabSheet Caption = 'Smothing' object Shape2: TShape @@ -11434,15 +11434,18 @@ object MainForm: TMainForm object Label21: TLabel Left = 8 Top = 5 - Width = 151 + Width = 320 Height = 13 - Caption = 'Focus support: (press TAB key)' + Caption = + 'Focus support: Press TAB key for Focus, and SPACE key for "Click' + + '"' end object EsImageControl14: TEsImageControl Left = 8 Top = 24 Width = 209 Height = 73 + AllowFocus = True Picture.Data = { 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000A60000 0038080600000077E483440000000473424954080808087C0864880000000970 @@ -11879,6 +11882,7 @@ object MainForm: TMainForm Top = 24 Width = 209 Height = 73 + AllowFocus = True Picture.Data = { 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000A60000 0038080600000077E483440000000473424954080808087C0864880000000970 @@ -12116,6 +12120,7 @@ object MainForm: TMainForm Top = 24 Width = 209 Height = 73 + AllowFocus = True Picture.Data = { 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000A60000 0038080600000077E483440000000473424954080808087C0864880000000970 diff --git a/Source/ES.Images.pas b/Source/ES.Images.pas index a70aaf9..a8808f9 100644 --- a/Source/ES.Images.pas +++ b/Source/ES.Images.pas @@ -292,6 +292,7 @@ TEsImageControl = class(TEsBaseLayout) FFrameWidth: TFrameWidth; FFrameColor: TColor; FFrameStyle: TFrameStyle; + FAllowFocus: Boolean; function GetCanvas: TCanvas; function GetImageIndex: TImageIndex; function GetImages: TCustomImageList; @@ -326,12 +327,14 @@ TEsImageControl = class(TEsBaseLayout) procedure CalcContentMargins(var Margins: TContentMargins); override; procedure ImageProxyChange(Sender: TObject); procedure KeyUp(var Key: Word; Shift: TShiftState); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Loaded; override; procedure Paint; override; procedure PaintWindow(DC: HDC); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + function CanFocus: Boolean; override; procedure BeginDraw; procedure EndDraw; procedure RecreateBitmap; @@ -339,6 +342,7 @@ TEsImageControl = class(TEsBaseLayout) published property Align; property AlignWithMargins; + property AllowFocus: Boolean read FAllowFocus write FAllowFocus default False; property Anchors; property AutoSize; property BorderWidth; @@ -393,6 +397,9 @@ TEsImageControl = class(TEsBaseLayout) property OnEndDrag; property OnEnter; property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; property OnGesture; property OnMouseActivate; property OnMouseDown; @@ -555,6 +562,7 @@ TEsCustomVirtualImageControl = class(TEsBaseLayout) FFrameWidth: TFrameWidth; FFrameColor: TColor; FFrameStyle: TFrameStyle; + FAllowFocus: Boolean; function GetImageCollection: TCustomImageCollection; function GetImageHeight: Integer; function GetImageIndex: TImageIndex; @@ -583,10 +591,12 @@ TEsCustomVirtualImageControl = class(TEsBaseLayout) procedure ChangeScale(M, D: Integer; isDpiChange: Boolean); override; procedure ImageProxyChange(Sender: TObject); procedure KeyUp(var Key: Word; Shift: TShiftState); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure Paint; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; + function CanFocus: Boolean; override; property FrameColor: TColor read FFrameColor write SetFrameColor default clBtnShadow; property FrameStyle: TFrameStyle read FFrameStyle write SetFrameStyle default TExFrameStyle.None; property FrameWidth: TFrameWidth read FFrameWidth write SetFrameWidth default 1; @@ -608,11 +618,13 @@ TEsCustomVirtualImageControl = class(TEsBaseLayout) property Opacity: Byte read GetOpacity write SetOpacity default 255; /// Image location property Stretch: TImageStretch read GetStretch write SetStretch default TImageStretch.Fit; + property AllowFocus: Boolean read FAllowFocus write FAllowFocus default False; end; TEsVirtualImageControl = class(TEsCustomVirtualImageControl) property Align; property AlignWithMargins; + property AllowFocus; property Anchors; property BorderWidth; property Color default clBtnFace; @@ -662,6 +674,9 @@ TEsVirtualImageControl = class(TEsCustomVirtualImageControl) property OnEndDrag; property OnEnter; property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; property OnGesture; property OnMouseActivate; property OnMouseDown; @@ -1491,6 +1506,11 @@ function TEsImageControl.CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; NewHeight := ImageProxy.ImageHeight + ContentMargins.Height; end; +function TEsImageControl.CanFocus: Boolean; +begin + Result := AllowFocus and Inherited; +end; + function TEsImageControl.GetOpacity: Byte; begin Result := ImageProxy.Opacity; @@ -1592,10 +1612,20 @@ function TEsImageControl.IsImageNameStored: Boolean; procedure TEsImageControl.KeyUp(var Key: Word; Shift: TShiftState); begin inherited; - if (Key = VK_SPACE) or (Key = VK_RETURN) then + if (Key = VK_SPACE) {or (Key = VK_RETURN)} then Click; end; +procedure TEsImageControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + inherited; + + if (Button = mbLeft) and Enabled and AllowFocus then + begin + Winapi.Windows.SetFocus(Handle); + end; +end; + procedure TEsImageControl.Loaded; begin inherited; @@ -2287,6 +2317,11 @@ procedure TEsCustomVirtualImageControl.CalcContentMargins( end; end; +function TEsCustomVirtualImageControl.CanFocus: Boolean; +begin + Result := AllowFocus and Inherited; +end; + {$IFDEF VER310UP} procedure TEsCustomVirtualImageControl.ChangeScale(M, D: Integer; isDpiChange: Boolean); begin @@ -2356,10 +2391,20 @@ function TEsCustomVirtualImageControl.IsImageNameStored: Boolean; procedure TEsCustomVirtualImageControl.KeyUp(var Key: Word; Shift: TShiftState); begin inherited; - if (Key = VK_SPACE) or (Key = VK_RETURN) then + if (Key = VK_SPACE) {or (Key = VK_RETURN)} then Click; end; +procedure TEsCustomVirtualImageControl.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + inherited; + + if (Button = mbLeft) and Enabled and AllowFocus then + begin + Winapi.Windows.SetFocus(Handle); + end; +end; + procedure TEsCustomVirtualImageControl.Paint; begin if (csDesigning in ComponentState) and IsDrawHelper and diff --git a/Source/ES.PaintBox.pas b/Source/ES.PaintBox.pas index e9b34ba..f611511 100644 --- a/Source/ES.PaintBox.pas +++ b/Source/ES.PaintBox.pas @@ -45,6 +45,8 @@ TEsPaintBox = class(TEsCustomControl) property ParentShowHint; property PopupMenu; property ShowHint; + property TabOrder; + property TabStop; property Touch; property Visible; property OnCanResize; @@ -56,6 +58,11 @@ TEsPaintBox = class(TEsCustomControl) property OnEndDock; property OnEndDrag; property OnGesture; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; property OnMouseActivate; property OnMouseDown; property OnMouseEnter;