From 8c6e9a9f171c15bad90ec5f422e31196167a5efa Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 6 Jan 2017 17:58:20 +0000 Subject: [PATCH] mbColorLib: Make OfficeMoreColorsDialog HighDPI-aware. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5600 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../mbColorLib/OfficeMoreColorsDialog.lfm | 625 ++++++++++++------ .../mbColorLib/OfficeMoreColorsDialog.pas | 207 +++--- 2 files changed, 516 insertions(+), 316 deletions(-) diff --git a/components/mbColorLib/OfficeMoreColorsDialog.lfm b/components/mbColorLib/OfficeMoreColorsDialog.lfm index e6edd3de5..47f15dc9e 100644 --- a/components/mbColorLib/OfficeMoreColorsDialog.lfm +++ b/components/mbColorLib/OfficeMoreColorsDialog.lfm @@ -1,13 +1,12 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin Left = 265 - Height = 325 + Height = 384 Top = 115 - Width = 355 - ActiveControl = OKbtn + Width = 425 BorderIcons = [biSystemMenu] Caption = 'More colors...' - ClientHeight = 325 - ClientWidth = 355 + ClientHeight = 384 + ClientWidth = 425 Constraints.MinHeight = 310 Constraints.MinWidth = 340 Font.Color = clWindowText @@ -17,66 +16,42 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin OnShow = FormShow Position = poMainFormCenter LCLVersion = '1.7' - object Label4: TLabel - AnchorSideLeft.Control = NewSwatch - AnchorSideLeft.Side = asrCenter - AnchorSideBottom.Control = NewSwatch - Left = 290 - Height = 15 - Top = 213 - Width = 24 - Anchors = [akLeft, akBottom] - BorderSpacing.Bottom = 4 - Caption = 'New' - ParentColor = False - end - object LblCurrent: TLabel - AnchorSideLeft.Control = OldSwatch - AnchorSideLeft.Side = asrCenter - AnchorSideTop.Control = OldSwatch - AnchorSideTop.Side = asrBottom - AnchorSideBottom.Control = Owner - AnchorSideBottom.Side = asrBottom - Left = 282 - Height = 15 - Top = 296 - Width = 40 - Anchors = [akLeft, akBottom] - BorderSpacing.Bottom = 14 - Caption = 'Current' - ParentColor = False - end object Pages: TPageControl Left = 6 - Height = 305 + Height = 372 Top = 6 - Width = 251 + Width = 321 ActivePage = Custom - Anchors = [akTop, akLeft, akRight, akBottom] + Align = alClient + BorderSpacing.Around = 6 TabIndex = 1 TabOrder = 0 OnChange = PagesChange OnChanging = PagesChanging object Standard: TTabSheet Caption = 'Standard' - ClientHeight = 277 - ClientWidth = 243 - object Label2: TLabel + ClientHeight = 344 + ClientWidth = 313 + object LblStandardColors: TLabel + AnchorSideLeft.Control = Standard + AnchorSideTop.Control = Standard Left = 6 Height = 15 - Top = 7 + Top = 4 Width = 37 + BorderSpacing.Left = 6 + BorderSpacing.Top = 4 Caption = '&Colors:' FocusControl = Hexa ParentColor = False end object Hexa: THexaColorPicker - AnchorSideTop.Control = Label2 + AnchorSideTop.Control = LblStandardColors AnchorSideTop.Side = asrBottom Left = 0 - Height = 254 - Top = 22 - Width = 240 + Height = 324 + Top = 19 + Width = 310 Anchors = [akTop, akLeft, akRight, akBottom] HintFormat = 'RGB(%r, %g, %b)'#13'Hex: %hex' IntensityText = 'Intensity' @@ -88,119 +63,40 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin end object Custom: TTabSheet Caption = 'Custom' - ClientHeight = 277 - ClientWidth = 243 + ClientHeight = 344 + ClientWidth = 313 ImageIndex = 1 - object Label1: TLabel + object LblCustomColors: TLabel + AnchorSideLeft.Control = Custom + AnchorSideTop.Control = Custom Left = 6 Height = 15 - Top = 7 + Top = 4 Width = 37 + BorderSpacing.Left = 6 + BorderSpacing.Top = 4 Caption = '&Colors:' FocusControl = HSL ParentColor = False end - object Label3: TLabel - Left = 6 - Height = 15 - Top = 171 - Width = 35 - Anchors = [akLeft, akBottom] - Caption = '&Picker:' - FocusControl = cbColorDisplay - ParentColor = False - end - object LRed: TLabel - Left = 6 - Height = 15 - Top = 197 - Width = 23 - Anchors = [akLeft, akBottom] - Caption = '&Red:' - ParentColor = False - end - object LGreen: TLabel - Left = 6 - Height = 15 - Top = 223 - Width = 34 - Anchors = [akLeft, akBottom] - Caption = '&Green:' - ParentColor = False - end - object LBlue: TLabel - Left = 6 - Height = 15 - Top = 249 - Width = 26 - Anchors = [akLeft, akBottom] - Caption = '&Blue:' - ParentColor = False - end - object cbColorDisplay: TComboBox - Left = 48 - Height = 23 - Top = 167 - Width = 147 - Anchors = [akLeft, akBottom] - ItemHeight = 15 - ItemIndex = 0 - Items.Strings = ( - 'HS box, L bar' - 'H ring, SL box' - 'SL box, H bar' - 'RGB trackbars' - ) - OnChange = cbColorDisplayChange - Style = csDropDownList - TabOrder = 1 - Text = 'HS box, L bar' - end - object LHue: TLabel - Left = 120 - Height = 15 - Top = 197 - Width = 25 - Anchors = [akLeft, akBottom] - Caption = '&Hue:' - ParentColor = False - end - object LSat: TLabel - Left = 120 - Height = 15 - Top = 223 - Width = 19 - Anchors = [akLeft, akBottom] - Caption = '&Sat:' - ParentColor = False - end - object LLumVal: TLabel - Left = 120 - Height = 15 - Top = 249 - Width = 27 - Anchors = [akLeft, akBottom] - Caption = 'L&um:' - ParentColor = False - end object PickerNotebook: TNotebook - AnchorSideTop.Control = Label1 + AnchorSideTop.Control = LblCustomColors AnchorSideTop.Side = asrBottom + AnchorSideBottom.Control = Panel1 Left = 6 - Height = 141 - Top = 26 - Width = 232 + Height = 207 + Top = 19 + Width = 302 PageIndex = 0 Anchors = [akTop, akLeft, akRight, akBottom] - BorderSpacing.Top = 4 TabOrder = 0 object nbHSL: TPage object HSL: THSLColorPicker AnchorSideTop.Side = asrBottom Left = 0 - Height = 141 + Height = 207 Top = 0 - Width = 232 + Width = 302 SelectedColor = 460791 Saturation = 241 HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex' @@ -213,13 +109,17 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin end end object nbHSLRing: TPage + OnResize = nbHSLRingResize object HSLRing: THSLRingPicker AnchorSideLeft.Control = nbHSLRing AnchorSideLeft.Side = asrCenter - Left = 42 - Height = 124 + AnchorSideTop.Control = nbHSLRing + AnchorSideBottom.Control = nbHSLRing + AnchorSideBottom.Side = asrBottom + Left = 46 + Height = 204 Top = 0 - Width = 136 + Width = 184 SelectedColor = 14803455 Saturation = 30 Luminance = 240 @@ -236,8 +136,8 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin object Bevel1: TBevel Left = 0 Height = 5 - Top = 127 - Width = 220 + Top = 199 + Width = 277 Align = alBottom Shape = bsSpacer end @@ -245,7 +145,7 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin object nbSLH: TPage object SLH: TSLHColorPicker Left = 0 - Height = 141 + Height = 157 Top = 0 Width = 232 ParentColor = False @@ -264,16 +164,19 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin end object nbRGB: TPage object RTrackbar: TRColorPicker + AnchorSideLeft.Control = LblR + AnchorSideLeft.Side = asrBottom AnchorSideRight.Control = nbRGB AnchorSideRight.Side = asrBottom - Left = 14 + Left = 19 Height = 32 Top = 0 - Width = 218 + Width = 258 SelectedColor = 8026879 Layout = lyHorizontal SelectionIndicator = siRect Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 TabOrder = 0 OnChange = ColorPickerChange Green = 122 @@ -281,18 +184,22 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin HintFormat = 'Red: %value (selected)' end object GTrackbar: TGColorPicker + AnchorSideLeft.Control = RTrackbar + AnchorSideTop.Control = RTrackbar + AnchorSideTop.Side = asrBottom AnchorSideRight.Control = nbRGB AnchorSideRight.Side = asrBottom - Left = 16 + Left = 19 Height = 32 Top = 40 - Width = 216 + Width = 258 SelectedColor = 8060794 BevelInner = bvLowered BevelOuter = bvRaised Layout = lyHorizontal SelectionIndicator = siRect Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 TabOrder = 1 OnChange = ColorPickerChange Red = 122 @@ -300,122 +207,404 @@ object OfficeMoreColorsWin: TOfficeMoreColorsWin HintFormat = 'Green: %value (selected)' end object BTrackbar: TBColorPicker + AnchorSideLeft.Control = RTrackbar + AnchorSideTop.Control = GTrackbar + AnchorSideTop.Side = asrBottom AnchorSideRight.Control = nbRGB AnchorSideRight.Side = asrBottom - Left = 16 + Left = 19 Height = 32 Top = 80 - Width = 216 + Width = 258 SelectedColor = 16743034 Layout = lyHorizontal SelectionIndicator = siRect Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 8 TabOrder = 2 OnChange = ColorPickerChange Green = 122 Red = 122 HintFormat = 'Blue: %value (selected)' end - object Label6: TLabel + object LblR: TLabel + AnchorSideLeft.Control = nbRGB AnchorSideTop.Control = RTrackbar AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = RTrackbar Left = 4 Height = 15 Top = 9 Width = 7 - Anchors = [akTop, akRight] + BorderSpacing.Left = 4 BorderSpacing.Right = 3 Caption = 'R' ParentColor = False end - object Label7: TLabel + object LblG: TLabel + AnchorSideLeft.Control = LblR AnchorSideTop.Control = GTrackbar AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = GTrackbar - Left = 3 + Left = 4 Height = 15 Top = 49 Width = 8 - Anchors = [akTop, akRight] - BorderSpacing.Left = 4 BorderSpacing.Right = 5 Caption = 'G' ParentColor = False end - object Label8: TLabel + object LblB: TLabel + AnchorSideLeft.Control = LblR AnchorSideTop.Control = BTrackbar AnchorSideTop.Side = asrCenter - AnchorSideRight.Control = BTrackbar Left = 4 Height = 15 Top = 89 Width = 7 - Anchors = [akTop, akRight] - BorderSpacing.Left = 4 BorderSpacing.Right = 5 Caption = 'B' ParentColor = False end end end + object Panel1: TPanel + Left = 0 + Height = 118 + Top = 226 + Width = 313 + Align = alBottom + AutoSize = True + BevelOuter = bvNone + ClientHeight = 118 + ClientWidth = 313 + TabOrder = 1 + object LblPicker: TLabel + AnchorSideLeft.Control = Panel1 + AnchorSideTop.Control = cbColorDisplay + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 8 + Width = 35 + BorderSpacing.Left = 6 + Caption = '&Picker:' + FocusControl = cbColorDisplay + ParentColor = False + end + object cbColorDisplay: TComboBox + AnchorSideLeft.Control = LblPicker + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = Panel1 + AnchorSideRight.Control = Panel1 + AnchorSideRight.Side = asrBottom + Left = 49 + Height = 23 + Top = 4 + Width = 254 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 8 + BorderSpacing.Top = 4 + BorderSpacing.Right = 10 + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'Hue/saturation box, luminance bar' + 'Hue ring, saturation/luminance box' + 'Saturation/luminance box, hue bar' + 'Red-green-blue trackbars' + ) + OnChange = cbColorDisplayChange + Style = csDropDownList + TabOrder = 0 + Text = 'Hue/saturation box, luminance bar' + end + object LblRed: TLabel + AnchorSideLeft.Control = LblPicker + AnchorSideTop.Control = EdRED + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 37 + Width = 23 + Caption = '&Red:' + ParentColor = False + end + object EdRED: TSpinEdit + AnchorSideLeft.Control = cbColorDisplay + AnchorSideTop.Control = cbColorDisplay + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Bevel2 + Left = 49 + Height = 23 + Top = 33 + Width = 99 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + MaxValue = 255 + OnChange = EdRedChange + TabOrder = 1 + Value = 255 + end + object LblGreen: TLabel + AnchorSideLeft.Control = LblPicker + AnchorSideTop.Control = EdGREEN + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 66 + Width = 34 + Caption = '&Green:' + ParentColor = False + end + object EdGREEN: TSpinEdit + AnchorSideLeft.Control = cbColorDisplay + AnchorSideTop.Control = EdRED + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Bevel2 + Left = 49 + Height = 23 + Top = 62 + Width = 99 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + MaxValue = 255 + OnChange = EdGreenChange + TabOrder = 2 + end + object LblBlue: TLabel + AnchorSideLeft.Control = LblPicker + AnchorSideTop.Control = EdBLUE + AnchorSideTop.Side = asrCenter + Left = 6 + Height = 15 + Top = 95 + Width = 26 + Caption = '&Blue:' + ParentColor = False + end + object EdBLUE: TSpinEdit + AnchorSideLeft.Control = cbColorDisplay + AnchorSideTop.Control = EdGREEN + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Bevel2 + Left = 49 + Height = 23 + Top = 91 + Width = 99 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + BorderSpacing.Bottom = 4 + MaxValue = 255 + OnChange = EdBlueChange + TabOrder = 3 + end + object LblHue: TLabel + AnchorSideLeft.Control = Bevel2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = EdHUE + AnchorSideTop.Side = asrCenter + Left = 164 + Height = 15 + Top = 37 + Width = 25 + Caption = '&Hue:' + ParentColor = False + end + object EdHUE: TSpinEdit + AnchorSideLeft.Control = LblLumVal + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = cbColorDisplay + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = cbColorDisplay + AnchorSideRight.Side = asrBottom + Left = 197 + Height = 23 + Top = 33 + Width = 106 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Left = 6 + BorderSpacing.Top = 6 + MaxValue = 359 + OnChange = EdHueChange + TabOrder = 4 + end + object LblSat: TLabel + AnchorSideLeft.Control = Bevel2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = EdSAT + AnchorSideTop.Side = asrCenter + Left = 164 + Height = 15 + Top = 66 + Width = 19 + Caption = '&Sat:' + ParentColor = False + end + object EdSAT: TSpinEdit + AnchorSideLeft.Control = EdHUE + AnchorSideTop.Control = EdHUE + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = cbColorDisplay + AnchorSideRight.Side = asrBottom + Left = 197 + Height = 23 + Top = 62 + Width = 106 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + MaxValue = 255 + OnChange = EdSatChange + TabOrder = 5 + Value = 255 + end + object LblLumVal: TLabel + AnchorSideLeft.Control = Bevel2 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = EdLUMVAL + AnchorSideTop.Side = asrCenter + Left = 164 + Height = 15 + Top = 95 + Width = 27 + Caption = 'L&um:' + ParentColor = False + end + object EdLUMVAL: TSpinEdit + AnchorSideLeft.Control = EdHUE + AnchorSideTop.Control = EdSAT + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = cbColorDisplay + AnchorSideRight.Side = asrBottom + Left = 197 + Height = 23 + Top = 91 + Width = 106 + Alignment = taRightJustify + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 6 + MaxValue = 255 + OnChange = EdLumValChange + TabOrder = 6 + Value = 127 + end + object Bevel2: TBevel + AnchorSideLeft.Control = Panel1 + AnchorSideLeft.Side = asrCenter + AnchorSideBottom.Side = asrBottom + Left = 148 + Height = 81 + Top = 203 + Width = 16 + Anchors = [akLeft, akBottom] + Shape = bsSpacer + end + end end end - object OKbtn: TButton - AnchorSideLeft.Control = Cancelbtn - AnchorSideTop.Control = Owner - Left = 266 - Height = 23 - Top = 6 - Width = 73 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 6 - Caption = 'OK' - ModalResult = 1 + object SidePanel: TPanel + Left = 333 + Height = 384 + Top = 0 + Width = 89 + Align = alRight + BorderSpacing.Right = 3 + BevelOuter = bvNone + ClientHeight = 384 + ClientWidth = 89 TabOrder = 1 - end - object Cancelbtn: TButton - AnchorSideTop.Control = OKbtn - AnchorSideTop.Side = asrBottom - Left = 266 - Height = 23 - Top = 35 - Width = 73 - Anchors = [akTop, akRight] - BorderSpacing.Top = 6 - Cancel = True - Caption = 'Cancel' - ModalResult = 2 - TabOrder = 2 - end - object NewSwatch: TmbColorPreview - AnchorSideLeft.Control = Cancelbtn - AnchorSideLeft.Side = asrCenter - AnchorSideBottom.Control = OldSwatch - Left = 266 - Height = 32 - Hint = 'RGB(255, 255, 255)' - Top = 232 - Width = 73 - Anchors = [akLeft, akBottom] - ShowHint = True - ParentShowHint = False - OnColorChange = NewSwatchColorChange - end - object OldSwatch: TmbColorPreview - AnchorSideLeft.Control = NewSwatch - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = NewSwatch - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Control = LblCurrent - Left = 266 - Height = 32 - Hint = 'RGB(255, 255, 255)'#13#10'Hex: FFFFFF' - Top = 264 - Width = 73 - Anchors = [akLeft, akRight, akBottom] - ShowHint = True - ParentShowHint = False - OnColorChange = OldSwatchColorChange + object BtnOK: TButton + AnchorSideLeft.Control = BtnCancel + AnchorSideTop.Control = SidePanel + AnchorSideRight.Control = BtnCancel + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 23 + Top = 10 + Width = 83 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Top = 10 + Caption = 'OK' + ModalResult = 1 + TabOrder = 0 + end + object BtnCancel: TButton + AnchorSideLeft.Control = SidePanel + AnchorSideTop.Control = BtnOK + AnchorSideTop.Side = asrBottom + Left = 0 + Height = 23 + Top = 39 + Width = 83 + BorderSpacing.Top = 6 + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 1 + end + object NewSwatch: TmbColorPreview + AnchorSideLeft.Control = BtnCancel + AnchorSideRight.Control = BtnCancel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = OldSwatch + Left = 0 + Height = 32 + Hint = 'RGB(255, 255, 255)' + Top = 293 + Width = 83 + Anchors = [akLeft, akRight, akBottom] + ShowHint = True + ParentShowHint = False + OnColorChange = NewSwatchColorChange + end + object OldSwatch: TmbColorPreview + AnchorSideLeft.Control = BtnCancel + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = BtnCancel + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = LblCurrent + Left = 0 + Height = 32 + Hint = 'RGB(255, 255, 255)'#13#10'Hex: FFFFFF' + Top = 325 + Width = 83 + Anchors = [akLeft, akRight, akBottom] + BorderSpacing.Bottom = 2 + ShowHint = True + ParentShowHint = False + OnColorChange = OldSwatchColorChange + end + object Label4: TLabel + AnchorSideLeft.Control = NewSwatch + AnchorSideLeft.Side = asrCenter + AnchorSideBottom.Control = NewSwatch + Left = 29 + Height = 15 + Top = 276 + Width = 24 + Anchors = [akLeft, akBottom] + BorderSpacing.Bottom = 2 + Caption = 'New' + ParentColor = False + end + object LblCurrent: TLabel + AnchorSideLeft.Control = OldSwatch + AnchorSideLeft.Side = asrCenter + AnchorSideTop.Control = OldSwatch + AnchorSideTop.Side = asrBottom + AnchorSideBottom.Control = SidePanel + AnchorSideBottom.Side = asrBottom + Left = 21 + Height = 15 + Top = 359 + Width = 40 + Anchors = [akLeft, akBottom] + BorderSpacing.Bottom = 10 + Caption = 'Current' + ParentColor = False + end end end diff --git a/components/mbColorLib/OfficeMoreColorsDialog.pas b/components/mbColorLib/OfficeMoreColorsDialog.pas index 2872da348..ef3835da4 100644 --- a/components/mbColorLib/OfficeMoreColorsDialog.pas +++ b/components/mbColorLib/OfficeMoreColorsDialog.pas @@ -15,17 +15,26 @@ type { TOfficeMoreColorsWin } TOfficeMoreColorsWin = class(TForm) + Bevel2: TBevel; BTrackbar: TBColorPicker; Bevel1: TBevel; + EdGREEN: TSpinEdit; + EdBLUE: TSpinEdit; + EdHUE: TSpinEdit; + EdSAT: TSpinEdit; + EdLUMVAL: TSpinEdit; GTrackbar: TGColorPicker; HSLRing: THSLRingPicker; - Label6: TLabel; - Label7: TLabel; - Label8: TLabel; - LLumVal: TLabel; - LSat: TLabel; - LHue: TLabel; + LblR: TLabel; + LblG: TLabel; + LblB: TLabel; + LblCurrent: TLabel; + LblLumVal: TLabel; + LblSat: TLabel; + LblHue: TLabel; nbRGB: TPage; + Panel1: TPanel; + SidePanel: TPanel; PickerNotebook: TNotebook; nbHSL: TPage; nbHSLRing: TPage; @@ -33,31 +42,32 @@ type Pages: TPageControl; RTrackbar: TRColorPicker; SLH: TSLHColorPicker; + EdRED: TSpinEdit; Standard: TTabSheet; Custom: TTabSheet; Hexa: THexaColorPicker; HSL: THSLColorPicker; - Label1: TLabel; - Label2: TLabel; - Label3: TLabel; + LblCustomColors: TLabel; + LblStandardColors: TLabel; + LblPicker: TLabel; cbColorDisplay: TComboBox; - LRed: TLabel; - LGreen: TLabel; - LBlue: TLabel; + LblRed: TLabel; + LblGreen: TLabel; + LblBlue: TLabel; Label4: TLabel; Label5: TLabel; - OKbtn: TButton; - Cancelbtn: TButton; + BtnOK: TButton; + BtnCancel: TButton; NewSwatch: TmbColorPreview; OldSwatch: TmbColorPreview; procedure cbColorDisplayChange(Sender: TObject); procedure ColorPickerChange(Sender: TObject); - procedure EBlueChange(Sender: TObject); - procedure EGreenChange(Sender: TObject); - procedure EHueChange(Sender: TObject); - procedure ELumValChange(Sender: TObject); - procedure ERedChange(Sender: TObject); - procedure ESatChange(Sender: TObject); + procedure EdBlueChange(Sender: TObject); + procedure EdGreenChange(Sender: TObject); + procedure EdHueChange(Sender: TObject); + procedure EdLumValChange(Sender: TObject); + procedure EdRedChange(Sender: TObject); + procedure EdSatChange(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState); procedure FormResize(Sender: TObject); @@ -66,20 +76,13 @@ type procedure HexaChange(Sender: TObject); procedure HSLChange(Sender: TObject); procedure HSLRingChange(Sender: TObject); + procedure nbHSLRingResize(Sender: TObject); procedure NewSwatchColorChange(Sender: TObject); procedure OldSwatchColorChange(Sender: TObject); procedure PagesChange(Sender: TObject); procedure PagesChanging(Sender: TObject; var {%H-}AllowChange: Boolean); procedure SLHChange(Sender: TObject); private - {$IFDEF mbXP_Lib} - ERed, EGreen, EBlue: TmbXPSpinEdit; - EHue, ESat, ELumVal: TmbXPSpinEdit; - grip: TmbXPSizeGrip; - {$ELSE} - ERed, EGreen, EBlue: TSpinEdit; - EHue, ESat, ELumVal: TSpinEdit; - {$ENDIF} FMaxHue: Integer; FMaxSat: Integer; FMaxLum: Integer; @@ -170,49 +173,49 @@ begin SLH.SelectedColor := NewSwatch.Color; end; -procedure TOfficeMoreColorsWin.EBlueChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdBlueChange(Sender: TObject); begin - if (EBlue.Text <> '') and EBlue.Focused and (FLockChange = 0) then + if (EdBlue.Text <> '') and EdBlue.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Blue := EBlue.Value; - SLH.Blue := EBlue.Value; - NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value); + HSL.Blue := EdBlue.Value; + SLH.Blue := EdBlue.Value; + NewSwatch.Color := RGB(EdRed.Value, EdGreen.Value, EdBlue.Value); finally dec(FLockChange); end; end; end; -procedure TOfficeMoreColorsWin.EGreenChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdGreenChange(Sender: TObject); begin - if (EGreen.Text <> '') and EGreen.Focused and (FLockChange = 0) then + if (EdGreen.Text <> '') and EdGreen.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Green := EGreen.Value; - SLH.Green := EGreen.Value; - NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value); + HSL.Green := EdGreen.Value; + SLH.Green := EdGreen.Value; + NewSwatch.Color := RGB(EdRed.Value, EdGreen.Value, EdBlue.Value); finally dec(FLockChange); end; end; end; -procedure TOfficeMoreColorsWin.EHueChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdHueChange(Sender: TObject); begin - if (EHue.Text <> '') and EHue.Focused and (FLockChange = 0) then + if (EdHue.Text <> '') and EdHue.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Hue := EHue.Value; - SLH.Hue := EHue.Value; + HSL.Hue := EdHue.Value; + SLH.Hue := EdHue.Value; case FBrightnessMode of bmLuminance: - NewSwatch.Color := HSLToColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumVal.Value/FMaxLum); + NewSwatch.Color := HSLToColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumVal.Value/FMaxLum); bmValue: - NewSwatch.Color := HSVtoColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumVal.Value/FMaxVal); + NewSwatch.Color := HSVtoColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumVal.Value/FMaxVal); end; finally dec(FLockChange); @@ -220,18 +223,18 @@ begin end; end; -procedure TOfficeMoreColorsWin.ELumValChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdLumValChange(Sender: TObject); begin - if (ELumVal.Text <> '') and ELumVal.Focused and (FLockChange = 0) then + if (EdLumVal.Text <> '') and EdLumVal.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Luminance := ELumVal.Value; + HSL.Luminance := EdLumVal.Value; case FBrightnessMode of bmLuminance: - NewSwatch.Color := HSLToColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumVal.Value/FMaxLum); + NewSwatch.Color := HSLToColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumVal.Value/FMaxLum); bmValue: - NewSwatch.Color := HSVtoColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumVal.Value/FMaxVal); + NewSwatch.Color := HSVtoColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumVal.Value/FMaxVal); end; finally dec(FLockChange); @@ -244,34 +247,34 @@ begin dec(FLockChange); end; -procedure TOfficeMoreColorsWin.ERedChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdRedChange(Sender: TObject); begin - if (ERed.Text <> '') and ERed.Focused and (FLockChange = 0) then + if (EdRed.Text <> '') and EdRed.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Red := ERed.Value; - SLH.Red := ERed.Value; - NewSwatch.Color := RGB(ERed.Value, EGreen.Value, EBlue.Value); + HSL.Red := EdRed.Value; + SLH.Red := EdRed.Value; + NewSwatch.Color := RGB(EdRed.Value, EdGreen.Value, EdBlue.Value); finally dec(FLockChange); end; end; end; -procedure TOfficeMoreColorsWin.ESatChange(Sender: TObject); +procedure TOfficeMoreColorsWin.EdSatChange(Sender: TObject); begin - if (ESat.Text <> '') and ESat.Focused and (FLockChange = 0) then + if (EdSat.Text <> '') and EdSat.Focused and (FLockChange = 0) then begin inc(FLockChange); try - HSL.Saturation := ESat.Value; - SLH.Saturation := ESat.Value; + HSL.Saturation := EdSat.Value; + SLH.Saturation := EdSat.Value; case FBrightnessMode of bmLuminance: - NewSwatch.Color := HSLToColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumval.Value/FMaxLum); + NewSwatch.Color := HSLToColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumval.Value/FMaxLum); bmValue: - NewSwatch.Color := HSVtoColor(EHue.Value/FMaxHue, ESat.Value/FMaxSat, ELumval.Value/FMaxVal); + NewSwatch.Color := HSVtoColor(EdHue.Value/FMaxHue, EdSat.Value/FMaxSat, EdLumval.Value/FMaxVal); end; finally dec(FLockChange); @@ -281,6 +284,9 @@ end; procedure TOfficeMoreColorsWin.FormCreate(Sender: TObject); begin + Width := ScaleX(Width, 96); + Height := ScaleY(Height, 96); + FBrightnessMode := bmLuminance; FMaxHue := 360; @@ -302,7 +308,7 @@ begin SLH.MaxSaturation := FMaxSat; SLH.MaxLuminance := FMaxLum; SLH.BrightnessMode := FBrightnessMode; - + (* {$IFDEF mbXP_Lib} ERed := TmbXPSpinEdit.CreateParented(Custom.Handle); EGreen := TmbXPSpinEdit.CreateParented(Custom.Handle); @@ -322,7 +328,7 @@ begin Width := 47; Height := 22; Left := cbColorDisplay.Left; - Top := LRed.Top - 4; + Top := LblRed.Top - 4; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; MaxValue := 255; @@ -337,7 +343,7 @@ begin Width := 47; Height := 22; Left := cbColorDisplay.Left; - Top := LGreen.Top - 3; + Top := LblGreen.Top - 3; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; MaxValue := 255; @@ -352,7 +358,7 @@ begin Width := 47; Height := 22; Left := cbColorDisplay.Left; - Top := LBlue.Top - 4; + Top := LblBlue.Top - 4; Alignment := taRightJustify; Anchors := [akLeft, akBottom]; MaxValue := 255; @@ -425,9 +431,9 @@ begin end; InsertControl(grip); {$ENDIF} - - OKBtn.TabOrder := ELumVal.TabOrder + 1; - CancelBtn.TabOrder := OKBtn.TabOrder + 1; + *) + BtnOK.TabOrder := EdLumVal.TabOrder + 1; + BtnCancel.TabOrder := BtnOK.TabOrder + 1; end; procedure TOfficeMoreColorsWin.FormKeyDown(Sender: TObject; var Key: Word; @@ -451,12 +457,12 @@ procedure TOfficeMoreColorsWin.FormShow(Sender: TObject); var h: Integer; begin - OKbtn.AutoSize := true; - h := OKbtn.Height; - OKbtn.AutoSize := false; - OKbtn.Height := h; - OKbtn.Width := Cancelbtn.Width; - CancelBtn.Height := h; + BtnOK.AutoSize := true; + h := BtnOK.Height; + BtnOK.AutoSize := false; + BtnOK.Height := h; + BtnOK.Width := BtnCancel.Width; + BtnCancel.Height := h; end; function TOfficeMoreColorsWin.GetHint(c: TColor): string; @@ -512,6 +518,11 @@ begin SetAllCustom(HSLRing.SelectedColor); end; +procedure TOfficeMoreColorsWin.nbHSLRingResize(Sender: TObject); +begin + HSLRing.Width := HSLRing.Height; +end; + procedure TOfficeMoreColorsWin.NewSwatchColorChange(Sender: TObject); begin NewSwatch.Hint := GetHint(NewSwatch.Color); @@ -519,8 +530,8 @@ begin exit; - if (ERed = nil) or (EBlue = nil) or (EGreen = nil) or - (EHue = nil) or (ESat = nil) or (ELumVal = nil) + if (EdRed = nil) or (EdBlue = nil) or (EdGreen = nil) or + (EdHue = nil) or (EdSat = nil) or (EdLumVal = nil) then exit; @@ -563,8 +574,8 @@ var r, g, b: Integer; H, S, L, V: Double; begin - if (ERed = nil) or (EGreen = nil) or (EBlue = nil) or - (EHue = nil) or (ESat = nil) or (ELumVal = nil) or + if (EdRed = nil) or (EdGreen = nil) or (EdBlue = nil) or + (EdHue = nil) or (EdSat = nil) or (EdLumVal = nil) or (PickerNotebook = nil) or (HSL = nil) or (HSLRing = nil) or (SLH = nil) or (FLockChange > 0) then @@ -602,14 +613,14 @@ begin else exit; //raise Exception.Create('Notbook page not prepared for color pickers'); - ERed.Value := r; - EGreen.Value := g; - EBlue.Value := b; - EHue.Value := H * HSL.MaxHue; - ESat.Value := S * HSL.MaxSaturation; + EdRed.Value := r; + EdGreen.Value := g; + EdBlue.Value := b; + EdHue.Value := H * HSL.MaxHue; + EdSat.Value := S * HSL.MaxSaturation; case FBrightnessMode of - bmLuminance: ELumVal.Value := L * HSL.MaxLuminance; - bmValue : ELumVal.Value := V * HSL.MaxValue; + bmLuminance: EdLumVal.Value := L * HSL.MaxLuminance; + bmValue : EdLumVal.Value := V * HSL.MaxValue; end; EndUpdate; @@ -632,8 +643,8 @@ procedure TOfficeMoreColorsWin.SetBrightnessMode(AMode: TBrightnessMode); begin FBrightnessMode := AMode; case AMode of - bmLuminance: LLumVal.Caption := 'Lum:'; - bmValue : LLumval.Caption := 'Val:'; + bmLuminance: LblLumVal.Caption := 'Lum:'; + bmValue : LblLumVal.Caption := 'Val:'; end; end; @@ -642,10 +653,10 @@ var hh: Double; begin inc(FLockChange); - hh := EHue.Value / FMaxHue; + hh := EdHue.Value / FMaxHue; FMaxHue := H; - EHue.MaxValue := H; - EHue.Value := round(hh * FMaxHue); + EdHue.MaxValue := H; + EdHue.Value := round(hh * FMaxHue); dec(FLockChange); end; @@ -654,10 +665,10 @@ var ll: Double; begin inc(FLockChange); - ll := ELumVal.Value / FMaxLum; + ll := EdLumVal.Value / FMaxLum; FMaxLum := L; - ELumVal.MaxValue := L; - ELumVal.Value := round(ll * FMaxLum); + EdLumVal.MaxValue := L; + EdLumVal.Value := round(ll * FMaxLum); dec(FLockChange); end; @@ -666,10 +677,10 @@ var ss: Double; begin inc(FLockChange); - ss := ESat.Value / FMaxSat; + ss := EdSat.Value / FMaxSat; FMaxSat := S; - ESat.MaxValue := S; - ESat.Value := round(ss * FMaxSat); + EdSat.MaxValue := S; + EdSat.Value := round(ss * FMaxSat); dec(FLockChange); end; @@ -678,10 +689,10 @@ var vv: Double; begin inc(FLockChange); - vv := ELumVal.Value / FMaxVal; + vv := EdLumVal.Value / FMaxVal; FMaxVal := V; - ELumVal.MaxValue := V; - ELumVal.Value := round(vv * FMaxVal); + EdLumVal.MaxValue := V; + EdLumVal.Value := round(vv * FMaxVal); dec(FLockChange); end;