Page 1 of 1

Request for additional tag for page.gadget

Posted: Sun Dec 07, 2025 8:15 pm
by OldFart
Hi,

Would it be possible to add a tag to the page.gadget's array of tags?
Tag in question: PAGE_AddHead.
Functionally identical to PAGE_Add, with the difference that the specified page is added at the head of page.gadget's internal list, in contrast with PAGE_Add, where the page is added to the list's tail.
For reasons of consistency (and clarity) PAGE_Add could then have a synonym with PAGE_AddTail, this latter being not much more then an update of the SDK.

OldFart

Re: Request for additional tag for page.gadget

Posted: Tue Dec 09, 2025 9:17 am
by trixie
@OldFart

For a static building of pages in a layout, PAGE_AddHead doesn't make much sense, because you can always add to the top the page you want at the top :-) Dynamic page arrangement is a different story, but page.gadget seems to lack an API for that - something along the lines of the LM_ADDCHILD / LM_REMOVECHILD methods in layout.gadget.

Re: Request for additional tag for page.gadget

Posted: Wed Dec 10, 2025 8:42 pm
by OldFart
@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