eudora-mac/stickypopup.c

1 line
41 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "stickypopup.h" #define FILE_NUM 94 #pragma segment StickyPopup /* MJN *//* new file */ /* stickypopup.c stickypopup.c contains code to do a "sticky" popup menu. It is basically identical to a normal popup menu, except that it doesn't require the mouse button to stay down in order to stay open, and it allows keyboard navigation to select items. Use NewStickyPopup to create a new, empty sticky popup. Use AddEntriesToStickyPopup to add items to the popup, and RemoveEntriesFromStickyPopup to remove items. Call StickyPopupSelect to bring up the sticky popup and allow the user to select a choice from it; this function is comperable to PopUpMenuSelect. Use DisposeStickyPopup to dispose of the sticky popup when you are through with it. WARNING: The sticky popup menu routines are not compatible with the Menu Manager routines for working with menus and standard popup menus. The data types (i.e. StickyPopupHdl and MenuHandle) are not interchangeable. */ #pragma mark Constants & defines #define STICKY_POPUP_MEM_TEST_SIZE 16384 /* 16 K */ #define MAX_LIST_DATA_SIZE 32000 /* safely less than 32 K */ #define CELL_WIDTH_EXTRA 4 /* number of extra pixels to leave on right hand side in list */ #define STICKY_SELECT_EVENT_MASK (mDownMask + mUpMask + keyDownMask + autoKeyMask + keyUpMask) #define RETURN_CHAR_CODE 0x0D /* ASCII code for Carriage Return */ #define ENTER_CHAR_CODE 0x03 /* ASCII code for Enter */ #define PERIOD_CHAR_CODE 0x2E /* ASCII code for Period */ #define ESCAPE_KEY_CODE 0x35 /* virtual key code for Escape */ #define BACKSPACE_CHAR_CODE 0x08 /* ASCII code for Backspace/Delete */ #define CLEAR_KEY_CODE 0x47 /* virtual key code for Clear key on numeric keypad */ #define FWD_DEL_CHAR_CODE 0x7F /* ASCII code for Forward Delete key on extended keyboard */ #define UP_ARROW_CHAR_CODE 0x1E /* ASCII code for Up Arrow */ #define DOWN_ARROW_CHAR_CODE 0x1F /* ASCII code for Down Arrow */ #define LEFT_ARROW_CHAR_CODE 0x1C /* ASCII code for Left Arrow */ #define RIGHT_ARROW_CHAR_CODE 0x1D /* ASCII code for Right Arrow */ #define HOME_CHAR_CODE 0x01 /* ASCII code for Home key on extended keyboard */ #define END_CHAR_CODE 0x04 /* ASCII code for End key on extended keyboard */ #define SPACE_CHAR_CODE 0x20 /* ASCII code for space character */ #define DASH_CHAR_CODE 0x2D /* ASCII code for dash character */ #define STICKY_SPACE_CHAR_CODE 0xCA /* ASCII code f