/*! * \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; }
// 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; }