[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Programmer's Guide



Layout Direction

Layout direction refers to the direction that is used to display visual elements such as widget children, widget components, and text. In general, this direction matches the direction that people use when reading or writing in a particular language. Languages such as English, French, German, and Swedish are read and written from left to right. Therefore, when users working in those languages enter characters from a computer keyboard, each new character is displayed to the right of the preceding one. These same users would also expect the layout of other visual elements to be displayed from left to right. For example, in a menu bar, the cascade buttons would be laid out from left to right so that a simple menu bar would position the "File" cascade button in the upper left corner, and the "Help" cascade button would appear in the upper right corner of the menu bar.

Languages such as Arabic and Hebrew are read and written from right to left. To display text correctly in these languages on the screen, each successive character that a user enters must appear to the left of the preceding character. Using the example above for layout of other visual elements, these users would expect a menu bar to lay out cascade buttons from right to left. The result would typically position the "File" cascade button in the upper right corner and the "Help" cascade button in the upper left corner of the menu bar.

There are several reasons why it is helpful for programmers to be able to specify the layout direction in applications:

  1. Application programmers want to use the same application in a variety of locales, including those with right-to-left oriented languages. They need to be able to specify that, when using a locale whose language is either Hebrew or Arabic, menus, labels, and messages, for example, should be displayed from right to left and be right justified.

  2. When applications require entering numeric values, even if the application is restricted to an audience with a right-to-left locale, users need to be able to enter numbers in certain text widgets so that they display from left to right while still entering text that displays from right to left in other text widgets.

    You can use the XmNlayoutDirection resource to set the default layout direction for your entire application. This resource specifies the default layout direction for all widgets that are affected by it. In turn, the XmNlayoutDirection resource sets a default rendering direction for any compound string (XmString) that does not have a component specifying the direction for that string. A widget that needs to render such a string should use this resource value to substitute for the missing direction indicator.

    The following two examples clarify the use of the XmNlayoutDirection resource.

    Suppose your application contains only unidirectional compound strings; that is, every XmString in the application is either left-to-right or right-to-left. To set the layout direction, all you need to do is set the appropriate value for the XmNlayoutDirection resource. You do not need to create compound strings with specific direction components. When the application renders an XmString, it should look to see if the string was created with an explicit direction (XmStringDirection). If there is no direction component, the application should check the value of the XmNlayoutDirection resource for the current widget and use that value as the default rendering direction for the XmString.

    Another more complex example involves an application that runs in a locale with right-to-left languages but includes text widgets for entering numbers, which need to be displayed from left to right. In this example, the application needs to set the XmNlayoutDirection resource to right-to-left for the entire application and then explicitly reset the XmNlayoutDirection resource to left-to-right only for those widgets that display numerical values. You still do not need to set any direction components for the compound strings themselves.

    In Motif applications, you can set the layout direction by using the XmNlayoutDirection resource from the VendorShell or MenuShell. Manager and Primitive widgets (as well as Gadgets) also have an XmNlayoutDirection resource. The default value is inherited from the closest ancestor that has the same resource.

    The layout direction resource affects some or all of the subwidgets of the following three widget classes:

    1. XmGadget

    2. XmPrimitive

    3. XmManager

      The specific effects of the XmNlayoutDirection resource vary with the widget in question. The following three sections outline these effects for the widgets in the three listed classes.

    4. XmLabelGadget and Related Widgets

      The following list describes display situations with elements of the XmLabelGadget class that are dependent on the layout direction.

      1. XmCascadeButtonGadget

        1. Positioning of cascade graphics

        2. Positioning of menu popup

        3. XmLabelGadget

          1. Meaning of XmNalignment resource values

          2. Default XmNstringDirection

          3. Positioning of accelerator text

          4. XmPushButtonGadget, XmTabButtonGadget

            1. Positioning of accelerator text

            2. Meaning of XmNalignment resource values

            3. XmToggleButtonGadget

              1. Positioning of accelerator text

              2. Meaning of XmNalignment resource values

              3. Positioning of toggle graphic

              4. XmPrimitive and Related Widgets

                The widgets XmCascadeButton, XmLabel, XmPushButton, XmTabButton, and XmToggleButton use the XmNlayoutDirection resource in the same manner as their corresponding gadget outlined in the previous section.

                Note that the arrow keys osfRight and osfLeft refer to absolute directions within a row, and do not change their meaning when a widget's layout direction changes. Similarly, osfUp and osfDown refer to absolute directions within a column, and do not change their meaning when a widget's layout direction changes. However, a widget's layout direction does affect the interpretation of the arrow keys when the pointer is at the end of a row or column. In other words, a widget's layout direction will affect the way in which the widget "wraps" when it reaches the end of a row or column.

                The following list describes display situations with elements of the XmPrimitive class that are dependent on the layout direction.

                1. XmDrawnButton

                  1. Resizing edge default

                  2. XmList

                    1. XmNstringDirection default value

                    2. Meaning of alignment resources

                    3. MARQUEE behavior during selection

                    4. XmScrollBar

                      1. Default value of XmNprocessingDirection

                      2. XmText

                        1. Text writing direction only for XmTOP_TO_BOTTOM is supported.

                        2. XmManager and Related Widgets

                          The following list describes display situations with elements of the XmManager class that are dependent on the layout direction.

                          1. XmBulletinBoard

                            1. The XmNdialogTitle direction is set from XmNstringDirection

                            2. XmComboBox

                              1. Layout of arrows with regard to text

                              2. Direction in which List can be displayed

                              3. Resize direction for List

                              4. XmCommand

                                1. Positioning of prompt string

                                2. XmContainer

                                  1. Default layout of contained objects

                                  2. Positioning of label with regard to pixmap for icons

                                  3. MARQUEE selection behavior

                                  4. Position of header

                                  5. XmDrawingArea

                                    1. Resizing edge default

                                    2. XmFileSelectionBox

                                      1. Placement of scrollbars

                                      2. XmForm

                                        1. Meaning of left and right in resource values

                                        2. Default side for attachments

                                        3. XmFrame

                                          1. Layout of children

                                          2. Meaning of XmNchild*Alignment resources

                                          3. XmMainWindow

                                            1. Layout of children

                                            2. MenuBar

                                              1. Layout of children

                                              2. XmMessageBox

                                                1. Layout of buttons

                                                2. Positioning of pixmap

                                                3. Default alignment of labels

                                                4. XmNoteBook

                                                  1. Default layout of children and book visuals

                                                  2. Meaning of "left" and "right" for arrows

                                                  3. OptionMenu

                                                    1. Alignment of label

                                                    2. Positioning of bar graphic

                                                    3. Positioning of pulldown menu

                                                    4. XmPanedWindow

                                                      1. Positioning of sash

                                                      2. Meaning of XmNsashIndent

                                                      3. PopupMenu

                                                        1. Location of hotspot

                                                        2. Positioning of menu

                                                        3. PulldownMenu

                                                          1. Alignment of edge of menu with regard to parent cascade button

                                                          2. XmRowColumn

                                                            1. Layout of children, including menu bar cascades

                                                            2. Meaning of XmNentryAlignment

                                                            3. Meaning of XmNentryVerticalAlignment

                                                            4. Meaning of XmNisAligned

                                                            5. XmScale

                                                              1. Positioning of text string

                                                              2. Positioning of value if shown

                                                              3. Default value of XmNprocessingDirection

                                                              4. Positioning of tick marks.

                                                              5. XmScrolledWindow

                                                                1. Default positioning of scrollbar

                                                                2. XmSelectionBox

                                                                  1. Layout of buttons

                                                                  2. Alignment of labels

                                                                  3. Interpretation of XmNchildPlacement resource

                                                                  4. XmSpinBox

                                                                    1. Default layout of text with regard to arrows

                                                                    2. Meaning of left and right arrows

                                                                    3. [ Previous | Next | Contents | Glossary | Home | Search ]