Difference between revisions of "Tabbed Gadget Class"

From wiki.amiga.org
Jump to navigation Jump to search
Line 407: Line 407:
 
;    SEE ALSO
 
;    SEE ALSO
 
:      gadgets/tabbed.h
 
:      gadgets/tabbed.h
 +
 +
 +
;tabbed_gc/--preferences--                          tabbed_gc/--prefetences--
 +
 +
;    PREFERENCES
 +
:        tabbed.gadget reads preferences from the environment variable
 +
:        Sys/Classes/tabbed.prefs which is usually stored as a file in
 +
:        ENV:Sys/Classes/tabbed.prefs and saved in ENVARC:Sys/Classes/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.
 +
 +
:        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.
 +
  
  

Revision as of 13:38, 22 May 2021

Tabbed Gadget With Bar V54
Tabbed Gadget With Bar V46
Tabbed Gadget V54
Tabbed Gadget V46
Gradient Back Fill With Bar
Orientation Set To Bottom

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

Gadgets Icon.png
Manual installation:

Copy the file tabbed.gadget to SYS:Classes/Gadgets/ directory

 

Developer Documentation

SDK Icon.png
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_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_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_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
tabbed.gadget reads preferences from the environment variable
Sys/Classes/tabbed.prefs which is usually stored as a file in
ENV:Sys/Classes/tabbed.prefs and saved in ENVARC:Sys/Classes/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.
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.


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