improved selection-autodeletion, but backspace handling not perfect
yet, untested git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -153,21 +153,15 @@ wxLayoutWindow::wxLayoutWindow(wxWindow *parent)
|
|||||||
m_bitmap = new wxBitmap(4,4);
|
m_bitmap = new wxBitmap(4,4);
|
||||||
m_bitmapSize = wxPoint(4,4);
|
m_bitmapSize = wxPoint(4,4);
|
||||||
m_llist = new wxLayoutList();
|
m_llist = new wxLayoutList();
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
SetAutoDeleteSelection(true);
|
||||||
|
#else
|
||||||
SetAutoDeleteSelection(false);
|
SetAutoDeleteSelection(false);
|
||||||
|
#endif
|
||||||
m_BGbitmap = NULL;
|
m_BGbitmap = NULL;
|
||||||
m_ScrollToCursor = false;
|
m_ScrollToCursor = false;
|
||||||
SetWrapMargin(0);
|
SetWrapMargin(0);
|
||||||
|
|
||||||
// initially the list is empty, so why would we need the scrollbars?
|
|
||||||
#if 0
|
|
||||||
wxPoint max = m_llist->GetSize();
|
|
||||||
SetScrollbars(X_SCROLL_PAGE, Y_SCROLL_PAGE,
|
|
||||||
max.x / X_SCROLL_PAGE + 1, max.y / Y_SCROLL_PAGE + 1);
|
|
||||||
EnableScrolling(true, true);
|
|
||||||
m_maxx = max.x + X_SCROLL_PAGE;
|
|
||||||
m_maxy = max.y + Y_SCROLL_PAGE;
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
// no scrollbars initially
|
// no scrollbars initially
|
||||||
m_hasHScrollbar =
|
m_hasHScrollbar =
|
||||||
m_hasVScrollbar = false;
|
m_hasVScrollbar = false;
|
||||||
@@ -338,12 +332,6 @@ wxLayoutWindow::OnMouse(int eventId, wxMouseEvent& event)
|
|||||||
m_llist->DrawCursor(dc, m_HaveFocus && IsEditable(), offset);
|
m_llist->DrawCursor(dc, m_HaveFocus && IsEditable(), offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// VZ: this should be unnecessary because mouse can only click on a
|
|
||||||
// visible part of the canvas
|
|
||||||
#if 0
|
|
||||||
ScrollToCursor();
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
DoPaint(); // DoPaint suppresses flicker under GTK
|
DoPaint(); // DoPaint suppresses flicker under GTK
|
||||||
#endif // wxGTK
|
#endif // wxGTK
|
||||||
@@ -429,7 +417,10 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
// pressed. OnKeyUp() cannot catch all Shift-Up events.
|
// pressed. OnKeyUp() cannot catch all Shift-Up events.
|
||||||
if(!event.ShiftDown())
|
if(!event.ShiftDown())
|
||||||
m_Selecting = false;
|
m_Selecting = false;
|
||||||
|
|
||||||
|
// If we deleted the selection here, we must not execute the
|
||||||
|
// deletion in Delete/Backspace handling.
|
||||||
|
bool deletedSelection = false;
|
||||||
// pressing any non-arrow key optionally replaces the selection:
|
// pressing any non-arrow key optionally replaces the selection:
|
||||||
if(m_AutoDeleteSelection
|
if(m_AutoDeleteSelection
|
||||||
&& !m_Selecting
|
&& !m_Selecting
|
||||||
@@ -437,7 +428,10 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
&& ! IsDirectionKey(keyCode)
|
&& ! IsDirectionKey(keyCode)
|
||||||
&& ! (event.AltDown() || ctrlDown)
|
&& ! (event.AltDown() || ctrlDown)
|
||||||
)
|
)
|
||||||
|
{
|
||||||
m_llist->DeleteSelection();
|
m_llist->DeleteSelection();
|
||||||
|
deletedSelection = true;
|
||||||
|
}
|
||||||
|
|
||||||
// <Shift>+<arrow> starts selection
|
// <Shift>+<arrow> starts selection
|
||||||
if ( IsDirectionKey(keyCode) )
|
if ( IsDirectionKey(keyCode) )
|
||||||
@@ -521,7 +515,8 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
break;
|
break;
|
||||||
case WXK_DELETE :
|
case WXK_DELETE :
|
||||||
case 'd':
|
case 'd':
|
||||||
m_llist->Delete(1);
|
if(! deletedSelection) // already done
|
||||||
|
m_llist->Delete(1);
|
||||||
break;
|
break;
|
||||||
case 'y':
|
case 'y':
|
||||||
m_llist->DeleteLines(1);
|
m_llist->DeleteLines(1);
|
||||||
@@ -576,11 +571,13 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
if(event.ShiftDown())
|
if(event.ShiftDown())
|
||||||
Cut();
|
Cut();
|
||||||
else
|
else
|
||||||
m_llist->Delete(1);
|
if(! deletedSelection)
|
||||||
|
m_llist->Delete(1);
|
||||||
break;
|
break;
|
||||||
case WXK_BACK: // backspace
|
case WXK_BACK: // backspace
|
||||||
if(m_llist->MoveCursorHorizontally(-1))
|
if(! deletedSelection)
|
||||||
m_llist->Delete(1);
|
if(m_llist->MoveCursorHorizontally(-1))
|
||||||
|
m_llist->Delete(1);
|
||||||
break;
|
break;
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
if(m_WrapMargin > 0)
|
if(m_WrapMargin > 0)
|
||||||
@@ -963,7 +960,7 @@ wxLayoutWindow::Paste(bool primary)
|
|||||||
wxTheClipboard->GetData(&wxldo);
|
wxTheClipboard->GetData(&wxldo);
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//FIXME: missing functionality m_llist->Insert(wxldo.GetList());
|
//FIXME: missing functionality m_llist->Insert(wxldo.GetList());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user