#ifndef c_Arrows_Manager_h #define c_Arrows_Manager_h #include #include "cBetterBroadcasterEditField.h" // =========================================================================== // cArrowsManager.cpp Version 1.2 ©1998 Joakim Braun All rights reserved. // =========================================================================== // // CONTENTS: cArrowsManager // A subclass of LView and LListener that manages an edit field with an LLittleArrows. // When arrow is clicked, edit field is updated; when something is typed in // edit field, arrows value is updated. // cCmdrArrowsManager // Subclass of cArrowsManager, adding capability of trapping char_UpArrow and char_DownArrow // keypresses and simulate a click in upArrow/DownArrow. See NOTE below, though. // cCmdrArrowsManagerAttachment // Attachment used by cCmdrArrowsManager to filter key presses // REQUIRES: This uses my cBetterBroadcasterEditField subclass of LBroadcasterEditField that // calls BroadcastValueMessage() every time text changes. It should be // included in the archive containing this file. // HOW TO USE: Add the included CTYP to your PPOB file and use Constructor to set up the LLittleArrows // and cBetterBroadcasterEditField inside a cArrowsManager, filling in the property fields // as indicated below. If you want to use a cCmdrArrowsManager, set up a cArrowsManager // and change its Class ID field to 'arCM'. // The property fields are: // Text changed msg The message broadcast by the // cBetterBroadcasterEditField // when user has changed the text. // cBetterBroadcastingEditField ID Pane ID of the cBetterBroadcasterEditField. // Arrows changed msg The message broadcast by the // LLittleArrows when user has changed // its value. // LLittleArrows ID Pane ID of the LLittleArrows. // Broadcast changed value Boolean indicating whether the cArrowsManager // should also broadcast when value has changed. // Changed value message The message for cArrowsManager to broadcast // if "Broadcast changed value" is true. // NOTE: There¥s a bug (to my mind) in LGALittleArrowsImp::HotSpotAction() // with the result that one can have either the visual feedback OR the value change // when calling LLittleArrows::SimulateHotSpotClick(). A way to fix it is to add checks // for kControlUpButtonPart/kControlDownButtonPart in LGALittleArrowsImp::HotSpotAction(). // Without the fix, cCmdrArrowsManager won't work (including PP 1.8.1 at least). // cArrowsManager is free for any and all use. // Do not distribute modified source code under my name. // No support promised, no liability accepted. Provided "as is". // That said, I can be reached at braun@swipnet.se. // Change history: // 1.0 May 2, 1998 First release // 1.1 August 14, 1998 Cleaned up code, added parameter constructor. // 1.2 August 30, 1998 Added keyboard upArrow/downArrow support in new cCmdrArrowsManager class class cArrowsManager : public LView, public LListener, public LBroadcaster{ public: enum { class_ID = 'arrM' }; cArrowsManager(void); cArrowsManager( PaneIDT inEditFieldID, PaneIDT inArrowsID, MessageT inTextChangedMsg, MessageT inArrowsChangedMsg, MessageT inChangedValueMsg, Boolean inBroadcastChangedValue); cArrowsManager(LStream* inStream); virtual void ListenToMessage(MessageT inMessage, void *ioParam); virtual void FinishCreateSelf(void); protected: MessageT mTextChangedMsg, mArrowsChangedMsg, mChangedValueMsg; PaneIDT mEditFieldID, mArrowsID; cBetterBroadcasterEditField* mEditField; LLittleArrows* mLittleArrows; virtual void ArrowsChanged(Int32 newValue); virtual void TextChanged(Str255 newText); virtual void ManagerChanged(void); }; class cCmdrArrowsManager : public cArrowsManager, public LCommander{ public: enum { class_ID = 'arCM' }; cCmdrArrowsManager(void); cCmdrArrowsManager( PaneIDT inEditFieldID, PaneIDT inArrowsID, MessageT inTextChangedMsg, MessageT inArrowsChangedMsg, MessageT inChangedValueMsg, Boolean inBroadcastChangedValue); cCmdrArrowsManager(LStream* inStream); virtual Boolean HandleKeyPress( const EventRecord &inKeyEvent); virtual void FinishCreateSelf(void); }; class cCmdrArrowsManagerAttachment : public LAttachment{ public: cCmdrArrowsManagerAttachment(cCmdrArrowsManager* inManager); protected: cCmdrArrowsManager* mArrowsManager; virtual void ExecuteSelf(MessageT inMessage, void* ioParam); }; #endif