Class BidiUtil

java.lang.Object
org.eclipse.swt.internal.BidiUtil

public class BidiUtil extends Object
  • Field Details

  • Constructor Details

    • BidiUtil

      public BidiUtil()
  • Method Details

    • addLanguageListener

      public static void addLanguageListener(long hwnd, Runnable runnable)
      Adds a language listener. The listener will get notified when the language of the keyboard changes (via Alt-Shift on Win platforms). Do this by creating a window proc for the Control so that the window messages for the Control can be monitored.
      Parameters:
      hwnd - the handle of the Control that is listening for keyboard language changes
      runnable - the code that should be executed when a keyboard language change occurs
    • addLanguageListener

      public static void addLanguageListener(Control control, Runnable runnable)
    • drawGlyphs

      public static void drawGlyphs(GC gc, char[] renderBuffer, int[] renderDx, int x, int y)
      Wraps the ExtTextOut function.
      Parameters:
      gc - the gc to use for rendering
      renderBuffer - the glyphs to render as an array of characters
      renderDx - the width of each glyph in renderBuffer
      x - x position to start rendering
      y - y position to start rendering
    • getRenderInfo

      public static char[] getRenderInfo(GC gc, String text, int[] order, byte[] classBuffer, int[] dx, int flags, int[] offsets)
      Return ordering and rendering information for the given text. Wraps the GetFontLanguageInfo and GetCharacterPlacement functions.
      Parameters:
      gc - the GC to use for measuring of this line, input parameter
      text - text that bidi data should be calculated for, input parameter
      order - an array of integers representing the visual position of each character in the text array, output parameter
      classBuffer - an array of integers representing the type (e.g., ARABIC, HEBREW, LOCALNUMBER) of each character in the text array, input/output parameter
      dx - an array of integers representing the pixel width of each glyph in the returned glyph buffer, output parameter
      flags - an integer representing rendering flag information, input parameter
      offsets - text segments that should be measured and reordered separately, input parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
      Returns:
      buffer with the glyphs that should be rendered for the given text
    • getOrderInfo

      public static void getOrderInfo(GC gc, String text, int[] order, byte[] classBuffer, int flags, int[] offsets)
      Return bidi ordering information for the given text. Does not return rendering information (e.g., glyphs, glyph distances). Use this method when you only need ordering information. Doing so will improve performance. Wraps the GetFontLanguageInfo and GetCharacterPlacement functions.
      Parameters:
      gc - the GC to use for measuring of this line, input parameter
      text - text that bidi data should be calculated for, input parameter
      order - an array of integers representing the visual position of each character in the text array, output parameter
      classBuffer - an array of integers representing the type (e.g., ARABIC, HEBREW, LOCALNUMBER) of each character in the text array, input/output parameter
      flags - an integer representing rendering flag information, input parameter
      offsets - text segments that should be measured and reordered separately, input parameter. See org.eclipse.swt.custom.BidiSegmentEvent for details.
    • getFontBidiAttributes

      public static int getFontBidiAttributes(GC gc)
      Return bidi attribute information for the font in the specified gc.
      Parameters:
      gc - the gc to query
      Returns:
      bitwise OR of the REORDER, LIGATE and GLYPHSHAPE flags defined by this class.
    • getKeyboardLanguage

      public static int getKeyboardLanguage()
      Return the active keyboard language type.
      Returns:
      an integer representing the active keyboard language (KEYBOARD_BIDI, KEYBOARD_NON_BIDI)
    • isBidiPlatform

      public static boolean isBidiPlatform()
      Return whether or not the platform supports a bidi language. Determine this by looking at the languages that are installed.
      Returns:
      true if bidi is supported, false otherwise. Always false on Windows CE.
    • isKeyboardBidi

      public static boolean isKeyboardBidi()
      Return whether or not the keyboard supports input of a bidi language. Determine this by looking at the languages that are installed for the keyboard.
      Returns:
      true if bidi is supported, false otherwise.
    • removeLanguageListener

      public static void removeLanguageListener(long hwnd)
      Removes the specified language listener.
      Parameters:
      hwnd - the handle of the Control that is listening for keyboard language changes
    • removeLanguageListener

      public static void removeLanguageListener(Control control)
    • resolveTextDirection

      public static int resolveTextDirection(String text)
      Determine the base direction for the given text. The direction is derived from the first strong bidirectional RIGHT_TO_LEFT character. Or if that does not exist from the first strong LEFT_TO_RIGHT character
      Parameters:
      text - Text base direction should be resolved for.
      Returns:
      SWT#LEFT_RIGHT or SWT#RIGHT_TO_LEFT if the text contains strong characters and thus the direction can be resolved, SWT#NONE otherwise.
      Since:
      3.105
    • setKeyboardLanguage

      public static void setKeyboardLanguage(int language)
      Switch the keyboard language to the specified language type. We do not distinguish between multiple bidi or multiple non-bidi languages, so set the keyboard to the first language of the given type.
      Parameters:
      language - integer representing language. One of KEYBOARD_BIDI, KEYBOARD_NON_BIDI.
    • setOrientation

      public static boolean setOrientation(long hwnd, int orientation)
      Sets the orientation (writing order) of the specified control. Text will be right aligned for right to left writing order.
      Parameters:
      hwnd - the handle of the Control to change the orientation of
      orientation - one of SWT.RIGHT_TO_LEFT or SWT.LEFT_TO_RIGHT
      Returns:
      true if the orientation was changed, false if the orientation could not be changed
    • setOrientation

      public static boolean setOrientation(Control control, int orientation)