Displays all of the players in the current Game in a tree control, with full drag and drop support. All of the colors in the system are displayed as tree nodes. If a player is in the game, the color that they are assigned to has their player name next to it in the tree. If a node in the tree does not have a player name next to it, that color is available for any player to select.
The class wxPlayerTreeCtrl is a drop target for any drag and drop operation that uses Player objects. The drop targets are the color nodes themselves, so that a user’s color may be directly selected with a drag/drop. Not only that, but wxPlayerTreeCtrl is also drag initiator for itself, meaning that a user may alter the color of a player in the game by selecting the player with the left mouse button, holding down the mouse, dragging the player to a new color, and then releasing the left mouse button.
wxBaseTreeCtrl IPlayerDropTarget
PlayerTreeCtrl.h
Displays all of the players in the current Game in a tree control, with full drag and drop support. | |
The wxPlayerTreeCtrl constructor. | |
The wxPlayerTreeCtrl destructor. | |
Handles the drag event when the mouse is over the control. | |
Handles a drop event. | |
The wxWidgets event table declaration. | |
Creates color nodes in the tree of all possible game colors. | |
Handles a left mouse down event. | |
Handles a double-click in the player list. | |
The tree ID of the player name being dragged. |
|
The wxPlayerTreeCtrl constructor. Calls the base wxBaseTreeCtrl constructor, creates all of the color nodes in the tree, registers itself as a drop target, then adds OnUpdatePlayers to the Controller as a receiver of the eventPreGame Event.
| parent | The parent window. |
| id | The message handling ID. Should be a unique (to the parent window) ID, if the parent window wants to receive messages from the control. |
| pos | The list control position in window coordinates. |
| size | The list control size. |
| ~wxPlayerTreeCtrl() |
The wxPlayerTreeCtrl destructor. Removes OnUpdatePlayers as a receiver of the eventPreGame Event.
|
Handles the drag event when the mouse is over the control. Overridden from IPlayerDropTarget. Does a hit test with the given coordinates and selects any color node that may be underneath the potential drop position.
| x | The x coordinate of the drag position. |
| y | The y coordinate of the drag position. |
|
Handles a drop event. Occurs when the player has released the mouse button over the control with a valid Player data object to drop. First checks to ensure that the drop position is valid and then does a combination of three things. Adds the player to the game if the player is not already in the tree, and/or changes the color of the player if they were already in the tree, and/or removes a player from the game if they were already at the dropped color.
| x | The x coordinate of the drop position. |
| y | The y coordinate of the drop position. |
| player | The Player to set to the color. |
|
Handles a left mouse down event. Checks to see if the mouse landed on a color node with 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.
| event | The mouse event. |
|
| ~wxPlayerTreeCtrl() |
|
|
| void CreateColors() |
|
|
|
| wxTreeItemId mDragID |