29#include <wx/bmpbndl.h>
30#include <wx/checkbox.h>
31#include <wx/dcbuffer.h>
32#include <wx/dcclient.h>
33#include <wx/stattext.h>
42 SetBackgroundStyle( wxBG_STYLE_PAINT );
43 Create( aParent, aId );
58 wxAutoBufferedPaintDC dc(
this );
60 dc.SetBackground( wxBrush( GetBackgroundColour() ) );
66 dc.DrawBitmap(
m_bitmap, 0, 0,
true );
120 m_bitmap = bundle.GetBitmapFor(
this );
142 wxControl* ctrl = field->GetControl();
149 wxSize scaledSize( width, ctrl->GetBestSize().GetHeight() );
151 ctrl->SetPosition( scaledPos );
152 ctrl->SetSize( scaledSize );
155 if( field->HasLabel() )
163 wxStaticText* label = aField->
GetLabel();
166 if( !label || !ctrl )
170 wxPoint ctrlPos = ctrl->GetPosition();
171 wxSize ctrlSize = ctrl->GetSize();
172 wxSize labelSize = label->GetBestSize();
175 constexpr int GAP = 4;
180 labelPos.x = ctrlPos.x - labelSize.GetWidth() -
GAP;
181 labelPos.y = ctrlPos.y + ( ctrlSize.GetHeight() - labelSize.GetHeight() ) / 2;
185 labelPos.x = ctrlPos.x + ctrlSize.GetWidth() +
GAP;
186 labelPos.y = ctrlPos.y + ( ctrlSize.GetHeight() - labelSize.GetHeight() ) / 2;
190 labelPos.x = ctrlPos.x + ( ctrlSize.GetWidth() - labelSize.GetWidth() ) / 2;
191 labelPos.y = ctrlPos.y - labelSize.GetHeight() -
GAP;
195 labelPos.x = ctrlPos.x + ( ctrlSize.GetWidth() - labelSize.GetWidth() ) / 2;
196 labelPos.y = ctrlPos.y + ctrlSize.GetHeight() +
GAP;
204 label->SetPosition( labelPos );
225 field->ShowError(
false );
234 it->second->ShowError(
true );
241 wxCheckBox* checkbox =
new wxCheckBox(
this, wxID_ANY, wxEmptyString );
243 auto field = std::make_unique<DRC_RE_OVERLAY_FIELD>(
this, aId, checkbox, aPosition );
248 wxPoint pos( aPosition.
xStart, aPosition.
yTop );
249 checkbox->SetPosition( pos );
258 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
constexpr int DRC_RE_OVERLAY_WE
@ 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.