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 SetStyle(long start, long end, const wxTextAttr& style) ;
virtual void Copy() ;
virtual void Cut() ;
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
+ EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground )
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar)
EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
m_macIsUserPane = FALSE ;
m_editable = true ;
- if ( !HasFlag(wxNO_BORDER) )
- style |= wxSUNKEN_BORDER ;
+ if ( ! ( style & wxNO_BORDER) )
+ style = ( style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
return FALSE;
int hText;
+ // these are the numbers from the HIG, we reduce them by the borders
+ // first
+
switch( m_windowVariant )
{
case wxWINDOW_VARIANT_NORMAL :
- hText = 22 ;
+ hText = 22 - 6 ;
break ;
case wxWINDOW_VARIANT_SMALL :
- hText = 19 ;
+ hText = 19 - 6 ;
break ;
case wxWINDOW_VARIANT_MINI :
- hText= 15 ;
+ hText= 15 - 6 ;
break ;
default :
- hText = 22 ;
+ hText = 22 - 6;
break ;
}
- if ( HasFlag(wxNO_BORDER) )
- hText -= 6 ;
-
+ // as the above numbers have some free space around the text
+ // we get 5 lines like this anyway
if ( m_windowStyle & wxTE_MULTILINE )
{
hText *= 5 ;
}
+ if ( !HasFlag(wxNO_BORDER) )
+ hText += 6 ;
+
return wxSize(wText, hText);
}
}
}
+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...
+}
+
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
int key = event.GetKeyCode() ;
val.Remove( start , end - start ) ;
val.insert( start , str ) ;
SetStringValue( val ) ;
- SetInsertionPoint( start + str.Length() ) ;
+ SetSelection( start + str.Length() , start + str.Length() ) ;
#endif
}
TXNSetBackground( m_txn , &tback);
}
+void wxMacMLTEControl::SetBackground( const wxBrush &brush )
+{
+ // currently only solid background are supported
+ TXNBackground tback;
+ tback.bgType = kTXNBackgroundTypeRGB;
+ tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() );
+ TXNSetBackground( m_txn , &tback);
+}
+
int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttributes typeAttr[] )
{
Str255 fontName = "\pMonaco" ;
typeAttr[attrCounter+2].size = kTXNQDFontStyleAttributeSize ;
typeAttr[attrCounter+2].data.dataValue = fontStyle ;
attrCounter += 3 ;
-
}
if ( style.HasTextColour() )
{
void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
{
EditHelper help(m_txn) ;
- wxTextAttr style(wxNullColour,wxNullColour,font) ;
+ wxTextAttr style(foreground,wxNullColour,font) ;
TXNTypeAttributes typeAttr[4] ;
int attrCounter = ConvertAttribute( style , typeAttr ) ;
if ( attrCounter > 0 )
#if TARGET_API_MAC_OSX
+#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+
wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer,
const wxString& str,
const wxPoint& pos,
bool wxMacMLTEHIViewControl::NeedsFocusRect() const
{
- return true ;
+ return m_windowStyle & wxNO_BORDER ? false : true;
}
+#endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
+
+
#endif
#endif // wxUSE_TEXTCTRL