The CPButtonObject & CPButtonView Classes

class CPButtonObject {


        //----------------------------------------------------
        // Object Identification
        //----------------------------------------------------

        int                             mIdNum;

        //----------------------------------------------------
        // Sound Info
        //----------------------------------------------------

        int                             mSound1;
        int                             mSound2;

        //----------------------------------------------------
        // State Information
        //----------------------------------------------------

        int                             mDelay;
        int                             mDelayInc;
        int                             mTotalStates;
        int                             mNormalState;
        int                             mCurrentState;

        //----------------------------------------------------
        // Pointers and data for Runtime Callback functions
        //----------------------------------------------------

        int                                     mCallbackSlot;
        ButtonCallback          mTransAeroToState;
        ButtonCallback          mTransStateToAero;

        //----------------------------------------------------
        // Pointer to this buttons views
        //----------------------------------------------------

        int                             mTotalViews;
        int                             mViewSlot;                      // Used only for adding views to button
        CPButtonView**  mpButtonView;           //List of views

        //----------------------------------------------------
        // Indicies for Cursor Information
        //----------------------------------------------------

        int                             mCursorIndex;

public:

#ifdef USE_SH_POOLS
        public:
                // Overload new/delete to use a SmartHeap pool
                void *operator new(size_t size) { return MemAllocPtr(gCockMemPool,size,FALSE);  };
                void operator delete(void *mem) { if (mem) MemFreePtr(mem); };
#endif
 

        //----------------------------------------------------
        // Access Functions
        //----------------------------------------------------

        void                            SetCurrentState(int);
        int                             GetCurrentState();
        int                             GetNormalState();
        int                             GetCursorIndex();
        int                             GetId();
        int                             GetSound(int);
        void                            SetSound(int, int);

        //----------------------------------------------------
        // Runtime Functions
        //----------------------------------------------------
 
        void                            AddView(CPButtonView*);
        void                            NotifyViews(void);
        void                            HandleMouseEvent(int);
        void                            HandleEvent(int);
        void                            DecrementDelay(void);
        BOOL                            DoBlit(void);

        //----------------------------------------------------
        // Constructors and Destructors
        //----------------------------------------------------

        CPButtonObject(ButtonObjectInitStr*);
        ~CPButtonObject();
};
 
 

//====================================================
// CPButtonView Class Definition
//====================================================
 

class CPButtonView {


        //----------------------------------------------------
        // Identification Tag and Callback Ids
        //----------------------------------------------------

        int                             mIdNum;
        int                             mParentButton;
        int                             mTransparencyType;
        RECT                            mDestRect;
        BOOL                            mDirtyFlag;
        BOOL                            mPersistant;
        int                             mStates;

        //----------------------------------------------------
        // Pointers to the Outside World
        //----------------------------------------------------

        ImageBuffer             *mpOTWImage;
        ImageBuffer             *mpTemplate;

        //----------------------------------------------------
        // Pointer to the Button Object that owns this view
        //----------------------------------------------------

        CPButtonObject  *mpButtonObject;

        //----------------------------------------------------
        // Source Locations for Template Surface
        //----------------------------------------------------

        RECT                            *mpSrcRect;     // List of Rects
        int                             mScale;

public:

#ifdef USE_SH_POOLS
        public:
                // Overload new/delete to use a SmartHeap pool
                void *operator new(size_t size) { return MemAllocPtr(gCockMemPool,size,FALSE);  };
                void operator delete(void *mem) { if (mem) MemFreePtr(mem); };
#endif

        //----------------------------------------------------
        // Runtime Member Functions
        //----------------------------------------------------

        void                                            DisplayBlit(void);
        BOOL                                            HandleEvent(int*, int, int, int);
        void                                            SetDirtyFlag() {mDirtyFlag = TRUE;};
        int                                             GetId();
        int                                             GetTransparencyType(void);
        int                                             GetParentButton(void);
        void                                            SetParentButtonPointer(CPButtonObject*);
        virtual void                    CreateLit(void){};
        void                                            DiscardLit(void){};
        void                                            Translate(WORD*) {};

        //----------------------------------------------------
        // Constructors and Destructors
        //----------------------------------------------------

        CPButtonView(ButtonViewInitStr*);
        ~CPButtonView();
};