home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:33:42-MDT,7771;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:33:32 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22305; Sat, 18 Jun 88 14:33:33 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24667; Sat, 18 Jun 88 14:33:30 MDT
- Date: Sat, 18 Jun 88 14:33:30 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182033.AA24667@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: ListMgrExample.c.shar
-
- #! /bin/sh
- #
- # This is a shell archive. Save this into a file, edit it
- # and delete all lines above this comment. Then give this
- # file to sh by executing the command "sh file". The files
- # will be extracted into the current directory owned by
- # you with default permissions.
- #
- # The files contained herein are:
- #
- # 2 ListMgrTest.c
- # 2 Listmgr.h
- # 2 listmgr.asm
- # 1 listmgr.voc
- #
- echo 'Extracting ListMgrTest.c'
- if test -f ListMgrTest.c; then echo 'shar: will not overwrite ListMgrTest.c'; else
- sed 's/^X//' << '________This_Is_The_END________' > ListMgrTest.c
- X/* List Manager test
- X Walter R. Smith, 21 April 1986
- X
- X This application is not actually linkable without my library
- X UILib, but it does illustrate the most-used List Manager calls.
- X
- X This puts a vertically-scrollable list of text in the window.
- X Double-clicking on an item deletes it from the list.
- X */
- X
- X#include <WindowMgr.h>
- X#include <EventMgr.h>
- X#include <UILib.h>
- X#include <ListMgr.h>
- X
- XHandle mymenus[1];
- XDoMenu() {}
- XDoKey() {}
- X
- XWindowRecord mywin;
- XListHandle mylist;
- X
- Xmyupdate(win)
- XWindowPeek win;
- X{
- X Rect box;
- X
- X box = (*mylist)->rView;
- X InsetRect(&box, -1, -1);
- X FrameRect(&box);
- X LUpdate(thePort->visRgn, mylist);
- X}
- X
- Xmyclose()
- X{
- X ExitToShell();
- X}
- X
- Xmyclick(win, where)
- XWindowPeek win;
- XPoint where;
- X{
- X long w;
- X
- X if (LClick(where, 0, mylist)) {
- X w = LLastClick(mylist);
- X LDelRow(1, (int) (w>>16), mylist);
- X InvalRect(&(*mylist)->rView);
- X }
- X}
- X
- Xmain()
- X{
- X Rect bounds, lbounds, databounds;
- X Point csize, cell;
- X int i;
- X static char *msgs[] = { "\pOranges", "\pLemons", "\pStrawberries",
- X "\pApples", "\pBananas", "\pT. S. Eliot", "\pKiwi", "\pPineapples",
- X "\pCoconut", "\pWatermelon" };
- X
- X InitBS();
- X
- X SetRect(&lbounds, 40, 40, 120, 40+5*15);
- X SetRect(&bounds, 40, 40, 180, 120+5*15);
- X BSNewWindow(&mywin, &bounds, "\pList Manager Test", 1, 0, 1,
- X 0L, myupdate, myclose, myclick, 0);
- X lbounds.right -= 15;
- X SetRect(&databounds, 0, 0, 1, 0);
- X csize.h = 150;
- X csize.v = 15;
- X mylist = LNew(&lbounds, &databounds, csize, 0, &mywin,
- X TRUE, TRUE, TRUE, TRUE);
- X LAddRow(10, 0, mylist);
- X cell.h = 0;
- X for (cell.v = 0; cell.v < 10; cell.v++)
- X LSetCell(msgs[cell.v]+1, (int) *msgs[cell.v], cell, mylist);
- X
- X while (1) BSOneEvent();
- X}
- ________This_Is_The_END________
- if test `wc -l < ListMgrTest.c` -ne 79; then
- echo 'shar: ListMgrTest.c was damaged during transit'
- echo ' (should have been 79 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting Listmgr.h'
- if test -f Listmgr.h; then echo 'shar: will not overwrite Listmgr.h'; else
- sed 's/^X//' << '________This_Is_The_END________' > Listmgr.h
- X/* List Manager definitions
- X Walter R. Smith, 21 April 1986
- X This code is hereby placed in the public domain.
- X */
- X
- X#ifndef _ListMgr_
- X#define _ListMgr_
- X
- X#ifndef _MacTypes_
- X#include "MacTypes.h"
- X#endif
- X
- X#ifndef _ControlMgr_
- X#include "ControlMgr.h"
- X#endif
- X
- X/* Masks for automatic scrolling */
- Xenum {
- X lDoHAutoScroll = 1,
- X lDoVAutoScroll
- X};
- X
- X/* Masks for selection flags */
- Xenum {
- X lNoNilHilite = 2,
- X lUseSense = 4,
- X lNoRect = 8,
- X lNoExtend = 16,
- X lNoDisjoint = 32,
- X lExtendDrag = 64,
- X lOnlyOne = 128
- X};
- X
- X/* Messages to list definition procedures */
- Xenum {
- X lInitMsg,
- X lDrawMsg,
- X lHiliteMsg,
- X lCloseMsg
- X};
- X
- Xtypedef Point Cell;
- Xtypedef char DataArray[32000];
- Xtypedef DataArray *DataPtr, **DataHandle;
- Xtypedef struct {
- X Rect rView;
- X GrafPtr port;
- X Point indent;
- X Point cellSize;
- X Rect visible;
- X ControlHandle vScroll;
- X ControlHandle hScroll;
- X Byte selFlags;
- X Byte lActive;
- X Byte lReserved;
- X Byte listFlags;
- X long clikTime;
- X Point clikLoc;
- X Point mouseLoc;
- X Ptr lClikLoop;
- X Cell lastClick;
- X long refCon;
- X Handle listDefProc;
- X Handle userHandle;
- X Rect dataBounds;
- X DataHandle cells;
- X int maxIndex;
- X int cellArray[1];
- X} ListRec;
- Xtypedef ListRec *ListPtr, **ListHandle;
- X
- Xextern pascal ListHandle LNew();
- Xextern pascal int LAddColumn(), LAddRow();
- Xextern pascal Boolean LGetSelect(), LClick(), LNextCell(), LSearch();
- Xextern pascal long LLastClick();
- Xextern pascal void LDispose(), LDelColumn(), LDelRow(), LAddToCell(),
- X LClrCell(), LGetCell(), LSetCell(), LCellSize(), LSetSelect(),
- X LFind(), LRect(), LSize(), LDraw(), LDoDraw(), LScroll(),
- X LAutoScroll(), LUpdate(), LActivate();
- X
- X#endif
- ________This_Is_The_END________
- if test `wc -l < Listmgr.h` -ne 81; then
- echo 'shar: Listmgr.h was damaged during transit'
- echo ' (should have been 81 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting listmgr.asm'
- if test -f listmgr.asm; then echo 'shar: will not overwrite listmgr.asm'; else
- sed 's/^X//' << '________This_Is_The_END________' > listmgr.asm
- X; List Manager support for LightspeedC
- X; Walter R. Smith, 21 April 1986
- X; This code is hereby placed in the public domain.
- X
- XXDEF LActivate, LAddColumn, LAddRow, LAddToCell, LAutoScroll, LCellSize
- XXDEF LClick, LClrCell, LDelColumn, LDelRow, LDispose, LDoDraw, LDraw
- XXDEF LFind, LGetCell, LGetSelect, LLastClick, LNew, LNextCell, LRect
- XXDEF LScroll, LSearch, LSetCell, LSetSelect, LSize, LUpdate
- X
- X .MACRO _DoCall
- X MOVE.W %1, D0
- X BRA PackIntf
- X .ENDM
- X
- XPackIntf
- X MOVE.L D3, -(SP) ; save this
- X MOVE.W D0, D3 ; so we can save this
- X MOVE.W #$1E7, D0 ; where is _Pack0?
- X DC.W $A146 ; _GetTrapAddress
- X MOVE.L D3, D0 ; get this back
- X MOVE.L (SP)+, D3 ; and restore the original D3
- X MOVE.L (SP)+, D1 ; get return address
- X MOVE.W D0, -(SP) ; push routine selector
- X MOVE.L D1, -(SP) ; push return address
- X JMP (A0) ; call _Pack0
- X
- XLActivate _DoCall #0
- XLAddColumn _DoCall #4
- XLAddRow _DoCall #8
- XLAddToCell _DoCall #12
- XLAutoScroll _DoCall #16
- XLCellSize _DoCall #20
- XLClick _DoCall #24
- XLClrCell _DoCall #28
- XLDelColumn _DoCall #32
- XLDelRow _DoCall #36
- XLDispose _DoCall #40
- XLDoDraw _DoCall #44
- XLDraw _DoCall #48
- XLFind _DoCall #52
- XLGetCell _DoCall #56
- XLGetSelect _DoCall #60
- XLLastClick _DoCall #64
- XLNew _DoCall #68
- XLNextCell _DoCall #72
- XLRect _DoCall #76
- XLScroll _DoCall #80
- XLSearch _DoCall #84
- XLSetCell _DoCall #88
- XLSetSelect _DoCall #92
- XLSize _DoCall #96
- XLUpdate _DoCall #100
- ________This_Is_The_END________
- if test `wc -l < listmgr.asm` -ne 52; then
- echo 'shar: listmgr.asm was damaged during transit'
- echo ' (should have been 52 bytes)'
- fi
- fi ; : end of overwriting check
- echo 'Extracting listmgr.voc'
- if test -f listmgr.voc; then echo 'shar: will not overwrite listmgr.voc'; else
- sed 's/^X//' << '________This_Is_The_END________' > listmgr.voc
- XLActivate
- XLAddColumn
- XLAddRow
- XLAddToCell
- XLAutoScroll
- XLCellSize
- XLClick
- XLClrCell
- XLDelColumn
- XLDelRow
- XLDispose
- XLDoDraw
- XLDraw
- XLFind
- XLGetCell
- XLGetSelect
- XLLastClick
- XLNew
- XLNextCell
- XLRect
- XLScroll
- XLSearch
- XLSetCell
- XLSetSelect
- XLSize
- XLUpdate
- ________This_Is_The_END________
- if test `wc -l < listmgr.voc` -ne 26; then
- echo 'shar: listmgr.voc was damaged during transit'
- echo ' (should have been 26 bytes)'
- fi
- fi ; : end of overwriting check
- exit 0
-