Looks like I've fixed the editing

bugs. Delete/Insert/Home/End/Ctrl-Delete all work as expected.
Cursor gets redrawn properly.
Scroll-to-cursor still missing.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-08-12 16:14:15 +00:00
parent 362c669367
commit 23b75a2db4
4 changed files with 119 additions and 60 deletions
+1 -2
View File
@@ -9,7 +9,7 @@ LGPL (GNU LIBRARY PUBLIC LICENSE), by Karsten Ballueder <ballueder@usa.net>.
This is still work in progress, so if you want to make any significant
changes, please get in touch with me before.
There are three building blocks for richt text editing:
There are three building blocks for rich text editing:
wxllist :
@@ -40,7 +40,6 @@ linebreaks) and export of objects, text or html.
Planned for the future is an html parser for importing html.
wxLayout.cpp is a simple test program. It will export Text and HTML to
stdout and demonstrate some of the features and bugs of wxLayoutList.
File diff suppressed because it is too large Load Diff
+7 -5
View File
@@ -39,7 +39,7 @@
/// Types of currently supported layout objects.
enum wxLayoutObjectType
{ WXLO_TYPE_INVALID, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK };
{ WXLO_TYPE_INVALID = 0, WXLO_TYPE_TEXT, WXLO_TYPE_CMD, WXLO_TYPE_ICON, WXLO_TYPE_LINEBREAK };
/// Type used for coordinates in drawing.
typedef long CoordType;
@@ -249,8 +249,8 @@ public:
void SetEditable(bool editable = true) { m_Editable = editable; }
/// return true if list is editable
bool IsEditable(void) const { return m_Editable; }
/// move cursor
void MoveCursor(int dx = 0, int dy = 0);
/// move cursor, returns true if it could move to the desired position
bool MoveCursor(int dx = 0, int dy = 0);
void SetCursor(wxPoint const &p) { m_CursorPosition = p; }
wxPoint GetCursor(void) const { return m_CursorPosition; }
/// delete one or more cursor positions
@@ -264,8 +264,10 @@ public:
wxLayoutObjectCmd const *GetDefaults(void) const { return m_DefaultSetting ; }
wxLayoutObjectList::iterator FindCurrentObject(CoordType *offset = NULL);
// get the length of the line with the object pointed to by i
CoordType GetLineLength(wxLayoutObjectList::iterator i);
// get the length of the line with the object pointed to by i, offs
// only used to decide whether we are before or after linebreak
CoordType GetLineLength(wxLayoutObjectList::iterator i,
CoordType offs = 0);
//@}
protected:
/// font parameters:
+12 -3
View File
@@ -68,6 +68,7 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
long keyCode = event.KeyCode();
wxPoint p;
CoordType help;
switch(event.KeyCode())
{
@@ -100,11 +101,19 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
m_llist.SetCursor(p);
break;
case WXK_DELETE :
m_llist.Delete(1);
if(event.ControlDown()) // delete to end of line
{
help = m_llist.GetLineLength(
m_llist.FindCurrentObject(NULL))
- m_llist.GetCursor().x;
m_llist.Delete(help ? help : 1);
}
else
m_llist.Delete(1);
break;
case WXK_BACK: // backspace
m_llist.MoveCursor(-1);
m_llist.Delete(1);
if(m_llist.MoveCursor(-1))
m_llist.Delete(1);
break;
case WXK_RETURN:
m_llist.LineBreak();