예제 #1
0
void PrefabSelector::populatePrefabs()
{
	_populated = true;

    if (_populator && _populator->getPrefabPath() == getPrefabFolder())
    {
        // Population already running for this path
        return;
    }

    // Clear the existing run first (this waits for it to finish)
    _populator.reset();

	// Clear the treestore first
	_treeStore->Clear();

	wxutil::TreeModel::Row row = _treeStore->AddItem();

	wxIcon prefabIcon;
	prefabIcon.CopyFromBitmap(
		wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "cmenu_add_prefab.png"));

	row[_columns.filename] = wxVariant(wxDataViewIconText(_("Loading..."), prefabIcon));
	row[_columns.isFolder] = false;
	row.SendItemAdded();

    _populator.reset(new PrefabPopulator(_columns, this, getPrefabFolder()));

	// Start the thread, will send an event when finished
	_populator->populate();
}
예제 #2
0
void StimTypes::setStimTypeCaption(int id, const std::string& caption)
{
	StimTypeMap::iterator found = _stimTypes.find(id);

	if (found != _stimTypes.end())
	{
		_stimTypes[id].caption = caption;

		// Combine the ID and the caption
		std::string captionPlusId = caption;
		bool showStimTypeIds = registry::getValue<bool>(RKEY_SHOW_STIM_TYPE_IDS);
		captionPlusId += showStimTypeIds ? " (" + string::to_string(id) + ")" : "";

		// Update the list store
		wxutil::TreeModel::Row row(getIterForId(id), *_listStore);

		wxBitmap bmp = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + _stimTypes[id].icon);
		wxIcon stimIcon;
		stimIcon.CopyFromBitmap(bmp);

		row[_columns.caption] = wxVariant(wxDataViewIconText(_stimTypes[id].caption, stimIcon));
		row[_columns.captionPlusID] = captionPlusId;

		row.SendItemChanged();
	}
}
예제 #3
0
void MyListModel::GetValueByRow( wxVariant &variant,
                                 unsigned int row, unsigned int col ) const
{
    switch ( col )
    {
        case Col_EditableText:
            if (row >= m_textColValues.GetCount())
                variant = wxString::Format( "virtual row %d", row );
            else
                variant = m_textColValues[ row ];
            break;

        case Col_IconText:
            {
                wxString text;
                if ( row >= m_iconColValues.GetCount() )
                    text = "virtual icon";
                else
                    text = m_iconColValues[row];

                variant << wxDataViewIconText(text, m_icon[row % 2]);
            }
            break;

        case Col_Date:
            variant = wxDateTime(1, wxDateTime::Jan, 2000).Add(wxTimeSpan(row));
            break;

        case Col_TextWithAttr:
            {
                static const char *labels[5] =
                {
                    "blue", "green", "red", "bold cyan", "default",
                };

                variant = labels[row % 5];
            }
            break;

        case Col_Custom:
            {
                IntToStringMap::const_iterator it = m_customColValues.find(row);
                if ( it != m_customColValues.end() )
                    variant = it->second;
                else
                    variant = wxString::Format("%d", row % 100);
            }
            break;

        case Col_Max:
            wxFAIL_MSG( "invalid column" );
    }
}
예제 #4
0
파일: mymodels.cpp 프로젝트: euler0/Helium
void MyListModel::GetValueByRow( wxVariant &variant,
                                 unsigned int row, unsigned int col ) const
{
    switch ( col )
    {
        case Col_EditableText:
            if (row >= m_textColValues.GetCount())
                variant = wxString::Format( "virtual row %d", row );
            else
                variant = m_textColValues[ row ];
            break;

        case Col_IconText:
            {
                wxString text;
                if ( row >= m_iconColValues.GetCount() )
                    text = "virtual icon";
                else
                    text = m_iconColValues[row];

                variant << wxDataViewIconText(text, m_icon[row % 2]);
            }
            break;

        case Col_TextWithAttr:
            {
                static const char *labels[5] =
                {
                    "blue", "green", "red", "bold cyan", "default",
                };

                variant = labels[row % 5];
            }
            break;

        case Col_Custom:
            variant = wxString::Format("%d", row % 100);
            break;

        case Col_Max:
            wxFAIL_MSG( "invalid column" );
    }
}
예제 #5
0
void MediaBrowser::populate()
{
	if (!_isPopulated)
	{
		// Clear our treestore and put a single item in it
		_treeStore->Clear();

		wxutil::TreeModel::Row row = _treeStore->AddItem();

		wxIcon icon;
		icon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + TEXTURE_ICON));
		row[_columns.iconAndName] = wxVariant(wxDataViewIconText(_("Loading, please wait..."), icon));

		row.SendItemAdded();
	}

	// Set the flag to true to avoid double-entering this function
	_isPopulated = true;

	// Start the background thread
	_populator.reset(new Populator(_columns, this));
	_populator->populate();
}
예제 #6
0
void StimTypes::add(int id,
					const std::string& name,
					const std::string& caption,
					const std::string& description,
					const std::string& icon,
					bool custom)
{
	StimType newStimType;
	newStimType.name = name;
	newStimType.caption = caption;
	newStimType.description = description;
	newStimType.icon = icon;
	newStimType.custom = custom;

	// Add the stim to the map
	_stimTypes[id] = newStimType;

	// Combine the ID and the caption
	std::string captionPlusId = caption;
	bool showStimTypeIds = registry::getValue<bool>(RKEY_SHOW_STIM_TYPE_IDS);
	captionPlusId += showStimTypeIds ? " (" + string::to_string(id) + ")" : "";

	wxutil::TreeModel::Row row = _listStore->AddItem();

	wxBitmap bmp = wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + newStimType.icon);
	wxIcon stimIcon;
	stimIcon.CopyFromBitmap(bmp);

	row[_columns.id] = id;
	row[_columns.caption] = wxVariant(wxDataViewIconText(_stimTypes[id].caption, stimIcon));
	row[_columns.captionPlusID] = captionPlusId;
	row[_columns.name] = _stimTypes[id].name;
	row[_columns.isCustom] = custom;

	row.SendItemAdded();
}
예제 #7
0
void
wxTreeListModel::GetValue(wxVariant& variant,
                          const wxDataViewItem& item,
                          unsigned col) const
{
    Node* const node = FromDVI(item);

    if ( col == 0 )
    {
        // Determine the correct image to use depending on the item state.
        int image = wxWithImages::NO_IMAGE;
        if ( m_treelist->IsExpanded(node) )
            image = node->m_imageOpened;

        if ( image == wxWithImages::NO_IMAGE )
            image = node->m_imageClosed;

        wxIcon icon = m_treelist->GetImage(image);

        if ( m_treelist->HasFlag(wxTL_CHECKBOX) )
            variant << wxDataViewCheckIconText(node->m_text, icon,
                                               node->m_checkedState);
        else
            variant << wxDataViewIconText(node->m_text, icon);
    }
    else
    {
        // Notice that we must still assign wxString to wxVariant to ensure
        // that it at least has the correct type.
        wxString text;
        if ( node->HasColumnsTexts() )
            text = node->GetColumnText(col);

        variant = text;
    }
}
예제 #8
0
// Populate tree view
void AddPropertyDialog::populateTreeView()
{
	wxIcon folderIcon;
	folderIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));

	// DEF-DEFINED PROPERTIES
	{
		// First add a top-level category named after the entity class, and populate
		// it with custom keyvals defined in the DEF for that class
		std::string cName = _entity->getEntityClass()->getName();

		wxutil::TreeModel::Row defRoot = _treeStore->AddItem();

		wxDataViewItemAttr blueBold;
		blueBold.SetColour(wxColor(0,0,255));
		blueBold.SetBold(true);

		defRoot[_columns.displayName] = wxVariant(wxDataViewIconText(cName, folderIcon));
		defRoot[_columns.displayName] = blueBold;
		defRoot[_columns.propertyName] = "";
		defRoot[_columns.description] = _(CUSTOM_PROPERTY_TEXT);

		defRoot.SendItemAdded();

		// Use a CustomPropertyAdder class to visit the entityclass and add all
		// custom properties from it
		CustomPropertyAdder adder(_entity, _treeStore, _columns, defRoot.getItem());
		_entity->getEntityClass()->forEachClassAttribute(boost::ref(adder));
	}

	// REGISTRY (GAME FILE) DEFINED PROPERTIES 

	// Ask the XML registry for the list of properties
    game::IGamePtr currentGame = GlobalGameManager().currentGame();
    xml::NodeList propNodes = currentGame->getLocalXPath(PROPERTIES_XPATH);

	// Cache of property categories to GtkTreeIters, to allow properties
	// to be parented to top-level categories
	typedef std::map<std::string, wxDataViewItem> CategoryMap;
	CategoryMap categories;

	// Add each .game-specified property to the tree view
	for (xml::NodeList::const_iterator iter = propNodes.begin();
		 iter != propNodes.end();
		 ++iter)
	{
		// Skip hidden properties
		if (iter->getAttributeValue("hidden") == "1")
		{
			continue;
		}

		wxDataViewItem item;

		// If this property has a category, look up the top-level parent iter
		// or add it if necessary.
		std::string category = iter->getAttributeValue("category");

		if (!category.empty())
		{
			CategoryMap::iterator mIter = categories.find(category);

			if (mIter == categories.end())
			{
				// Not found, add to treestore
				wxutil::TreeModel::Row catRow = _treeStore->AddItem();

				catRow[_columns.displayName] = wxVariant(wxDataViewIconText(category, folderIcon));;
				catRow[_columns.propertyName] = "";
				catRow[_columns.description] = "";

				// Add to map
				mIter = categories.insert(CategoryMap::value_type(category, catRow.getItem())).first;

				catRow.SendItemAdded();
			}

			// Category sorted, add this property below it
			item = _treeStore->AddItem(mIter->second).getItem();

			_treeStore->ItemAdded(mIter->second, item);
		}
		else
		{
			// No category, add at toplevel
			item = _treeStore->AddItem().getItem();

			_treeStore->ItemAdded(_treeStore->GetRoot(), item);
		}

		// Obtain information from the XML node and add it to the treeview
		std::string name = iter->getAttributeValue("match");
		std::string type = iter->getAttributeValue("type");
		std::string description = iter->getContent();

		wxutil::TreeModel::Row row(item, *_treeStore);

		wxIcon icon;
		icon.CopyFromBitmap(PropertyEditorFactory::getBitmapFor(type));

		row[_columns.displayName] = wxVariant(wxDataViewIconText(name, icon));
		row[_columns.propertyName] = name;
		row[_columns.description] = description;

		_treeStore->ItemChanged(item);
	}
}
예제 #9
0
 /**
  * @brief Get Value By Row.
  */
void PMBUSCMDListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned int col) const
{
	wxString rawStr("");
	
	switch (col)
	{
	case Col_Toggle:
		if (this->m_available[row]==false){
			variant = false;
		}
		else{
			variant = true;
		}
		break;
	case Col_RegisterIconText:
	{
		//PSU_DEBUG_PRINT("Count of m_registerColValues = %d", m_registerColValues.GetCount());
		wxString text;
		if (row >= m_registerColValues.GetCount()){
			text = "virtual icon";
		}
		else{
			text = m_registerColValues[row];
		}

		//variant << wxDataViewIconText(text, m_icon[row % 2]);
		if(this->m_available[row] == true){

			switch (this->m_pmBusCommand[row].m_cmdStatus.m_status){

			case cmd_status_not_run:
				if (PMBUSHelper::isOwnReadAccess(this->m_pmBusCommand[row].m_access) == true){//this->m_pmBusCommand[row].m_access != cmd_access_write){
					variant << wxDataViewIconText(text, m_icon[XPM_red]);
				}
				else{
					variant << wxDataViewIconText(text, m_icon[XPM_grey]);
				}
				break;

			case cmd_status_running:
				variant << wxDataViewIconText(text, m_icon[XPM_yellow]);
				break;

			case cmd_status_success:
				variant << wxDataViewIconText(text, m_icon[XPM_green]);
				break;

			case cmd_status_failure:
			case cmd_status_checksum_error:
			case cmd_status_i2c_bus_not_acknowledge:
				variant << wxDataViewIconText(text, m_icon[XPM_red]);
				break;


			default:
				PSU_DEBUG_PRINT(MSG_ERROR, "CMD Status Abnormal, Status=%d", this->m_pmBusCommand[row].m_cmdStatus.m_status);
				break;
			}
		}
		else{
			variant << wxDataViewIconText(text, m_icon[XPM_grey]);
		}

	}
	break;
	case Col_NameText:
		if (row >= m_nameColValues.GetCount())
			variant = wxString::Format("virtual row %d", row);
		else
			variant = m_nameColValues[row];
		break;

	case Col_AccessText:
		if (row >= m_nameColValues.GetCount())
			variant = wxString::Format("virtual access %d", row);
		else
			variant = m_accessColValues[row];
		break;

	case Col_QueryText:
		variant = m_queryColValues[row];

		break;

	case Col_CoefficientsText:
		variant = m_coefficientsColValues[row];

		break;

	case Col_CookText:

		variant = m_cookColValues[row];

		break;

	case Col_RawText:

		variant = m_rawColValues[row];

		break;

	case Col_Date:
		variant = wxDateTime(1, wxDateTime::Jan, 2000).Add(wxTimeSpan(row));
		break;

	case Col_TextWithAttr:
	{
		static const char *labels[5] =
		{
			"blue", "green", "red", "bold cyan", "default",
		};

		variant = labels[row % 5];
	}
	break;

	case Col_Custom:
	{
		IntToStringMap::const_iterator it = m_customColValues.find(row);
		if (it != m_customColValues.end())
			variant = it->second;
		else
			variant = wxString::Format("%d", row % 100);
	}
	break;

	case Col_Max:
		wxFAIL_MSG("invalid column");
	}
}