Corrected double clicks (always on the same window).

Corrected mouse up events (same window as mouse down).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-05-05 11:36:33 +00:00
parent a9d171bd00
commit 32b5be3d67
6 changed files with 374 additions and 320 deletions

View File

@@ -183,7 +183,9 @@ void wxTextCtrl::SetValue(const wxString& st)
else else
value = st ; value = st ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
MacRedrawControl() ; MacRedrawControl() ;
Update();
} }
// Clipboard operations // Clipboard operations
@@ -194,10 +196,10 @@ void wxTextCtrl::Copy()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECopy( teH ) ; TECopy( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
} }
} }
@@ -208,12 +210,12 @@ void wxTextCtrl::Cut()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ; TECut( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
} }
} }
void wxTextCtrl::Paste() void wxTextCtrl::Paste()
@@ -1277,40 +1279,40 @@ bail:
/* mUPOpenControl initializes a user pane control so it will be drawn /* mUPOpenControl initializes a user pane control so it will be drawn
and will behave as a scrolling text edit field inside of a window. and will behave as a scrolling text edit field inside of a window.
This routine performs all of the initialization steps necessary, This routine performs all of the initialization steps necessary,
except it does not create the user pane control itself. theControl except it does not create the user pane control itself. theControl
should refer to a user pane control that you have either created should refer to a user pane control that you have either created
yourself or extracted from a dialog's control heirarchy using yourself or extracted from a dialog's control heirarchy using
the GetDialogItemAsControl routine. */ the GetDialogItemAsControl routine. */
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) { OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
Rect bounds; Rect bounds;
WindowPtr theWindow; WindowPtr theWindow;
STPTextPaneVars **tpvars, *varsp; STPTextPaneVars **tpvars, *varsp;
OSStatus err; OSStatus err;
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF}; RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
TXNBackground tback; TXNBackground tback;
/* set up our globals */ /* set up our globals */
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc); if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc); if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc); if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc); if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc); if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc); if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc); if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
/* allocate our private storage */ /* allocate our private storage */
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars)); tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
SetControlReference(theControl, (long) tpvars); SetControlReference(theControl, (long) tpvars);
HLock((Handle) tpvars); HLock((Handle) tpvars);
varsp = *tpvars; varsp = *tpvars;
/* set the initial settings for our private data */ /* set the initial settings for our private data */
varsp->fInFocus = false; varsp->fInFocus = false;
varsp->fIsActive = true; varsp->fIsActive = true;
varsp->fTEActive = false; varsp->fTEActive = false;
varsp->fUserPaneRec = theControl; varsp->fUserPaneRec = theControl;
theWindow = varsp->fOwner = GetControlOwner(theControl); theWindow = varsp->fOwner = GetControlOwner(theControl);
#if TARGET_CARBON #if TARGET_CARBON
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner); varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
#else #else
@@ -1838,16 +1840,16 @@ void wxTextCtrl::Copy()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECopy( teH ) ; TECopy( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
} }
else else
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ;
} }
} }
} }
void wxTextCtrl::Cut() void wxTextCtrl::Cut()
@@ -1859,17 +1861,17 @@ void wxTextCtrl::Cut()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ; TECut( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
}
else
{
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ;
}
} }
else
{
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ;
}
}
} }
void wxTextCtrl::Paste() void wxTextCtrl::Paste()
@@ -1881,16 +1883,16 @@ void wxTextCtrl::Paste()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TEFromScrap() ; TEFromScrap() ;
TEPaste( teH ) ; TEPaste( teH ) ;
MacRedrawControl() ; MacRedrawControl() ;
} }
else else
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ;
} }
} }
} }
bool wxTextCtrl::CanCopy() const bool wxTextCtrl::CanCopy() const
@@ -1986,22 +1988,22 @@ long wxTextCtrl::GetLastPosition() const
} }
else else
{ {
STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl);
int actualsize = 0 ; int actualsize = 0 ;
Handle theText ; Handle theText ;
OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
/* all done */ /* all done */
if ( err ) if ( err )
{ {
actualsize = 0 ; actualsize = 0 ;
} }
else else
{ {
actualsize = GetHandleSize( theText ) ; actualsize = GetHandleSize( theText ) ;
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
return actualsize ; return actualsize ;
} }
} }
@@ -2014,19 +2016,19 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
selection.selStart = from ; selection.selStart = from ;
selection.selEnd = to ; selection.selEnd = to ;
::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TESetSelect( from , to , teH ) ; TESetSelect( from , to , teH ) ;
TEDelete( teH ) ; TEDelete( teH ) ;
TEInsert( value , value.Length() , teH ) ; TEInsert( value , value.Length() , teH ) ;
} }
else else
{ {
// TODO // TODO
} }
Refresh() ; Refresh() ;
} }
void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::Remove(long from, long to)
@@ -2038,11 +2040,11 @@ void wxTextCtrl::Remove(long from, long to)
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
selection.selStart = from ; selection.selStart = from ;
selection.selEnd = to ; selection.selEnd = to ;
::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TEDelete( teH ) ; TEDelete( teH ) ;
} }
else else
{ {
@@ -2134,7 +2136,7 @@ void wxTextCtrl::Clear()
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPClear) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPClear) ;
} }
Refresh() ; Refresh() ;
} }
bool wxTextCtrl::IsModified() const bool wxTextCtrl::IsModified() const
@@ -2219,13 +2221,13 @@ int wxTextCtrl::GetNumberOfLines() const
{ {
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
int count = 1; int count = 1;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return count; return count;
} }
@@ -2249,25 +2251,25 @@ int wxTextCtrl::GetLineLength(long lineNo) const
{ {
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
// Find line first // Find line first
int count = 0; int count = 0;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (count == lineNo) if (count == lineNo)
{ {
// Count chars in line then // Count chars in line then
count = 0; count = 0;
for (int j = i; j < content.Length(); j++) for (int j = i; j < content.Length(); j++)
{ {
count++; count++;
if (content[j] == '\r') return count; if (content[j] == '\r') return count;
} }
return count; return count;
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return 0; return 0;
} }
@@ -2276,27 +2278,27 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
// Find line first // Find line first
int count = 0; int count = 0;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (count == lineNo) if (count == lineNo)
{ {
// Add chars in line then // Add chars in line then
wxString tmp(""); wxString tmp("");
for (int j = i; j < content.Length(); j++) for (int j = i; j < content.Length(); j++)
{ {
if (content[j] == '\r') if (content[j] == '\r')
return tmp; return tmp;
tmp += content[j]; tmp += content[j];
} }
return tmp; return tmp;
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return wxString(""); return wxString("");
} }

View File

@@ -52,7 +52,15 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// list of all frames and modeless dialogs // list of all frames and modeless dialogs
wxWindowList wxModelessWindows; wxWindowList wxModelessWindows;
// double click testing
static Point gs_lastWhere;
static long gs_lastWhen = 0;
// cursor stuff
extern int wxBusyCursorCount;
// ============================================================================ // ============================================================================
// wxTopLevelWindowMac implementation // wxTopLevelWindowMac implementation
@@ -347,10 +355,6 @@ void wxTopLevelWindowMac::Lower()
::SendBehind( (WindowRef)m_macWindow , NULL ) ; ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
} }
Point lastWhere ;
long lastWhen = 0 ;
extern int wxBusyCursorCount ;
void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr ) void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
{ {
EventRecord *ev = (EventRecord*) evr ; EventRecord *ev = (EventRecord*) evr ;
@@ -397,22 +401,25 @@ void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
if ( ev->what == mouseDown ) if ( ev->what == mouseDown )
{ {
if ( ev->when - lastWhen <= GetDblTime() ) if ( ev->when - gs_lastWhen <= GetDblTime() )
{ {
if ( abs( localwhere.h - lastWhere.h ) < 3 || abs( localwhere.v - lastWhere.v ) < 3 ) if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
{ {
// This is not right if the second mouse down
// event occured in a differen window. We
// correct this in MacDispatchMouseEvent.
if ( controlDown ) if ( controlDown )
event.SetEventType(wxEVT_RIGHT_DCLICK ) ; event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
else else
event.SetEventType(wxEVT_LEFT_DCLICK ) ; event.SetEventType(wxEVT_LEFT_DCLICK ) ;
} }
lastWhen = 0 ; gs_lastWhen = 0 ;
} }
else else
{ {
lastWhen = ev->when ; gs_lastWhen = ev->when ;
} }
lastWhere = localwhere ; gs_lastWhere = localwhere ;
} }
event.m_x = localwhere.h; event.m_x = localwhere.h;

View File

@@ -1386,6 +1386,7 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa
} }
extern int wxBusyCursorCount ; extern int wxBusyCursorCount ;
static wxWindow *gs_lastWhich = NULL;
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
{ {
@@ -1438,6 +1439,23 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
wxToolTip::RelayEvent( this , event); wxToolTip::RelayEvent( this , event);
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
if (gs_lastWhich != this)
{
gs_lastWhich = this;
// Double clicks must always occur on the same window
if (event.GetEventType() == wxEVT_LEFT_DCLICK)
event.SetEventType( wxEVT_LEFT_DOWN );
if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
event.SetEventType( wxEVT_RIGHT_DOWN );
// Same for mouse up events
if (event.GetEventType() == wxEVT_LEFT_UP)
return TRUE;
if (event.GetEventType() == wxEVT_RIGHT_UP)
return TRUE;
}
GetEventHandler()->ProcessEvent( event ) ; GetEventHandler()->ProcessEvent( event ) ;
return TRUE; return TRUE;

View File

@@ -183,7 +183,9 @@ void wxTextCtrl::SetValue(const wxString& st)
else else
value = st ; value = st ;
::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ; ::SetControlData( (ControlHandle) m_macControl, 0, ( m_windowStyle & wxTE_PASSWORD ) ? kControlEditTextPasswordTag : kControlEditTextTextTag , value.Length() , (char*) ((const char*)value) ) ;
MacRedrawControl() ; MacRedrawControl() ;
Update();
} }
// Clipboard operations // Clipboard operations
@@ -194,10 +196,10 @@ void wxTextCtrl::Copy()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECopy( teH ) ; TECopy( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
} }
} }
@@ -208,12 +210,12 @@ void wxTextCtrl::Cut()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ; TECut( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
} }
} }
void wxTextCtrl::Paste() void wxTextCtrl::Paste()
@@ -1277,40 +1279,40 @@ bail:
/* mUPOpenControl initializes a user pane control so it will be drawn /* mUPOpenControl initializes a user pane control so it will be drawn
and will behave as a scrolling text edit field inside of a window. and will behave as a scrolling text edit field inside of a window.
This routine performs all of the initialization steps necessary, This routine performs all of the initialization steps necessary,
except it does not create the user pane control itself. theControl except it does not create the user pane control itself. theControl
should refer to a user pane control that you have either created should refer to a user pane control that you have either created
yourself or extracted from a dialog's control heirarchy using yourself or extracted from a dialog's control heirarchy using
the GetDialogItemAsControl routine. */ the GetDialogItemAsControl routine. */
OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) { OSStatus mUPOpenControl(ControlHandle theControl, bool multiline) {
Rect bounds; Rect bounds;
WindowPtr theWindow; WindowPtr theWindow;
STPTextPaneVars **tpvars, *varsp; STPTextPaneVars **tpvars, *varsp;
OSStatus err; OSStatus err;
RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF}; RGBColor rgbWhite = {0xFFFF, 0xFFFF, 0xFFFF};
TXNBackground tback; TXNBackground tback;
/* set up our globals */ /* set up our globals */
if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc); if (gTPDrawProc == NULL) gTPDrawProc = NewControlUserPaneDrawUPP(TPPaneDrawProc);
if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc); if (gTPHitProc == NULL) gTPHitProc = NewControlUserPaneHitTestUPP(TPPaneHitTestProc);
if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc); if (gTPTrackProc == NULL) gTPTrackProc = NewControlUserPaneTrackingUPP(TPPaneTrackingProc);
if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc); if (gTPIdleProc == NULL) gTPIdleProc = NewControlUserPaneIdleUPP(TPPaneIdleProc);
if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc); if (gTPKeyProc == NULL) gTPKeyProc = NewControlUserPaneKeyDownUPP(TPPaneKeyDownProc);
if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc); if (gTPActivateProc == NULL) gTPActivateProc = NewControlUserPaneActivateUPP(TPPaneActivateProc);
if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc); if (gTPFocusProc == NULL) gTPFocusProc = NewControlUserPaneFocusUPP(TPPaneFocusProc);
/* allocate our private storage */ /* allocate our private storage */
tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars)); tpvars = (STPTextPaneVars **) NewHandleClear(sizeof(STPTextPaneVars));
SetControlReference(theControl, (long) tpvars); SetControlReference(theControl, (long) tpvars);
HLock((Handle) tpvars); HLock((Handle) tpvars);
varsp = *tpvars; varsp = *tpvars;
/* set the initial settings for our private data */ /* set the initial settings for our private data */
varsp->fInFocus = false; varsp->fInFocus = false;
varsp->fIsActive = true; varsp->fIsActive = true;
varsp->fTEActive = false; varsp->fTEActive = false;
varsp->fUserPaneRec = theControl; varsp->fUserPaneRec = theControl;
theWindow = varsp->fOwner = GetControlOwner(theControl); theWindow = varsp->fOwner = GetControlOwner(theControl);
#if TARGET_CARBON #if TARGET_CARBON
varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner); varsp->fDrawingEnvironment = GetWindowPort(varsp->fOwner);
#else #else
@@ -1838,16 +1840,16 @@ void wxTextCtrl::Copy()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECopy( teH ) ; TECopy( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
} }
else else
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCopy ) ;
} }
} }
} }
void wxTextCtrl::Cut() void wxTextCtrl::Cut()
@@ -1859,17 +1861,17 @@ void wxTextCtrl::Cut()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TECut( teH ) ; TECut( teH ) ;
ClearCurrentScrap(); ClearCurrentScrap();
TEToScrap() ; TEToScrap() ;
// MacInvalidateControl() ; // MacInvalidateControl() ;
}
else
{
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ;
}
} }
else
{
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPCut ) ;
}
}
} }
void wxTextCtrl::Paste() void wxTextCtrl::Paste()
@@ -1881,16 +1883,16 @@ void wxTextCtrl::Paste()
TEHandle teH ; TEHandle teH ;
long size ; long size ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TEFromScrap() ; TEFromScrap() ;
TEPaste( teH ) ; TEPaste( teH ) ;
MacRedrawControl() ; MacRedrawControl() ;
} }
else else
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPPaste ) ;
} }
} }
} }
bool wxTextCtrl::CanCopy() const bool wxTextCtrl::CanCopy() const
@@ -1986,22 +1988,22 @@ long wxTextCtrl::GetLastPosition() const
} }
else else
{ {
STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl); STPTextPaneVars** tpvars = (STPTextPaneVars **) GetControlReference( (ControlHandle) m_macControl);
int actualsize = 0 ; int actualsize = 0 ;
Handle theText ; Handle theText ;
OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData ); OSErr err = TXNGetDataEncoded( (**tpvars).fTXNRec, kTXNStartOffset, kTXNEndOffset, &theText , kTXNTextData );
/* all done */ /* all done */
if ( err ) if ( err )
{ {
actualsize = 0 ; actualsize = 0 ;
} }
else else
{ {
actualsize = GetHandleSize( theText ) ; actualsize = GetHandleSize( theText ) ;
DisposeHandle( theText ) ; DisposeHandle( theText ) ;
} }
return actualsize ; return actualsize ;
} }
} }
@@ -2014,19 +2016,19 @@ void wxTextCtrl::Replace(long from, long to, const wxString& value)
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
selection.selStart = from ; selection.selStart = from ;
selection.selEnd = to ; selection.selEnd = to ;
::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TESetSelect( from , to , teH ) ; TESetSelect( from , to , teH ) ;
TEDelete( teH ) ; TEDelete( teH ) ;
TEInsert( value , value.Length() , teH ) ; TEInsert( value , value.Length() , teH ) ;
} }
else else
{ {
// TODO // TODO
} }
Refresh() ; Refresh() ;
} }
void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::Remove(long from, long to)
@@ -2038,11 +2040,11 @@ void wxTextCtrl::Remove(long from, long to)
ControlEditTextSelectionRec selection ; ControlEditTextSelectionRec selection ;
selection.selStart = from ; selection.selStart = from ;
selection.selEnd = to ; selection.selEnd = to ;
::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ; ::SetControlData( (ControlHandle) m_macControl , 0, kControlEditTextSelectionTag , sizeof( selection ) , (char*) &selection ) ;
::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ; ::GetControlData( (ControlHandle) m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &teH , &size ) ;
TEDelete( teH ) ; TEDelete( teH ) ;
} }
else else
{ {
@@ -2134,7 +2136,7 @@ void wxTextCtrl::Clear()
{ {
mUPDoEditCommand( (ControlHandle) m_macControl , kmUPClear) ; mUPDoEditCommand( (ControlHandle) m_macControl , kmUPClear) ;
} }
Refresh() ; Refresh() ;
} }
bool wxTextCtrl::IsModified() const bool wxTextCtrl::IsModified() const
@@ -2219,13 +2221,13 @@ int wxTextCtrl::GetNumberOfLines() const
{ {
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
int count = 1; int count = 1;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return count; return count;
} }
@@ -2249,25 +2251,25 @@ int wxTextCtrl::GetLineLength(long lineNo) const
{ {
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
// Find line first // Find line first
int count = 0; int count = 0;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (count == lineNo) if (count == lineNo)
{ {
// Count chars in line then // Count chars in line then
count = 0; count = 0;
for (int j = i; j < content.Length(); j++) for (int j = i; j < content.Length(); j++)
{ {
count++; count++;
if (content[j] == '\r') return count; if (content[j] == '\r') return count;
} }
return count; return count;
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return 0; return 0;
} }
@@ -2276,27 +2278,27 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
// TODO change this if possible to reflect real lines // TODO change this if possible to reflect real lines
wxString content = GetValue() ; wxString content = GetValue() ;
// Find line first // Find line first
int count = 0; int count = 0;
for (int i = 0; i < content.Length() ; i++) for (int i = 0; i < content.Length() ; i++)
{ {
if (count == lineNo) if (count == lineNo)
{ {
// Add chars in line then // Add chars in line then
wxString tmp(""); wxString tmp("");
for (int j = i; j < content.Length(); j++) for (int j = i; j < content.Length(); j++)
{ {
if (content[j] == '\r') if (content[j] == '\r')
return tmp; return tmp;
tmp += content[j]; tmp += content[j];
} }
return tmp; return tmp;
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return wxString(""); return wxString("");
} }

View File

@@ -52,7 +52,15 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// list of all frames and modeless dialogs // list of all frames and modeless dialogs
wxWindowList wxModelessWindows; wxWindowList wxModelessWindows;
// double click testing
static Point gs_lastWhere;
static long gs_lastWhen = 0;
// cursor stuff
extern int wxBusyCursorCount;
// ============================================================================ // ============================================================================
// wxTopLevelWindowMac implementation // wxTopLevelWindowMac implementation
@@ -347,10 +355,6 @@ void wxTopLevelWindowMac::Lower()
::SendBehind( (WindowRef)m_macWindow , NULL ) ; ::SendBehind( (WindowRef)m_macWindow , NULL ) ;
} }
Point lastWhere ;
long lastWhen = 0 ;
extern int wxBusyCursorCount ;
void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr ) void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
{ {
EventRecord *ev = (EventRecord*) evr ; EventRecord *ev = (EventRecord*) evr ;
@@ -397,22 +401,25 @@ void wxTopLevelWindowMac::MacFireMouseEvent( WXEVENTREF evr )
if ( ev->what == mouseDown ) if ( ev->what == mouseDown )
{ {
if ( ev->when - lastWhen <= GetDblTime() ) if ( ev->when - gs_lastWhen <= GetDblTime() )
{ {
if ( abs( localwhere.h - lastWhere.h ) < 3 || abs( localwhere.v - lastWhere.v ) < 3 ) if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 )
{ {
// This is not right if the second mouse down
// event occured in a differen window. We
// correct this in MacDispatchMouseEvent.
if ( controlDown ) if ( controlDown )
event.SetEventType(wxEVT_RIGHT_DCLICK ) ; event.SetEventType(wxEVT_RIGHT_DCLICK ) ;
else else
event.SetEventType(wxEVT_LEFT_DCLICK ) ; event.SetEventType(wxEVT_LEFT_DCLICK ) ;
} }
lastWhen = 0 ; gs_lastWhen = 0 ;
} }
else else
{ {
lastWhen = ev->when ; gs_lastWhen = ev->when ;
} }
lastWhere = localwhere ; gs_lastWhere = localwhere ;
} }
event.m_x = localwhere.h; event.m_x = localwhere.h;

View File

@@ -1386,6 +1386,7 @@ bool wxWindowMac::MacGetWindowFromPoint( const wxPoint &screenpoint , wxWindowMa
} }
extern int wxBusyCursorCount ; extern int wxBusyCursorCount ;
static wxWindow *gs_lastWhich = NULL;
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event) bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
{ {
@@ -1438,6 +1439,23 @@ bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
wxToolTip::RelayEvent( this , event); wxToolTip::RelayEvent( this , event);
#endif // wxUSE_TOOLTIPS #endif // wxUSE_TOOLTIPS
if (gs_lastWhich != this)
{
gs_lastWhich = this;
// Double clicks must always occur on the same window
if (event.GetEventType() == wxEVT_LEFT_DCLICK)
event.SetEventType( wxEVT_LEFT_DOWN );
if (event.GetEventType() == wxEVT_RIGHT_DCLICK)
event.SetEventType( wxEVT_RIGHT_DOWN );
// Same for mouse up events
if (event.GetEventType() == wxEVT_LEFT_UP)
return TRUE;
if (event.GetEventType() == wxEVT_RIGHT_UP)
return TRUE;
}
GetEventHandler()->ProcessEvent( event ) ; GetEventHandler()->ProcessEvent( event ) ;
return TRUE; return TRUE;