Prima::...::Header(3)

πŸ“¦
version 1.74000 Β· 5 versions
, in opensuse-leap 16.0

πŸ’– Prima::...::Header(3) πŸ’–

okay bestie so this little gem is from the User Contributed Perl Documentation section of the Prima family β€” welcome to the header widget page, you're gonna love it here 🫢


✨ NAME ✨

Prima::Widget::Header β€” the multi-column header widget, and yes she is that girl πŸ‘‘


🌸 DESCRIPTION 🌸

So basically this widget class gives you the whole functionality of several button-like caption tabs, and the user can move them around and resize them. That's the whole vibe β€” draggable, resizable caption tabs, lowkey iconic πŸ’…

It was implemented to serve as a table header for list and grid widgets, which is honestly exactly what it sounds like: she's the crown on top of your table πŸ‘‘ iykyk


πŸ¦‹ API πŸ¦‹

πŸŽ€ Events

  • Click INDEX β€” gets called when the user clicks on the tab sitting pretty at position INDEX. simple as that, no cap ✨
  • DrawItem CANVAS, INDEX, X1, Y1, X2, Y2, TEXT_BASELINE β€” this is your callback to draw the tabs. CANVAS is the output object; INDEX is the index of a tab. X1,Y2,X2,Y2 are the coordinates of the boundaries of the tab rectangle; TEXT_BASELINE is a pre-calculated vertical position for eventual centered text output. literally handing you the baseline so your text can be centered and slay πŸ“πŸ’–
  • MeasureItem INDEX, RESULT β€” stores in the scalar referenced by RESULT the width or height (depending on the vertical property value) of the *INDEX*th tab, in pixels. yes, in pixels, always pixels πŸ“
  • MoveItem OLD_INDEX, NEW_INDEX β€” called when the user moves a tab from its old location, specified by OLD_INDEX, to the NEW_INDEX position. and here's the cute part: by the time of the call, all internal structures are already updated 🫢 so no stale data for you bestie
  • SizeItem INDEX, OLD_EXTENT, NEW_EXTENT β€” called when the user resizes a tab in the INDEXth position. OLD_EXTENT and NEW_EXTENT are either the width or height of the tab, depending on the vertical property value. glow-up documented πŸ“βœ¨
  • SizeItems β€” called when more than one tab changes its extent. and ngl this might happen as a result of both user and programmatic actions, so don't assume it's just the human 🫑

πŸ’œ Properties πŸ’œ

  • clickable BOOLEAN β€” selects whether the user is allowed to click the tabs. gatekeeping, but consensual πŸšͺ

Default value: 1

  • dragable BOOLEAN β€” selects whether the user is allowed to move the tabs. (yes the spelling is dragable, don't come for her, copy it exactly bestie πŸ™ˆ)

Default value: 1

  • items ARRAY β€” an array of scalars representing the internal data of the tabs. by default, the scalars are treated as text strings. but they're yours to fill with whatever πŸ’…
  • minTabWidth INTEGER β€” a minimal extent in pixels a tab must occupy. no tiny tabs allowed, she has standards πŸŽ€

Default value: 2

  • offset INTEGER β€” an offset on the major axis (depends on the vertical property value) that the widget is drawn with. used for the conjunction with list widgets (see Prima::DetailedList), when the list is horizontally or vertically scrolled. yes, this is the scroll-sync glue 🧚

Default value: 0

  • pressed INTEGER β€” contains the index of the currently pressed tab. a -1 value is selected when no tabs are pressed. chill mode = -1 😌

Default value: -1

  • scalable BOOLEAN β€” selects whether the user is allowed to resize the tabs. let her stretch πŸ’…

Default value: 1

  • vertical BOOLEAN β€” if 1, the tabs are aligned vertically; the offset, widths property, and extent parameters of the callback notification assume the heights of the tabs.

If 0, the tabs are aligned horizontally, and the extent properties and parameters assume tab widths.

so like: sideways mode = everything means height, normal mode = everything means width. pick your axis, bestie πŸ“

  • widths ARRAY β€” array of integer values, corresponding to the extents of the tabs. the extents are widths ("vertical" is 0) or heights ("vertical" is 1). yeah it's called widths even when they're heights, she's quirky like that πŸ’€

🧚 Methods 🧚

  • tab2offset INDEX β€” returns the offset of the *INDEX*th tab (without regard to the offset property value). note the disclaimer, it's important πŸ‘€
  • tab2rect INDEX β€” returns four integers representing the rectangle area occupied by the *INDEX*th tab (without regard to the offset property value). four integers, one beautiful rectangle 🌈

⭐ AUTHOR ⭐

Dmitry Karasik, <dmitry@karasik.eu.org>. king behavior, we stan πŸ‘‘


πŸ”₯ SEE ALSO πŸ”₯

Prima, Prima::Widget, Prima::DetailedList, examples/sheet.pl. go read those next, they're all friends πŸ’–


and that's the whole page, bestie β€” no details left behind, no facts invented 🫢

signed off with love from the manpage crew: perl v5.42.0, dated 2024-08-20 πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from