Skip to content

Commit

Permalink
- Allow localization of clNone and clDefault color names in TSpTBXCol…
Browse files Browse the repository at this point in the history
…orEdit

- Fixed MDI button high DPI scaling issues.
  • Loading branch information
SilverpointDev committed Jan 22, 2020
1 parent 07f7b33 commit e5d9f27
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
8 changes: 8 additions & 0 deletions Release History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
22 January 2020 - version 2.5.6
- Allow localization of clNone and clDefault color names in TSpTBXColorEdit
- Fixed MDI button high DPI scaling issues.
- Fixed TSpTBXEditItem.StartEditing handling, it resets DoneAction to tbdaNone before entering in editing mode.
- Fixed double buffer painting on TTBCustomDockableWindow.WMMove
- Fixed incorrect MDI button painting.
- Fixed incorrect Caption painting on TSpTBXPanel when Font color is changed.

26 November 2018 - version 2.5.5
- Added RAD Studio 10.3 Rio support.
- Added TB2K patch files
Expand Down
8 changes: 4 additions & 4 deletions Source/SpTBXColorPickerForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ procedure SpScreenShotMagnify(DestCanvas: TCanvas; DestR: TRect; DrawCrosshair:
crSpTBXEyeDropper = 103; // Cursor ID used for Eye Dropper cursor

resourcestring
SSpTBXTransparentColor = 'Transparent Color';
SSpTBXColorPicker = 'Color Picker';
SSpTBXClickAndDrag = 'Drag && Drop';

Expand Down Expand Up @@ -514,10 +513,11 @@ procedure TSpTBXColorPickerForm.SetSelectedColor(AColor: TColor);
procedure TSpTBXColorPickerForm.UpdateColorLabel(AColor: TColor; AButtonType: Integer = -1);
begin
btnColor.CaptionGlowColor := AColor;
if AColor = clNone then
btnLabel.Caption := SSpTBXTransparentColor
if AColor = clNone then btnLabel.Caption := SSpTBXColorNone
else
btnLabel.Caption := SpColorToHTML(AColor);
if AColor = clDefault then btnLabel.Caption := SSpTBXColorDefault
else
btnLabel.Caption := SpColorToHTML(AColor);
end;

end.
5 changes: 1 addition & 4 deletions Source/SpTBXExtEditors.pas
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,7 @@ procedure TSpTBXColorEdit.SetSelectedFormat(const Value: TSpTBXColorTextType);

procedure TSpTBXColorEdit.UpdateTextFromValue;
begin
if (SelectedColor = clNone) or (SelectedColor = clDefault) then
Text := ColorToString(SelectedColor)
else
Text := SpColorToString(SelectedColor, FSelectedFormat);
Text := SpColorToString(SelectedColor, FSelectedFormat);
SelStart := Length(Text);
end;

Expand Down
2 changes: 1 addition & 1 deletion Source/SpTBXItem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9855,7 +9855,7 @@ procedure InitializeStock;

// Dummy ImageList, used by TSpTBXItemViewer and TSpTBXButtonOptions
MDIButtonsImgList := TImageList.Create(nil);
MDIButtonsImgList.SetSize(8, 8);
MDIButtonsImgList.SetSize(SpDPIScale(8), SpDPIScale(8));

{$IF CompilerVersion >= 23}
// XE2 and up
Expand Down
2 changes: 1 addition & 1 deletion Source/SpTBXMDIMRU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ constructor TSpTBXMDIButtonsItem.Create(AOwner: TComponent);
A.ItemStyle := A.ItemStyle + [tbisRightAlign];
Result.Images := MDIButtonsImgList;
Result.ImageIndex := ImageIndex;
Result.CustomWidth := 17;
Result.CustomWidth := SpDPIScale(17);
Result.OnClick := ItemClick;
Result.OnDrawItem := DrawItem;
Result.OnDrawImage := DrawItemImage;
Expand Down
26 changes: 24 additions & 2 deletions Source/SpTBXSkins.pas
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ interface
{$IFEND}
Themes, Generics.Collections;

resourcestring
SSpTBXColorNone = 'None';
SSpTBXColorDefault = 'Default';

const
WM_SPSKINCHANGE = WM_APP + 2007; // Skin change notification message

Expand Down Expand Up @@ -265,7 +269,7 @@ TSpTBXMenuItemInfo = record
{ Colors }

TSpTBXColorTextType = (
cttDefault, // Default format (clWhite, $FFFFFF)
cttDefault, // Use color idents (clWhite), if not possible use Delphi format ($FFFFFF)
cttHTML, // HTML format (#FFFFFF)
cttIdentAndHTML // Use color idents (clWhite), if not possible use HTML format
);
Expand Down Expand Up @@ -1301,7 +1305,12 @@ function SpColorToString(const Color: TColor; TextType: TSpTBXColorTextType = ct
cttDefault:
Result := ColorToString(Color);
cttHTML:
Result := SpColorToHTML(Color);
// Use resourcestring only when clNone or clDefault
if Color = clNone then Result := SSpTBXColorNone
else
if Color = clDefault then Result := SSpTBXColorDefault
else
Result := SpColorToHTML(Color);
cttIdentAndHTML:
begin
Result := ColorToString(Color);
Expand All @@ -1320,6 +1329,19 @@ function SpStringToColor(S: string; out Color: TColor): Boolean;
L := Length(S);
if L < 2 then Exit;

// Try to convert clNone and clDefault resourcestring
if S = SSpTBXColorNone then begin
Color := clNone;
Result := True;
Exit;
end
else
if S = SSpTBXColorDefault then begin
Color := clDefault;
Result := True;
Exit;
end;

if (S[1] = '#') and (L = 7) then begin // HTML format: #FFFFFF
S[1] := '$';
if TryStrToInt(S, C) then begin
Expand Down

0 comments on commit e5d9f27

Please sign in to comment.