TabX Operations / Examples

See the sample program TSTTABX for a working example of many of the operations discussed in the following sections.

Creating a TabX Control

map1 tabdefs$,s,0

map1 tabid$,s,24,"tbx1"

 

! start with TABX global options

tabdefs$ = "@style=0~"           ! std modern style

tabdefs$ += "XbtnVisible=1~"     ! "x" (close) button visible

tabdefs$ += "XbtnEnabled=1~"     ! close button is enabled

tabdefs$ += "XbnTip=Close current tab~"  ! tool tip for close btn

tabdefs$ += "themes=0~"          ! themes disabled

tabdefs$ += "~"                  ! end of global options

 

! add tabs (each with individual options)

tabdefs$ += "Label=&One~"

tabdefs$ += "Cmd=VK_xF101~"

tabdefs$ += "id=One~"

tabdefs$ += "RGBbgClient=200,180,160~"  ! active panel/lbl (light beige)

tabdefs$ += "RGBbg=140,130,120~"        ! inactive lbl (darker gray/beige)

tabdefs$ += "tip=this is the tab one tip~"

tabdefs$ += "~"                         ! end of tab 1 options

 

tabdefs$ += "Label=&Two~"

tabdefs$ += "Cmd=VK_xF102~"

tabdefs$ += "id=Two~"

tabdefs$ += "tip=this is the tab two tip~"

tabdefs$ += "RGBbgClient=150,200,250~"

tabdefs$ += "RGBbg=140,130,120~"        ! inactive lbl (darker gray/beige)

tabdefs$ += "~"                         ! end of tab 2

 

xcall AUI, AUI_CONTROL, CTLOP_ADD, TABID$, tabdefs$, MBST_ENABLE, MBF_TAB, NUL_CMD$, NUL_FUNC$, NUL_CSTATUS, tsrow,tscol,terow,tecol, NUL_FGC,NUL_BGC,NUL_FONTATTR,NUL_FONTSCALE, NUL_FONTFACE$, NUL_TOOLTIP$, parentid$, NUL_WINCLASS$, NUL_WINSTYLE,NUL_WINSTYLEX, MBF2_TABX

 

Selecting a Panel

When first creating a Tab (or TabX) control, the first tab label will automatically be selected. To select a different label/panel, use the CTLOP_PANE opcode, specifying either the pane/label number in the cstate parameter (and leaving ctext empty), or the pane/label text or click string (as defined by the label or cmd attributes) in the ctext parameter and setting cstate to 0. For example:

tabno = 3            ! select panel #3 (Tab or TabX control)

xcall AUI, AUI_CONTROL, CTLOP_PANE, ctlid$, "", tabno

 

! (the following methods only work with the TabX control)

labelid$ = "&One"       ! select panel with label text "&One"  

xcall AUI, AUI_CONTROL, CTLOP_PANE, ctlid$, labelid$, 0

 

labelid$ = "VK_xF402"       ! select panel with click str "VK_xF402"  

xcall AUI, AUI_CONTROL, CTLOP_PANE, ctlid$, labelid$, 0

 

Switching Panels

Typically, the user will signal the desire to switch to another panel by clicking on the label, which will transmit the label's click string, which will typically generate an exitcode in the application. To respond (or to switch panels purely according to the whim of the application), you might first want to start by validating or storing the contents of the current panel (if applicable), then proceed by clearing the panel with the CTLOP_CLR opcode, followed by selecting the new panel with the CTLOP_PANE opcode (as described above). In the example below, we use the exitcode returned by clicking on the label to identify the label (assuming that the exitcode was generated by the standard click string syntax of VK_xF###):

switch exitcode

  case -102                           ! user clicked label #2

<validate current panel contents>

if <ok to switch to new panel> then

xcall AUI, AUI_CONTROL, CTLOP_CLR, ctlid$     ! clear current panel contents

labelid$ = "VK_xF"+str(exitcode)

xcall AUI, AUI_CONTROL, CTLOP_PANE, ctlid$, labelid$, 0

<display contents of panel>

else

<display a message saying why switch is not allowed>

! now we must re-select the current panel

labelid$ = <id of previous panel>

xcall AUI, AUI_CONTROL, CTLOP_PANE, ctlid$, labelid$, 0     ! select new panel

endif

endif

 

If you don't want to allow the user to switch panels, then you must explicitly use CTLOP_PANE to re-establish the label/panel you were previously on, else the control will display the clicked-on label as if it were the current label. An alternate approach would be to disable the other panels until you wanted to allow the user to switch to them.

Disabling/Enabling a Panel/Label

To disable or enable panels, use the CTLOP_CHG opcode and cstate MBST_CHANGEX, identifying the labels to be enabled/disabled using "=labelid:" clauses in the ctext parameter (either by # or by the alphanumeric id), e.g.

ctext$ = "=1:~Enabled=0~~"       ! disable the first panel

ctext$ += "=Th&ree:Enabled=1~~"  ! and enable the panel "Th&ree"

 

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

Adding a Panel/Label

To add a new panel to the end, specify the panel's label definition, preceded by "+:", e.g.

ctext$ = "+:label=New~cmd=VK_xF405~~"   ! add new panel "New"

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

Inserting a panel in another position is the same except that you must specify the panel's labelid (number or label text or click string).  Here we insert the new label in position 2:

ctext$ = "+2:label=New~cmd=VK_xF405~~"   ! insert new panel "New" at position 2

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

Here we insert it prior to the panel whose cmd click string is "VK_xF402":

ctext$ = "+VK_xF402:label=New~cmd=VK_xF405~~"

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

Note that inserting or deleting a label in the middle causes the pre-existing labels to be renumbered.

Deleting a Panel

To delete a panel, specify the panel's label identifier preceded by a "-" and followed by the ":". Note that as with the other operations, the label identifier can be a number (the panel's ordinal position), or the panel's text label string, or its command string. Also note that although we are deleting a panel, we are not deleting the entire control, so we are using the CTLOP_CHG opcode (rather than CTLOP_DEL). For example:

ctext$ = "-2:~~"   ! delete panel #2

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

ctext$ = "-Th&ree:~~" ! delete panel whose label is "Th&ree"

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

ctext$ = "-VK_xF101:~~" ! delete panel whose command string is "VK_xF101"

xcall AUI, AUI_CONTROL, CTLOP_CHG, ctlid$, ctext$, MBST_CHANGEX

 

Finally, note that deleting a panel effectively renumbers all of the panels to its right, which is why the panel label text or command text might be generally more useful than the ordinal position for identifying the panel.