eudora-mac/table.c

1 line
34 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 "table.h" #define FILE_NUM 102 /* Copyright (c) 2000 by QUALCOMM Incorporated */ #pragma segment Table static Boolean EditingTable(MyWindowPtr win); static OSErr InsertTable(MyWindowPtr win,TIHandle table); static void MakeTable(MyWindowPtr win); static void TableDisplay(PETEHandle pte,TIHandle table,long offset); static void SizeTable(PETEHandle pte,TIHandle tableInfo,short maxWidth); static short **GetColWidths(PETEHandle pte,TIHandle tableInfo,short *sumWidths,short tableWidth,Boolean tableWidthSpecified); static short **GetRowHeights(PETEHandle pte,TIHandle tableInfo,short *sumHeights,short **hColWidths); static void SetCellBounds(PETEHandle pte,TableHandle table,short **hColWidths,short **hRowHeights); static short GetCellWidth(PETEHandle pte,TIHandle tableInfo,short cellIdx); static short GetCellHeight(PETEHandle pte,TIHandle tableInfo,short cellIdx,short colWidth); static OSErr SetCellText(PETEHandle pte,TIHandle tableInfo,short cellIdx,short cellWidth); static OSErr TableClone(TableHandle *table); static void CloneHandle(Handle *pHand,OSErr *pErr); RgnHandle SavePeteWinUpdateRgn(PETEHandle pte); void RestorePeteWinUpdateRgn(PETEHandle pte,RgnHandle rgn); static OSErr CreateSparePETE(MyWindowPtr win,PETEHandle *pte); static OSErr ResetCellStyle(TIHandle tableInfo, short cellIdx); /************************************************************************ * MakeTableGraphic - make a table, insert as graphic ************************************************************************/ OSErr MakeTableGraphic(PETEHandle pte,long offset,TableHandle table,PETEStyleEntryPtr pse) { TIHandle hTableInfo; OSErr err = noErr; PETEHandle pteSpare; MyWindowPtr win = (*PeteExtra(pte))->win; if (!(hTableInfo = NuHandleClear(sizeof(TableInfo)))) return MemError(); (*hTableInfo)->pgi.itemProc = TableGraphic; (*hTableInfo)->pgi.wantsEvents = true; (*hTableInfo)->table = table; (*hTableInfo)->offset = offset; // make a PETEHandle to measure, draw cells if (err = CreateSparePETE(win,&pteSpare)) return err; (*hTableInfo)->pteSpare = pteSpare; SizeTable(pte,hTableInfo,RectWi(win->contR)); Zero(*pse); pse->psGraphic = 1; pse->psStyle.graphicStyle.tsFont = kPETEDefaultFont; pse->psStyle.graphicStyle.tsSize = kPETERelativeSizeBase; pse->psStyle.graphicStyle.graphicInfo = (PETEGraphicInfoHandle)hTableInfo; return(err); } /****************************************************