Finding a page in a page gadget

7 posts / 0 new
Last post
OldFart
OldFart's picture
Offline
Last seen: 5 hours 50 min ago
Joined: 2010-11-30 14:09
Finding a page in a page gadget

Hi,

I plan on using a page gadget in an application and happen to grasp the inner workings of that gadget somehow.

What I would like to know, whether there is a method of retrieving a page's index, when that is not known from its address, by comparing that address with some internal list or array, until a match is found. Does layout.gadget maintain such a list or array?

Point is that two gadgets are somehow linked to eachother: one being a list, the other the page.gadget. Problem is that the sequence of entries in the list does not neccessarilly correspond with the sequence of pages in the page.gadget (due to some uncertain circumstances). It would even be a rather strange and noteworthy coincedence if it would.
What's more: entries from the list can be deleted and so should the corresponding page. Evenso: entries can be added to the list and a corresponding page need to be added. Due to the nature of the list entries, the pages need NOT be added in exactly the same sequence!

Ending up like this:
entry -- page
a 2
b 4
c 5
f 3
h 1

Is there somewhere some kind of an 'entry point' for the pages, from which by comparison of addresses the corresponding page index can be retrieved?

OldFart

thomas
thomas's picture
Offline
Last seen: 12 hours 37 min ago
Joined: 2011-05-16 14:23
I see no easy solution for

I see no easy solution for this. The autodocs for page.gadget are quite concise. There is obviously no access to the internal page list.

Best would be if the maintainer would add a PAGE_CurrentObject attribute which refers to the current page as an object pointer rather than a number (similar to LISTVIEW_SelectedNode).

Currently your only chance probably is to maintain your own list of page objects and numbers.

trixie
trixie's picture
Offline
Last seen: 5 months 9 hours ago
Joined: 2011-02-03 13:58
@OldFart So you use a

@OldFart

So you use a listbrowser to trigger pages, do I understand you right? You have listbrowser entries that correspond to respective pages, in an arbitrary order; if an entry is deleted, the corresponding page is deleted etc.

Would it be possible for you to create an array of Object pointers, each of which corresponding to the page.gadget's individual page layout? Then you could store the pointers, in any order you want, in the listbrowser list's individual LBNA_UserData fields. To access a page you'd then retrieve the page layout pointer from the list node's UserData, and act upon it:

  1. struct Node *listNode;
  2. Object *myPage;
  3.  
  4. IListBrowser->GetListBrowserNodeAttrs(listNode, LBNA_UserData, (uint32 *)&myPage);
  5.  
  6. /* "myPage" now points to your page layout */

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

OldFart
OldFart's picture
Offline
Last seen: 5 hours 50 min ago
Joined: 2010-11-30 14:09
@trixie I've been pondering

@trixie

I've been pondering that idea, but could not actually get my mind around it. However, by your depicting of the situation I might have the solution:
First establish a list structure (conversion list) (an array would not be appropriate as the number of entries is not known beforehand).
Then for every page added to the gadget a node, containing the Object's address, is added to the list: the physical position of the node tells the index of the page. (Not neccessarily true: This means that entries have to be Insert()-ed into the list (and Remove()-ed, for that matter).) No problem so far.
As you said add the Object's address into UserData field of the listgadget.
When looking for the page index related to a listgadget's entry, traverse the conversion list, whilst increasing an IndexCounter and comparing the value in UserData with the ones in the conversion list until a match is found, in which case the IndexCounter yields the proper PageIndex (or -1 in case of an error...)

Hm, doable and intriguing.

Thanks,

OldFart

trixie
trixie's picture
Offline
Last seen: 5 months 9 hours ago
Joined: 2011-02-03 13:58
Yes, the Exec list looks like

Yes, the Exec list looks like a neat solution. Let us know how it all worked.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

OldFart
OldFart's picture
Offline
Last seen: 5 hours 50 min ago
Joined: 2010-11-30 14:09
Hi Trixie! In a test set up

Hi Trixie!

In a test set up I got it to work like a charm!

I constructed a GUI with a chooser, a checkbox and a page.
The chooser shows a list of possible choices (remarkable, isn't it ;-)?).
Clicking the checkbox inverts the sequence of the chooserlist.
The page shows labels with the same text as is found in the chooser, so easy to verify the correct working.

No matter how many times i click the checkbox, whatever selection i make from the chooser, the corresponding page comes up!
So far it was quite easy-peasy, and I expect adding and deleting entries will not prove a huge issue.

Just to let you know. (PM-ed you as well)

OldFart

trixie
trixie's picture
Offline
Last seen: 5 months 9 hours ago
Joined: 2011-02-03 13:58
Glad to hear you got it

Glad to hear you got it working!

Using a chooser to flip layout pages is not very common, I wouldn't use it in my GUI: I personally consider it a GUI blooper. The chooser is supposed to work like the radiobutton, not like the clicktab. The chooser (= a more sophisticated version of the original cycle gadget) "should be used to set attributes, not trigger actions" (Amiga User Interface Style Guide, chapter 5).

It's much better a solution to use the listbrowser as page selector, if the clicktab is not an option.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments