⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 swtselectionhelper.java

📁 A translator that converts Qt Designer UI files into SWT java classes. Use the power of Qt Designer
💻 JAVA
字号:

package ui2swt.swt;

import ui2swt.UIDefinition;
import ui2swt.Widget;


public class SWTSelectionHelper extends SWTHelper
{
    public static final int SWT_SELECTION_SINGLE        = 1;
    public static final int SWT_SELECTION_MULTI         = 2;
    public static final int SWT_SELECTION_EXTENDED      = 3;
    public static final int SWT_SELECTION_CONTIGUOUS    = 4;
    public static final int SWT_SELECTION_NONE          = 5;

    
    //
    //
    //

    private static final String UI_SELECTION_MODE = "selectionMode.enum";

    private static final String UI_SELECTION_MODE_STRING_VALUE_2[] =
        {   "Single",
            "Multi",
            "Extended",
            "Contiguous",
            "NoSelection" };

    private static final String UI_SELECTION_MODE_STRING_VALUE_3[] =
        {   "Single",
            "Multi",
            "Extended",
            "Contiguous",
            "NoSelection" };

    private static final String UI_SELECTION_MODE_STRING_VALUE_4[] =
        {   "QAbstractItemView::SingleSelection",
            "QAbstractItemView::MultiSelection",
            "QAbstractItemView::ExtendedSelection",
            "QAbstractItemView::ContiguousSelection",
            "QAbstractItemView::NoSelection" };

    private static final int UI_SELECTION_MODE_INT_VALUE[] =
        {   SWT_SELECTION_SINGLE,
            SWT_SELECTION_MULTI,
            SWT_SELECTION_EXTENDED,
            SWT_SELECTION_CONTIGUOUS,
            SWT_SELECTION_NONE };

    
    //
    //
    //
    
    public static int getSelectionMode(
        UIDefinition    iUIDefinition,
        Widget          iWidget )
    {
        int result = SWT_SELECTION_SINGLE;
        
        switch (iUIDefinition.getVersion())
        {
            case UIDefinition.VERSION_2:
                result = 
                    iWidget.getEnumProperty(
                        UI_SELECTION_MODE,
                        UI_SELECTION_MODE_STRING_VALUE_2,
                        UI_SELECTION_MODE_INT_VALUE,
                        SWT_SELECTION_SINGLE);
                break;
                
            case UIDefinition.VERSION_3:
                result = 
                    iWidget.getEnumProperty(
                        UI_SELECTION_MODE,
                        UI_SELECTION_MODE_STRING_VALUE_3,
                        UI_SELECTION_MODE_INT_VALUE,
                        SWT_SELECTION_SINGLE);
                break;
                
            case UIDefinition.VERSION_4:
                result = 
                    iWidget.getEnumProperty(
                        UI_SELECTION_MODE,
                        UI_SELECTION_MODE_STRING_VALUE_4,
                        UI_SELECTION_MODE_INT_VALUE,
                        SWT_SELECTION_SINGLE);
                break;
        }
        
        return result;
    }

    
    public static void appendSelectionModeStyle(
        UIDefinition    iUIDefinition,
        Widget          iWidget,
        StringBuffer    iStyle )
    {
        switch (getSelectionMode(iUIDefinition, iWidget))
        {
            case SWT_SELECTION_MULTI:
            case SWT_SELECTION_EXTENDED:
            case SWT_SELECTION_CONTIGUOUS:
                appendStyleValue(iStyle, "SWT.MULTI");
                break;

            case SWT_SELECTION_SINGLE:
            case SWT_SELECTION_NONE:
            default:
                appendStyleValue(iStyle, "SWT.SINGLE");
                break;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -