Tabbed Gadget Class
Introduction
Tabbed is a Gadget Class used to create a tabbed bar. It is available for both Release V46 and Release V54.
It has some features such as:
- sliding/dragging of tabs by holding down left mouse button over the selected tab and move mouse
- dynamic opening and closing of tabs with an application
- custom tab close gadget
- custom tab fonts and colours
- optional bar which runs underneath tabs
- help pop-up hint tips when hovering mouse pointer over tab
- The active/inactive tab background can be filled with a custom image or gradient
Installation
Manual installation:
Copy the file tabbed.gadget to SYS:Classes/Gadgets/ directory |
Developer Documentation
Software Development Kit (SDK):
The include files, examples source code and developer documentation are included in the SDK drawer. |
Datasheet
- NAME
- tabbed.gadget -- Create a tabbed bar
- SUPERCLASS
- gadgetclass
- REQUIRES
- DESCRIPTION
- The tabbed gadget class is used to create a clickable bar with a variable number of tabs (like index cards).
Supported methods
Method ID | Description |
---|---|
OM_NEW | Passed to superclass, defaults set, then OM_SET. |
OM_SET | Passed to superclass, custom tags set. Calls GM_RENDER if gps_GInfo is supplied. |
OM_GET | Custom tag returned or passed to superclass. |
OM_UPDATE | Same as OM_SET |
OM_NOTIFY | Tag set then passed to superclass. |
OM_DISPOSE | Free all TabbedNodes and all temporary gfx memory, then passed to superclass. |
GM_RENDER | Render tab bar. |
GM_HITTEST | Checks which tab was hit and returns GMR_GADGETHIT if one was hit. |
GM_GOACTIVE | Re-renders the tab bar with the new active tab highlighted. |
GM_HANDLEINPUT | Processes input. If the clicked tab was inactive, it acts like a button and becomes active if the mouse button was released over it. If the clicked tab was the active one, it can be dragged left or right. |
GM_GOINACTIVE | Re-renders the tab bar with the new active tab highlighted. |
GM_DOMAIN | Returns the required dimensions matching the value in gpd_Which. |
GM_LAYOUT | calculates the size and position of each tab relative to the total space given. |
TGM_ADDTAB | Inserts a new tab with the given labal and flags at the given position. Returns a pointer to the TabbedNode of the new tab or NULL in case of failure. Calls GM_RENDER if tgp_GInfo is supplied. |
TGM_REMTAB | Removes the tab at the given position and frees the TabbedNode.Calls GM_RENDER if tgp_GInfo is supplied. |
TGM_MOVETAB | Moves the tab at the given position to the new position. Calls GM_RENDER if tgp_GInfo is supplied. |
TGM_ADDNODE | Inserts a new tab before the given successor TabbedNode. If tgp_Succ is NULL the new tab is added to the end of the list. Returns a pointer to the TabbedNode of the new tab or NULL in case of failure. Calls GM_RENDER if tgp_GInfo is supplied. |
TGM_REMNODE | Removes the given TabbedNode and frees its memory.Calls GM_RENDER if tgp_GInfo is supplied. |
TGM_MOVENODE | Removes the given TabbedNode and inserts it back before the new successor. Calls GM_RENDER if tgp_GInfo is supplied. |
ATTRIBUTES
- GA_BackFill (struct Hook *)
- REACTION_BackFill
- GM_RENDER installs the given backfill hook before doing it's rendering
- Applicability is (OM_NEW, OM_SET, OM_UPDATE)
- TABBED_Labels (STRPTR *)
- A NULL-terminated array of string pointers. Replaces all tabs.
- The previous tab list is freed. Each string in the array gives
- a new tab. The tbn_ID field of each tab is initialized with a
- sequential number starting at 0 for the first tab.
- Applicability is (OM_NEW, OM_SET, OM_UPDATE)
- TABBED_Underscore (ULONG)
- Like GT_Underscore: enables underscoring of single characters in
- tab labels. The first letter in each label which is preceded by
- the given character is drawn with an underscore. Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_UPDATE)
- TABBED_Active (ULONG)
- Sets or returns the place number of the currently active tab.
- -1 means no tab is active. Defaults to -1.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE, OM_NOTIFY)
- TABBED_ActiveNode (struct TabbedNode *)
- Sets or returns a pointer to the TabbedNode of the currently
- active tab. Defaults to NULL.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE, OM_NOTIFY)
- TABBED_ActiveID (ULONG)
- When a new tab becomes active, the ICA_TARGET is notifed with
- this tag. Contains the tbn_ID of the active TabbedNode or -1
- if no tab is active. Defaults to -1.
- Applicability is (OM_NOTIFY)
- TABBED_Skew (ULONG)
- Sets or returns the level of skewing. For rounded corners it
- defines the radius of the rounding. Defaults to 8.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_Rounded (BOOL)
- Selects whether the tabs have rounded corners (TRUE) or are
- skewed squares (FALSE). Defaults to FALSE.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_Font (struct TextFont *)
- Sets the font used by tab labels. Defaults to the screen font.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_MinWidth (ULONG)
- Minimum width of each tab. Useful when using TBNF_NameIsHook
- because the hook does not have a width or if the labels are
- very short. Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_MaxWidthPercent (ULONG)
- Limit the width of each tab to the given percentage of the gadget
- width. Valid values are between 10 and 100. Defaults to 50.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_EvenSize (BOOL)
- Tells the tab bar to use the same size for each tab. The minimum
- size for all tabs is that of the tab with the longest label.
- When set to FALSE, each tab can have a different size depending on
- its label and whether it has a close button. Results might vary.
- Defaults to TRUE.
- V54: defaults to FALSE if CLICKTAB_EVENWIDTH is not set in GUI
- attrs and GA_DrawInfo is given to OM_NEW.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_AllowDragging (BOOL)
- Selects whether tabs can be reordered by dragging the active tab
- with the mouse (TRUE) or not (FALSE). Defaults to FALSE.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_FirstNode (struct TabbedNode *)
- Returns a pointer to the TabbedNode of the first tab in the list.
- Returns NULL if there are no tabs.
- Applicability is (OM_GET)
- TABBED_LastNode (struct TabbedNode *)
- Returns a pointer to the TabbedNode of the last tab in the list.
- Returns NULL if there are no tabs.
- Applicability is (OM_GET)
- TABBED_TabMovedFrom (ULONG)
- TABBED_TabMovedTo (ULONG)
- If the user has dragged a tab to a new position, the ICA_TARGET
- is notified with these tags.
- Note that only the active tab can be dragged. So if you receive
- an update with these tags, you can get the TABBED_ActiveNode
- attribute to find out details about the dragged node.
- Applicability is (OM_NOTIFY)
- TABBED_SmallWidth (ULONG)
- Like TABBED_MinWidth, but for tabs with TBNF_SmallTab set.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_Pens (UWORD *)
- Points to an array of pen numbers. The entries match those in
- the dri_Pens field of struct DrawInfo (see intuition/screens.h).
- The array does not need to be terminated, but it must contain
- all these entries:
- SHINEPEN -> bright edges of the border surrounding each tab
- SHADOWPEN -> dark edges and shadow of the active tab's label
- HIGHLIGHTTEXTPEN -> label of the active tab
- FILLTEXTPEN -> label of a tab when the user clicks on it
- TEXTPEN -> label of all other tabs
- DETAILPEN -> background of the active tab
- FILLPEN -> background of a tab when the user clicks on it
- BACKGROUNDPEN -> background of all other tabs
- HIGHLIGHTTEXTPEN is the highest index which means the array must
- contain at least 9 entries.
- If set to NULL the pens from the screen the GUI runs on are used.
- Defaults to NULL.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_CloseImage (struct Image *)
- Sets the image used for nodes with the TBNF_HasCloseButton flag
- set. A BOOPSI image is preferred. If not set it defaults to a
- small round button with a cross in it.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_CloseImagePens (UWORD *)
- This tag is forwarded to the TABBED_CloseImage object as IA_Pens.
- Points to an array of pen numbers. The entries match those in
- the dri_Pens field of struct DrawInfo (see intuition/screens.h).
- For the default close button image the array does not need to be
- terminated, but it must contain all these entries:
- FILLPEN -> the area inside the button
- SHINEPEN -> the bright edges of the outer border and
- the inner of the cross if not selected
- SHADOWPEN -> the dark edges of the outer border and
- the outer of the cross
- BACKGROUNDPEN -> the inner of the cross when selected
- BACKGROUNDPEN is the highest index which means the array must
- contain at least 8 entries.
- If set to NULL the pens from the screen the GUI runs on are used.
- Defaults to NULL.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_ClosedTab (ULONG)
- TABBED_ClosedNode (struct TabbedNode *)
- TABBED_ClosedID (ULONG)
- When the close button of a tab was clicked by the user, the
- ICA_TARGET will be notified about these tags.
- TABBED_ClosedTab is the place in the list of the clicked tab.
- TABBED_ClosedNode is the TabbedNode of the clicked tab.
- TABBED_ClosedID is the tbn_ID of the clicked tab.
- Applicability is (OM_GET, OM_NOTIFY)
- TABBED_ClickedTab (ULONG)
- TABBED_ClickedNode (struct TabbedNode *)
- TABBED_ClickedID (ULONG)
- When a tab with the TBNF_DontActivate flag set was clicked by the
- user, the ICA_TARGET will be notified about these tags.
- TABBED_ClickedTab is the place in the list of the clicked tab.
- TABBED_ClickedNode is the TabbedNode of the clicked tab.
- TABBED_ClickedID is the tbn_ID of the clicked tab.
- Applicability is (OM_GET, OM_NOTIFY)
- TABBED_BarHeight (ULONG)
- Determines the height of a bar which is drawn below the row of
- tabs in the color of the active tab. If set to 0, no bar is drawn.
- Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_GadgetHelpCode (ULONG)
- Specifies what tabbed.gadget should return from a GM_HELPTEST
- method call. Currently the following values are supported:
- 0 - returns the place of the tab the mouse is over.
- 1 - returns the tbn_ID of the tab the mouse is over.
- Any other value will cause it to return GMR_HELPHIT.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_HintInfoHook (struct Hook *)
- This hook is called by the GM_QUERY method if the mouse hovers
- over a tab. Defaults to NULL.
- result = info_hook (hook, tab, msg);
- D0 A0 A2 A1
- CONST_STRPTR result -> hint text to be displayed
- struct Hook *hook;
- struct TabbedNode *tab;
- struct qpQuery *msg;
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_TabBackFill (struct Hook *)
- Backfill hook for normal (not active) tabs.
- Set this to TABBED_BACKFILL_GRADIENT to get a gradient in the
- background. Gradients are only drawn on truecolor RTG screens
- (16 bits or more).
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_ActiveBackFill (struct Hook *)
- Backfill hook for the active tab.
- Set this to TABBED_BACKFILL_GRADIENT to get a gradient in the
- background. Gradients are only drawn on truecolor RTG screens
- (16 bits or more).
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_AlignLabel (LONG)
- Define the alignment of standard labels in tabs. Valid values are:
- -1 left justified
- 0 centered
- 1 right justified
- Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_Orientation (ULONG)
- Defines whether the tab gadget should appear as if it is above or below the pages it controls.
- Valid values are:
- TABBED_ORIENTATION_TOP - the tabs are above the pages
- TABBED_ORIENTATION_BOTTOM - the tabs are below the pages
- Defaults to TABBED_ORIENTATION_TOP.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_DontOverlap (BOOL)
- Do not allow the tabs to overlap each other. This will shrink the
- tabs so that they all fit next to each other. It might cause
- graphical glitches if the tabs become too small to display
- properly. Defaults to FALSE.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_FrameStyle (ULONG)
- Define the style of the frame around each tab. These are the valid
- values:
- 0 plain 3D style as in Amiga OS 3.1 and below
- 1 outline 3D style as in AmigaOS 4.1 or MUI XEN style.
- Defaults to 0 on V46 (OS3) and 1 on V54 (OS4).
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_LabelSpace (ULONG)
- This space is added twice (on the left and on the right) to the
- minimum width of each tab. It gives some more space around the
- label if TABBED_EvenSize is set to FALSE.
- Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_Spacing (ULONG)
- Defines space between tabs.
- Defaults to 0.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_BrightenTab (LONG)
- Adds brightness to the background of inactive tabs. Only applies
- if TABBED_TabBackFill is set to TABBED_BACKFILL_GRADIENT. Valid
- values are between -64 and 64. Use negative values to darken the colour.
- Defaults to 0.
- V54: defaults to -64 if CLICKTAB_INACTIVEDARK is set in GUI attrs
- and GA_DrawInfo is provided to OM_NEW.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_BrightenActive (LONG)
- Adds brightness to the background of the active tab. Only applies
- if TABBED_ActiveBackFill is set to TABBED_BACKFILL_GRADIENT. Valid
- values are between -64 and 64. Use negative values to darken the colour.
- Defaults to 0.
- V54: defaults to 64 if CLICKTAB_ACTIVEBRIGHT is set in GUI attrs and GA_DrawInfo is provided to OM_NEW.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- The following tags define numeric indexes into the dri_Pens resp.
- TABBED_Pens array for various purposes.
- V54: The OS4 version will override the defaults by GUI attributes if GA_DrawInfo is given to OM_NEW.
- Warning: if you provide TABBED_Pens and override pen indexes by these
- tags or let them default to GUI attrs, then you have to ensure that
- the given pens array is large enough. Tabbed.gadget does not do any validity checks.
- Applicability is (OM_NEW, OM_SET, OM_GET, OM_UPDATE)
- TABBED_TabTextPenIX (ULONG)
- Index in dri_Pens for the text of inactive tabs.
- Defaults to TEXTPEN.
- TABBED_TabFillPenIX (ULONG)
- Index in dri_Pens for the background of inactive tabs. Only used
- if TABBED_TabBackFill is either NULL or TABBED_BACKFILL_GRADIENT.
- Defaults to BACKGROUNDPEN.
- TABBED_SelectedTextPenIX (ULONG)
- Index in dri_Pens for the text of an inactive tab when the user clicks on it.
- Defaults to FILLTEXTPEN.
- TABBED_SelectedFillPenIX (ULONG)
- Index in dri_Pens for the background of an inactive tab when the
- user clicks on it. Only used if TABBED_TabBackFill is either NULL or TABBED_BACKFILL_GRADIENT.
- Defaults to FILLPEN.
- TABBED_ActiveTextPenIX (ULONG)
- Index in dri_Pens for the text of the active tab.
- Defaults to HIGHLIGHTTEXTPEN.
- TABBED_ActiveFillPenIX (ULONG)
- Index in dri_Pens for the background of the active tab.
- Only used if TABBED_ActiveBackFill is either NULL or
- TABBED_BACKFILL_GRADIENT.
- Defaults to DETAILPEN.
- TABBED_ActiveShadowPenIX (ULONG)
- Index in dri_Pens for the shadow behind the text of the active tab.
- Set this to -1 to remove the shadow.
- Defaults to SHADOWPEN.
- tabbed_gc/--background--
- BACKGROUND
- Initially tabbed class only supported setting the list of tabs through
- the TABBED_Labels attribute. This has kind of static character. Although
- you could set it to a new value at any time, it would always replace the
- whole list of tabs. And tabs could only have textual labels.
- Internally it always worked with a linked list of TabbedNode structures,
- therefore new methods were introduced which allow basic access to the internal TabbedNodes.
- While TGM_ADDTAB, TGM_REMTAB and TGM_MOVETAB still work with place numbers,
- TGM_ADDNODE, TGM_REMNODE and TGM_MOVENODE allow to use node pointers.
- Still you have to use TGM_ADDTAB or TGM_ADDNODE to create a new tab. You
- must not allocate your own TabbedNode and insert it into the list!
- The ln_Name field holds a pointer to the label. Depending on tbn_Flags
- this pointer can be interpreted in different ways:
- TBNF_NameIsLabel -> ln_Name points to a string
- TBNF_NameIsIntuiText -> ln_Name points to a struct IntuiText
- TBNF_NameIsImage -> ln_Name points to a struct Image or to a BOOPSI image object
- TBNF_NameIsHook -> ln_Name points to a struct Hook. This is very similar to GTLV_CallBack in GadTools.
- There is one flag which is only relevant when the tab is added by
- TGM_ADDTAB or TGM_ADDNODE:
- TBNF_Activate -> if this flag is set, the new tab will become the active one.
- These flags are for advanced functions:
- TBNF_HasCloseButton -> this flag adds a close button to the tab. The
- image used can be set by the TABBED_CloseImage
- tag. The size of the close button adds to the
- minimum width of the tab.
- When the user clicks the close button, there
- will be no action except that the application
- is notified about the TABBED_ClosedTab,
- TABBED_ClosedNode and TABBED_ClosedID tags.
- TBNF_SmallTab -> if this flag is set, the tab will stay at its
- minimum width and won't be resized like regular tabs.
- You can define a minimum width for all tabs
- with the TBNF_SmallTab flag set using the
- TABBED_SmallWidth tag.
- TBNF_DontActivate -> if this flag is set, the tab won't become the
- active tab when the user clicks on it. The
- application will be notified via the
- TABBED_ClickedTab, TABBED_ClickedNode and
- TABBED_ClickedID tags.
- TBNF_StopDrag -> if this flag is set, the user cannot drag other
- tabs beyond this one. It is especially useful
- if the tab shall stay at the end or at the
- beginning of the list. But it can also be used
- to seperate groups of tabs.
- SEE ALSO
- gadgets/tabbed.h
- tabbed_gc/--preferences-- tabbed_gc/--prefetences--
- PREFERENCES
- The OM_NEW method of tabbed.gadget reads preferences from the
- environment variable Classes/Gadgets/tabbed.prefs which is usually
- stored as a file in ENV:Classes/Gadgets/tabbed.prefs and saved in
- ENVARC:Classes/Gadgets/tabbed.prefs.
- The following arguments are allowed:
- SKEW=8 sets the value of TABBED_Skew.
- ROUNDED sets TABBED_Rounded to TRUE.
- MINWIDTH=0 sets the value of TABBED_MinWidth.
- MAXWIDTHPERCENT=50 sets the value of TABBED_MaxWidthPercent.
- CLOSEONLYACTIVE sets TABBED_CloseOnlyActive to TRUE.
- BARHEIGHT=0 sets the value of TABBED_BarHeight.
- TABGRADIENT sets TABBED_TabBackFill to TABBED_BACKFILL_GRADIENT.
- ACTIVEGRADIENT sets TABBED_TABBED_ActiveBackFill to TABBED_BACKFILL_GRADIENT.
- ALIGNLABEL=0 sets the value of TABBED_AlignLabel.
- DONTOVERLAP sets TABBED_DontOverlap to TRUE.
- NOEVENSIZE sets TABBED_EvenSize to FALSE.
- FRAMESTYLE=0 sets the value of TABBED_FrameStyle.
- LABELSPACE=0 sets the value of TABBED_LabelSpace.
- SPACING=0 sets the value of TABBED_Spacing.
- BRIGHTENTAB=0 sets the value of TABBED_BrightenTab.
- BRIGHTENACTIVE=0 sets the value of TABBED_BrightenActive.
- TABTEXTPENIX=2 sets the value of TABBED_TabTextPenIX.
- TABFILLPENIX=7 sets the value of TABBED_TabFillPenIX.
- SELECTEDTEXTPENIX=6 sets the value of TABBED_SelectedTextPenIX.
- SELECTEDFILLPENIX=5 sets the value of TABBED_SelectedFillPenIX.
- ACTIVETEXTPENIX=8 sets the value of TABBED_ActiveTextPenIX.
- ACTIVEFILLPENIX=0 sets the value of TABBED_ActiveFillPenIX.
- ACTIVESHADOWPENIX=4 sets the value of TABBED_ActiveShadowPenIX.
- The variable can contain comments enclosed in /* and */. Arguments can be separated by spaces or new lines. Empty lines are ignored.
- The preferences are read and applied by the OM_NEW method before the tags given by the application are checked. This means the application can override each of them via tags.
- The V54 version first reads the GUI attributes from Intuition and tries to apply the clicktab settings. However, the concepts of these two classes are quite different, so results might differ.
- Note: to get the right GUI settings, the application has to provide GA_DrawInfo with the DrawInfo of the destination screen. Otherwise Intuition returns global defaults which do not match the GUI prefs.
- tabbed_gc/TABBED_GetClass
- NAME
- TABBED_GetClass -- Gets the pointer to the tabbed class (deprecated).
- SYNOPSIS
- tabbed_class = TABBED_GetClass();
- D0
- Class * TABBED_GetClass(VOID);
- FUNCTION
- For compatibility with ClassAct and ReAction on OS 3 the class
- library contains this function at offset -30 which returns the
- class pointer.
- The preferred method to obtain the class pointer is to read it
- from the cl_Class field of the library base.
- INPUTS
- Nothing.
- RESULT
- tabbed_class - Pointer to the Tabbed gadget class.
- SEE ALSO