Package cards

Class MacaoCardStack

Inherited from MacaoObject

          What is a Substack?
          Schemes and Offsets
          Internals

Fields   Constructor   Methods

A MacaoCardStack handles a list of cards and arrages them on the page. You can use a stack to handle a deck of cards, a row of cards on the table or a hand of cards of a player.

A stack may or may be not a visible object. The stack needs to be visible (have a look), if the user needs to drop cards on the stack using Drag & Drop.

You can add cards to a stack using the methods addCard(), addCards(), addSubstack(), insertCard() and insertSubstack(). A card usually should be on a stack. A card can only be on one stack at a time. So adding a card to a stack will automatically remove it from its previous stack. You can remove a card explicitely from a source stack before you add it to a target stack in order to prevent multiple time consuming adjustments of the source stack.

What is a Substack?

The cards on a stack are in a row from the bottom card to the top card. A substack is defined as a sublist of this cards from a start card to the top card.

Schemes and Offsets

The behavior of a stack is defined by an exposed schema and a drag schema (see the EXPOSED_SCHEMA_ and DRAG_SCHEMA_ constants). This schemes define, which cards of the stack are exposed and which can be dragged by the user. The offset values define, how the cards are arranged by the stack. By setting large offsets, you can put the cards beside each other. By setting small offsets you can arrange the cards to a deck. Even if the offset values are in pixels, an offset can be a float value like 0.2 pixels.

The defined schemes and offsets and the stacking are used by the method adjustCards() to adjust the cards exposure, drag activation, position and stacking. This functionality is time consuming. So you should pay attention to only trigger it once for a stack after a user action.

Internals

Internally the stack works with a double linked list of stack items. Each stack item has the attributes prevItem, nextItem and card. The stack holds references to the bottom item and the top item.

Field Summary
String DRAG_SCHEMA_ALL
     This constant defines the drag schema, where all of the cards of the stack can be dragged by the user.
String DRAG_SCHEMA_ALL_SUBSTACK
     This constant defines the drag schema, where all of the cards of the stack can be dragged by the user. Dragging a card will cause the entire substack to be dragged.
String DRAG_SCHEMA_EXPOSED
     This constant defines the drag schema, where only the exposed cards of the stack can be dragged by the user.
String DRAG_SCHEMA_EXPOSED_SUBSTACK
     This constant defines the drag schema, where only the exposed cards of the stack can be dragged by the user. Dragging a card will cause the entire substack to be dragged.
String DRAG_SCHEMA_INDIVIDUAL
     This constant defines the drag schema, where you control individually, which of the cards of the stack can be dragged by the user.
String DRAG_SCHEMA_INDIVIDUAL_SUBSTACK
     This constant defines the drag schema, where you control individually, which of the cards of the stack can be dragged by the user. Dragging a card will cause the entire substack to be dragged.
String DRAG_SCHEMA_NONE
     This constant defines the drag schema, where none of the cards of the stack can be dragged by the user.
String DRAG_SCHEMA_TOP
     This constant defines the drag schema, where only the top card of the stack can be dragged by the user.
String EXPOSED_SCHEMA_ALL
     This constant defines the exposed schema, where all of the cards of the stack are exposed.
String EXPOSED_SCHEMA_INDIVIDUAL
     This constant defines the exposed schema, where the exposure of each card is controlled individually.
String EXPOSED_SCHEMA_NONE
     This constant defines the exposed schema, where none of the cards of the stack is exposed.
String EXPOSED_SCHEMA_SUBSTACK
     This constant defines the exposed schema, where a number of cards at the top of the stack are exposed.
String EXPOSED_SCHEMA_TOP
     This constant defines the exposed schema, where the top card of the stack is exposed.
boolean IS_STACK
     This constant marks a stack as stack. It is always true.

Inherited Fields
BUNCH_TYPE_SAY, BUNCH_TYPE_STAND, BUNCH_TYPE_WALK

Constructor Summary
MacaoCardStack(String name, String title, number left, number top, String stackType, boolean standardLook, number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY, String exposedSchema, String dragSchema)
     Use this constructor to create a new stack object.

Method Summary
void addCard(MacaoCard card, optional boolean dontAdjustCards)
     Call this method to add a single card to the top of the stack.
void addCards(Array cards, optional boolean dontAdjustCards)
     Call this method to add an array of cards to the top of the stack.
void addSubstack(MacaoCard startCard, optional boolean dontAdjustCards)
     Call this method to move a substack from another stack to the top of this stack.
void adjustCards(optional MacaoCard startCard)
     Call this method to adjust the exposure, the drag activation, the position and the stacking of the cards in the stack.
Array getAllCards()
     Call this method to get all cards of the stack.
number getBaseOffsetX()
     Call this method to get the offset between the left edge of the stack and the bottom card.
number getBaseOffsetY()
     Call this method to get the offset between the top edge of the stack and the bottom card.
MacaoCard getBottomCard()
     Call this method to get the bottom card of the stack.
MacaoCard getCardAt(integer index)
     Call this method to get a card of the stack by its index.
integer getCardIndex(MacaoCard card)
     Call this method to calculate the position of the card in the stack.
number getCardOffsetX()
     Call this method to get the offset between the left edges of two cards
number getCardOffsetY()
     Call this method to get the offset between the top edges of two cards
String getDragSchema()
     Call this method to get the drag schema of the stack.
String getExposedSchema()
     Call this method to get the exposed schema of the stack.
MacaoCard getNextCard(MacaoCard card)
     Call this method to get the next card of a card.
MacaoCard getPreviousCard(MacaoCard card)
     Call this method to get the previous card of a card.
integer getSize()
     Call this method to evaluate how many cards are on the stack.
String getStackType()
     Call this method to get the stack type.
Array getSubstack(MacaoCard startCard)
     Call this method to get the cards of a substack of this stack.
MacaoCard getTopCard()
     Call this method to get the top card of the stack.
boolean hasCard(MacaoCard card)
     Call this method to check, if a card is element of a stack.
void initCardStack(String name, String title, number left, number top, String stackType, boolean standardLook, number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY, String exposedSchema, String dragSchema)
     This method is called by the constructor to initialize the stack.
void insertCard(MacaoCard card, optional MacaoCard afterCard, optional boolean dontAdjustCards)
     Call this method to insert a card into the stack.
void insertSubstack(MacaoCard startCard, optional MacaoCard afterCard, optional boolean dontAdjustCards)
     Call this method to insert a substack into this stack.
boolean isDragSubstack()
     Call this method to check, if a dragging means to drag a substack.
boolean isEmpty()
     Call this method to check, if the stack is empty.
void onAdjustCards()
     This event handler is called after the method adjustCards() has been called.
void onClickStack(Event event, number mouseX, number mouseY)
     This event handler is called, when the user clicks on the stack.
void onDblClickStack(Event event, number mouseX, number mouseY)
     This event handler is called, when the user double clicks on the stack.
void removeAllCards()
     Call this method to remove all cards from the stack.
void removeCard(MacaoCard card, optional boolean dontAdjustCards)
     Call this method to remove a card from the stack.
void removeSubstack(MacaoCard startCard, optional boolean dontAdjustCards)
     Call this method to remove a substack from the stack.
void setAllExposed(optional boolean exposed, optional boolean dontAdjustCards)
     Call this method to make all cards of the stack show their front side or rear side.
void setCardOffsets(number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY)
     Call this method to change the offset of the cards.
void setDragSchema(String dragSchema)
     Call this method to change the drag schema of the stack.
void setExposedSchema(String exposedSchema)
     Call this method to change the exposed schema of the stack.
void shuffle(optional boolean dontAdjustCards)
     Call this method to shuffle the cards of the stack.
void sort(optional Function compareFunction, optional boolean dontAdjustCards)
     Call this method to sort the cards of the stack.
integer sumCardValues()
     Call this method to get the sum of the values of all cards in the stack.

Inherited Methods
accelerate, addLookBunch, addTalkItem, adjustStacking, approachAndTryAction, approachObject, approachPos, assignRoadNode, bindToNet, calculateApproachPos, calculateStackingIndex, changeDirection, createTalkItem, getAnchorXPos, getAnchorYPos, getApproachable, getAssignedNode, getBunchPhase, getDirection, getLookDirection, getMaxVelocity, getMeetingObjectNames, getNearestNode, getNetType, getResponsesSenderName, getResponseTalkItems, getReverseGear, getVelocity, hearEvent, hearFreeText, isMeetingObject, isWalking, leave, mayILeaveNode, meet, moveAnchorTo, moveToNode, onClickOther, onClickWindow, restore, setAnchorAtBottom, setApproachable, setApproachClick, setAssignedNode, setAutoAcceleration, setAutoRestore, setBunchDepth, setBunchPhase, setCollisionBreak, setDirection, setDisableApproach, setPreferredLook, setRandomTalk, setReverseGear, setStacking, setSteeringIndex, setTalkCssClassName, setVelocity, setWalkCharacteristics, setWalkPhases, startAutoAcceleration, steeredVelocityChanged, stopWalking, store, tryAction, walkToNode, walkToPos, wanderAroundactivateDrag, activateDrop, addController, broadcastEvent, createLayer, createLook, displayMeasures, getActualLook, getCollisionCheck, getCssClassName, getFrameName, getHeight, getLayer, getLeft, getLook, getName, getTitle, getTop, getType, getVisibility, getWidth, getZIndex, getZoom, hasLook, initObject, isController, isDragActive, isDragged, isDropActive, isDropAllowed, moveTo, moveToCenter, notifyControllers, onClick, onClickOther, onClickOtherItem, onClickWindow, onCollisionOut, onCollisionOver, onDblClick, onDblClickOther, onDblClickWindow, onDragEnd, onDragOut, onDragOver, onDragStart, onDrop, onKeyDown, onKeyPress, onKeyUp, onLoad, onMouseDown, onMouseDownWindow, onMouseMove, onMouseOut, onMouseOver, onMouseUp, onMouseUpWindow, onUnload, openPage, postEvent, refreshZoom, removeController, removeObject, say, scrollVisible, sendEvent, setActualLook, setBaseSize, setCollisionCheck, setCssClassName, setForwardMouseEvents, setHTML, setImage, setScrollVisibleOptions, setTitle, setToolTip, setType, setVisibility, setZIndex, setZoom, toBack, toFront

Field Details
String DRAG_SCHEMA_ALL

String DRAG_SCHEMA_ALL_SUBSTACK

String DRAG_SCHEMA_EXPOSED

String DRAG_SCHEMA_EXPOSED_SUBSTACK

String DRAG_SCHEMA_INDIVIDUAL

String DRAG_SCHEMA_INDIVIDUAL_SUBSTACK

String DRAG_SCHEMA_NONE

String DRAG_SCHEMA_TOP

String EXPOSED_SCHEMA_ALL

String EXPOSED_SCHEMA_INDIVIDUAL

String EXPOSED_SCHEMA_NONE

String EXPOSED_SCHEMA_SUBSTACK

String EXPOSED_SCHEMA_TOP

boolean IS_STACK

Constructor Details
MacaoCardStack(String name, String title, number left, number top, String stackType, boolean standardLook, number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY, String exposedSchema, String dragSchema)

Method Details
void addCard(MacaoCard card, optional boolean dontAdjustCards)

void addCards(Array cards, optional boolean dontAdjustCards)

void addSubstack(MacaoCard startCard, optional boolean dontAdjustCards)

void adjustCards(optional MacaoCard startCard)

Array getAllCards()

number getBaseOffsetX()

number getBaseOffsetY()

MacaoCard getBottomCard()

MacaoCard getCardAt(integer index)

integer getCardIndex(MacaoCard card)

number getCardOffsetX()

number getCardOffsetY()

String getDragSchema()

String getExposedSchema()

MacaoCard getNextCard(MacaoCard card)

MacaoCard getPreviousCard(MacaoCard card)

integer getSize()

String getStackType()

Array getSubstack(MacaoCard startCard)

MacaoCard getTopCard()

boolean hasCard(MacaoCard card)

void initCardStack(String name, String title, number left, number top, String stackType, boolean standardLook, number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY, String exposedSchema, String dragSchema)

void insertCard(MacaoCard card, optional MacaoCard afterCard, optional boolean dontAdjustCards)

void insertSubstack(MacaoCard startCard, optional MacaoCard afterCard, optional boolean dontAdjustCards)

boolean isDragSubstack()

boolean isEmpty()

void onAdjustCards()

void onClickStack(Event event, number mouseX, number mouseY)

void onDblClickStack(Event event, number mouseX, number mouseY)

void removeAllCards()

void removeCard(MacaoCard card, optional boolean dontAdjustCards)

void removeSubstack(MacaoCard startCard, optional boolean dontAdjustCards)

void setAllExposed(optional boolean exposed, optional boolean dontAdjustCards)

void setCardOffsets(number baseOffsetX, number baseOffsetY, number cardOffsetX, number cardOffsetY)

void setDragSchema(String dragSchema)

void setExposedSchema(String exposedSchema)

void shuffle(optional boolean dontAdjustCards)

void sort(optional Function compareFunction, optional boolean dontAdjustCards)

integer sumCardValues()