Rotating Label Widget

Classname: XwRotLabelWidgetClass

Description:

The Rotating Label Widget is similar to the normal Label widget, but intended to be rotated by any number of degrees. The rotation center can be defined to the lower left corner, the lower right corner or the center of the given textstring. Of course, there are some differences to the Label Widget, as, p.e. RotLabel does NOT support pixmap-labels or compound strings. Another difference is, that it is an autosize widget, i.e. It only needs the coordinates of the center-point (the rotation center), it does a self-adjustment in respect of position and size. Using GetValues, the actual position and size may be retrieved as well as the position of the center-point.

Example of three labels, different alignment:




Resources:

The widget includes the »core« and the »primitive« class with all resources. To describe the features of the rotlabel widget, it has several resources for it's own. The following table contains the resource-name, the resource-class and the access-type. Defining the resource in a general resourcefile file like .Xdefaults, means, leave out the prefix XwN or XwC. The access type defines, if the resource may be set at creation »C«, using XtSetValues »S«, only at creation»CC« and being read using XtGetValues »G«.



Name

Class

Type

Default

Access

XmNstring

XmCstring

char

NULL

C S G

XmNfontList

XmCfontList

XmFontList

XtDefaultFont

C S

XwNRotCenter

XwCRotCenter

int

XmALIGNMENT_CENTER

C S G

XwNrotation

XwCrotation

int

0

C S G

XwNmarginWidth

XwCmarginWidth

int

0

C S G

XwNRotcenterx

XwCRotcenterx

int


G

XwNRotcentery

XwCRotcentery

int


G



Detailed Description of special Resources



XmNstring

This sets the string to be displayed. In opposite to the Label Widget, this is a straight character string. Its length together with the defined font defines the size of the widget.

XmNfontList

The default font is used, if this resource isn't set. Otherwise, the label text will be displayed using this font.



XwNRotCenter

The resource XwNCenter defines the center of rotation in relation to the text. The following values are maintained:

XmALIGNMENT_CENTER the default uses the center of the given text-string for rotation, that means, that the autosize/position will put half of the text left to the given position and the other half right to the position. The similar is done for vertical position.

XmALIGNMENT_BEGINNING The lower left corner of the text bounding-box is put to the given position.

XmALIGNMENT_END The lower right corner of the zext bounding box is put to the given position.



XwNrotation

This resource gives the rotation around the center-point. The value should be given in integer degrees, either positive or negative. Positive rotation is defined counterclockwise. As this resource might be used to dynamise the Widget, a short explanation what happens:

First, the text string is written into a pixmap. The subimage of the pixmap is extracted and rotated by copying it into a new Ximage. The new Ximage then is copied to screen, adjusting the widgets positions.



XwNmarginWidth Setting XwNmarginWidth to any value other than zero will draw a rectangle with this line-width as bounding box. The rectangle is rotated together with the text.



XwNRotcenterx XwNRotcenterx

These two resources are only used to retrieve the position of the centerpoint. In case the widget should be repositioned (p.e. If moved in EasyMotif) the actual center-point position needs to be known together with the actual position of the left upper corner and width/height.

Convenience Functions:

Name: XwCreateRotLabel
Header file: »WRotLabel.h«

Widget XwCreateRotLabel ( Widget parent , char *name , ArgList arg, Cardinal argcount);

XwCreateRotLabel creates a widgetinstance of class XwRotLabelWidgetClass and returns the widget-id. The argumentlist follows the general standard.



Name: XwSetRotValues

Header file: »WRotLabel.h«

void XwSetRotValues(Widget w, ArgList args, Cardinal num_args);

As the RotLabel Widget is autosize/positioning it needs at any redrawing feature a simultanous setting of left and top attachment to NONE. This is requested by the behavior of the Form Widget. The function now checks if these settings are needed, adds the to the argument list and does a XtSetValues call.

CAUTION: Never user attachments together with the RotLabel Widget, this would lead to undefined results.


Contents

Description: 1

Resources: 1

Detailed Description of special Resources 1

Convenience Functions: 1