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

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

Inheritance diagram for ProgressBar:
Collaboration diagram for ProgressBar:

Public Member Functions

 ProgressBar ()
 ProgressBar (wxWindow *parent, wxWindowID id=wxID_ANY, int max=100, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, bool shown=false)
void create (wxWindow *parent, wxWindowID id, const wxPoint &pos, wxSize &size)
 ~ProgressBar ()
void ShowNumber (bool shown)
void Disable (wxString text)
void SetValue (int step)
void Reset ()
void SetProgress (int step)
void SetRadius (double radius)
void SetProgressForedColour (wxColour colour)
void SetProgressBackgroundColour (wxColour colour)
void Rescale ()
void SetHeight (int height)
virtual void SetMinSize (const wxSize &size) override

Public Attributes

bool m_shownumber = {false}
int m_disable = {false}
int m_max = {100}
int m_step = {0}
int m_miniHeight = {0}
const int miniHeight = {14}
double m_radius = {7}
double m_proportion = {0}
wxColour m_progress_background_colour = {233, 233, 233}
wxColour m_progress_colour = {0, 150, 136}
wxColour m_progress_colour_disable = {255, 111, 0}
wxString m_disable_text

Protected Member Functions

void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
void doRender (wxDC &dc)
virtual void DoSetSize (int x, int y, int width, int height, int sizeFlags=wxSIZE_AUTO) override

Detailed Description

Constructor & Destructor Documentation

◆ ProgressBar() [1/2]

ProgressBar::ProgressBar ( )

Referenced by ProgressBar().

Here is the caller graph for this function:

◆ ProgressBar() [2/2]

ProgressBar::ProgressBar ( wxWindow * parent,
wxWindowID id = wxID_ANY,
int max = 100,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
bool shown = false )
18{
19 m_shownumber = shown;
20 SetBackgroundColour(wxColour(255,255,255));
21
22 if (size.y >= miniHeight) {
23 m_miniHeight = size.y;
24 } else {
26 }
27
28 m_max = max;
30 wxSize temp_size(size.x, m_miniHeight);
31
32 SetFont(Label::Head_12);
33 create(parent, id, pos, temp_size);
34}
static wxFont Head_12
Definition Label.hpp:47
double m_radius
Definition ProgressBar.hpp:34
int m_miniHeight
Definition ProgressBar.hpp:32
bool m_shownumber
Definition ProgressBar.hpp:28
int m_max
Definition ProgressBar.hpp:30
const int miniHeight
Definition ProgressBar.hpp:33
void create(wxWindow *parent, wxWindowID id, const wxPoint &pos, wxSize &size)
Definition ProgressBar.cpp:40

References ProgressBar(), create(), Label::Head_12, m_max, m_miniHeight, m_radius, m_shownumber, and miniHeight.

Here is the call graph for this function:

◆ ~ProgressBar()

ProgressBar::~ProgressBar ( )
37{}

Member Function Documentation

◆ create()

void ProgressBar::create ( wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
wxSize & size )
41{
42 wxWindow::Create(parent, id, pos, size);
43 // m_static_info = new wxStaticText(this, wxID_ANY,wxT(""),wxPoint(this->padding, 20), wxSize(GetSize().GetWidth() - this->padding * 3, -1), wxST_ELLIPSIZE_END);
44 // m_static_info->Wrap(-1);
45
46 /* wxBoxSizer *m_sizer_body = new wxBoxSizer(wxHORIZONTAL);
47
48 auto m_progress_bk = new StaticBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
49 m_progress_bk->SetBackgroundColour(wxColour(238, 130, 238));
50 StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
51 std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
52
53 wxBoxSizer *m_sizer_progress= new wxBoxSizer(wxHORIZONTAL);
54
55 auto m_progress = new wxPanel(m_progress_bk, wxID_ANY, wxDefaultPosition, wxSize(50, -1), wxTAB_TRAVERSAL);
56 m_progress->SetBackgroundColour(wxColour(128, 0, 255));
57
58 m_sizer_progress->Add(m_progress, 0, wxEXPAND, 0);
59
60 m_progress_bk->SetSizer(m_sizer_progress);
61 m_progress_bk->Layout();
62 m_sizer_progress->Fit(m_progress_bk);
63 m_sizer_body->Add(m_progress_bk, 1, wxEXPAND, 0);
64
65 this->SetSizer(m_sizer_body);
66 this->Layout();*/
67}

Referenced by ProgressBar().

Here is the caller graph for this function:

◆ Disable()

void ProgressBar::Disable ( wxString text)
99{
100 if (m_disable) return;
101 m_disable_text = text;
102 m_disable = true;
103 Refresh();
104}
wxString m_disable_text
Definition ProgressBar.hpp:39
int m_disable
Definition ProgressBar.hpp:29

References m_disable, and m_disable_text.

◆ doRender()

void ProgressBar::doRender ( wxDC & dc)
protected
176{
177 if (m_step >= m_max) m_step = m_max;
178 wxSize size = GetSize();
179 dc.SetPen(wxPen(m_progress_background_colour, 1));
180 dc.SetBrush(wxBrush(m_progress_background_colour));
181 if (m_radius == 0) {
182 dc.DrawRectangle(0, 0, size.x, size.y);
183 } else {
184 dc.DrawRoundedRectangle(0, 0, size.x, size.y, m_radius);
185 }
186
187 //draw progress
188 if (m_disable) {
189 m_proportion = float(size.x * float(this->m_step) / float(this->m_max));
190 if (m_proportion < m_radius * 2 && m_proportion != 0) { m_proportion = m_radius * 2; }
191
192 dc.SetPen(wxPen(m_progress_colour_disable, 1));
193 dc.SetBrush(wxBrush(m_progress_colour_disable));
194 if (m_radius == 0) {
195 dc.DrawRectangle(0, 0, m_proportion, size.y);
196 } else {
197 dc.DrawRoundedRectangle(0, 0, m_proportion, size.y, m_radius);
198 }
199
200 dc.SetFont(::Label::Head_12);
201 auto textSize = dc.GetMultiLineTextExtent(m_disable_text);
202 dc.SetTextForeground(wxColour(144, 144, 144));
203 auto pt = wxPoint();
204 pt.x = (size.x - textSize.x) / 2;
205 pt.y = (size.y - textSize.y) / 2;
206 dc.DrawText(m_disable_text, pt);
207
208 } else {
209 m_proportion = float(size.x * float(this->m_step) / float(this->m_max));
210 if (m_proportion < m_radius * 2 && m_proportion != 0) { m_proportion = m_radius * 2; }
211
212 dc.SetPen(wxPen(m_progress_colour, 1));
213 dc.SetBrush(wxBrush(m_progress_colour));
214 if (m_radius == 0) {
215 dc.DrawRectangle(0, 0, m_proportion, size.y);
216 } else {
217 dc.DrawRoundedRectangle(0, 0, m_proportion, size.y, m_radius);
218 }
219
220 dc.SetFont(GetFont());
221 auto textSize = dc.GetMultiLineTextExtent(wxString("000%"));
222 dc.SetTextForeground(wxColour(144, 144, 144));
223 auto pt = wxPoint();
224 pt.x = (size.x - textSize.x) / 2;
225 pt.y = (size.y - textSize.y) / 2;
226
227 auto text = wxString("");
228 if (m_step < 10) {
229 text = wxString::Format("%d", m_step);
230 } else {
231 text = wxString::Format("%d", m_step);
232 }
233
234 if (m_shownumber) {
235 dc.DrawText(text + wxString("%"), pt);
236 }
237 }
238
239}
double m_proportion
Definition ProgressBar.hpp:35
wxColour m_progress_colour
Definition ProgressBar.hpp:37
wxColour m_progress_background_colour
Definition ProgressBar.hpp:36
wxColour m_progress_colour_disable
Definition ProgressBar.hpp:38
int m_step
Definition ProgressBar.hpp:31

References Label::Head_12, m_disable, m_disable_text, m_max, m_progress_background_colour, m_progress_colour, m_progress_colour_disable, m_proportion, m_radius, m_shownumber, and m_step.

Referenced by render().

Here is the caller graph for this function:

◆ DoSetSize()

void ProgressBar::DoSetSize ( int x,
int y,
int width,
int height,
int sizeFlags = wxSIZE_AUTO )
overrideprotectedvirtual
243{
244 wxWindow::DoSetSize(x, y, width, height, sizeFlags);
245}

◆ paintEvent()

void ProgressBar::paintEvent ( wxPaintEvent & evt)
protected
148{
149
150 wxPaintDC dc(this);
151 render(dc);
152}
void render(wxDC &dc)
Definition ProgressBar.cpp:154

References render().

Referenced by wxDEFINE_EVENT().

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

◆ render()

void ProgressBar::render ( wxDC & dc)
protected
155{
156#ifdef __WXMSW__
157 wxSize size = GetSize();
158 wxMemoryDC memdc;
159 wxBitmap bmp(size.x, size.y);
160 memdc.SelectObject(bmp);
161 memdc.Blit({0, 0}, size, &dc, {0, 0});
162
163 {
164 wxGCDC dc2(memdc);
165 doRender(dc2);
166 }
167
168 memdc.SelectObject(wxNullBitmap);
169 dc.DrawBitmap(bmp, 0, 0);
170#else
171 doRender(dc);
172#endif
173}
void doRender(wxDC &dc)
Definition ProgressBar.cpp:175

References doRender().

Referenced by paintEvent().

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

◆ Rescale()

void ProgressBar::Rescale ( )
88{
89 ;
90}

◆ Reset()

void ProgressBar::Reset ( )
113{
114 m_step = 0;
115 SetValue(0);
116}
void SetValue(int step)
Definition ProgressBar.cpp:106

References m_step, and SetValue().

Here is the call graph for this function:

◆ SetHeight()

void ProgressBar::SetHeight ( int height)
inline
52 {
53 m_minHeight = height;
54 m_radius = m_minHeight / 2;
55 SetSize(GetSize().x, height);
56 }
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References m_radius.

◆ SetMinSize()

void ProgressBar::SetMinSize ( const wxSize & size)
overridevirtual
133{
134 if (size.y >= miniHeight) {
135 m_miniHeight = size.y;
136 } else {
137 return;
138 }
139
140 m_radius = m_miniHeight / 2.4;
141 wxWindow::SetMinSize({size.x, m_miniHeight});
142 // SetSize(size);
144}
void SetRadius(double radius)
Definition ProgressBar.cpp:70

References m_miniHeight, m_radius, miniHeight, and SetRadius().

Here is the call graph for this function:

◆ SetProgress()

void ProgressBar::SetProgress ( int step)
119{
120 if (step < 0) return;
121 if (m_disable == false && m_step == step)
122 {
123 return;
124 }
125
126 m_disable = false;
127 m_step = step;
128 Refresh();
129}
void step(Coord &crd, const Dir d, const long n=1)
Definition MarchingSquares.hpp:213

References m_disable, and m_step.

Referenced by SetValue().

Here is the caller graph for this function:

◆ SetProgressBackgroundColour()

void ProgressBar::SetProgressBackgroundColour ( wxColour colour)
82{
83 m_progress_colour = colour;
84 Refresh();
85}

References m_progress_colour.

◆ SetProgressForedColour()

void ProgressBar::SetProgressForedColour ( wxColour colour)
76{
78 Refresh();
79}

References m_progress_background_colour.

◆ SetRadius()

void ProgressBar::SetRadius ( double radius)
70 {
71 m_radius = radius;
72 Refresh();
73}

References m_radius.

Referenced by SetMinSize().

Here is the caller graph for this function:

◆ SetValue()

void ProgressBar::SetValue ( int step)
107{
108 m_disable = false;
109 SetProgress(step);
110}
void SetProgress(int step)
Definition ProgressBar.cpp:118

References m_disable, and SetProgress().

Referenced by Reset().

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

◆ ShowNumber()

void ProgressBar::ShowNumber ( bool shown)
93{
94 m_shownumber = shown;
95 Refresh();
96}

References m_shownumber.

Member Data Documentation

◆ m_disable

int ProgressBar::m_disable = {false}
29{false};

Referenced by Disable(), doRender(), SetProgress(), and SetValue().

◆ m_disable_text

wxString ProgressBar::m_disable_text

Referenced by Disable(), and doRender().

◆ m_max

int ProgressBar::m_max = {100}
30{100};

Referenced by ProgressBar(), and doRender().

◆ m_miniHeight

int ProgressBar::m_miniHeight = {0}
32{0};

Referenced by ProgressBar(), and SetMinSize().

◆ m_progress_background_colour

wxColour ProgressBar::m_progress_background_colour = {233, 233, 233}
36{233, 233, 233};

Referenced by doRender(), and SetProgressForedColour().

◆ m_progress_colour

wxColour ProgressBar::m_progress_colour = {0, 150, 136}
37{0, 150, 136};

Referenced by doRender(), and SetProgressBackgroundColour().

◆ m_progress_colour_disable

wxColour ProgressBar::m_progress_colour_disable = {255, 111, 0}
38{255, 111, 0};

Referenced by doRender().

◆ m_proportion

double ProgressBar::m_proportion = {0}

◆ m_radius

double ProgressBar::m_radius = {7}

◆ m_shownumber

bool ProgressBar::m_shownumber = {false}

◆ m_step

int ProgressBar::m_step = {0}
31{0};

Referenced by doRender(), Reset(), and SetProgress().

◆ miniHeight

const int ProgressBar::miniHeight = {14}
33{14};

Referenced by ProgressBar(), and SetMinSize().


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