GpiSetTextAlignment
Appearance
This function determines the alignment used to position the characters in a string.
Syntax
GpiSetTextAlignment(hps, lHoriz, lVert)
Parameters
- hps (HPS) - input
- Presentation-space handle.
- lHoriz (LONG) - input
- Horizontal alignment.
- This parameter and the next one (lVert) specify the alignment of character strings horizontally and vertically. Together they define a reference point within the string that is positioned on the starting point specified for the string.
- Note: The terms used in this definition (left, right, top and bottom) must be interpreted with regard to the direction of the current coordinate system, as follows:
- Left the side of the display corresponding to the lowest x-value.
- Right the side of the display corresponding to the highest x-value.
- Top the side of the display corresponding to the highest y-value.
- Bottom the side of the display corresponding to the lowest y-value.
- The possible values are:
- TA_NORMAL_HORIZ
- Normal alignment. This is the initial default. The alignment assumed depends on the current character direction as set by GpiSetCharDirection:
- CHDIRN_LEFTRIGHT Same as TA_LEFT.
- CHDIRN_TOPBOTTOM Same as TA_US.CENTER.
- CHDIRN_RIGHTLEFT Same as TA_RIGHT.
- CHDIRN_BOTTOMTOP Same as TA_CENTER.
- TA_LEFT
- Left alignment. The string is aligned on the left edge of its leftmost character.
- TA_CENTER
- Center alignment. The string is aligned on the arithmetic mean of Left and Right.
- TA_RIGHT
- Right alignment. The string is aligned on the right edge of its rightmost character.
- TA_STANDARD_HORIZ
- Standard alignment. This is the initial default. The alignment assumed depends on the current character direction:
- CHDIRN_LEFTRIGHT Same as TA_LEFT.
- CHDIRN_TOPBOTTOM Same as TA_US.LEFT.
- CHDIRN_RIGHTLEFT Same as TA_RIGHT.
- CHDIRN_BOTTOMTOP Same as TA_LEFT.
- lVert (LONG) - input
- Vertical alignment.
- TA_NORMAL_VERT
- Normal alignment. This is the initial default. The alignment assumed depends on the current character direction as set by GpiSetCharDirection:
- CHDIRN_LEFTRIGHT Same as TA_BASE.
- CHDIRN_TOPBOTTOM Same as TA_US.TOP.
- CHDIRN_RIGHTLEFT Same as TA_BASE.
- CHDIRN_BOTTOMTOP Same as TA_BOTTOM.
- TA_TOP
- Top alignment. The string is aligned on the top edge of its topmost character.
- TA_HALF
- Half alignment. The string is aligned on the arithmetic mean of Bottom and Top.
- TA_BASE
- Base alignment. The string is aligned on the base of its bottom character.
- TA_BOTTOM
- Bottom alignment. The string is aligned on the bottom edge of its bottom character.
- TA_STANDARD_VERT
- Standard alignment. This is the initial default. The alignment assumed depends on the current character direction:
- CHDIRN_LEFTRIGHT Same as TA_BOTTOM.
- CHDIRN_TOPBOTTOM Same as TA_US.TOP.
- CHDIRN_RIGHTLEFT Same as TA_BOTTOM.
- CHDIRN_BOTTOMTOP Same as TA_BOTTOM.
Return Value
- rc (BOOL) - returns
- Success indicator.
- TRUE
- Successful completion
- FALSE
- Error occurred.
Remarks
This function must not be issued in an area bracket. The attribute mode determines whether the current value of the text alignment attribute is preserved. Support for this function is device dependent.
Errors
Possible returns from WinGetLastError:
- PMERR_INV_HPS (0x207F)
- An invalid presentation-space handle was specified.
- PMERR_PS_BUSY (0x20F4)
- An attempt was made to access the presentation space from more than one thread simultaneously.
- PMERR_INV_CHAR_ALIGN_ATTR (0x2117)
- The text alignment attribute specified in GpiSetTextAlignment is not valid.
Example Code
#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */ #include <os2.h> HPS hps; /* Presentation-space handle. */ LONG lHoriz; /* Horizontal alignment. */ LONG lVert; /* Vertical alignment. */ BOOL rc; /* Success indicator. */ rc = GpiSetTextAlignment(hps, lHoriz, lVert);
Graphic Elements and Orders
- Element Type
- OCODE_GSTA
- This element type is generated if the attribute mode (see GpiSetAttrMode) is set to AM_NOPRESERVE.
- Order: Set Text Alignment
- Element Type
- OCODE_GPSTA
- This element type is generated if the attribute mode is set to AM_PRESERVE.
- Order: Push and Set Text Alignment
Related Functions
- GpiCharString
- GpiCharStringAt
- GpiCharStringPos
- GpiCharStringPosAt
- GpiPop
- GpiQueryCharStringPos
- GpiQueryCharStringPosAt
- GpiQueryTextAlignment
- GpiSetAttrMode
- GpiSetAttrs
- GpiSetBackColor
- GpiSetBackMix
- GpiSetCharBox
- GpiSetCharDirection
- GpiSetCharMode
- GpiSetCharSet
- GpiSetCharShear
- GpiSetColor
- GpiSetMix
- GpiSetDefAttrs