addCheckbox(35, row++, "Checkbox 2", true);
row += 2;
- /*
- auto group = addRadioGroup(1, row, "Group 1");
+ TRadioGroup group = addRadioGroup(1, row, "Group 1");
group.addRadioButton("Radio option 1");
group.addRadioButton("Radio option 2");
group.addRadioButton("Radio option 3");
- addButton("&Close Window", (width - 14) / 2, height - 4,
- {
- application.closeWindow(this);
+ addButton("&Close Window", (getWidth() - 14) / 2, getHeight() - 4,
+ new TAction() {
+ public void DO() {
+ DemoCheckboxWindow.this.getApplication().closeWindow(DemoCheckboxWindow.this);
+ }
}
-
);
- */
}
}
class DemoMainWindow extends TWindow {
- /*
// Timer that increments a number
private TTimer timer;
+ // Timer label is updated with timerrr ticks
+ TLabel timerLabel;
+
+ /*
// The modal window is a more low-level example of controlling a window
// "from the outside". Most windows will probably subclass TWindow and
// do this kind of logic on their own.
private void modalWindowClose() {
application.closeWindow(modalWindow);
}
+ */
- /// We need to override onClose so that the timer will no longer be
- /// called after we close the window. TTimers currently are completely
- /// unaware of the rest of the UI classes.
- override public void onClose() {
- application.removeTimer(timer);
- }
+ /**
+ * We need to override onClose so that the timer will no longer be called
+ * after we close the window. TTimers currently are completely unaware
+ * of the rest of the UI classes.
*/
+ @Override
+ public void onClose() {
+ getApplication().removeTimer(timer);
+ }
/**
* Construct demo window. It will be centered on screen.
this(parent, CENTERED | RESIZABLE);
}
+ int timerI = 0;
+ TProgressBar progressBar;
+
/**
* Constructor.
*/
row += 2;
- /*
addLabel("Variable-width text field:", 1, row);
addField(35, row++, 15, false, "Field text");
addLabel("Fixed-width text field:", 1, row);
addField(35, row, 15, true);
row += 2;
- */
if (!isModal()) {
addLabel("Radio buttons and checkboxes", 1, row);
addButton("&Checkboxes", 35, row,
new TAction() {
public void DO() {
- new DemoCheckboxWindow(getApplication(), MODAL);
+ new DemoCheckboxWindow(getApplication());
}
}
);
);
}
row += 2;
+ */
- TProgressBar bar = addProgressBar(1, row, 22);
+ progressBar = addProgressBar(1, row, 22, 0);
row++;
- TLabel timerLabel = addLabel("Timer", 1, row);
- timer = parent.addTimer(100,
- {
- static int i = 0;
- auto writer = appender!dstring();
- formattedWrite(writer, "Timer: %d", i);
- timerLabel.text = writer.data;
- timerLabel.width = cast(uint)timerLabel.text.length;
- if (i < 100) {
- i++;
+ timerLabel = addLabel("Timer", 1, row);
+ timer = getApplication().addTimer(100, true,
+ new TAction() {
+
+ public void DO() {
+ timerLabel.setText(String.format("Timer: %d", timerI));
+ timerLabel.setWidth(timerLabel.getText().length());
+ if (timerI < 100) {
+ timerI++;
+ }
+ progressBar.setValue(timerI);
+ DemoMainWindow.this.setRepaint();
}
- bar.value = i;
- parent.repaint = true;
- }, true);
- */
+ }
+ );
}
}