]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/textctrl.cpp
unicode fixes
[wxWidgets.git] / src / mac / textctrl.cpp
index 852aa49750da80b291a6195fa10cbedd92b85d0a..a289930a71611f2be530caf24b248919c28d3bca 100644 (file)
@@ -60,7 +60,6 @@
 
 #define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
 
-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
@@ -576,6 +575,13 @@ OSStatus mUPOpenControl(ControlHandle theControl, long wxStyle )
         kTXNSystemDefaultEncoding,
         &varsp->fTXNRec, &varsp->fTXNFrame, (TXNObjectRefcon) tpvars);
 
+    if ( (wxStyle & wxTE_MULTILINE) && (wxStyle & wxTE_DONTWRAP) )
+    {
+        TXNControlTag tag = kTXNWordWrapStateTag ;
+        TXNControlData dat ;
+        dat.uValue = kTXNNoAutoWrap ;
+        TXNSetTXNObjectControls( varsp->fTXNRec , false , 1 , &tag , &dat ) ;
+    }
         Str255 fontName ;
         SInt16 fontSize ;
         Style fontStyle ;
@@ -674,7 +680,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, validator, name) )
         return FALSE;
 
     wxSize mySize = size ;
@@ -722,7 +728,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
         m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , "\p" , true , 0 , 0 , 1,
             (style & wxTE_PASSWORD) ? kControlEditTextPasswordProc : kControlEditTextProc , (long) this ) ;
         long size ;
-        ::GetControlData((ControlHandle)  m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*) &((TEHandle) m_macTE) , &size ) ;
+        ::GetControlData((ControlHandle)  m_macControl , 0, kControlEditTextTEHandleTag , sizeof( TEHandle ) , (char*)((TEHandle *)&m_macTE) , &size ) ;
 
     }
     else
@@ -931,8 +937,10 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
 
         if ( attrCounter > 0 )
         {
-            OSStatus status = TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr,
-                start,end);
+#ifdef __WXDEBUG__
+            OSStatus status =
+#endif // __WXDEBUG__
+                TXNSetTypeAttributes ((TXNObject)m_macTXN, attrCounter , typeAttr, start,end);
             wxASSERT_MSG( status == noErr , wxT("Couldn't set text attributes") ) ;
         }
         if ( !formerEditable )
@@ -1344,6 +1352,10 @@ void wxTextCtrl::Undo()
 {
     if (CanUndo())
     {
+        if ( m_macUsesTXN ) 
+        {
+            TXNUndo((TXNObject)m_macTXN); 
+        }
     }
 }
 
@@ -1351,16 +1363,36 @@ void wxTextCtrl::Redo()
 {
     if (CanRedo())
     {
+        if ( m_macUsesTXN ) 
+        {
+            TXNRedo((TXNObject)m_macTXN); 
+        }
     }
 }
 
 bool wxTextCtrl::CanUndo() const
 {
+    if ( !IsEditable() ) 
+    {
+        return false ; 
+    }
+    if ( m_macUsesTXN ) 
+    {
+        return TXNCanUndo((TXNObject)m_macTXN,NULL); 
+    }
     return FALSE ;
 }
 
 bool wxTextCtrl::CanRedo() const
 {
+    if ( !IsEditable() ) 
+    {
+        return false ; 
+    }
+    if ( m_macUsesTXN ) 
+    {
+        return TXNCanRedo((TXNObject)m_macTXN,NULL); 
+    }
     return FALSE ;
 }
 
@@ -1566,8 +1598,25 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
 
     if (!eat_key)
     {
-        // default handling
-        event.Skip() ;
+        // perform keystroke handling
+#if TARGET_CARBON
+        if ( m_macUsesTXN && wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
+            CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+        else 
+#endif
+        {
+            EventRecord rec ;
+            if ( wxMacConvertEventToRecord(  (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) )
+            {
+                EventRecord *ev = &rec ;
+                short keycode ;
+                short keychar ;
+                keychar = short(ev->message & charCodeMask);
+                keycode = short(ev->message & keyCodeMask) >> 8 ;
+
+                ::HandleControlKey( (ControlHandle) m_macControl , keycode , keychar , ev->modifiers ) ;
+            }
+        }
     }
     if ( ( key >= 0x20 && key < WXK_START ) ||
          key == WXK_RETURN ||