Skip to content
ModernUI A DaneTrades developer library

AppWindow, Section, and LabeledField

These are the first fast wrappers to learn.

They create the outer structure of a ModernUI panel:

  • Mui::AppWindow creates a chart-hosted window and sets it as the root UI.
  • Mui::Section creates a titled section/card inside a container.
  • Mui::LabeledField wraps an existing control with a label and optional hint.

Use them when you want a clean panel shell without manually building every container.

When to use this

Use these wrappers for:

  • EA settings panels
  • compact trade-style panels
  • dashboard side panels
  • utility windows
  • grouped form sections

They are optional. You can build the same UI manually with new MuiWindow, MuiPanel, containers, raw controls, and Add.

Mui::AppWindow

Mui::AppWindow creates a standard chart-hosted app window.

Reference excerpt
MuiAppWindow Mui::AppWindow(
  MuiRoot &root,
  string title,
  int x,
  int y,
  int width,
  int height,
  bool scrollable=true
);

It returns:

Field Meaning
window The created MuiWindow
content The inner body container where you add sections and controls

Basic example:

Place inside OnInit after g_ui.Init succeeds
MuiAppWindow app=Mui::AppWindow(g_ui,"Trade Manager",20,40,340,430,true);

AppWindow calls root.SetRoot(...) for you. It is intended for the main chart-hosted panel.

Mui::Section

Mui::Section creates a grouped panel with a title, optional subtitle, and a body container.

Reference excerpt
MuiSection Mui::Section(
  MuiContainer *parent,
  string title,
  string subtitle="",
  bool fullWidth=true
);

It returns:

Field Meaning
panel The outer MuiPanel
title The title label
subtitle The subtitle label, or NULL when no subtitle is passed
body The container where controls should be added

Basic example:

UI build fragment
MuiSection order=Mui::Section(app.content,"Order","Execution setup");
MuiSection actions=Mui::Section(app.content,"Actions","");

If parent == NULL, the returned struct is empty and its fields are NULL.

Mui::LabeledField

Mui::LabeledField wraps an existing control in a caption/hint column.

Reference excerpt
MuiLabeledField Mui::LabeledField(
  MuiContainer *parent,
  string label,
  MuiElement *control,
  string hint=""
);

It returns:

Field Meaning
root The created field container
label The caption label
control The wrapped control
hint The hint label, or NULL when no hint is passed

Use LabeledField when you already have a control pointer and want to place it into a labelled row.

UI build fragment
MuiButtonAction *button=Mui::Button(NULL,"Place",NULL,100.0,34.0);

MuiLabeledField action=Mui::LabeledField(
  order.body,
  "Action",
  button,
  "UI-only demo action."
);

Controls passed into LabeledField are normally created with parent == NULL, then attached by the wrapper.

Practical shell example

Place inside OnInit after g_ui.Init succeeds
MuiAppWindow app=Mui::AppWindow(g_ui,"Panel",20,40,340,430,true);

MuiSection general=Mui::Section(app.content,"General","Common settings");
MuiSection advanced=Mui::Section(app.content,"Advanced","Optional controls");

MuiButtonAction *save=Mui::Button(NULL,"Save",NULL,100.0,34.0);
MuiLabeledField saveField=Mui::LabeledField(general.body,"Action",save,"Attach a click handler later.");

Customising after creation

Returned fields are normal controls.

UI build fragment
if(general.title!=NULL)
  general.title.Text("Main settings");

if(general.panel!=NULL)
  general.panel.Pad(14.0);

if(save!=NULL)
  save.Text("Save settings");

Common mistakes

Adding controls to the wrong field

Add controls to section.body, not section.panel.

Correct
Mui::LabeledTextBox(section.body,"Name","Default");

Passing an already-parented control into LabeledField

For LabeledField, create the control with parent == NULL so it can be attached once.

Correct
MuiButtonAction *button=Mui::Button(NULL,"Run",NULL,100.0,34.0);
Mui::LabeledField(section.body,"Command",button,"");

Treating wrappers as required

Wrappers are optional. If a section needs custom layout or behaviour, use raw controls.

Related pages