mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	InfoDialog: Small code refactoring
This commit is contained in:
		
							parent
							
								
									767f401ada
								
							
						
					
					
						commit
						7967997c7e
					
				
					 1 changed files with 3 additions and 38 deletions
				
			
		|  | @ -218,47 +218,12 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString& | |||
| 	: MsgDialog(parent, wxString::Format(_L("%s information"), SLIC3R_APP_NAME), title) | ||||
| 	, msg(msg) | ||||
| { | ||||
| 	this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); | ||||
| 
 | ||||
| 	// Text shown as HTML, so that mouse selection and Ctrl-V to copy will work.
 | ||||
| 	wxHtmlWindow* html = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO); | ||||
| 	{ | ||||
| 		wxFont 	  	font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); | ||||
| 		wxFont      monospace = wxGetApp().code_font(); | ||||
| 		wxColour  	text_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT); | ||||
| 		wxColour  	bgr_clr = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); | ||||
| 		auto      	text_clr_str = wxString::Format(wxT("#%02X%02X%02X"), text_clr.Red(), text_clr.Green(), text_clr.Blue()); | ||||
| 		auto      	bgr_clr_str = wxString::Format(wxT("#%02X%02X%02X"), bgr_clr.Red(), bgr_clr.Green(), bgr_clr.Blue()); | ||||
| 		const int 	font_size = font.GetPointSize() - 1; | ||||
| 		int 		size[] = { font_size, font_size, font_size, font_size, font_size, font_size, font_size }; | ||||
| 		html->SetFonts(font.GetFaceName(), monospace.GetFaceName(), size); | ||||
| 		html->SetBorders(2); | ||||
| 
 | ||||
| 		// calculate html page size from text
 | ||||
| 		int lines = msg.Freq('\n'); | ||||
| 
 | ||||
| 		if (msg.Contains("<tr>")) { | ||||
| 			int pos = 0; | ||||
| 			while (pos < (int)msg.Len() && pos != wxNOT_FOUND) { | ||||
| 				pos = msg.find("<tr>", pos + 1); | ||||
| 				lines+=2; | ||||
| 			} | ||||
| 		} | ||||
| 		int page_height = std::min((font.GetPixelSize().y + 1) * lines, 68 * wxGetApp().em_unit()); | ||||
| 		wxSize page_size(68 * wxGetApp().em_unit(), page_height); | ||||
| 
 | ||||
| 		html->SetMinSize(page_size); | ||||
| 
 | ||||
| 		std::string msg_escaped = xml_escape(msg.ToUTF8().data(), true); | ||||
| 		boost::replace_all(msg_escaped, "\r\n", "<br>"); | ||||
| 		boost::replace_all(msg_escaped, "\n", "<br>"); | ||||
| 		html->SetPage("<html><body bgcolor=\"" + bgr_clr_str + "\"><font color=\"" + text_clr_str + "\">" + wxString::FromUTF8(msg_escaped.data()) + "</font></body></html>"); | ||||
| 		content_sizer->Add(html, 1, wxEXPAND); | ||||
| 	} | ||||
| 
 | ||||
|     add_msg_content(this, content_sizer, msg); | ||||
| 	// Set info bitmap
 | ||||
| 	logo->SetBitmap(create_scaled_bitmap("info", this, 84)); | ||||
| 
 | ||||
|     wxGetApp().UpdateDlgDarkUI(this); | ||||
| 
 | ||||
| 	Fit(); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 YuSanka
						YuSanka