home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / cshar_li.sit < prev    next >
Encoding:
Text File  |  1988-06-20  |  7.3 KB  |  304 lines

  1. 18-Jun-88 14:33:42-MDT,7771;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:33:32 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA22305; Sat, 18 Jun 88 14:33:33 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA24667; Sat, 18 Jun 88 14:33:30 MDT
  8. Date: Sat, 18 Jun 88 14:33:30 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8806182033.AA24667@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: ListMgrExample.c.shar
  13.  
  14. #! /bin/sh
  15. #
  16. # This is a shell archive.  Save this into a file, edit it
  17. # and delete all lines above this comment.  Then give this
  18. # file to sh by executing the command "sh file".  The files
  19. # will be extracted into the current directory owned by
  20. # you with default permissions.
  21. #
  22. # The files contained herein are:
  23. #
  24. #    2 ListMgrTest.c
  25. #    2 Listmgr.h
  26. #    2 listmgr.asm
  27. #    1 listmgr.voc
  28. #
  29. echo 'Extracting ListMgrTest.c'
  30. if test -f ListMgrTest.c; then echo 'shar: will not overwrite ListMgrTest.c'; else
  31. sed 's/^X//' << '________This_Is_The_END________' > ListMgrTest.c
  32. X/*    List Manager test
  33. X    Walter R. Smith, 21 April 1986
  34. X    
  35. X    This application is not actually linkable without my library
  36. X    UILib, but it does illustrate the most-used List Manager calls.
  37. X    
  38. X    This puts a vertically-scrollable list of text in the window.
  39. X    Double-clicking on an item deletes it from the list.
  40. X */
  41. X
  42. X#include <WindowMgr.h>
  43. X#include <EventMgr.h>
  44. X#include <UILib.h>
  45. X#include <ListMgr.h>
  46. X
  47. XHandle mymenus[1];
  48. XDoMenu() {}
  49. XDoKey() {}
  50. X
  51. XWindowRecord mywin;
  52. XListHandle mylist;
  53. X
  54. Xmyupdate(win)
  55. XWindowPeek win;
  56. X{
  57. X    Rect box;
  58. X    
  59. X    box = (*mylist)->rView;
  60. X    InsetRect(&box, -1, -1);
  61. X    FrameRect(&box);
  62. X    LUpdate(thePort->visRgn, mylist);
  63. X}
  64. X
  65. Xmyclose()
  66. X{
  67. X    ExitToShell();
  68. X}
  69. X
  70. Xmyclick(win, where)
  71. XWindowPeek win;
  72. XPoint where;
  73. X{
  74. X    long w;
  75. X    
  76. X    if (LClick(where, 0, mylist)) {
  77. X        w = LLastClick(mylist);
  78. X        LDelRow(1, (int) (w>>16), mylist);
  79. X        InvalRect(&(*mylist)->rView);
  80. X    }
  81. X}
  82. X
  83. Xmain()
  84. X{
  85. X    Rect bounds, lbounds, databounds;
  86. X    Point csize, cell;
  87. X    int i;
  88. X    static char *msgs[] = { "\pOranges", "\pLemons", "\pStrawberries",
  89. X        "\pApples", "\pBananas", "\pT. S. Eliot", "\pKiwi", "\pPineapples",
  90. X        "\pCoconut", "\pWatermelon" };
  91. X    
  92. X    InitBS();
  93. X    
  94. X    SetRect(&lbounds, 40, 40, 120, 40+5*15);
  95. X    SetRect(&bounds, 40, 40, 180, 120+5*15);
  96. X    BSNewWindow(&mywin, &bounds, "\pList Manager Test", 1, 0, 1,
  97. X        0L, myupdate, myclose, myclick, 0);
  98. X    lbounds.right -= 15;
  99. X    SetRect(&databounds, 0, 0, 1, 0);
  100. X    csize.h = 150;
  101. X    csize.v = 15;
  102. X    mylist = LNew(&lbounds, &databounds, csize, 0, &mywin,
  103. X        TRUE, TRUE, TRUE, TRUE);
  104. X    LAddRow(10, 0, mylist);
  105. X    cell.h = 0;
  106. X    for (cell.v = 0; cell.v < 10; cell.v++)
  107. X        LSetCell(msgs[cell.v]+1, (int) *msgs[cell.v], cell, mylist);
  108. X    
  109. X    while (1) BSOneEvent();
  110. X}
  111. ________This_Is_The_END________
  112. if test `wc -l < ListMgrTest.c` -ne 79; then
  113.     echo 'shar: ListMgrTest.c was damaged during transit'
  114.   echo '      (should have been 79 bytes)'
  115. fi
  116. fi        ; : end of overwriting check
  117. echo 'Extracting Listmgr.h'
  118. if test -f Listmgr.h; then echo 'shar: will not overwrite Listmgr.h'; else
  119. sed 's/^X//' << '________This_Is_The_END________' > Listmgr.h
  120. X/*    List Manager definitions
  121. X    Walter R. Smith, 21 April 1986
  122. X    This code is hereby placed in the public domain.
  123. X */
  124. X
  125. X#ifndef _ListMgr_
  126. X#define _ListMgr_
  127. X
  128. X#ifndef _MacTypes_
  129. X#include "MacTypes.h"
  130. X#endif
  131. X
  132. X#ifndef _ControlMgr_
  133. X#include "ControlMgr.h"
  134. X#endif
  135. X
  136. X/* Masks for automatic scrolling */
  137. Xenum {
  138. X    lDoHAutoScroll = 1,
  139. X    lDoVAutoScroll
  140. X};
  141. X
  142. X/* Masks for selection flags */
  143. Xenum {
  144. X    lNoNilHilite = 2,
  145. X    lUseSense = 4,
  146. X    lNoRect = 8,
  147. X    lNoExtend = 16,
  148. X    lNoDisjoint = 32,
  149. X    lExtendDrag = 64,
  150. X    lOnlyOne = 128
  151. X};
  152. X
  153. X/* Messages to list definition procedures */
  154. Xenum {
  155. X    lInitMsg,
  156. X    lDrawMsg,
  157. X    lHiliteMsg,
  158. X    lCloseMsg
  159. X};
  160. X
  161. Xtypedef Point Cell;
  162. Xtypedef char DataArray[32000];
  163. Xtypedef DataArray *DataPtr, **DataHandle;
  164. Xtypedef struct {
  165. X    Rect rView;
  166. X    GrafPtr port;
  167. X    Point indent;
  168. X    Point cellSize;
  169. X    Rect visible;
  170. X    ControlHandle vScroll;
  171. X    ControlHandle hScroll;
  172. X    Byte selFlags;
  173. X    Byte lActive;
  174. X    Byte lReserved;
  175. X    Byte listFlags;
  176. X    long clikTime;
  177. X    Point clikLoc;
  178. X    Point mouseLoc;
  179. X    Ptr lClikLoop;
  180. X    Cell lastClick;
  181. X    long refCon;
  182. X    Handle listDefProc;
  183. X    Handle userHandle;
  184. X    Rect dataBounds;
  185. X    DataHandle cells;
  186. X    int maxIndex;
  187. X    int cellArray[1];
  188. X} ListRec;
  189. Xtypedef ListRec *ListPtr, **ListHandle;
  190. X
  191. Xextern pascal ListHandle LNew();
  192. Xextern pascal int LAddColumn(), LAddRow();
  193. Xextern pascal Boolean LGetSelect(), LClick(), LNextCell(), LSearch();
  194. Xextern pascal long LLastClick();
  195. Xextern pascal void LDispose(), LDelColumn(), LDelRow(), LAddToCell(),
  196. X    LClrCell(), LGetCell(), LSetCell(), LCellSize(), LSetSelect(), 
  197. X    LFind(), LRect(), LSize(), LDraw(), LDoDraw(), LScroll(),
  198. X    LAutoScroll(), LUpdate(), LActivate();
  199. X
  200. X#endif
  201. ________This_Is_The_END________
  202. if test `wc -l < Listmgr.h` -ne 81; then
  203.     echo 'shar: Listmgr.h was damaged during transit'
  204.   echo '      (should have been 81 bytes)'
  205. fi
  206. fi        ; : end of overwriting check
  207. echo 'Extracting listmgr.asm'
  208. if test -f listmgr.asm; then echo 'shar: will not overwrite listmgr.asm'; else
  209. sed 's/^X//' << '________This_Is_The_END________' > listmgr.asm
  210. X; List Manager support for LightspeedC
  211. X; Walter R. Smith, 21 April 1986
  212. X; This code is hereby placed in the public domain.
  213. X
  214. XXDEF LActivate, LAddColumn, LAddRow, LAddToCell, LAutoScroll, LCellSize
  215. XXDEF LClick, LClrCell, LDelColumn, LDelRow, LDispose, LDoDraw, LDraw
  216. XXDEF LFind, LGetCell, LGetSelect, LLastClick, LNew, LNextCell, LRect
  217. XXDEF LScroll, LSearch, LSetCell, LSetSelect, LSize, LUpdate
  218. X
  219. X    .MACRO    _DoCall
  220. X    MOVE.W    %1, D0
  221. X    BRA    PackIntf
  222. X    .ENDM
  223. X    
  224. XPackIntf
  225. X    MOVE.L    D3, -(SP)    ; save this
  226. X    MOVE.W    D0, D3        ; so we can save this
  227. X    MOVE.W    #$1E7, D0    ; where is _Pack0?
  228. X    DC.W    $A146        ; _GetTrapAddress
  229. X    MOVE.L    D3, D0        ; get this back
  230. X    MOVE.L    (SP)+, D3    ; and restore the original D3
  231. X    MOVE.L    (SP)+, D1    ; get return address
  232. X    MOVE.W    D0, -(SP)    ; push routine selector
  233. X    MOVE.L    D1, -(SP)    ; push return address
  234. X    JMP    (A0)        ; call _Pack0
  235. X
  236. XLActivate    _DoCall #0
  237. XLAddColumn    _DoCall #4
  238. XLAddRow        _DoCall #8
  239. XLAddToCell    _DoCall #12
  240. XLAutoScroll    _DoCall #16
  241. XLCellSize    _DoCall #20
  242. XLClick        _DoCall #24
  243. XLClrCell    _DoCall #28
  244. XLDelColumn    _DoCall #32
  245. XLDelRow        _DoCall #36
  246. XLDispose    _DoCall #40
  247. XLDoDraw        _DoCall #44
  248. XLDraw        _DoCall #48
  249. XLFind        _DoCall #52
  250. XLGetCell    _DoCall #56
  251. XLGetSelect    _DoCall #60
  252. XLLastClick    _DoCall #64
  253. XLNew        _DoCall #68
  254. XLNextCell    _DoCall #72
  255. XLRect        _DoCall #76
  256. XLScroll        _DoCall #80
  257. XLSearch        _DoCall #84
  258. XLSetCell    _DoCall #88
  259. XLSetSelect    _DoCall #92
  260. XLSize        _DoCall #96
  261. XLUpdate        _DoCall #100
  262. ________This_Is_The_END________
  263. if test `wc -l < listmgr.asm` -ne 52; then
  264.     echo 'shar: listmgr.asm was damaged during transit'
  265.   echo '      (should have been 52 bytes)'
  266. fi
  267. fi        ; : end of overwriting check
  268. echo 'Extracting listmgr.voc'
  269. if test -f listmgr.voc; then echo 'shar: will not overwrite listmgr.voc'; else
  270. sed 's/^X//' << '________This_Is_The_END________' > listmgr.voc
  271. XLActivate
  272. XLAddColumn
  273. XLAddRow
  274. XLAddToCell
  275. XLAutoScroll
  276. XLCellSize
  277. XLClick
  278. XLClrCell
  279. XLDelColumn
  280. XLDelRow
  281. XLDispose
  282. XLDoDraw
  283. XLDraw
  284. XLFind
  285. XLGetCell
  286. XLGetSelect
  287. XLLastClick
  288. XLNew
  289. XLNextCell
  290. XLRect
  291. XLScroll
  292. XLSearch
  293. XLSetCell
  294. XLSetSelect
  295. XLSize
  296. XLUpdate
  297. ________This_Is_The_END________
  298. if test `wc -l < listmgr.voc` -ne 26; then
  299.     echo 'shar: listmgr.voc was damaged during transit'
  300.   echo '      (should have been 26 bytes)'
  301. fi
  302. fi        ; : end of overwriting check
  303. exit 0
  304.