#include "wx/textctrl.h"
#include "wx/settings.h"
+#include "wx/filefn.h"
+#include "wx/utils.h"
#if defined(__BORLANDC__) && !defined(__WIN32__)
#include <alloc.h>
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
- EVT_CHAR(wxTextCtrl::OnChar)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
- EVT_ERASE_BACKGROUND(wxTextCtrl::OnEraseBackground)
+ EVT_MENU(wxID_CUT, wxTextCtrl::OnCut)
+ EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy)
+ EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste)
+ EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo)
+ EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo)
+
+ EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut)
+ EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy)
+ EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste)
+ EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo)
+ EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo)
END_EVENT_TABLE()
#endif
void wxTextCtrl::Replace(long from, long to, const wxString& value)
{
// TODO
- return 0;
}
void wxTextCtrl::Remove(long from, long to)
// TODO write text to control
}
+void wxTextCtrl::AppendText(const wxString& text)
+{
+ // TODO append text to control
+}
+
void wxTextCtrl::Clear()
{
// TODO
return wxString("");
}
-/*
- * Text item
- */
-
+bool wxTextCtrl::CanCopy() const
+{
+ // Can copy if there's a selection
+ long from, to;
+ GetSelection(& from, & to);
+ return (from != to) ;
+}
+
+bool wxTextCtrl::CanCut() const
+{
+ // Can cut if there's a selection
+ long from, to;
+ GetSelection(& from, & to);
+ return (from != to) ;
+}
+
+bool wxTextCtrl::CanPaste() const
+{
+ return IsEditable() ;
+}
+
+// Undo/redo
+void wxTextCtrl::Undo()
+{
+ // TODO
+}
+
+void wxTextCtrl::Redo()
+{
+ // TODO
+}
+
+bool wxTextCtrl::CanUndo() const
+{
+ // TODO
+ return FALSE;
+}
+
+bool wxTextCtrl::CanRedo() const
+{
+ // TODO
+ return FALSE;
+}
+
+// If the return values from and to are the same, there is no
+// selection.
+void wxTextCtrl::GetSelection(long* from, long* to) const
+{
+ // TODO
+ *from = 0;
+ *to = 0;
+}
+
+bool wxTextCtrl::IsEditable() const
+{
+ // TODO
+ return FALSE;
+}
+
void wxTextCtrl::Command(wxCommandEvent & event)
{
SetValue (event.GetString());
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
- WriteText(txt);
+ AppendText(txt);
delete[] txt;
}
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
{
- WriteText(s);
+ AppendText(s);
return *this;
}
{
wxString str;
str.Printf("%.2f", f);
- WriteText(str);
+ AppendText(str);
return *this;
}
{
wxString str;
str.Printf("%.2f", d);
- WriteText(str);
+ AppendText(str);
return *this;
}
{
wxString str;
str.Printf("%d", i);
- WriteText(str);
+ AppendText(str);
return *this;
}
{
wxString str;
str.Printf("%ld", i);
- WriteText(str);
+ AppendText(str);
return *this;
}
buf[0] = c;
buf[1] = 0;
- WriteText(buf);
+ AppendText(buf);
return *this;
}
+void wxTextCtrl::OnCut(wxCommandEvent& event)
+{
+ Cut();
+}
+
+void wxTextCtrl::OnCopy(wxCommandEvent& event)
+{
+ Copy();
+}
+
+void wxTextCtrl::OnPaste(wxCommandEvent& event)
+{
+ Paste();
+}
+
+void wxTextCtrl::OnUndo(wxCommandEvent& event)
+{
+ Undo();
+}
+
+void wxTextCtrl::OnRedo(wxCommandEvent& 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() );
+}