javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/LabelExtension.java
changeset 21 2a9601315dfc
child 61 bf7ee68962da
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials 
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  * 
       
     8  * Contributors:
       
     9  *     Nokia Corporation - initial implementation 
       
    10  *******************************************************************************/
       
    11 
       
    12 package org.eclipse.swt.internal.extension;
       
    13 
       
    14 import org.eclipse.swt.internal.qt.OS;
       
    15 import org.eclipse.swt.widgets.Composite;
       
    16 import org.eclipse.swt.widgets.Internal_PackageSupport;
       
    17 import org.eclipse.swt.widgets.Label;
       
    18 
       
    19 public final class LabelExtension extends Label {
       
    20 
       
    21     public static final int STANDARDICON_ALARM = 0;
       
    22     public static final int STANDARDICON_CONFIRMATION = 1;
       
    23     public static final int STANDARDICON_ERROR = 2;
       
    24     public static final int STANDARDICON_INFO = 3;
       
    25     public static final int STANDARDICON_WARNING = 4;
       
    26 
       
    27     public LabelExtension(Composite parent, int style) {
       
    28         super(parent, style, true);
       
    29     }
       
    30 
       
    31     /**
       
    32      * Set a standard icon to the Label. Will set QPixmap directly to the native
       
    33      * Label. Note that this won't set the Image like setImage. getImage won't
       
    34      * return the standard icon.
       
    35      * 
       
    36      * @param iconType
       
    37      *            One of the standard icon constants LabelExtension.STANDARDICON_*.
       
    38      * @param iconWidth Desired width
       
    39      * @param iconHeight Desired height
       
    40      */
       
    41     public void setStandardIcon(int iconType, int iconWidth, int iconHeight) {
       
    42         int standardIcon = 0;
       
    43 
       
    44         switch (iconType) {
       
    45         case STANDARDICON_ALARM:
       
    46             standardIcon = OS.QSTYLE_SP_MESSAGEBOXWARNING;
       
    47             break;
       
    48         case STANDARDICON_CONFIRMATION:
       
    49             standardIcon = OS.QSTYLE_SP_MESSAGEBOXQUESTION;
       
    50             break;
       
    51         case STANDARDICON_ERROR:
       
    52             standardIcon = OS.QSTYLE_SP_MESSAGEBOXCRITICAL;
       
    53             break;
       
    54         case STANDARDICON_INFO:
       
    55             standardIcon = OS.QSTYLE_SP_MESSAGEBOXINFORMATION;
       
    56             break;
       
    57         case STANDARDICON_WARNING:
       
    58             standardIcon = OS.QSTYLE_SP_MESSAGEBOXWARNING;
       
    59             break;
       
    60         default:
       
    61             return;
       
    62         }
       
    63         
       
    64         Internal_PackageSupport.setStandardIcon(this, standardIcon, iconWidth, iconHeight);
       
    65     }
       
    66 }