@trixie,
In my recently published version of 'HexView', I have a.o. applied both a pag.gadget and a chooser.gadget, the latter controling the first. The chooser.gadget shows its labels in a fashion of the last label entered is at the top (head) of the list. However, to obtain congruency between both gadgets in terms of order of addition, I need to add pages at the top of the list.
Currently this code code is applied to achieve that goal:
Code: Select all
{
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_ChooseEntry, ACTIVEWOID), CHOOSER_Labels, (Tag)LABELS_DETACHED, TAG_END);
/*
** As adding a page to a page gadget allows only to
** do this at the page's internal list's tail,
** measurements have to be taken to circumvent this
** when pages have to be added at that list's head.
** This is achieved by first removing all existing
** pages from the gadget's list one-by-one and subsequently
** adding the new page at the list's tail, as that's the
** only possibility, and finally adding them at the
** list's tail again. This will effectively put the
** newly added page at the top of the list.
** Cumbersome, but hey! it works.
*/
{
struct EntryData *EntryData;
struct Node *ChooserNode = IExec->GetHead((__GD)->gd_ChooserList);
/*
** For starters, remove all existing pages
** from the page gadget's internal list:
** (Don't worry: they are restored later on
** from the Chooser's list...)
*/
while (ChooserNode != NULL)
{
IChooser->GetChooserNodeAttrs(ChooserNode, CNA_UserData, &EntryData, TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Remove, (Tag)EntryData->ed_PageObject, TAG_END);
ChooserNode = IExec->GetSucc(ChooserNode);
}
/*
** Now add the newly created ChooserNode to the chooser's
** list and subsequently the corresponding new page at
** the (tail of the) page gadget's internal list:
*/
ChooserNode = IExec->GetHead((__GD)->gd_ChooserList);
IExec->AddHead((__GD)->gd_ChooserList, (__ED)->ed_ChooserNode);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Add , (Tag)(__ED)->ed_PageObject
, PAGE_NoDispose, (Tag)TRUE
, TAG_END);
/*
** And finally restore the page gadget's list
** by adding all pages again at the list's tail:
*/
while (ChooserNode != NULL)
{
IChooser->GetChooserNodeAttrs(ChooserNode, CNA_UserData, (Tag)&EntryData, TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Add , (Tag)EntryData->ed_PageObject
, PAGE_NoDispose, (Tag)TRUE
, TAG_END);
ChooserNode = IExec->GetSucc(ChooserNode);
}
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_Page, ACTIVEWOID), PAGE_Current, (Tag)1, TAG_END);
ILayout->RethinkLayout (_SetGadTarget(GOID_Page, ACTIVEWOID), TRUE);
IIntuition->RefreshGList (_SetGadTarget(GOID_Page, ACTIVEWOID), 1);
}
(__GD)->gd_LabelCount++;
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_ChooseEntry, ACTIVEWOID), CHOOSER_Labels , (Tag)(__GD)->gd_ChooserList
, CHOOSER_Selected, (Tag)0
, GA_Disabled , (Tag)FALSE
, GA_HintInfo , (Tag)(__ED)->ed_HintInfo
, TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_NextEntry , ACTIVEWOID), GA_Disabled , (Tag)TRUE , TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_CurrentEntry, ACTIVEWOID), BUTTON_Integer, (Tag)1 , TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_RemEntry , ACTIVEWOID), GA_Disabled , (Tag)((__GD)->gd_LabelCount == 0) , TAG_END);
IIntuition->SetGadgetAttrs(_SetGadTarget(GOID_PrevEntry , ACTIVEWOID), GA_Disabled , (Tag)((__GD)->gd_LabelCount < 2) , TAG_END);
Success = TRUE;
}
_ElseError("Alloc ChooserNode");
Huge parts could be circumvented when pages could be added to the head of page.gadget's list, hence my request.
OldFart