Combo, List, Table, and Tabs
ModernUI includes helpers for common array-backed controls:
Mui::ComboBoxfrom a string array and selected indexMui::ListBoxfrom a string arrayMui::SimpleTablefrom headers and row countMui::TabsFromNamesfrom tab names
Use these when you need simple data display or simple navigation without writing a custom source class.
Array-backed ComboBox
The selected-index overload creates a combo box from a string array.
MuiComboBoxHost *Mui::ComboBox(
MuiContainer *parent,
string &items[],
int selected=0,
double width=0,
double height=0
);
Example:
string modes[];
ArrayResize(modes,3);
modes[0]="Manual";
modes[1]="Semi-auto";
modes[2]="Disabled";
MuiComboBoxHost *combo=Mui::ComboBox(section.body,modes,0,0.0,0.0);
If items[] is not empty, selected is clamped to the valid range.
Mui::LabeledCombo uses this overload internally.
ListBox
ListBox creates a MuiListView backed by a simple string array source.
MuiListBox Mui::ListBox(
MuiContainer *parent,
string &items[],
int selected=-1,
double width=0,
double height=0
);
Example:
string rows[];
ArrayResize(rows,4);
rows[0]="EURUSD";
rows[1]="GBPUSD";
rows[2]="USDJPY";
rows[3]="XAUUSD";
MuiListBox symbols=Mui::ListBox(section.body,rows,0,0.0,0.0);
if(symbols.list!=NULL)
symbols.list.RowHeight(28.0);
symbols.SetItem(2,"USDJPY updated");
MuiListBox exposes:
| Member | Purpose |
|---|---|
list |
The MuiListView |
source |
The backing string source |
Count() |
Row count |
SetItem(index,value) |
Update one row |
Item(index) |
Read one row |
Refresh() |
Notify the view after direct source changes |
SimpleTable
SimpleTable creates a table with column headers and a simple backing string source.
MuiSimpleTable Mui::SimpleTable(
MuiContainer *parent,
string &headers[],
int rows,
double width=0,
double height=0,
bool scrollable=true,
bool selectable=true
);
Example:
string headers[];
ArrayResize(headers,3);
headers[0]="Time";
headers[1]="Event";
headers[2]="Status";
MuiSimpleTable log=Mui::SimpleTable(section.body,headers,4,0.0,180.0,true,true);
log.SetCell(0,0,"10:30");
log.SetCell(0,1,"Panel opened");
log.SetCell(0,2,"OK");
log.Refresh();
MuiSimpleTable exposes:
| Member/method | Purpose |
|---|---|
table |
The MuiTableView |
source |
The simple table source |
Rows() |
Data row count |
Cols() / Columns() |
Column count |
SetCell(row,col,value) |
Write one cell |
Cell(row,col) |
Read one cell |
SetRow(row,values[]) |
Write a full row |
Clear() |
Clear data rows, keep headers |
Refresh() |
Notify after direct source changes |
Use a custom MuiTableSource when you need domain-specific sorting, numeric ordering, virtual data, or advanced table behaviour.
TabsFromNames
TabsFromNames creates a tab control and one body container per tab.
MuiTabsBundle Mui::TabsFromNames(
MuiContainer *parent,
string &names[],
int selected=0
);
Example:
string names[];
ArrayResize(names,3);
names[0]="General";
names[1]="Risk";
names[2]="Advanced";
MuiTabsBundle tabs=Mui::TabsFromNames(section.body,names,0);
Mui::LabeledTextBox(tabs.Body(0),"Name","Default");
Mui::LabeledSpinEdit(tabs.Body(1),"Risk %",0.1,10.0,0.1,1.0);
Mui::LabeledCheckbox(tabs.Body(2),"Enable extra checks",false);
tabs.Selected(g_ui,1);
Each tab body is owned by the tab control. Body(index) is a convenience pointer and should not be deleted.
Choosing the right helper
| Need | Use |
|---|---|
| Select one text item from a small list | Mui::ComboBox or Mui::LabeledCombo |
| Show a simple list of strings | Mui::ListBox |
| Show a simple grid of strings | Mui::SimpleTable |
| Split a settings area into pages | Mui::TabsFromNames |
| Use custom row logic or numeric sorting | Raw MuiListView / MuiTableView with custom source |
Ownership notes
The simple helpers keep the UI easy, but the backing sources matter:
MuiListViewdoes not delete its source.MuiTableViewdoes not delete its source.MuiListBoxandMuiSimpleTableexpose their backing source pointers.- Keep the wrapper value or source pointer available while you update rows.
- For strict cleanup in reload-heavy experts, delete exposed sources in
OnDeinitafter the UI is shut down if your usage requires it.
For normal small demo EAs, g_ui.Shutdown() tears down the visible UI tree.
Common mistakes
Expecting numeric table sorting
SimpleTable sorts strings lexically. Numeric strings are not sorted as numbers.
For numeric sorting, use a custom table source.
Deleting tab bodies
TabsFromNames tab bodies are owned by the MuiTabs control. Do not delete them.
Keeping only the list pointer
For MuiListBox, keep the wrapper or source pointer if you need to update row strings later.