use of edu.cmu.cs.hcii.cogtool.model.RadioButton in project cogtool by cogtool.
the class FrameEditorController method createWidget.
private Widget createWidget(WidgetType defaultType, DoubleRectangle bounds, String widgetTitle, boolean isStandard) {
Widget widget;
// the user specified actual bounds interactively
if (isStandard) {
if (defaultType == WidgetType.Menu) {
SimpleWidgetGroup newMenuHeaderGroup = new SimpleWidgetGroup(SimpleWidgetGroup.HORIZONTAL);
widget = new MenuHeader(newMenuHeaderGroup, bounds, widgetTitle);
} else if (defaultType == WidgetType.PullDownList) {
widget = new PullDownHeader(bounds, widgetTitle);
} else if (defaultType == WidgetType.ContextMenu) {
widget = new ContextMenu(bounds, widgetTitle);
// The default value for CONTEXT_MENU_ACTION_ATTR
// is RIGHT_CLICK; must change to TAP_HOLD if the devices
// contain a Touchscreen but not a Mouse
Set<DeviceType> deviceTypes = design.getDeviceTypes();
if (deviceTypes.contains(DeviceType.Touchscreen) && !deviceTypes.contains(DeviceType.Mouse)) {
widget.setAttribute(WidgetAttributes.CONTEXT_MENU_ACTION_ATTR, WidgetAttributes.TAP_HOLD);
}
} else if (defaultType == WidgetType.ListBoxItem) {
SimpleWidgetGroup newListItemGroup = new SimpleWidgetGroup(SimpleWidgetGroup.VERTICAL);
widget = new ListItem(newListItemGroup, bounds, widgetTitle);
newListItemGroup.setAttribute(WidgetAttributes.FIRST_VISIBLE_ATTR, widget);
} else if (defaultType == WidgetType.Radio) {
RadioButtonGroup newRadioGroup = new RadioButtonGroup();
widget = new RadioButton(newRadioGroup, bounds, widgetTitle);
} else if (defaultType == WidgetType.Check) {
GridButtonGroup newCheckGroup = new GridButtonGroup();
widget = new CheckBox(newCheckGroup, bounds, widgetTitle);
} else {
// Create new widget in specified location
// Note: could be a child widget;
// if so, the user is managing the hierarchy!
widget = new Widget(bounds, defaultType);
}
widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_STANDARD);
} else {
// Create new widget in specified location
// Note: could be a child widget;
// if so, the user is managing the hierarchy!
widget = new Widget(bounds, defaultType);
widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_CUSTOM);
}
return widget;
}
use of edu.cmu.cs.hcii.cogtool.model.RadioButton in project cogtool by cogtool.
the class FrameEditorController method createNewWidgetAction.
/**
* Create a ListenerAction to handle creating a new Widget.
*
*/
private IListenerAction createNewWidgetAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
// TODO: Should we provide more input to this default widget?
// Dialog box with option?
// Current/last palette setting
// TODO: Bonnie wanted to have new widgets show up under the
// mouse. To do that we need to do something like
// getCursorLocation() (from display)
// offset based on the (0,0) of the window
// Might want to get that based on GetCursorControl().
// If working with the control, you need to walk the tree to
// get the actual offset from 0,0, in the display.
//
// Alternatively, in specialize, get the mouse pointer position
// from mousestate (but that would require tracking the mouse
// state -- on hover at least).
// Instantiate the appropriate widget. If the class was passed
// a prms, use that to dictate what to do.
Widget widget = null;
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(NEW_WIDGET, FrameEditorLID.NewWidget);
if (prms instanceof FrameEditorUI.NewWidgetParameters) {
FrameEditorUI.NewWidgetParameters nwp = (FrameEditorUI.NewWidgetParameters) prms;
// widget
if (nwp.parent != null) {
if (nwp.type == WidgetType.MenuItem) {
// Create menu item; may become a submenu through
// user interaction later
widget = new MenuItem((AMenuWidget) nwp.parent, nwp.bounds, nwp.widgetTitle);
} else if (nwp.type == WidgetType.PullDownItem) {
widget = new PullDownItem((PullDownHeader) nwp.parent, nwp.bounds, nwp.widgetTitle);
boolean rendered = nwp.parent.isRendered();
SimpleWidgetGroup group = widget.getParentGroup();
group.setAttribute(WidgetAttributes.IS_RENDERED_ATTR, Boolean.valueOf(rendered));
}
} else // widget group
if (nwp.parentGroup != null) {
if (nwp.type == WidgetType.Menu) {
widget = new MenuHeader(nwp.parentGroup, nwp.bounds, nwp.widgetTitle);
} else if (nwp.type == WidgetType.ListBoxItem) {
widget = new ListItem(nwp.parentGroup, nwp.bounds, nwp.widgetTitle);
} else if (nwp.type == WidgetType.Radio) {
widget = new RadioButton((RadioButtonGroup) nwp.parentGroup, nwp.bounds, nwp.widgetTitle);
} else if (nwp.type == WidgetType.Check) {
widget = new CheckBox((GridButtonGroup) nwp.parentGroup, nwp.bounds, nwp.widgetTitle);
}
} else {
widget = createWidget(nwp.type, nwp.bounds, nwp.widgetTitle, nwp.isAutomatic);
}
if (nwp.isSeparator) {
frameSetAttribute(widget, WidgetAttributes.IS_SEPARATOR_ATTR, WidgetAttributes.IS_SEPARATOR, editSequence);
}
}
// if (widget.getWidgetType() == WidgetType.TextBox) {
// widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR,
// WidgetAttributes.IS_CUSTOM);
// }
// Auto-generate a unique name for the widget
widget.setName(generateUniqueWidgetName());
// Build the widget: check for uniqueness and add to the frame
boolean result = addCreatedWidget(widget, editSequence);
editSequence.end();
undoMgr.addEdit(editSequence);
return result;
}
};
}
Aggregations