public class FontChooserGuiImpl extends FrameGuiImpl implements Container<GuiOutputManager>, IsModal, ActionListener
NOTE: Known issues:
1. at this moment, the list of fonts is obtained from the AWT graphic environment. This is
fine for Swing FWD driver, but it does not make sense for web driver. Alternatively, we
can use a predefined list of fonts like the DEFAULT_FONTS (or maybe request them from
server);
2. I could not find a way to get properties of a specified font. Properties like ANSI
compatibility, FIXED-SIZE and SCRIPT are not fully functional. The exclusions for ANSI
and FIXED fonts are implemented by hardcoded (constant) lists;
3. Strikeout property has no support in FontStyle
; FWD cannot handle it.
Modifier and Type | Class and Description |
---|---|
private class |
FontChooserGuiImpl.FontChooserLayout
The manager that does the layout of the widgets of this frame.
|
private class |
FontChooserGuiImpl.Preview
Shows a quick preview of the font properties selected in dialog.
|
FrameGuiImpl.GuiScrollContainer
Frame.ScrollContainer
Modifier and Type | Field and Description |
---|---|
private ButtonGuiImpl |
accept
The button for accepting the current selection.
|
private boolean |
accepted
Flag that turns to true only if the user closed the dialog by accepting it.
|
private static java.lang.String[] |
ANSI_FIXED_FONTS
A list of known fonts to have both FIXED-SIZE and ANSI compatible property.
|
private static java.lang.String[] |
ANSI_FONTS
A list of known ANSI fonts.
|
private CoordinatesConversion |
cc
Cached coordinates.
|
private static java.lang.String[] |
DEFAULT_FONTS
The list of default font names.
|
private static java.lang.String[] |
DEFAULT_SCRIPTS
The names of script support.
|
private static int[] |
DEFAULT_SIZES
The list of standard sizes for the fonts.
|
private RectangleGuiImpl |
effectsGroup
The effects groupbox.
|
private SimpleLabel |
effectsLabel
The label of the EFFECTS groupbox.
|
private static java.lang.String[] |
FIXED_FONTS
A list of known fixed-size fonts.
|
private ComboBoxGuiImpl |
fontFaceCbx
The combobox allowing to chose the font face.
|
private SimpleLabel |
fontLabel
A label for the combobox allowing to chose the font face.
|
private ComboBoxGuiImpl |
fontSizeCbx
The combobox allowing to chose the font size.
|
private ComboBoxGuiImpl |
fontStyleCbx
The combobox allowing to chose the font style.
|
private GuiDriver |
gd
Cached driver.
|
private boolean |
inputDone
Flag which tracks user input.
|
private int |
maxSize
Locally saves the maximum size of the font for validation.
|
private int |
minSize
Locally saves the minimum size of the font for validation.
|
private int |
NATIVE_HEIGHT
The native height of the dialog.
|
private int |
NATIVE_WIDTH
The native width of the dialog.
|
private FontChooserGuiImpl.Preview |
preview
A quick preview of the selected font.
|
private ButtonGuiImpl |
reject
The button for rejecting hte dialog.
|
private RectangleGuiImpl |
sampleGroup
The sample groupbox.
|
private SimpleLabel |
sampleLabel
The label of the SAMPLE groupbox.
|
private ComboBoxGuiImpl |
scriptCbx
The combobox allowing to chose the font's scripting.
|
private SimpleLabel |
scriptLabel
A label for the combobox allowing to chose the font scripting.
|
private SimpleLabel |
sizeLabel
A label for the combobox allowing to chose the font size.
|
private ToggleBoxGuiImpl |
strikeChk
Configures whether the font instance is stroke at the middle (strikeout).
|
private SimpleLabel |
styleLabel
A label for the combobox allowing to chose the font style.
|
private static java.lang.String[] |
STYLES
The styles of the fonts: all combinations of bold and italic attributes.
|
private ToggleBoxGuiImpl |
underlineChk
Configures whether the font instance is underlined.
|
chooseHandler, configUpdateActive, contentPane, currentStatement, cursor, down, downBody, EXTRA_DLG_PIXELS, frameScroll, headersHeight, headersOutput, lastRow, needPause, nonbody, originalHeightChars, paintable, redirected, savedTabOrder, startRow, touched, trailingSkips, underline, underlinedRow, verticalStepBoxed
location, mousePtr, nativeInsets, physicalLocation
Modifier | Constructor and Description |
---|---|
private |
FontChooserGuiImpl(WidgetId id,
FrameConfig cfg)
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addWidget(Widget<GuiOutputManager> widget)
Adding new widget to the container.
|
void |
configure(java.lang.String fontName,
int fontSize,
boolean bold,
boolean italic,
boolean underline,
boolean strikeout)
Configures the dialog by setting the widgets to reflect the properties of the current font.
|
private ButtonGuiImpl |
createButton(java.lang.String text,
java.lang.String action,
int width,
int height,
boolean def)
Creates and initializes a customized button widget.
|
private ComboBoxGuiImpl |
createCombobox(ComboBoxConfig.Mode mode,
int x,
int y,
int w,
int h,
ControlSetItem[] items,
java.lang.String selVal,
java.lang.String format)
Creates a customized
ComboBoxGuiImpl to be used on this dialog. |
private RectangleGuiImpl |
createGoupbox(int x,
int y,
int w,
int h)
Creates a customized
RectangleGuiImpl to be used on this dialog. |
static FontChooserGuiImpl |
createInstance(int windowId,
boolean ansiOnly,
boolean fixedOnly,
int minSize,
int maxSize)
Factory method.
|
private SimpleLabel |
createSimpleLabel(java.lang.String text,
int w,
int h,
boolean rightAlign)
Creates a customized
SimpleLabel to be used on this dialog. |
private ToggleBoxGuiImpl |
createTogglebox(java.lang.String text,
int x,
int y,
int w,
int h)
Creates a customized
ToggleBoxGuiImpl to be used on this dialog. |
void |
dismiss()
Set the result code, hide the dialog and flag input as complete.
|
private static java.lang.String[] |
getAvailableFonts()
Obtain available fonts from the graphic environment.
|
int |
getFontSize()
Obtain the currently selected size of the font.
|
FontDetails<?> |
getSelectedFont()
Returns the font that the user has selected.
|
protected void |
init(boolean ansiOnly,
boolean fixedOnly,
int minSize,
int maxSize)
Initialize the dialog by performing tasks that was not possible in the constructor because
it was not fully created.
|
boolean |
isAccepted()
Checks whether the user accepted the selection from the dialog.
|
boolean |
isDismissed()
Get status of the input processing.
|
void |
onAction(ActionEvent event)
This method is invoked when action event is generated.
|
activateDirectManipulation, adjustMinSize, adjustWidth, afterConfigUpdate, calculateHeight, calculateHeightDelta, captionHeight, compareColors, convertToStreamable, createMouseHoverAction, createScrollContainer, deactivateDirectManipulation, defaultFocus, destroy, doLayoutWorker, draw, drawDownFrame, drawUnderline, findMouseSource, frameContentBounds, getColorResolver, getCustomMousePointer, getDialogDecorationCharSize, getDynamicLayout, getFrameBgColor, getFrameFgColor, getLabelHeight, getLabelWidth, getMaxFrameSize, getPortableMouseEventCoordinates, getResizeRectangle, getRowDelta, getTitleHeight, hasBox, initialize, isDirectManipulationRequired, isDroppable, location, mouseActions, physicalLocation, processCancelButton, processDefaultButton, processDirectManipulationEvent, realizeFrame, resetColors, setFocus, setOuterSize, setVisible, supportsCustomMousePointer
adjustDown, adjustDown, allFramesVisible, applyConfig, arrangeToInteract, arrangeToStream, attachToWindow, calculateFrameRect, calculateWidthDelta, canSetColumn, canSetHeightChars, canSetRow, canSetWidthChars, clear, clearCurrent, clearWorker, clipping, config, copyState, currentFocus, doLayout, doLayout, draw, enableAllWidgets, enabledWidgetsByList, enterChoose, fixNonBody, forceBox, getBorderBottomChars, getBorderLeftChars, getBorderRightChars, getBorderTopChars, getChooseData, getChooseHelp, getContentPane, getCursor, getDown, getDownConfigs, getField, getField, getFirstEnabledWidget, getFirstFocusableId, getFirstFocusableId, getFixedHeight, getFocusId, getFrameValue, getFrameValue, getInnerSize, getIterationHeight, getIterationIds, getLeadingSkipSize, getMinHeight, getNextEnabledWidget, getNextTabItemList, getOriginalHeightChars, getRootFrame, getSavedDimension, getScopeNesting, getSelectedField, getSelectedWidget, getStreamId, getTrailingSkipSize, getValues, getZOrderClass, hasAnyEnabled, hasDefaultButton, hasEditors, hasEnabled, hasHeaders, hasSavedState, hasTitle, isActive, isAlive, isAllClear, isAttrSpace, isAutoplacing, isCanHide, isCanHideOthers, isCanWipeScreen, isChanged, isChooseActive, isConfigUpdateActive, isCurrentTouched, isDelayedRepaint, isDialog, isDown, isDownCalculated, isDynamic, isExplicitHide, isFixedWidth, isFocusAttractor, isFocusReset, isForcedRefresh, isForcePause, isForceWipeScreen, isHonorNextConditionalDown, isInChoose, isInScope, isInternalGo, isLabels, isLastWidget, isLeftMostWidget, isNeedPause, isNeedReset, isNoHide, isPendingFixedDown, isPendingUnderline, isPlacedForRedirected, isRedirected, isRightMostWidget, isRootFrame, isSideLabels, isStreamed, isThreeD, isTopFrame, isViewed, isVisibilityChanged, isWithHeaders, leaveChoose, markAsStreamed, markChanged, moveAboveWidget, moveBelowWidget, moveCursor, moveToBottom, moveToTop, moveWidgetBeforeTabItem, needClearRow, notifyClose, notifyPageBreak, notifyUnbind, placeAtTop, placed, placeToWindow, placeToWindow, postponePlace, postponeSetVisible, postprocess, postprocessConfig, prepareIteration, preprocess, previousFocus, processFrameMnemonic, processKeyEvent, rearrangeEditors, relayout, relocateComponent, repaint, repaintCurrent, repaintUninitialized, requestFocus, reset, resetAll, resetAutoplacing, resetChanged, resetForcedRefresh, resetNeedPause, resetPlacementQuirk, resetWidget, resolveWidgetId, restore, restoreEditors, restoreInitialTabOrder, scroll, setAlive, setAllClear, setAttrSpace, setBodyVisible, setBox, setCanHide, setCanHideOthers, setCanWipeScreen, setChooseAt, setColumns, setCurrentStatement, setCursor, setDelayedRepaint, setDown, setDynCol, setDynRow, setExplicitHide, setFocusAttractor, setFocusId, setFocusReset, setForcePause, setForceWipeScreen, setFormatCheck, setHeight, setHonorNextConditionalDown, setInnerSize, setInScope, setLabels, setLayout, setNeedPause, setNeedPauseDirect, setNeedReset, setNextTabItemList, setPaintable, setPendingFixedDown, setPendingUnderline, setProtected, setRedirected, setSavedDimension, setScopeNesting, setSensitive, setSize, setState, setValue, setValue, setViewed, setVisibilityChanged, setWidth, shortName, switchLabelsEmptyMode, toString, touchBody, touchRow, unbind, underline, updateInnerSize, view
add, add, add, addContainerStateListener, addDirectly, belongsTo, checkWidget, childrenLocation, clipRectangle, currentFocus, cycleFocus, detach, dimension, dumpCurrentWidgets, dumpWidgets, endSizeChange, firstFocus, focus, focusTraversable, focusWorker, formatDump, get, getClipRect, getEffectiveScrollableSize, getFocusInt, getIgnoreFocus, getLayout, getScrollableSize, getTabItemList, hasFocusable, height, insets, lastFocus, minimumSize, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, normalizeZOrder, onWidgetAdded, onWidgetRemoved, prepareWidgets, prevFocus, reflectAncestorChange, reflectLocationChange, remove, removeContainerStateListener, replace, requestFocus, setFocusInt, setIgnoreFocus, setInsets, setSize, setTabItemList, startSizeChange, triggerContainerStateRedrawEnabled, unrealize, updateSizeWorker, widgets, widgetsAsList, width
_setHidden, _setVisible, addFocusListener, addKeyListener, afterConfigUpdateBase, ancestor, ancestorId, autoResize, bounds, clear, clearWidget, clipRectangle, clipRectangle, clipWith, copyColors, debug, disable, displayPhysicalLocation, drawCaret, enable, enclosingFrame, forceCursorOnFocus, forceVisibility, getActualBounds, getAndResetBitmap, getAndSetBitmap, getBitmapCopy, getCachedScreenLocation, getCachedScreenPhysicalLocation, getDefaultEvent, getEffectiveMousePointer, getId, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getTextHeight, getTextHeightNative, getTextWidth, getTextWidth, getTextWidthNative, getTextWidthNative, getVisiblePart, hasFocus, hidden, hide, highlighted, ignoreAction, isCurrent, isDirectManipulationCapable, isDisplayed, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isScreenLocationCached, isTabStop, isTotallyObscured, isVisible, isVisible, manageSystemActions, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, prepParentLocation, processEvent, processFocusEvent, processKeyListeners, processMnemonic, processMnemonicImpl, processSystemKey, raiseLegacyMouseEvents, refresh, registerWidgetStateListener, repaint, requestSync, resetBitmap, resizeTo, resolveFont, resolvePopupMenuId, resolveTitleFont, screen, screenDimension, screenHeight, screenLocation, screenPhysicalLocation, screenWidth, setBitmap, setCachedScreenLocation, setCachedScreenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, show, showPopupMenu, sync, topLevelWindow, translate, window
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, add, add, addContainerStateListener, childrenLocation, clipping, currentFocus, currentFocus, defaultFocus, detach, doLayout, endSizeChange, firstFocus, focus, get, getClipRect, getIgnoreFocus, getLayout, getTabItemList, hasFocusable, insets, lastFocus, moveAfterTabItem, moveBeforeTabItem, moveToBottom, moveToBottomInClass, moveToTop, moveToTopInClass, moveToZpos, nextFocus, prevFocus, remove, removeContainerStateListener, replace, setFocus, setHeight, setIgnoreFocus, setInsets, setLayout, setSize, setSize, setWidth, startSizeChange, widgets, widgetsAsList
addFocusListener, addKeyListener, ancestor, ancestorId, bounds, clearWidget, config, defaultMousePtr, destroy, dimension, displayPhysicalLocation, draw, drawCaret, enclosingFrame, enforceDefaultMousePtr, findMouseSource, focusTraversable, forceCursorOnFocus, forceVisibility, getActualBounds, getCustomMousePointer, getEffectiveMousePointer, getId, getLegacyWidget, getLoadedMousePointer, getMenuMouse, getMouseActions, getSelectedText, getState, getVisiblePart, getZOrderClass, hasFocus, height, hidden, hide, highlighted, isCurrent, isDirectManipulable, isDisplayed, isDroppable, isEnabled, isFocusable, isHeader, isRealized, isRepaintDisabled, isRMBEntrySupported, isTabStop, isThreeD, isTotallyObscured, isVisible, isVisible, location, maySwitchFocus, minimumSize, moveToBottom, moveToTop, name, navigable, parent, parent, parentObject, parentOrSelf, parentOrSelfObject, physicalBounds, physicalDimension, physicalLocation, postprocessConfig, processDirectManipulationEvent, processEvent, processFocusEvent, processKeyEvent, processKeyListeners, processMnemonic, raiseLegacyMouseEvents, repaint, repaint, requestFocus, requestFocus, requestSync, resizeTo, resolvePopupMenuId, screen, screenLocation, screenPhysicalLocation, setEnabled, setHidden, setHighlighted, setLocation, setLocation, setMousePointer, setParent, setPhysicalLocation, setState, setVisible, show, supportsCustomMousePointer, topLevelWindow, unrealize, width, window
mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased
convertToStreamable
private final int NATIVE_WIDTH
private final int NATIVE_HEIGHT
private boolean accepted
private boolean inputDone
private GuiDriver gd
private CoordinatesConversion cc
private SimpleLabel fontLabel
private SimpleLabel styleLabel
private SimpleLabel sizeLabel
private SimpleLabel scriptLabel
private SimpleLabel effectsLabel
private SimpleLabel sampleLabel
private RectangleGuiImpl effectsGroup
private RectangleGuiImpl sampleGroup
private ComboBoxGuiImpl fontFaceCbx
private ComboBoxGuiImpl fontStyleCbx
private ComboBoxGuiImpl fontSizeCbx
private ComboBoxGuiImpl scriptCbx
private ToggleBoxGuiImpl strikeChk
private ToggleBoxGuiImpl underlineChk
private ButtonGuiImpl accept
private ButtonGuiImpl reject
private FontChooserGuiImpl.Preview preview
private int minSize
private int maxSize
private static final java.lang.String[] DEFAULT_FONTS
private static final java.lang.String[] FIXED_FONTS
private static final java.lang.String[] ANSI_FONTS
private static final java.lang.String[] ANSI_FIXED_FONTS
private static final int[] DEFAULT_SIZES
private static final java.lang.String[] DEFAULT_SCRIPTS
private static final java.lang.String[] STYLES
private FontChooserGuiImpl(WidgetId id, FrameConfig cfg)
createInstance(int, boolean, boolean, int, int)
factory
method.id
- The WidgetId
of the dialog.cfg
- The FrameConfig
of the dialog.public static FontChooserGuiImpl createInstance(int windowId, boolean ansiOnly, boolean fixedOnly, int minSize, int maxSize)
FontChooserGuiImpl
dialog.windowId
- The parent window of the newly created dialog.ansiOnly
- The dialog will present to user to select only fonts that are ANSI compatible (that
do not include graphic symbols).fixedOnly
- The dialog will present to user to select only fixed-size fonts (also known as
monospace in which all characters take the same width when displayed).minSize
- Constraint on font-size. User is not allowed to select (or key-in) a font-size that
is less than this value. In case he does, a warning dialog will remind him of the
constraint.maxSize
- Constraint on font-size. User is not allowed to select (or key-in) a font-size that
is greater than this value. In case he does, a warning dialog will remind him of
the constraint.FontChooserGuiImpl
configured as requested.protected void init(boolean ansiOnly, boolean fixedOnly, int minSize, int maxSize)
ansiOnly
- If true
filter only the ANSI fonts.fixedOnly
- If true
filter only fixed-sized the ANSI fonts.minSize
- The minimum size of the fonts allowed to be selected.maxSize
- The maximum size of the fonts allowed to be selected.public boolean isAccepted()
true
if the dialog was accepted, and false
if the dialog was not
yet displayed or it was rejected by user.public boolean isDismissed()
isDismissed
in interface IsModal
public void dismiss()
public void onAction(ActionEvent event)
onAction
in interface ActionListener
event
- Event which triggered this call.public void configure(java.lang.String fontName, int fontSize, boolean bold, boolean italic, boolean underline, boolean strikeout)
fontName
- The font name.fontSize
- The font size.bold
- true
if the font is bold.italic
- true
if the font is italic.underline
- true
if the font is underlined.strikeout
- true
if the font is stroke at the middle.public int getFontSize()
public FontDetails<?> getSelectedFont()
FontDetails
object with all
properties from the dialog set and null
if the dialog was not accepted
(still running or rejected).public void addWidget(Widget<GuiOutputManager> widget)
widget
.addWidget
in class Frame<GuiOutputManager>
widget
- The new widget to be added to the container.private static java.lang.String[] getAvailableFonts()
private ButtonGuiImpl createButton(java.lang.String text, java.lang.String action, int width, int height, boolean def)
text
- The text (label) displayed on the button.action
- The action to trigger when button is pressed.width
- The width of the button (native units).height
- The height of the button (native units).def
- true
if this is the default button for the frame.ButtonGuiImpl
instance.private SimpleLabel createSimpleLabel(java.lang.String text, int w, int h, boolean rightAlign)
SimpleLabel
to be used on this dialog.text
- The text to be displayed.w
- The physical width of the label.h
- The physical height of the label.rightAlign
- Whether the text is right aligned.SimpleLabel
.private RectangleGuiImpl createGoupbox(int x, int y, int w, int h)
RectangleGuiImpl
to be used on this dialog.w
- The physical width of the widget.h
- The physical height of the widget.x
- The physical X coordinate of the widget.y
- The physical Y coordinate of the widget.RectangleGuiImpl
.private ComboBoxGuiImpl createCombobox(ComboBoxConfig.Mode mode, int x, int y, int w, int h, ControlSetItem[] items, java.lang.String selVal, java.lang.String format)
ComboBoxGuiImpl
to be used on this dialog.mode
- The type of combobox to be returned.w
- The physical width of the widget.h
- The physical height of the widget.x
- The physical X coordinate of the widget.y
- The physical Y coordinate of the widget.items
- An array of items to be used in the combobox.selVal
- The value to be selected bu default.format
- The format of the displayed data.ComboBoxGuiImpl
.private ToggleBoxGuiImpl createTogglebox(java.lang.String text, int x, int y, int w, int h)
ToggleBoxGuiImpl
to be used on this dialog.text
- The text (label) of the toggle button.w
- The physical width of the widget.h
- The physical height of the widget.x
- The physical X coordinate of the widget.y
- The physical Y coordinate of the widget.ToggleBoxGuiImpl
.