Пример #1
0
const wxString ecConfigItem::StringValue(ecWhereType where) const
{
    wxString str;
    switch(where){
    case ecInName:
        str=GetName();
        break;
    case ecInMacro:
        str=GetMacro();
        break;
    case ecInDesc:
        str=GetDescription();
        break;
    case ecInCurrentValue:
        if (ecOptionTypeNone==GetOptionType())
	    str = wxEmptyString;
        else
            str = StringValue(CdlValueSource_Current);
        break;
    case ecInDefaultValue:
        if (ecOptionTypeNone==GetOptionType())
	    str = wxEmptyString;
        else
            str = StringValue(CdlValueSource_Default);
        break;
    default:
        wxASSERT(FALSE);
        break;
    }
    return str;
}    
Пример #2
0
bool ecConfigItem::TransferDataFromWindow(wxWindow* window)
{
    ecConfigToolDoc* doc = wxGetApp().GetConfigToolDoc();
    wxASSERT (doc != NULL);

    if (!doc)
        return FALSE;

    if (window->IsKindOf(CLASSINFO(ecTextEditorCtrl)))
    {
        ecTextEditorCtrl* win = (ecTextEditorCtrl*) window;

        wxASSERT ( GetOptionType() == ecString );

        // TODO: do checking
        wxString str(win->GetValue());
        str.Replace("\\n", "\n"); // remove escaping of newline chars
        doc->SetValue(*this, str);
    }
    else if (window->IsKindOf(CLASSINFO(ecDoubleEditorCtrl)))
    {
        ecDoubleEditorCtrl* win = (ecDoubleEditorCtrl*) window;

        wxASSERT ( GetOptionType() == ecDouble );

        // TODO: do checking
        doc->SetValue(*this, atof(win->GetValue()));
    }
    else if (window->IsKindOf(CLASSINFO(ecEnumEditorCtrl)))
    {
        ecEnumEditorCtrl* win = (ecEnumEditorCtrl*) window;

        wxASSERT ( GetOptionType() == ecEnumerated );

        // TODO: do checking
        doc->SetValue(*this, win->GetStringSelection());
    }
    else if (window->IsKindOf(CLASSINFO(ecIntegerEditorCtrl)))
    {
        ecIntegerEditorCtrl* win = (ecIntegerEditorCtrl*) window;

        wxASSERT ( GetOptionType() == ecLong );

        // TODO: do checking
        doc->SetValue(*this, (long) win->GetValue());
    }

    return TRUE;
}
/*!
 * \brief Create a control to edit our value.
 *
 * This routine is called when the user clicks on an editable
 * item in the value window.
 */
wxWindow *CConfigItem::CreateEditWindow(wxWindow * parent)
{
    wxWindow *window = NULL;

    switch (GetOptionType()) {
    case nutEnumerated:
        /* Create drop down box for enumerated values. */
    {
        window = new CEnumEditCtrl(parent, ID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize, 0);
        wxArrayString arEnumStrings;
        GetEnumStrings(arEnumStrings);
        for (unsigned int i = 0; i < arEnumStrings.GetCount(); i++) {
            ((CEnumEditCtrl *) window)->Append(arEnumStrings[i]);
        }
    }
    break;
    case nutInteger:
        /* Use a spin control for integer values. */
        window = new CIntEditCtrl(parent, ID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS);
        break;
    case nutString:
        /* Normal entry control for string values. */
        window = new CTextEditCtrl(parent, ID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
        break;
    }

    wxASSERT(window != NULL);

    return window;
}
/*!
 * \brief Refresh a CConfigItem entry in a specified CConfigTree.
 */
bool CConfigItem::UpdateTreeItem(CConfigTree & treeCtrl)
{
    treeCtrl.SetItemText(m_itemId, GetBriefDescription());

    static wxColour normalColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    static wxColour disabledColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);

    treeCtrl.SetItemTextColour(m_itemId, normalColour);

    int iconState = 0;
    wxString iconName;

    switch (GetConfigType()) {
    case nutFolder:
        iconName = wxT("Folder");
        break;
    case nutLibrary:
        iconName = wxT("Library");
        break;
    case nutModule:
        iconName = wxT("Module");
        break;
    case nutOption:
        if (GetOptionFlavor() == nutFlavorData) {
            switch (GetOptionType()) {
            case nutInteger:
                iconName = wxT("Integer");
                break;
            case nutEnumerated:
                iconName = wxT("Enumerated");
                break;
            case nutString:
                iconName = wxT("Text");
                break;
            case nutBool:
                if (GetUIHint() == nutHintRadio)
                    iconName = wxT("Radiobox");
                else
                    iconName = wxT("Checkbox");
                iconState = (m_value.GetBool()? 0 : 1);
                break;
            }
        }
        if (GetOptionFlavor() == nutFlavorBoolData || GetOptionFlavor() == nutFlavorBool) {
            if (GetUIHint() == nutHintRadio)
                iconName = wxT("Radiobox");
            else
                iconName = wxT("Checkbox");
            iconState = (IsActive()? 0 : 1);
        }
        break;
    }

    if (!iconName.IsEmpty()) {
        int iconId = treeCtrl.GetIconDB().GetIconId(iconName, iconState, IsEnabled());
        treeCtrl.SetItemImage(m_itemId, iconId, wxTreeItemIcon_Normal);
        treeCtrl.SetItemImage(m_itemId, iconId, wxTreeItemIcon_Selected);
    }
    return true;
}
Пример #5
0
bool ecConfigItem::IsModifiable() const
{
    const CdlValuable valuable = GetCdlValuable();
    if (valuable && ((GetOptionType() != ecOptionTypeNone) || HasBool()))
    {
        return (valuable->is_modifiable () && valuable->is_active ());
    }
    else
        return GetCdlItem()->is_active();
}
/*!
 * \brief Retrieve value from an edit control.
 *
 * Called when editing the value of an item has stopped.
 *
 * \param window The edit control.
 */
bool CConfigItem::TransferDataFromWindow(wxWindow * window)
{
    CNutConfDoc *doc = wxGetApp().GetNutConfDoc();
    wxASSERT(doc != NULL);

    if (!doc)
        return false;

    /* Retrieve value from text edit control. */
    if (window->IsKindOf(CLASSINFO(CTextEditCtrl))) {
        CTextEditCtrl *win = (CTextEditCtrl *) window;

        wxASSERT(GetOptionType() == nutString);

        // TODO: do checking
        doc->SetValue(*this, win->GetValue().Trim(false));
    }

    /* Retrieve value from enumerated edit control. */
    else if (window->IsKindOf(CLASSINFO(CEnumEditCtrl))) {
        CEnumEditCtrl *win = (CEnumEditCtrl *) window;

        wxASSERT(GetOptionType() == nutEnumerated);

        // TODO: do checking
        doc->SetValue(*this, win->GetStringSelection().Trim(false));
    }

    /* Retrieve value from integer edit control. */
    else if (window->IsKindOf(CLASSINFO(CIntEditCtrl))) {
        CIntEditCtrl *win = (CIntEditCtrl *) window;

        wxASSERT(GetOptionType() == nutInteger);

        // TODO: do checking
        doc->SetValue(*this, (long) win->GetValue());
    }
    return true;
}
wxString CConfigItem::GetDisplayValue() const
{
    wxString str;

    switch (GetOptionType()) {
    case nutEnumerated:
    case nutInteger:
    case nutString:
        str = StringValue();
        break;
    }
    return str;
}
/*!
 * \brief Return configuration item as a string.
 */
wxString CConfigItem::StringValue() const
{
    if (m_option) {
        if (m_option->nco_value) {
            return wxString(m_option->nco_value,wxConvLocal);
        }
        if (GetOptionType() == nutEnumerated) {
            if (m_option->nco_choices && m_option->nco_choices[0]) {
                return wxString(m_option->nco_choices[0],wxConvLocal);
            }
        }
    }
    return wxEmptyString;
}
Пример #9
0
// Creates an edit window. It will be positioned by the caller.
wxWindow* ecConfigItem::CreateEditWindow(wxWindow* parent)
{
    wxWindow* window = NULL;

    switch(GetOptionType())
    {
    case ecEnumerated:
        {
            window = new ecEnumEditorCtrl(parent, ecID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize,
                /* wxNO_BORDER */ 0);
            wxArrayString arEnumStrings;
            EvalEnumStrings(arEnumStrings);
            int i;
            for (i = 0; i < arEnumStrings.GetCount(); i++)
            {
                ((ecEnumEditorCtrl*) window)->Append(arEnumStrings[i]);
            }
            break;
        }
    case ecLong:
        {
            window = new ecIntegerEditorCtrl(parent, ecID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize,
                /* wxNO_BORDER | */ wxSP_ARROW_KEYS);
            break;
        }
    case ecDouble:
        {
            window = new ecDoubleEditorCtrl(parent, ecID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize,
                /* wxNO_BORDER|*/ wxTE_PROCESS_ENTER);
            break;
        }
    case ecString:
        {
            window = new ecTextEditorCtrl(parent, ecID_ITEM_EDIT_WINDOW, wxDefaultPosition, wxDefaultSize,
                /* wxNO_BORDER|*/ wxTE_PROCESS_ENTER);
            break;
        }
    default:
        break;
    }

    wxASSERT (window != NULL) ;
    
    return window;
}
Пример #10
0
//해당 옵션이 없으면 0 리턴!
int CItems::GetWearLevelReduction()
{
	for( SBYTE sbOption = 0; sbOption < MAX_OPTION_INC_ORIGIN; ++sbOption )
	{
		SBYTE sbOptionType = GetOptionType( sbOption );
		LONG lOptionLevel = GetOptionLevel( sbOption );

		if( sbOptionType == -1 || lOptionLevel == 0 )
			break;

		//착용제한레벨 다운 옵션
		if( sbOptionType == OPTION_DOWN_LIMITLEVEL)
		{
			COptionData* podItem = COptionData::getData( sbOptionType );
			if (podItem == NULL)
				return 0;

			return podItem->GetValue( lOptionLevel - 1 );
		}
	}
	
	return 0;
}
Пример #11
0
void xrSASH::GetAllOptions()
{
	Msg("SASH:: GetAllOptions.");
	TryInitEngine();

	oaNamedOptionStruct Option; 
	oaInitOption(&Option);
	
	DescribeOption("renderer",		Option.Dependency);
	DescribeOption("vid_mode",		Option.Dependency);
	DescribeOption("rs_fullscreen", Option.Dependency);

	DescribeOption("rs_vis_distance",				Option.Dependency);
	DescribeOption("r__geometry_lod",				Option.Dependency);
	DescribeOption("r__detail_density",				Option.Dependency);
	DescribeOption("texture_lod",					Option.Dependency);
	DescribeOption("r__tf_aniso",					Option.Dependency);
	DescribeOption("ai_use_torch_dynamic_lights",	Option.Dependency);

	//	r1 only
	Option.Dependency.ParentName = TEXT("renderer");
	Option.Dependency.ComparisonOp = OA_COMP_OP_EQUAL;
	Option.Dependency.ComparisonVal.Enum = TEXT("renderer_r1");
	Option.Dependency.ComparisonValType = GetOptionType("renderer");
	{
		DescribeOption("r__supersample",		Option.Dependency);
		DescribeOption("r1_no_detail_textures", Option.Dependency);
	}

	//	>=r2
	oaInitOption(&Option);	//	Reset dependency info
	//	Currently only equal/not equal works
	//Option.Dependency.ParentName = TEXT("renderer");
	//Option.Dependency.ComparisonOp = OA_COMP_OP_GREATER_OR_EQUAL;
	//Option.Dependency.ComparisonVal.Enum = TEXT("renderer_r2");
	//Option.Dependency.ComparisonValType = GetOptionType("renderer");
	{
		DescribeOption("r2_sun", Option.Dependency);
		DescribeOption("r2_sun_quality", Option.Dependency);
		DescribeOption("r2_slight_fade", Option.Dependency);
		DescribeOption("r2_ls_squality", Option.Dependency);
		DescribeOption("r2_detail_bump", Option.Dependency);
	}

	//	>=r2.5
	//Option.Dependency.ParentName = TEXT("renderer");
	//Option.Dependency.ComparisonOp = OA_COMP_OP_GREATER_OR_EQUAL;
	//Option.Dependency.ComparisonVal.Enum = TEXT("renderer_r2.5");
	//Option.Dependency.ComparisonValType = GetOptionType("renderer");
	{
		DescribeOption("r2_sun_shafts",			Option.Dependency);
		DescribeOption("r2_ssao",				Option.Dependency);
		DescribeOption("r2_ssao_opt_data",		Option.Dependency);
		DescribeOption("r2_ssao_half_data",		Option.Dependency);
		DescribeOption("r2_ssao_hbao",			Option.Dependency);
		DescribeOption("r2_soft_water",			Option.Dependency);
		DescribeOption("r2_soft_particles",		Option.Dependency);
		DescribeOption("r2_dof_enable",			Option.Dependency);
		DescribeOption("r2_volumetric_lights",	Option.Dependency);
		DescribeOption("r2_steep_parallax",		Option.Dependency);
	}

	//	>=r3
	//Option.Dependency.ParentName = TEXT("renderer");
	//Option.Dependency.ComparisonOp = OA_COMP_OP_GREATER_OR_EQUAL;
	//Option.Dependency.ComparisonVal.Enum = TEXT("renderer_r3");
	//Option.Dependency.ComparisonValType = GetOptionType("renderer");
	{
		DescribeOption("r3_dynamic_wet_surfaces",Option.Dependency);
		DescribeOption("r3_volumetric_smoke",	Option.Dependency);
		DescribeOption("r3_gbuff_opt",			Option.Dependency);
		DescribeOption("r3_use_dx10_1",			Option.Dependency);
		DescribeOption("r3_minmax_sm",			Option.Dependency);
		DescribeOption("r3_msaa",				Option.Dependency);
		//	>= 2x
		//Option.Dependency.ParentName = TEXT("r3_msaa");
		//Option.Dependency.ComparisonOp = OA_COMP_OP_GREATER_OR_EQUAL;
		//Option.Dependency.ComparisonVal.Enum = TEXT("2x");
		//Option.Dependency.ComparisonValType = GetOptionType("r3_msaa");
		{
			DescribeOption("r3_msaa_opt",			Option.Dependency);
			DescribeOption("r3_msaa_alphatest",		Option.Dependency);
		}
	}

	ReleaseEngine();
}
Пример #12
0
// Gets the value to display (often an empty string)
wxString ecConfigItem::GetDisplayValue() const
{
    wxString str;
    switch(GetOptionType())
    {
    case ecEnumerated:
    case ecLong:
    case ecDouble:
    case ecString:
        {
            if (GetCdlValuable())
                str = StringValue();
                str.Replace("\n", "\\n"); // escape any newline chars (eg CYGDAT_UITRON_TASK_INITIALIZERS)
        }
        break;
    default:
        break;
    }
    return str;
#if 0
    switch (GetConfigType())
    {
        case ecComponent:
        case ecContainer:
            {
                return wxEmptyString;
                break;
            }
        case ecPackage:
            {
                return m_value.GetString();
                break;
            }
        case ecOption:
            {
                switch (GetOptionType())
                {
                    case ecDouble:
                        {
                            wxString val;
                            val.Printf("%.4lf", (double) m_value.GetDouble());
                            return val;
                        }
                    case ecLong:
                        {
                            wxString val;
                            val.Printf("%.ld", (long) m_value.GetLong());
                            return val;
                            break;
                        }
                    case ecEnumerated:
                    case ecString:
                        {
                            return m_value.GetString();
                            break;
                        }
                    case ecBool:
                        {
                            return wxEmptyString;
                            break;
                        }
                    default:
                        {
                            break;
                        }
                }
                break;
            }
        default:
            {
                break;
            }
    }

    return wxEmptyString;
#endif
}
Пример #13
0
// Handle a left click on the icon: e.g. (un)check the option
// In the old MFC tool, this was handled by CControlView::Bump
void ecConfigItem::OnIconLeftDown(ecConfigTreeCtrl& treeCtrl)
{
    if (GetConfigType() != ecOption)
        return;

    switch (GetOptionFlavor())
    {
    case ecFlavorBool:
    case ecFlavorBoolData:
        {
            if (GetModifiable())
            {
                wxGetApp().GetConfigToolDoc()->SetEnabled(*this, !m_enabled);
            }
            break;
        }
    case ecFlavorData:
        {
            if (GetModifiable())
            {
                switch (GetOptionType())
                {
                case ecLong:
                    {
                        int nInc = 1;

                        long nOldValue = Value();
                        if(nInc==1 && nOldValue == long(-1))
                        {
                            nOldValue=0;
                        } else if(nInc==-1 && nOldValue==0){
                            nOldValue = long(-1);
                        } else {
                            nOldValue+=nInc;
                        }
                        wxGetApp().GetConfigToolDoc()->SetValue(*this, nOldValue);
                        break;
                    }
                case ecEnumerated:
                    {
                        int nInc = 1;

                        wxArrayString arEnum;
                        EvalEnumStrings (arEnum); // calculate legal values just in time
                        if (0 == arEnum.GetCount()) // if no legal values...
                            break;           // ...do nothing
                        int nIndex = -1;
                        const wxString strCurrent = StringValue ();
                        int nEnum;
                        for (nEnum = 0; (nEnum < arEnum.GetCount()) && (nIndex == -1); nEnum++)
                            if (0 == arEnum[nEnum].CompareTo (strCurrent))
                                nIndex = nEnum; // the index of the current value
                            
                            if (nIndex != -1) // if the current value is still legal
                                nIndex += (nInc < 0 ? -1 : 1); // increment/decrement the index
                            else
                                nIndex = 0; // otherwise select the first enum
                            
                            if (nIndex < 0) // if the new index is negative
                                nIndex = arEnum.GetCount()-1; // make it positive

                            wxGetApp().GetConfigToolDoc()->SetValue(*this, arEnum[nIndex % arEnum.GetCount()]);
                            break;
                    }
                default:
                    {
                        break;
                    }
                }
            }
            break;   
        }
    default:
        {
            break;
        }
    }

}
Пример #14
0
// Sets the text and icon for this item
bool ecConfigItem::UpdateTreeItem(ecConfigTreeCtrl& treeCtrl)
{
    treeCtrl.SetItemText(m_treeItem, GetItemNameOrMacro());

#if wxCHECK_VERSION(2, 6, 0)
    static wxColour normalColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
    static wxColour disabledColour = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
#else
    static wxColour normalColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOWTEXT);
    static wxColour disabledColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_GRAYTEXT);
#endif

    treeCtrl.SetItemTextColour(m_treeItem, GetActive() ? normalColour : disabledColour);
    

    // Find which icon state we're in so we can get the appropriate icon id
    int iconState = 0;
    wxString iconName;

    switch (GetConfigType())
    {
        case ecContainer:
            {
                iconName = _("Container");
                iconState = 0;
                break;
            }
        case ecPackage:
            {
                iconName = _("Package");
                iconState = 0;
                break;
            }
        case ecComponent:
            {
                iconName = _("??");
                iconState = 0;
                break;
            }
        case ecOption:
            {
                if (GetOptionFlavor() == ecFlavorData)
                {
                    switch (GetOptionType())
                    {
                    case ecDouble:
                    case ecLong:
                        {
                            iconName = _("Integer");
                            iconState = 0;
                            break;
                        }
                    case ecEnumerated:
                        {
                            iconName = _("Enumerated");
                            iconState = 0;
                            break;
                        }
                    case ecString:
                        {
                            iconName = _("Text");
                            iconState = 0;
                            break;
                        }
                    // ??? Actually I don't think there's such a think as ecBool type, only enabled/disabled
                    case ecBool:
                        {
                            if (GetUIHint() == ecHintCheck)
                                iconName = _("Checkbox");
                            else
                                iconName = _("Radiobox");
                            iconState = (m_value.GetBool() ? 0 : 1);
                            break;
                        }
                    default:
                        {
                            break;
                        }
                    }
                }
                if (GetOptionFlavor() == ecFlavorBoolData || GetOptionFlavor() == ecFlavorBool)
                {
                    if (GetUIHint() == ecHintCheck)
                        iconName = _("Checkbox");
                    else
                        iconName = _("Radiobox");
                    iconState = (m_enabled ? 0 : 1);
                }
                break;
            }
        default:
            {
                break;
            }
    }

    if (!iconName.IsEmpty())
    {
        int iconId = treeCtrl.GetIconDB().GetIconId(iconName, iconState, GetModifiable());
        treeCtrl.SetItemImage(m_treeItem, iconId, wxTreeItemIcon_Normal);
        treeCtrl.SetItemImage(m_treeItem, iconId, wxTreeItemIcon_Selected);
    }

    return TRUE;
}
Пример #15
0
// Bump by specified amount, or toggle if a boolean value
bool ecConfigItem::BumpItem(int nInc)
{
    bool rc = FALSE;
    
    // Take an action for clicking on the icon
    ecConfigToolDoc* pDoc = wxGetApp().GetConfigToolDoc();
    
    // do not modify the option value if it is inactive or not modifiable
    const CdlValuable valuable = GetCdlValuable();
    if (!valuable || (valuable->is_modifiable () && valuable->is_active ()))
    {
        if (0 == nInc) // if a toggle request
        {
            if (HasBool () && ! (HasRadio () && IsEnabled ())) { // only enable (not disable) a radio button
                rc = pDoc->SetEnabled (*this, ! this->IsEnabled ()); // toggle enabled/disabled state
            }
        } else if (IsEnabled ()) { // the item is enabled...
            switch(GetOptionType())
            {
            case ecOptionTypeNone:
            case ecString:
            case ecDouble:
                break;
            case ecEnumerated:
                {
                    wxArrayString arEnum;
                    EvalEnumStrings (arEnum); // calculate legal values just in time
                    if (0==arEnum.Count()) // if no legal values...
                        break;           // ...do nothing
                    int nIndex = -1;
                    const wxString strCurrent = StringValue ();
                    int nEnum;
                    for (nEnum = 0; (nEnum < arEnum.Count()) && (nIndex == -1); nEnum++)
                        if (strCurrent == arEnum[nEnum])
                            nIndex = nEnum; // the index of the current value
                        
                        if (nIndex != -1) // if the current value is still legal
                            nIndex += (nInc < 0 ? -1 : 1); // increment/decrement the index
                        else
                            nIndex = 0; // otherwise select the first enum
                        
                        if (nIndex < 0) // if the new index is negative
                            nIndex = arEnum.Count()-1; // make it positive
                        
                        rc=pDoc->SetValue (*this, arEnum[nIndex % arEnum.Count()]);
                }
                break;
            case ecLong:
                {
                    // TODO: if we're editing, we should get the value in the edit item
                    // and not the ecConfigItem.
                    long nOldValue = Value();
                    if(nInc==1 && nOldValue==-1){
                        nOldValue=0;
                    } else if(nInc==-1 && nOldValue==0){
                        nOldValue=-1;
                    } else {
                        nOldValue+=nInc;
                    }
                    rc=pDoc->SetValue(*this, nOldValue);
                    break;
                }
                
                break;
                /*
                case CConfigItem::Boolean:
                
                  {
                  ItemIntegerType nOldValue=Value(h);
                  pDoc->SetValue(ti,nOldValue^1);
                  }
                  break;
                  case CConfigItem::Radio:
                  
                    if(0==Value(h)){
                    pDoc->SetValue(ti, (ItemIntegerType) 1);
                    }
                    break;
                */
            default:
                break;
            }
        }
    }
    return rc;
}
Пример #16
0
	JNIEXPORT jint JNICALL Java_aflobby_CUnitSyncJNIBindings_GetOptionType
		(JNIEnv *env, jclass myobject, jint optIndex){
			return GetOptionType(optIndex);
	}