UNIT - FrameColorPicker

   Path: D:\DEV\DX10\FramesFMX\FrameColorPicker.pas

   Date, Size, Lines: 04.06.2020 14:51:20 / 5 kb / 175 lines

 
 SUMMARY ( Unit )

   Frame to show a modern Color-selection box
    ---
    Documentation generated by Pascal Project Manager & Editor
 
REMARKS ( Unit )

   How to use:
    1 Add the unit to your project
    2 From the Component-selector select frames and draw a small rectangle on
      the form, were the frame sould be insert
    3 In the opened dialog select FrameColorpicker
   
    Downloadlink for source: FrameColorPicker.zip
 
CLASSES

Name Description
TF_FrameColorPicker = class(TFrame) Here FRAME for the HTML-Editor window (but can be used also in any other projects)
 
 
CLASSES AND ROUTINES

 
TF_FrameColorPicker = class(TFrame)    Methods    private    public

Methods and Fields Description
ComboColorBox: TComboColorBox; // A standard FMX ComboColorbox (only button is used)
LayoutColorPickerButton: TLayout; // Only container
LayoutColorPickerColors: TLayout; -
FMXColorBox: TColorBox; // A standard FMX Colorbox (only used for the alpha-color part)
ColorBoxImage: TImage; The image with the colorbox rectangles
LayoutColorButton: TLayout; -
RectangleColorBoxContainer: TRectangle; Contains a standard FMX-Colorbox and the image
P LayoutColorButtonClick(); Click on color-button to show the colorbox
P FMXColorBoxClick(); Returns the selected color and sets the comboboxColor (here only for the alpha-case)
P ColorBoxImageMouseDown(); Returns the clicked color from the colorbox-image
P FrameKeyDown(); Checks if ESC is pressed to close the color-box
P HidePicker; Hide the Colorpicker (box)
private -
public -
HideAlpha: Boolean; If this is true, then the part for Alpha-color is not shown (see image 1), so set it on creation event
 
ROUTINES IN DETAILS

 

procedure HidePicker;

Procedure Description
Summary: Hide the Colorpicker (box)
Example:  
 // If Picker is not closed by select or ESC,
 // check, when other controls been entered, if the picker is visible
 // and close it then
 // in a Form you could use also the event OnFocusChanged

 procedure TF_MainForm.CheckPickers;
 begin
   FrTextColorPicker.HidePicker;
   FrBGColorPicker.HidePicker;
 end;

 // if the frame is used in a form, you can use also
 // "Onfocus-Changed"-Event to make the check

 procedure TF_Main.FormFocusChanged(Sender: TObject);
 var
   Cont: TControl;
  begin
    if Focused <> NIL then begin
      Cont := TControl (Focused.GetObject);

      if Cont <> NIL then begin
        if Cont <> F_FrameTextColorPicker.ComboColorBox then begin
          F_FrameTextColorPicker.HidePicker;
        end;

        if Cont <> F_FrameBGColorPicker.ComboColorBox then begin
          F_FrameBGColorPicker.HidePicker;
        end;
      end;
    end;
  end;