const wxPoint& pos,
const wxSize& size, long style ) ;
~wxMacMLTEClassicControl() ;
+
virtual void VisibilityChanged(bool shown) ;
virtual void SuperChangedPosition() ;
virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
virtual void MacControlUserPaneBackgroundProc(void* info) ;
- virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) ) { MacControlUserPaneIdleProc() ; return true ;}
+ virtual bool SetupCursor( const wxPoint& WXUNUSED(pt) )
+ {
+ MacControlUserPaneIdleProc();
+ return true;
+ }
virtual void SetRect( Rect *r ) ;
#endif
};
-#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
-
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
m_editable = true ;
m_dirty = false;
- m_maxLength = TE_UNLIMITED_LENGTH ;
+ m_maxLength = 0;
m_privateContextMenu = NULL;
}
delete m_privateContextMenu;
}
-bool wxTextCtrl::Create(wxWindow *parent,
+bool wxTextCtrl::Create( wxWindow *parent,
wxWindowID id,
const wxString& str,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
- const wxString& name)
+ const wxString& name )
{
m_macIsUserPane = false ;
m_editable = true ;
if ( ! (style & wxNO_BORDER) )
style = (style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ;
- if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) )
+ if ( !wxTextCtrlBase::Create( parent, id, pos, size, style & ~(wxHSCROLL | wxVSCROLL), validator, name ) )
return false;
if ( m_windowStyle & wxTE_MULTILINE )
bool forceMLTE = false ;
#if wxUSE_SYSTEM_OPTIONS
- if ( wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE ) && ( wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE ) == 1) )
+ if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE ) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE ) == 1))
{
forceMLTE = true ;
}
// Can copy if there's a selection
long from, to;
GetSelection( &from, &to );
+
return (from != to);
}
// Can cut if there's a selection
long from, to;
GetSelection( &from, &to );
+
return (from != to);
}
void wxTextCtrl::SetInsertionPointEnd()
{
wxTextPos pos = GetLastPosition();
- SetInsertionPoint(pos);
+ SetInsertionPoint( pos );
}
long wxTextCtrl::GetInsertionPoint() const
{
- long begin,end ;
+ long begin, end ;
GetSelection( &begin , &end ) ;
+
return begin ;
}
void wxTextCtrl::Replace(long from, long to, const wxString& str)
{
- GetPeer()->Replace( from , to , str) ;
+ GetPeer()->Replace( from , to , str ) ;
}
void wxTextCtrl::Remove(long from, long to)
bool wxTextCtrl::LoadFile(const wxString& file)
{
- if ( wxTextCtrlBase::LoadFile(file) )
- return true;
-
- return false;
+ return wxTextCtrlBase::LoadFile( file );
}
void wxTextCtrl::WriteText(const wxString& str)
// unfortunately CW 8 is not able to correctly deduce the template types,
// so we have to instantiate explicitly
wxMacMPRemoteGUICall<wxTextCtrl,wxString>( this , &wxTextCtrl::WriteText , str ) ;
+
return ;
}
- else
- {
- GetPeer()->WriteText( str ) ;
- }
+
+ GetPeer()->WriteText( str ) ;
}
void wxTextCtrl::AppendText(const wxString& text)
{
SetInsertionPointEnd();
- WriteText(text);
+ WriteText( text );
}
void wxTextCtrl::Clear()
bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
{
- return GetPeer()->PositionToXY(pos , x , y ) ;
+ return GetPeer()->PositionToXY( pos , x , y ) ;
}
void wxTextCtrl::ShowPosition(long pos)
{
// By default, load the first file into the text window.
if (event.GetNumberOfFiles() > 0)
- LoadFile(event.GetFiles()[0]);
+ LoadFile( event.GetFiles()[0] );
}
void wxTextCtrl::OnEraseBackground(wxEraseEvent& event)
return ;
}
- // Check if we have reached the max # of chars, but still allow navigation and deletion
- if ( !IsMultiLine() && GetValue().Length() >= m_maxLength &&
+ // Check if we have reached the max # of chars (if it is set), but still
+ // allow navigation and deletion
+ if ( !IsMultiLine() && m_maxLength && GetValue().Length() >= m_maxLength &&
key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
)
{
// eat it, we don't want to add more than allowed # of characters
+
+ // TODO: generate EVT_TEXT_MAXLEN()
return;
}
if (!eat_key)
{
// perform keystroke handling
- if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
- {
- CallNextEventHandler( (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef(), (EventRef)wxTheApp->MacGetCurrentEvent() ) ;
- }
- else
- {
- EventRecord rec ;
- if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
- {
- short keycode, keychar ;
- EventRecord *ev = &rec ;
- keychar = short(ev->message & charCodeMask);
- keycode = short(ev->message & keyCodeMask) >> 8 ;
-
- m_peer->HandleKey( keycode , keychar , ev->modifiers ) ;
- }
- }
+ event.Skip(true) ;
}
if ( ( key >= 0x20 && key < WXK_START ) ||
void wxTextCtrl::OnDelete(wxCommandEvent& WXUNUSED(event))
{
long from, to;
+
GetSelection( &from, &to );
if (from != -1 && to != -1)
Remove( from, to );
void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent& event)
{
long from, to;
+
GetSelection( &from, &to );
event.Enable( from != -1 && to != -1 && from != to && IsEditable() ) ;
}
m_privateContextMenu->AppendSeparator();
m_privateContextMenu->Append(wxID_SELECTALL, _("Select &All"));
}
-
+
if (m_privateContextMenu != NULL)
PopupMenu(m_privateContextMenu);
}
#if TARGET_API_MAC_OSX
wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer,
- const wxString& str,
- const wxPoint& pos,
- const wxSize& size, long style ) : wxMacTextControl( wxPeer )
+ const wxString& str,
+ const wxPoint& pos,
+ const wxSize& size, long style )
+ : wxMacTextControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
CFStringRef cfr = cf ;
Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
m_valueTag = isPassword ? kControlEditTextPasswordCFStringTag : kControlEditTextCFStringTag ;
- CreateEditUnicodeTextControl(
+
+ OSStatus err = CreateEditUnicodeTextControl(
MAC_WXHWND(wxPeer->MacGetTopLevelWindowRef()), &bounds , cfr ,
isPassword , NULL , &m_controlRef ) ;
+ verify_noerr( err );
if ( !(m_windowStyle & wxTE_MULTILINE) )
SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
{
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
- wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
+ wxMacCFStringHolder cf( st , m_font.GetEncoding() ) ;
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
}
void wxMacUnicodeTextControl::SetEditable(bool editable)
{
- SetData<Boolean>( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#if 0 // leads to problem because text cannot be selected anymore
+ SetData<Boolean>( kControlEditTextPart , kControlEditTextLockedTag , (Boolean) !editable ) ;
+#endif
}
void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const
TXNControlData m_data[1] ;
} ;
-wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer ) : wxMacTextControl( peer )
+wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
+ : wxMacTextControl( peer )
{
SetNeedsFocusRect( true ) ;
}
: kTXNAutoWrap;
}
- verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ) ;
+ OSStatus err = TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ;
+ verify_noerr( err );
// setting the default font:
// under 10.2 this causes a visible caret, therefore we avoid it
SInt16 fontSize ;
Style fontStyle ;
- GetThemeFont(kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+ GetThemeFont( kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
TXNTypeAttributes typeAttr[] =
{
{ kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
} ;
- verify_noerr(
- TXNSetTypeAttributes(
- m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes),
- typeAttr, kTXNStartOffset, kTXNEndOffset ) );
+ err = TXNSetTypeAttributes(
+ m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes),
+ typeAttr, kTXNStartOffset, kTXNEndOffset );
+ verify_noerr( err );
}
if ( m_windowStyle & wxTE_PASSWORD )
{
- UniChar c = 0xA5 ;
- verify_noerr (TXNEchoMode( m_txn , c , 0 , true ) );
+ UniChar c = 0x00A5 ;
+ err = TXNEchoMode( m_txn , c , 0 , true );
+ verify_noerr( err );
}
TXNBackground tback;
if ( y == ypos && x == xpos )
return n ;
- TXNOffsetToPoint( m_txn , n , &curpt );
+ TXNOffsetToPoint( m_txn, n, &curpt ) ;
if ( curpt.v > lastHeight )
{
for ( n = 0 ; n <= (ItemCount) pos ; ++n )
{
- TXNOffsetToPoint(m_txn , n , &curpt);
+ TXNOffsetToPoint( m_txn, n, &curpt ) ;
if ( curpt.v > lastHeight )
{
OSErr theErr = noErr;
SInt32 dv = desired.v - current.v;
SInt32 dh = desired.h - current.h;
- TXNShowSelection( m_txn, kTXNShowEnd ); // NB: should this be kTXNShowStart or kTXNShowEnd ??
+ TXNShowSelection( m_txn, kTXNShowStart ) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
theErr = TXNScroll( m_txn, kTXNScrollUnitsInPixels, kTXNScrollUnitsInPixels, &dv, &dh );
// there will be an error returned for classic MLTE implementation when the control is
return line ;
}
-int wxMacMLTEControl::GetLineLength(long lineNo) const
+int wxMacMLTEControl::GetLineLength(long lineNo) const
{
int theLength = 0;
{
Point firstPoint;
Fixed lineWidth, lineHeight, currentHeight;
- long ypos ;
+ long ypos;
// get the first possible position in the control
TXNOffsetToPoint(m_txn, 0, &firstPoint);
switch ( partCode )
{
-
case kControlDownButtonPart :
delta = 10 ;
break ;
err = TXNScroll(
mlte->m_txn, kTXNScrollUnitsInPixels, kTXNScrollUnitsInPixels,
&verticalDelta, &horizontalDelta );
+ verify_noerr( err );
if ( isHorizontal )
mlte->m_lastHorizontalValue = newValue ;
}
wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
- const wxString& str,
- const wxPoint& pos,
- const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
+ const wxString& str,
+ const wxPoint& pos,
+ const wxSize& size, long style )
+ : wxMacMLTEControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
// | kControlHasSpecialBackground
| kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
- verify_noerr(
- ::CreateUserPaneControl(
- MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
- &bounds, featureSet, &m_controlRef ) );
+ OSStatus err = ::CreateUserPaneControl(
+ MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
+ &bounds, featureSet, &m_controlRef );
+ verify_noerr( err );
DoCreate();
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- win->MacControlUserPaneDrawProc(part) ;
+ win->MacControlUserPaneDrawProc( part ) ;
}
static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where)
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- return win->MacControlUserPaneHitTestProc(where.h , where.v) ;
+ return win->MacControlUserPaneHitTestProc( where.h , where.v ) ;
else
return kControlNoPart ;
}
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc) ;
+ return win->MacControlUserPaneTrackingProc( startPt.h , startPt.v , (void*) actionProc ) ;
else
return kControlNoPart ;
}
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- return win->MacControlUserPaneKeyDownProc(keyCode,charCode,modifiers) ;
+ return win->MacControlUserPaneKeyDownProc( keyCode, charCode, modifiers ) ;
else
return kControlNoPart ;
}
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- win->MacControlUserPaneActivateProc(activating) ;
+ win->MacControlUserPaneActivateProc( activating ) ;
}
static pascal ControlPartCode wxMacControlUserPaneFocusProc(ControlRef control, ControlFocusPart action)
wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ;
wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ;
if ( win )
- return win->MacControlUserPaneFocusProc(action) ;
+ return win->MacControlUserPaneFocusProc( action ) ;
else
return kControlNoPart ;
}
OSStatus wxMacMLTEClassicControl::DoCreate()
{
Rect bounds;
-
OSStatus err = noErr ;
// set up our globals
#endif
- verify_noerr(
- TXNNewObject(
- NULL, m_txnWindow, &bounds, frameOptions,
- kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding,
- &m_txn, &m_txnFrameID, NULL ) );
+ err = TXNNewObject(
+ NULL, m_txnWindow, &bounds, frameOptions,
+ kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding,
+ &m_txn, &m_txnFrameID, NULL );
+ verify_noerr( err );
#if 0
TXNControlTag iControlTags[] = { kTXNUseCarbonEvents };
#endif
SetGWorld( origPort , origDev ) ;
+
return err;
}
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer,
- const wxString& str,
- const wxPoint& pos,
- const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
+ const wxString& str,
+ const wxPoint& pos,
+ const wxSize& size, long style ) : wxMacMLTEControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
- HIRect hr = { { bounds.left , bounds.top} ,
- { bounds.right - bounds.left , bounds.bottom - bounds.top} } ;
+ HIRect hr = {
+ { bounds.left , bounds.top },
+ { bounds.right - bounds.left, bounds.bottom - bounds.top } } ;
m_scrollView = NULL ;
TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ;
component[2] = col.blue / 65536.0 ;
component[3] = 1.0 ; // alpha
- CGColorRef color = CGColorCreate (rgbSpace , component );
- HITextViewSetBackgroundColor( m_textView , color ) ;
+ CGColorRef color = CGColorCreate( rgbSpace , component );
+ HITextViewSetBackgroundColor( m_textView , color );
CGColorSpaceRelease( rgbSpace );
#endif
}