javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/BaseCSSEngine.java
changeset 78 71ad690e91f5
parent 35 85266cc22c7f
equal deleted inserted replaced
72:1f0034e370aa 78:71ad690e91f5
    17  * </pre>
    17  * </pre>
    18  *
    18  *
    19  * <p><b>NOTE:</b> This class is intended for internal use only.</p>
    19  * <p><b>NOTE:</b> This class is intended for internal use only.</p>
    20  */
    20  */
    21 public final class BaseCSSEngine {
    21 public final class BaseCSSEngine {
       
    22 	private static final String FILE_SCHEME = "file:///";
    22 	private Display parent;
    23 	private Display parent;
    23 
    24 
    24 	/**
    25 	/**
    25 	 * Creates an engine instance.
    26 	 * Creates an engine instance.
    26 	 *
    27 	 *
    61      * </ul>
    62      * </ul>
    62 	 */
    63 	 */
    63 	public void applyCSS( String style ){
    64 	public void applyCSS( String style ){
    64 		checkEngine();
    65 		checkEngine();
    65 		if( style == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    66 		if( style == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    66 		if( style.startsWith("file:///") ) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
    67 		if( style.startsWith(FILE_SCHEME) ) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
    67 		OS.QApplication_setStyleSheet(style);
    68 		OS.QApplication_setStyleSheet(style);
    68 	}
    69 	}
    69 
    70 
    70 	/**
    71 	/**
    71 	 * Applies the given string containing valid CSS to the widget.
    72 	 * Applies the given string containing valid CSS to the widget.
    88 	public void applyCSS(Widget widget, String style ){
    89 	public void applyCSS(Widget widget, String style ){
    89 		checkEngine();
    90 		checkEngine();
    90 		if( style == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    91 		if( style == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    91 		if( widget == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    92 		if( widget == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
    92 		if( widget.isDisposed() ) SWT.error( SWT.ERROR_WIDGET_DISPOSED);
    93 		if( widget.isDisposed() ) SWT.error( SWT.ERROR_WIDGET_DISPOSED);
    93 		if( style.startsWith("file:///") ) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
    94 		if( style.startsWith(FILE_SCHEME) ) SWT.error (SWT.ERROR_INVALID_ARGUMENT);
    94 		OS.QWidget_setStyleSheet(Internal_PackageSupport.handle(widget), style);
    95 		OS.QWidget_setStyleSheet(Internal_PackageSupport.handle(widget), style);
    95 	}
    96 	}
    96 	/**
    97 	/**
    97 	 * Loads a file containing valid CSS and applies to all the widgets for Display.
    98 	 * Loads a file containing valid CSS and applies to all the widgets for Display.
    98 	 * This function bypasses java security checks for accessing the file.
    99 	 * This function bypasses java security checks for accessing the file.
   109      * </ul>
   110      * </ul>
   110 	 */
   111 	 */
   111 	public void loadCSS( String filename ){
   112 	public void loadCSS( String filename ){
   112 		checkEngine();
   113 		checkEngine();
   113 		if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
   114 		if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
   114 		OS.QApplication_setStyleSheet("file:///"+filename);
   115 		OS.QApplication_setStyleSheet(FILE_SCHEME+filename);
   115 	}
   116 	}
   116 
   117 
   117 	/**
   118 	/**
   118 	 * Loads a file containing valid CSS and applies to the widget.
   119 	 * Loads a file containing valid CSS and applies to the widget.
   119 	 * This function bypasses Java security checks for accessing the file.
   120 	 * This function bypasses Java security checks for accessing the file.
   132 	 */
   133 	 */
   133 	public void loadCSS( Widget widget, String filename ){
   134 	public void loadCSS( Widget widget, String filename ){
   134 		if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
   135 		if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
   135 		if( widget == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
   136 		if( widget == null ) SWT.error (SWT.ERROR_NULL_ARGUMENT);
   136 		if( widget.isDisposed() ) SWT.error( SWT.ERROR_WIDGET_DISPOSED);
   137 		if( widget.isDisposed() ) SWT.error( SWT.ERROR_WIDGET_DISPOSED);
   137 		OS.QWidget_setStyleSheet(Internal_PackageSupport.handle(widget), "file:///"+filename);
   138 		OS.QWidget_setStyleSheet(Internal_PackageSupport.handle(widget), FILE_SCHEME+filename);
   138 	}
   139 	}
   139 
   140 
   140 	/**
   141 	/**
   141 	 * Dispose the engine.
   142 	 * Dispose the engine.
   142 	 * @exception SWTException <ul>
   143 	 * @exception SWTException <ul>