eudora-mac/statwin.c

1 line
9.8 KiB
C
Raw 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 "statwin.h" #define FILE_NUM 132 /* Copyright (c) 2000 by Qualcomm, Inc */ enum { kHeaderHeight = 30 }; typedef struct { MyWindowPtr win; Boolean inited; ControlHandle ctlHeader,ctlTimePeriod,ctlMore; PETEHandle pte; short timePeriod,more; } WinData; static WinData gWin; /************************************************************************ * prototypes ************************************************************************/ static Boolean StatClose(MyWindowPtr win); static void StatDidResize(MyWindowPtr win, Rect *oldContR); static void StatClick(MyWindowPtr win,EventRecord *event); static Boolean StatMenu(MyWindowPtr win, int menu, int item, short modifiers); static void StatZoomSize(MyWindowPtr win,Rect *zoom); static Boolean StatKey(MyWindowPtr win, EventRecord *event); /************************************************************************ * OpenStatWin - open statistics window ************************************************************************/ void OpenStatWin(void) { WindowPtr gWinWinWP; if (!HasFeature(featureStatistics)) return; if (SelectOpenWazoo(STAT_WIN)) return; // Already opened in a wazoo if (!gWin.inited) { short err=0; PETEDocInitInfo pi; if (!(gWin.win=GetNewMyWindow(STAT_WIND,nil,nil,BehindModal,false,false,STAT_WIN))) {err=MemError(); goto fail;} gWinWinWP = GetMyWindowWindowPtr(gWin.win); SetWinMinSize(gWin.win,-1,-1); SetPort_(GetWindowPort(gWinWinWP)); ConfigFontSetup(gWin.win); MySetThemeWindowBackground(gWin.win,kThemeListViewBackgroundBrush,False); // controls if (!(gWin.ctlHeader = GetNewControlSmall_(PLACARD_CNTL,gWinWinWP)) || !(gWin.ctlTimePeriod = GetNewControlSmall_(STAT_TIME_MENU_CNTL,gWinWinWP)) || !(gWin.ctlMore = GetNewControlSmall_(STAT_MORE_CNTL,gWinWinWP))) goto fail; EmbedControl(gWin.ctlTimePeriod,gWin.ctlHeader); EmbedControl(gWin.ctlMore,gWin.ctlHeader); SetControlValue(gWin.ctlTimePeriod,gWin.timePeriod = GetPrefLong(PREF_STAT_TIME_PERIOD)); if (gWin.timePeriod) gWin.timePeriod--; SetControlValue(gWin.ctlMore,gWin.more = GetPrefLong(PREF_STAT_MORE)); DefaultPII(gWin.win,true,peVScroll|peGrowBox,&pi); if (err=PeteCreate(gWin.win,&gWin.pte,0,&pi)) goto fail; CleanPII(&pi); PeteLock(gWin.pte,0,0x7fffffff,peModLock); PeteFocus(gWin.win,gWin.pte,true); gWin.win->dontControl = true; gWin.win->position = PositionPrefsTitle; gWin.wi