cleanup - reformat (part 3)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36704 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-05 08:38:57 +00:00
parent 7dd40b6f4b
commit c88b7d288c

View File

@@ -179,6 +179,10 @@ public :
virtual wxString GetStringValue() const = 0 ; virtual wxString GetStringValue() const = 0 ;
virtual void SetStringValue( const wxString &val ) = 0 ; virtual void SetStringValue( const wxString &val ) = 0 ;
virtual void SetSelection( long from, long to ) = 0 ;
virtual void GetSelection( long* from, long* to ) const = 0 ;
virtual void WriteText( const wxString& str ) = 0 ;
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ; virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
virtual void Copy() ; virtual void Copy() ;
virtual void Cut() ; virtual void Cut() ;
@@ -188,9 +192,7 @@ public :
virtual wxTextPos GetLastPosition() const ; virtual wxTextPos GetLastPosition() const ;
virtual void Replace( long from, long to, const wxString &str ) ; virtual void Replace( long from, long to, const wxString &str ) ;
virtual void Remove( long from, long to ) ; virtual void Remove( long from, long to ) ;
virtual void SetSelection( long from , long to ) = 0 ;
virtual void GetSelection( long* from, long* to) const = 0 ;
virtual void WriteText(const wxString& str) = 0 ;
virtual bool HasOwnContextMenu() const virtual bool HasOwnContextMenu() const
{ return false ; } { return false ; }
@@ -228,6 +230,7 @@ class wxMacMLTEControl : public wxMacTextControl
{ {
public : public :
wxMacMLTEControl( wxTextCtrl *peer ) ; wxMacMLTEControl( wxTextCtrl *peer ) ;
virtual wxString GetStringValue() const ; virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str ) ; virtual void SetStringValue( const wxString &str ) ;
@@ -422,15 +425,13 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
END_EVENT_TABLE() END_EVENT_TABLE()
// Text item
void wxTextCtrl::Init() void wxTextCtrl::Init()
{ {
m_editable = true ; m_editable = true ;
m_dirty = false; m_dirty = false;
m_privateContextMenu = NULL;
m_maxLength = TE_UNLIMITED_LENGTH ; m_maxLength = TE_UNLIMITED_LENGTH ;
m_privateContextMenu = NULL;
} }
wxTextCtrl::~wxTextCtrl() wxTextCtrl::~wxTextCtrl()
@@ -438,10 +439,12 @@ wxTextCtrl::~wxTextCtrl()
delete m_privateContextMenu; delete m_privateContextMenu;
} }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent,
wxWindowID id,
const wxString& str, const wxString& str,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size,
long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
@@ -456,7 +459,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
{ {
wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER), wxASSERT_MSG(
!(m_windowStyle & wxTE_PROCESS_ENTER),
wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") ); wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") );
m_windowStyle |= wxTE_PROCESS_ENTER; m_windowStyle |= wxTE_PROCESS_ENTER;
@@ -466,7 +470,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
bool forceMLTE = false ; bool forceMLTE = false ;
#if wxUSE_SYSTEM_OPTIONS #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 ; forceMLTE = true ;
} }
@@ -474,7 +478,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
#ifdef __WXMAC_OSX__ #ifdef __WXMAC_OSX__
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
if ( UMAGetSystemVersion() >= 0x1030 && forceMLTE == false ) if ( UMAGetSystemVersion() >= 0x1030 && !forceMLTE )
{ {
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ; m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ;
@@ -483,15 +487,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
if ( !m_peer ) if ( !m_peer )
{ {
if ( !(m_windowStyle & wxTE_MULTILINE) && forceMLTE == false ) if ( !(m_windowStyle & wxTE_MULTILINE) && !forceMLTE )
m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ; m_peer = new wxMacUnicodeTextControl( this , str , pos , size , style ) ;
} }
#endif #endif
if ( !m_peer ) if ( !m_peer )
{
m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ; m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ;
}
MacPostControlCreate(pos, size) ; MacPostControlCreate(pos, size) ;
@@ -737,12 +739,11 @@ bool wxTextCtrl::AcceptsFocus() const
wxSize wxTextCtrl::DoGetBestSize() const wxSize wxTextCtrl::DoGetBestSize() const
{ {
int wText = 100 ; int wText, hText;
int hText;
// these are the numbers from the HIG: // these are the numbers from the HIG:
// we reduce them by the borders first // we reduce them by the borders first
wText = 100 ;
switch ( m_windowVariant ) switch ( m_windowVariant )
{ {
@@ -986,14 +987,16 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
// perform keystroke handling // perform keystroke handling
if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL ) if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
{
CallNextEventHandler( (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef(), (EventRef)wxTheApp->MacGetCurrentEvent() ) ; CallNextEventHandler( (EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef(), (EventRef)wxTheApp->MacGetCurrentEvent() ) ;
}
else else
{ {
EventRecord rec ; EventRecord rec ;
if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ) if ( wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
{ {
EventRecord *ev = &rec ;
short keycode, keychar ; short keycode, keychar ;
EventRecord *ev = &rec ;
keychar = short(ev->message & charCodeMask); keychar = short(ev->message & charCodeMask);
keycode = short(ev->message & keyCodeMask) >> 8 ; keycode = short(ev->message & keyCodeMask) >> 8 ;
@@ -1536,6 +1539,7 @@ wxString wxMacMLTEControl::GetStringValue() const
wxString result ; wxString result ;
OSStatus err ; OSStatus err ;
Size actualSize = 0; Size actualSize = 0;
{ {
#if wxUSE_UNICODE #if wxUSE_UNICODE
Handle theText ; Handle theText ;
@@ -1555,7 +1559,7 @@ wxString wxMacMLTEControl::GetStringValue() const
#if SIZEOF_WCHAR_T == 2 #if SIZEOF_WCHAR_T == 2
ptr = new wxChar[actualSize + 1] ; ptr = new wxChar[actualSize + 1] ;
wxStrncpy( ptr , (wxChar*) *theText , actualSize ) ; wxStrncpy( ptr , (wxChar*)(*theText) , actualSize ) ;
#else #else
SetHandleSize( theText, (actualSize + 1) * sizeof(UniChar) ) ; SetHandleSize( theText, (actualSize + 1) * sizeof(UniChar) ) ;
HLock( theText ) ; HLock( theText ) ;
@@ -1612,8 +1616,8 @@ wxString wxMacMLTEControl::GetStringValue() const
void wxMacMLTEControl::SetStringValue( const wxString &str ) void wxMacMLTEControl::SetStringValue( const wxString &str )
{ {
wxString st = str; wxString st = str;
wxMacConvertNewlines10To13( &st ); wxMacConvertNewlines10To13( &st );
{ {
wxMacWindowClipper c( m_peer ); wxMacWindowClipper c( m_peer );
@@ -1629,38 +1633,34 @@ void wxMacMLTEControl::SetStringValue( const wxString &str )
TXNFrameOptions wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle ) TXNFrameOptions wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle )
{ {
TXNFrameOptions frameOptions = TXNFrameOptions frameOptions = kTXNDontDrawCaretWhenInactiveMask;
kTXNDontDrawCaretWhenInactiveMask
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
| kTXNDoFontSubstitutionMask frameOptions |= kTXNDoFontSubstitutionMask;
#endif #endif
;
if ( ! (wxStyle & wxTE_NOHIDESEL) ) if ( ! (wxStyle & wxTE_NOHIDESEL) )
frameOptions |= kTXNDontDrawSelectionWhenInactiveMask ; frameOptions |= kTXNDontDrawSelectionWhenInactiveMask ;
if ( wxStyle & (wxHSCROLL | wxTE_DONTWRAP) )
frameOptions |= kTXNWantHScrollBarMask ;
if ( wxStyle & wxTE_MULTILINE ) if ( wxStyle & wxTE_MULTILINE )
{ {
if ( ! ( wxStyle & wxTE_DONTWRAP ) )
frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ; frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
else
{
frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ;
frameOptions |= kTXNWantHScrollBarMask ;
}
if ( !(wxStyle & wxTE_NO_VSCROLL) ) if ( !(wxStyle & wxTE_NO_VSCROLL) )
{ {
frameOptions |= kTXNWantVScrollBarMask ; frameOptions |= kTXNWantVScrollBarMask ;
if ( frameOptions & kTXNWantHScrollBarMask ) if ( frameOptions & kTXNWantHScrollBarMask )
frameOptions |= kTXNDrawGrowIconMask ; frameOptions |= kTXNDrawGrowIconMask ;
} }
} }
else else
{
frameOptions |= kTXNSingleLineOnlyMask ; frameOptions |= kTXNSingleLineOnlyMask ;
}
if ( wxStyle & wxHSCROLL )
frameOptions |= kTXNWantHScrollBarMask ;
return frameOptions ; return frameOptions ;
} }
@@ -1682,10 +1682,10 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo
if ( m_windowStyle & wxTE_MULTILINE ) if ( m_windowStyle & wxTE_MULTILINE )
{ {
if (m_windowStyle & wxTE_DONTWRAP) iControlData[1].uValue =
iControlData[1].uValue = kTXNNoAutoWrap ; (m_windowStyle & wxTE_DONTWRAP)
else ? kTXNNoAutoWrap
iControlData[1].uValue = kTXNAutoWrap ; : kTXNAutoWrap;
} }
verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ) ; verify_noerr( TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ) ;
@@ -1708,9 +1708,10 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo
{ kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } , { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
} ; } ;
verify_noerr( TXNSetTypeAttributes (m_txn, sizeof( typeAttr ) / sizeof(TXNTypeAttributes) , typeAttr, verify_noerr(
kTXNStartOffset, TXNSetTypeAttributes(
kTXNEndOffset) ); m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes),
typeAttr, kTXNStartOffset, kTXNEndOffset ) );
} }
if ( m_windowStyle & wxTE_PASSWORD ) if ( m_windowStyle & wxTE_PASSWORD )
@@ -1976,8 +1977,7 @@ long wxMacMLTEControl::XYToPosition(long x, long y) const
// line metrics of a certain line, we don't get its starting // line metrics of a certain line, we don't get its starting
// position, so it would probably be rather a binary search // position, so it would probably be rather a binary search
// for the start position // for the start position
long xpos = 0 ; long xpos = 0, ypos = 0 ;
long ypos = 0 ;
int lastHeight = 0 ; int lastHeight = 0 ;
ItemCount n ; ItemCount n ;
@@ -2017,7 +2017,7 @@ bool wxMacMLTEControl::PositionToXY(long pos, long *x, long *y) const
lastpos = GetLastPosition() ; lastpos = GetLastPosition() ;
if ( pos <= lastpos ) if ( pos <= lastpos )
{ {
// TODO: find a better implementation : while we can get the // TODO: find a better implementation - while we can get the
// line metrics of a certain line, we don't get its starting // line metrics of a certain line, we don't get its starting
// position, so it would probably be rather a binary search // position, so it would probably be rather a binary search
// for the start position // for the start position
@@ -2256,8 +2256,7 @@ pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef
break ; break ;
case kControlIndicatorPart : case kControlIndicatorPart :
delta = value - delta = value - (isHorizontal ? mlte->m_lastHorizontalValue : mlte->m_lastVerticalValue) ;
( isHorizontal ? mlte->m_lastHorizontalValue : mlte->m_lastVerticalValue ) ;
break ; break ;
default : default :
@@ -2433,11 +2432,13 @@ void wxMacMLTEClassicControl::MacUpdatePosition()
#endif #endif
#else #else
TXNSetFrameBounds( m_txn, m_txnControlBounds.top, m_txnControlBounds.left, TXNSetFrameBounds(
m_txn, m_txnControlBounds.top, m_txnControlBounds.left,
wxMax( m_txnControlBounds.bottom, m_txnControlBounds.top ), wxMax( m_txnControlBounds.bottom, m_txnControlBounds.top ),
wxMax( m_txnControlBounds.right, m_txnControlBounds.left ), m_txnFrameID ); wxMax( m_txnControlBounds.right, m_txnControlBounds.left ), m_txnFrameID );
#endif #endif
// the SetFrameBounds method unter classic sometimes does not correctly scroll a selection into sight after a
// the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
// movement, therefore we have to force it // movement, therefore we have to force it
// this problem has been reported in OSX as well, so we use this here once again // this problem has been reported in OSX as well, so we use this here once again
@@ -2521,8 +2522,8 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxIn
case kControlEditTextPart : case kControlEditTextPart :
{ {
wxMacWindowClipper clipper( textctrl ) ; wxMacWindowClipper clipper( textctrl ) ;
EventRecord rec ; EventRecord rec ;
ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ; ConvertEventRefToEventRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;
TXNClick( m_txn, &rec ); TXNClick( m_txn, &rec );
} }
@@ -2589,12 +2590,11 @@ void wxMacMLTEClassicControl::MacControlUserPaneActivateProc( bool activating)
wxInt16 wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action) wxInt16 wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action)
{ {
ControlPartCode focusResult; ControlPartCode focusResult = kControlFocusNoPart;
focusResult = kControlFocusNoPart;
wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef ); wxTextCtrl* textctrl = (wxTextCtrl*)GetControlReference( m_controlRef );
if ( textctrl == NULL ) if ( textctrl == NULL )
return 0; return focusResult;
wxMacWindowClipper clipper( textctrl ) ; wxMacWindowClipper clipper( textctrl ) ;
@@ -2633,9 +2633,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer,
m_windowStyle = style ; m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
short featureSet; short featureSet =
featureSet =
kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle kControlSupportsEmbedding | kControlSupportsFocus | kControlWantsIdle
| kControlWantsActivate | kControlHandlesTracking | kControlWantsActivate | kControlHandlesTracking
// | kControlHasSpecialBackground // | kControlHasSpecialBackground
@@ -2802,6 +2800,7 @@ OSStatus wxMacMLTEClassicControl::DoCreate()
SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc); SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneActivateProcTag, sizeof(gTPActivateProc), &gTPActivateProc);
SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc); SetControlData(m_controlRef, kControlEntireControl, kControlUserPaneFocusProcTag, sizeof(gTPFocusProc), &gTPFocusProc);
#endif #endif
// calculate the rectangles used by the control // calculate the rectangles used by the control
UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds ); UMAGetControlBoundsInWindowCoords( m_controlRef, &bounds );
@@ -2849,11 +2848,10 @@ OSStatus wxMacMLTEClassicControl::DoCreate()
#endif #endif
verify_noerr(TXNNewObject(NULL, m_txnWindow , &bounds, verify_noerr(
frameOptions , TXNNewObject(
kTXNTextEditStyleFrameType, NULL, m_txnWindow, &bounds, frameOptions,
kTXNTextensionFile, kTXNTextEditStyleFrameType, kTXNTextensionFile, kTXNSystemDefaultEncoding,
kTXNSystemDefaultEncoding,
&m_txn, &m_txnFrameID, NULL ) ); &m_txn, &m_txnFrameID, NULL ) );
#if 0 #if 0