eudora-mac/mbdrawer.c

1 line
23 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 "mbdrawer.h" #include "listview.h" #define FILE_NUM 143 /* Copyright (c) 2002-2003 by QUALCOMM Incorporated */ #if TARGET_RT_MAC_CFM // constants enum { kEventWindowDrawerOpening = 220, kEventWindowDrawerOpened = 221, kEventWindowDrawerClosing = 222, kEventWindowDrawerClosed = 223 }; // These items aren't in the carbon headers yet typedef UInt32 WindowDrawerState; enum { kWindowDrawerOpening = 1, kWindowDrawerOpen = 2, kWindowDrawerClosing = 3, kWindowDrawerClosed = 4 }; WindowDrawerState GetDrawerState(WindowRef inDrawerWindow); #endif // structs typedef struct { ViewListPtr list; // mailboxes list ExpandInfo expandList; MyWindowPtr parentWin; TOCHandle tocH; ControlRef listCtl; Boolean hasFocus; } MBDrawerVars, **MBDrawerHandle; // functions static MBDrawerHandle GetMBDrawerInfo(MyWindowPtr win); static void MBDrawerClick(MyWindowPtr win,EventRecord *event); static void MBDrawerDidResize(MyWindowPtr win, Rect *oldContR); static void MBDrawerGetListRect(WindowRef win,Rect *r); static Boolean MBDrawerKey(MyWindowPtr win, EventRecord *event); static long MBDrawerLVCallBack(ViewListPtr pView, VLCallbackMessage message, long data); static void MBDrawerUpdate(MyWindowPtr win); static OSErr MBDrawerDragHandler(MyWindowPtr win,DragTrackingMessage which,DragReference drag); static OSStatus ControlEvents(EventHandlerCallRef inHandlerCallRef, EventRef theEvent, void *userData); static OSStatus ListControlEvents(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData); static void OpenMyDrawer(MyWindowPtr winDrawer); static void SetDrawerIcon(MyWindowPtr winParent,Boolean open); void MBDrawerSetState(MyWindowPtr winParent,Boolean open); // globals /************************************************************************ * MBDrawerOpen - open a mailbox drawer ************************************************************************/ MyWindowPtr MBDrawerOpen(MyWindowPtr winParent) { TOCHandle tocH = (TOCHandle)GetMyWindowPrivateData(winParent); WindowRef winWP,winParentWP; MyWindowPtr win; OSErr err; CGrafPtr winPort; Rect r; GrafPtr oldPort; MBDrawerVars vars; Handle hMBDrawerInfo=nil; short width = GetPrefLong(PREF_DRAWER_WIDTH); EventTypeSpec ctlEventList[] = { {kEventClassControl, kEventControlHitTest} }; EventTypeSpec listCtlEventList[] = { {kEventClassControl, kEventControlDraw} }; DECLARE_UPP(Contr