d_list_proc(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’… d_list_proc(3) β€” bestie edition πŸ’…

okay so like, welcome to the Allegro manual, page for d_list_proc(3). this is the Allegro game programming library, and today we're talking about one specific little guy. sit down, get comfy, grab a strawberry πŸ“


✨ NAME ✨

d_list_proc β€” a dialog procedure that implements a list box object. yep, that's the whole vibe. Allegro game programming library, no cap. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int d_list_proc(int msg, DIALOG *d, int c);

look at that signature. iconic. no notes. ✨


🌸 DESCRIPTION 🌸

so bestie, d_list_proc is a list box object. the way that it works is it lets the user scroll through a whole list of items and pick one β€” either by clicking on it, or by using the arrow keys. very demure, very mindful. πŸ‘‘

and here's a lil something: if the D_EXIT flag is set, then double clicking on a list item will close the dialog. boom. done. exit stage left. πŸ’…

now, where does it keep track of stuff? listen up:

  • the index of the selected item lives in the d1 field.
  • the d2 field is used to store how far it has scrolled through the list.
  • the dp field points to a function, and that function gets called to obtain information about the contents of the list.

that function? it should follow this exact form, fr fr:

char *foobar(int index, int *list_size);

here's the tea on how that callback is supposed to behave:

  • if index is zero or positive, the function should return a pointer to the string that is to be displayed at position index in the list.
  • if index is negative, it should return NULL, and list_size should be set to the number of items in the list.

periodt. πŸŽ€


🌈 multiple selection listboxes 🌈

okay this part is giving main character energy, so pay attention. if you wanna create a multiple selection listbox, you set the dp2 field to an array of byte flags indicating the selection state of each list item β€” non-zero for selected entries. πŸ’š

⚠️ and this is the important bit, no skipping: that table must be at least as big as the number of objects in the list! like, do not play with this one. the table has to be big enough. fr fr. 😭

πŸ’œ SEE ALSO πŸ’œ

  • exgui(3) β€” go look, bestie 🫢

and that's the whole page! this little masterpiece came from the Allegro crew, version 4.4.3, and it's filed under d_list_proc(3). mwah, slay, go build something cute with it πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from