当前位置: 首页>>代码示例>>C++>>正文


C++ ComboBox::IsSelected方法代码示例

本文整理汇总了C++中ComboBox::IsSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ ComboBox::IsSelected方法的具体用法?C++ ComboBox::IsSelected怎么用?C++ ComboBox::IsSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ComboBox的用法示例。


在下文中一共展示了ComboBox::IsSelected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnCommand

void CGECreateServer::OnCommand( const char *command )
{
	if ( !Q_stricmp(command, "play") )
	{
		CUtlVector<char*> commands;

		// Pull the values from our controls and apply them to commands and save off the choices
		for ( KeyValues *kv = m_kvCmdMap->GetFirstTrueSubKey(); kv; kv = kv->GetNextTrueSubKey() )
		{
			KeyValues *kv_value = m_kvCmdValues->FindKey( kv->GetName(), true );
			char *cmd = new char[128];

			try {
				if ( !Q_stricmp(kv->GetString("type"), "CHOICE") )
				{
					ComboBox *panel = dynamic_cast<ComboBox*>( FindChildByName(kv->GetName()) );

					const char *cmd_value = panel->GetActiveItemUserData()->GetName();
					kv_value->SetStringValue( cmd_value );

					if ( !Q_stricmp(cmd_value, RANDOM_VALUE) )
					{
						int idx = GERandom<int>( panel->GetItemCount()-1 ) + 1;
						idx = panel->GetItemIDFromRow( idx );
						cmd_value = panel->GetItemUserData( idx )->GetName();
					}

					Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
					commands.AddToTail( cmd );
				}
				else if ( !Q_stricmp(kv->GetString("type"), "TEXT") )
				{
					char cmd_value[64];
					TextEntry *panel = dynamic_cast<TextEntry*>( FindChildByName(kv->GetName()) );
					panel->GetText( cmd_value, 64 );

					// We don't allow blank values... use default instead
					if ( !cmd_value[0] )
						Q_strncpy( cmd_value, kv->GetString("default",""), 64 );

					kv_value->SetStringValue( cmd_value );

					Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), cmd_value );
					commands.AddToTail( cmd );
				}
				else if ( !Q_stricmp(kv->GetString("type"), "BOOL") )
				{
					CheckButton *panel = dynamic_cast<CheckButton*>( FindChildByName(kv->GetName()) );
					
					if ( panel->IsSelected() ) {
						kv_value->SetStringValue( "1" );
						Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("on_val","1") );
					} else {
						kv_value->SetStringValue( "0" );
						Q_snprintf( cmd, 128, "%s \"%s\"", kv->GetString("cmd"), kv->GetString("off_val","0") );
					}
				
					commands.AddToTail( cmd );
				}
				else
				{
					delete [] cmd;
				}
			} catch (...) {
				delete [] cmd;
			}
		}

		// Apply the commands
		for ( int i=0; i < commands.Count(); i++ )
			engine->ClientCmd_Unrestricted( commands[i] );
		
		// Save our last used settings to our custom file
		m_kvCmdValues->SaveToFile( filesystem, COMMAND_MAP_VAL, "MOD" );

		// Cleanup
		commands.PurgeAndDeleteElements();
	}

	SetVisible( false );
}
开发者ID:djoslin0,项目名称:ges-legacy-code,代码行数:81,代码来源:ge_createserver.cpp


注:本文中的ComboBox::IsSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。