mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 13:58:04 +02:00
Tools/icons_to_html: Updated version by Roland Hahn allowing to check the images also on dark background.
This commit is contained in:
parent
af4d73a918
commit
9fd15edd81
@ -7,9 +7,9 @@
|
||||
body {font-family: sans-serif; font-size: 16px; font-weight: 400; margin: 0 auto; padding: 30px 0px 80px 0px; background-color: #ffffff; color: #000000;}
|
||||
td.topleft {border-bottom: 5px solid #ddd; padding: 15px; text-align: left; background-color: #ffffe0;}
|
||||
td.topcenter {border-bottom: 5px solid #ddd; padding: 15px; text-align: center; background-color: #ffffe0;}
|
||||
.info_container {margin: 0 auto; width: 500px; background-color: #f7f7f7; box-shadow: 0px 0px 5px 3px rgba(192, 192, 192, 0.37); padding: 15px; margin-top: 30px;}
|
||||
table {border-collapse: collapse; margin-left: auto; margin-right: auto;}
|
||||
td {border-bottom: 1px solid #ddd; padding: 15px; text-align: left;}
|
||||
.info_container {margin: 0 auto; width: 500px; background-color: #f7f7f7; box-shadow: 0px 0px 5px 3px rgba(192, 192, 192, 0.37); padding: 15px; margin-top: 30px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
@ -1,7 +1,7 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 1163
|
||||
Left = 450
|
||||
Height = 515
|
||||
Top = 323
|
||||
Top = 214
|
||||
Width = 600
|
||||
Caption = 'IconTable'
|
||||
ClientHeight = 515
|
||||
@ -29,7 +29,7 @@ object MainForm: TMainForm
|
||||
Default = True
|
||||
Enabled = False
|
||||
OnClick = btnCreateHTMLClick
|
||||
TabOrder = 2
|
||||
TabOrder = 3
|
||||
end
|
||||
object DirectoryEdit: TDirectoryEdit
|
||||
AnchorSideLeft.Control = Owner
|
||||
@ -68,7 +68,7 @@ object MainForm: TMainForm
|
||||
Caption = 'Save'
|
||||
Enabled = False
|
||||
OnClick = btnSaveClick
|
||||
TabOrder = 3
|
||||
TabOrder = 4
|
||||
end
|
||||
object btnClose: TButton
|
||||
AnchorSideRight.Control = Owner
|
||||
@ -87,7 +87,7 @@ object MainForm: TMainForm
|
||||
Cancel = True
|
||||
Caption = 'Close'
|
||||
OnClick = btnCloseClick
|
||||
TabOrder = 5
|
||||
TabOrder = 6
|
||||
end
|
||||
inline SynEdit: TSynEdit
|
||||
AnchorSideLeft.Control = Owner
|
||||
@ -614,7 +614,18 @@ object MainForm: TMainForm
|
||||
Caption = 'Show'
|
||||
Enabled = False
|
||||
OnClick = btnShowClick
|
||||
TabOrder = 4
|
||||
TabOrder = 5
|
||||
end
|
||||
object cbDarkMode: TCheckBox
|
||||
AnchorSideTop.Control = btnCreateHTML
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 24
|
||||
Height = 19
|
||||
Top = 483
|
||||
Width = 76
|
||||
Caption = 'Dark Mode'
|
||||
OnChange = cbDarkModeChange
|
||||
TabOrder = 2
|
||||
end
|
||||
object TaskDialog: TTaskDialog
|
||||
Buttons = <>
|
||||
|
@ -17,10 +17,12 @@ type
|
||||
btnSave: TButton;
|
||||
btnShow: TButton;
|
||||
btnClose: TButton;
|
||||
cbDarkMode: TCheckBox;
|
||||
DirectoryEdit: TDirectoryEdit;
|
||||
SynEdit: TSynEdit;
|
||||
SynHTMLSyn: TSynHTMLSyn;
|
||||
TaskDialog: TTaskDialog;
|
||||
procedure cbDarkModeChange(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure DirectoryEditChange(Sender: TObject);
|
||||
procedure btnCreateHTMLClick(Sender: TObject);
|
||||
@ -28,7 +30,9 @@ type
|
||||
procedure btnShowClick(Sender: TObject);
|
||||
procedure btnCloseClick(Sender: TObject);
|
||||
private
|
||||
FLazImgDir: String;
|
||||
procedure ErrorMsg(const AMsg: String);
|
||||
function GetDestFileName: String;
|
||||
procedure InfoMsg(const AMsg: String);
|
||||
public
|
||||
|
||||
@ -45,12 +49,19 @@ implementation
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if DirectoryExists(CleanAndExpandDirectory('../../images/general_purpose/')) then
|
||||
DirectoryEdit.Text := CleanAndExpandDirectory('../../images/general_purpose/')
|
||||
FLazImgDir := CleanAndExpandDirectory('../../images/general_purpose/');
|
||||
if DirectoryExists(FLazImgDir) then
|
||||
DirectoryEdit.Text := FLazImgDir
|
||||
else
|
||||
DirectoryEdit.Text := CleanAndExpandDirectory(GetCurrentDir);
|
||||
end;
|
||||
|
||||
procedure TMainForm.cbDarkModeChange(Sender: TObject);
|
||||
begin
|
||||
btnSave.Enabled := false;
|
||||
btnShow.Enabled := false;
|
||||
end;
|
||||
|
||||
procedure TMainForm.DirectoryEditChange(Sender: TObject);
|
||||
begin
|
||||
btnCreateHTML.Enabled := (DirectoryEdit.Text <> '') and DirectoryExists(DirectoryEdit.Text);
|
||||
@ -125,12 +136,22 @@ begin
|
||||
SynEdit.Lines.Add('<title>Icons</title>');
|
||||
SynEdit.Lines.Add('<meta charset="UTF-8">');
|
||||
SynEdit.Lines.Add('<style media="all">');
|
||||
SynEdit.Lines.Add(' body {font-family: sans-serif; font-size: 16px; font-weight: 400; margin: 0 auto; padding: 30px 0px 80px 0px;}');
|
||||
if cbDarkMode.Checked then
|
||||
begin
|
||||
SynEdit.Lines.Add(' body {font-family: sans-serif; font-size: 16px; font-weight: 400; margin: 0 auto; padding: 30px 0px 80px 0px; background-color: #303030; color: #ffffff;}');
|
||||
SynEdit.Lines.Add(' td.topleft {border-bottom: 5px solid #ddd; padding: 15px; text-align: left; background-color: #000000;}');
|
||||
SynEdit.Lines.Add(' td.topcenter {border-bottom: 5px solid #ddd; padding: 15px; text-align: center; background-color: #000000;}');
|
||||
SynEdit.Lines.Add(' .info_container {margin: 0 auto; width: 500px; background-color: #000000; box-shadow: 0px 0px 5px 3px rgba(192, 192, 192, 0.37); padding: 15px; margin-top: 30px;}');
|
||||
end
|
||||
else
|
||||
begin
|
||||
SynEdit.Lines.Add(' body {font-family: sans-serif; font-size: 16px; font-weight: 400; margin: 0 auto; padding: 30px 0px 80px 0px; background-color: #ffffff; color: #000000;}');
|
||||
SynEdit.Lines.Add(' td.topleft {border-bottom: 5px solid #ddd; padding: 15px; text-align: left; background-color: #ffffe0;}');
|
||||
SynEdit.Lines.Add(' td.topcenter {border-bottom: 5px solid #ddd; padding: 15px; text-align: center; background-color: #ffffe0;}');
|
||||
SynEdit.Lines.Add(' .info_container {margin: 0 auto; width: 500px; background-color: #f7f7f7; box-shadow: 0px 0px 5px 3px rgba(192, 192, 192, 0.37); padding: 15px; margin-top: 30px;}');
|
||||
end;
|
||||
SynEdit.Lines.Add(' table {border-collapse: collapse; margin-left: auto; margin-right: auto;}');
|
||||
SynEdit.Lines.Add(' td {border-bottom: 1px solid #ddd; padding: 15px; text-align: left;}');
|
||||
SynEdit.Lines.Add(' td.topleft {border-bottom: 5px solid #ddd; padding: 15px; text-align: left; background-color: #ffffe0;}');
|
||||
SynEdit.Lines.Add(' td.topcenter {border-bottom: 5px solid #ddd; padding: 15px; text-align: center; background-color: #ffffe0;}');
|
||||
SynEdit.Lines.Add(' .info_container {margin: 0 auto; width: 500px; background-color: #f7f7f7; box-shadow: 0px 0px 5px 3px rgba(192, 192, 192, 0.37); padding: 15px; margin-top: 30px;}');
|
||||
SynEdit.Lines.Add('</style>');
|
||||
SynEdit.Lines.Add('</head>');
|
||||
SynEdit.Lines.Add('<body>');
|
||||
@ -165,7 +186,7 @@ begin
|
||||
|
||||
SynEdit.Lines.Add('</table>');
|
||||
|
||||
if RightStr(DirectoryEdit.Text, 16) = 'general_purpose' + PathDelim then
|
||||
if DirectoryEdit.Text = FLazImgDir then
|
||||
begin
|
||||
SynEdit.Lines.Add('<div class="info_container">');
|
||||
SynEdit.Lines.Add('The images in this folder can be used in Lazarus applications as toolbar or button icons.<br><br>');
|
||||
@ -182,10 +203,10 @@ begin
|
||||
|
||||
SynEdit.Lines.Add('</body>');
|
||||
SynEdit.Lines.Add('</html>');
|
||||
|
||||
btnSave.Enabled := true;
|
||||
|
||||
btnSave.Enabled := True;
|
||||
btnSave.SetFocus;
|
||||
btnShow.Enabled := false;
|
||||
btnShow.Enabled := False;
|
||||
finally
|
||||
AllFileList.Free;
|
||||
IcoFileList.Free;
|
||||
@ -199,13 +220,13 @@ end;
|
||||
|
||||
procedure TMainForm.btnSaveClick(Sender: TObject);
|
||||
var
|
||||
fn: String = '';
|
||||
fn: String;
|
||||
begin
|
||||
fn := AppendPathDelim(DirectoryEdit.Text) + 'IconTable.html';
|
||||
fn := GetDestFileName;
|
||||
try
|
||||
SynEdit.Lines.SaveToFile(fn);
|
||||
InfoMsg('Saved as: ' + fn);
|
||||
btnShow.Enabled := true;
|
||||
btnShow.Enabled := True;
|
||||
btnShow.SetFocus;
|
||||
except
|
||||
ErrorMsg('The file could not be saved as: ' + fn);
|
||||
@ -214,9 +235,9 @@ end;
|
||||
|
||||
procedure TMainForm.btnShowClick(Sender: TObject);
|
||||
var
|
||||
fn: String = '';
|
||||
fn: String;
|
||||
begin
|
||||
fn := AppendPathDelim(DirectoryEdit.Text) + 'IconTable.html';
|
||||
fn := GetDestFileName;
|
||||
if FileExists(fn) then
|
||||
OpenURL(fn);
|
||||
btnClose.SetFocus;
|
||||
@ -238,6 +259,11 @@ begin
|
||||
TaskDialog.Execute;
|
||||
end;
|
||||
|
||||
function TMainForm.GetDestFileName: String;
|
||||
begin
|
||||
Result := AppendPathDelim(DirectoryEdit.Text) + 'IconTable.html';
|
||||
end;
|
||||
|
||||
procedure TMainForm.InfoMsg(const AMsg: String);
|
||||
begin
|
||||
TaskDialog.Caption := 'Information';
|
||||
|
Loading…
Reference in New Issue
Block a user