I'm attempting to create a dialog box with 3 tabs and 3 frames (1 for each tab). I'd then like to be able to put dialog box elements inside each of the three frames. However, I'm having issues getting this to work and I can't seem to find any DOORS help examples which do this kind of thing. Does anyone have any code they can post which demonstrates this?
|
Re: Tab Strips and Frames
It is true that there is no useful information on tabs in the DOORS help. As a matter of fact, all DBEs on all tabs are always shown, unless you write your code in a away that this does not happen.
// Define the tab names
const string tabStrings[] = {"A", "B", "C"}
DB mainDB
DBE theTab // The tab strip DBE itself
DBE frameA , frameB, frameC // The frames you asked for
DBE labelA , fieldB, textC // DBE elements, to be put on the different tabs
// Add your specific DBEs here
Skip tabASkip = create // Skip for all DBEs on the first tab
Skip tabBSkip = create // Skip for all DBEs on the second tab
Skip tabCSkip = create // Skip for all DBEs on the third tab
Skip allTabsSkip = create // Skip for all tab skip lists
int iKey
// -----------------------------------------------------------------------------
// Tab callBack routine
void tabSelected(DBE tabDBE)
{ // Hide all DBEs and show the DBEs of the selectded tab
int i = get tabDBE
Skip oneTabSkp
DBE dbe
for oneTabSkp in allTabsSkip do {for dbe in oneTabSkp do {hide dbe}}
if (find(allTabsSkip, i, oneTabSkp)){for dbe in oneTabSkp do {show dbe}}
} // Hide all DBEs and show the DBEs of the selectded tab
// -----------------------------------------------------------------------------
void closeDB__CallBack(DB db)
{ // Close dialogue box and delete skip lists
Skip s
for s in allTabsSkip do {delete s}
delete allTabsSkip
hide db
destroy db
db = null
} // Close dialogue box and delete skip lists
// -----------------------------------------------------------------------------
// Create the DB and the tab strip
mainDB = create "Example"
theTab = tab(mainDB, tabStrings, 300, 300, tabSelected)
// Define the first tab
iKey = 0
frameA = frame(mainDB, "A frame", 100, 100)
labelA = label(mainDB, "This is a label on the first tab")
// Store the DBEs in the respective Skip list
put(tabASkip, iKey++, frameA)
put(tabASkip, iKey++, labelA)
// Define the second tab
iKey = 0
frameB = frame(mainDB, "B frame", 100, 100)
fieldB = field(mainDB, "A field on the second tab", "...", 20, false)
// Store the DBEs in the respective Skip list
put(tabBSkip, iKey++, frameB)
put(tabBSkip, iKey++, fieldB)
// Define the third tab
iKey = 0
frameC = frame(mainDB, "C frame", 100, 100)
textC = text(mainDB, "", "I wonder how the built-in equivalent to my self-written 'tabSelected' routine is called.", 100, 70, false)
// Store the DBEs in the respective Skip list
put(tabCSkip, iKey++, frameC)
put(tabCSkip, iKey++, textC)
// Store the tab-specific Skip lists in the main tab Skip list
iKey = 0
put(allTabsSkip, iKey++, tabASkip)
put(allTabsSkip, iKey++, tabBSkip)
put(allTabsSkip, iKey++, tabCSkip)
// Add the close buton call-back which deletes the Skip lists
close(mainDB, true, closeDB__CallBack)
// Position the DBEs
// The tab strip is straight forward
theTab->"left" ->"form"
theTab->"right" ->"form"
theTab->"top" ->"form"
theTab->"bottom"->"form"
// All frames are completely inside the tab
frameA->"left" ->"inside"->theTab
frameA->"right" ->"inside"->theTab
frameA->"top" ->"inside"->theTab
frameA->"bottom"->"inside"->theTab
frameB->"left" ->"inside"->theTab
frameB->"right" ->"inside"->theTab
frameB->"top" ->"inside"->theTab
frameB->"bottom" ->"inside"->theTab
frameC->"left" ->"inside"->theTab
frameC->"right" ->"inside"->theTab
frameC->"top" ->"inside"->theTab
frameC->"bottom" ->"inside"->theTab
// The individual DBEs are inside each respective frame
labelA->"top" ->"inside"->frameA
labelA->"left"->"inside"->frameA
fieldB->"top" ->"inside"->frameB
fieldB->"left"->"inside"->frameB
textC->"top" ->"inside"->frameC
textC->"left" ->"inside"->frameC
textC->"right" ->"inside"->frameC
textC->"bottom"->"unattached"
realize mainDB
tabSelected(theTab)
show mainDB
|
Re: Tab Strips and Frames Peter_Albert - Tue Dec 28 08:32:33 EST 2010
It is true that there is no useful information on tabs in the DOORS help. As a matter of fact, all DBEs on all tabs are always shown, unless you write your code in a away that this does not happen.
// Define the tab names
const string tabStrings[] = {"A", "B", "C"}
DB mainDB
DBE theTab // The tab strip DBE itself
DBE frameA , frameB, frameC // The frames you asked for
DBE labelA , fieldB, textC // DBE elements, to be put on the different tabs
// Add your specific DBEs here
Skip tabASkip = create // Skip for all DBEs on the first tab
Skip tabBSkip = create // Skip for all DBEs on the second tab
Skip tabCSkip = create // Skip for all DBEs on the third tab
Skip allTabsSkip = create // Skip for all tab skip lists
int iKey
// -----------------------------------------------------------------------------
// Tab callBack routine
void tabSelected(DBE tabDBE)
{ // Hide all DBEs and show the DBEs of the selectded tab
int i = get tabDBE
Skip oneTabSkp
DBE dbe
for oneTabSkp in allTabsSkip do {for dbe in oneTabSkp do {hide dbe}}
if (find(allTabsSkip, i, oneTabSkp)){for dbe in oneTabSkp do {show dbe}}
} // Hide all DBEs and show the DBEs of the selectded tab
// -----------------------------------------------------------------------------
void closeDB__CallBack(DB db)
{ // Close dialogue box and delete skip lists
Skip s
for s in allTabsSkip do {delete s}
delete allTabsSkip
hide db
destroy db
db = null
} // Close dialogue box and delete skip lists
// -----------------------------------------------------------------------------
// Create the DB and the tab strip
mainDB = create "Example"
theTab = tab(mainDB, tabStrings, 300, 300, tabSelected)
// Define the first tab
iKey = 0
frameA = frame(mainDB, "A frame", 100, 100)
labelA = label(mainDB, "This is a label on the first tab")
// Store the DBEs in the respective Skip list
put(tabASkip, iKey++, frameA)
put(tabASkip, iKey++, labelA)
// Define the second tab
iKey = 0
frameB = frame(mainDB, "B frame", 100, 100)
fieldB = field(mainDB, "A field on the second tab", "...", 20, false)
// Store the DBEs in the respective Skip list
put(tabBSkip, iKey++, frameB)
put(tabBSkip, iKey++, fieldB)
// Define the third tab
iKey = 0
frameC = frame(mainDB, "C frame", 100, 100)
textC = text(mainDB, "", "I wonder how the built-in equivalent to my self-written 'tabSelected' routine is called.", 100, 70, false)
// Store the DBEs in the respective Skip list
put(tabCSkip, iKey++, frameC)
put(tabCSkip, iKey++, textC)
// Store the tab-specific Skip lists in the main tab Skip list
iKey = 0
put(allTabsSkip, iKey++, tabASkip)
put(allTabsSkip, iKey++, tabBSkip)
put(allTabsSkip, iKey++, tabCSkip)
// Add the close buton call-back which deletes the Skip lists
close(mainDB, true, closeDB__CallBack)
// Position the DBEs
// The tab strip is straight forward
theTab->"left" ->"form"
theTab->"right" ->"form"
theTab->"top" ->"form"
theTab->"bottom"->"form"
// All frames are completely inside the tab
frameA->"left" ->"inside"->theTab
frameA->"right" ->"inside"->theTab
frameA->"top" ->"inside"->theTab
frameA->"bottom"->"inside"->theTab
frameB->"left" ->"inside"->theTab
frameB->"right" ->"inside"->theTab
frameB->"top" ->"inside"->theTab
frameB->"bottom" ->"inside"->theTab
frameC->"left" ->"inside"->theTab
frameC->"right" ->"inside"->theTab
frameC->"top" ->"inside"->theTab
frameC->"bottom" ->"inside"->theTab
// The individual DBEs are inside each respective frame
labelA->"top" ->"inside"->frameA
labelA->"left"->"inside"->frameA
fieldB->"top" ->"inside"->frameB
fieldB->"left"->"inside"->frameB
textC->"top" ->"inside"->frameC
textC->"left" ->"inside"->frameC
textC->"right" ->"inside"->frameC
textC->"bottom"->"unattached"
realize mainDB
tabSelected(theTab)
show mainDB
I have another problem related to tabs. I am trying to place a tab in another tab. Is this possible with DXL? I modified the code snippet that Peter provided as follows: // Define the tab names const string tabStrings[] = {"A", "B", "C"} const string secondTabStrings[] = {"Tab1", "Tab2"} DB mainDB DBE theTab, theSecondTab // The tab strip DBE itself DBE frameA , frameB, frameC // The frames you asked for DBE labelA // DBE elements, to be put on the different tabs // Add your specific DBEs here Skip tabASkip = create // Skip for all DBEs on the first tab Skip tabBSkip = create // Skip for all DBEs on the second tab Skip tabCSkip = create // Skip for all DBEs on the third tab Skip allTabsSkip = create // Skip for all tab skip lists int iKey // // Tab callBack routine void tabSelected(DBE tabDBE) { // Hide all DBEs and show the DBEs of the selectded tab int i = get tabDBE Skip oneTabSkp DBE dbe for oneTabSkp in allTabsSkip do {for dbe in oneTabSkp do {hide dbe}} if (find(allTabsSkip, i, oneTabSkp)){for dbe in oneTabSkp do {show dbe}} } // Hide all DBEs and show the DBEs of the selectded tab // void secondTabSelected(DBE tabDBE) { int i = get tabDBE ack "Tab clicked " i "." } void closeDB__CallBack(DB db) { // Close dialogue box and delete skip lists Skip s for s in allTabsSkip do {delete s} delete allTabsSkip hide db destroy db db = null } // Close dialogue box and delete skip lists // // Create the DB and the tab strip mainDB = create "Example" theTab = tab(mainDB, tabStrings, 300, 300, tabSelected) // Define the first tab iKey = 0 frameA = frame(mainDB, "A frame", 100, 100) labelA = label(mainDB, "This is a label on the first tab") theSecondTab = tab(mainDB, secondTabStrings, 800, 250, secondTabSelected) // Store the DBEs in the respective Skip list put(tabASkip, iKey++, frameA) put(tabASkip, iKey++, labelA) put(tabASkip, iKey++, theSecondTab) // Define the second tab iKey = 0 frameB = frame(mainDB, "B frame", 100, 100) // Store the DBEs in the respective Skip list put(tabBSkip, iKey++, frameB) // Define the third tab iKey = 0 frameC = frame(mainDB, "C frame", 100, 100) // Store the DBEs in the respective Skip list put(tabCSkip, iKey++, frameC) // Store the tab-specific Skip lists in the main tab Skip list iKey = 0 put(allTabsSkip, iKey++, tabASkip) put(allTabsSkip, iKey++, tabBSkip) put(allTabsSkip, iKey++, tabCSkip) // Add the close buton call-back which deletes the Skip lists close(mainDB, true, closeDB__CallBack) // Position the DBEs // The tab strip is straight forward theTab->"left" ->"form" theTab->"right" ->"form" theTab->"top" ->"form" theTab->"bottom"->"form" // All frames are completely inside the tab frameA->"left" ->"inside"->theTab frameA->"right" ->"inside"->theTab frameA->"top" ->"inside"->theTab frameA->"bottom"->"inside"->theTab frameB->"left" ->"inside"->theTab frameB->"right" ->"inside"->theTab frameB->"top" ->"inside"->theTab frameB->"bottom" ->"inside"->theTab frameC->"left" ->"inside"->theTab frameC->"right" ->"inside"->theTab frameC->"top" ->"inside"->theTab frameC->"bottom" ->"inside"->theTab // The individual DBEs are inside each respective frame labelA->"top" ->"inside"->frameA labelA->"left"->"inside"->frameA theSecondTab->"left"->"inside"->frameA theSecondTab->"right"->"inside"->frameA theSecondTab->"top"->"spaced"->labelA; theSecondTab->"bottom"->"unattached" realize mainDB tabSelected(theTab) show mainDB The second tab is not visible, or better say it appears under the first tab. Any idea how can I fix this? Thanks! Emilia |
Re: Tab Strips and Frames EmiliaH - Thu Nov 08 03:57:11 EST 2012 // Tab callBack routine void tabSelected(DBE tabDBE) { // Hide all DBEs and show the DBEs of the selectded tab int i = get tabDBE Skip oneTabSkp DBE dbe for oneTabSkp in allTabsSkip do {for dbe in oneTabSkp do {hide dbe}} if (find(allTabsSkip, i, oneTabSkp)){for dbe in oneTabSkp do {show dbe}} } // Hide all DBEs and show the DBEs of the selectded tab // void secondTabSelected(DBE tabDBE) { int i = get tabDBE ack "Tab clicked " i "." } void closeDB__CallBack(DB db) { // Close dialogue box and delete skip lists Skip s for s in allTabsSkip do {delete s} delete allTabsSkip hide db destroy db db = null } // Close dialogue box and delete skip lists // // Create the DB and the tab strip mainDB = create "Example" theTab = tab(mainDB, tabStrings, 300, 300, tabSelected) // Define the first tab iKey = 0 frameA = frame(mainDB, "A frame", 100, 100) labelA = label(mainDB, "This is a label on the first tab") theSecondTab = tab(mainDB, secondTabStrings, 800, 250, secondTabSelected) // Store the DBEs in the respective Skip list put(tabASkip, iKey++, frameA) put(tabASkip, iKey++, labelA) put(tabASkip, iKey++, theSecondTab) // Define the second tab iKey = 0 frameB = frame(mainDB, "B frame", 100, 100) // Store the DBEs in the respective Skip list put(tabBSkip, iKey++, frameB) // Define the third tab iKey = 0 frameC = frame(mainDB, "C frame", 100, 100) // Store the DBEs in the respective Skip list put(tabCSkip, iKey++, frameC) // Store the tab-specific Skip lists in the main tab Skip list iKey = 0 put(allTabsSkip, iKey++, tabASkip) put(allTabsSkip, iKey++, tabBSkip) put(allTabsSkip, iKey++, tabCSkip) // Add the close buton call-back which deletes the Skip lists close(mainDB, true, closeDB__CallBack) // Position the DBEs // The tab strip is straight forward theTab->"left" ->"form" theTab->"right" ->"form" theTab->"top" ->"form" theTab->"bottom"->"form" // All frames are completely inside the tab frameA->"left" ->"inside"->theTab frameA->"right" ->"inside"->theTab frameA->"top" ->"inside"->theTab frameA->"bottom"->"inside"->theTab frameB->"left" ->"inside"->theTab frameB->"right" ->"inside"->theTab frameB->"top" ->"inside"->theTab frameB->"bottom" ->"inside"->theTab frameC->"left" ->"inside"->theTab frameC->"right" ->"inside"->theTab frameC->"top" ->"inside"->theTab frameC->"bottom" ->"inside"->theTab // The individual DBEs are inside each respective frame labelA->"top" ->"inside"->frameA labelA->"left"->"inside"->frameA theSecondTab->"left"->"inside"->frameA theSecondTab->"right"->"inside"->frameA theSecondTab->"top"->"spaced"->labelA; theSecondTab->"bottom"->"unattached" realize mainDB tabSelected(theTab) show mainDB The second tab is not visible, or better say it appears under the first tab. Any idea how can I fix this? Thanks! Emilia
Well, nested tabs are possible, but require a careful order of DBE definition and placement. The odd thing is that the inner tab has to be defined before the outer tab, as otherwise the inner tab is always hidden below the outer tab as you already observed. This, however, makes the classic DBE placement impossible, by which you would place the inner tab "inside" the outer tab. You therefore have to define a small label, which you later hide, which you use to place the outer tab a bit higher in the dialogue box than the inner tab. Finally, in the 'tabSelect' callBack, you have to ensure to also hide the DBEs in the inner tab when selecting a outer tab different than the one containing the inner tab. The rest is careful DBE placement and definition of the different Skip lists.
// Example for nested tabs
/*
*/
DB mainDB
string outerTabItems[] = {"A", "B", "C"}
string innerTabItems[] = {"1", "2"}
DBE outerTab, innerTab
Skip aTabSkip // key: int, value: DBE
Skip outerTabSkip = create() // key: int, value: Skip aTabSkip
Skip innerTabSkip = create() // key: int, value: Skip aTabSkip
// -----------------------------------------------------
void closeDB__CallBack(DB db){
for aTabSkip in outerTabSkip do {delete aTabSkip}
delete outerTabSkip
for aTabSkip in innerTabSkip do {delete aTabSkip}
delete innerTabSkip
hide db; destroy db; db = null
// -----------------------------------------------------
}
// -----------------------------------------------------
void tabSelected(DBE tabDBE){
int i = get tabDBE
Skip tabList
DBE dbe
if (tabDBE == outerTab){tabList = outerTabSkip}
else if (tabDBE == innerTab){tabList = innerTabSkip}
else {return}
for aTabSkip in tabList do {for dbe in aTabSkip do {hide dbe}}
if (find(tabList, i, aTabSkip)){for dbe in aTabSkip do {show dbe}}
if (tabDBE == outerTab){ // If in the outer tab, force hiding of inner tab for tabs first tab
if (i != 0){for aTabSkip in innerTabSkip do {for dbe in aTabSkip do {hide dbe}}}
else {tabSelected(innerTab)}
}
}
// -----------------------------------------------------
mainDB = create "nested tabs"
DBE x = label(mainDB, ".")
innerTab = tab( mainDB, innerTabItems, 200, 100, tabSelected)
outerTab = tab( mainDB, outerTabItems, 1, 1, tabSelected)
DBE tabBLabel = label(mainDB, "Tab B")
DBE tabCLabel = label(mainDB, "Tab C")
DBE tabA1Label = label(mainDB, "Tab A1")
DBE tabA2Label = label(mainDB, "Tab A2")
// DBE placement
outerTab -> "top" -> "form"
outerTab -> "bottom" -> "form"
// DBE placement for DBEs in outer tabstrip
innerTab -> "top" -> "spaced" -> x
innerTab -> "left" -> "spaced" -> x
innerTab -> "bottom" -> "form"
tabBLabel -> "top" -> "inside" -> outerTab
tabCLabel -> "top" -> "inside" -> outerTab
// DBE placement for DBEs in inner tabstrip
tabA1Label -> "top" -> "inside" -> innerTab
tabA1Label -> "left" -> "inside" -> innerTab
tabA2Label -> "top" -> "inside" -> innerTab
tabA2Label -> "left" -> "inside" -> innerTab
hide x
aTabSkip = create() // First tab in outer tabstrip
put(aTabSkip,0,innerTab)
put(outerTabSkip, 0, aTabSkip)
aTabSkip = create() // Second tab in outer tabstrip
put(aTabSkip,0,tabBLabel)
put(outerTabSkip, 1, aTabSkip)
aTabSkip = create() // Third tab in outer tabstrip
put(aTabSkip,0,tabCLabel)
put(outerTabSkip, 2, aTabSkip)
aTabSkip = create() // First tab in inner tabstrip
put(aTabSkip,0,tabA1Label)
put(innerTabSkip, 0, aTabSkip)
aTabSkip = create() // Second tab in inner tabstrip
put(aTabSkip,0,tabA2Label)
put(innerTabSkip, 1, aTabSkip)
realize(mainDB)
tabSelected(innerTab)
tabSelected(outerTab)
close(mainDB, true, closeDB__CallBack)
show mainDB
|