KiCad PCB EDA Suite
Loading...
Searching...
No Matches
COLOR_SWATCH Class Reference

A simple color swatch of the kind used to set layer colors. More...

#include <color_swatch.h>

Inheritance diagram for COLOR_SWATCH:

Public Member Functions

 COLOR_SWATCH (wxWindow *aParent, const KIGFX::COLOR4D &aColor, int aID, const KIGFX::COLOR4D &aBackground, const KIGFX::COLOR4D &aDefault, SWATCH_SIZE aSwatchType, bool aTriggerWithSingleClick=false)
 Construct a COLOR_SWATCH. More...
 
 COLOR_SWATCH (wxWindow *aParent, wxWindowID aId, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0)
 constructor for wxFormBuilder More...
 
void SetSwatchColor (const KIGFX::COLOR4D &aColor, bool aSendEvent)
 Set the current swatch color directly. More...
 
void SetDefaultColor (const KIGFX::COLOR4D &aColor)
 Sets the color that will be chosen with the "Reset to Default" button in the chooser. More...
 
void SetSwatchBackground (const KIGFX::COLOR4D &aBackground)
 Set the swatch background color. More...
 
void SetUserColors (CUSTOM_COLORS_LIST *aUserColors)
 Fetch a reference to the user colors list. More...
 
KIGFX::COLOR4D GetSwatchColor () const
 
void SetWindowID (wxWindowID aId)
 Updates the window ID of this control and its children. More...
 
void GetNewSwatchColor ()
 Prompt for a new colour, using the colour picker dialog. More...
 
void SetReadOnly (bool aReadOnly=true)
 
bool IsReadOnly () const
 
void SetSupportsOpacity (bool aSupportsOpacity)
 
void SetReadOnlyCallback (std::function< void()> aCallback)
 Registers a handler for when the user tries to interact with a read-only swatch. More...
 
void OnDarkModeToggle ()
 Respond to a change in the OS's DarkMode setting. More...
 

Static Public Member Functions

static wxBitmap MakeBitmap (const KIGFX::COLOR4D &aColor, const KIGFX::COLOR4D &aBackground, const wxSize &aSize, const wxSize &aCheckerboardSize, const KIGFX::COLOR4D &aCheckerboardBackground)
 
static void RenderToDC (wxDC *aDC, const KIGFX::COLOR4D &aColor, const KIGFX::COLOR4D &aBackground, const wxRect &aRect, const wxSize &aCheckerboardSize, const KIGFX::COLOR4D &aCheckerboardBackground)
 

Private Member Functions

void setupEvents (bool aTriggerWithSingleClick)
 
void rePostEvent (wxEvent &aEvent)
 Pass unwanted events on to listeners of this object. More...
 

Private Attributes

KIGFX::COLOR4D m_color
 
KIGFX::COLOR4D m_background
 
KIGFX::COLOR4D m_default
 
CUSTOM_COLORS_LISTm_userColors
 
wxStaticBitmap * m_swatch
 
wxSize m_size
 
wxSize m_checkerboardSize
 
KIGFX::COLOR4D m_checkerboardBg
 
bool m_readOnly
 A read-only swatch won't show the color chooser dialog but otherwise works normally. More...
 
std::function< void()> m_readOnlyCallback
 
bool m_supportsOpacity
 If opacity is not supported the color chooser dialog will be displayed without it. More...
 

Detailed Description

A simple color swatch of the kind used to set layer colors.

Definition at line 56 of file color_swatch.h.

Constructor & Destructor Documentation

◆ COLOR_SWATCH() [1/2]

COLOR_SWATCH::COLOR_SWATCH ( wxWindow *  aParent,
const KIGFX::COLOR4D aColor,
int  aID,
const KIGFX::COLOR4D aBackground,
const KIGFX::COLOR4D aDefault,
SWATCH_SIZE  aSwatchType,
bool  aTriggerWithSingleClick = false 
)

◆ COLOR_SWATCH() [2/2]

COLOR_SWATCH::COLOR_SWATCH ( wxWindow *  aParent,
wxWindowID  aId,
const wxPoint &  aPos = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = 0 
)

constructor for wxFormBuilder

Definition at line 172 of file color_swatch.cpp.

References CHECKERBOARD_SIZE_DU(), m_checkerboardBg, m_checkerboardSize, m_size, m_swatch, MakeBitmap(), setupEvents(), and SWATCH_SIZE_MEDIUM_DU().

Member Function Documentation

◆ GetNewSwatchColor()

◆ GetSwatchColor()

COLOR4D COLOR_SWATCH::GetSwatchColor ( ) const
Returns
the current swatch color

Definition at line 290 of file color_swatch.cpp.

References m_color.

Referenced by PROPERTIES_FRAME::CopyPrmsFromPanelToItem(), DIALOG_LIB_SHAPE_PROPERTIES::onBorderSwatch(), PANEL_COLOR_SETTINGS::OnColorChanged(), APPEARANCE_CONTROLS_3D::onColorSwatchChanged(), APPEARANCE_CONTROLS::OnColorSwatchChanged(), LAYER_WIDGET::OnLayerSwatchChanged(), APPEARANCE_CONTROLS::onNetclassColorChanged(), APPEARANCE_CONTROLS::onNetclassContextMenu(), LAYER_WIDGET::OnRenderSwatchChanged(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), PANEL_3D_OPENGL_OPTIONS::TransferDataFromWindow(), PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow(), DIALOG_FIELD_PROPERTIES::TransferDataFromWindow(), DIALOG_JUNCTION_PROPS::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SHAPE_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataFromWindow(), DIALOG_LINE_PROPERTIES::TransferDataFromWindow(), DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataFromWindow(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), DIALOG_TABLE_PROPERTIES::TransferDataFromWindow(), DIALOG_TABLECELL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_WIRE_BUS_PROPERTIES::TransferDataFromWindow(), PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow(), DIALOG_TABLECELL_PROPERTIES::TransferDataToWindow(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsReadOnly()

bool COLOR_SWATCH::IsReadOnly ( ) const
inline

Definition at line 120 of file color_swatch.h.

References m_readOnly.

◆ MakeBitmap()

wxBitmap COLOR_SWATCH::MakeBitmap ( const KIGFX::COLOR4D aColor,
const KIGFX::COLOR4D aBackground,
const wxSize &  aSize,
const wxSize &  aCheckerboardSize,
const KIGFX::COLOR4D aCheckerboardBackground 
)
static

◆ OnDarkModeToggle()

void COLOR_SWATCH::OnDarkModeToggle ( )

Respond to a change in the OS's DarkMode setting.

Definition at line 327 of file color_swatch.cpp.

References m_background, m_checkerboardBg, m_checkerboardSize, m_color, m_size, m_swatch, and MakeBitmap().

◆ RenderToDC()

void COLOR_SWATCH::RenderToDC ( wxDC *  aDC,
const KIGFX::COLOR4D aColor,
const KIGFX::COLOR4D aBackground,
const wxRect &  aRect,
const wxSize &  aCheckerboardSize,
const KIGFX::COLOR4D aCheckerboardBackground 
)
static

◆ rePostEvent()

void COLOR_SWATCH::rePostEvent ( wxEvent &  aEvent)
private

Pass unwanted events on to listeners of this object.

Definition at line 246 of file color_swatch.cpp.

Referenced by setupEvents().

◆ SetDefaultColor()

◆ SetReadOnly()

void COLOR_SWATCH::SetReadOnly ( bool  aReadOnly = true)
inline

Definition at line 119 of file color_swatch.h.

References m_readOnly.

Referenced by APPEARANCE_CONTROLS::rebuildLayers().

◆ SetReadOnlyCallback()

void COLOR_SWATCH::SetReadOnlyCallback ( std::function< void()>  aCallback)
inline

Registers a handler for when the user tries to interact with a read-only swatch.

Definition at line 125 of file color_swatch.h.

References m_readOnlyCallback.

Referenced by APPEARANCE_CONTROLS_3D::rebuildLayers(), APPEARANCE_CONTROLS::rebuildLayers(), and APPEARANCE_CONTROLS::rebuildObjects().

◆ SetSupportsOpacity()

void COLOR_SWATCH::SetSupportsOpacity ( bool  aSupportsOpacity)
inline

Definition at line 122 of file color_swatch.h.

References m_supportsOpacity.

Referenced by PANEL_3D_OPENGL_OPTIONS::PANEL_3D_OPENGL_OPTIONS().

◆ SetSwatchBackground()

◆ SetSwatchColor()

void COLOR_SWATCH::SetSwatchColor ( const KIGFX::COLOR4D aColor,
bool  aSendEvent 
)

◆ setupEvents()

void COLOR_SWATCH::setupEvents ( bool  aTriggerWithSingleClick)
private

Definition at line 202 of file color_swatch.cpp.

References GetNewSwatchColor(), m_swatch, and rePostEvent().

Referenced by COLOR_SWATCH().

◆ SetUserColors()

void COLOR_SWATCH::SetUserColors ( CUSTOM_COLORS_LIST aUserColors)
inline

Fetch a reference to the user colors list.

Definition at line 95 of file color_swatch.h.

References m_userColors.

◆ SetWindowID()

void COLOR_SWATCH::SetWindowID ( wxWindowID  aId)
inline

Updates the window ID of this control and its children.

Parameters
aIdnew Window ID to set

Definition at line 106 of file color_swatch.h.

References m_swatch.

Member Data Documentation

◆ m_background

KIGFX::COLOR4D COLOR_SWATCH::m_background
private

◆ m_checkerboardBg

KIGFX::COLOR4D COLOR_SWATCH::m_checkerboardBg
private

◆ m_checkerboardSize

wxSize COLOR_SWATCH::m_checkerboardSize
private

◆ m_color

KIGFX::COLOR4D COLOR_SWATCH::m_color
private

◆ m_default

KIGFX::COLOR4D COLOR_SWATCH::m_default
private

Definition at line 149 of file color_swatch.h.

Referenced by GetNewSwatchColor(), and SetDefaultColor().

◆ m_readOnly

bool COLOR_SWATCH::m_readOnly
private

A read-only swatch won't show the color chooser dialog but otherwise works normally.

Definition at line 159 of file color_swatch.h.

Referenced by GetNewSwatchColor(), IsReadOnly(), and SetReadOnly().

◆ m_readOnlyCallback

std::function<void()> COLOR_SWATCH::m_readOnlyCallback
private

Definition at line 160 of file color_swatch.h.

Referenced by GetNewSwatchColor(), and SetReadOnlyCallback().

◆ m_size

wxSize COLOR_SWATCH::m_size
private

◆ m_supportsOpacity

bool COLOR_SWATCH::m_supportsOpacity
private

If opacity is not supported the color chooser dialog will be displayed without it.

Definition at line 163 of file color_swatch.h.

Referenced by GetNewSwatchColor(), and SetSupportsOpacity().

◆ m_swatch

wxStaticBitmap* COLOR_SWATCH::m_swatch
private

◆ m_userColors

CUSTOM_COLORS_LIST* COLOR_SWATCH::m_userColors
private

Definition at line 150 of file color_swatch.h.

Referenced by GetNewSwatchColor(), and SetUserColors().


The documentation for this class was generated from the following files: