mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	FIX: CheckBox style on MacOS
Change-Id: I54f0c4188288a55d44c510c15efb894b3e9419df
This commit is contained in:
		
							parent
							
								
									9d2d28ca62
								
							
						
					
					
						commit
						10c152c40d
					
				
					 3 changed files with 87 additions and 2 deletions
				
			
		|  | @ -18,6 +18,12 @@ CheckBox::CheckBox(wxWindow* parent) | |||
| 	if (parent) | ||||
| 		SetBackgroundColour(parent->GetBackgroundColour()); | ||||
| 	Bind(wxEVT_TOGGLEBUTTON, [this](auto& e) { m_half_checked = false; update(); e.Skip(); }); | ||||
| #ifdef __WXOSX__ // State not fully implement on MacOS
 | ||||
|     Bind(wxEVT_SET_FOCUS, &CheckBox::updateBitmap, this); | ||||
|     Bind(wxEVT_KILL_FOCUS, &CheckBox::updateBitmap, this); | ||||
|     Bind(wxEVT_ENTER_WINDOW, &CheckBox::updateBitmap, this); | ||||
|     Bind(wxEVT_LEAVE_WINDOW, &CheckBox::updateBitmap, this); | ||||
| #endif | ||||
| 	SetSize(m_on.GetBmpSize()); | ||||
| 	SetMinSize(m_on.GetBmpSize()); | ||||
| 	update(); | ||||
|  | @ -47,8 +53,66 @@ void CheckBox::update() | |||
| { | ||||
| 	SetBitmapLabel((m_half_checked ? m_half : GetValue() ? m_on : m_off).bmp()); | ||||
|     SetBitmapDisabled((m_half_checked ? m_half_disabled : GetValue() ? m_on_disabled : m_off_disabled).bmp()); | ||||
| #ifdef __WXMSW__ | ||||
|     SetBitmapFocus((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp()); | ||||
| #endif | ||||
|     SetBitmapCurrent((m_half_checked ? m_half_focused : GetValue() ? m_on_focused : m_off_focused).bmp()); | ||||
| #ifdef __WXOSX__ | ||||
|     wxCommandEvent e(wxEVT_UPDATE_UI); | ||||
|     updateBitmap(e); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| #ifdef __WXMSW__ | ||||
| 
 | ||||
| CheckBox::State CheckBox::GetNormalState() const { return State_Normal; } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| #ifdef __WXOSX__ | ||||
| 
 | ||||
| bool CheckBox::Enable(bool enable) | ||||
| { | ||||
|     bool result = wxBitmapToggleButton::Enable(enable); | ||||
|     if (result) { | ||||
|         m_disable = !enable; | ||||
|         wxCommandEvent e(wxEVT_ACTIVATE); | ||||
|         updateBitmap(e); | ||||
|     } | ||||
|     return result; | ||||
| } | ||||
| 
 | ||||
| wxBitmap CheckBox::DoGetBitmap(State which) const | ||||
| { | ||||
|     if (m_disable) { | ||||
|         return wxBitmapToggleButton::DoGetBitmap(State_Disabled); | ||||
|     } | ||||
|     if (m_focus) { | ||||
|         return wxBitmapToggleButton::DoGetBitmap(State_Current); | ||||
|     } | ||||
|     return wxBitmapToggleButton::DoGetBitmap(which); | ||||
| } | ||||
| 
 | ||||
| void CheckBox::updateBitmap(wxEvent & evt) | ||||
| { | ||||
|     evt.Skip(); | ||||
|     if (evt.GetEventType() == wxEVT_ENTER_WINDOW) { | ||||
|         m_hover = true; | ||||
|     } else if (evt.GetEventType() == wxEVT_LEAVE_WINDOW) { | ||||
|         m_hover = false; | ||||
|     } else { | ||||
|         if (evt.GetEventType() == wxEVT_SET_FOCUS) { | ||||
|             m_focus = true; | ||||
|         } else if (evt.GetEventType() == wxEVT_KILL_FOCUS) { | ||||
|             m_focus = false; | ||||
|         } | ||||
|         wxMouseEvent e; | ||||
|         if (m_hover)	 | ||||
|             OnEnterWindow(e); | ||||
|         else | ||||
|             OnLeaveWindow(e); | ||||
|     } | ||||
| } | ||||
| 	 | ||||
| #endif | ||||
|  |  | |||
|  | @ -17,9 +17,25 @@ public: | |||
| 
 | ||||
| 	void Rescale(); | ||||
| 
 | ||||
| protected: | ||||
|     virtual State GetNormalState() const wxOVERRIDE; | ||||
| #ifdef __WXOSX__ | ||||
|     virtual bool Enable(bool enable = true) wxOVERRIDE; | ||||
| #endif | ||||
| 
 | ||||
| protected: | ||||
| #ifdef __WXMSW__ | ||||
|     virtual State GetNormalState() const wxOVERRIDE; | ||||
| #endif | ||||
|      | ||||
| #ifdef __WXOSX__ | ||||
|     virtual wxBitmap DoGetBitmap(State which) const wxOVERRIDE; | ||||
|      | ||||
|     void updateBitmap(wxEvent & evt); | ||||
|      | ||||
|     bool m_disable = false; | ||||
|     bool m_hover = false; | ||||
|     bool m_focus = false; | ||||
| #endif | ||||
|      | ||||
| private: | ||||
| 	void update(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -140,6 +140,11 @@ void WKWebView_evaluateJavaScript(void * web, wxString const & script, void (*ca | |||
|     method_exchangeImplementations(setBezelStyle, setBezelStyle2); | ||||
| } | ||||
| 
 | ||||
| - (NSFocusRingType) focusRingType | ||||
| { | ||||
|     return NSFocusRingTypeNone; | ||||
| } | ||||
| 
 | ||||
| @end | ||||
| 
 | ||||
| /* edit column for wxTableView */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 chunmao.guo
						chunmao.guo