mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	FIX:fixed imageswitchbutton can not display all text
Change-Id: Iae692f5967de269a81d2eb71489198ea4108750b
This commit is contained in:
		
							parent
							
								
									8192b1a239
								
							
						
					
					
						commit
						179d2ec120
					
				
					 1 changed files with 17 additions and 1 deletions
				
			
		|  | @ -42,6 +42,8 @@ void ImageSwitchButton::SetLabels(wxString const &lbl_on, wxString const &lbl_of | |||
| { | ||||
| 	labels[0] = lbl_on; | ||||
| 	labels[1] = lbl_off; | ||||
|     auto fina_txt = GetValue() ? labels[0] : labels[1]; | ||||
|     SetToolTip(fina_txt); | ||||
|     messureSize(); | ||||
|     Refresh(); | ||||
| } | ||||
|  | @ -135,7 +137,21 @@ void ImageSwitchButton::render(wxDC& dc) | |||
|         dc.SetTextForeground(text_color.colorForStates(StateColor::Disabled)); | ||||
|     else | ||||
|         dc.SetTextForeground(text_color.colorForStates(states)); | ||||
| 	dc.DrawText(GetValue() ? labels[0] : labels[1], pt); | ||||
| 
 | ||||
|     auto fina_txt = GetValue() ? labels[0] : labels[1]; | ||||
|     if (dc.GetTextExtent(fina_txt).x > size.x) {  | ||||
|         wxString forment_txt = wxEmptyString; | ||||
|         for (auto i = 0; i < fina_txt.length(); i++) {  | ||||
|             forment_txt = fina_txt.SubString(0, i) + "..."; | ||||
|             if (dc.GetTextExtent(forment_txt).x > size.x) { | ||||
|                 pt.x = (size.x - dc.GetTextExtent(forment_txt).x) / 2; | ||||
|                 dc.DrawText(forment_txt, pt); | ||||
|                 break; | ||||
|             } | ||||
|         } | ||||
|     } else { | ||||
|         dc.DrawText(fina_txt, pt); | ||||
|     }   | ||||
| } | ||||
| 
 | ||||
| void ImageSwitchButton::Rescale() | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao wang
						tao wang