I'm trying to use listbrowser.gadget node pens to display different information state. However, I noticed that LBNCA_FGPen doesn't work as I expected. in SetListBrowserNodeAttrs autodoc there are following lines:
LBNCA_FGPen (int16)
LBNCA_BGPen (int16)
The pens to be used for rendering the text or integer in this
column. Requires that the LBFLG_CUSTOMPENS flag in LBNA_Flags
be specified otherwise the default system pens will be used.
Defaults to TEXTPEN and BACKGROUNDPEN.
In my example code below I would expect the 1st and 2nd listbrowser node would be of the same colour (pen TEXTPEN) but as the screenshot proves they are not. Have I understood something wrong
Code: Select all
/* listbrowser Example
gcc -o testlbpen testlbpen -lauto
quit
*/
/**
** Simple test for listbrowser LBNCA_FGPen
**/
#include <classes/window.h>
#include <gadgets/layout.h>
#include <gadgets/listbrowser.h>
[attachment=0]grab_290x255x24.jpg[/attachment]
#include <proto/intuition.h>
#include <proto/exec.h>
#include <proto/window.h>
#include <proto/listbrowser.h>
STRPTR nodetexts[] = {
"Node 1",
"Node 2",
"Node 3",
NULL
};
int main()
{
Object *winobj,*lbobj;
struct Window *win;
struct ColumnInfo *cinfos;
struct List lbnodes;
struct Node *node;
int i,pen;
cinfos = IListBrowser->AllocLBColumnInfo(1,
LBCIA_Column,0,
LBCIA_Title,"Test listbrowser",
TAG_DONE);
IExec->NewList(&lbnodes);
for (i = 0;nodetexts[i];i++)
{
if (node = IListBrowser->AllocListBrowserNode(1,
LBNA_Flags,LBFLG_CUSTOMPENS,
LBNA_Column,0,
LBNCA_Text,nodetexts[i],
TAG_DONE))
{
/* note: no pen set when i == 0 */
if (i == 1)
IListBrowser->SetListBrowserNodeAttrs(node,LBNA_Column,0,LBNCA_FGPen,TEXTPEN,TAG_DONE);
else
if (i == 2)
IListBrowser->SetListBrowserNodeAttrs(node,LBNA_Column,0,LBNCA_FGPen,DISABLEDTEXTPEN,TAG_DONE);
IExec->AddTail(&lbnodes,node);
}
}
winobj = IIntuition->NewObject(NULL, "window.class",
WA_Activate, TRUE,
WA_DepthGadget, TRUE,
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_Width,280,
WA_Height,200,
WA_Title,"Test ListBrowser node pens",
WINDOW_Layout, IIntuition->NewObject(NULL, "layout.gadget",
LAYOUT_AddChild, lbobj = IIntuition->NewObject(NULL, "listbrowser.gadget",
LISTBROWSER_ColumnInfo,cinfos,
LISTBROWSER_Labels,&lbnodes,
TAG_DONE),
TAG_DONE),
TAG_DONE);
if (winobj != NULL)
{
win = (struct Window *)IIntuition->IDoMethod(winobj, WM_OPEN);
if (win != NULL)
{
uint32 signal = 0;
BOOL done = FALSE;
IIntuition->GetAttr(WINDOW_SigMask, winobj, &signal);
while (!done)
{
uint32 wait = IExec->Wait(signal);
if ( wait & signal )
{
uint32 result = WMHI_LASTMSG;
int16 code = 0;
while ((result = IIntuition->IDoMethod(winobj, WM_HANDLEINPUT, &code)) != WMHI_LASTMSG)
{
switch (result & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
done = TRUE;
break;
}
}
}
}
}
IIntuition->DisposeObject(winobj);
}
IListBrowser->FreeListBrowserList(&lbnodes);
IListBrowser->FreeLBColumnInfo(cinfos);
}