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

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

Inheritance diagram for Slic3r::GUI::AmsHumidityTipPopup:
Collaboration diagram for Slic3r::GUI::AmsHumidityTipPopup:

Public Member Functions

 AmsHumidityTipPopup (wxWindow *parent)
 ~AmsHumidityTipPopup ()
void set_humidity_level (int level)
void msw_rescale ()
bool Create (wxWindow *parent, int flags=wxBORDER_NONE)

Protected Member Functions

virtual bool ShouldDismissOnTopWindowDeactivate ()

Private Member Functions

virtual void OnDismiss () wxOVERRIDE
virtual bool ProcessLeftDown (wxMouseEvent &event) wxOVERRIDE
void paintEvent (wxPaintEvent &evt)
void render (wxDC &dc)
void doRender (wxDC &dc)

Private Attributes

int current_humidity_level = 0
ScalableBitmap close_img
wxStaticBitmap * curr_humidity_img
Label * m_staticText
Label * m_staticText_note
AmsHumidityLevelList * humidity_level_list {nullptr}

Detailed Description

Constructor & Destructor Documentation

◆ AmsHumidityTipPopup()

Slic3r::GUI::AmsHumidityTipPopup::AmsHumidityTipPopup ( wxWindow * parent)
1714 :PopupWindow(parent, wxBORDER_NONE)
1715{
1716 SetBackgroundColour(*wxWHITE);
1717
1718 wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
1719
1720 close_img = ScalableBitmap(this, "hum_popup_close", 24);
1721
1722 m_staticText = new Label(this, _L("Current AMS humidity"));
1724
1725 humidity_level_list = new AmsHumidityLevelList(this);
1726 curr_humidity_img = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("hum_level1_light", this, 132), wxDefaultPosition, wxSize(FromDIP(132), FromDIP(132)), 0);
1727
1728 // Orca: kept the grammatically-corrected desiccant note (existing translation)
1729 m_staticText_note = new Label(this, _L("Please change the desiccant when it is too wet. The indicator may not represent accurately in following cases: when the lid is open or the desiccant pack is changed. It takes a few hours to absorb the moisture, and low temperatures also slow down the process."));
1730 m_staticText_note->SetMinSize(wxSize(FromDIP(680), -1));
1731 m_staticText_note->SetMaxSize(wxSize(FromDIP(680), -1));
1732 m_staticText_note->Wrap(FromDIP(680));
1733
1734
1735 Bind(wxEVT_LEFT_UP, [this](auto& e) {
1736
1737 auto rect = ClientToScreen(wxPoint(0, 0));
1738
1739 auto close_left = rect.x + GetSize().x - close_img.GetBmpWidth() - FromDIP(38);
1740 auto close_right = close_left + close_img.GetBmpWidth();
1741 auto close_top = rect.y + FromDIP(24);
1742 auto close_bottom = close_top + close_img.GetBmpHeight();
1743
1744 auto mouse_pos = ClientToScreen(e.GetPosition());
1745 if (mouse_pos.x > close_left
1746 && mouse_pos.y > close_top
1747 && mouse_pos.x < close_right
1748 && mouse_pos.y < close_bottom
1749 )
1750 {
1751 Dismiss();
1752 }
1753 });
1754
1755 main_sizer->Add(0, 0, 0, wxTOP, FromDIP(24));
1756 main_sizer->Add(m_staticText, 0, wxALIGN_CENTER, 0);
1757 main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(28));
1758 main_sizer->Add(curr_humidity_img, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(35));
1759 main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(15));
1760 main_sizer->Add(humidity_level_list, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, FromDIP(35));
1761 main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6));
1762 main_sizer->Add(m_staticText_note, 0, wxALIGN_CENTER, 0);
1763 main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(5));
1764 main_sizer->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(25));
1765 SetSizer(main_sizer);
1766 Layout();
1767 Fit();
1768
1769 Bind(wxEVT_PAINT, &AmsHumidityTipPopup::paintEvent, this);
1770 wxGetApp().UpdateDarkUIWin(this);
1771}
#define _L(s)
Definition OBJ.cpp:34
static wxFont Head_24
Definition Label.hpp:40
PopupWindow()
Definition PopupWindow.hpp:10
Label * m_staticText
Definition AmsMappingPopup.hpp:469
ScalableBitmap close_img
Definition AmsMappingPopup.hpp:465
Label * m_staticText_note
Definition AmsMappingPopup.hpp:470
wxStaticBitmap * curr_humidity_img
Definition AmsMappingPopup.hpp:467
AmsHumidityLevelList * humidity_level_list
Definition AmsMappingPopup.hpp:472
void paintEvent(wxPaintEvent &evt)
Definition AmsMappingPopup.cpp:1805
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References PopupWindow::PopupWindow(), _L, close_img, create_scaled_bitmap(), curr_humidity_img, Label::Head_24, humidity_level_list, m_staticText, m_staticText_note, and paintEvent().

Here is the call graph for this function:

◆ ~AmsHumidityTipPopup()

Slic3r::GUI::AmsHumidityTipPopup::~AmsHumidityTipPopup ( )
inline
448{};

Member Function Documentation

◆ Create()

bool PopupWindow::Create ( wxWindow * parent,
int flags = wxBORDER_NONE )
inherited
22{
23 if (!wxPopupTransientWindow::Create(parent, style))
24 return false;
25#ifdef __WXGTK__
26 GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
27#endif
28#ifdef __WXOSX__
29 if (style & wxPU_CONTAINS_CONTROLS)
30 for (auto evt : {wxEVT_LEFT_DOWN, wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK, wxEVT_MOTION, wxEVT_MOUSEWHEEL})
31 Bind(evt, &PopupWindow::OnMouseEvent2, this);
32#endif
33 return true;
34}
static wxWindow * GetTopParent(wxWindow *pWindow)
Definition PopupWindow.cpp:10
#define style
Definition WipeTowerDialog.cpp:101

References GetTopParent(), and style.

Referenced by PopupWindow(), and DropDown::Create().

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

◆ doRender()

void Slic3r::GUI::AmsHumidityTipPopup::doRender ( wxDC & dc)
private
1833{
1834 //close
1835 dc.DrawBitmap(close_img.bmp(), GetSize().x - close_img.GetBmpWidth() - FromDIP(38), FromDIP(24));
1836
1837 //background
1838 dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
1839 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1840 dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
1841}

References close_img.

Referenced by render().

Here is the caller graph for this function:

◆ msw_rescale()

void Slic3r::GUI::AmsHumidityTipPopup::msw_rescale ( )
1786{
1787 // close image
1788 close_img.msw_rescale();
1789
1790 // current humidity level image
1792 {
1793 std::string mode_string = wxGetApp().dark_mode() ? "_dark" : "_light";
1794 curr_humidity_img->SetBitmap(create_scaled_bitmap("hum_level" + std::to_string(current_humidity_level) + mode_string, this, 132));
1795 }
1796
1797 // the list
1798 humidity_level_list->msw_rescale();
1799
1800 // refresh
1801 Refresh();
1802}
int current_humidity_level
Definition AmsMappingPopup.hpp:463

References close_img, create_scaled_bitmap(), curr_humidity_img, current_humidity_level, and humidity_level_list.

Here is the call graph for this function:

◆ OnDismiss()

virtual void Slic3r::GUI::AmsHumidityTipPopup::OnDismiss ( )
inlineprivatevirtual
455{};

◆ paintEvent()

void Slic3r::GUI::AmsHumidityTipPopup::paintEvent ( wxPaintEvent & evt)
private
1806{
1807 wxPaintDC dc(this);
1808 render(dc);
1809}
void render(wxDC &dc)
Definition AmsMappingPopup.cpp:1811

References render().

Referenced by AmsHumidityTipPopup().

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

◆ ProcessLeftDown()

virtual bool Slic3r::GUI::AmsHumidityTipPopup::ProcessLeftDown ( wxMouseEvent & event)
inlineprivatevirtual
456{ return PopupWindow::ProcessLeftDown(event); };

References Slic3r::GUI::wxMouseEvent.

◆ render()

void Slic3r::GUI::AmsHumidityTipPopup::render ( wxDC & dc)
private
1812{
1813#ifdef __WXMSW__
1814 wxSize size = GetSize();
1815 wxMemoryDC memdc;
1816 wxBitmap bmp(size.x, size.y);
1817 memdc.SelectObject(bmp);
1818 memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
1819
1820 {
1821 wxGCDC dc2(memdc);
1822 doRender(dc2);
1823 }
1824
1825 memdc.SelectObject(wxNullBitmap);
1826 dc.DrawBitmap(bmp, 0, 0);
1827#else
1828 doRender(dc);
1829#endif
1830}
void doRender(wxDC &dc)
Definition AmsMappingPopup.cpp:1832

References doRender().

Referenced by paintEvent().

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

◆ set_humidity_level()

void Slic3r::GUI::AmsHumidityTipPopup::set_humidity_level ( int level)
1774{
1775 if (0 < level && level < 6)
1776 {
1777 current_humidity_level = level;
1778 std::string mode_string = wxGetApp().dark_mode() ? "_dark" : "_light";
1779 curr_humidity_img->SetBitmap(create_scaled_bitmap("hum_level" + std::to_string(current_humidity_level) + mode_string, this, 132));
1780 curr_humidity_img->Refresh();
1781 curr_humidity_img->Update();
1782 }
1783}

References create_scaled_bitmap(), curr_humidity_img, and current_humidity_level.

Here is the call graph for this function:

◆ ShouldDismissOnTopWindowDeactivate()

virtual bool PopupWindow::ShouldDismissOnTopWindowDeactivate ( )
inlineprotectedvirtualinherited

Reimplemented in DropDown.

28{ return true; }

Member Data Documentation

◆ close_img

ScalableBitmap Slic3r::GUI::AmsHumidityTipPopup::close_img
private

◆ curr_humidity_img

wxStaticBitmap* Slic3r::GUI::AmsHumidityTipPopup::curr_humidity_img
private

◆ current_humidity_level

int Slic3r::GUI::AmsHumidityTipPopup::current_humidity_level = 0
private

Referenced by msw_rescale(), and set_humidity_level().

◆ humidity_level_list

AmsHumidityLevelList* Slic3r::GUI::AmsHumidityTipPopup::humidity_level_list {nullptr}
private
472{nullptr};

Referenced by AmsHumidityTipPopup(), and msw_rescale().

◆ m_staticText

Label* Slic3r::GUI::AmsHumidityTipPopup::m_staticText
private

Referenced by AmsHumidityTipPopup().

◆ m_staticText_note

Label* Slic3r::GUI::AmsHumidityTipPopup::m_staticText_note
private

Referenced by AmsHumidityTipPopup().


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