X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1ea39a039924df94abcd7f9ce1c4c51abda09080..f7476b53e6da9a916d7863dc62bc6c7f60685651:/src/mac/textctrl.cpp diff --git a/src/mac/textctrl.cpp b/src/mac/textctrl.cpp index b79f2fc5d3..90871927da 100644 --- a/src/mac/textctrl.cpp +++ b/src/mac/textctrl.cpp @@ -426,7 +426,7 @@ static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlF /* set up locals */ focusResult = kControlFocusNoPart; tpvars = (STPTextPaneVars **) GetControlReference(theControl); - if (tpvars != NULL) { + if (tpvars != NULL && IsControlVisible( theControl ) ) { state = HGetState((Handle) tpvars); HLock((Handle) tpvars); varsp = *tpvars; @@ -637,13 +637,16 @@ END_EVENT_TABLE() #endif // Text item -wxTextCtrl::wxTextCtrl() +void wxTextCtrl::Init() { m_macTE = NULL ; m_macTXN = NULL ; m_macTXNvars = NULL ; m_macUsesTXN = false ; + m_editable = true ; + m_dirty = false; + m_maxLength = TE_UNLIMITED_LENGTH ; } @@ -680,7 +683,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_macUsesTXN &= (TXNInitTextension != (void*) kUnresolvedCFragSymbolAddress) ; // base initialization - if ( !CreateBase(parent, id, pos, size, style, validator, name) ) + if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) return FALSE; wxSize mySize = size ; @@ -1202,17 +1205,19 @@ void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::SetSelection(long from, long to) { - if ( from == -1 ) - from = 0; - - if ( to == -1 ) - to = GetLastPosition(); - if ( !m_macUsesTXN ) { ControlEditTextSelectionRec selection ; - selection.selStart = from ; - selection.selEnd = to ; + if ((from == -1) && (to == -1)) + { + selection.selStart = 0 ; + selection.selEnd = 32767 ; + } + else + { + selection.selStart = from ; + selection.selEnd = to ; + } TESetSelect( selection.selStart , selection.selEnd , ((TEHandle) m_macTE) ) ; ::SetControlData((ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; @@ -1226,7 +1231,10 @@ void wxTextCtrl::SetSelection(long from, long to) may force a redraw in the text area. */ SetPort((**tpvars).fDrawingEnvironment); /* change the selection */ - TXNSetSelection( (**tpvars).fTXNRec, from, to); + if ((from == -1) && (to == -1)) + TXNSelectAll((TXNObject) m_macTXN); + else + TXNSetSelection( (**tpvars).fTXNRec, from, to); TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart); } } @@ -1297,7 +1305,7 @@ void wxTextCtrl::Clear() bool wxTextCtrl::IsModified() const { - return TRUE; + return m_dirty; } bool wxTextCtrl::IsEditable() const @@ -1399,7 +1407,7 @@ bool wxTextCtrl::CanRedo() const // Makes 'unmodified' void wxTextCtrl::DiscardEdits() { - // TODO + m_dirty = false; } int wxTextCtrl::GetNumberOfLines() const @@ -1526,6 +1534,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // eat it return ; } + + // assume that any key not processed yet is going to modify the control + m_dirty = true; + if ( key == 'v' && event.MetaDown() ) { if ( CanPaste() )