wxPlayerDataObject

A data object for Player drag and drop operations.  All drag and drop operations in wxWidgets involve a wxDataObject-derived class of some kind.  The base class wxDataObject provides an interface pure virtual functions that must be supplied for drag and drop to work with any user-defined data.  However, there are many cases where a drag and drop object only needs to support just a single piece of user-defined data.  The wxDataObjectSimple class narrows the wxDataObject interface down to the minimum set of functions that must be implemented for drag and drop to work.

The class wxPlayerDataObject is derived from wxDataObjectSimple and provides drag and drop support for the class Player, allowing Player objects to be dragged and dropped throughout the UI where this class is used.  See http://www.wxwindows.org /manuals /2.4.2 /wx495.htm#wxdndoverview for a full overview of drag and drop in wxWidgets.

Derived From

wxDataObjectSimple (see http://www.wxwindows.org/manuals/2.4.2/wx88.htm)

Project

Cities3D

Include

PlayerDataObject.h

Summary
A data object for Player drag and drop operations.
The wxPlayerDataObject constructor.
Returns the Player data associated with this object.
Returns the size of the data needing to be passed via drag and drop.
Retrieves the data object.
Stores the data object.
The internal data format.
The Player data associated with this drop object.

Public

Summary
The wxPlayerDataObject constructor.
Returns the Player data associated with this object.
Returns the size of the data needing to be passed via drag and drop.
Retrieves the data object.
Stores the data object.

Constructors

wxPlayerDataObject

wxPlayerDataObject(const Player &player)

The wxPlayerDataObject constructor.  Creates the internal data format for this type of wxDataObject and registers it with wxWidgets.  Initializes the mPlayer member variable with the given Player data.

Parameters

playerThe Player object to drag and drop.

Functions

GetPlayer

const Player &GetPlayer() const

Returns the Player data associated with this object.

Returns

A const reference to the Player data associated with this object.

Virtual Functions

GetDataSize

virtual size_t GetDataSize() const

Returns the size of the data needing to be passed via drag and drop.

Returns

The size of the Player data object.

GetDataHere

virtual bool GetDataHere(void *buf) const

Retrieves the data object.  In normal wxWidgets drag and drop handling, this function is used to retrieve the outgoing dropped data and put it in the buffer provided.  However, we cheat by just using a static Player instance to keep track of the data being passed around, a much simpler and easier to maintain solution.

Parameters

bufThe buffer data is supposed to be written to.  Unused.

Returns

A bool indicating success.  Always returns true.

SetData

virtual bool SetData(size_t len,
const void *buf)

Stores the data object.  In normal wxWidgets drag and drop handling, this function is used to set the incoming dropped data by giving the length of the data and a pointer to the raw bytes.  However, we cheat by just keeping a static Player instance around, which is much simpler and easier to maintain.

Parameters

lenThe length of the data.  Unused.
bufThe raw data.  Unused.

Returns

A bool indicating success.  Always returns true.

Private

Summary
The internal data format.
The Player data associated with this drop object.

Variables

mDataFormat

wxDataFormat mDataFormat

The internal data format.  Used by wxWidgets for some mysterious sorcery.

mPlayer

Player mPlayer

The Player data associated with this drop object.

Still volatile.
wxPlayerDataObject(const Player &player)
The wxPlayerDataObject constructor.
const Player &GetPlayer() const
Returns the Player data associated with this object.
virtual size_t GetDataSize() const
Returns the size of the data needing to be passed via drag and drop.
virtual bool GetDataHere(void *buf) const
Retrieves the data object.
virtual bool SetData(size_t len,
const void *buf)
Stores the data object.
wxDataFormat mDataFormat
The internal data format.
Player mPlayer
The Player data associated with this drop object.
Cities3D is a cross-platform implementation of the board game Settlers of Catan with all expansions, including Seafarers, and Cities & Knights.