// ================================================================================= // CBetterListBox.h ©1995 J. Rodden, DD/MF & Associates. All rights reserved // // Based on: // CListBox ©1994 Harold Ekstrom, AG Group, Inc. All rights reserved // CDDxList ©1995 Malcolm Pradhan. All rights reserved // ================================================================================= // Note: if mBroadcastDblClkModifiers is true (default), when the double click message // is broadcast, the high byte of the EventRecord's modifiers field is packed into the // high byte of the broadcasted message. To access the original message (in your // ListenToMessage routine) mask out the high byte ( inMessage & ~modifiersMask ). // To access the modifiers, use HiWord(inMessage) and the system defined modifer bit // masks (cmdKey, shiftKey, etc). #pragma once #include #ifndef __LISTS__ #include #endif #define __CLISTBOX__ const short kTextGap = 4; const short kTextSelSlop = 2; // ================================================================================= const MessageT modifiersMask = 0xFF000000; inline void PackModifiersInMessage(MessageT& ioMessage, const SMouseDownEvent& inMouseDown) { ioMessage = (ioMessage & ~modifiersMask) | ((MessageT(inMouseDown.macEvent.modifiers) << 16) & modifiersMask); } // ================================================================================= class CBetterListBox : public LListBox { public: enum { classID = 'clst' }; static CBetterListBox* CreateFromStream(LStream *inStream); CBetterListBox(); CBetterListBox(LStream *inStream); virtual ~CBetterListBox(); virtual void SwapListItems(Cell& toCell, Cell& fromCell, short inDataLen); virtual void ClearCell(Cell inCell); virtual void DeleteRow(short inRowNum); virtual void DeleteCol(short inColNum); virtual void AddRowElement(const void *lElement, const short lDataLen, Cell& inCell); virtual void AddColElement(const void *lElement, const short lDataLen, Cell& inCell); virtual void CopyCell( Cell inSrcCell, Cell inDestCell, short inDataLen); virtual Boolean HandleKeyPress(const EventRecord& inKeyEvent); protected: Boolean mAllowDeleteKey; Boolean mBroadcastDblClkModifiers; virtual void FinishCreateSelf(); virtual void LDEFInitialize(); virtual void LDEFDraw( Boolean lSelect, Rect *lRect, Cell lCell, short lDataOffset, short lDataLen ); virtual void LDEFHilite( Boolean lSelect, Rect *lRect, Cell lCell, short lDataOffset, short lDataLen ); virtual void DrawElementSelf( Boolean lSelect, Rect *lRect, Cell lCell, short lDataLen ); virtual void TakeOffDuty(void); virtual void PutOnDuty(void); virtual void ClickSelf(const SMouseDownEvent &inMouseDown); virtual Boolean ClickInCell(const SMouseDownEvent &inMouseDown, Rect& inRect, Cell& inCell); virtual void ClickInScrollBar(Point& inLocalPt, short inModifiers); virtual void HandleDoubleClick(const Cell& inCell, const SMouseDownEvent& inMouseDown); virtual void DoDeleteKey(); Boolean IsValidCell(Cell& inCell); private: ListDefProcPtr mLDEFProc; friend static pascal void CBetterListBoxLDEF( short lMessage, Boolean lSelect, Rect *lRect, Cell lCell, short lDataOffset, short lDataLen, ListHandle lList ); };