#include "wx/filefn.h"
#include "wx/sysopt.h"
+#include "wx/thread.h"
#include "wx/mac/uma.h"
#include "wx/mac/carbon/private/mactext.h"
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;
+};
+
+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 ) ;
+}
// 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 ) ;
}
void wxTextCtrl::MacVisibilityChanged()
{
- GetPeer()->VisibilityChanged( MacIsReallyShown() ) ;
-}
-
-void wxTextCtrl::MacEnabledStateChanged()
-{
+ GetPeer()->VisibilityChanged( GetPeer()->IsVisible() );
}
void wxTextCtrl::MacCheckSpelling(bool check)
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;
}
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
- wxMacCFStringHolder cf(st , m_font.GetEncoding()) ;
+ wxCFStringRef cf(st , m_font.GetEncoding()) ;
CFStringRef cfr = cf ;
m_valueTag = kControlEditTextCFStringTag ;
CFStringRef value = GetData<CFStringRef>(0, m_valueTag) ;
if ( value )
{
- wxMacCFStringHolder cf(value) ;
+ wxCFStringRef cf(value) ;
result = cf.AsString() ;
}
{
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
- wxMacCFStringHolder cf( st , m_font.GetEncoding() ) ;
+ wxCFStringRef cf( st , m_font.GetEncoding() ) ;
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
}
CFStringRef value = GetData<CFStringRef>(0, m_valueTag) ;
if ( value )
{
- wxMacCFStringHolder cf(value) ;
+ wxCFStringRef cf(value) ;
textLength = cf.AsString().length() ;
}
if ( HasFocus() )
{
- wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
+ wxCFStringRef cf(st , m_font.GetEncoding() ) ;
CFStringRef value = cf ;
SetData<CFStringRef>( 0, kControlEditTextInsertCFStringRefTag, &value );
}
if ( wxStyle & wxTE_MULTILINE )
{
- frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
+ if ( ! (wxStyle & wxTE_DONTWRAP ) )
+ frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
if ( !(wxStyle & wxTE_NO_VSCROLL) )
{
TXNBackground tback;
tback.bgType = kTXNBackgroundTypeRGB;
- tback.bg.color = MAC_WXCOLORREF( background.GetPixel() );
+ background.GetRGBColor( &tback.bg.color );
TXNSetBackground( m_txn , &tback );
}
}
-void wxMacMLTEControl::SetBackground( const wxBrush &brush )
+void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
{
- // currently only solid background are supported
TXNBackground tback;
-
tback.bgType = kTXNBackgroundTypeRGB;
- tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() );
+ col.GetRGBColor(&tback.bg.color);
TXNSetBackground( m_txn , &tback );
}
TXNTab* tabs = NULL;
bool relayout = false;
+ wxFont font ;
if ( style.HasFont() )
{
wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) );
- const wxFont &font = style.GetFont() ;
+ font = style.GetFont() ;
typeAttr[typeAttrCount].tag = kTXNATSUIStyle ;
typeAttr[typeAttrCount].size = kTXNATSUIStyleSize ;
typeAttr[typeAttrCount].data.dataPtr = font.MacGetATSUStyle() ;
if ( style.HasTextColour() )
{
wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) );
- color = MAC_WXCOLORREF(style.GetTextColour().GetPixel()) ;
-
+ style.GetTextColour().GetRGBColor( &color );
typeAttr[typeAttrCount].tag = kTXNQDFontColorAttribute ;
typeAttr[typeAttrCount].size = kTXNQDFontColorAttributeSize ;
typeAttr[typeAttrCount].data.dataPtr = (void*) &color ;
return ;
Rect bounds ;
- UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
+ GetRectInWindowCoords( &bounds );
wxRect visRect = textctrl->MacGetClippedClientRect() ;
Rect visBounds = { visRect.y , visRect.x , visRect.y + visRect.height , visRect.x + visRect.width } ;
if ( textctrl == NULL )
return ;
- if ( textctrl->MacIsReallyShown() )
+ if ( textctrl->IsShownOnScreen() )
{
wxMacWindowClipper clipper( textctrl ) ;
TXNDraw( m_txn , NULL ) ;
ControlPartCode result = kControlNoPart;
wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef );
- if ( (textctrl != NULL) && textctrl->MacIsReallyShown() )
+ if ( (textctrl != NULL) && textctrl->IsShownOnScreen() )
{
if (PtInRect( where, &m_txnControlBounds ))
{
ControlPartCode result = kControlNoPart;
wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef );
- if ( (textctrl != NULL) && textctrl->MacIsReallyShown() )
+ if ( (textctrl != NULL) && textctrl->IsShownOnScreen() )
{
Point startPt = { y , x } ;
if ( textctrl == NULL )
return ;
- if (textctrl->MacIsReallyShown())
+ if (textctrl->IsShownOnScreen())
{
if (IsControlActive(m_controlRef))
{
AdjustCreationAttributes( *wxWHITE , true ) ;
- MacSetObjectVisibility( wxPeer->MacIsReallyShown() ) ;
+ MacSetObjectVisibility( wxPeer->IsShownOnScreen() ) ;
{
wxString st = str ;
SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc);
// calculate the rectangles used by the control
- UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
+ GetRectInWindowCoords( &bounds );
m_txnControlBounds = bounds ;
m_txnVisBounds = bounds ;
m_scrollView = NULL ;
TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ;
- if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || !(frameOptions &kTXNSingleLineOnlyMask))
+ if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || (frameOptions &kTXNSingleLineOnlyMask))
{
if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) )
{
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 = MAC_WXCOLORREF(brush.GetColour().GetPixel()) ;
-
- 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