This is CardPileView.h in view mode; [Download] [Up]
/* indent:4 tabsize:8 font:fixed-width */ /*-------------------------------------------------------------------------- | -------------------------------------------------------------------------- | | CardPileView :View :Responder :Object | | Instances of this class provide a visual representation of a pile of | cards. CardPileView uses CardPile as the underlying representation, | but adds a visual aspect and user interaction. Users can click on | CardPileViews and drag cards from one view to another. The decisions | on when this is allowed and what happens as a result are left to the | CardPileView's delegate. | | --------------------------------------------------------------------------- \-------------------------------------------------------------------------- */ #import <appkit/appkit.h> #import "cardset.h" /*---------------------------------------------------------------------------- | | Card dimensions | \---------------------------------------------------------------------------*/ #define CS_CARDWIDTH 107 #define CS_CARDHEIGHT 168 #define CS_SMALLCARDWIDTH 80 #define CS_SMALLCARDHEIGHT 126 /*---------------------------------------------------------------------------- | | Delegate method flags | \---------------------------------------------------------------------------*/ #define CS_CLICKED (1 << 0) #define CS_DRAGGED (1 << 1) #define CS_CANACCEPT (1 << 2) #define CS_ACCEPT (1 << 3) #define CS_REMOVED (1 << 4) #define CS_GETOFFSET (1 << 5) #define CS_DOUBLECLICKED (1 << 6) @interface CardPileView:View { float xOffset, yOffset; id cardPile, dragCardPile; BOOL useDragCardPile; id delegate; int delegateFlags; int tag; NXColor backgroundColor; float backgroundGray; BOOL drawOutline; BOOL coversOthers; id coverPile1; id coverPile2; id coverPile3; id coverPile4; id beneath; } /*---------------------------------------------------------------------------- | | Class initialization | \---------------------------------------------------------------------------*/ + initialize; /*---------------------------------------------------------------------------- | | Creating and freeing | \---------------------------------------------------------------------------*/ - initFrame:(NXRect *)frameRect; - free; /*---------------------------------------------------------------------------- | | Managing related objects | \---------------------------------------------------------------------------*/ - setDelegate:anObject; - delegate; - cardPile; /*---------------------------------------------------------------------------- | | Displaying the CardPile | \---------------------------------------------------------------------------*/ - (NXColor)backgroundColor; - setBackgroundColor:(NXColor)aColor; - setCardSize:(CardSize)aSize; - (BOOL)willDrawOutline; - setDrawOutline:(BOOL)aFlag; - drawSelf:(NXRect *)theRect :(int)rectCount; /*--------------------------------------------------------------------------- | | Overlapping card pile methods | \---------------------------------------------------------------------------*/ - (BOOL)pileCovered:sender; - (BOOL)pileCoveredBy:aCardPileView; - setCoversOthers:(BOOL)doesCover; - setCoverPile:(int)offset to:aPile; - resetBacking:sender; /*---------------------------------------------------------------------------- | | Responder methods | \---------------------------------------------------------------------------*/ - mouseDown:(NXEvent *)theEvent; /*---------------------------------------------------------------------------- | | Drag and drop methods | \---------------------------------------------------------------------------*/ - (NXDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag; - draggedImage:(NXImage *)image beganAt:(NXPoint *)screenPoint; - draggedImage:(NXImage *)image endedAt:(NXPoint *)screenPoint deposited:(BOOL) flag; - (NXDragOperation)draggingEntered:sender; - (BOOL)prepareForDragOperation:sender; - (BOOL)performDragOperation:sender; /*---------------------------------------------------------------------------- | | Utility | \---------------------------------------------------------------------------*/ - findCardAt:(NXPoint *)thePoint; - getRect:(NXRect *)cardRect forCard:aCard; - drawDragCard:sender; - setTag:(int)theTag; - (int)tag; @end /*--------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | CardPileViewDelegate | | These methods may be implemented by a delegate of CardPileView | | --------------------------------------------------------------------------- \---------------------------------------------------------------------------*/ @interface Object(CardPileViewDelegate) - clickedCard:aCard in:aCardPileView; - doubleClickedCard:aCard in:aCardPileView; - (BOOL)draggedPile:aCardPile from:aCardPileView; - (BOOL)canAcceptPile:aCardPile from:sender in:aCardPileView; - acceptPile:aCardPile in:aCardPileView; - removedPile:aCardPile from:aCardPileView; - getOffset:(float *)xOffset :(float *)yOffset forSize:(CardSize)aSize; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.