Example #1
0
  void backgroundImageApplied_pp(Image image) {
    // There's a problem with scrolling QTextEdit when non-single-color
    // backgrounds are used. Background can't be scrolled but needs to be
    // redrawn. To fix this we detect when background image is taken into use
    // with QTextEdit and temporarily set null background brush to viewport.
    // Viewport will inherit the background from its parent and whole area is
    // updated correctly.

    // Only MULTI uses QLineEdit
    if ((style & SWT.MULTI) == 0) return;

    int textPalette = 0;
    try {
      textPalette = OS.QWidget_swt_palette_new(handle);
      int[] bkRoles = getBackgroundImageRoles();
      for (int i = 0; i < bkRoles.length; ++i) {
        OS.QPalette_swt_setBrush(textPalette, bkRoles[i], 0);
      }
      OS.QWidget_setPalette(handle, textPalette);
    } finally {
      OS.QPalette_delete(textPalette);
    }
  }