Jump to content

GpiSetTextAlignment: Difference between revisions

From EDM2
Created page with "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 spec..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 5: Line 5:


==Parameters==
==Parameters==
; hps ([[HPS]]) - input
; hps ([[HPS]]) - input: Presentation-space handle.
: Presentation-space handle.
; lHoriz ([[LONG]]) - input: Horizontal alignment.
 
; 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.
: 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:
: 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.
:: Left the side of the display corresponding to the lowest x-value.
:; Right the side of the display corresponding to the highest 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.
:: Top the side of the display corresponding to the highest y-value.
:; Bottom the side of the display corresponding to the lowest y-value.
:: Bottom the side of the display corresponding to the lowest y-value.
: The possible values are:
: The possible values are:
:; TA_NORMAL_HORIZ
:: TA_NORMAL_HORIZ - Normal alignment. This is the initial default. The alignment assumed depends on the current character direction as set by [[GpiSetCharDirection]]:
:: 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_LEFTRIGHT Same as TA_LEFT.
::: CHDIRN_TOPBOTTOM Same as TA_US.CENTER.
::; CHDIRN_TOPBOTTOM Same as TA_US.CENTER.
::: CHDIRN_RIGHTLEFT Same as TA_RIGHT.
::; CHDIRN_RIGHTLEFT Same as TA_RIGHT.
::: CHDIRN_BOTTOMTOP Same as TA_CENTER.
::; CHDIRN_BOTTOMTOP Same as TA_CENTER.
:: TA_LEFT - Left alignment. The string is aligned on the left edge of its leftmost character.
:; TA_LEFT
:: TA_CENTER - Center alignment. The string is aligned on the arithmetic mean of Left and Right.
:: Left alignment. The string is aligned on the left edge of its leftmost character.
:: TA_RIGHT - Right alignment. The string is aligned on the right edge of its rightmost character.
:; TA_CENTER
:: TA_STANDARD_HORIZ - Standard alignment. This is the initial default. The alignment assumed depends on the current character direction:
:: Center alignment. The string is aligned on the arithmetic mean of Left and Right.
::: CHDIRN_LEFTRIGHT Same as TA_LEFT.
:; TA_RIGHT
::: CHDIRN_TOPBOTTOM Same as TA_US.LEFT.
:: Right alignment. The string is aligned on the right edge of its rightmost character.
::: CHDIRN_RIGHTLEFT Same as TA_RIGHT.
:; TA_STANDARD_HORIZ
::: CHDIRN_BOTTOMTOP Same as TA_LEFT.
:: Standard alignment. This is the initial default. The alignment assumed depends on the current character direction:
; lVert (LONG) - input: Vertical alignment.
::; CHDIRN_LEFTRIGHT Same as TA_LEFT.
:: TA_NORMAL_VERT - Normal alignment. This is the initial default. The alignment assumed depends on the current character direction as set by [[GpiSetCharDirection]]:
::; CHDIRN_TOPBOTTOM Same as TA_US.LEFT.
::: CHDIRN_LEFTRIGHT Same as TA_BASE.
::; CHDIRN_RIGHTLEFT Same as TA_RIGHT.
::: CHDIRN_TOPBOTTOM Same as TA_US.TOP.
::; CHDIRN_BOTTOMTOP Same as TA_LEFT.
::: CHDIRN_RIGHTLEFT Same as TA_BASE.
 
::: CHDIRN_BOTTOMTOP Same as TA_BOTTOM.
; lVert ([[LONG]]) - input
:: TA_TOP - Top alignment. The string is aligned on the top edge of its topmost character.
: Vertical alignment.
:: TA_HALF - Half alignment. The string is aligned on the arithmetic mean of Bottom and Top.
:; TA_NORMAL_VERT
:: TA_BASE - Base alignment. The string is aligned on the base of its bottom character.
:: Normal alignment. This is the initial default. The alignment assumed depends on the current character direction as set by [[GpiSetCharDirection]]:
:: TA_BOTTOM - Bottom alignment. The string is aligned on the bottom edge of its bottom character.
::; CHDIRN_LEFTRIGHT Same as TA_BASE.
:: TA_STANDARD_VERT - Standard alignment. This is the initial default. The alignment assumed depends on the current character direction:
::; CHDIRN_TOPBOTTOM Same as TA_US.TOP.
::: CHDIRN_LEFTRIGHT Same as TA_BOTTOM.
::; CHDIRN_RIGHTLEFT Same as TA_BASE.
::: CHDIRN_TOPBOTTOM Same as TA_US.TOP.
::; CHDIRN_BOTTOMTOP Same as TA_BOTTOM.
::: CHDIRN_RIGHTLEFT Same as TA_BOTTOM.
:; TA_TOP
::: CHDIRN_BOTTOMTOP Same as TA_BOTTOM.
:: 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==
==Return Value==
; rc ([[BOOL]]) - returns
;rc ([[BOOL]]) - returns: Success indicator.
: Success indicator.
::TRUE - Successful completion
:; TRUE
::FALSE - Error occurred.
:: Successful completion
:; FALSE
:: Error occurred.


==Remarks==
==Remarks==
Line 73: Line 54:
==Errors==
==Errors==
Possible returns from WinGetLastError:
Possible returns from WinGetLastError:
; PMERR_INV_HPS (0x207F)
; PMERR_INV_HPS (0x207F): An invalid presentation-space handle was specified.
: 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_PS_BUSY (0x20F4)
; PMERR_INV_CHAR_ALIGN_ATTR (0x2117): The text alignment attribute specified in GpiSetTextAlignment is not valid.
: 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==
==Example Code==
<PRE>
<PRE>
#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */
#define INCL_GPIPRIMITIVES /* Or use INCL_GPI, INCL_PM, */
#include &lt;os2.h&gt;
#include <os2.h>


HPS    hps;    /* Presentation-space handle. */
HPS    hps;    /* Presentation-space handle. */

Latest revision as of 00:54, 17 November 2025

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