added carbon events for navigation keys, size corrections

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2002-05-11 06:52:50 +00:00
parent 7eb67c0012
commit 402679b0f8
2 changed files with 92 additions and 84 deletions

View File

@@ -159,7 +159,6 @@ typedef struct {
/* OS records referenced */ /* OS records referenced */
TXNObject fTXNRec; /* the txn record */ TXNObject fTXNRec; /* the txn record */
TXNFrameID fTXNFrame; /* the txn frame ID */ TXNFrameID fTXNFrame; /* the txn frame ID */
bool fMultiline ;
ControlHandle fUserPaneRec; /* handle to the user pane control */ ControlHandle fUserPaneRec; /* handle to the user pane control */
WindowPtr fOwner; /* window containing control */ WindowPtr fOwner; /* window containing control */
GrafPtr fDrawingEnvironment; /* grafport where control is drawn */ GrafPtr fDrawingEnvironment; /* grafport where control is drawn */
@@ -176,6 +175,7 @@ typedef struct {
/* our focus advance override routine */ /* our focus advance override routine */
EventHandlerUPP handlerUPP; EventHandlerUPP handlerUPP;
EventHandlerRef handlerRef; EventHandlerRef handlerRef;
bool fMultiline ;
} STPTextPaneVars; } STPTextPaneVars;
@@ -194,8 +194,8 @@ ControlUserPaneFocusUPP gTPFocusProc = NULL;
/* events handled by our focus advance override routine */ /* events handled by our focus advance override routine */
#if TARGET_CARBON #if TARGET_CARBON
//static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } }; static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
//#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec )) #define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
#endif #endif
@@ -601,21 +601,18 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline)
kTXNSystemDefaultEncoding, kTXNSystemDefaultEncoding,
&varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars); &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
/* set the field's font and style */ Str255 fontName ;
TXNTypeAttributes typeAttr[2]; SInt16 fontSize ;
typeAttr[0].tag = kTXNQDFontSizeAttribute; Style fontStyle ;
typeAttr[0].size = kTXNFontSizeAttributeSize;
typeAttr[0].data.dataValue = 10 << 16;
typeAttr[1].tag = kTXNQDFontStyleAttribute; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
typeAttr[1].size = kTXNQDFontStyleAttributeSize;
typeAttr[1].data.dataValue = normal ;
/* this does not seem to get the font id through TXNTypeAttributes typeAttr[] =
typeAttr[2].tag = kTXNQDFontFamilyIDAttribute ; // NameAttribute; {
typeAttr[2].size = kTXNQDFontFamilyIDAttributeSize ; // kTXNQDFontNameAttributeSize; { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } ,
typeAttr[2].data.dataValue = kFontIDTimes ; // (void*) "\pGeneva" ; { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } ,
*/ { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
} ;
OSStatus status = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr, OSStatus status = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr,
kTXNStartOffset, kTXNStartOffset,
@@ -627,9 +624,9 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline)
/* install our focus advance override routine */ /* install our focus advance override routine */
#if TARGET_CARBON #if TARGET_CARBON
// varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride); varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride);
// err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP, err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
// kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef ); kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
#endif #endif
/* unlock our storage */ /* unlock our storage */
@@ -667,8 +664,9 @@ END_EVENT_TABLE()
// Text item // Text item
wxTextCtrl::wxTextCtrl() wxTextCtrl::wxTextCtrl()
{ {
((TEHandle) m_macTE) = NULL ; m_macTE = NULL ;
((TXNObject) m_macTXN) = NULL ; m_macTXN = NULL ;
m_macTXNvars = NULL ;
m_macUsesTXN = false ; m_macUsesTXN = false ;
m_editable = true ; m_editable = true ;
} }
@@ -677,16 +675,16 @@ wxTextCtrl::~wxTextCtrl()
{ {
if ( m_macUsesTXN ) if ( m_macUsesTXN )
{ {
SetControlReference((ControlHandle)m_macControl, 0) ;
TXNDeleteObject((TXNObject)m_macTXN); TXNDeleteObject((TXNObject)m_macTXN);
#if TARGET_CARBON #if TARGET_CARBON
/* remove our focus advance override */ /* remove our focus advance override */
// RemoveEventHandler((**tpvars).handlerRef); ::RemoveEventHandler((**(STPTextPaneVars **) m_macTXNvars).handlerRef);
// DisposeEventHandlerUPP((**tpvars).handlerUPP); ::DisposeEventHandlerUPP((**(STPTextPaneVars **) m_macTXNvars).handlerUPP);
#endif #endif
/* delete our private storage */ /* delete our private storage */
DisposeHandle((Handle) m_macTXNvars); DisposeHandle((Handle) m_macTXNvars);
/* zero the control reference */ /* zero the control reference */
SetControlReference((ControlHandle)m_macControl, 0) ;
} }
} }
@@ -700,8 +698,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
((TEHandle) m_macTE) = NULL ; m_macTE = NULL ;
((TXNObject) m_macTXN) = NULL ; m_macTXN = NULL ;
m_macTXNvars = NULL ;
m_macUsesTXN = false ; m_macUsesTXN = false ;
m_editable = true ; m_editable = true ;
@@ -728,17 +727,16 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
/*
if ( mySize.y == -1 ) if ( mySize.y == -1 )
{ {
if ( !m_macUsesTXN )
mySize.y = 13 ; mySize.y = 13 ;
else if ( m_windowStyle & wxTE_MULTILINE )
mySize.y = 16 ; mySize.y *= 5 ;
mySize.y += 2 * m_macVerticalBorder ; mySize.y += 2 * m_macVerticalBorder ;
} }
*/
MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ;
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
@@ -762,7 +760,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
{ {
short featurSet; short featurSet;
featurSet = kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle featurSet = kControlSupportsEmbedding | kControlSupportsFocus // | kControlWantsIdle
| kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground | kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground
| kControlGetsFocusOnClick | kControlSupportsLiveFeedback; | kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
/* create the control */ /* create the control */
@@ -1179,12 +1177,15 @@ wxSize wxTextCtrl::DoGetBestSize() const
{ {
int wText = 100 ; int wText = 100 ;
int hText ; int hText;
if ( UMAHasAppearance() ) if ( m_macUsesTXN )
hText = 13 ; {
hText = 17 ;
}
else else
hText = 24 ; {
hText += 2 * m_macHorizontalBorder ; hText = 13 ;
}
/* /*
int cx, cy; int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
@@ -1197,8 +1198,10 @@ wxSize wxTextCtrl::DoGetBestSize() const
*/ */
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
{ {
hText *= wxMin(GetNumberOfLines(), 5); hText *= 5 ;
} }
hText += 2 * m_macVerticalBorder ;
wText += 2 * m_macHorizontalBorder ;
//else: for single line control everything is ok //else: for single line control everything is ok
return wxSize(wText, hText); return wxSize(wText, hText);
} }
@@ -1319,6 +1322,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return "" ;
} }
/* /*

View File

@@ -159,7 +159,6 @@ typedef struct {
/* OS records referenced */ /* OS records referenced */
TXNObject fTXNRec; /* the txn record */ TXNObject fTXNRec; /* the txn record */
TXNFrameID fTXNFrame; /* the txn frame ID */ TXNFrameID fTXNFrame; /* the txn frame ID */
bool fMultiline ;
ControlHandle fUserPaneRec; /* handle to the user pane control */ ControlHandle fUserPaneRec; /* handle to the user pane control */
WindowPtr fOwner; /* window containing control */ WindowPtr fOwner; /* window containing control */
GrafPtr fDrawingEnvironment; /* grafport where control is drawn */ GrafPtr fDrawingEnvironment; /* grafport where control is drawn */
@@ -176,6 +175,7 @@ typedef struct {
/* our focus advance override routine */ /* our focus advance override routine */
EventHandlerUPP handlerUPP; EventHandlerUPP handlerUPP;
EventHandlerRef handlerRef; EventHandlerRef handlerRef;
bool fMultiline ;
} STPTextPaneVars; } STPTextPaneVars;
@@ -194,8 +194,8 @@ ControlUserPaneFocusUPP gTPFocusProc = NULL;
/* events handled by our focus advance override routine */ /* events handled by our focus advance override routine */
#if TARGET_CARBON #if TARGET_CARBON
//static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventUnicodeForKeyEvent } }; static const EventTypeSpec gMLTEEvents[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } };
//#define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec )) #define kMLTEEventCount (sizeof( gMLTEEvents ) / sizeof( EventTypeSpec ))
#endif #endif
@@ -601,21 +601,18 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline)
kTXNSystemDefaultEncoding, kTXNSystemDefaultEncoding,
&varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars); &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
/* set the field's font and style */ Str255 fontName ;
TXNTypeAttributes typeAttr[2]; SInt16 fontSize ;
typeAttr[0].tag = kTXNQDFontSizeAttribute; Style fontStyle ;
typeAttr[0].size = kTXNFontSizeAttributeSize;
typeAttr[0].data.dataValue = 10 << 16;
typeAttr[1].tag = kTXNQDFontStyleAttribute; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
typeAttr[1].size = kTXNQDFontStyleAttributeSize;
typeAttr[1].data.dataValue = normal ;
/* this does not seem to get the font id through TXNTypeAttributes typeAttr[] =
typeAttr[2].tag = kTXNQDFontFamilyIDAttribute ; // NameAttribute; {
typeAttr[2].size = kTXNQDFontFamilyIDAttributeSize ; // kTXNQDFontNameAttributeSize; { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } ,
typeAttr[2].data.dataValue = kFontIDTimes ; // (void*) "\pGeneva" ; { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } ,
*/ { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
} ;
OSStatus status = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr, OSStatus status = TXNSetTypeAttributes (varsp->fTXNRec, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr,
kTXNStartOffset, kTXNStartOffset,
@@ -627,9 +624,9 @@ OSStatus mUPOpenControl(ControlHandle theControl, bool multiline)
/* install our focus advance override routine */ /* install our focus advance override routine */
#if TARGET_CARBON #if TARGET_CARBON
// varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride); varsp->handlerUPP = NewEventHandlerUPP(FocusAdvanceOverride);
// err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP, err = InstallWindowEventHandler( varsp->fOwner, varsp->handlerUPP,
// kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef ); kMLTEEventCount, gMLTEEvents, tpvars, &varsp->handlerRef );
#endif #endif
/* unlock our storage */ /* unlock our storage */
@@ -667,8 +664,9 @@ END_EVENT_TABLE()
// Text item // Text item
wxTextCtrl::wxTextCtrl() wxTextCtrl::wxTextCtrl()
{ {
((TEHandle) m_macTE) = NULL ; m_macTE = NULL ;
((TXNObject) m_macTXN) = NULL ; m_macTXN = NULL ;
m_macTXNvars = NULL ;
m_macUsesTXN = false ; m_macUsesTXN = false ;
m_editable = true ; m_editable = true ;
} }
@@ -677,16 +675,16 @@ wxTextCtrl::~wxTextCtrl()
{ {
if ( m_macUsesTXN ) if ( m_macUsesTXN )
{ {
SetControlReference((ControlHandle)m_macControl, 0) ;
TXNDeleteObject((TXNObject)m_macTXN); TXNDeleteObject((TXNObject)m_macTXN);
#if TARGET_CARBON #if TARGET_CARBON
/* remove our focus advance override */ /* remove our focus advance override */
// RemoveEventHandler((**tpvars).handlerRef); ::RemoveEventHandler((**(STPTextPaneVars **) m_macTXNvars).handlerRef);
// DisposeEventHandlerUPP((**tpvars).handlerUPP); ::DisposeEventHandlerUPP((**(STPTextPaneVars **) m_macTXNvars).handlerUPP);
#endif #endif
/* delete our private storage */ /* delete our private storage */
DisposeHandle((Handle) m_macTXNvars); DisposeHandle((Handle) m_macTXNvars);
/* zero the control reference */ /* zero the control reference */
SetControlReference((ControlHandle)m_macControl, 0) ;
} }
} }
@@ -700,8 +698,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
((TEHandle) m_macTE) = NULL ; m_macTE = NULL ;
((TXNObject) m_macTXN) = NULL ; m_macTXN = NULL ;
m_macTXNvars = NULL ;
m_macUsesTXN = false ; m_macUsesTXN = false ;
m_editable = true ; m_editable = true ;
@@ -728,17 +727,16 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
Rect bounds ; Rect bounds ;
Str255 title ; Str255 title ;
/*
if ( mySize.y == -1 ) if ( mySize.y == -1 )
{ {
if ( !m_macUsesTXN )
mySize.y = 13 ; mySize.y = 13 ;
else if ( m_windowStyle & wxTE_MULTILINE )
mySize.y = 16 ; mySize.y *= 5 ;
mySize.y += 2 * m_macVerticalBorder ; mySize.y += 2 * m_macVerticalBorder ;
} }
*/
MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ; MacPreControlCreate( parent , id , "" , pos , mySize ,style, validator , name , &bounds , title ) ;
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
@@ -762,7 +760,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
{ {
short featurSet; short featurSet;
featurSet = kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle featurSet = kControlSupportsEmbedding | kControlSupportsFocus // | kControlWantsIdle
| kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground | kControlWantsActivate | kControlHandlesTracking | kControlHasSpecialBackground
| kControlGetsFocusOnClick | kControlSupportsLiveFeedback; | kControlGetsFocusOnClick | kControlSupportsLiveFeedback;
/* create the control */ /* create the control */
@@ -1179,12 +1177,15 @@ wxSize wxTextCtrl::DoGetBestSize() const
{ {
int wText = 100 ; int wText = 100 ;
int hText ; int hText;
if ( UMAHasAppearance() ) if ( m_macUsesTXN )
hText = 13 ; {
hText = 17 ;
}
else else
hText = 24 ; {
hText += 2 * m_macHorizontalBorder ; hText = 13 ;
}
/* /*
int cx, cy; int cx, cy;
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont()); wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
@@ -1197,8 +1198,10 @@ wxSize wxTextCtrl::DoGetBestSize() const
*/ */
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
{ {
hText *= wxMin(GetNumberOfLines(), 5); hText *= 5 ;
} }
hText += 2 * m_macVerticalBorder ;
wText += 2 * m_macHorizontalBorder ;
//else: for single line control everything is ok //else: for single line control everything is ok
return wxSize(wText, hText); return wxSize(wText, hText);
} }
@@ -1319,6 +1322,7 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
} }
if (content[i] == '\r') count++; if (content[i] == '\r') count++;
} }
return "" ;
} }
/* /*