@Ponki1986, post #35
@sand, post #36
@sand, post #38
Co do podświetlania to musiłbym napisać nowy gadget bo listview, z tego co wiem nie obsługuje podświetlania.
@Hexmage960, post #39
@sand, post #40
@sand, post #43
Następne będą jak ogarnę poprawnie tego Hooka.
@Hexmage960, post #45
struct ExtNode { struct Node node; char *displayText; char *name; char *url; char *codec; char *country; int bitrate; }; static UWORD GhostPattern[2] = { 0x4444, 0x1111 }; static VOID Ghost(struct RastPort *rp, UWORD pen, UWORD x0, UWORD y0, UWORD x1, UWORD y1) { SetABPenDrMd(rp, pen, 0, JAM1); SetAfPt(rp, GhostPattern, 1); RectFill(rp, x0, y0, x1, y1); SetAfPt(rp, NULL, 0); } static ULONG RenderHook(register struct Hook *hook, register struct Node *node, register struct LVDrawMsg *msg) { struct RastPort *rp; struct DrawInfo *drawInfo; UWORD *pens; struct ExtNode *ext; char buffer[32]; WORD x, y, columnWidth; if (msg->lvdm_MethodID != LV_DRAW) return LVCB_UNKNOWN; rp = msg->lvdm_RastPort; drawInfo = msg->lvdm_DrawInfo; pens = drawInfo->dri_Pens; ext = (struct ExtNode *)node; if (!rp || !drawInfo || !ext) return LVCB_UNKNOWN; // Set up pens and drawing mode -( trying TEXTPEN not FILLTEXTPEN ) SetABPenDrMd(rp, pens[TEXTPEN], pens[BACKGROUNDPEN], JAM2); // Calculate column widths (divide space into 4 columns) columnWidth = (msg->lvdm_Bounds.MaxX - msg->lvdm_Bounds.MinX) / 4; // Clear the background SetAPen(rp, pens[BACKGROUNDPEN]); RectFill(rp, msg->lvdm_Bounds.MinX, msg->lvdm_Bounds.MinY, msg->lvdm_Bounds.MaxX, msg->lvdm_Bounds.MaxY); // Set text color SetAPen(rp, pens[FILLTEXTPEN]); // Draw vertical separators for (int i = 1; i < 4; i++) { x = msg->lvdm_Bounds.MinX + (columnWidth * i); Move(rp, x, msg->lvdm_Bounds.MinY); Draw(rp, x, msg->lvdm_Bounds.MaxY); } // Calculate vertical centering y = msg->lvdm_Bounds.MinY + ((msg->lvdm_Bounds.MaxY - msg->lvdm_Bounds.MinY - rp->TxHeight) / 2) + rp->TxBaseline; // Draw name if (ext->name) { Move(rp, msg->lvdm_Bounds.MinX + 4, y); Text(rp, ext->name, strlen(ext->name)); } // Draw codec if (ext->codec) { Move(rp, msg->lvdm_Bounds.MinX + columnWidth + 4, y); Text(rp, ext->codec, strlen(ext->codec)); } // Draw bitrate sprintf(buffer, "%ld kbps", ext->bitrate); Move(rp, msg->lvdm_Bounds.MinX + (columnWidth * 2) + 4, y); Text(rp, buffer, strlen(buffer)); // Draw country if (ext->country) { Move(rp, msg->lvdm_Bounds.MinX + (columnWidth * 3) + 4, y); Text(rp, ext->country, strlen(ext->country)); } // Ghost the item if disabled if (msg->lvdm_State == LVR_NORMALDISABLED || msg->lvdm_State == LVR_SELECTEDDISABLED) { Ghost(rp, pens[BLOCKPEN], msg->lvdm_Bounds.MinX, msg->lvdm_Bounds.MinY, msg->lvdm_Bounds.MaxX, msg->lvdm_Bounds.MaxY); } return LVCB_OK; } renderHook.h_Entry = *(HOOKFUNC)RenderHook; renderHook.h_SubEntry = NULL; renderHook.h_Data = NULL; listView = CreateGadget(LISTVIEW_KIND, searchButton, &ng, GTLV_Labels, site_labels, GTLV_ShowSelected, NULL, GTLV_CallBack, &renderHook, GTLV_ScrollWidth, 16, GTLV_ItemHeight, 12, GTLV_Selected, 0, GTLV_MaxPen, 255, GTLV_ReadOnly, FALSE, TAG_DONE);
@sand, post #46
h_SubEntry = (HOOKFUNC)RenderHook;
@Hexmage960, post #47
Procedura w języku C (która standardowo pobiera parametry ze stosu) powinna być podpięta pod h_SubEntry.W GCC można wykorzystać możliwość wskazania argumentom funkcji konkretnych rejestrów procesora. Jeżeli korzystamy z adresowania danych globalnych względem rejestru A4, (-fbaserel), to zamiast geta4 dodajemy funkcji atrybut __saveds__. Wtedy można funkcję dać jako h_Entry.
__saveds__ static ULONG RenderHook(struct Hook *hook asm("a2"), struct Node *node asm("a0"), struct LVDrawMsg *msg asm("a1"))
@Krashan, post #49
static ULONG RenderFunc(struct Hook *hook, struct Node *node, struct LVDrawMsg *msg) { geta4(); struct RastPort *rp; struct DrawInfo *drawInfo; UWORD *pens; struct ExtNode *ext; char buffer[32]; char nameBuffer[MAX_STATION_NAME + 1]; WORD x, y; WORD totalWidth; WORD nameWidth, codecWidth, bitrateWidth, countryWidth; UWORD bgColor, fgColor; if (!msg || msg->lvdm_MethodID != LV_DRAW) return LVCB_UNKNOWN; rp = msg->lvdm_RastPort; drawInfo = msg->lvdm_DrawInfo; pens = drawInfo->dri_Pens; ext = (struct ExtNode *)node; if (!rp || !drawInfo || !ext) return LVCB_UNKNOWN; // Set colors if (msg->lvdm_State == LVR_SELECTED || msg->lvdm_State == LVR_SELECTEDDISABLED) { bgColor = pens[FILLPEN]; fgColor = pens[FILLTEXTPEN]; } else { bgColor = pens[BACKGROUNDPEN]; fgColor = pens[TEXTPEN]; } // Set up pens and drawing mode SetABPenDrMd(rp, fgColor, bgColor, JAM2); // Calculate column widths totalWidth = msg->lvdm_Bounds.MaxX - msg->lvdm_Bounds.MinX; nameWidth = (totalWidth * 75) / 100; codecWidth = (totalWidth * 10) / 100; bitrateWidth = (totalWidth * 10) / 100; countryWidth = totalWidth - nameWidth - codecWidth - bitrateWidth; // Clear the background SetAPen(rp, bgColor); RectFill(rp, msg->lvdm_Bounds.MinX, msg->lvdm_Bounds.MinY, msg->lvdm_Bounds.MaxX, msg->lvdm_Bounds.MaxY); // Set text color SetAPen(rp, fgColor); // Draw vertical separators at new positions x = msg->lvdm_Bounds.MinX + nameWidth; Move(rp, x, msg->lvdm_Bounds.MinY); Draw(rp, x, msg->lvdm_Bounds.MaxY); x += codecWidth; Move(rp, x, msg->lvdm_Bounds.MinY); Draw(rp, x, msg->lvdm_Bounds.MaxY); x += bitrateWidth; Move(rp, x, msg->lvdm_Bounds.MinY); Draw(rp, x, msg->lvdm_Bounds.MaxY); // Calculate v. centering y = msg->lvdm_Bounds.MinY + ((msg->lvdm_Bounds.MaxY - msg->lvdm_Bounds.MinY - rp->TxHeight) / 2) + rp->TxBaseline; // Draw name if (ext->name) { cleanNonAscii(nameBuffer, ext->name, MAX_STATION_NAME + 1); Move(rp, msg->lvdm_Bounds.MinX + 4, y); Text(rp, nameBuffer, strlen(nameBuffer)); } // Draw codec if (ext->codec) { ULONG textLength = strlen(ext->codec); ULONG textWidth = TextLength(rp, ext->codec, textLength); Move(rp, msg->lvdm_Bounds.MinX + nameWidth + codecWidth - textWidth - 4, y); Text(rp, ext->codec, textLength); } // Draw bitrate sprintf(buffer, "%ld", ext->bitrate); ULONG textLength = strlen(buffer); ULONG textWidth = TextLength(rp, buffer, textLength); Move(rp, msg->lvdm_Bounds.MinX + nameWidth + codecWidth + bitrateWidth - textWidth - 4, y); Text(rp, buffer, textLength); // Draw country if (ext->country) { Move(rp, msg->lvdm_Bounds.MinX + nameWidth + codecWidth + bitrateWidth + 4, y); Text(rp, ext->country, strlen(ext->country)); } // Ghost if disabled if (msg->lvdm_State == LVR_NORMALDISABLED || msg->lvdm_State == LVR_SELECTEDDISABLED) { Ghost(rp, pens[BLOCKPEN], msg->lvdm_Bounds.MinX, msg->lvdm_Bounds.MinY, msg->lvdm_Bounds.MaxX, msg->lvdm_Bounds.MaxY); } return LVCB_OK; } I to renderhook dla listy renderHook.h_Entry = (HOOKFUNC)HookEntry; // Standard entry stub renderHook.h_SubEntry = (HOOKFUNC)RenderFunc;
@Krashan, post #49
@Ponki1986, post #53
#define LISTVIEWIDCMP (IDCMP_GADGETUP | IDCMP_GADGETDOWN |\ IDCMP_MOUSEMOVE | ARROWIDCMP)
@Hexmage960, post #54
Należy załączyć LISTVIEWIDCMP.
@sand, post #55