added new implementation for editable and brought selection behaviour in synch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -54,6 +54,7 @@
|
|||||||
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
|
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
|
||||||
|
|
||||||
extern wxApp *wxTheApp ;
|
extern wxApp *wxTheApp ;
|
||||||
|
extern wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ;
|
||||||
|
|
||||||
// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
|
// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
|
||||||
// the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
|
// the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
|
||||||
@@ -198,6 +199,8 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart
|
|||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
/* verify our boundary */
|
/* verify our boundary */
|
||||||
GetControlBounds(theControl, &bounds);
|
GetControlBounds(theControl, &bounds);
|
||||||
|
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
if ( ! EqualRect(&bounds, &varsp->fRFocusOutline) ) {
|
if ( ! EqualRect(&bounds, &varsp->fRFocusOutline) ) {
|
||||||
// scrollbar is on the border, we add one
|
// scrollbar is on the border, we add one
|
||||||
Rect oldbounds = varsp->fRFocusOutline ;
|
Rect oldbounds = varsp->fRFocusOutline ;
|
||||||
@@ -224,6 +227,7 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart
|
|||||||
if ((**tpvars).fIsActive && varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, true);
|
if ((**tpvars).fIsActive && varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, true);
|
||||||
/* release our globals */
|
/* release our globals */
|
||||||
HSetState((Handle) tpvars, state);
|
HSetState((Handle) tpvars, state);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +288,7 @@ static pascal ControlPartCode TPPaneTrackingProc(ControlHandle theControl, Point
|
|||||||
/* handle clicks in the text part */
|
/* handle clicks in the text part */
|
||||||
case kmUPTextPart:
|
case kmUPTextPart:
|
||||||
{ SetPort((**tpvars).fDrawingEnvironment);
|
{ SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
|
TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -314,6 +319,7 @@ static pascal void TPPaneIdleProc(ControlHandle theControl) {
|
|||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* get the current mouse coordinates (in our window) */
|
/* get the current mouse coordinates (in our window) */
|
||||||
SetPortWindowPort(GetControlOwner(theControl));
|
SetPortWindowPort(GetControlOwner(theControl));
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
GetMouse(&mousep);
|
GetMouse(&mousep);
|
||||||
/* there's a 'focus thing' and an 'unfocused thing' */
|
/* there's a 'focus thing' and an 'unfocused thing' */
|
||||||
if (varsp->fInFocus) {
|
if (varsp->fInFocus) {
|
||||||
@@ -351,6 +357,7 @@ static pascal ControlPartCode TPPaneKeyDownProc(ControlHandle theControl,
|
|||||||
if ((**tpvars).fInFocus) {
|
if ((**tpvars).fInFocus) {
|
||||||
/* turn autoscrolling on and send the key event to text edit */
|
/* turn autoscrolling on and send the key event to text edit */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
EventRecord ev ;
|
EventRecord ev ;
|
||||||
memset( &ev , 0 , sizeof( ev ) ) ;
|
memset( &ev , 0 , sizeof( ev ) ) ;
|
||||||
ev.what = keyDown ;
|
ev.what = keyDown ;
|
||||||
@@ -378,6 +385,7 @@ static pascal void TPPaneActivateProc(ControlHandle theControl, Boolean activati
|
|||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* de/activate the text edit record */
|
/* de/activate the text edit record */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
GetControlBounds(theControl, &bounds);
|
GetControlBounds(theControl, &bounds);
|
||||||
varsp->fIsActive = activating;
|
varsp->fIsActive = activating;
|
||||||
TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
|
TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
|
||||||
@@ -423,6 +431,7 @@ static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlF
|
|||||||
define your own value for handling click-to-focus type events. */
|
define your own value for handling click-to-focus type events. */
|
||||||
/* save the drawing state */
|
/* save the drawing state */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
/* calculate the next highlight state */
|
/* calculate the next highlight state */
|
||||||
switch (action) {
|
switch (action) {
|
||||||
default:
|
default:
|
||||||
@@ -736,6 +745,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macTXN = (**tpvars).fTXNRec ;
|
m_macTXN = (**tpvars).fTXNRec ;
|
||||||
m_macTXNvars = tpvars ;
|
m_macTXNvars = tpvars ;
|
||||||
m_macUsesTXN = true ;
|
m_macUsesTXN = true ;
|
||||||
|
TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -813,8 +824,13 @@ void wxTextCtrl::SetValue(const wxString& st)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
||||||
kTXNStartOffset, kTXNEndOffset);
|
kTXNStartOffset, kTXNEndOffset);
|
||||||
|
TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
|
SetEditable(formerEditable) ;
|
||||||
}
|
}
|
||||||
MacRedrawControl() ;
|
MacRedrawControl() ;
|
||||||
}
|
}
|
||||||
@@ -828,6 +844,8 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
|||||||
{
|
{
|
||||||
if ( m_macUsesTXN )
|
if ( m_macUsesTXN )
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNTypeAttributes typeAttr[4] ;
|
TXNTypeAttributes typeAttr[4] ;
|
||||||
Str255 fontName = "\pMonaco" ;
|
Str255 fontName = "\pMonaco" ;
|
||||||
SInt16 fontSize = 12 ;
|
SInt16 fontSize = 12 ;
|
||||||
@@ -872,6 +890,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
|||||||
OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr,
|
OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr,
|
||||||
start,end);
|
start,end);
|
||||||
}
|
}
|
||||||
|
SetEditable(formerEditable) ;
|
||||||
}
|
}
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
@@ -942,6 +961,7 @@ void wxTextCtrl::Paste()
|
|||||||
{
|
{
|
||||||
TXNConvertFromPublicScrap();
|
TXNConvertFromPublicScrap();
|
||||||
TXNPaste((TXNObject)m_macTXN);
|
TXNPaste((TXNObject)m_macTXN);
|
||||||
|
SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
|
||||||
}
|
}
|
||||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
||||||
event.SetString( GetValue() ) ;
|
event.SetString( GetValue() ) ;
|
||||||
@@ -1010,11 +1030,20 @@ void wxTextCtrl::SetEditable(bool editable)
|
|||||||
if ( editable != m_editable )
|
if ( editable != m_editable )
|
||||||
{
|
{
|
||||||
m_editable = editable ;
|
m_editable = editable ;
|
||||||
|
if ( !m_macUsesTXN )
|
||||||
|
{
|
||||||
if ( editable )
|
if ( editable )
|
||||||
UMAActivateControl( (ControlHandle) m_macControl ) ;
|
UMAActivateControl( (ControlHandle) m_macControl ) ;
|
||||||
else
|
else
|
||||||
UMADeactivateControl((ControlHandle) m_macControl ) ;
|
UMADeactivateControl((ControlHandle) m_macControl ) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
|
||||||
|
TXNControlData data[] = { editable ? kTXNReadWrite : kTXNReadOnly } ;
|
||||||
|
TXNSetTXNObjectControls( (TXNObject) m_macTXN , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::SetInsertionPoint(long pos)
|
void wxTextCtrl::SetInsertionPoint(long pos)
|
||||||
@@ -1075,10 +1104,13 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
||||||
TXNClear( ((TXNObject) m_macTXN) ) ;
|
TXNClear( ((TXNObject) m_macTXN) ) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
||||||
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -1096,8 +1128,11 @@ void wxTextCtrl::Remove(long from, long to)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
||||||
TXNClear( ((TXNObject) m_macTXN) ) ;
|
TXNClear( ((TXNObject) m_macTXN) ) ;
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -1124,6 +1159,7 @@ void wxTextCtrl::SetSelection(long from, long to)
|
|||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
/* change the selection */
|
/* change the selection */
|
||||||
TXNSetSelection( (**tpvars).fTXNRec, from, to);
|
TXNSetSelection( (**tpvars).fTXNRec, from, to);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1150,12 +1186,15 @@ void wxTextCtrl::WriteText(const wxString& text)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
long start , end , dummy ;
|
long start , end , dummy ;
|
||||||
GetSelection( &start , &dummy ) ;
|
GetSelection( &start , &dummy ) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(),
|
||||||
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
||||||
GetSelection( &dummy , &end ) ;
|
GetSelection( &dummy , &end ) ;
|
||||||
SetStyle( start , end , GetDefaultStyle() ) ;
|
SetStyle( start , end , GetDefaultStyle() ) ;
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
MacRedrawControl() ;
|
MacRedrawControl() ;
|
||||||
}
|
}
|
||||||
@@ -1376,6 +1415,13 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
int key = event.GetKeyCode() ;
|
int key = event.GetKeyCode() ;
|
||||||
bool eat_key = false ;
|
bool eat_key = false ;
|
||||||
|
|
||||||
|
if ( key == 'c' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanCopy() )
|
||||||
|
Copy() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
|
if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
|
||||||
!( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
|
!( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
|
||||||
/* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */
|
/* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */
|
||||||
@@ -1384,6 +1430,18 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// eat it
|
// eat it
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
if ( key == 'v' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanPaste() )
|
||||||
|
Paste() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if ( key == 'x' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanCut() )
|
||||||
|
Cut() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
switch ( key )
|
switch ( key )
|
||||||
{
|
{
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
@@ -1447,7 +1505,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// default handling
|
// default handling
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
}
|
}
|
||||||
if ( key >= 0x20 ||
|
if ( ( key >= 0x20 && key < WXK_START ) ||
|
||||||
key == WXK_RETURN ||
|
key == WXK_RETURN ||
|
||||||
key == WXK_DELETE ||
|
key == WXK_DELETE ||
|
||||||
key == WXK_BACK)
|
key == WXK_BACK)
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
|
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
|
||||||
|
|
||||||
extern wxApp *wxTheApp ;
|
extern wxApp *wxTheApp ;
|
||||||
|
extern wxControl *wxFindControlFromMacControl(ControlHandle inControl ) ;
|
||||||
|
|
||||||
// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
|
// CS:TODO we still have a problem getting properly at the text events of a control because under Carbon
|
||||||
// the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
|
// the MLTE engine registers itself for the key events thus the normal flow never occurs, the only measure for the
|
||||||
@@ -198,6 +199,8 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart
|
|||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
/* verify our boundary */
|
/* verify our boundary */
|
||||||
GetControlBounds(theControl, &bounds);
|
GetControlBounds(theControl, &bounds);
|
||||||
|
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
if ( ! EqualRect(&bounds, &varsp->fRFocusOutline) ) {
|
if ( ! EqualRect(&bounds, &varsp->fRFocusOutline) ) {
|
||||||
// scrollbar is on the border, we add one
|
// scrollbar is on the border, we add one
|
||||||
Rect oldbounds = varsp->fRFocusOutline ;
|
Rect oldbounds = varsp->fRFocusOutline ;
|
||||||
@@ -224,6 +227,7 @@ static pascal void TPPaneDrawProc(ControlRef theControl, ControlPartCode thePart
|
|||||||
if ((**tpvars).fIsActive && varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, true);
|
if ((**tpvars).fIsActive && varsp->fInFocus) DrawThemeFocusRect(&varsp->fRFocusOutline, true);
|
||||||
/* release our globals */
|
/* release our globals */
|
||||||
HSetState((Handle) tpvars, state);
|
HSetState((Handle) tpvars, state);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,6 +288,7 @@ static pascal ControlPartCode TPPaneTrackingProc(ControlHandle theControl, Point
|
|||||||
/* handle clicks in the text part */
|
/* handle clicks in the text part */
|
||||||
case kmUPTextPart:
|
case kmUPTextPart:
|
||||||
{ SetPort((**tpvars).fDrawingEnvironment);
|
{ SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
|
TXNClick( varsp->fTXNRec, (const EventRecord*) wxTheApp->MacGetCurrentEvent());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -314,6 +319,7 @@ static pascal void TPPaneIdleProc(ControlHandle theControl) {
|
|||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* get the current mouse coordinates (in our window) */
|
/* get the current mouse coordinates (in our window) */
|
||||||
SetPortWindowPort(GetControlOwner(theControl));
|
SetPortWindowPort(GetControlOwner(theControl));
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
GetMouse(&mousep);
|
GetMouse(&mousep);
|
||||||
/* there's a 'focus thing' and an 'unfocused thing' */
|
/* there's a 'focus thing' and an 'unfocused thing' */
|
||||||
if (varsp->fInFocus) {
|
if (varsp->fInFocus) {
|
||||||
@@ -351,6 +357,7 @@ static pascal ControlPartCode TPPaneKeyDownProc(ControlHandle theControl,
|
|||||||
if ((**tpvars).fInFocus) {
|
if ((**tpvars).fInFocus) {
|
||||||
/* turn autoscrolling on and send the key event to text edit */
|
/* turn autoscrolling on and send the key event to text edit */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
EventRecord ev ;
|
EventRecord ev ;
|
||||||
memset( &ev , 0 , sizeof( ev ) ) ;
|
memset( &ev , 0 , sizeof( ev ) ) ;
|
||||||
ev.what = keyDown ;
|
ev.what = keyDown ;
|
||||||
@@ -378,6 +385,7 @@ static pascal void TPPaneActivateProc(ControlHandle theControl, Boolean activati
|
|||||||
varsp = *tpvars;
|
varsp = *tpvars;
|
||||||
/* de/activate the text edit record */
|
/* de/activate the text edit record */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
GetControlBounds(theControl, &bounds);
|
GetControlBounds(theControl, &bounds);
|
||||||
varsp->fIsActive = activating;
|
varsp->fIsActive = activating;
|
||||||
TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
|
TPActivatePaneText(tpvars, varsp->fIsActive && varsp->fInFocus);
|
||||||
@@ -423,6 +431,7 @@ static pascal ControlPartCode TPPaneFocusProc(ControlHandle theControl, ControlF
|
|||||||
define your own value for handling click-to-focus type events. */
|
define your own value for handling click-to-focus type events. */
|
||||||
/* save the drawing state */
|
/* save the drawing state */
|
||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
|
wxMacWindowClipper clipper( wxFindControlFromMacControl(theControl ) ) ;
|
||||||
/* calculate the next highlight state */
|
/* calculate the next highlight state */
|
||||||
switch (action) {
|
switch (action) {
|
||||||
default:
|
default:
|
||||||
@@ -736,6 +745,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
m_macTXN = (**tpvars).fTXNRec ;
|
m_macTXN = (**tpvars).fTXNRec ;
|
||||||
m_macTXNvars = tpvars ;
|
m_macTXNvars = tpvars ;
|
||||||
m_macUsesTXN = true ;
|
m_macUsesTXN = true ;
|
||||||
|
TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -813,8 +824,13 @@ void wxTextCtrl::SetValue(const wxString& st)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
||||||
kTXNStartOffset, kTXNEndOffset);
|
kTXNStartOffset, kTXNEndOffset);
|
||||||
|
TXNSetSelection( (TXNObject) m_macTXN, 0, 0);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
|
SetEditable(formerEditable) ;
|
||||||
}
|
}
|
||||||
MacRedrawControl() ;
|
MacRedrawControl() ;
|
||||||
}
|
}
|
||||||
@@ -828,6 +844,8 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
|||||||
{
|
{
|
||||||
if ( m_macUsesTXN )
|
if ( m_macUsesTXN )
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNTypeAttributes typeAttr[4] ;
|
TXNTypeAttributes typeAttr[4] ;
|
||||||
Str255 fontName = "\pMonaco" ;
|
Str255 fontName = "\pMonaco" ;
|
||||||
SInt16 fontSize = 12 ;
|
SInt16 fontSize = 12 ;
|
||||||
@@ -872,6 +890,7 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
|
|||||||
OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr,
|
OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr,
|
||||||
start,end);
|
start,end);
|
||||||
}
|
}
|
||||||
|
SetEditable(formerEditable) ;
|
||||||
}
|
}
|
||||||
return TRUE ;
|
return TRUE ;
|
||||||
}
|
}
|
||||||
@@ -942,6 +961,7 @@ void wxTextCtrl::Paste()
|
|||||||
{
|
{
|
||||||
TXNConvertFromPublicScrap();
|
TXNConvertFromPublicScrap();
|
||||||
TXNPaste((TXNObject)m_macTXN);
|
TXNPaste((TXNObject)m_macTXN);
|
||||||
|
SetStyle( kTXNUseCurrentSelection , kTXNUseCurrentSelection , GetDefaultStyle() ) ;
|
||||||
}
|
}
|
||||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
|
||||||
event.SetString( GetValue() ) ;
|
event.SetString( GetValue() ) ;
|
||||||
@@ -1010,11 +1030,20 @@ void wxTextCtrl::SetEditable(bool editable)
|
|||||||
if ( editable != m_editable )
|
if ( editable != m_editable )
|
||||||
{
|
{
|
||||||
m_editable = editable ;
|
m_editable = editable ;
|
||||||
|
if ( !m_macUsesTXN )
|
||||||
|
{
|
||||||
if ( editable )
|
if ( editable )
|
||||||
UMAActivateControl( (ControlHandle) m_macControl ) ;
|
UMAActivateControl( (ControlHandle) m_macControl ) ;
|
||||||
else
|
else
|
||||||
UMADeactivateControl((ControlHandle) m_macControl ) ;
|
UMADeactivateControl((ControlHandle) m_macControl ) ;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TXNControlTag tag[] = { kTXNIOPrivilegesTag } ;
|
||||||
|
TXNControlData data[] = { editable ? kTXNReadWrite : kTXNReadOnly } ;
|
||||||
|
TXNSetTXNObjectControls( (TXNObject) m_macTXN , false , sizeof(tag) / sizeof (TXNControlTag) , tag , data ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::SetInsertionPoint(long pos)
|
void wxTextCtrl::SetInsertionPoint(long pos)
|
||||||
@@ -1075,10 +1104,13 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
||||||
TXNClear( ((TXNObject) m_macTXN) ) ;
|
TXNClear( ((TXNObject) m_macTXN) ) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*)value.c_str(), value.Length(),
|
||||||
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -1096,8 +1128,11 @@ void wxTextCtrl::Remove(long from, long to)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
TXNSetSelection( ((TXNObject) m_macTXN) , from , to ) ;
|
||||||
TXNClear( ((TXNObject) m_macTXN) ) ;
|
TXNClear( ((TXNObject) m_macTXN) ) ;
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
Refresh() ;
|
Refresh() ;
|
||||||
}
|
}
|
||||||
@@ -1124,6 +1159,7 @@ void wxTextCtrl::SetSelection(long from, long to)
|
|||||||
SetPort((**tpvars).fDrawingEnvironment);
|
SetPort((**tpvars).fDrawingEnvironment);
|
||||||
/* change the selection */
|
/* change the selection */
|
||||||
TXNSetSelection( (**tpvars).fTXNRec, from, to);
|
TXNSetSelection( (**tpvars).fTXNRec, from, to);
|
||||||
|
TXNShowSelection( (TXNObject) m_macTXN, kTXNShowStart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1150,12 +1186,15 @@ void wxTextCtrl::WriteText(const wxString& text)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool formerEditable = IsEditable() ;
|
||||||
|
SetEditable(true) ;
|
||||||
long start , end , dummy ;
|
long start , end , dummy ;
|
||||||
GetSelection( &start , &dummy ) ;
|
GetSelection( &start , &dummy ) ;
|
||||||
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(),
|
TXNSetData( ((TXNObject) m_macTXN), kTXNTextData, (void*) (const char*)value, value.Length(),
|
||||||
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
kTXNUseCurrentSelection, kTXNUseCurrentSelection);
|
||||||
GetSelection( &dummy , &end ) ;
|
GetSelection( &dummy , &end ) ;
|
||||||
SetStyle( start , end , GetDefaultStyle() ) ;
|
SetStyle( start , end , GetDefaultStyle() ) ;
|
||||||
|
SetEditable( formerEditable ) ;
|
||||||
}
|
}
|
||||||
MacRedrawControl() ;
|
MacRedrawControl() ;
|
||||||
}
|
}
|
||||||
@@ -1376,6 +1415,13 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
int key = event.GetKeyCode() ;
|
int key = event.GetKeyCode() ;
|
||||||
bool eat_key = false ;
|
bool eat_key = false ;
|
||||||
|
|
||||||
|
if ( key == 'c' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanCopy() )
|
||||||
|
Copy() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
|
if ( !IsEditable() && key != WXK_LEFT && key != WXK_RIGHT && key != WXK_DOWN && key != WXK_UP && key != WXK_TAB &&
|
||||||
!( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
|
!( key == WXK_RETURN && ( (m_windowStyle & wxPROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
|
||||||
/* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */
|
/* && key != WXK_PRIOR && key != WXK_NEXT && key != WXK_HOME && key != WXK_END */
|
||||||
@@ -1384,6 +1430,18 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// eat it
|
// eat it
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
if ( key == 'v' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanPaste() )
|
||||||
|
Paste() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
if ( key == 'x' && event.MetaDown() )
|
||||||
|
{
|
||||||
|
if ( CanCut() )
|
||||||
|
Cut() ;
|
||||||
|
return ;
|
||||||
|
}
|
||||||
switch ( key )
|
switch ( key )
|
||||||
{
|
{
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
@@ -1447,7 +1505,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// default handling
|
// default handling
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
}
|
}
|
||||||
if ( key >= 0x20 ||
|
if ( ( key >= 0x20 && key < WXK_START ) ||
|
||||||
key == WXK_RETURN ||
|
key == WXK_RETURN ||
|
||||||
key == WXK_DELETE ||
|
key == WXK_DELETE ||
|
||||||
key == WXK_BACK)
|
key == WXK_BACK)
|
||||||
|
Reference in New Issue
Block a user