Пример #1
0
Emfout::Emfout(Configuration **configuration, wxString filename)
{
  m_width = m_height = -1;
  m_configuration = configuration;
  m_oldconfig = *m_configuration;
  m_tree = NULL;
  m_emfFormat = wxDataFormat(wxT("image/x-emf"));

  m_filename = filename;
  if (m_filename == wxEmptyString)
    m_filename = wxFileName::CreateTempFileName(wxT("wxmaxima_"));

  m_dc = NULL;

  wxString m_tempFileName = wxFileName::CreateTempFileName(wxT("wxmaxima_size_"));
  m_recalculationDc = new wxEnhMetaFileDC(m_tempFileName,3000,50000);
  *m_configuration = new Configuration(*m_recalculationDc);
  (*m_configuration)->ShowCodeCells(m_oldconfig->ShowCodeCells());
  (*m_configuration)->SetClientWidth(3000);
  (*m_configuration)->SetZoomFactor_temporarily(1);
  // The last time I tried it the vertical positioning of the elements
  // of a big unicode parenthesis wasn't accurate enough in emf to be
  // usable. Also the probability was high that the right font wasn't
  // available in inkscape.
  (*m_configuration)->SetGrouphesisDrawMode(Configuration::handdrawn);
  (*m_configuration)->ClipToDrawRegion(false);
  (*m_configuration)->RecalculationForce(true);
}
Пример #2
0
void
Shader::OnTimer(wxTimerEvent& evt)
{
	wxString title = wxT("FragmentShader - ");
	if (m_FileName.IsEmpty())
	{
		title.Append(wxT("(untitled)"));
	}
	else
	{
		title.append(wxFileName::FileName(m_FileName).GetFullName());
	}
	if (Project::GetProject() != 0)
	{
		m_MenuBar->Enable(wxID_SAVEAS, true);
		m_MenuBar->Enable(wxID_SAVE, true);
	}
	else
	{
		m_MenuBar->Enable(wxID_SAVEAS, false);
		m_MenuBar->Enable(wxID_SAVE, false);
	}
	SetTitle(title);
	m_MenuBar->Enable(wxID_PASTE, wxTheClipboard->IsSupported(wxDataFormat(wxDF_TEXT)));
}
Пример #3
0
static void
selection_handler( GtkWidget *WXUNUSED(widget),
                   GtkSelectionData *selection_data,
                   guint WXUNUSED(info),
                   guint WXUNUSED(time),
                   gpointer WXUNUSED(data) )
{
    if (!wxTheClipboard) return;

    if (!wxTheClipboard->m_data) return;

    wxDataObject *data = wxTheClipboard->m_data;

    wxDataFormat format( selection_data->target );

#ifdef __WXDEBUG__
    wxLogTrace(TRACE_CLIPBOARD,
               _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s"),
               format.GetId().c_str(),
               wxString::FromAscii(gdk_atom_name(selection_data->target)).c_str(),
               wxString::FromAscii(gdk_atom_name(selection_data->type)).c_str(),
               wxString::FromAscii(gdk_atom_name(selection_data->selection)).c_str()
               );
#endif
    
    if (!data->IsSupportedFormat( format )) return;

    int size = data->GetDataSize( format );

    if (size == 0) return;

    void *d = malloc(size);

    // Text data will be in UTF8 in Unicode mode.
    data->GetDataHere( selection_data->target, d );

#ifdef __WXGTK20__
    // NB: GTK+ requires special treatment of UTF8_STRING data, the text
    //     would show as UTF-8 data interpreted as latin1 (?) in other
    //     GTK+ apps if we used gtk_selection_data_set()
    if (format == wxDataFormat(wxDF_UNICODETEXT))
    {
        gtk_selection_data_set_text(
            selection_data,
            (const gchar*)d,
            size-1 );
    }
    else
#endif
    {
        gtk_selection_data_set(
            selection_data,
            GDK_SELECTION_TYPE_STRING,
            8*sizeof(gchar),
            (unsigned char*) d,
            size-1 );
    }

    free(d);
}
Пример #4
0
void wxBitmapDataObject::GetAllFormats(wxDataFormat *formats,
                               wxDataObjectBase::Direction WXUNUSED(dir) ) const
{
    *formats++ = wxDataFormat( wxDF_BITMAP );
#if wxMAC_USE_CORE_GRAPHICS
    *formats = s_pict;
#endif
}
Пример #5
0
CRemoteDataObject::CRemoteDataObject(const CServer& server, const CServerPath& path)
	: wxDataObjectSimple(wxDataFormat(_T("FileZilla3RemoteDataObject")))
	, m_server(server)
	, m_path(path)
	, m_didSendData()
	, m_processId(wxGetProcessId())
{
}
bool ObjectDataObject::GetDataHere(const wxDataFormat& format, void *buf) const{
  if (format == wxDataFormat("FaintObject")){
    // Shallow copy - the deep copy is done in SetData, which is
    // called behind the scenes
    memcpy(buf, &(*begin(m_objects)), sizeof(Object*) * m_objects.size());
    return true;
  }
  return false;
}
Пример #7
0
bool wxDropTarget::CurrentDragHasSupportedFormat()
{
    bool supported = false;

    if ( gTrackingGlobals.m_currentSource != NULL )
    {
        wxDataObject* data = gTrackingGlobals.m_currentSource->GetDataObject();

        if ( data )
        {
            size_t formatcount = data->GetFormatCount();
            wxDataFormat *array = new wxDataFormat[formatcount];
            data->GetAllFormats( array );
            for (size_t i = 0; !supported && i < formatcount; i++)
            {
                wxDataFormat format = array[i];
                if ( m_dataObject->IsSupported( format ) )
                {
                    supported = true;
                    break;
                }
            }

            delete [] array;
        }
    }

    if ( !supported )
    {
        UInt16 items;
        ItemReference theItem;
        FlavorType theType;
        UInt16 flavors = 0;

        CountDragItems( (DragReference)m_currentDrag, &items );
        for (UInt16 index = 1; index <= items && !supported; ++index)
        {
            flavors = 0;
            GetDragItemReferenceNumber( (DragReference)m_currentDrag, index, &theItem );
            CountDragItemFlavors( (DragReference)m_currentDrag, theItem, &flavors );

            for ( UInt16 flavor = 1; flavor <= flavors; ++flavor )
            {
                GetFlavorType( (DragReference)m_currentDrag, theItem, flavor, &theType );
                if ( m_dataObject->IsSupportedFormat( wxDataFormat( theType ) ) )
                {
                    supported = true;
                    break;
                }
            }
        }
    }

    return supported;
}
Пример #8
0
void wxGxContentView::OnBeginDrag(wxListEvent& event)
{
    //TODO: wxDELETE(pDragData) somethere
    wxDataObjectComposite *pDragData = new wxDataObjectComposite();

    wxGISStringDataObject *pNamesData = new wxGISStringDataObject(wxDataFormat(wxGIS_DND_NAME));
    pDragData->Add(pNamesData, true);

    wxFileDataObject *pFileData = new wxFileDataObject();
    pDragData->Add(pFileData, false);

    //wxGISDecimalDataObject *pIDsData = new wxGISDecimalDataObject(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-id")));
    //pDragData->Add(pIDsData, false);


    //TODO: create dataobject for QGIS
//        wxDataObjectSimple* pDataObjectSimple = new wxDataObjectSimple(wxDataFormat(wxT("application/x-vnd.qgis.qgis.uri")));
//        my_data->Add(pDataObjectSimple);
//
//        wxMemoryOutputStream *pstream = new wxMemoryOutputStream();
//        wxDataOutputStream dostr(*pstream);
//


    long nItem = wxNOT_FOUND;
    int nCount(0);
    for ( ;; )
    {
        nItem = GetNextItem(nItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if ( nItem == wxNOT_FOUND )
            break;

        LPITEMDATA pItemData = (LPITEMDATA)GetItemData(nItem);
	    if(pItemData == NULL)
            continue;

        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pItemData->nObjectID);
	    if(pGxObject == NULL)
            continue;
        wxString sSystemPath(pGxObject->GetPath(), wxConvUTF8);

        pFileData->AddFile(sSystemPath);
        pNamesData->AddString(pGxObject->GetFullName());
        //pIDsData->AddDecimal(pGxObject->GetId());
    }

    wxDropSource dragSource( this );
	dragSource.SetData( *pDragData );
	wxDragResult result = dragSource.DoDragDrop( wxDrag_DefaultMove );
}
bool ObjectDataObject::SetData(const wxDataFormat& format, size_t len,
  const void* buf)
{
  if (format != wxDataFormat("FaintObject")){
    return false;
  }

  // Fixme: Need a proper serialized object format.
  delete_objects(m_objects);
  Object** objects = new Object*[len / sizeof(Object*)];
  memcpy(objects, buf, len);
  for (size_t i = 0; i !=  len / sizeof(Object*); i++){
    m_objects.push_back(objects[i]->Clone());
  }
  delete[] objects;
  return true;
}
Пример #10
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;
}
Пример #11
0
wxPlotFunction wxClipboardGetPlotFunction()
{
    bool is_opened = wxTheClipboard->IsOpened();
    wxPlotFunction plotFunc;

    if (is_opened || wxTheClipboard->Open())
    {
        wxTextDataObject textDataObject;
        if (wxTheClipboard->IsSupported(wxDataFormat(wxDF_TEXT)) &&
            wxTheClipboard->GetData(textDataObject))
        {
            wxString str = textDataObject.GetText();
            plotFunc.Create(str.BeforeLast(wxT(';')), str.AfterLast(wxT(';')));
        }

        if (!is_opened)
            wxTheClipboard->Close();
    }

    return plotFunc;
}
Пример #12
0
void wxGISToolExecuteView::OnBeginDrag(wxListEvent& event)
{
    wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(m_nParentGxObjectId);
    if(!pGxObject)
        return;
    wxGISTaskDataObject DragData(wxThread::GetMainId(), wxDataFormat(wxGIS_DND_ID));


    long nItem = wxNOT_FOUND;
    int nCount(0);
    for ( ;; )
    {
        nItem = GetNextItem(nItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if ( nItem == wxNOT_FOUND )
            break;

        DragData.AddDecimal(GetItemData(nItem));
    }

    wxDropSource dragSource( this );
    dragSource.SetData( DragData );
    wxDragResult result = dragSource.DoDragDrop( wxDrag_DefaultMove );
}
Пример #13
0
CRemoteDataObject::CRemoteDataObject()
	: wxDataObjectSimple(wxDataFormat(_T("FileZilla3RemoteDataObject")))
{
	m_didSendData = false;
}
Пример #14
0
static void
selection_handler( GtkWidget *WXUNUSED(widget),
                   GtkSelectionData *selection_data,
                   guint WXUNUSED(info),
                   guint WXUNUSED(time),
                   gpointer signal_data )
{
    wxClipboard * const clipboard = wxTheClipboard;
    if ( !clipboard )
        return;

    wxDataObject * const data = clipboard->GTKGetDataObject(
        gtk_selection_data_get_selection(selection_data));
    if ( !data )
        return;

    // ICCCM says that TIMESTAMP is a required atom.
    // In particular, it satisfies Klipper, which polls
    // TIMESTAMP to see if the clipboards content has changed.
    // It shall return the time which was used to set the data.
    if (gtk_selection_data_get_target(selection_data) == g_timestampAtom)
    {
        guint timestamp = GPOINTER_TO_UINT (signal_data);
        gtk_selection_data_set(selection_data,
                               GDK_SELECTION_TYPE_INTEGER,
                               32,
                               (guchar*)&(timestamp),
                               sizeof(timestamp));
        wxLogTrace(TRACE_CLIPBOARD,
                   wxT("Clipboard TIMESTAMP requested, returning timestamp=%u"),
                   timestamp);
        return;
    }

    wxDataFormat format(gtk_selection_data_get_target(selection_data));

    wxLogTrace(TRACE_CLIPBOARD,
               wxT("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"),
               format.GetId().c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_target(selection_data)))).c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_data_type(selection_data)))).c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(gtk_selection_data_get_selection(selection_data)))).c_str(),
               GPOINTER_TO_UINT( signal_data )
               );

    if ( !data->IsSupportedFormat( format ) )
        return;

    int size = data->GetDataSize( format );
    if ( !size )
        return;

    wxCharBuffer buf(size - 1); // it adds 1 internally (for NUL)

    // text data must be returned in UTF8 if format is wxDF_UNICODETEXT
    if ( !data->GetDataHere(format, buf.data()) )
        return;

    // use UTF8_STRING format if requested in Unicode build but just plain
    // STRING one in ANSI or if explicitly asked in Unicode
#if wxUSE_UNICODE
    if (format == wxDataFormat(wxDF_UNICODETEXT))
    {
        gtk_selection_data_set_text(
            selection_data,
            (const gchar*)buf.data(),
            size );
    }
    else
#endif // wxUSE_UNICODE
    {
        gtk_selection_data_set(
            selection_data,
            format.GetFormatId(),
            8*sizeof(gchar),
            (const guchar*)buf.data(),
            size );
    }
}
void wxsItemResDataObject::GetAllFormats(wxDataFormat *formats, cb_unused Direction dir) const
{
    formats[0] = wxDataFormat(wxDF_TEXT);
    formats[1] = wxDataFormat(wxsDF_WIDGET);
}
Пример #16
0
void wxTextDataObject::GetAllFormats( wxDataFormat *formats, wxDataObjectBase::Direction dir ) const
{
    *formats++ = wxDataFormat( wxDF_TEXT );
    *formats = wxDataFormat( wxDF_UNICODETEXT );
}
Пример #17
0
void wxPageContainer::OnMouseMove(wxMouseEvent& event)
{
	if (!m_pagesInfoVec.empty() && IsShown())
	{
		const int xButtonStatus = m_nXButtonStatus;
		const int xTabButtonStatus = m_nTabXButtonStatus;
		const int rightButtonStatus = m_nRightButtonStatus;
		const int leftButtonStatus = m_nLeftButtonStatus;
		const int dropDownButtonStatus = m_nArrowDownButtonStatus;
		/// Patch (savePreviewId) ---- Ti-R ---- Enable to show next tab selected if user click
		const int savePreviewId = m_nTabPreviewId;

		long style = GetParent()->GetWindowStyleFlag();

		m_nXButtonStatus = wxFNB_BTN_NONE;
		m_nRightButtonStatus = wxFNB_BTN_NONE;
		m_nLeftButtonStatus = wxFNB_BTN_NONE;
		m_nTabXButtonStatus = wxFNB_BTN_NONE;
		m_nArrowDownButtonStatus = wxFNB_BTN_NONE;
		/// Patch (m_nTabStatus) ---- Ti-R ---- Enable to show next tab selected if user click
		m_nTabStatus = wxFNB_BTN_NONE;

		wxPageInfo pgInfo;
		int tabIdx;

		int where = HitTest(event.GetPosition(), pgInfo, tabIdx);
		switch ( where )
		{
		case wxFNB_X:
			if (event.LeftIsDown())
			{
				m_nXButtonStatus = (m_nLeftClickZone==wxFNB_X) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
			}
			else
			{
				m_nXButtonStatus = wxFNB_BTN_HOVER;
			}
			break;
		case wxFNB_DROP_DOWN_ARROW:
			if (event.LeftIsDown())
			{
				m_nArrowDownButtonStatus = (m_nLeftClickZone == wxFNB_DROP_DOWN_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
			}
			else
			{
				m_nArrowDownButtonStatus = wxFNB_BTN_HOVER;
			}
			break;
		case wxFNB_TAB_X:
			if (event.LeftIsDown())
			{
				m_nTabXButtonStatus = (m_nLeftClickZone==wxFNB_TAB_X) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
			}
			else
			{
				m_nTabXButtonStatus = wxFNB_BTN_HOVER;
			}
			break;
		case wxFNB_RIGHT_ARROW:
			if (event.LeftIsDown())
			{
				m_nRightButtonStatus = (m_nLeftClickZone==wxFNB_RIGHT_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
			}
			else
			{
				m_nRightButtonStatus = wxFNB_BTN_HOVER;
			}
			break;

		case wxFNB_LEFT_ARROW:
			if (event.LeftIsDown())
			{
				m_nLeftButtonStatus = (m_nLeftClickZone==wxFNB_LEFT_ARROW) ? wxFNB_BTN_PRESSED : wxFNB_BTN_NONE;
			}
			else
			{
				m_nLeftButtonStatus = wxFNB_BTN_HOVER;
			}
			break;

		case wxFNB_TAB:
			// Call virtual method for showing tooltip
			ShowTabTooltip(tabIdx);
			if(!GetEnabled((size_t)tabIdx))
			{
				// Set the cursor to be 'No-entry'
				::wxSetCursor(wxCURSOR_NO_ENTRY);
			}

#if wxUSE_DRAG_AND_DROP
			// Support for drag and drop
			if(event.Dragging() && !(style & wxFNB_NODRAG))
			{
				wxFNBDragInfo draginfo(this, tabIdx);
				wxFNBDragInfoDataObject dataobject(wxDataFormat(wxT("wxFNB")));
				dataobject.SetData(sizeof(wxFNBDragInfo), &draginfo);
				wxFNBDropSource dragSource(this);
				dragSource.SetData(dataobject);
				dragSource.DoDragDrop(wxDrag_DefaultMove);
			}
#endif // wxUSE_DRAG_AND_DROP

/// Patch ---- Ti-R ---- Enable to show next tab selected if user click
			if(style & wxFNB_PREVIEW_SELECT_TAB)
			{
				m_nTabStatus = wxFNB_BTN_HOVER;
				m_nTabPreviewId = tabIdx;
			}

			break;
		default:
			m_nTabXButtonStatus = wxFNB_BTN_NONE;
			break;
		}
		/// Patch (bRedrawTab) ---- Ti-R ---- Enable to show next tab selected if user click
		if(m_nTabStatus != wxFNB_BTN_HOVER)
			m_nTabPreviewId=-1;

		const bool bRedrawTab = (m_nTabPreviewId != savePreviewId);
		const bool bRedrawX = m_nXButtonStatus != xButtonStatus;
		const bool bRedrawDropArrow = m_nArrowDownButtonStatus != dropDownButtonStatus;
		const bool bRedrawRight = m_nRightButtonStatus != rightButtonStatus;
		const bool bRedrawLeft = m_nLeftButtonStatus != leftButtonStatus;
		const bool bRedrawTabX = m_nTabXButtonStatus != xTabButtonStatus;

		wxFNBRendererPtr render = wxFNBRendererMgrST::Get()->GetRenderer( GetParent()->GetWindowStyleFlag() );

		if (bRedrawTab || bRedrawX || bRedrawRight || bRedrawLeft || bRedrawTabX || bRedrawDropArrow)
		{
			wxClientDC dc(this);
			if (bRedrawTab)
			{
				Refresh();
			}
			if (bRedrawX)
			{
				render->DrawX(this, dc);
			}
			if (bRedrawLeft)
			{
				render->DrawLeftArrow(this, dc);
			}
			if (bRedrawRight)
			{
				render->DrawRightArrow(this, dc);
			}
			if (bRedrawTabX)
			{
				render->DrawTabX(this, dc, pgInfo.GetXRect(), tabIdx, m_nTabXButtonStatus);
			}
			if (bRedrawDropArrow)
			{
				render->DrawDropDownArrow(this, dc);
			}
		}
	}
	event.Skip();
}
Пример #18
0
bool wxGxTreeView::CanPaste()
{            
    wxClipboardLocker lockClip;
    return wxTheClipboard->IsSupported(wxDF_FILENAME) | wxTheClipboard->IsSupported(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-name")));
    //& wxTheClipboard->IsSupported(wxDF_TEXT); | wxDF_BITMAP | wxDF_TIFF | wxDF_DIB | wxDF_UNICODETEXT | wxDF_HTML
}
Пример #19
0
static void
selection_handler( GtkWidget *WXUNUSED(widget),
                   GtkSelectionData *selection_data,
                   guint WXUNUSED(info),
                   guint WXUNUSED(time),
                   gpointer signal_data )
{
    if (!wxTheClipboard) return;

    if (!wxTheClipboard->m_data) return;

    wxDataObject *data = wxTheClipboard->m_data;

    // ICCCM says that TIMESTAMP is a required atom.
    // In particular, it satisfies Klipper, which polls
    // TIMESTAMP to see if the clipboards content has changed.
    // It shall return the time which was used to set the data.
    if (selection_data->target == g_timestampAtom)
    {
        guint timestamp = GPOINTER_TO_UINT (signal_data);
        gtk_selection_data_set(selection_data,
                               GDK_SELECTION_TYPE_INTEGER,
                               32,
                               (guchar*)&(timestamp),
                               sizeof(timestamp));
        wxLogTrace(TRACE_CLIPBOARD,
                   _T("Clipboard TIMESTAMP requested, returning timestamp=%u"),
                   timestamp);
        return;
    }

    wxDataFormat format( selection_data->target );

#ifdef __WXDEBUG__
    wxLogTrace(TRACE_CLIPBOARD,
               _T("clipboard data in format %s, GtkSelectionData is target=%s type=%s selection=%s timestamp=%u"),
               format.GetId().c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->target))).c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->type))).c_str(),
               wxString::FromAscii(wxGtkString(gdk_atom_name(selection_data->selection))).c_str(),
               GPOINTER_TO_UINT( signal_data )
               );
#endif

    if (!data->IsSupportedFormat( format )) return;

    int size = data->GetDataSize( format );

    if (size == 0) return;

    void *d = malloc(size);

    // Text data will be in UTF8 in Unicode mode.
    data->GetDataHere( selection_data->target, d );

    // NB: GTK+ requires special treatment of UTF8_STRING data, the text
    //     would show as UTF-8 data interpreted as latin1 (?) in other
    //     GTK+ apps if we used gtk_selection_data_set()
    if (format == wxDataFormat(wxDF_UNICODETEXT))
    {
        gtk_selection_data_set_text(
            selection_data,
            (const gchar*)d,
            size );
    }
    else
    {
        gtk_selection_data_set(
            selection_data,
            GDK_SELECTION_TYPE_STRING,
            8*sizeof(gchar),
            (unsigned char*) d,
            size );
    }

    free(d);
}
Пример #20
0
bool wxDataObject::GetFromPasteboard( void * pb )
{
    PasteboardRef pasteboard = (PasteboardRef) pb;

    size_t formatcount = GetFormatCount(wxDataObject::Set);
    wxDataFormat *array = new wxDataFormat[ formatcount ];
    GetAllFormats(array, wxDataObject::Set);
    
    ItemCount itemCount = 0;
    wxString filenamesPassed;
    bool transferred = false;
    bool pastelocationset = false;

    // we synchronize here once again, so we don't mind which flags get returned
    PasteboardSynchronize( pasteboard );

    OSStatus err = PasteboardGetItemCount( pasteboard, &itemCount );
    if ( err == noErr )
    {
        for (size_t i = 0; !transferred && i < formatcount; i++)
        {
            // go through the data in our order of preference
            wxDataFormat dataFormat = array[ i ];

            for( UInt32 itemIndex = 1; itemIndex <= itemCount && transferred == false ; itemIndex++ )
            {
                PasteboardItemID    itemID = 0;
                CFArrayRef          flavorTypeArray = NULL;
                CFIndex             flavorCount = 0;

                err = PasteboardGetItemIdentifier( pasteboard, itemIndex, &itemID );
                if ( err != noErr )
                    continue;

                err = PasteboardCopyItemFlavors( pasteboard, itemID, &flavorTypeArray );
                if ( err != noErr )
                    continue;

                flavorCount = CFArrayGetCount( flavorTypeArray );

                for( CFIndex flavorIndex = 0; !transferred && flavorIndex < flavorCount ; flavorIndex++ )
                {
                    CFStringRef             flavorType;
                    CFDataRef               flavorData;
                    CFIndex                 flavorDataSize;

                    flavorType = (CFStringRef)CFArrayGetValueAtIndex( flavorTypeArray,
                                                                         flavorIndex );

                    wxDataFormat flavorFormat( (wxDataFormat::NativeFormat) flavorType );

                    if ( dataFormat == flavorFormat )
                    {
                        if ( UTTypeConformsTo( (CFStringRef)flavorType, kPasteboardTypeFileURLPromise) )
                        {
                            if ( !pastelocationset )
                            {
                                wxString tempdir = wxFileName::GetTempDir() + wxFILE_SEP_PATH + "wxtemp.XXXXXX";
                                char* result = mkdtemp((char*)tempdir.fn_str().data());
                                
                                if (!result)
                                    continue;
                                
                                wxCFRef<CFURLRef> dest(CFURLCreateFromFileSystemRepresentation(NULL,(const UInt8*)result,strlen(result),true));
                                PasteboardSetPasteLocation(pasteboard, dest);
                                pastelocationset = true;
                           }
                        }
                        else if ( flavorFormat.GetType() != wxDF_PRIVATE )
                        {
                            // indicate the expected format for the type, benefiting from native conversions eg utf8 -> utf16
                            flavorType = (CFStringRef) wxDataFormat( flavorFormat.GetType()).GetFormatId();
                        }
                        
                        err = PasteboardCopyItemFlavorData( pasteboard, itemID, flavorType , &flavorData );
                        if ( err == noErr )
                        {
                            flavorDataSize = CFDataGetLength( flavorData );
                            if (dataFormat.GetType() == wxDF_FILENAME )
                            {
                                 // revert the translation and decomposition to arrive at a proper utf8 string again
                                CFURLRef url = CFURLCreateWithBytes( kCFAllocatorDefault, CFDataGetBytePtr( flavorData ), flavorDataSize, kCFStringEncodingUTF8, NULL );
                                CFStringRef cfString = CFURLCopyFileSystemPath( url, kCFURLPOSIXPathStyle );
                                CFRelease( url );
                                CFMutableStringRef cfMutableString = CFStringCreateMutableCopy(NULL, 0, cfString);
                                CFRelease( cfString );
                                CFStringNormalize(cfMutableString,kCFStringNormalizationFormC);
                                wxString path = wxCFStringRef(cfMutableString).AsString();
                                if (!path.empty())
                                    filenamesPassed += path + wxT("\n");
                            }
                            else
                            {
                                // because some data implementation expect trailing a trailing NUL, we add some headroom
                                void *buf = malloc( flavorDataSize + 4 );
                                if ( buf )
                                {
                                    memset( buf, 0, flavorDataSize + 4 );
                                    memcpy( buf, CFDataGetBytePtr( flavorData ), flavorDataSize );

                                    if (dataFormat.GetType() == wxDF_TEXT)
                                        wxMacConvertNewlines10To13( (char*) buf );
                                    SetData( flavorFormat, flavorDataSize, buf );
                                    transferred = true;
                                    free( buf );
                                }
                            }
                            CFRelease (flavorData);
                        }
                    }
                    else if ( dataFormat.GetType() == wxDF_UNICODETEXT && flavorFormat.GetType() == wxDF_TEXT )
                    {
                        err = PasteboardCopyItemFlavorData( pasteboard, itemID, flavorType, &flavorData );
                        if ( err == noErr )
                        {
                            flavorDataSize = CFDataGetLength( flavorData );
                            void *asciibuf = malloc( flavorDataSize + 1 );
                            if ( asciibuf )
                            {
                                memset( asciibuf, 0, flavorDataSize + 1 );
                                memcpy( asciibuf, CFDataGetBytePtr( flavorData ), flavorDataSize );
                                CFRelease (flavorData);

                                SetData( wxDF_TEXT, flavorDataSize, asciibuf );
                                transferred = true;
                                free( asciibuf );
                            }
                            else
                                CFRelease (flavorData);
                        }
                    }
                }
                CFRelease( flavorTypeArray );
            }
            if ( !filenamesPassed.empty() )
            {
                wxCharBuffer buf = filenamesPassed.fn_str();
                SetData( wxDF_FILENAME, strlen( buf ), (const char*)buf );
                transferred = true;
            }
        }
    }
    return transferred;
}
Пример #21
0
bool wxGxContentView::CanPaste()
{
    wxClipboardLocker lockClip;
    return wxTheClipboard->IsSupported(wxDF_FILENAME) | wxTheClipboard->IsSupported(wxDataFormat(wxGIS_DND_NAME));
    //& wxTheClipboard->IsSupported(wxDF_TEXT); | wxDF_BITMAP | wxDF_TIFF | wxDF_DIB | wxDF_UNICODETEXT | wxDF_HTML
}
Пример #22
0
void wxGxTreeView::OnBeginDrag(wxTreeEvent& event)
{
    //event.Skip();
	wxTreeItemId item = event.GetItem();
	if(!item.IsOk())
		return;
    SelectItem(item);

    //TODO: wxDELETE(pDragData) somethere
    wxDataObjectComposite *pDragData = new wxDataObjectComposite();

    wxGISStringDataObject *pNamesData = new wxGISStringDataObject(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-name")));
    pDragData->Add(pNamesData, true);

    wxFileDataObject *pFileData = new wxFileDataObject();
    pDragData->Add(pFileData, false);

    //wxGISDecimalDataObject *pIDsData = new wxGISDecimalDataObject(wxDataFormat(wxT("application/x-vnd.wxgis.gxobject-id")));
    //pDragData->Add(pIDsData, false);


    //TODO: create dataobject for QGIS
//        wxDataObjectSimple* pDataObjectSimple = new wxDataObjectSimple(wxDataFormat(wxT("application/x-vnd.qgis.qgis.uri")));
//        my_data->Add(pDataObjectSimple);
//
//        wxMemoryOutputStream *pstream = new wxMemoryOutputStream();
//        wxDataOutputStream dostr(*pstream);
//
    wxArrayTreeItemIds treearray;
    size_t count = GetSelections(treearray);
    if(count == 0)
        return;
    //first is catalog memory address to prevent different app drop
    //pIDsData->AddDecimal((long)GetGxCatalog());
    for(size_t i = 0; i < count; ++i)
    {
	    wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(treearray[i]);
	    if(pData == NULL)
            continue;

        wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
	    if(pGxObject == NULL)
            continue;        
        wxString sSystemPath(pGxObject->GetPath(), wxConvUTF8);

        pFileData->AddFile(sSystemPath);
        pNamesData->AddString(pGxObject->GetFullName());
        //pIDsData->AddDecimal(pGxObject->GetId());
    }

    wxDropSource dragSource( this );
	dragSource.SetData( *pDragData );
	wxDragResult result = dragSource.DoDragDrop( wxDrag_DefaultMove );  

//    IGxObject* pParentGxObject(NULL);
//    for(size_t i = 0; i < count; ++i)
//    {
//	    wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(treearray[i]);
//	    if(pData == NULL)
//            continue;
//
//        IGxObjectSPtr pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
//        pParentGxObject = pGxObject->GetParent();
//        wxString sSystemPath(pGxObject->GetInternalName(), wxConvUTF8);
//        pFileData->AddFile(sSystemPath);
//        dostr.WriteString(sSystemPath);
//        wxStreamBuffer* theBuffer = pstream->GetOutputStreamBuffer();
//
//        pDataObjectSimple->SetData(theBuffer->GetBufferSize(), theBuffer->GetBufferStart());
//    }
  ////  		IGxObjectUI* pGxObjectUI = dynamic_cast<IGxObjectUI*>(pGxObject.get());
		////if(pGxObjectUI)
		////{
		////	wxDataFormat frm = pGxObjectUI->GetDataFormat();
		////	if(frm.GetType() != wxDF_INVALID)
		////		my_data.SetFormat(frm);
		////}
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 //   wxFileDataObject my_data;

 //   wxArrayTreeItemIds treearray;
 //   size_t count = GetSelections(treearray);
 //   if(count == 0)
 //       return;
 //   wxGxObject* pParentGxObject(NULL);
 //   for(size_t i = 0; i < count; ++i)
 //   {
	//    wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(treearray[i]);
	//    if(pData == NULL)
 //           continue;

 //       wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID);
 //       pParentGxObject = pGxObject->GetParent();
 //       wxString sSystemPath(pGxObject->GetPath(), wxConvUTF8);
 //       my_data.AddFile(sSystemPath);
 //   }
 //   wxDropSource dragSource( this );
	//dragSource.SetData( my_data );
	//wxDragResult result = dragSource.DoDragDrop(  );  
}
wxDataFormat ObjectDataObject::GetPreferredFormat(Direction) const{
  return wxDataFormat("FaintObject");
}
size_t ObjectDataObject::GetDataSize(const wxDataFormat& f) const{
  if (f == wxDataFormat("FaintObject")){
    return sizeof(Object*) * m_objects.size();
  }
  return 0;
}
Пример #25
0
void SetInfoDataObject::GetAllFormats(wxDataFormat *formats, Direction dir) const {
	formats[0] = wxDataFormat(wxDF_TEXT);
	formats[1] = wxDataFormat(wxDF_FILENAME);
	formats[2] = wxDataFormat(wxDF_UNICODETEXT);
//	formats[3] = wxDataFormat(wxDF_OEMTEXT);
}
wxDataFormat wxsItemResDataObject::GetPreferredFormat(cb_unused Direction dir) const
{
    return wxDataFormat(wxsDF_WIDGET);
}
Пример #27
0
wxDataFormat SetInfoDataObject::GetPreferredFormat(Direction dir) const {
	return wxDataFormat(wxDF_TEXT);
}
Пример #28
0
wxDataFormat wxDropTarget::GetMatchingPair()
{
    return wxDataFormat( GTKGetMatchingPair() );
}
Пример #29
0
CRemoteDataObject::CRemoteDataObject()
	: wxDataObjectSimple(wxDataFormat(_T("FileZilla3RemoteDataObject")))
	, m_didSendData()
	, m_processId(wxGetProcessId())
{
}
void ObjectDataObject::GetAllFormats(wxDataFormat* formats, Direction) const{
  formats[0] = wxDataFormat("FaintObject");
}