AmendHub

Download

cyberslak

/

lightsout

/

entity_ldef.c

 

(View History)

cyberslak   code cleanup Latest amendment: 23 on 2025-03-17

1 // SPDX-License-Identifier: MIT
2
3 #include <string.h>
4 #include "entity_ldef.h"
5 #include "entity.h"
6 #include "util.h"
7
8 pascal void
9 entity_ldef_proc(short message, Boolean selected, Rect *cellRect,
10 Cell theCell, short dataOffset, short dataLen,
11 ListHandle theList)
12 {
13 FontInfo info;
14 Handle cells = (**theList).cells;
15 struct entity* ent;
16 HLock(cells);
17
18 GetFontInfo(&info);
19
20 switch (message)
21 {
22 case lInitMsg:
23 break;
24 case lCloseMsg:
25 break;
26 case lDrawMsg:
27 if (dataLen > 0)
28 {
29 if (dataLen != sizeof(Ptr)) die("invalid dataLen %d", dataLen);
30 memcpy(&ent, (*cells) + dataOffset, dataLen);
31 EraseRect(cellRect);
32 MoveTo(cellRect->left + 2, cellRect->top + info.ascent);
33 DrawText(ent->state.name, 0, strlen(ent->state.name));
34 }
35 if (selected)
36 {
37 InvertRect(cellRect);
38 }
39 break;
40 case lHiliteMsg:
41 InvertRect(cellRect);
42 break;
43 }
44
45 HUnlock(cells);
46 }