OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
LabeledStaticBox Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/LabeledStaticBox.hpp>

Inheritance diagram for LabeledStaticBox:
Collaboration diagram for LabeledStaticBox:

Public Member Functions

 LabeledStaticBox ()
 LabeledStaticBox (wxWindow *parent, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
bool Create (wxWindow *parent, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
void SetCornerRadius (int radius)
void SetBorderWidth (int width)
void SetBorderColor (StateColor const &color)
bool SetFont (const wxFont &set_font) override
bool Enable (bool enable) override
int GetCornerRadius () const
int GetBorderWidth () const
StateColor GetBorderColor () const
float GetScale () const

Protected Member Functions

virtual void DrawBorderAndLabel (wxDC &dc)
void GetBordersForSizer (int *borderTop, int *borderOther) const override

Protected Attributes

StateHandler state_handler
StateColor text_color
StateColor border_color
StateColor background_color
int m_border_width
int m_radius
wxFont m_font
wxString m_label
int m_label_height
int m_label_width
float m_scale
wxPoint m_pos

Private Member Functions

void PickDC (wxDC &dc)

Detailed Description

Constructor & Destructor Documentation

◆ LabeledStaticBox() [1/2]

LabeledStaticBox::LabeledStaticBox ( )
19 : state_handler(this)
20{
21 m_radius = 3;
24 text_color = StateColor(
25 std::make_pair(0x363636, (int) StateColor::Normal),
26 std::make_pair(0x6B6B6B, (int) StateColor::Disabled)
27 );
28 background_color = StateColor(
29 std::make_pair(0xFFFFFF, (int) StateColor::Normal),
30 std::make_pair(0xF0F0F1, (int) StateColor::Disabled)
31 );
32 border_color = StateColor(
33 std::make_pair(0xDBDBDB, (int) StateColor::Normal),
34 std::make_pair(0xDBDBDB, (int) StateColor::Disabled)
35 );
36}
static wxFont Head_14
Definition Label.hpp:45
StateHandler state_handler
Definition LabeledStaticBox.hpp:63
int m_border_width
Definition LabeledStaticBox.hpp:67
int m_radius
Definition LabeledStaticBox.hpp:68
StateColor background_color
Definition LabeledStaticBox.hpp:66
wxFont m_font
Definition LabeledStaticBox.hpp:69
StateColor text_color
Definition LabeledStaticBox.hpp:64
StateColor border_color
Definition LabeledStaticBox.hpp:65
@ Normal
Definition StateColor.hpp:16
@ Disabled
Definition StateColor.hpp:22

References background_color, border_color, StateColor::Disabled, Label::Head_14, m_border_width, m_font, m_radius, StateColor::Normal, state_handler, and text_color.

Referenced by LabeledStaticBox().

Here is the caller graph for this function:

◆ LabeledStaticBox() [2/2]

LabeledStaticBox::LabeledStaticBox ( wxWindow * parent,
const wxString & label = wxEmptyString,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
46{
47 Create(parent, label, pos, size, style);
48}
#define style
Definition WipeTowerDialog.cpp:101
bool Create(wxWindow *parent, const wxString &label=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0)
Definition LabeledStaticBox.cpp:50
LabeledStaticBox()
Definition LabeledStaticBox.cpp:18

References LabeledStaticBox(), Create(), and style.

Here is the call graph for this function:

Member Function Documentation

◆ Create()

bool LabeledStaticBox::Create ( wxWindow * parent,
const wxString & label = wxEmptyString,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = 0 )
57{
58 if (style & wxBORDER_NONE)
60 wxStaticBox::Create(parent, wxID_ANY, label, pos, size, style);
61#ifdef __WXOSX__
63#endif
64
65 m_label = label;
66 m_scale = FromDIP(100) / 100.f;
67 m_pos = this->GetPosition();
68
69 int tW,tH,descent,externalLeading;
70 // empty label sets m_label_height as 0 that causes extra spacing at top
71 GetTextExtent(m_label.IsEmpty() ? "Orca" : m_label, &tW, &tH, &descent, &externalLeading, &m_font);
72 m_label_height = tH - externalLeading;
73 m_label_width = tW;
74
75 Bind(wxEVT_PAINT,([this](wxPaintEvent e) {
76 wxPaintDC dc(this);
77 PickDC(dc);
78 }));
79
81 state_handler.update_binds();
82 #ifndef __WXOSX__
83 SetBackgroundStyle(wxBG_STYLE_PAINT);
84 #endif
85 SetBackgroundColour(background_color.colorForStates(state_handler.states()));
86 SetForegroundColour( text_color.colorForStates(state_handler.states()));
87 SetBorderColor( border_color.colorForStates(state_handler.states()));
88 SetCanFocus(false);
89 DisableFocusFromKeyboard();
90 return true;
91}
void SetBorderColor(StateColor const &color)
Definition LabeledStaticBox.cpp:105
void PickDC(wxDC &dc)
Definition LabeledStaticBox.cpp:139
wxString m_label
Definition LabeledStaticBox.hpp:70
wxPoint m_pos
Definition LabeledStaticBox.hpp:74
int m_label_width
Definition LabeledStaticBox.hpp:72
int m_label_height
Definition LabeledStaticBox.hpp:71
float m_scale
Definition LabeledStaticBox.hpp:73
void staticbox_remove_margin(wxStaticBox *sb)
Definition GUI_UtilsMac.mm:19

References background_color, border_color, m_border_width, m_font, m_label, m_label_height, m_label_width, m_pos, m_scale, PickDC(), SetBorderColor(), state_handler, Slic3r::GUI::staticbox_remove_margin(), style, and text_color.

Referenced by LabeledStaticBox().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawBorderAndLabel()

void LabeledStaticBox::DrawBorderAndLabel ( wxDC & dc)
protectedvirtual
167{
168 // fill full background
169 dc.SetBackground(wxBrush(background_color.colorForStates(0)));
170 dc.Clear();
171
172 wxSize wSz = GetSize();
173
174 dc.SetBrush(*wxTRANSPARENT_BRUSH);
175 dc.SetPen(wxPen(border_color.colorForStates(state_handler.states()), m_border_width, wxPENSTYLE_SOLID));
176 dc.DrawRoundedRectangle( // Border
177 std::max(0, m_pos.x),
178 std::max(0, m_pos.y) + m_label_height * .5,
179 wSz.GetWidth(),
180 wSz.GetHeight() - m_label_height * .5,
182 );
183
184 if (!m_label.IsEmpty()) {
185 dc.SetFont(m_font);
186 dc.SetPen(*wxTRANSPARENT_PEN);
187 dc.SetBrush(wxBrush(background_color.colorForStates(0)));
188 dc.DrawRectangle(wxRect(7 * m_scale,0 , m_label_width + 7 * m_scale, m_label_height)); // text background
189 // NEEDFIX if text lenght > client size
190 dc.SetTextForeground(text_color.colorForStates(state_handler.states()));
191 dc.DrawText(m_label, wxPoint(10 * m_scale, 0));
192 }
193}

References background_color, border_color, m_border_width, m_font, m_label, m_label_height, m_label_width, m_pos, m_radius, m_scale, state_handler, and text_color.

Referenced by PickDC().

Here is the caller graph for this function:

◆ Enable()

bool LabeledStaticBox::Enable ( bool enable)
override
127{
128 bool result = this->wxStaticBox::Enable(enable);
129 if (result) {
130 wxCommandEvent e(EVT_ENABLE_CHANGED);
131 e.SetEventObject(this);
132 GetEventHandler()->ProcessEvent(e);
133 this->SetForegroundColour( text_color.colorForStates(state_handler.states()));
134 this->SetBorderColor( border_color.colorForStates(state_handler.states()));
135 }
136 return result;
137}

References border_color, SetBorderColor(), state_handler, and text_color.

Here is the call graph for this function:

◆ GetBorderColor()

StateColor LabeledStaticBox::GetBorderColor ( ) const
inline
56{ return border_color; }

References border_color.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ GetBordersForSizer()

void LabeledStaticBox::GetBordersForSizer ( int * borderTop,
int * borderOther ) const
overrideprotected
195 {
196 wxStaticBox::GetBordersForSizer(borderTop, borderOther);
197#ifdef __WXOSX__
198 *borderOther = 5; // Make sure macOS uses the same border padding as other platforms
199#endif
200}

◆ GetBorderWidth()

int LabeledStaticBox::GetBorderWidth ( ) const
inline
55{ return m_border_width; }

References m_border_width.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ GetCornerRadius()

int LabeledStaticBox::GetCornerRadius ( ) const
inline
54{ return m_radius; }

References m_radius.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ GetScale()

float LabeledStaticBox::GetScale ( ) const
inline
57{ return m_scale; }

References m_scale.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ PickDC()

void LabeledStaticBox::PickDC ( wxDC & dc)
private
140{
141#ifdef __WXMSW__
142 wxSize size = GetSize();
143 if (size.x <= 0 || size.y <= 0)
144 return;
145 wxMemoryDC memdc(&dc);
146 if (!memdc.IsOk()) {
148 return;
149 }
150 wxBitmap bmp(size.x, size.y);
151 memdc.SelectObject(bmp);
152 memdc.SetBackground(wxBrush(GetBackgroundColour()));
153 memdc.Clear();
154 {
155 wxGCDC dc2(memdc);
157 }
158
159 memdc.SelectObject(wxNullBitmap);
160 dc.DrawBitmap(bmp, 0, 0);
161#else
163#endif
164}
virtual void DrawBorderAndLabel(wxDC &dc)
Definition LabeledStaticBox.cpp:166

References DrawBorderAndLabel().

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBorderColor()

void LabeledStaticBox::SetBorderColor ( StateColor const & color)
106{
107 border_color = color;
108 state_handler.update_binds();
109 Refresh();
110}

References border_color, and state_handler.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps(), Create(), and Enable().

Here is the caller graph for this function:

◆ SetBorderWidth()

void LabeledStaticBox::SetBorderWidth ( int width)
100{
101 this->m_border_width = width;
102 Refresh();
103}
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184

References m_border_width.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ SetCornerRadius()

void LabeledStaticBox::SetCornerRadius ( int radius)
94{
95 this->m_radius = radius;
96 Refresh();
97}

References m_radius.

Referenced by CustomWidgetsPlugin::addLabeledStaticBoxProps().

Here is the caller graph for this function:

◆ SetFont()

bool LabeledStaticBox::SetFont ( const wxFont & set_font)
override
113{
114 m_font = set_font;
115
116 int tW,tH,descent,externalLeading;
117 // empty label sets m_label_height as 0 that causes extra spacing at top
118 GetTextExtent(m_label.IsEmpty() ? "Orca" : m_label, &tW, &tH, &descent, &externalLeading, &m_font);
119 m_label_height = tH - externalLeading;
120 m_label_width = tW;
121
122 Refresh();
123 return true;
124}

References m_font, m_label, m_label_height, and m_label_width.

Member Data Documentation

◆ background_color

StateColor LabeledStaticBox::background_color
protected

◆ border_color

StateColor LabeledStaticBox::border_color
protected

◆ m_border_width

int LabeledStaticBox::m_border_width
protected

◆ m_font

wxFont LabeledStaticBox::m_font
protected

◆ m_label

wxString LabeledStaticBox::m_label
protected

Referenced by Create(), DrawBorderAndLabel(), and SetFont().

◆ m_label_height

int LabeledStaticBox::m_label_height
protected

Referenced by Create(), DrawBorderAndLabel(), and SetFont().

◆ m_label_width

int LabeledStaticBox::m_label_width
protected

Referenced by Create(), DrawBorderAndLabel(), and SetFont().

◆ m_pos

wxPoint LabeledStaticBox::m_pos
protected

Referenced by Create(), and DrawBorderAndLabel().

◆ m_radius

int LabeledStaticBox::m_radius
protected

◆ m_scale

float LabeledStaticBox::m_scale
protected

◆ state_handler

StateHandler LabeledStaticBox::state_handler
protected

◆ text_color

StateColor LabeledStaticBox::text_color
protected

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