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

Wraps a wxControl positioned over a bitmap overlay panel. More...

#include <drc_re_overlay_field.h>

Public Types

using Getter = std::function<double()>
 
using Setter = std::function<void( double )>
 

Public Member Functions

 DRC_RE_OVERLAY_FIELD (wxWindow *aParent, const wxString &aFieldId, wxControl *aControl, const DRC_RE_FIELD_POSITION &aPosition)
 Construct an overlay field wrapping an existing control.
 
 ~DRC_RE_OVERLAY_FIELD ()
 
wxControl * GetControl () const
 
const wxString & GetFieldId () const
 
const DRC_RE_FIELD_POSITIONGetPosition () const
 
bool TransferToWindow ()
 Transfer data from the model to the control.
 
bool TransferFromWindow ()
 Transfer data from the control to the model.
 
void SetGetter (Getter aGetter)
 Set the getter lambda for reading model data.
 
void SetSetter (Setter aSetter)
 Set the setter lambda for writing model data.
 
void SetUnitBinder (UNIT_BINDER *aBinder)
 Associate a UNIT_BINDER for unit conversion.
 
UNIT_BINDERGetUnitBinder () const
 
void ShowError (bool aShow)
 Show or hide the error indicator icon adjacent to this field.
 
bool IsShowingError () const
 
wxStaticText * GetLabel () const
 
bool HasLabel () const
 
void CreateLabel ()
 Create and associate a label with this field.
 

Private Member Functions

void createErrorIcon ()
 

Private Attributes

wxWindow * m_parent
 
wxString m_fieldId
 
wxControl * m_control
 
DRC_RE_FIELD_POSITION m_position
 
Getter m_getter
 
Setter m_setter
 
UNIT_BINDERm_unitBinder
 
wxStaticBitmap * m_errorIcon
 
bool m_showingError
 
wxStaticText * m_label
 

Detailed Description

Wraps a wxControl positioned over a bitmap overlay panel.

Manages the control's position within the overlay, data binding via lambda functions, optional UNIT_BINDER integration for unit conversion, and error icon display for validation feedback.

Definition at line 46 of file drc_re_overlay_field.h.

Member Typedef Documentation

◆ Getter

using DRC_RE_OVERLAY_FIELD::Getter = std::function<double()>

Definition at line 49 of file drc_re_overlay_field.h.

◆ Setter

using DRC_RE_OVERLAY_FIELD::Setter = std::function<void( double )>

Definition at line 50 of file drc_re_overlay_field.h.

Constructor & Destructor Documentation

◆ DRC_RE_OVERLAY_FIELD()

DRC_RE_OVERLAY_FIELD::DRC_RE_OVERLAY_FIELD ( wxWindow * aParent,
const wxString & aFieldId,
wxControl * aControl,
const DRC_RE_FIELD_POSITION & aPosition )

Construct an overlay field wrapping an existing control.

Parameters
aParentParent window (typically the overlay panel)
aFieldIdUnique identifier for this field, used for error mapping
aControlThe wxControl to wrap and position
aPositionPosition specification in 1x bitmap coordinates

Definition at line 35 of file drc_re_overlay_field.cpp.

References m_control, m_errorIcon, m_fieldId, m_getter, m_label, m_parent, m_position, m_setter, m_showingError, and m_unitBinder.

◆ ~DRC_RE_OVERLAY_FIELD()

DRC_RE_OVERLAY_FIELD::~DRC_RE_OVERLAY_FIELD ( )

Definition at line 52 of file drc_re_overlay_field.cpp.

References m_errorIcon, and m_label.

Member Function Documentation

◆ createErrorIcon()

void DRC_RE_OVERLAY_FIELD::createErrorIcon ( )
private

Definition at line 68 of file drc_re_overlay_field.cpp.

References KiBitmapBundle(), m_control, m_errorIcon, m_parent, and small_warning.

Referenced by ShowError().

◆ CreateLabel()

void DRC_RE_OVERLAY_FIELD::CreateLabel ( )

Create and associate a label with this field.

The label is positioned according to the LABEL_POSITION in the field position struct.

Definition at line 145 of file drc_re_overlay_field.cpp.

References m_label, m_parent, m_position, and NONE.

Referenced by DRC_RE_BITMAP_OVERLAY_PANEL::AddCheckbox(), and DRC_RE_BITMAP_OVERLAY_PANEL::AddField().

◆ GetControl()

◆ GetFieldId()

const wxString & DRC_RE_OVERLAY_FIELD::GetFieldId ( ) const
inline
Returns
The unique field identifier string.

Definition at line 73 of file drc_re_overlay_field.h.

References m_fieldId.

◆ GetLabel()

wxStaticText * DRC_RE_OVERLAY_FIELD::GetLabel ( ) const
inline
Returns
The label control, or nullptr if no label was created.

Definition at line 143 of file drc_re_overlay_field.h.

References m_label.

Referenced by DRC_RE_BITMAP_OVERLAY_PANEL::PositionLabel().

◆ GetPosition()

const DRC_RE_FIELD_POSITION & DRC_RE_OVERLAY_FIELD::GetPosition ( ) const
inline
Returns
The field's position specification in 1x bitmap coordinates.

Definition at line 78 of file drc_re_overlay_field.h.

References m_position.

Referenced by DRC_RE_BITMAP_OVERLAY_PANEL::PositionLabel().

◆ GetUnitBinder()

UNIT_BINDER * DRC_RE_OVERLAY_FIELD::GetUnitBinder ( ) const
inline
Returns
The associated UNIT_BINDER, or nullptr if none.

Definition at line 126 of file drc_re_overlay_field.h.

References m_unitBinder.

◆ HasLabel()

bool DRC_RE_OVERLAY_FIELD::HasLabel ( ) const
inline
Returns
true if this field has a label.

Definition at line 148 of file drc_re_overlay_field.h.

References m_label.

Referenced by DRC_RE_BITMAP_OVERLAY_PANEL::AddCheckbox(), and DRC_RE_BITMAP_OVERLAY_PANEL::AddField().

◆ IsShowingError()

bool DRC_RE_OVERLAY_FIELD::IsShowingError ( ) const
inline
Returns
true if the error icon is currently visible.

Definition at line 138 of file drc_re_overlay_field.h.

References m_showingError.

◆ SetGetter()

void DRC_RE_OVERLAY_FIELD::SetGetter ( Getter aGetter)
inline

Set the getter lambda for reading model data.

Parameters
aGetterFunction returning the current model value

Definition at line 104 of file drc_re_overlay_field.h.

References m_getter.

◆ SetSetter()

void DRC_RE_OVERLAY_FIELD::SetSetter ( Setter aSetter)
inline

Set the setter lambda for writing model data.

Parameters
aSetterFunction accepting the new value from the control

Definition at line 111 of file drc_re_overlay_field.h.

References m_setter.

◆ SetUnitBinder()

void DRC_RE_OVERLAY_FIELD::SetUnitBinder ( UNIT_BINDER * aBinder)
inline

Associate a UNIT_BINDER for unit conversion.

When set, TransferToWindow and TransferFromWindow use the UNIT_BINDER's SetDoubleValue and GetDoubleValue methods for proper unit handling.

Parameters
aBinderThe UNIT_BINDER to associate (ownership remains with caller)

Definition at line 121 of file drc_re_overlay_field.h.

References m_unitBinder.

Referenced by DRC_RE_BITMAP_OVERLAY_PANEL::AddFieldWithUnits().

◆ ShowError()

void DRC_RE_OVERLAY_FIELD::ShowError ( bool aShow)

Show or hide the error indicator icon adjacent to this field.

Parameters
aShowtrue to display the error icon, false to hide it

Definition at line 88 of file drc_re_overlay_field.cpp.

References createErrorIcon(), m_errorIcon, and m_showingError.

◆ TransferFromWindow()

bool DRC_RE_OVERLAY_FIELD::TransferFromWindow ( )

Transfer data from the control to the model.

Reads the control value (via UNIT_BINDER if associated) and calls the setter lambda.

Returns
true on success, false if setter throws or is not set

Definition at line 123 of file drc_re_overlay_field.cpp.

References m_setter, and m_unitBinder.

◆ TransferToWindow()

bool DRC_RE_OVERLAY_FIELD::TransferToWindow ( )

Transfer data from the model to the control.

Uses the getter lambda if set. If a UNIT_BINDER is associated, the value is passed through SetDoubleValue for unit conversion.

Returns
true on success, false if getter throws or is not set

Definition at line 100 of file drc_re_overlay_field.cpp.

References m_getter, and m_unitBinder.

Member Data Documentation

◆ m_control

wxControl* DRC_RE_OVERLAY_FIELD::m_control
private

Definition at line 161 of file drc_re_overlay_field.h.

Referenced by createErrorIcon(), DRC_RE_OVERLAY_FIELD(), and GetControl().

◆ m_errorIcon

wxStaticBitmap* DRC_RE_OVERLAY_FIELD::m_errorIcon
private

◆ m_fieldId

wxString DRC_RE_OVERLAY_FIELD::m_fieldId
private

Definition at line 160 of file drc_re_overlay_field.h.

Referenced by DRC_RE_OVERLAY_FIELD(), and GetFieldId().

◆ m_getter

Getter DRC_RE_OVERLAY_FIELD::m_getter
private

Definition at line 164 of file drc_re_overlay_field.h.

Referenced by DRC_RE_OVERLAY_FIELD(), SetGetter(), and TransferToWindow().

◆ m_label

wxStaticText* DRC_RE_OVERLAY_FIELD::m_label
private

◆ m_parent

wxWindow* DRC_RE_OVERLAY_FIELD::m_parent
private

Definition at line 159 of file drc_re_overlay_field.h.

Referenced by createErrorIcon(), CreateLabel(), and DRC_RE_OVERLAY_FIELD().

◆ m_position

DRC_RE_FIELD_POSITION DRC_RE_OVERLAY_FIELD::m_position
private

Definition at line 162 of file drc_re_overlay_field.h.

Referenced by CreateLabel(), DRC_RE_OVERLAY_FIELD(), and GetPosition().

◆ m_setter

Setter DRC_RE_OVERLAY_FIELD::m_setter
private

Definition at line 165 of file drc_re_overlay_field.h.

Referenced by DRC_RE_OVERLAY_FIELD(), SetSetter(), and TransferFromWindow().

◆ m_showingError

bool DRC_RE_OVERLAY_FIELD::m_showingError
private

Definition at line 169 of file drc_re_overlay_field.h.

Referenced by DRC_RE_OVERLAY_FIELD(), IsShowingError(), and ShowError().

◆ m_unitBinder

UNIT_BINDER* DRC_RE_OVERLAY_FIELD::m_unitBinder
private

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