Пример #1
0
void wxComboBox::Replace(
  long                              lFrom
, long                              lTo
, const wxString&                   rsValue
)
{
#if wxUSE_CLIPBOARD
    HWND                            hWnd = GetHwnd();

    //
    // Set selection and remove it
    //
    ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
    ::WinSendMsg(hWnd, EM_CUT, (MPARAM)0, (MPARAM)0);

    //
    // Now replace with 'value', by pasting.
    //
    wxSetClipboardData( wxDF_TEXT
                       ,(wxObject *)rsValue.c_str()
                       ,0
                       ,0
                      );

    //
    // Paste into edit control
    //
    ::WinSendMsg(hWnd, EM_PASTE, (MPARAM)0, (MPARAM)0L);
#endif
} // end of wxComboBox::Replace
Пример #2
0
void wxComboBox::Replace(long from, long to, const wxString& value)
{
#if wxUSE_CLIPBOARD
    Remove(from, to);

    // Now replace with 'value', by pasting.
    wxSetClipboardData(wxDF_TEXT, (wxObject *)(const wxChar *)value, 0, 0);

    // Paste into edit control
    SendMessage(GetHwnd(), WM_PASTE, (WPARAM)0, (LPARAM)0L);
#else
    wxUnusedVar(from);
    wxUnusedVar(to);
    wxUnusedVar(value);
#endif
}
Пример #3
0
bool wxMetafile::SetClipboard(int width, int height)
{
#if !wxUSE_CLIPBOARD
    wxUnusedVar(width);
    wxUnusedVar(height);
    return false;
#else
    if (!m_refData)
        return false;

    bool alreadyOpen=wxClipboardOpen();
    if (!alreadyOpen)
    {
        wxOpenClipboard();
        if (!wxEmptyClipboard()) return false;
    }
    bool success = wxSetClipboardData(wxDF_METAFILE, this, width,height);
    if (!alreadyOpen) wxCloseClipboard();
    return (bool) success;
#endif
}
Пример #4
0
void wxTextCtrl::Replace( long lFrom,
                          long lTo,
                          const wxString& rsValue )
{
#if wxUSE_CLIPBOARD
    HWND hWnd = GetHwnd();

    //
    // Set selection and remove it
    //
    if (m_bIsMLE)
    {
        ::WinSendMsg(hWnd, MLM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
        ::WinSendMsg(hWnd, MLM_CUT, 0, 0);
    }
    else
    {
        ::WinSendMsg(hWnd, EM_SETSEL, MPFROM2SHORT((USHORT)lFrom, (USHORT)lTo), 0);
        ::WinSendMsg(hWnd, EM_CUT, 0, 0);
    }

    //
    // Now replace with 'value', by pasting.
    //
    wxSetClipboardData(wxDF_TEXT, (wxObject *) (const wxChar *)rsValue, 0, 0);

    // Paste into edit control
    if (m_bIsMLE)
        ::WinSendMsg(hWnd, MLM_PASTE, (MPARAM)0, (MPARAM)0);
    else
        ::WinSendMsg(hWnd, EM_PASTE, (MPARAM)0, (MPARAM)0);
#else
    wxUnusedVar(lFrom);
    wxUnusedVar(lTo);
    wxUnusedVar(rsValue);
    wxFAIL_MSG("wxTextCtrl::Replace not implemented if wxUSE_CLIPBOARD is 0.");
#endif
}  // end of wxTextCtrl::Replace
Пример #5
0
bool wxClipboard::AddData( wxDataObject *data )
{
    wxCHECK_MSG( data, false, wxT("data is invalid") );

#if wxUSE_OLE_CLIPBOARD
    HRESULT hr = OleSetClipboard(data->GetInterface());
    if ( FAILED(hr) )
    {
        wxLogSysError(hr, _("Failed to put data on the clipboard"));

        // don't free anything in this case

        return false;
    }

    // we have a problem here because we should delete wxDataObject, but we
    // can't do it because IDataObject which we just gave to the clipboard
    // would try to use it when it will need the data. IDataObject is ref
    // counted and so doesn't suffer from such problem, so we release it now
    // and tell it to delete wxDataObject when it is deleted itself.
    data->SetAutoDelete();

    // we have to call either OleSetClipboard(NULL) or OleFlushClipboard() when
    // using OLE clipboard when the app terminates - by default, we call
    // OleSetClipboard(NULL) which won't waste RAM, but the app can call
    // wxClipboard::Flush() to chaneg this
    m_clearOnExit = true;

    return true;
#elif wxUSE_DATAOBJ
    wxCHECK_MSG( wxIsClipboardOpened(), false, wxT("clipboard not open") );

    wxDataFormat format = data->GetPreferredFormat();

    switch ( format )
    {
        case wxDF_TEXT:
        case wxDF_OEMTEXT:
        {
            wxTextDataObject* textDataObject = (wxTextDataObject*) data;
            wxString str(textDataObject->GetText());
            return wxSetClipboardData(format, str.c_str());
        }

        case wxDF_BITMAP:
        case wxDF_DIB:
        {
            wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
            wxBitmap bitmap(bitmapDataObject->GetBitmap());
            return wxSetClipboardData(data->GetPreferredFormat(), &bitmap);
        }

#if wxUSE_METAFILE
        case wxDF_METAFILE:
        {
#if 1
            // TODO
            wxLogError(wxT("Not implemented because wxMetafileDataObject does not contain width and height values."));
            return false;
#else
            wxMetafileDataObject* metaFileDataObject =
                (wxMetafileDataObject*) data;
            wxMetafile metaFile = metaFileDataObject->GetMetafile();
            return wxSetClipboardData(wxDF_METAFILE, &metaFile,
                                      metaFileDataObject->GetWidth(),
                                      metaFileDataObject->GetHeight());
#endif
        }
#endif // wxUSE_METAFILE

        default:
        {
// This didn't compile, of course
//            return wxSetClipboardData(data);
            // TODO
            wxLogError(wxT("Not implemented."));
            return false;
        }
    }
#else // !wxUSE_DATAOBJ
    return false;
#endif // wxUSE_DATAOBJ/!wxUSE_DATAOBJ
}