• Moderator
    Kronos
    Posts: 2240 from 2003/2/24
    I'll try to explain it based the baseclass listview in MMamM :

    Code:


    static ULONG mNew(struct IClass *cl,Object *obj,struct opSet *msg)
    {
    struct Data *data,t;
    obj = (Object*)DoSuperNew(cl,obj,
    MUIA_List_DragType, MUIV_List_DragType_Immediate,
    MUIA_List_Title,TRUE,
    MUIA_List_Format, " MINWIDTH=60 BAR,MAXWIDTH=40",
    MUIA_List_ConstructHook,MUIV_List_ConstructHook_String,
    MUIA_List_DestructHook,MUIV_List_DestructHook_String,
    TAG_MORE,msg->ops_AttrList,
    TAG_DONE);
    if(obj)
    {
    data = (struct Data*)INST_DATA(cl,obj);

    *data = t;
    doset( obj, data, msg->ops_AttrList);
    }
    return (ULONG)obj;
    }


    The MUIA_List_Format tells MUI that I want a List with to columns seperated by a bar.
    Construct/DestructHooks makes sure that the entries get copied as strings instead of just passing a pointer.
    The tricky part here is that MUI will only maintain 1 object per row, be it a string or anything else and you need to decipher that into seperate strings for every column yourself.
    I decided here to merge both into 1 string, which will be seperated at display, allowing me to use MUIV_List_ConstructHook_String. If you use your own data object you'll need to do your own housekeeping.
    Code:


    static ULONG mDisplay(struct IClass *cl,Object *obj,struct MUIP_List_Display *msg)
    {
    struct TagItem *tstate, *tag;
    struct Data *data = (struct Data*)INST_DATA(cl,obj);
    if(msg->entry == 0)
    {
    *msg->array++ = "Method";
    *msg->array = "Class";
    }

    If msg->entry is 0 MUI want the strings for title of each column. (I did set MUIA_List_Title to true, remember)
    Code:

    else
    {
    static char classname[100];
    char *clend = classname;
    char *methodname = (char*) msg->entry;
    ULONG i = 0;
    while((!isspace(*methodname)&&(*methodname)))
    {
    *clend = *methodname;
    clend++;
    methodname++;
    }
    methodname++;
    *clend = 0;
    *msg->array++ = methodname;
    *msg->array = classname;
    }
    return 0;
    }



    Otherwise I sperate the stored string into 2 strings for that row.
    msg->array is a pointer to an array of STRPTRs, one for each column in your list.

    Offcourse you will need to add this to your dispather:
    Code:

    case MUIM_List_Display : return(mDisplay (cl,obj,(struct MUIP_List_Display *)msg));

  • »31.05.14 - 07:33
    Profile