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

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

Inheritance diagram for Slic3r::GUI::GridCellSupportRenderer:
Collaboration diagram for Slic3r::GUI::GridCellSupportRenderer:

Public Member Functions

virtual void Draw (wxGrid &grid, wxGridCellAttr &attr, wxDC &dc, const wxRect &rect, int row, int col, bool isSelected) wxOVERRIDE
virtual wxSize GetBestSize (wxGrid &WXUNUSED(grid), wxGridCellAttr &attr, wxDC &dc, int WXUNUSED(row), int WXUNUSED(col)) wxOVERRIDE
virtual GridCellSupportRenderer * Clone () const wxOVERRIDE

Detailed Description

Member Function Documentation

◆ Clone()

GridCellSupportRenderer * Slic3r::GUI::GridCellSupportRenderer::Clone ( ) const
virtual
804{
805 return new GridCellSupportRenderer();
806}

◆ Draw()

void Slic3r::GUI::GridCellSupportRenderer::Draw ( wxGrid & grid,
wxGridCellAttr & attr,
wxDC & dc,
const wxRect & rect,
int row,
int col,
bool isSelected )
virtual
680{
681 /*ObjectGridTable *table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
682 wxRect text_rect = rect;
683
684 if (table) {
685 ObjectGridTable::ObjectGridCol* grid_col = table->get_grid_col(col);
686 ObjectGridTable::ObjectGridRow* grid_row = table->get_grid_row(row - 1);
687 ConfigOptionBool& cur_option = dynamic_cast<ConfigOptionBool&>((*grid_row)[(ObjectGridTable::GridColType)col]);
688 wxString support_text;
689
690 if (cur_option.value)
691 support_text = L("Support Enabled");
692 else
693 support_text = L("Support Disabled");
694 int text_width, text_height;
695 grid.GetTextExtent(L("Support Disabled"), &text_width, &text_height, NULL, NULL, &Label::Body_10);
696
697 int offset_x = grid_cell_border_width;
698 int offset_y = (rect.height > text_height)?(rect.height - text_height)/2 : grid_cell_border_height;
699
700 //dc.SetPen(*wxTRANSPARENT_PEN);
701 //dc.SetBrush(wxBrush(attr.GetBackgroundColour()));
702 //dc.DrawRectangle(rect);
703
704 wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
705
706 wxColour text_back_colour;
707 wxColour text_fore_colour;
708 if ( isSelected )
709 {
710 text_back_colour = grid.GetSelectionBackground();
711 text_fore_colour = grid.GetSelectionForeground();
712 }
713 else
714 {
715 text_back_colour = attr.GetBackgroundColour();
716 text_fore_colour = attr.GetTextColour();
717 }
718 dc.SetTextBackground(text_back_colour);
719 dc.SetTextForeground(text_fore_colour);
720 dc.DrawText(support_text, wxPoint(rect.x + offset_x, rect.y + offset_y));
721 text_rect.x += text_width + grid_cell_border_width *2;
722 text_rect.width -= (text_width + grid_cell_border_width *2);
723 text_rect.y += offset_y;
724 text_rect.height = grid_cell_checkbox_size;// + grid_cell_border_width *2;
725
726 int flags = wxCONTROL_CELL;
727 if (cur_option.value)
728 flags |= wxCONTROL_CHECKED;
729
730 wxRendererNative::Get().DrawCheckBox( &grid, dc, text_rect, flags );
731 }*/
732
733
734 //wxGridCellBoolRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
735
736 ObjectGridTable * table = dynamic_cast<ObjectGridTable *>(grid.GetTable());
737 ObjectGridTable::ObjectGridCol *grid_col = table->get_grid_col(col);
738 ObjectGridTable::ObjectGridRow *grid_row = table->get_grid_row(row - 1);
739 ConfigOptionBool & cur_option = dynamic_cast<ConfigOptionBool &>((*grid_row)[(ObjectGridTable::GridColType) col]);
740
741 auto height = grid.GetRowSize(row);
742 auto width = grid.GetColSize(col);
743
744 wxGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);
745 wxString value = table->GetValue(row, col);
746 if (grid_row->row_type != table->GridRowType::row_volume || col != table->GridColType::col_printable) {
747 if (cur_option.value) {
748
749 auto check_on = create_scaled_bitmap("check_on", nullptr, 18);
750 dc.SetPen(*wxTRANSPARENT_PEN);
751
752 auto offsetx = 0;
753 auto offsety = 0;
754
755 #ifdef __WXOSX_MAC__
756 offsetx = (width - 18) / 2;
757 offsety = (height - 18) / 2;
758 #else
759 offsetx = (width - check_on.GetSize().x) / 2;
760 offsety = (height - check_on.GetSize().y) / 2;
761 #endif // __WXOSX_MAC__
762
763 dc.DrawBitmap(check_on, rect.x + offsetx, rect.y + offsety);
764 } else {
765 auto check_off = create_scaled_bitmap("check_off_focused", nullptr, 18);
766 dc.SetPen(*wxTRANSPARENT_PEN);
767
768 auto offsetx = 0;
769 auto offsety = 0;
770
771 #ifdef __WXOSX_MAC__
772 offsetx = (width - 18) / 2;
773 offsety = (height - 18) / 2;
774 #else
775 offsetx = (width - check_off.GetSize().x) / 2;
776 offsety = (height - check_off.GetSize().y) / 2;
777 #endif // __WXOSX_MAC__
778
779 dc.DrawBitmap(check_off, rect.x + offsetx, rect.y + offsety);
780 }
781 }
782
783}
GridColType
Definition GUI_ObjectTable.hpp:294
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
std::vector< ArithmeticOnly< T > > grid(const T &start, const T &stop, const T &stride)
A set of equidistant values starting from 'start' (inclusive), ending in the closest multiple of 'str...
Definition MTUtils.hpp:127
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 create_scaled_bitmap(), Slic3r::GUI::ObjectGridTable::get_grid_col(), Slic3r::GUI::ObjectGridTable::get_grid_row(), Slic3r::GUI::ObjectGridTable::GetValue(), Slic3r::grid(), Slic3r::GUI::ObjectGridTable::ObjectGridRow::row_type, and Slic3r::ConfigOptionSingle< T >::value.

Here is the call graph for this function:

◆ GetBestSize()

wxSize Slic3r::GUI::GridCellSupportRenderer::GetBestSize ( wxGrid & WXUNUSEDgrid,
wxGridCellAttr & attr,
wxDC & dc,
int WXUNUSEDrow,
int WXUNUSEDcol )
virtual
790{
791/*
792 int text_width, text_height, width;
793 grid.GetTextExtent(L("Support Disabled"), &text_width, &text_height, NULL, NULL, &Label::Body_10);
794 width = text_width + 3*grid_cell_border_width + grid_cell_checkbox_size;
795
796 wxSize size{width, 20};
797*/
798 wxSize size{32, 20};
799
800 return size;
801}

References Slic3r::grid().

Here is the call graph for this function:

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