jvcllaz: High-DPI palette icons for TAdvLED, TLEDNumber, TStopLighSensor. One more fix for TLEDNumber lcl scaling (still not perfect). one issue left).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7306 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-01-20 16:00:01 +00:00
parent a331e9e33c
commit 31a2ea6284
48 changed files with 101 additions and 112 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

View File

@@ -1,34 +0,0 @@
/* XPM */
static char * LEDBULBOFF[] = {
"15 15 16 1",
" c #000000",
". c #800000",
"+ c #008000",
"@ c #808000",
"# c #000080",
"$ c #800080",
"% c #008080",
"& c #808080",
"* c #C0C0C0",
"= c #FF0000",
"- c #00FF00",
"; c #FFFF00",
"> c #0000FF",
", c #FF00FF",
"' c #00FFFF",
") c #FFFFFF",
"@@@@@@@@@@@@@@@",
"@@@@@@@@@@@@@@@",
"@@@@@@@@@@@@@@@",
"@@@@@@@@@@@@@@@",
"@@@@@@ @@@@@@",
"@@@@@ ))) @@@@@",
"@@@@ ))))) @@@@",
"@@@@ ))&)) @@@@",
"@@@@ ))&)) @@@@",
"@@@@@ )&) @@@@@",
"@@@@@@ ) @@@@@@",
"@@@@@@ ) @@@@@@",
"@@@@@@ @@@@@@",
"@@@@@@ * @@@@@@",
"@@@@@@ @@@@@@"};

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 975 B

View File

@@ -1,34 +0,0 @@
/* XPM */
static char * LEDBULBON[] = {
"15 15 16 1",
" c #000000",
". c #800000",
"+ c #008000",
"@ c #808000",
"# c #000080",
"$ c #800080",
"% c #008080",
"& c #808080",
"* c #C0C0C0",
"= c #FF0000",
"- c #00FF00",
"; c #FFFF00",
"> c #0000FF",
", c #FF00FF",
"' c #00FFFF",
") c #FFFFFF",
"@@@@@@@;@@@@@@@",
"@@@@@@@;@@@@@@@",
"@@;@@;;;;;@@;@@",
"@@@;;;;;;;;;@@@",
"@@@;;; ;;;@@@",
"@@;;; );) ;;;@@",
"@@;; ););) ;;@@",
";;;; ;)&); ;;;;",
"@@;; );&;) ;;@@",
"@@;;; )&) ;;;@@",
"@@@;;; ) ;;;@@@",
"@@@;;; ; ;;;@@@",
"@@;@@; ;@@;@@",
"@@@@@@ * @@@@@@",
"@@@@@@ @@@@@@"};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,9 +1,15 @@
tadvled.png tadvled.png
tadvled_150.png
tadvled_200.png
tanalogsensor.png tanalogsensor.png
tindgnoumeter.png tindgnoumeter.png
tindled.png tindled.png
tlednumber.png tlednumber.png
tlednumber_150.png
tlednumber_200.png
tstoplightsensor.png tstoplightsensor.png
tstoplightsensor_150.png
tstoplightsensor_200.png
ta3naloggauge.png ta3naloggauge.png
ta3naloggauge_150.png ta3naloggauge_150.png
ta3naloggauge_200.png ta3naloggauge_200.png

View File

@@ -1,6 +1,30 @@
black.png black.png
black_150.png
black_200.png
green.png green.png
green_150.png
green_200.png
red.png red.png
red_150.png
red_200.png
yellow.png yellow.png
bulboff.xpm yellow_150.png
bulbon.xpm yellow_200.png
bulboff.png
bulboff_150.png
bulboff_200.png
bulbon.png
bulbon_150.png
bulbon_200.png
greenoff.png
greenoff_150.png
greenoff_200.png
redoff.png
redoff_150.png
redoff_200.png
yellowoff.png
yellowoff_150.png
yellowoff_200.png
bulbdisabled.png
bulbdisabled_150.png
bulbdisabled_200.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -56,6 +56,8 @@ type
protected protected
FlipFLop : Boolean; FlipFLop : Boolean;
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
procedure DoChange(AState: TLedState); dynamic; procedure DoChange(AState: TLedState); dynamic;
procedure Loaded; override; procedure Loaded; override;
public public
@@ -181,16 +183,17 @@ begin
inherited; inherited;
if FKind <> lkCustom then if FKind <> lkCustom then
BitmapNeeded; BitmapNeeded;
{ end;
Try procedure TAdvLed.DoAutoAdjustLayout(
If (csDesigning in ComponentState) Then Exit ; const AMode: TLayoutAdjustmentPolicy;
// Load Bitmap if necessary const AXProportion, AYProportion: Double);
BitmapNeeded; begin
Finally inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
inherited Loaded; if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
End; begin
} BitmapNeeded;
end;
end; end;
// timer // timer
@@ -231,14 +234,22 @@ const
DisabledBitmaps: array[TLedKind] of string = ('LEDREDOFF', 'LEDGREENOFF', DisabledBitmaps: array[TLedKind] of string = ('LEDREDOFF', 'LEDGREENOFF',
'LEDBLUEOFF', 'LEDYELLOWOFF', 'LEDPURPLEOFF', 'LEDBULBOFF' ,''); } 'LEDBLUEOFF', 'LEDYELLOWOFF', 'LEDPURPLEOFF', 'LEDBULBOFF' ,''); }
OnBitmaps: array[TLedKind] of string = ('RED', 'GREEN', 'YELLOW', 'BULBON', ''); OnBitmaps: array[TLedKind] of string = ('RED', 'GREEN', 'YELLOW', 'BULBON', '');
OffBitmaps: array[TLedKind] of string = ('BLACK', 'BLACK', 'BLACK','BULBOFF', ''); OffBitmaps: array[TLedKind] of string = ('REDOFF', 'GREENOFF', 'YELLOWOFF','BULBOFF', '');
DisabledBitmaps: array[TLedKind] of string = ('BLACK', 'BLACK', 'BLACK','BULBOFF' ,''); DisabledBitmaps: array[TLedKind] of string = ('BLACK', 'BLACK', 'BLACK','BULBDISABLED' ,'');
var
resName: String;
begin begin
if LedKind <> lkCustom then if LedKind <> lkCustom then
begin begin
FGlyphs[lsOn].LoadFromResourceName(HInstance, OnBitmaps[LedKind]); if Font.PixelsPerInch >=168 then
FGlyphs[lsOff].LoadFromResourceName(HInstance, OffBitmaps[LedKind]); resName := '_200'
FGlyphs[lsDisabled].LoadFromResourceName(HInstance, DisabledBitmaps[LedKind]); else if Font.PixelsPerInch >= 120 then
resName := '_150'
else
resName := '';
FGlyphs[lsOn].LoadFromResourceName(HInstance, OnBitmaps[LedKind] + resName);
FGlyphs[lsOff].LoadFromResourceName(HInstance, OffBitmaps[LedKind] + resName);
FGlyphs[lsDisabled].LoadFromResourceName(HInstance, DisabledBitmaps[LedKind] + resName);
end; end;
end; end;

View File

@@ -49,12 +49,14 @@ type
FScaleFactor: Double; FScaleFactor: Double;
procedure SetBorderStyle(AValue: TLedNumberBorderStyle); procedure SetBorderStyle(AValue: TLedNumberBorderStyle);
procedure SetTransparent(AValue: boolean); procedure SetTransparent(AValue: boolean);
procedure SetZeroToO(AValue: Boolean);
protected{private} protected{private}
FBgColor : TColor; FBgColor : TColor;
FOffColor : TColor; FOffColor : TColor;
FOnColor : TColor; FOnColor : TColor;
FColumns : Integer; FColumns : Integer;
FRows : Integer; FRows : Integer;
FZeroToO : Boolean;
FSize : TSegmentSize; FSize : TSegmentSize;
FSlantAngle: Integer; FSlantAngle: Integer;
FSlanted : Boolean; FSlanted : Boolean;
@@ -69,6 +71,7 @@ type
procedure PaintSegment(Segment: Integer; TheColor: TColor; procedure PaintSegment(Segment: Integer; TheColor: TColor;
Points: array of TPoint; OffsetX, OffsetY: Integer); Points: array of TPoint; OffsetX, OffsetY: Integer);
procedure ResizeControl(Row, Col, ASize: Integer); procedure ResizeControl(Row, Col, ASize: Integer);
procedure SetParent(NewParent: TWinControl); override;
function GetAbout: string; function GetAbout: string;
function GetSlantAngle: Double; function GetSlantAngle: Double;
procedure SetAbout(const {%H-}Value: string); procedure SetAbout(const {%H-}Value: string);
@@ -79,7 +82,7 @@ type
procedure SetOffColor(Value: TColor); procedure SetOffColor(Value: TColor);
procedure SetRows(Value: Integer); procedure SetRows(Value: Integer);
procedure SetColumns(Value: Integer); procedure SetColumns(Value: Integer);
procedure SetbgColor(Value: TColor); procedure SetBGColor(Value: TColor);
procedure SelectSegments(Segment: Word; Points: array of TPoint; procedure SelectSegments(Segment: Word; Points: array of TPoint;
OffsetX, OffsetY: Integer); OffsetX, OffsetY: Integer);
protected protected
@@ -96,6 +99,7 @@ type
property SlantAngle: Integer read FSlantAngle write SetSlantAngle default 5; property SlantAngle: Integer read FSlantAngle write SetSlantAngle default 5;
property Slanted: Boolean read FSlanted write SetSlanted default false; property Slanted: Boolean read FSlanted write SetSlanted default false;
property Transparent: boolean read FTransparent write SetTransparent default false; {Draws segments with transparent background.BgColor is used as mask color.} property Transparent: boolean read FTransparent write SetTransparent default false; {Draws segments with transparent background.BgColor is used as mask color.}
property ZeroToO: Boolean read FZeroToO write SetZeroToO default false;
public public
constructor Create(AOwner:TComponent); override; constructor Create(AOwner:TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@@ -104,6 +108,7 @@ type
TLEDNumber = class(TCustomLEDNumber) TLEDNumber = class(TCustomLEDNumber)
published published
property Version; property Version;
property BorderSpacing;
property BorderStyle; property BorderStyle;
property Caption; property Caption;
property Columns; property Columns;
@@ -127,6 +132,7 @@ type
property Slanted; property Slanted;
property Transparent; property Transparent;
property Visible; property Visible;
property ZeroToO;
end; end;
@@ -235,6 +241,10 @@ const
44, 0, 45, 0, 0, 0, 0, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 44, 0, 45, 0, 0, 0, 0, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44); 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44);
const
BASE_WIDTH = 17;
BASE_HEIGHT = 30;
{===== TCustomLEDNumber ============================================} {===== TCustomLEDNumber ============================================}
@@ -249,14 +259,15 @@ begin
csSetCaption, csSetCaption,
csClickEvents, csClickEvents,
csDoubleClicks]; csDoubleClicks];
Width := 170; FRows := 1;
Height := 30; FColumns := 10;
Width := FColumns * BASE_WIDTH;
Height := FRows * BASE_HEIGHT;
FOnColor := clLime; FOnColor := clLime;
FOffColor := $000E3432; FOffColor := $000E3432;
FBgColor := clBlack; FBgColor := clBlack;
FSize := 2; FSize := 2;
FRows := 1;
FColumns := 10;
FSlantAngle := 5; FSlantAngle := 5;
Caption := 'LED-LABEL'; Caption := 'LED-LABEL';
lbDrawBmp := TBitmap.Create; lbDrawBmp := TBitmap.Create;
@@ -292,6 +303,13 @@ begin
Invalidate; Invalidate;
end; end;
procedure TCustomLEDNumber.SetZeroToO(AValue: Boolean);
begin
if FZeroToO = AValue then Exit;
FZeroToO := AValue;
Invalidate;
end;
procedure TCustomLEDNumber.SetBorderStyle(AValue: TLedNumberBorderStyle); procedure TCustomLEDNumber.SetBorderStyle(AValue: TLedNumberBorderStyle);
begin begin
if FBorderStyle=AValue then Exit; if FBorderStyle=AValue then Exit;
@@ -312,8 +330,6 @@ procedure TCustomLEDNumber.DoAutoAdjustLayout(
begin begin
inherited; inherited;
FScalefactor := Font.PixelsPerInch / 96; FScalefactor := Font.PixelsPerInch / 96;
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
FScaleFactor *= Max(AXProportion, AYProportion)
end; end;
procedure TCustomLEDNumber.SlantPoint(var P: TPoint; procedure TCustomLEDNumber.SlantPoint(var P: TPoint;
@@ -336,7 +352,7 @@ begin
if FSlanted and (FSlantAngle <> 0) then if FSlanted and (FSlantAngle <> 0) then
begin begin
tanAlpha := tan(GetSlantAngle); tanAlpha := tan(GetSlantAngle);
baseY := round(FScaleFactor * 30 * (FSize - 1)); baseY := round(FScaleFactor * BASE_HEIGHT * (FSize - 1));
for i := 0 to MAX_POINTS do for i := 0 to MAX_POINTS do
SlantPoint(Points[i], baseY, tanAlpha); SlantPoint(Points[i], baseY, tanAlpha);
end; end;
@@ -346,9 +362,9 @@ end;
function TCustomLEDNumber.NewOffset(xOry: char; OldOffset: Integer): Integer; function TCustomLEDNumber.NewOffset(xOry: char; OldOffset: Integer): Integer;
begin begin
if (xOry = 'x')then if (xOry = 'x')then
Result := oldOffset + round(FScaleFactor * 17 * (FSize - 1)) Result := oldOffset + round(FScaleFactor * BASE_WIDTH * (FSize - 1))
else else
Result := oldOffset + round(FScaleFactor * 30 * (FSize - 1)); Result := oldOffset + round(FScaleFactor * BASE_HEIGHT * (FSize - 1));
end; end;
{=====} {=====}
@@ -415,8 +431,8 @@ var
begin begin
if (Segment and $FFFF) = $FFFF then begin if (Segment and $FFFF) = $FFFF then begin
MyColor := FOnColor; MyColor := FOnColor;
PaintSegment(17, MyColor, Points, OffsetX, OffsetY); PaintSegment(BASE_WIDTH, MyColor, Points, OffsetX, OffsetY);
PaintSegment(18, MyColor, Points, OffsetX, OffsetY); PaintSegment(BASE_WIDTH+1, MyColor, Points, OffsetX, OffsetY);
end end
else begin else begin
Bit := $8000; Bit := $8000;
@@ -451,7 +467,6 @@ begin
Last := #0; Last := #0;
OffsetX := FSize; OffsetX := FSize;
OffsetY := 0; OffsetY := 0;
DisplayStr := Caption; DisplayStr := Caption;
if Length(DisplayStr) > 0 then if Length(DisplayStr) > 0 then
@@ -479,12 +494,13 @@ begin
OffsetX := NewOffset('x', OffsetX); OffsetX := NewOffset('x', OffsetX);
end end
else begin else begin
OffsetX := OffsetX - round(FScaleFactor * 17 * (FSize - 1)); OffsetX := OffsetX - round(FScaleFactor * BASE_WIDTH * (FSize - 1));
Tmp := (Characters[CharacterNDX[Ord(Next)]] or Characters[CharacterNDX[Ord(Last)]]); Tmp := (Characters[CharacterNDX[Ord(Next)]] or Characters[CharacterNDX[Ord(Last)]]);
SelectSegments(Tmp, Points, OffsetX, OffsetY); SelectSegments(Tmp, Points, OffsetX, OffsetY);
OffsetX := NewOffset('x', OffsetX); OffsetX := NewOffset('x', OffsetX);
end end
else begin else begin
if FZeroToO and (Next = '0') then Next := 'O';
Tmp := Characters[CharacterNDX[Ord(Next)]]; Tmp := Characters[CharacterNDX[Ord(Next)]];
SelectSegments(Tmp, Points, OffsetX, OffsetY); SelectSegments(Tmp, Points, OffsetX, OffsetY);
OffsetX := NewOffset('x', OffsetX); OffsetX := NewOffset('x', OffsetX);
@@ -546,8 +562,8 @@ begin
FRows := Row; FRows := Row;
FColumns := Col; FColumns := Col;
FSize := ASize; FSize := ASize;
h := round(FScaleFactor * FRows * 30 * (FSize - 1)); h := round(FScaleFactor * FRows * BASE_HEIGHT * (FSize - 1));
w := round(FScaleFactor * (FColumns * 17 * (FSize - 1))); w := round(FScaleFactor * (FColumns * BASE_WIDTH * (FSize - 1)));
if FSlanted and (FSlantAngle <> 0) then if FSlanted and (FSlantAngle <> 0) then
inc(w, round(h * tan(GetSlantAngle))); inc(w, round(h * tan(GetSlantAngle)));
SetBounds(Left, Top, w, h); SetBounds(Left, Top, w, h);
@@ -555,10 +571,10 @@ begin
end; end;
{=====} {=====}
procedure TCustomLEDNumber.SetbgColor(Value: TColor); procedure TCustomLEDNumber.SetBGColor(Value: TColor);
begin begin
if FBgColor <> Value then begin if FBGColor <> Value then begin
FBgColor := Value; FBGColor := Value;
Invalidate; Invalidate;
end; end;
end; end;
@@ -580,7 +596,12 @@ begin
Invalidate; Invalidate;
end; end;
end; end;
{=====}
procedure TCustomLEDNumber.SetParent(NewParent: TWinControl);
begin
inherited;
Resizecontrol(FRows, FColumns, FSize);
end;
procedure TCustomLEDNumber.SetRows(Value : Integer); procedure TCustomLEDNumber.SetRows(Value : Integer);
begin begin

View File

@@ -265,14 +265,9 @@ begin
inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion); inherited DoAutoAdjustLayout(AMode, AXProportion, AYProportion);
if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then if AMode in [lapAutoAdjustWithoutHorizontalScrolling, lapAutoAdjustForDPI] then
begin begin
DisableAutosizing; case Orientation of
try soHorizontal : FButtonSize := Round(FButtonSize * AXProportion);
case Orientation of soVertical : FButtonSize := Round(FButtonSize * AYProportion);
soHorizontal : FButtonSize := Round(FButtonSize * AXProportion);
soVertical : FButtonSize := Round(FButtonSize * AYProportion);
end;
finally
EnableAutoSizing;
end; end;
end; end;
end; end;