25#include <wx/bmpbndl.h>
26#include <wx/checkbox.h>
27#include <wx/dcbuffer.h>
28#include <wx/dcclient.h>
29#include <wx/stattext.h>
38 SetBackgroundStyle( wxBG_STYLE_PAINT );
39 Create( aParent, aId );
54 wxAutoBufferedPaintDC dc(
this );
56 dc.SetBackground( wxBrush( GetBackgroundColour() ) );
62 dc.DrawBitmap(
m_bitmap, 0, 0,
true );
138 wxControl* ctrl = field->GetControl();
143 int heightLogical = ctrl->GetBestSize().GetHeight();
144 int widthLogical = FromDIP( pos.
xEnd - pos.
xStart );
145 int xLogical = FromDIP( pos.
xStart );
146 int yLogical = FromDIP( pos.
yCenter ) - heightLogical / 2;
148 ctrl->SetPosition( wxPoint( xLogical, yLogical ) );
149 ctrl->SetSize( wxSize( widthLogical, heightLogical ) );
152 if( field->HasLabel() )
155 if( field->HasPrefixLabel() )
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 int GAP = FromDIP( 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 );
205 label->SetSize( labelSize );
214 if( !prefix || !ctrl )
217 wxPoint ctrlPos = ctrl->GetPosition();
218 wxSize ctrlSize = ctrl->GetSize();
219 wxSize prefixSize = prefix->GetBestSize();
221 int GAP = FromDIP( 4 );
224 prefixPos.x = ctrlPos.x - prefixSize.GetWidth() -
GAP;
225 prefixPos.y = ctrlPos.y + ( ctrlSize.GetHeight() - prefixSize.GetHeight() ) / 2;
227 prefix->SetPosition( prefixPos );
228 prefix->SetSize( prefixSize );
249 field->ShowError(
false );
258 it->second->ShowError(
true );
265 long style = wxALIGN_CENTER_VERTICAL;
268 style |= wxALIGN_RIGHT;
270 style |= wxALIGN_LEFT;
272 wxCheckBox* checkbox =
273 new wxCheckBox(
this, wxID_ANY, aPosition.
labelText, wxDefaultPosition, wxDefaultSize, style );
275 return AddControl( aId, aPosition, checkbox );
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.
DRC_RE_OVERLAY_FIELD * AddControl(const wxString &aId, const DRC_RE_FIELD_POSITION &aPosition, T *aControl)
Position a control on the bitmap overlay.
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_logicalBitmapSize
Bitmap size in logical pixels.
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.
void PositionPrefixLabel(DRC_RE_OVERLAY_FIELD *aField)
Position a prefix label to the left of its field control.
Wraps a wxControl positioned over a bitmap overlay panel.
wxStaticText * GetLabel() const
wxStaticText * GetPrefixLabel() const
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.
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.
wxString labelText
Optional label text (empty for no label)
int yCenter
Vertical center Y coordinate of the field.