wxHSCROLL | wxVSCROLL | wxBORDER)
{
+ SetStatusBar(NULL); // don't use statusbar
m_Editable = false;
m_doSendEvents = false;
m_ViewStartX = 0; m_ViewStartY = 0;
EnableScrolling(true,true);
m_maxx = max.x; m_maxy = max.y;
m_Selecting = false;
+ SetCursorVisibility(-1);
SetCursor(wxCURSOR_IBEAM);
SetDirty();
}
bool found;
wxLayoutObject *obj = m_llist->FindObjectScreen(dc, findPos,
&cursorPos, &found);
+ wxLayoutObject::UserData *u = obj ? obj->GetUserData() : NULL;
//has the mouse only been moved?
if(eventId == WXLOWIN_MENU_MOUSEMOVE)
{
// found is only true if we are really over an object, not just
// behind it
- if(found && obj && obj->GetUserData() != NULL)
+ if(found && u && ! m_Selecting)
{
if(!m_HandCursor)
SetCursor(wxCURSOR_HAND);
m_HandCursor = TRUE;
+ if(m_StatusBar && m_StatusFieldLabel != -1)
+ {
+ const wxString &label = u->GetLabel();
+ if(label.Length())
+ m_StatusBar->SetStatusText(label,
+ m_StatusFieldLabel);
+ }
}
else
{
if(m_HandCursor)
SetCursor(wxCURSOR_IBEAM);
m_HandCursor = FALSE;
+ if(m_StatusBar && m_StatusFieldLabel != -1)
+ m_StatusBar->SetStatusText("", m_StatusFieldLabel);
}
+ if(event.LeftIsDown())
+ {
+ if(! m_Selecting)
+ {
+ m_llist->StartSelection();
+ m_Selecting = true;
+ DoPaint(FALSE);
+ }
+ else
+ {
+ m_llist->ContinueSelection(cursorPos);
+ DoPaint(FALSE);
+ }
+ }
+ if(m_Selecting && ! event.LeftIsDown())
+ {
+ m_llist->EndSelection(cursorPos);
+ m_Selecting = false;
+ DoPaint(FALSE);
+ }
+ if(u) u->DecRef();
return;
}
if(obj && eventId == WXLOWIN_MENU_LCLICK)
{
m_llist->MoveCursorTo(cursorPos);
+ if(m_CursorVisibility == -1)
+ m_CursorVisibility = 1;
ScrollToCursor();
- Refresh(FALSE); // DoPaint suppresses flicker under GTK
+ DoPaint(FALSE); // DoPaint suppresses flicker under GTK
}
+
if(!m_doSendEvents) // nothing to do
+ {
+ if(u) u->DecRef();
return;
+ }
// only do the menu if activated, editable and not on a clickable object
if(eventId == WXLOWIN_MENU_RCLICK
&& IsEditable()
- && (! obj || (obj && obj->GetUserData() == NULL))
- )
+ && (! obj || u == NULL))
{
PopupMenu(m_PopupMenu, m_ClickPosition.x, m_ClickPosition.y);
+ if(u) u->DecRef();
return;
}
+
+ if(u) u->DecRef();
// find the object at this position
if(obj)
{
}
}
+ // If needed, make cursor visible:
+ if(m_CursorVisibility == -1)
+ m_CursorVisibility = 1;
+
/* These two nested switches work like this:
The first one processes all non-editing keycodes, to move the
cursor, etc. It's default will process all keycodes causing
{
switch(keyCode)
{
+ case WXK_INSERT:
+ Copy();
+ break;
case WXK_DELETE :
case 'd':
m_llist->Delete(1);
case 'v':
Paste();
break;
+ case 'c':
+ Copy();
+ break;
+ case 'x':
+ Cut();
+ break;
#ifdef WXLAYOUT_DEBUG
case WXK_F1:
m_llist->SetFont(-1,-1,-1,-1,true); // underlined
Paste();
break;
case WXK_DELETE :
- m_llist->Delete(1);
+ if(event.ShiftDown())
+ Cut();
+ else
+ m_llist->Delete(1);
break;
case WXK_BACK: // backspace
if(m_llist->MoveCursorHorizontally(-1)) m_llist->Delete(1);
wxLayoutWindow::OnKeyUp(wxKeyEvent& event)
{
if(event.KeyCode() == WXK_SHIFT && m_llist->IsSelecting())
+ {
m_llist->EndSelection();
+ m_Selecting = false;
+ }
event.Skip();
}
if(x1 > m_maxx) m_maxx = x1;
if(y1 > m_maxy) m_maxy = y1;
- WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
- updateRect->x, updateRect->y,
- updateRect->x+updateRect->width,
- updateRect->y+updateRect->height));
+ if(updateRect)
+ {
+ WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y,
+ updateRect->x+updateRect->width,
+ updateRect->y+updateRect->height));
+ }
if(IsDirty())
{
m_llist->Layout(dc);
/* This is the important bit: we tell the list to draw itself: */
#if WXLO_DEBUG_URECT
- WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
- updateRect->x, updateRect->y,
- updateRect->x+updateRect->width,
- updateRect->y+updateRect->height));
+ if(updateRect)
+ {
+ WXLO_DEBUG(("Update rect: %ld,%ld / %ld,%ld",
+ updateRect->x, updateRect->y,
+ updateRect->x+updateRect->width,
+ updateRect->y+updateRect->height));
+ }
#endif
// Device origins on the memDC are suspect, we translate manually
// update rectangle (although they are drawn on the memDC, this is
// needed to erase it):
m_llist->InvalidateUpdateRect();
- m_llist->DrawCursor(*m_memDC,
- m_HaveFocus && IsEditable(), // draw a thick
- // cursor for editable windows with focus
- offset);
+ if(m_CursorVisibility == 1)
+ m_llist->DrawCursor(*m_memDC,
+ m_HaveFocus && IsEditable(), // draw a thick
+ // cursor for editable windows with focus
+ offset);
// Now copy everything to the screen:
#if 0
ResetDirty();
m_ScrollToCursor = false;
+ if(m_StatusBar && m_StatusFieldCursor != -1)
+ {
+ wxString label;
+ label.Printf(_("L:%d C:%d"), m_llist->GetCursorPos().x+1, m_llist->GetCursorPos().y+1);
+ m_StatusBar->SetStatusText(label, m_StatusFieldCursor);
+ }
}
// change the range and position of scrollbars
void
wxLayoutWindow::Paste(void)
{
- wxString text;
// Read some text
if (wxTheClipboard->Open())
{
- wxTextDataObject data;
- if (wxTheClipboard->IsSupported( data.GetFormat() ))
+#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
+ wxLayoutDataObject wxldo;
+ if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
{
- wxTheClipboard->GetData(&data);
- text += data.GetText();
+ wxTheClipboard->GetData(&wxldo);
+ {
+ }
+ //FIXME: missing functionality m_llist->Insert(wxldo.GetList());
}
+ else
+#endif
+ {
+ wxTextDataObject data;
+ if (wxTheClipboard->IsSupported( data.GetFormat() ))
+ {
+ wxTheClipboard->GetData(&data);
+ wxString text = data.GetText();
+ wxLayoutImportText( m_llist, text);
+ }
+ }
wxTheClipboard->Close();
}
#if 0
text += tmp_tctrl.GetValue();
}
#endif
- wxLayoutImportText( m_llist, text);
}
bool
-wxLayoutWindow::Copy(void)
+wxLayoutWindow::Copy(bool invalidate)
{
// Calling GetSelection() will automatically do an EndSelection()
// on the list, but we need to take a note of it, too:
m_Selecting = false;
m_llist->EndSelection();
}
- wxLayoutList *llist = m_llist->GetSelection();
+
+ wxLayoutDataObject wldo;
+ wxLayoutList *llist = m_llist->GetSelection(&wldo, invalidate);
if(! llist)
return FALSE;
-
+ // Export selection as text:
wxString text;
wxLayoutExportObject *export;
wxLayoutExportStatus status(llist);
text = text.Mid(0,len-1);
}
- // Read some text
+
if (wxTheClipboard->Open())
{
wxTextDataObject *data = new wxTextDataObject( text );
bool rc = wxTheClipboard->SetData( data );
+#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
+ rc |= wxTheClipboard->AddData( &wldo );
+#endif
wxTheClipboard->Close();
return rc;
}
bool
wxLayoutWindow::Cut(void)
{
- if(Copy())
+ if(Copy(false)) // do not invalidate selection after copy
{
m_llist->DeleteSelection();
return TRUE;