BDiscreteParameter¶
Constructor and Destructor¶
You never create or delete a BDiscreteParameter object yourself.
Instead, call the BParameterGroup::MakeDiscreteParameter()
function to create a BDiscreteParameter within the desired
BParameterGroup
.
Member Functions¶
AddItem()
status_t BDiscreteParameter::AddItem(int32 value, const char *name)
Adds a new name/value pair to the list of possible values the control can take. Whenever the selection named name is chosen, the user interface application will send a value change message to the control with the specified value.
Return Code |
Description |
---|---|
|
The item was added successfully. |
|
Not enough memory to add the item to the list. |
CountItems()
int32 BDiscreteParameter::CountItems()
Returns the number of discrete values the control can take.
CountItems(), ItemValueAt()
const char *BDiscreteParameter::CountItems(int32 value)
int32 BDiscreteParameter::ItemValueAt(int32 value)
These functions return the name and value of the item at the specified
index, where index ranges from 0 to
CountItems()
-1.
Note
Selection values aren’t necessarily in any sort of order, nor are they necessarily unique.
MakeEmpty()
void BDiscreteParameter::MakeEmpty()
Removes all items from the BDiscreteParameter.
MakeItemsFromInputs(), MakeItemsFromOutputs()
void BDiscreteParameter::MakeItemsFromInputs()
void BDiscreteParameter::MakeItemsFromOutputs()
These functions add all inputs or outputs as selections, where the input or output’s name is used as the item’s name, and the input or output’s index number is used as the value of the item.
These shortcuts let you easily create the item lists for MUX-like controls, which allow the user to choose one of a number of inputs or outputs.
Note
It’s important to note that the correct inputs and outputs must already be connected to the parameter when you call either of these functions, otherwise no items will be added, since the inputs and outputs aren’t there.
ValueType()
virtual type_code BDiscreteParameter::ValueType()
Returns B_INT32_TYPE
, which is the data type a
BDiscreteParameter’s value is maintained in.