OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::wgtMsgPanelItem Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceTab/wgtMsgPanel.h>

Inheritance diagram for Slic3r::GUI::wgtMsgPanelItem:
Collaboration diagram for Slic3r::GUI::wgtMsgPanelItem:

Public Member Functions

 wgtMsgPanelItem (wxWindow *parent, const wxColour &colour, const wxString &text, int max_width, const wxString &wiki_url=wxEmptyString)
void SetColour (const wxColour &colour)
void SetText (const wxString &text)
void SetWiki (const wxString &wiki_url)

Private Member Functions

void CreateGui ()
void OnClickWiki (wxHyperlinkEvent &evt)

Private Attributes

int m_max_width
wxColour m_colour
wxString m_text
wxString m_wiki_url
Label * m_text_label { nullptr }
wxHyperlinkCtrl * m_wiki_link { nullptr }

Detailed Description

Constructor & Destructor Documentation

◆ wgtMsgPanelItem()

Slic3r::GUI::wgtMsgPanelItem::wgtMsgPanelItem ( wxWindow * parent,
const wxColour & colour,
const wxString & text,
int max_width,
const wxString & wiki_url = wxEmptyString )
26 : wxPanel(parent, wxID_ANY)
27 , m_max_width(max_width)
28 , m_colour(colour)
29 , m_text(text)
30 , m_wiki_url(wiki_url)
31{
32 CreateGui();
33}
wxColour m_colour
Definition wgtMsgPanel.h:42
int m_max_width
Definition wgtMsgPanel.h:41
wxString m_text
Definition wgtMsgPanel.h:43
wxString m_wiki_url
Definition wgtMsgPanel.h:44
void CreateGui()
Definition wgtMsgPanel.cpp:35

References CreateGui(), m_colour, m_max_width, m_text, and m_wiki_url.

Here is the call graph for this function:

Member Function Documentation

◆ CreateGui()

void Slic3r::GUI::wgtMsgPanelItem::CreateGui ( )
private
36{
37 SetBackgroundColour(StateColor::darkModeColorFor(wxColour(*wxWHITE)));
38
39 wxBoxSizer* main_sizer = new wxBoxSizer(wxHORIZONTAL);
40
41 // Color bar on the left
42 //wxPanel* color_bar = new wxPanel(this, wxID_ANY);
43 //color_bar->SetMinSize(wxSize(FromDIP(4), -1));
44 //color_bar->SetBackgroundColour(m_colour);
45 //main_sizer->Add(color_bar, 0, wxEXPAND | wxRIGHT, FromDIP(4));
46
47 // Text and optional wiki link
48 wxBoxSizer* text_sizer = new wxBoxSizer(wxHORIZONTAL);
49
50 m_text_label = new ::Label(this, m_text);
52 m_text_label->SetBackgroundColour(StateColor::darkModeColorFor(wxColour(*wxWHITE)));
53 m_text_label->SetForegroundColour(m_colour);
54 if (!m_wiki_url.IsEmpty()) {
55 m_text_label->Wrap(m_max_width - FromDIP(20)); // Wrap text to fit within a reasonable width
56 } else {
57 m_text_label->Wrap(m_max_width - FromDIP(10)); // Wrap text to fit within a reasonable width
58 }
59
60 text_sizer->Add(m_text_label, 0, wxALIGN_CENTER_VERTICAL);
61
62 if (!m_wiki_url.IsEmpty()) {
63 m_wiki_link = new wxHyperlinkCtrl(this, wxID_ANY, _L("Wiki->"), m_wiki_url);
64 m_wiki_link->SetNormalColour(m_colour);
65 m_wiki_link->SetHoverColour(wxColour(0, 0, 200));
66 m_wiki_link->SetVisitedColour(*wxBLUE);
67 Bind(wxEVT_HYPERLINK, &wgtMsgPanelItem::OnClickWiki, this, m_wiki_link->GetId());
68 text_sizer->AddSpacer(FromDIP(4));
69 text_sizer->Add(m_wiki_link, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND);
70 }
71
72 main_sizer->Add(text_sizer, 0, wxALIGN_LEFT | wxEXPAND);
73
74 SetSizer(main_sizer);
75 Layout();
76 Fit();
77}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Body_13
Definition Label.hpp:54
Label * m_text_label
Definition wgtMsgPanel.h:46
void OnClickWiki(wxHyperlinkEvent &evt)
Definition wgtMsgPanel.cpp:102
wxHyperlinkCtrl * m_wiki_link
Definition wgtMsgPanel.h:47
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References _L, Label::Body_13, StateColor::darkModeColorFor(), m_colour, m_max_width, m_text, m_text_label, m_wiki_link, m_wiki_url, and OnClickWiki().

Referenced by wgtMsgPanelItem().

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

◆ OnClickWiki()

void Slic3r::GUI::wgtMsgPanelItem::OnClickWiki ( wxHyperlinkEvent & evt)
private
103{
104 if (!m_wiki_url.IsEmpty()) {
105 wxLaunchDefaultBrowser(m_wiki_url);
106 }
107}

References m_wiki_url.

Referenced by CreateGui().

Here is the caller graph for this function:

◆ SetColour()

void Slic3r::GUI::wgtMsgPanelItem::SetColour ( const wxColour & colour)
80{
81 m_colour = colour;
82 // Simple handling: refresh the whole control to redraw the color bar
83 Refresh();
84}

References m_colour.

◆ SetText()

void Slic3r::GUI::wgtMsgPanelItem::SetText ( const wxString & text)
87{
88 m_text = text;
89 if (m_text_label) {
90 m_text_label->SetLabel(m_text);
91 }
92}

References m_text, and m_text_label.

◆ SetWiki()

void Slic3r::GUI::wgtMsgPanelItem::SetWiki ( const wxString & wiki_url)
95{
96 m_wiki_url = wiki_url;
97 if (m_wiki_link) {
98 m_wiki_link->SetURL(m_wiki_url);
99 }
100}

References m_wiki_link, and m_wiki_url.

Member Data Documentation

◆ m_colour

wxColour Slic3r::GUI::wgtMsgPanelItem::m_colour
private

◆ m_max_width

int Slic3r::GUI::wgtMsgPanelItem::m_max_width
private

Referenced by wgtMsgPanelItem(), and CreateGui().

◆ m_text

wxString Slic3r::GUI::wgtMsgPanelItem::m_text
private

Referenced by wgtMsgPanelItem(), CreateGui(), and SetText().

◆ m_text_label

Label* Slic3r::GUI::wgtMsgPanelItem::m_text_label { nullptr }
private
46{ nullptr };

Referenced by CreateGui(), and SetText().

◆ m_wiki_link

wxHyperlinkCtrl* Slic3r::GUI::wgtMsgPanelItem::m_wiki_link { nullptr }
private
47{ nullptr };

Referenced by CreateGui(), and SetWiki().

◆ m_wiki_url

wxString Slic3r::GUI::wgtMsgPanelItem::m_wiki_url
private

The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceTab/wgtMsgPanel.h
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DeviceTab/wgtMsgPanel.cpp