From 041636dfcfb03fdcac7143924222e88fd6a37e83 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 5 May 2018 23:13:45 -0300 Subject: [PATCH] Adds click-to-copy functionality for color values (color preview). --- InForm/UiEditor.bas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/InForm/UiEditor.bas b/InForm/UiEditor.bas index 678de0f..a23c712 100644 --- a/InForm/UiEditor.bas +++ b/InForm/UiEditor.bas @@ -140,6 +140,7 @@ DIM SHARED LastKeyPress AS DOUBLE DIM SHARED UiEditorTitle$, Edited AS _BYTE, ZOrderingDialogOpen AS _BYTE DIM SHARED OpenDialogOpen AS _BYTE, OverwriteOldFiles AS _BYTE DIM SHARED RevertEdit AS _BYTE, OldColor AS _UNSIGNED LONG +DIM SHARED ColorPreviewWord$ TYPE newInputBox ID AS LONG @@ -384,6 +385,8 @@ SUB __UI_Click (id AS LONG) b$ = MKI$(Control(id).Value) SendData b$, 18 Edited = True + CASE "COLORPREVIEW" + _CLIPBOARD$ = ColorPreviewWord$ CASE "DISABLED" b$ = MKI$(Control(id).Value) SendData b$, 19 @@ -1636,6 +1639,7 @@ SUB __UI_OnLoad REDIM _PRESERVE InputBox(1 TO i) AS newInputBox ToolTip(FontTB) = "Multiple fonts can be specified by separating them with a question mark (?)." + CHR$(10) + "The first font that can be found/loaded is used." + ToolTip(ColorPreview) = "Click to copy the current color's hex value to the clipboard." 'LoadFontList @@ -5924,23 +5928,26 @@ SUB SendSignal (Value AS INTEGER) END SUB SUB UpdateColorPreview (Attribute AS _BYTE, ForeColor AS _UNSIGNED LONG, BackColor AS _UNSIGNED LONG) - DIM PreviewWord$ _DEST Control(ColorPreview).HelperCanvas _FONT Control(ColorPreview).Font IF Attribute = 5 THEN CLS , BackColor LINE (20, 20)-STEP(_WIDTH - 41, _HEIGHT - 41), ForeColor, B LINE (21, 21)-STEP(_WIDTH - 43, _HEIGHT - 43), ForeColor, B + ColorPreviewWord$ = "#" + MID$(HEX$(ForeColor), 3) + COLOR ForeColor, BackColor + _PRINTSTRING (_WIDTH \ 2 - _PRINTWIDTH(ColorPreviewWord$) \ 2, _HEIGHT \ 2 - _FONTHEIGHT \ 2), ColorPreviewWord$ ELSE CLS , BackColor COLOR ForeColor, BackColor SELECT CASE Attribute CASE 1, 3 - PreviewWord$ = "FG: #" + MID$(HEX$(ForeColor), 3) + ColorPreviewWord$ = "FG: #" + MID$(HEX$(ForeColor), 3) CASE 2, 4 - PreviewWord$ = "BG: #" + MID$(HEX$(BackColor), 3) + ColorPreviewWord$ = "BG: #" + MID$(HEX$(BackColor), 3) END SELECT - _PRINTSTRING (_WIDTH \ 2 - _PRINTWIDTH(PreviewWord$) \ 2, _HEIGHT \ 2 - _FONTHEIGHT \ 2), PreviewWord$ + _PRINTSTRING (_WIDTH \ 2 - _PRINTWIDTH(ColorPreviewWord$) \ 2, _HEIGHT \ 2 - _FONTHEIGHT \ 2), ColorPreviewWord$ + ColorPreviewWord$ = MID$(ColorPreviewWord$, 5) END IF _DEST 0 Control(ColorPreview).Redraw = True 'Force update