Package ilcd
Class Control
Public Method setTextAlignment
static void setTextAlignment(int mode, int width, int height)
Throws:
_INSERT_METHOD_SIGNATURE_HERE_
Description:
Parameter |
Range |
Description |
mode |
Bit 0 ... 7 |
alignment properties |
width |
0 ... display width (0 = full display) |
width of the alignment area |
height |
0 ... display height (0 = full display) |
height of the alignment area |
This powerful method helps you to align text on the screen automatically.
The next invocation of the methode Draw.writeText(String),
Draw.writeTextMessage(int) or
Control.getTextExtent(String) will align,
word-wrap and crop text corresponding to the mode set by this
method in the specified area. A maximum of 1024 characters and 48 text lines can be aligned.
The mode consists of the following bits:
mode |
TEXT_CENTER_HORIZONTALLY |
TEXT_CENTER_VERTICALLY |
TEXT_RIGHT_JUSTIFY |
TEXT_BOTTOM_JUSTIFY |
TEXT_DO_NOT_WORD_WRAP |
TEXT_ADD_HORIZONTAL_SPACE_OF_BORDER |
TEXT_ADD_VERTICAL_SPACE_OF_BORDER |
TEXT_TURN_ALIGNMENT_ON |
Note
- After executing a method, for example Draw.writeTextMessage(int), the alignment is automatically cleared. For consecutive aligning of text strings, the set text alignment method has to be repeated!
- Bit 7 must always be set to enable the alignment settings. Clearing this bit allows an accidentally set alignment to be disabled before the text output.
- If alignment is turned on and none of the bits TEXT_CENTER_HORIZONTALLY, TEXT_CENTER_VERTICALLY, TEXT_RIGHT_JUSTIFY or TEXT_BOTTOM_JUSTIFY are set, following text will be top/left justified (just as without any alignment), but also wrapped and cropped in the specified alignment area.
- Some bits do not make sense when used together, so there are some logical precedent rules (centering always overrules justifying).
- If the text does not fit into the given area, it will be truncated. If word wrap cannot be done due to words, which are longer than the available space, or word wrapping is switched off, the rest of the word will be continued on the next line.
- If the width and/or height parameter would exceed the resulting right/bottom margin when the actual method (for example Draw.writeText(String)) is executed, the controller automatically adjusts the width and/or height accordingly to the margins.
- If the width and/or height parameter is set to 0, the controller automatically uses the maximum area available (starting from the current cursor position when an actual method is called).
- Even ANSI sequences (such as setting the font, etc.) can be used within the text to be aligned, although using cursor control ANSI commands within text alignments does not make sense and may produce unwanted results.
- Carriage returns and linefeeds can be used to force a new line regardless of the actual horizontal space already used for the current line. Entering a CR/LF pair causes one new line, entering e.g. two consecutive CRs causes two new lines.
- The default value for mode is 0. It will be automatically set to default on startup and by the methods General.resetAll() or General.rebootPanelController().
Control.setTextAlignment(Control.TEXT_CENTER_HORIZONTALLY |
Control.TEXT_CENTER_VERTICALLY |
Control.TEXT_TURN_ALIGNMENT_ON,
200, 100);
This will set text alignment to center subsequently outputted text horizontally and vertically in an area of 200 pixels width and 100 pixels height.
See also:
Copyright © demmel products gmbh. All rights reserved.