wxPlayerDropListCtrl

Displays all of the players in the PlayerDatabase in a list control, with drag and drop initiation.  Players are displayed as in the base class wxPlayerListCtrl.  However, with wxPlayerDropListCtrl, users can select a player in the list, hold down the left mouse button, and drag them to another object that supports receiving Player objects.  The class also implements a mechanism for users to directly add a player in the list to the current Game by handling the double-click mouse event for the list control.  If a player name is double-clicked, the player is added to the game via the RuleUIAddPlayer Rule.

A wxPlayerDropListCtrl object also refreshes itself whenever the eventPreGame Event is triggered.  It repopulates itself with every player in the PlayerDatabase and then removes all players from the list that are already in the game.

Derived From

wxPlayerListCtrl

Project

Cities3D

Include

PlayerDropListCtrl.h

Summary
Displays all of the players in the PlayerDatabase in a list control, with drag and drop initiation.
The wxPlayerDropListCtrl constructor.
The wxPlayerDropListCtrl destructor.
Adds a new player to the list.
Changes the name of a player currently in the list.
The wxWidgets event table declaration.
Repopulates the player list, removing all players already in the game.
Handles a left mouse down event.
Handles a double-click in the player list.

Public

Summary
The wxPlayerDropListCtrl constructor.
The wxPlayerDropListCtrl destructor.
Adds a new player to the list.
Changes the name of a player currently in the list.
The wxWidgets event table declaration.

Constructors

wxPlayerDropListCtrl

wxPlayerDropListCtrl(wxWindow *parent, 
wxWindowID id, 
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize)

The wxPlayerDropListCtrl constructor.  Calls the base wxPlayerListCtrl constructor, then adds OnUpdatePlayers to the Controller as a receiver of the eventPreGame Event.

Parameters

parentThe parent window.
idThe message handling ID.  Should be a unique (to the parent window) ID, if the parent window wants to receive messages from the control.
posThe list control position in window coordinates.
sizeThe list control size.

Destructor

~wxPlayerDropListCtrl

~wxPlayerDropListCtrl()

The wxPlayerDropListCtrl destructor.  Removes OnUpdatePlayers as a receiver of the eventPreGame Event.

Functions

AddPlayer

void AddPlayer(const wxString &name)

Adds a new player to the list.  Looks up the player’s index in the PlayerDatabase and then inserts the new player’s name into the list, storing the index for later reference.

Parameters

nameThe name of the new player.

EditPlayer

void EditPlayer(const wxString &oldName,
const wxString &newName)

Changes the name of a player currently in the list.

Variables

DECLARE_EVENT_TABLE

The wxWidgets event table declaration.

Private

Summary
Repopulates the player list, removing all players already in the game.
Handles a left mouse down event.
Handles a double-click in the player list.

Game Event Functions

OnUpdatePlayers

void OnUpdatePlayers(GamePtr game)

Repopulates the player list, removing all players already in the game.  Triggered by the eventPreGame Event.

Parameters

gameThe current Game.

Event Message Handling

OnLeftDown

void OnLeftDown(wxMouseEvent &event)

Handles a left mouse down event.  Checks to see if the mouse landed on a player name.  If so, sets the item to selected and then creates a new wxPlayerDataObject with the Player data for the selected player name.  Finally, creates a wxDropSource object for doing drag and drop in wxWidgets.

Parameters

eventThe mouse event.

OnItemDoubleClick

void OnItemDoubleClick(wxListEvent &event)

Handles a double-click in the player list.  If a player name is selected, the RuleUIAddPlayer Rule is executed and the Player data corresponding to the selected player name is added to the game.

Parameters

eventThe list control event.
Still volatile.
wxPlayerDropListCtrl(wxWindow *parent, 
wxWindowID id, 
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize)
The wxPlayerDropListCtrl constructor.
~wxPlayerDropListCtrl()
The wxPlayerDropListCtrl destructor.
void AddPlayer(const wxString &name)
Adds a new player to the list.
void EditPlayer(const wxString &oldName,
const wxString &newName)
Changes the name of a player currently in the list.
void OnUpdatePlayers(GamePtr game)
Repopulates the player list, removing all players already in the game.
void OnLeftDown(wxMouseEvent &event)
Handles a left mouse down event.
void OnItemDoubleClick(wxListEvent &event)
Handles a double-click in the player list.
Displays all of the players in the PlayerDatabase in a list control.
Still volatile.
Still volatile.
The default implementation of IRule for normal Game actions.
A generic implementation of the Observer design pattern.
Cities3D is a cross-platform implementation of the board game Settlers of Catan with all expansions, including Seafarers, and Cities & Knights.
The communication mechanism between the View and the Model.
A data object for Player drag and drop operations.