Removed wxNullRegion

Finalized wxClpboard


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1508 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-01-28 18:25:36 +00:00
parent 6085b116d6
commit 75ce058154
9 changed files with 204 additions and 140 deletions

View File

@@ -344,68 +344,74 @@ bool wxClipboard::Open()
return TRUE;
}
bool wxClipboard::SetData( wxDataBroker *data )
bool wxClipboard::SetData( wxDataObject *data )
{
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
wxCHECK_MSG( data, FALSE, "data is invalid" );
Clear();
m_dataBroker = data;
if (!m_dataBroker) return FALSE;
return AddData( data );
}
bool wxClipboard::AddData( wxDataObject *data )
{
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
wxNode *node = m_dataBroker->m_dataObjects.First();
while (node)
{
wxDataObject *dobj = (wxDataObject*)node->Data();
GdkAtom format = dobj->GetFormat().GetAtom();
if (format != (GdkAtom) 0)
{
/* This should happen automatically */
m_ownsClipboard = FALSE;
m_ownsPrimarySelection = FALSE;
wxCHECK_MSG( data, FALSE, "data is invalid" );
/* Add handlers if someone requests data */
/* if clipboard has been cleared before, create new data broker */
gtk_selection_add_handler( m_clipboardWidget,
if (!m_dataBroker) m_dataBroker = new wxDataBroker();
/* add new data to list of offered data objects */
m_dataBroker->Add( data );
/* get native format id of new data object */
GdkAtom format = data->GetFormat().GetAtom();
wxCHECK_MSG( format, FALSE, "data has invalid format" );
/* This should happen automatically, but to be on the safe side */
m_ownsClipboard = FALSE;
m_ownsPrimarySelection = FALSE;
/* Add handlers if someone requests data */
gtk_selection_add_handler( m_clipboardWidget,
g_clipboardAtom,
format,
selection_handler,
(gpointer) NULL );
gtk_selection_add_handler( m_clipboardWidget,
gtk_selection_add_handler( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
format,
selection_handler,
(gpointer) NULL );
/* Tell the world we offer clipboard data */
/* Tell the world we offer clipboard data */
if (!gtk_selection_owner_set( m_clipboardWidget,
if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
GDK_CURRENT_TIME ))
{
return FALSE;
}
m_ownsClipboard = TRUE;
{
return FALSE;
}
m_ownsClipboard = TRUE;
if (!gtk_selection_owner_set( m_clipboardWidget,
if (!gtk_selection_owner_set( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME ))
{
return FALSE;
}
m_ownsPrimarySelection = TRUE;
}
node = node->Next();
{
return FALSE;
}
m_ownsPrimarySelection = TRUE;
return TRUE;
}
@@ -416,22 +422,16 @@ void wxClipboard::Close()
m_open = FALSE;
}
bool wxClipboard::GetData( wxDataObject *data )
bool wxClipboard::IsSupported( wxDataObject &data )
{
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
m_receivedData = data;
/* store requested format to be asked for by callbacks */
wxCHECK_MSG( m_receivedData, FALSE, "invalid data object" );
/* STEP ONE: check if there is such data in the clipboard */
m_targetRequested = data->GetFormat().GetAtom();
m_targetRequested = data.GetFormat().GetAtom();
wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
if (m_targetRequested == 0) return FALSE;
/* add handler for target (= format) query */
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
@@ -454,8 +454,29 @@ bool wxClipboard::GetData( wxDataObject *data )
(gpointer) this );
if (!m_formatSupported) return FALSE;
return TRUE;
}
bool wxClipboard::GetData( wxDataObject &data )
{
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
/* is data supported by clipboard ? */
if (!IsSupported( data )) return FALSE;
/* store pointer to data object to be filled up by callbacks */
m_receivedData = &data;
/* store requested format to be asked for by callbacks */
m_targetRequested = data.GetFormat().GetAtom();
/* STEP TWO: get the data from the clipboard */
wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
/* start query */
m_formatSupported = FALSE;
@@ -464,6 +485,8 @@ bool wxClipboard::GetData( wxDataObject *data )
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
/* ask for clipboard contents */
gtk_selection_convert( m_clipboardWidget,
g_clipboardAtom,
m_targetRequested,