+static void
+wxTextWindowModifyProc (Widget WXUNUSED(w), XtPointer clientData, XmTextVerifyCallbackStruct *cbs)
+{
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ tw->m_processedDefault = FALSE;
+
+ // First, do some stuff if it's a password control: in this case, we need
+ // to store the string inside the class because GetValue() can't retrieve
+ // it from the text ctrl. We do *not* do it in other circumstances because
+ // it would double the amount of memory needed.
+
+ if ( tw->GetWindowStyleFlag() & wxTE_PASSWORD )
+ {
+ MergeChangesIntoString(tw->m_value, cbs);
+
+ if ( cbs->text->length > 0 )
+ {
+ int i;
+ for (i = 0; i < cbs->text->length; ++i)
+ cbs->text->ptr[i] = '*';
+ cbs->text->ptr[i] = '\0';
+ }
+ }
+
+ if(tw->InSetValue())
+ return;
+
+ // If we're already within an OnChar, return: probably a programmatic
+ // insertion.
+ if (tw->m_tempCallbackStruct)
+ return;
+
+ // Check for a backspace
+ if (cbs->startPos == (cbs->currInsert - 1))
+ {
+ tw->DoSendEvents((void *)cbs, WXK_DELETE);
+
+ return;
+ }
+
+ // Pasting operation: let it through without calling OnChar
+ if (cbs->text->length > 1)
+ return;
+
+ // Something other than text
+ if (cbs->text->ptr == NULL)
+ return;
+
+ // normal key press
+ char ch = cbs->text->ptr[0];
+ tw->DoSendEvents((void *)cbs, ch == '\n' ? '\r' : ch);
+}
+
+static void
+wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *WXUNUSED(cbs))
+{
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
+ event.SetEventObject(tw);
+ tw->GetEventHandler()->ProcessEvent(event);
+}
+
+static void
+wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *WXUNUSED(cbs))
+{
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
+ event.SetEventObject(tw);
+ tw->GetEventHandler()->ProcessEvent(event);
+}
+
+static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
+ XmAnyCallbackStruct *WXUNUSED(ptr))
+{
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+
+ if (tw->InSetValue())
+ return;
+
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
+ event.SetId(tw->GetId());
+ event.SetEventObject(tw);
+ tw->ProcessCommand(event);
+}
+
+void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event))
+{
+ Cut();
+}
+
+void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event))
+{
+ Copy();
+}
+
+void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event))
+{
+ Paste();
+}
+
+void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event))
+{
+ Undo();
+}
+
+void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event))
+{
+ Redo();
+}
+
+void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCut() );
+}
+
+void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event)
+{
+ event.Enable( CanCopy() );
+}
+
+void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event)
+{
+ event.Enable( CanPaste() );
+}
+
+void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanUndo() );
+}
+
+void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event)
+{
+ event.Enable( CanRedo() );
+}