[261749]: libs / gtdrag / GTD_TreeHook.c Maximize Restore History

Download this file

GTD_TreeHook.c    217 lines (173 with data), 6.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Copyright Š1999-2008 pinc Software. All Rights Reserved.
* Licensed under the terms of the MIT License.
*/
//! Tree Render-Hook.
#include "gtdrag_includes.h"
#define TREE_SHOWFIRST /* show root-trees connected? */
static UBYTE sOpenedBitmap[] = {
0x00,0x00, // 0000 0000 0000 0000
0x00,0x00, // 0000 0000 0000 0000
0xff,0x80, // 1111 1111 1000 0000
0xff,0x00, // 0111 1111 0000 0000
0x3e,0x00, // 0011 1110 0000 0000
0x1c,0x00, // 0001 1100 0000 0000
0x08,0x00, // 0000 1000 0000 0000
};
static UBYTE sClosedBitmap[] = {
0x18,0x00, // 0001 1000 0000 0000
0x1e,0x00, // 0001 1110 0000 0000
0x1f,0x80, // 0001 1111 1000 0000
0xff,0xe0, // 1111 1111 1110 0000
0x1f,0x80, // 0001 1111 1000 0000
0x1e,0x00, // 0001 1110 0000 0000
0x18,0x00, // 0001 1000 0000 0000
};
ULONG PUBLIC
TreeHook(REG(a0, struct Hook *h), REG(a2, struct TreeNode *tn), REG(a1, struct LVDrawMsg *msg))
{
struct RastPort *rp;
struct Rectangle bounds;
UBYTE state;
ULONG apen,bpen,treecolor;
UWORD ow,i,cen,mid,wid,depth;
UWORD *pens;
if (msg->lvdm_MethodID != LV_DRAW)
return LVCB_UNKNOWN;
rp = msg->lvdm_RastPort;
state = msg->lvdm_State;
pens = msg->lvdm_DrawInfo->dri_Pens;
bounds = msg->lvdm_Bounds;
tn = TREENODE(tn);
treecolor = (LONG)h->h_Data;
apen = pens[FILLTEXTPEN];
bpen = pens[FILLPEN];
if ((state == LVR_NORMAL) || (state == LVR_NORMALDISABLED)) {
apen = pens[TEXTPEN];
bpen = pens[BACKGROUNDPEN];
}
SetAPen(rp, bpen);
wid = rp->Font->tf_YSize+2; cen = wid >> 1;
mid = (bounds.MinY+bounds.MaxY) >> 1;
#ifdef TREE_SHOWFIRST
depth = tn->tn_Depth + 1;
#else
depth = tn->tn_Depth;
#endif
for (i = 0; i < depth; i++) {
if (((1L << i) & tn->tn_DepthLines) || i == depth - 1) {
RectFill(rp, bounds.MinX, bounds.MinY, bounds.MinX + cen - 1, bounds.MaxY);
if (i == depth - 1) {
RectFill(rp,bounds.MinX+cen+1,bounds.MinY,bounds.MinX+wid-1,mid-1);
RectFill(rp,bounds.MinX+cen+1,mid+1,bounds.MinX+wid-1,bounds.MaxY);
if (tn->tn_Flags & TNF_LAST)
RectFill(rp,bounds.MinX+cen,mid+1,bounds.MinX+cen,bounds.MaxY);
} else
RectFill(rp,bounds.MinX+cen+1,bounds.MinY,bounds.MinX+wid-1,bounds.MaxY);
SetAPen(rp, treecolor);
if (i == depth - 1) {
Move(rp, bounds.MinX + cen, mid);
Draw(rp, bounds.MinX + wid - 1, mid);
}
Move(rp, bounds.MinX + cen, bounds.MinY);
if (i == depth-1 && tn->tn_Flags & TNF_LAST)
Draw(rp, bounds.MinX + cen, mid);
else
Draw(rp, bounds.MinX + cen, bounds.MaxY);
SetAPen(rp, bpen);
} else
RectFill(rp, bounds.MinX, bounds.MinY, bounds.MinX + wid - 1, bounds.MaxY);
bounds.MinX += wid;
}
if (tn->tn_Flags & TNF_CONTAINER) {
RectFill(rp, bounds.MinX, bounds.MinY, bounds.MinX + wid - 1, bounds.MaxY);
SetAPen(rp, treecolor);
#ifndef TREE_SHOWFIRST
if (tn->tn_Depth)
#endif
{
Move(rp,bounds.MinX, mid);
Draw(rp,bounds.MinX + cen - 5, mid);
}
//Move(rp,bounds.MinX + cen + 4, mid);
//Draw(rp,bounds.MinX + wid - 1, mid);
if (tn->tn_Flags & TNF_OPEN && !IsListEmpty((struct List *)&tn->tn_Nodes)) {
Move(rp, bounds.MinX + cen, mid + 4);
Draw(rp, bounds.MinX + cen, bounds.MaxY);
}
//SetAPen(rp,pens[SHINEPEN]);
//RectFill(rp,bounds.MinX+cen-2,mid-2,bounds.MinX+cen+2,mid+2);
SetABPenDrMd(rp, treecolor, bpen, JAM2);
// draw opened or closed rectangle
//DrawRect(rp,tn->tn_X = bounds.MinX+cen-3,tn->tn_Y = mid-3,TREEKNOBSIZE,TREEKNOBSIZE);
tn->tn_X = bounds.MinX + cen - 4;
tn->tn_Y = mid - 3;
if (!IsListEmpty((struct List *)&tn->tn_Nodes)) {
BltTemplate((PLANEPTR)(tn->tn_Flags & TNF_OPEN ? sOpenedBitmap : sClosedBitmap), 0, 2, rp, tn->tn_X, tn->tn_Y, 11, 7);
/* {
Move(rp,bounds.MinX+cen,mid-1);
Draw(rp,bounds.MinX+cen,mid+1);
}
Move(rp,bounds.MinX+cen-1,mid);
Draw(rp,bounds.MinX+cen+1,mid);*/
} else {
//RectFill(rp, tn->tn_X, mid - 2, bounds.MinX + cen + 2, mid + 2);
DrawRect(rp, tn->tn_X, mid - 2, 5, 5);
DrawRect(rp, tn->tn_X + 1, mid - 1, 3, 3);
}
tn->tn_Y -= bounds.MinY;
bounds.MinX += wid;
}
if (tn->tn_Node.in_Image) {
if ((state == LVR_NORMAL) || (state == LVR_NORMALDISABLED)) {
/*ow = min(tn->tn_Image->Width,itemwidth);*/
ow = min(tn->tn_Node.in_Image->Width,(bounds.MaxX-bounds.MinX) >> 1);
EraseRect(rp,bounds.MinX,bounds.MinY,bounds.MinX+2,bounds.MaxY);
SetAPen(rp,pens[SHADOWPEN]);
Move(rp,bounds.MinX+3,bounds.MaxY);
Draw(rp,bounds.MinX+ow+4,bounds.MaxY);
Draw(rp,bounds.MinX+ow+4,bounds.MinY);
SetAPen(rp,pens[SHINEPEN]);
Draw(rp,bounds.MinX+3,bounds.MinY);
Draw(rp,bounds.MinX+3,bounds.MaxY-1);
} else {
/*ow = min(tn->tn_Image->Width,itemwidth);*/
ow = min(tn->tn_Node.in_Image->Width,(bounds.MaxX-bounds.MinX) >> 1);
SetAPen(rp, bpen);
RectFill(rp,bounds.MinX,bounds.MinY,bounds.MinX+2,bounds.MaxY);
SetAPen(rp,pens[SHINEPEN]);
Move(rp,bounds.MinX+3,bounds.MaxY);
Draw(rp,bounds.MinX+ow+4,bounds.MaxY);
Draw(rp,bounds.MinX+ow+4,bounds.MinY);
SetAPen(rp,pens[SHADOWPEN]);
Draw(rp,bounds.MinX+3,bounds.MinY);
Draw(rp,bounds.MinX+3,bounds.MaxY-1);
}
if (ow >= tn->tn_Node.in_Image->Width)
DrawImage(rp,tn->tn_Node.in_Image,bounds.MinX+4,bounds.MinY+1);
else
EraseRect(rp,bounds.MinX+4,bounds.MinY+1,bounds.MinX+3+ow,bounds.MinY+tn->tn_Node.in_Image->Height);
if (bounds.MaxY-bounds.MinY-2 > tn->tn_Node.in_Image->Height) {
SetAPen(rp,pens[BACKGROUNDPEN]);
RectFill(rp,bounds.MinX+4,bounds.MinY+tn->tn_Node.in_Image->Height+1,bounds.MinX+3+ow,bounds.MaxY-1);
}
bounds.MinX += ow+5;
}
SetABPenDrMd(rp, tn->tn_Flags & TNF_HIGHLIGHTED ? pens[SHINEPEN] : apen, bpen, JAM2);
bounds.MinX += WriteHookText(rp, &bounds, tn->tn_Node.in_Name, bpen) + 4;
if (tn->tn_Flags & (TNF_ADD | TNF_REPLACE)) {
SetAPen(rp, treecolor);
RectFill(rp, tn->tn_X = bounds.MinX, tn->tn_Y = mid + 1, bounds.MinX + TREEKNOBSIZE, mid + TREEKNOBSIZE + 1);
tn->tn_Y -= bounds.MinY;
SetAPen(rp, bpen);
if (tn->tn_Flags & TNF_ADD) {
Move(rp, bounds.MinX + 3, mid + 2);
Draw(rp, bounds.MinX + 3, mid + 6);
}
Move(rp, bounds.MinX + 1, mid + 4);
Draw(rp, bounds.MinX + 5, mid + 4);
}
if ((state == LVR_NORMALDISABLED) || (state == LVR_SELECTEDDISABLED))
GhostRect(rp, pens[BLOCKPEN], msg->lvdm_Bounds.MinX, msg->lvdm_Bounds.MinY, msg->lvdm_Bounds.MaxX, msg->lvdm_Bounds.MaxY);
return LVCB_OK;
}