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

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

Inheritance diagram for StaticLine:
Collaboration diagram for StaticLine:

Public Member Functions

 StaticLine (wxWindow *parent, bool vertical=false, const wxString &label={}, const wxString &icon={})
void SetLabel (const wxString &label) override
void SetIcon (const wxString &icon)
void SetLineColour (wxColour color)
void Rescale ()

Private Member Functions

void paintEvent (wxPaintEvent &evt)
void messureSize ()
void render (wxDC &dc)

Private Attributes

wxColour lineColor
bool vertical
ScalableBitmap icon

Detailed Description

Constructor & Destructor Documentation

◆ StaticLine()

StaticLine::StaticLine ( wxWindow * parent,
bool vertical = false,
const wxString & label = {},
const wxString & icon = {} )
26 : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE)
28{
29 wxWindow::SetBackgroundColour(parent->GetBackgroundColour());
30 this->lineColor = wxColour("#EEEEEE");
31 DisableFocusFromKeyboard();
32 SetFont(Label::Body_14);
33 wxWindow::SetLabel(label);
35}
static wxFont Body_14
Definition Label.hpp:53
ScalableBitmap icon
Definition StaticLine.hpp:27
bool vertical
Definition StaticLine.hpp:26
wxColour lineColor
Definition StaticLine.hpp:25
void SetIcon(const wxString &icon)
Definition StaticLine.cpp:44

References StaticLine(), Label::Body_14, icon, lineColor, SetIcon(), and vertical.

Referenced by StaticLine().

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

Member Function Documentation

◆ messureSize()

void StaticLine::messureSize ( )
private
72{
73 wxClientDC dc(this);
74 wxSize textSize = dc.GetTextExtent(GetLabel());
75 wxSize szContent = textSize;
76 if (this->icon.bmp().IsOk()) {
77 if (szContent.y > 0) {
78 // BBS norrow size between text and icon
79 szContent.x += 5;
80 }
81 wxSize szIcon = this->icon.GetBmpSize();
82 szContent.x += szIcon.x;
83 if (szIcon.y > szContent.y) szContent.y = szIcon.y;
84 }
85 if (vertical)
86 szContent.y += 10;
87 else
88 szContent.x += 10;
89 SetMinSize(szContent);
90}

References icon, and vertical.

Referenced by Rescale(), SetIcon(), and SetLabel().

Here is the caller graph for this function:

◆ paintEvent()

void StaticLine::paintEvent ( wxPaintEvent & evt)
private
65{
66 // depending on your system you may need to look at double-buffered dcs
67 wxPaintDC dc(this);
68 render(dc);
69}
void render(wxDC &dc)
Definition StaticLine.cpp:97

References render().

Here is the call graph for this function:

◆ render()

void StaticLine::render ( wxDC & dc)
private
98{
99 wxSize size = GetSize();
100 wxSize textSize;
101 auto label = GetLabel();
102 if (!label.IsEmpty()) textSize = dc.GetTextExtent(label);
103 wxRect titleRect{{0, 0}, size};
104 titleRect.height = wxMax(icon.GetBmpHeight(), textSize.GetHeight());
105 int contentWidth = icon.GetBmpWidth() + ((icon.bmp().IsOk() && textSize.GetWidth() > 0) ? 5 : 0) +
106 textSize.GetWidth();
107 if (vertical) titleRect.Deflate((size.GetWidth() - contentWidth) / 2, 0);
108 if (icon.bmp().IsOk()) {
109 dc.DrawBitmap(icon.bmp(), {0, (size.y - icon.GetBmpHeight()) / 2});
110 titleRect.x += icon.GetBmpWidth() + 5;
111 }
112 if (!label.IsEmpty()) {
113 dc.SetTextForeground(StateColor::darkModeColorFor(GetForegroundColour()));
114 dc.DrawText(label, titleRect.x, (size.GetHeight() - textSize.GetHeight()) / 2);
115 titleRect.x += textSize.GetWidth() + 5;
116 }
117 dc.SetPen(wxPen(StateColor::darkModeColorFor(lineColor)));
118 if (vertical) {
119 size.x /= 2;
120 if (titleRect.y > 0) titleRect.y += 5;
121 dc.DrawLine(size.x, titleRect.y, size.x, size.y);
122 } else {
123 size.y /= 2;
124 dc.DrawLine(titleRect.x, size.y, size.x, size.y);
125 }
126}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), icon, lineColor, and vertical.

Referenced by paintEvent().

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

◆ Rescale()

void StaticLine::Rescale ( )
58{
59 if (this->icon.bmp().IsOk())
60 this->icon.msw_rescale();
62}
void messureSize()
Definition StaticLine.cpp:71

References icon, and messureSize().

Here is the call graph for this function:

◆ SetIcon()

void StaticLine::SetIcon ( const wxString & icon)
45{
46 this->icon = icon.IsEmpty() ? ScalableBitmap()
47 : ScalableBitmap(this, icon.ToStdString(), 18);
49 Refresh();
50}

References icon, and messureSize().

Referenced by StaticLine().

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

◆ SetLabel()

void StaticLine::SetLabel ( const wxString & label)
override
38{
39 wxWindow::SetLabel(label);
41 Refresh();
42}

References messureSize().

Here is the call graph for this function:

◆ SetLineColour()

void StaticLine::SetLineColour ( wxColour color)
53{
54 this->lineColor = color;
55}

References lineColor.

Member Data Documentation

◆ icon

ScalableBitmap StaticLine::icon
private

◆ lineColor

wxColour StaticLine::lineColor
private

Referenced by StaticLine(), render(), and SetLineColour().

◆ vertical

bool StaticLine::vertical
private

Referenced by StaticLine(), messureSize(), and render().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/StaticLine.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/StaticLine.cpp