예제 #1
0
bool wxGetClipboardFormatName(const wxDataFormat& dataFormat, char *formatName,
                              int maxCount)
{
    wxStrlcpy( formatName, dataFormat.GetId().c_str(), maxCount );

    return true;
}
예제 #2
0
bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
{
    wxLogTrace(TRACE_CLIPBOARD, wxT("Checking if format %s is available"),
               dataFormat.GetId().c_str());

    if ( m_data )
        return m_data->IsSupported( dataFormat );
    return wxDataObject::IsFormatInPasteboard( m_pasteboard, dataFormat );
}
예제 #3
0
void wxClipboard::GTKOnSelectionReceived(const GtkSelectionData& sel)
{
    wxCHECK_RET( m_receivedData, wxT("should be inside GetData()") );

    const wxDataFormat format(gtk_selection_data_get_target(const_cast<GtkSelectionData*>(&sel)));
    wxLogTrace(TRACE_CLIPBOARD, wxT("Received selection %s"),
               format.GetId().c_str());

    if ( !m_receivedData->IsSupportedFormat(format, wxDataObject::Set) )
        return;

    m_receivedData->SetData(format,
        gtk_selection_data_get_length(const_cast<GtkSelectionData*>(&sel)),
        gtk_selection_data_get_data(const_cast<GtkSelectionData*>(&sel)));
    m_formatSupported = true;
}
예제 #4
0
bool wxClipboard::IsSupported( const wxDataFormat& format )
{
    /* reentrance problems */
    if (m_waiting) return FALSE;

    /* store requested format to be asked for by callbacks */
    m_targetRequested = format;

    wxLogTrace( TRACE_CLIPBOARD,
                wxT("wxClipboard:IsSupported: requested format: %s"),
                format.GetId().c_str() );

    wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") );

    m_formatSupported = FALSE;

    /* perform query. this will set m_formatSupported to
       TRUE if m_targetRequested is supported.
       also, we have to wait for the "answer" from the
       clipboard owner which is an asynchronous process.
       therefore we set m_waiting = TRUE here and wait
       until the callback "targets_selection_received"
       sets it to FALSE */

    m_waiting = TRUE;

    gtk_selection_convert( m_targetsWidget,
                           m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY
                                        : g_clipboardAtom,
                           g_targetsAtom,
                           (guint32) GDK_CURRENT_TIME );

    while (m_waiting) gtk_main_iteration();

#if defined(__WXGTK20__) && wxUSE_UNICODE
    if (!m_formatSupported && format == wxDataFormat(wxDF_UNICODETEXT))
    {
        // Another try with plain STRING format
        extern GdkAtom g_altTextAtom;
        return IsSupported(g_altTextAtom);
    }
#endif

    return m_formatSupported;
}
예제 #5
0
bool wxClipboard::IsSupported(const wxDataFormat& format)
{
    Display* xdisplay = wxGlobalDisplay();
    Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelRealizedWidget() );
    bool isSupported = false;
    int retval, count;
    unsigned long  max_name_length;
    wxString id = format.GetId();

    while( ( retval = XmClipboardLock( xdisplay, xwindow ) )
            == XmClipboardLocked );
    if( retval != XmClipboardSuccess )
        return false;

    if( XmClipboardInquireCount( xdisplay, xwindow, &count, &max_name_length )
            == XmClipboardSuccess )
    {
        wxCharBuffer buf( max_name_length + 1 );
        unsigned long copied;

        for( int i = 0; i < count; ++i )
        {
            if( XmClipboardInquireFormat( xdisplay, xwindow, i + 1,
                                          (XtPointer)buf.data(),
                                          max_name_length, &copied )
                    != XmClipboardSuccess )
                continue;

            buf.data()[copied] = '\0';

            if( buf == id )
            {
                isSupported = true;
                break;
            }
        }
    }

    XmClipboardUnlock( xdisplay, xwindow, False );

    return isSupported;
}
예제 #6
0
bool wxClipboard::IsSupported( const wxDataFormat& format )
{
    /* reentrance problems */
    if (m_waiting) return false;

    /* store requested format to be asked for by callbacks */
    m_targetRequested = format;

#if 0
    wxLogTrace( TRACE_CLIPBOARD,
                wxT("wxClipboard:IsSupported: requested format: %s"),
                format.GetId().c_str() );
#endif

    wxCHECK_MSG( m_targetRequested, false, wxT("invalid clipboard format") );

    m_formatSupported = false;

    /* perform query. this will set m_formatSupported to
       true if m_targetRequested is supported.
       also, we have to wait for the "answer" from the
       clipboard owner which is an asynchronous process.
       therefore we set m_waiting = true here and wait
       until the callback "targets_selection_received"
       sets it to false */

    m_waiting = true;

#if 0
    gtk_selection_convert( m_targetsWidget,
                           m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY
                                        : g_clipboardAtom,
                           g_targetsAtom,
                           (guint32) GDK_CURRENT_TIME );

    while (m_waiting) gtk_main_iteration();
#endif

    if (!m_formatSupported) return false;

    return true;
}
예제 #7
0
bool wxClipboard::DoIsSupported(const wxDataFormat& format)
{
    wxCHECK_MSG( format, false, wxT("invalid clipboard format") );

    wxLogTrace(TRACE_CLIPBOARD, wxT("Checking if format %s is available"),
               format.GetId().c_str());

    // these variables will be used by our GTKOnTargetReceived()
    m_targetRequested = format;
    m_formatSupported = false;

    // block until m_formatSupported is set from targets_selection_received
    // callback
    {
        wxClipboardSync sync(*this);

        gtk_selection_convert( m_targetsWidget,
                               GTKGetClipboardAtom(),
                               g_targetsAtom,
                               (guint32) GDK_CURRENT_TIME );
    }

    return m_formatSupported;
}