29#include <wx/bmpbndl.h>
30#include <wx/checkbox.h>
31#include <wx/dcclient.h>
33#include <wx/stattext.h>
42 SetBackgroundStyle( wxBG_STYLE_PAINT );
43 Create( aParent, aId );
63 dc.DrawBitmap(
m_bitmap, 0, 0,
true );
117 m_bitmap = bundle.GetBitmapFor(
this );
139 wxControl* ctrl = field->GetControl();
147 wxSize scaledSize( width, ctrl->GetBestSize().GetHeight() );
152 wxSize bmpSize =
m_bitmap.GetSize();
154 if( scaledPos.x + scaledSize.GetWidth() > bmpSize.GetWidth() ||
155 scaledPos.y + scaledSize.GetHeight() > bmpSize.GetHeight() )
157 wxLogWarning(
"Field '%s' position exceeds bitmap bounds", field->GetFieldId() );
161 ctrl->SetPosition( scaledPos );
162 ctrl->SetSize( scaledSize );
165 if( field->HasLabel() )
173 wxStaticText* label = aField->
GetLabel();
176 if( !label || !ctrl )
180 wxPoint ctrlPos = ctrl->GetPosition();
181 wxSize ctrlSize = ctrl->GetSize();
182 wxSize labelSize = label->GetBestSize();
185 constexpr int GAP = 4;
190 labelPos.x = ctrlPos.x - labelSize.GetWidth() -
GAP;
191 labelPos.y = ctrlPos.y + ( ctrlSize.GetHeight() - labelSize.GetHeight() ) / 2;
195 labelPos.x = ctrlPos.x + ctrlSize.GetWidth() +
GAP;
196 labelPos.y = ctrlPos.y + ( ctrlSize.GetHeight() - labelSize.GetHeight() ) / 2;
200 labelPos.x = ctrlPos.x + ( ctrlSize.GetWidth() - labelSize.GetWidth() ) / 2;
201 labelPos.y = ctrlPos.y - labelSize.GetHeight() -
GAP;
205 labelPos.x = ctrlPos.x + ( ctrlSize.GetWidth() - labelSize.GetWidth() ) / 2;
206 labelPos.y = ctrlPos.y + ctrlSize.GetHeight() +
GAP;
214 label->SetPosition( labelPos );
235 field->ShowError(
false );
244 it->second->ShowError(
true );
251 wxCheckBox* checkbox =
new wxCheckBox(
this, wxID_ANY, wxEmptyString );
253 auto field = std::make_unique<DRC_RE_OVERLAY_FIELD>(
this, aId, checkbox, aPosition );
258 wxPoint pos( aPosition.
xStart, aPosition.
yTop );
259 checkbox->SetPosition( pos );
268 m_fields.push_back( std::move( field ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
BITMAPS
A list of all bitmap identifiers.
DRC_RE_OVERLAY_FIELD * AddCheckbox(const wxString &aId, const DRC_RE_FIELD_POSITION &aPosition)
Create and position a checkbox control on the bitmap overlay.
void LoadBitmap()
Load the appropriate bitmap variant for the current theme and DPI.
void OnThemeChange(wxSysColourChangedEvent &aEvent)
wxBitmap m_bitmap
Current background bitmap.
void OnDPIChanged(wxDPIChangedEvent &aEvent)
void PositionLabel(DRC_RE_OVERLAY_FIELD *aField)
Position a label relative to its field control based on the label position setting.
void ShowFieldError(const wxString &aFieldId)
Show an error indicator on the specified field.
void OnPaint(wxPaintEvent &aEvent)
void OnFieldBlur(wxFocusEvent &aEvent)
void SetupFieldStyling(wxControl *aControl)
Apply transparent styling to a field control.
virtual ~DRC_RE_BITMAP_OVERLAY_PANEL()
bool TransferDataToWindow() override
std::map< wxString, DRC_RE_OVERLAY_FIELD * > m_fieldIdMap
Field ID to field lookup.
void SetBackgroundBitmap(BITMAPS aBitmap)
Set the background bitmap for this panel.
wxSize m_baseBitmapSize
Bitmap size at 1x scale.
bool TransferDataFromWindow() override
DRC_RE_BITMAP_OVERLAY_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY)
void ClearFieldErrors()
Clear error indicators from all fields.
BITMAPS m_bitmapId
BITMAPS enum value.
void PositionFields()
Position all fields based on the current scale factor.
void OnFieldFocus(wxFocusEvent &aEvent)
std::vector< std::unique_ptr< DRC_RE_OVERLAY_FIELD > > m_fields
All overlay fields.
Wraps a wxControl positioned over a bitmap overlay panel.
wxStaticText * GetLabel() const
void CreateLabel()
Create and associate a label with this field.
const DRC_RE_FIELD_POSITION & GetPosition() const
wxControl * GetControl() const
@ BOTTOM
Label below the field.
@ RIGHT
Label to the right of the field.
@ TOP
Label above the field.
@ LEFT
Label to the left of the field.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
Specifies the position and size of a field overlaid on a constraint bitmap.
LABEL_POSITION labelPosition
Position of label relative to field.
int xEnd
Right edge X coordinate where the field ends.
int xStart
Left edge X coordinate where the field starts.
int yTop
Top edge Y coordinate of the field.