UIpane.h 1.99 KB


#ifndef __UIPane__
#define __UIPane__


#include "UI.h"
#include "UIevent.h"


#define kInvalidID      -1


typedef void            * UIPaneDataPtr;
typedef struct uiitem   * UIItemPtr;
typedef struct uipane   * UIPanePtr;

typedef void    (*TPaneDrawProc)(UIPanePtr pPane, Gfx **ppGfx);
typedef void    (*TItemDrawProc)(UIItemPtr pItem, Gfx **ppGfx);
typedef char    (*THandleEventProc)(UIPanePtr pPane, UIEvent *pEvent);


typedef struct uipane
{
    Rect                bounds;         /* In screen coordinates. */
    int                 numItems;       /* The number of UIItems this pane contains. */
    UIItemPtr           itemList;       /* A pointer to the the pane's list of UIItems (stored somewhere in pane data) */
    UIPaneDataPtr       pData;          /* Reference to pane-specific data including storage for the UIItem list. */

    TPaneDrawProc       DrawProc;
    THandleEventProc    HandleEventProc;    
} UIPane;


typedef struct uiitem
{
    int                 id;             /* The item's unique id.  Often matches the array index if it is stored in one. */
    Rect                bounds;         /* In pane coordinates. */
    char                fIsSelected;    /* Indicates the selection state of the UIItem. */
    char		fIsClicked;	/* Indicates if the item is being clicked on. */
    Sprite *            pSpriteIcon;    /* The item's sprite data in it has an icon, NULL if it does not. */
    UIPane *            pPane;          /* The pane which contains this item.  Used to convert pane to screen coords. */
    
    TItemDrawProc       DrawProc;
    
} UIItem;



void    Pane_Init (UIPane *pPane);
char    Pane_ItemClicked (UIPane *pPane, Point *pPt, UIItem **ppItem);
char	Pane_GetSelectedItem (UIPane *pPane, UIItem **ppItem);
void	Pane_DeselectAllItems (UIPane *pPane);


void    Item_Init (UIItem *pItem, int id);
void    Item_GetScreenBounds (UIItem *pItem, Rect *pRect);
void	Item_SetSelected (UIItem *pItem, char isSelected);
char	Item_IsSelected (UIItem *pItem);


#endif /* __UIPane__ */