X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d7463f75f9c170c29b4965d27dccf535ac32cfde..04633c190f5a6eafe607a5712647aaa131522b1f:/utils/configtool/src/configitem.cpp diff --git a/utils/configtool/src/configitem.cpp b/utils/configtool/src/configitem.cpp index 2db7ac8e7a..c64056711d 100644 --- a/utils/configtool/src/configitem.cpp +++ b/utils/configtool/src/configitem.cpp @@ -9,7 +9,7 @@ // Licence: ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "configitem.h" #endif @@ -128,7 +128,7 @@ ctConfigItem* ctConfigItem::GetChild(int n) const if ( n < GetChildCount() && n > -1 ) { - ctConfigItem* child = wxDynamicCast(m_children.Nth(n)->Data(), ctConfigItem); + ctConfigItem* child = wxDynamicCast(m_children.Item(n)->GetData(), ctConfigItem); return child; } else @@ -220,6 +220,12 @@ void ctConfigItem::InitProperties() wxVariant(wxT(""), wxT("enabled-if-not")), wxT("configitems"))); + m_properties.AddProperty( + new ctProperty( + wxT("Indeterminate-if
When any of these settings are 1, this setting becomes active and indeterminate. Taking wxUSE_UNICODE as an example:
If Custom is 1, wxUSE_UNICODE is indeterminate."), + wxVariant(wxT(""), wxT("indeterminate-if")), + wxT("configitems"))); + m_properties.AddProperty( new ctProperty( wxT("Exclusivity
The settings that are mutually exclusive with this one."), @@ -255,7 +261,7 @@ void ctConfigItem::InitProperties() /// Do additional actions to apply the property to the internal /// representation. -void ctConfigItem::ApplyProperty(ctProperty* prop, const wxVariant& oldValue) +void ctConfigItem::ApplyProperty(ctProperty* prop, const wxVariant& WXUNUSED(oldValue)) { ctConfigToolDoc* doc = GetDocument(); bool oldModified = doc->IsModified(); @@ -266,6 +272,7 @@ void ctConfigItem::ApplyProperty(ctProperty* prop, const wxVariant& oldValue) name == wxT("precludes") || name == wxT("enabled-if") || name == wxT("enabled-if-not") || + name == wxT("indeterminate-if") || name == wxT("context")) { doc->RefreshDependencies(); @@ -481,11 +488,14 @@ bool ctConfigItem::IsInActiveContext() /// then this one is disabled (and inactive). void ctConfigItem::EvaluateDependencies() { + // For debugging purposes + wxString name = GetName(); wxList items; wxString requires = GetPropertyString(wxT("requires")); wxString precludes = GetPropertyString(wxT("precludes")); wxString enabledIf = GetPropertyString(wxT("enabled-if")); wxString enabledIfNot = GetPropertyString(wxT("enabled-if-not")); + wxString indeterminateIf = GetPropertyString(wxT("indeterminate-if")); bool active = TRUE; bool enabled = IsEnabled(); @@ -581,6 +591,7 @@ void ctConfigItem::EvaluateDependencies() for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() ) { ctConfigItem* otherItem = (ctConfigItem*) node->GetData(); + wxString otherName = otherItem->GetName(); if (inActiveContext && otherItem->IsInActiveContext()) { @@ -608,6 +619,7 @@ void ctConfigItem::EvaluateDependencies() { StringToItems(GetDocument()->GetTopItem(), precludes, items); int enabledCount = 0; + // int disabledCount = 0; int inContextCount = 0; for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() ) @@ -616,20 +628,55 @@ void ctConfigItem::EvaluateDependencies() if (inActiveContext && otherItem->IsInActiveContext()) { - // Make this enabled and inactive, _unless_ it's - // already been explicitly disabled in the previous - // requires evaluation (it really _has_ to be off) + // Make this disabled and inactive, _unless_ it's + // already been explicitly enabled in the previous + // requires evaluation (it really _has_ to be on) +// if (!otherItem->IsEnabled()) if (otherItem->IsEnabled()) { enabledCount ++; + // disabledCount ++; } + inContextCount ++; } } // Disable if there were no related items that were disabled - if (inContextCount > 0 && (enabledCount == inContextCount) && !explicitlyEnabled) + if (inContextCount > 0 && (enabledCount > 0) && !explicitlyEnabled) +// if (inContextCount > 0 && (disabledCount > 0) && !explicitlyEnabled) { enabled = FALSE; active = FALSE; + explicitlyDisabled = TRUE; + } + } + + // Indeterminate overrides the others, and + // makes the item active. + items.Clear(); + if (!indeterminateIf.IsEmpty()) + { + StringToItems(GetDocument()->GetTopItem(), indeterminateIf, items); + int enabledCount = 0; + int inContextCount = 0; + + for ( wxNode* node = items.GetFirst(); node; node = node->GetNext() ) + { + ctConfigItem* otherItem = (ctConfigItem*) node->GetData(); + + if (inActiveContext && otherItem->IsInActiveContext()) + { + if (otherItem->IsEnabled()) + { + enabledCount ++; + } + inContextCount ++; + } + } + if (inContextCount > 0 && enabledCount > 0) + { + active = TRUE; + explicitlyEnabled = FALSE; + explicitlyDisabled = FALSE; } } @@ -637,6 +684,13 @@ void ctConfigItem::EvaluateDependencies() // context is active. If not, make this inactive. if (!IsInActiveContext()) active = FALSE; + else + { + // If we didn't explicitly enable or disable it, + // then we should make it active. + if (!explicitlyEnabled && !explicitlyDisabled) + active = TRUE; + } SetActive(active);