private dataformat almost working - minor fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1568,6 +1568,18 @@ wxLayoutList::InternalClear(void)
|
|||||||
m_CursorStyleInfo = m_DefaultStyleInfo;
|
m_CursorStyleInfo = m_DefaultStyleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wxLayoutList::Read(wxString &istr)
|
||||||
|
{
|
||||||
|
while(istr.Length())
|
||||||
|
{
|
||||||
|
wxLayoutObject *obj = wxLayoutObject::Read(istr);
|
||||||
|
if(obj)
|
||||||
|
Insert(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wxLayoutList::SetFont(int family, int size, int style, int weight,
|
wxLayoutList::SetFont(int family, int size, int style, int weight,
|
||||||
int underline, wxColour *fg,
|
int underline, wxColour *fg,
|
||||||
@@ -2352,15 +2364,10 @@ wxLayoutList::Draw(wxDC &dc,
|
|||||||
}
|
}
|
||||||
InvalidateUpdateRect();
|
InvalidateUpdateRect();
|
||||||
|
|
||||||
#ifdef DEBUG
|
WXLO_DEBUG(("Selection is %s : l%d,%ld/%ld,%ld",
|
||||||
if ( m_Selection.m_valid )
|
m_Selection.m_valid ? "valid" : "invalid",
|
||||||
{
|
m_Selection.m_CursorA.x, m_Selection.m_CursorA.y,
|
||||||
WXLO_DEBUG(("Selection is %s : %ld,%ld/%ld,%ld",
|
m_Selection.m_CursorB.x, m_Selection.m_CursorB.y));
|
||||||
m_Selection.m_valid ? "valid" : "invalid",
|
|
||||||
m_Selection.m_CursorA.x, m_Selection.m_CursorA.y,
|
|
||||||
m_Selection.m_CursorB.x, m_Selection.m_CursorB.y));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLayoutObject *
|
wxLayoutObject *
|
||||||
@@ -2860,7 +2867,6 @@ wxLayoutList::GetSelection(wxLayoutDataObject *wxlo, bool invalidate)
|
|||||||
exp->content.object->Write(string);
|
exp->content.object->Write(string);
|
||||||
delete exp;
|
delete exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxlo->SetLayoutData(string);
|
wxlo->SetLayoutData(string);
|
||||||
}
|
}
|
||||||
return llist;
|
return llist;
|
||||||
|
@@ -1140,6 +1140,12 @@ public:
|
|||||||
|
|
||||||
/// get the line by number
|
/// get the line by number
|
||||||
wxLayoutLine *GetLine(CoordType index) const;
|
wxLayoutLine *GetLine(CoordType index) const;
|
||||||
|
|
||||||
|
/** Reads objects from a string and inserts them.
|
||||||
|
@param istr stream to read from, will bee changed
|
||||||
|
*/
|
||||||
|
void Read(wxString &istr);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Clear the list.
|
/// Clear the list.
|
||||||
void InternalClear(void);
|
void InternalClear(void);
|
||||||
|
@@ -88,7 +88,7 @@ static const int Y_SCROLL_PAGE = 20;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 1
|
#define wxUSE_PRIVATE_CLIPBOARD_FORMAT 0
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// event tables
|
// event tables
|
||||||
@@ -496,20 +496,17 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
if ( IsDirectionKey(keyCode) )
|
if ( IsDirectionKey(keyCode) )
|
||||||
{
|
{
|
||||||
// just continue the old selection
|
// just continue the old selection
|
||||||
if ( m_Selecting )
|
if ( m_Selecting && event.ShiftDown() )
|
||||||
{
|
|
||||||
if( event.ShiftDown() )
|
|
||||||
m_llist->ContinueSelection();
|
m_llist->ContinueSelection();
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_llist->DiscardSelection();
|
|
||||||
m_Selecting = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( event.ShiftDown() )
|
|
||||||
{
|
{
|
||||||
m_Selecting = true;
|
m_llist->DiscardSelection();
|
||||||
m_llist->StartSelection();
|
m_Selecting = false;
|
||||||
|
if( event.ShiftDown() )
|
||||||
|
{
|
||||||
|
m_Selecting = true;
|
||||||
|
m_llist->StartSelection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,8 +628,12 @@ wxLayoutWindow::OnChar(wxKeyEvent& event)
|
|||||||
m_llist->DeleteToEndOfLine();
|
m_llist->DeleteToEndOfLine();
|
||||||
SetDirty();
|
SetDirty();
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
Copy();
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
Paste();
|
// if SHIFT is down, use primary selection
|
||||||
|
Paste( event.ShiftDown() );
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
Cut();
|
Cut();
|
||||||
@@ -1079,11 +1080,14 @@ wxLayoutWindow::Paste(bool primary)
|
|||||||
{
|
{
|
||||||
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
|
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
|
||||||
wxLayoutDataObject wxldo;
|
wxLayoutDataObject wxldo;
|
||||||
if ( wxTheClipboard->GetData(wxldo) )
|
if (wxTheClipboard->IsSupported( wxldo.GetFormat() ))
|
||||||
{
|
{
|
||||||
//FIXME: missing functionality m_llist->Insert(wxldo.GetList());
|
if(wxTheClipboard->GetData(wxldo))
|
||||||
wxLayoutImportText(m_llist, wxldo.GetLayoutData());
|
{
|
||||||
SetDirty();
|
wxString str = wxldo.GetLayoutData();
|
||||||
|
m_llist->Read(str);
|
||||||
|
RequestUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
@@ -1112,20 +1116,10 @@ wxLayoutWindow::Copy(bool invalidate)
|
|||||||
m_llist->EndSelection();
|
m_llist->EndSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
|
|
||||||
// the data object which holds all different data objects, one for each
|
|
||||||
// format we support
|
|
||||||
wxDataObjectComposite *data = new wxDataObjectComposite;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxLayoutDataObject *wldo = new wxLayoutDataObject;
|
wxLayoutDataObject *wldo = new wxLayoutDataObject;
|
||||||
wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate);
|
wxLayoutList *llist = m_llist->GetSelection(wldo, invalidate);
|
||||||
if(! llist)
|
if(! llist)
|
||||||
{
|
|
||||||
delete wldo;
|
|
||||||
delete data;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
// Export selection as text:
|
// Export selection as text:
|
||||||
wxString text;
|
wxString text;
|
||||||
wxLayoutExportObject *exp;
|
wxLayoutExportObject *exp;
|
||||||
@@ -1138,7 +1132,6 @@ wxLayoutWindow::Copy(bool invalidate)
|
|||||||
}
|
}
|
||||||
delete llist;
|
delete llist;
|
||||||
|
|
||||||
bool rc;
|
|
||||||
// The exporter always appends a newline, so we chop it off if it
|
// The exporter always appends a newline, so we chop it off if it
|
||||||
// is there:
|
// is there:
|
||||||
{
|
{
|
||||||
@@ -1151,19 +1144,20 @@ wxLayoutWindow::Copy(bool invalidate)
|
|||||||
|
|
||||||
if (wxTheClipboard->Open())
|
if (wxTheClipboard->Open())
|
||||||
{
|
{
|
||||||
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
|
wxTextDataObject *data = new wxTextDataObject( text );
|
||||||
data->Add(wldo, TRUE /* preferred */);
|
bool rc;
|
||||||
data->Add(new wxTextDataObject(text));
|
|
||||||
#endif
|
|
||||||
rc = wxTheClipboard->SetData( data );
|
rc = wxTheClipboard->SetData( data );
|
||||||
|
#if wxUSE_PRIVATE_CLIPBOARD_FORMAT
|
||||||
|
rc |= wxTheClipboard->SetData( wldo );
|
||||||
|
#endif
|
||||||
wxTheClipboard->Close();
|
wxTheClipboard->Close();
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rc = FALSE;
|
delete wldo;
|
||||||
|
|
||||||
delete wldo;
|
return FALSE;
|
||||||
delete data;
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
Reference in New Issue
Block a user