wxDataObject(3)
β¨ NAME β¨
wxDataObject β bestie, it's a whole data object π one that can be copied to or from the clipboard, or dragged and dropped. Slay.
π¦ DESCRIPTION π¦
okay so the main character detail here? wxDataObject is 'smart' data. not like those 'dumb' data containers you've met before (memory buffers? files? yeah. those). being 'smart' here means the data object itself knows what data formats it supports, and it knows how to render itself in every one of those formats. it's self-aware, it's giving main character energy fr fr π
a supported format, incidentally, is exactly the format in which the data can be requested from a data object, or from which the data object may be set. and in the general case? an object may support totally different formats on 'input' and 'output' β i.e. it may be able to render itself in a given format but not be created from data in that format, or the other way around. wxDataObject defines the wxDataObject::Direction (not implemented in wx) enumeration type which distinguishes between them. π
hit up the wxDataFormat (not implemented in wx) docs for more about formats, iykyk.
not surprisingly, being 'smart' comes at a price of added complexity π which is reasonable for the situations where you really need to support multiple formatsβ¦ but honestly it can be lowkey annoying if you just want to do something simple like cut and paste text.
so to provide a solution for both cases, wxWidgets has two predefined classes that derive from wxDataObject:
wxDataObjectSimple(not implemented in wx) β the simplestwxDataObjectpossible. it only holds data in a single format (such as HTML or text). minimal, unbothered, moisturized β¨wxDataObjectComposite(not implemented in wx) β the simplest way to implement awxDataObjectthat does support multiple formats, because it achieves this by simply holding severalwxDataObjectSimple(not implemented in wx) objects. iconic behavior honestly π
so, you have several solutions when you need a wxDataObject class (and you need one as soon as you want to transfer data via the clipboard or drag and drop):
π pls note: the easiest way to use drag and drop and the clipboard with multiple formats is by usingwxDataObjectComposite(not implemented in wx) β but it is not the most efficient one, because eachwxDataObjectSimple(not implemented in wx) would contain the whole data in its respective formats.
now imagine you want to paste 200 pages of text in your proprietary format, as well as Word, RTF, HTML, Unicode and plain text to the clipboardβ¦ bestie, even today's computers are in trouble. π for this case, you will have to derive from wxDataObject directly and make it enumerate its formats and provide the data in the requested format on demand.
alsoooo β note that neither the GTK+ data transfer mechanisms for clipboard and drag and drop, nor OLE data transfer, copies any data until another application actually requests the data. this is in contrast to the 'feel' offered to the user of a program who would normally think that the data resides in the clipboard after having pressed 'Copy' β in reality it is only declared to be available. not the clipboard lying to youβ¦ just vibes π
you may also derive your own data object classes from wxCustomDataObject (not implemented in wx) for user-defined types. the format of user-defined data is given as a mime-type string literal, such as "application/word" or "image/png". these strings are used as they are under Unix (so far only GTK+) to identify a format, and are translated into their Windows equivalent under Win32 (using the OLE IDataObject for data exchange to and from the clipboard and for drag and drop). note that the format string translation under Windows is not yet finished. π§
each class derived directly from wxDataObject must override and implement all of its functions which are pure virtual in the base class. and the data objects which only render their data or only set it (i.e. work in only one direction) should return 0 from GetFormatCount() (not implemented in wx). periodt. π―
see also, bestie:
- Overview dnd
- Examples
wxFileDataObjectwxTextDataObjectwxBitmapDataObject
wxWidgets docs: wxDataObject
πΈ DATA TYPES πΈ
okay so the one and only type on this page, no notes:
wxDataObject() :: wx:wx_object().
she's literally just a wx:wx_object() π«Ά
β FUNCTIONS β
crickets π¦β¨
no cap, this section is just sitting here looking pretty β the page lists the heading and nothing else. the good stuff lives up in DESCRIPTION. π
that's the whole vibe check, bestie π this lil gem ships with wx 2.6 and it's brought to you by Ericsson AB β ty for coming to my ted talk, go forth and copy/paste responsibly, mwah π
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms