mirror of https://gitlab.com/basile.b/dexed.git
display greyed toobar image when tblbtn not enabled
This commit is contained in:
parent
1b5076f959
commit
7fe1d76ea6
|
|
@ -15,7 +15,7 @@ uses
|
||||||
{$IFNDEF CEBUILD}
|
{$IFNDEF CEBUILD}
|
||||||
forms,
|
forms,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
process, asyncprocess, fgl;
|
process, asyncprocess;
|
||||||
|
|
||||||
const
|
const
|
||||||
exeExt = {$IFDEF WINDOWS} '.exe' {$ELSE} '' {$ENDIF};
|
exeExt = {$IFDEF WINDOWS} '.exe' {$ELSE} '' {$ENDIF};
|
||||||
|
|
@ -25,8 +25,6 @@ const
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
TIntByString = class(specialize TFPGMap<string, integer>);
|
|
||||||
|
|
||||||
TIndentationMode = (imSpaces, imTabs);
|
TIndentationMode = (imSpaces, imTabs);
|
||||||
|
|
||||||
TCECompiler = (dmd, gdc, ldc);
|
TCECompiler = (dmd, gdc, ldc);
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ type
|
||||||
fResourceName: string;
|
fResourceName: string;
|
||||||
fScaledSeparator: boolean;
|
fScaledSeparator: boolean;
|
||||||
fPng: TPortableNetworkGraphic;
|
fPng: TPortableNetworkGraphic;
|
||||||
|
fDPng: TPortableNetworkGraphic;
|
||||||
procedure setResourceName(const value: string);
|
procedure setResourceName(const value: string);
|
||||||
procedure setScaledSeparator(value: boolean);
|
procedure setScaledSeparator(value: boolean);
|
||||||
procedure setToolBar(value: TToolbar);
|
procedure setToolBar(value: TToolbar);
|
||||||
protected
|
protected
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
|
procedure SetEnabled(Value: Boolean); override;
|
||||||
published
|
published
|
||||||
property resourceName: string read fResourceName write setResourceName;
|
property resourceName: string read fResourceName write setResourceName;
|
||||||
property scaledSeparator: boolean read fScaledSeparator write setScaledSeparator;
|
property scaledSeparator: boolean read fScaledSeparator write setScaledSeparator;
|
||||||
|
|
@ -61,12 +63,15 @@ constructor TCEToolButton.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
fPng := TPortableNetworkGraphic.Create;
|
fPng := TPortableNetworkGraphic.Create;
|
||||||
|
fDPng := TPortableNetworkGraphic.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCEToolButton.Destroy;
|
destructor TCEToolButton.Destroy;
|
||||||
begin
|
begin
|
||||||
fPng.FreeImage;
|
fPng.FreeImage;
|
||||||
fPng.Free;
|
fPng.Free;
|
||||||
|
fDPng.FreeImage;
|
||||||
|
fDPng.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -76,6 +81,10 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEToolButton.setResourceName(const value: string);
|
procedure TCEToolButton.setResourceName(const value: string);
|
||||||
|
var
|
||||||
|
i,j:integer;
|
||||||
|
px: PRGBAQuad;
|
||||||
|
gr: byte;
|
||||||
begin
|
begin
|
||||||
if fResourceName = value then
|
if fResourceName = value then
|
||||||
exit;
|
exit;
|
||||||
|
|
@ -86,8 +95,25 @@ begin
|
||||||
begin
|
begin
|
||||||
fPng.FreeImage;
|
fPng.FreeImage;
|
||||||
fPng.LoadFromResourceName(HINSTANCE, fResourceName);
|
fPng.LoadFromResourceName(HINSTANCE, fResourceName);
|
||||||
|
fDPng.FreeImage;
|
||||||
|
fDPng.LoadFromResourceName(HINSTANCE, fResourceName);
|
||||||
|
if fDpng.PixelFormat = pf32bit then for i:= 0 to fDPng.Height-1 do
|
||||||
|
begin
|
||||||
|
{$PUSH}{$HINTS OFF}{$WARNINGS OFF}{$R-}
|
||||||
|
px := PRGBAQuad(fDPng.ScanLine[i]);
|
||||||
|
{$POP}
|
||||||
|
for j:= 0 to fDPng.Width-1 do
|
||||||
|
begin
|
||||||
|
gr := (px^.Red div 5) + (px^.Green div 100) * 70 + (px^.Blue div 11);
|
||||||
|
px^.Green:=gr;
|
||||||
|
px^.Blue:=gr;
|
||||||
|
px^.Red:=gr;
|
||||||
|
px += 1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
FToolBar.Repaint;
|
if assigned(fToolBar) then
|
||||||
|
FToolBar.Repaint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEToolButton.setScaledSeparator(value: boolean);
|
procedure TCEToolButton.setScaledSeparator(value: boolean);
|
||||||
|
|
@ -98,6 +124,16 @@ begin
|
||||||
// store ratio if true
|
// store ratio if true
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCEToolButton.SetEnabled(Value: Boolean);
|
||||||
|
var
|
||||||
|
old: boolean;
|
||||||
|
begin
|
||||||
|
old := Enabled;
|
||||||
|
inherited;
|
||||||
|
if (old <> Enabled) and assigned(fToolBar) then
|
||||||
|
FToolBar.Repaint;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCEToolButton.Paint;
|
procedure TCEToolButton.Paint;
|
||||||
var
|
var
|
||||||
rc: TRect;
|
rc: TRect;
|
||||||
|
|
@ -109,7 +145,10 @@ begin
|
||||||
rc := ClientRect;
|
rc := ClientRect;
|
||||||
x := ((rc.Right - rc.Left) - fPng.width) div 2;
|
x := ((rc.Right - rc.Left) - fPng.width) div 2;
|
||||||
y := ((rc.Bottom - rc.Top) - fPng.Height) div 2;
|
y := ((rc.Bottom - rc.Top) - fPng.Height) div 2;
|
||||||
Canvas.Draw(x, y, fPng);
|
if Enabled then
|
||||||
|
Canvas.Draw(x, y, fPng)
|
||||||
|
else
|
||||||
|
Canvas.Draw(x, y, fDPng);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue