return result ;
}
+class WXDLLEXPORT wxMacPortSaver
+{
+ DECLARE_NO_COPY_CLASS(wxMacPortSaver)
+
+public:
+ wxMacPortSaver( GrafPtr port );
+ ~wxMacPortSaver();
+private :
+ GrafPtr m_port;
+};
+
+
+/*
+ Clips to the visible region of a control within the current port
+ */
+
+class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
+{
+ DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
+
+public:
+ wxMacWindowClipper( const wxWindow* win );
+ ~wxMacWindowClipper();
+private:
+ GrafPtr m_newPort;
+ RgnHandle m_formerClip;
+ RgnHandle m_newClip;
+};
// common parts for implementations based on MLTE
void AdjustCreationAttributes( const wxColour& background, bool visible ) ;
virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle ) ;
- virtual void SetBackground( const wxBrush &brush ) ;
+ virtual void SetBackgroundColour(const wxColour& col );
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
virtual void Copy() ;
virtual void Cut() ;
virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
virtual bool HasFocus() const ;
- virtual void SetBackground( const wxBrush &brush) ;
+ virtual void SetBackgroundColour(const wxColour& col ) ;
protected :
HIViewRef m_scrollView ;
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase)
BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase)
- EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground )
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar)
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
if ( !forceMLTE )
{
- if ( m_windowStyle & wxTE_MULTILINE )
+ if ( m_windowStyle & wxTE_MULTILINE || ( UMAGetSystemVersion() >= 0x1050 ) )
m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
}
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ HandleWindowEvent( event );
}
}
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId );
event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ HandleWindowEvent( event );
}
}
LoadFile( event.GetFiles()[0] );
}
-void wxTextCtrl::OnEraseBackground(wxEraseEvent& event)
-{
- // all erasing should be done by the real mac control implementation
- // while this is true for MLTE under classic, the HITextView is somehow
- // transparent but background erase is not working correctly, so intercept
- // things while we can...
- event.Skip() ;
-}
-
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
int key = event.GetKeyCode() ;
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
event.SetEventObject( this );
event.SetString( GetValue() );
- if ( GetEventHandler()->ProcessEvent(event) )
+ if ( HandleWindowEvent(event) )
return;
}
if ( wxStyle & wxTE_MULTILINE )
{
- frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
+ if ( ! (wxStyle & wxTE_DONTWRAP ) )
+ frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
if ( !(wxStyle & wxTE_NO_VSCROLL) )
{
}
}
-void wxMacMLTEControl::SetBackground( const wxBrush &brush )
+void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
{
- // currently only solid background are supported
TXNBackground tback;
-
tback.bgType = kTXNBackgroundTypeRGB;
- brush.GetColour().GetRGBColor(&tback.bg.color);
+ col.GetRGBColor(&tback.bg.color);
TXNSetBackground( m_txn , &tback );
}
// while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
// no way out, therefore we are using our own implementation and our own scrollbars ....
+wxMacPortSaver::wxMacPortSaver( GrafPtr port )
+{
+ ::GetPort( &m_port );
+ ::SetPort( port );
+}
+
+wxMacPortSaver::~wxMacPortSaver()
+{
+ ::SetPort( m_port );
+}
+
+wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) :
+ wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) )
+{
+ m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ;
+ m_formerClip = NewRgn() ;
+ m_newClip = NewRgn() ;
+ GetClip( m_formerClip ) ;
+
+ if ( win )
+ {
+ // guard against half constructed objects, this just leads to a empty clip
+ if ( win->GetPeer() )
+ {
+ int x = 0 , y = 0;
+ win->MacWindowToRootWindow( &x, &y ) ;
+
+ // get area including focus rect
+ HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip );
+ if ( !EmptyRgn( m_newClip ) )
+ OffsetRgn( m_newClip , x , y ) ;
+ }
+
+ SetClip( m_newClip ) ;
+ }
+}
+
+wxMacWindowClipper::~wxMacWindowClipper()
+{
+ SetPort( m_newPort ) ;
+ SetClip( m_formerClip ) ;
+ DisposeRgn( m_newClip ) ;
+ DisposeRgn( m_formerClip ) ;
+}
+
TXNScrollInfoUPP gTXNScrollInfoProc = NULL ;
ControlActionUPP gTXNScrollActionProc = NULL ;
return control == m_textView ;
}
-void wxMacMLTEHIViewControl::SetBackground( const wxBrush &brush )
+void wxMacMLTEHIViewControl::SetBackgroundColour(const wxColour& col )
{
- wxMacMLTEControl::SetBackground( brush ) ;
-
-#if 0
- CGColorSpaceRef rgbSpace = CGColorSpaceCreateDeviceRGB();
- RGBColor col;
- brush.GetColour().GetRGBColor(&col) ;
-
- float component[4] ;
- component[0] = col.red / 65536.0 ;
- component[1] = col.green / 65536.0 ;
- component[2] = col.blue / 65536.0 ;
- component[3] = 1.0 ; // alpha
-
- CGColorRef color = CGColorCreate( rgbSpace , component );
- HITextViewSetBackgroundColor( m_textView , color );
- CGColorSpaceRelease( rgbSpace );
-#endif
+ HITextViewSetBackgroundColor( m_textView, col.GetPixel() );
}
#endif // wxUSE_TEXTCTRL