Tick Marks for Scales

The VkTickMarks class, derived from VkComponent, displays a vertical set of tick marks. Most frequently, you would use this component next to a vertical OSF/Motif XmScale(3) widget. By default, a VkTickMarks component right-justifies its tick marks and displays its labels to the left, which is appropriate if you display the component to the left of a scale. You can also configure a VkTickMarks component to left-justify its tick marks and display its labels to the right, which is appropriate if you display the component to the right of a scale. Figure 46. shows an example of each version of the tick marks.

Figure 46. VkTickMarks Component Examples

Tick Marks Component Constructor

The VkTickMarks constructor accepts five arguments:

VkTickMarks(char* name, Widget parent, Boolean labelsToLeft = TRUE,
Boolean noLabels = FALSE, Boolean centerLabels = FALSE)

The first two arguments are the standard ObjectPak component constructor arguments, a component name and a parent widget. If labelsToLeft is TRUE, the tick marks are right-justified and the labels appear to the left; if labelsToLeft is FALSE, the tick marks are left-justified and the labels appear to the right. If you set noLabels to TRUE, the VkTickMarks component does not display any labels. If you set centerLabels to TRUE, the VkTickMarks component centers the labels. This is useful if you want to center a VkTickMarks object between two XmScale widgets.

Configuring the Tick Marks

Set the scale of the tick marks with the VkTickMarks::setScale() function:

void setScale(int min, int max,
int majorInterval, int minorInterval)


min and max specify the minimum and maximum values for the tick mark component. If you set the VkTickMarks component to display labels, it displays the minimum and maximum values next to the bottom and top tick marks, respectively.

majorInterval and minorInterval specify the tick mark spacing. You can specify the number of units between each major and minor tick mark.

For example, the following sets the minimum value of the ticks VkTickMarks object to 0, the maximum to 1000, the major interval to 100, and the minor interval to 50, as shown in Figure 47.:

ticks->setScale( 0, 1000, 100, 50 );

Figure 47. Example of Setting Tick Mark Scale and Spacing

If you do not use setScale() to set the scale of the tick marks, VkTickMarks uses the values of the resources "minimum," "maximum," "majorInterval," and "minorInterval" to set the respective scale values.

You can add additional labels to the scale with VkTickMarks::addLabel():

void addLabel(int value)

The VkTickMarks object displays a label at the value you indicate. You can call addLabel() multiple times to add multiple labels.

The VkTickMarks::setMargin() function controls the VkTickMarks margins:

void setMargin(int marginTop, int marginBottom);

setMargin() allows you to specify the spacing between the top of the VkTickMarks component and the first tick mark, and the bottom of the component and the last tick mark. The default settings are designed for use next to an XmScale widget: the first and last tick marks align horizontally with the mark in the middle of the scale's slider.

X Resources Associated with the Tick Marks Component

The VkTickMarks class provides several X resources that determine display characteristics of the component:



X Resource



Initial minimum value (default 0)


Initial maximum value (default 10)


Major tick interval (default 5)


Minor tick interval (default 1)


Width in pixels of major tick marks (default 10)


Width in pixels of minor tick mark width (default 6)


Spacing in pixels between tick marks and labels (default 3)


Margin in pixels between top of component and top tick mark (default 19)


Margin in pixels between bottom of component and bottom tick mark (default 19)


Thickness in pixels of tick marks thickness (default 1)


Foreground color used for labels and tick marks


Background color used for labels and tick marks


Font used for labels