void
CBCSharpStyler::Scan
	(
	istream&			input,
	const TokenExtra&	initData
	)
{
	BeginScan(input);

	const JString& text = GetText();

	Token token;
	JFontStyle style;
	do
		{
		token = NextToken();
		if (token.type == kEOF)
			{
			break;
			}

		// save token starts

		if (token.type == kID                 ||
			token.type == kReservedCKeyword   ||
			token.type == kBuiltInDataType    ||
			token.type == kString             ||
			token.type == kComment            ||
			token.type == kDocComment)
			{
			SaveTokenStart(TokenExtra());
			}

		// set the style

		const JIndex typeIndex = token.type - kWhitespace;
		if (token.type == kWhitespace)
			{
			style = GetDefaultFontStyle();
			}
		else if (token.type == kComment    ||
				 token.type == kDocComment ||
				 token.type == kString)
			{
			style = GetTypeStyle(typeIndex);
			}
		else if (token.type == kPPDirective && SlurpPPComment(&(token.range)))
			{
			token.type = kComment;
			style      = GetTypeStyle(kComment - kWhitespace);
			}
		else if (token.type == kPPDirective)
			{
			style = GetStyle(typeIndex, text.GetSubstring(GetPPNameRange()));
			}
		else if (token.type < kWhitespace)
			{
			style = GetTypeStyle(kError - kWhitespace);
			}
		else if (token.type > kError)	// misc
			{
			if (!GetWordStyle(text.GetSubstring(token.range), &style))
				{
				style = GetDefaultFontStyle();
				}
			}
		else
			{
			style = GetStyle(typeIndex, text.GetSubstring(token.range));
			}
		}
		while (SetStyle(token.range, style));
}
示例#2
0
bool CPrefsDialog::OKClicked()
{
	font_family defFamily;
	font_style defStyle;

	be_plain_font->GetFamilyAndStyle(&defFamily, &defStyle);
	gPrefs->SetPrefString("defdoc font family", fNewFontFamily);
	gPrefs->SetPrefString("defdoc font style", defStyle);
	gPrefs->SetPrefDouble("defdoc font size", fNewFontSize);

	be_bold_font->GetFamilyAndStyle(&defFamily, &defStyle);
	gPrefs->SetPrefString("border font family", fNewBFontFamily);
	gPrefs->SetPrefString("border font style", defStyle);
	gPrefs->SetPrefDouble("border font size", fNewBFontSize);

	gPrefs->SetPrefInt("decimal point", *GetText("decsep"));
	gPrefs->SetPrefInt("thousands separator", *GetText("thoussep"));
	gPrefs->SetPrefInt("list separator", *GetText("listsep"));
	gPrefs->SetPrefInt("date separator", *GetText("datesep"));
	gPrefs->SetPrefInt("time separator", *GetText("timesep"));
	gPrefs->SetPrefString("date order", fDMY->FindMarked()->Label());	
	gPrefs->SetPrefInt("24 hours", IsOn("24 hours"));
	gPrefs->SetPrefInt("Excel keys", IsOn("excel"));
	gPrefs->SetPrefInt("Select Gray", IsOn("grayselect"));
	gPrefs->SetPrefInt("start with new", IsOn("donew"));
	gWithEqualSign = IsOn("formula starts with equal");
	gPrefs->SetPrefInt("formula starts with equal", gWithEqualSign);
	gPrefs->SetPrefInt("dark gridlines", 	IsOn("dark gridlines"));
	if (gPrefs->GetPrefInt("dark gridlines", 0))
		gGridColor = 10;
	else
		gGridColor = 6;

	gPrefs->SetPrefString("c_symbol", GetText("c_symbol"));
	gPrefs->SetPrefInt("c_before", IsOn("c_before"));
	gPrefs->SetPrefInt("c_neg_par", IsOn("c_neg_par"));
	gPrefs->SetPrefInt("c_digits", atoi(GetText("c_digits")));

	if (fPageSetup)
	{
		char *ps = Bin2Hex(fPageSetup, fPageSetupSize);
		gPrefs->SetPrefString("default page setup", ps);
		FREE(ps);
	}

	BMessage msg(msg_WindowOptions);

	msg.AddString("docfamily", fDocFontFamily);
	msg.AddString("docstyle", "Roman");
	msg.AddFloat("docsize", fDocFontSize);
	msg.AddString("borderfamily", fDocBFontFamily);
	msg.AddString("borderstyle", "Bold");
	msg.AddFloat("bordersize", fDocBFontSize);
	msg.AddBool("autorecalc", IsOn("autorecalc"));
	msg.AddBool("displayzero", IsOn("displayzero"));
	msg.AddBool("dispgrid", IsOn("dispgrid"));
	msg.AddBool("disphead", IsOn("disphead"));
	msg.AddBool("prgrid", IsOn("prgrid"));
	msg.AddBool("prhead", IsOn("prhead"));
	
	fOwner->PostMessage(&msg, fOwner->GetCellView());

	BButton *b;
	b = (BButton *)FindView("ok");
	b->SetEnabled(false);
	b = (BButton *)FindView("cancel");
	b->SetEnabled(false);

	InitFormatter();

	return false;
} /* CPrefsDialog::OKClicked */
示例#3
0
void CListBoxEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	m_pwndSBV->MoveWindow(m_rcSBV);

	if ((int)lpDrawItemStruct->itemID < 0)
		return; 

	CString text;
	GetText(lpDrawItemStruct->itemID, text);
	CRect rect = lpDrawItemStruct->rcItem;

	int cntItem = GetCount();
	int numShow = m_rcSBV.Height() / m_nItemHeight;
	// 스크롤바가 생성되면 List Box의 드로우 영역을 줄인다.
	if (cntItem > numShow)
		rect.right -= 20;

	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	Graphics mainG (lpDrawItemStruct->hDC);

	Color clrText = m_clrTextNom;
	// 선택된 Item 영역 그리는 부분.
	if ((lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
	{
		DrawItem(&mainG,rect,m_clrItemHot);
		clrText = m_clrTextHot;
		DrawText(&mainG,rect,text,clrText);
	}

	// 기본 Item 영역 그리는 부분.
	if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
	{
		if (m_bModeOneColor == true)
		{
			DrawItem(&mainG,rect,m_clrItemNom1);
		}
		else
		{
			Color clr;
			lpDrawItemStruct->itemID%2 ? clr = m_clrItemNom1 : clr = m_clrItemNom2;
			DrawItem(&mainG,rect,clr);
		}
		DrawText(&mainG,rect,text,clrText);
	}

	// 선택 -> 미선택 Item 영역 그리는 부분.
	if (!(lpDrawItemStruct->itemState & ODS_SELECTED) && (lpDrawItemStruct->itemAction & ODA_SELECT))
	{
		if (m_bModeOneColor == true)
		{
			DrawItem(&mainG,rect,m_clrItemNom1);
		}
		else
		{
			Color clr;
			lpDrawItemStruct->itemID%2 ? clr = m_clrItemNom1 : clr = m_clrItemNom2;
			DrawItem(&mainG,rect,clr);
		}
		DrawText(&mainG,rect,text,clrText);
	}

}
示例#4
0
CString FORMULA_Formula::GetText(byte mode)
{
	int layer = 0;
	return GetText(mode, layer);
}
			WString GuiBindableListView::ItemSource::GetTextValue(vint itemIndex)
			{
				return GetText(itemIndex);
			}
 const char32_t* LineEditData::GetViewText() const {
     return GetText().c_str() + scroll;
 }
示例#7
0
文件: GUITextBox.cpp 项目: has12/xbmc
std::string CGUITextBox::GetDescription() const
{
  return GetText();
}
void
CBTCLStyler::Scan
	(
	std::istream&			input,
	const TokenExtra&	initData
	)
{
	BeginScan(input);

	const JString& text = GetText();

	JBoolean keepGoing;
	Token token;
	JFontStyle style;
	do
		{
		token = NextToken();
		if (token.type == kEOF)
			{
			break;
			}

		// save token starts

		if (token.type == kPredefinedWord ||
			token.type == kOtherWord ||
			token.type == kVariable ||
			token.type == kString ||
			token.type == kComment)
			{
			SaveTokenStart(TokenExtra());
			}

		// handle special cases

		if (token.type == kString ||
			token.type == kUnterminatedString)
			{
			ExtendCheckRangeForString(token.range);
			}

		// set the style

		const JIndex typeIndex = token.type - kWhitespace;
		if (token.type == kWhitespace)
			{
			style = GetDefaultFont().GetStyle();
			}
		else if (token.type == kComment       ||
				 token.type == kString        ||
				 token.type == kBrace         ||
				 token.type == kSquareBracket ||
				 token.type == kParenthesis)
			{
			style = GetTypeStyle(typeIndex);
			}
		else if (token.type < kWhitespace)
			{
			style = GetTypeStyle(kError - kWhitespace);
			}
		else
			{
			style = GetStyle(typeIndex, text.GetSubstring(token.range));
			}

		keepGoing = SetStyle(token.range, style);

		if (token.type == kString)
			{
			StyleEmbeddedVariables(token);
			}
		}
		while (keepGoing);
}
示例#9
0
文件: UIEditBox.cpp 项目: 2asoft/xray
void CUIEditBox::SaveValue(){
	CUIOptionsItem::SaveValue();
	SaveOptStringValue(GetText());
}
示例#10
0
/**
 * Convenience for {@link Selection#selectAll}.
 */
ECode EditText::SelectAll()
{
    Selection::SelectAll(ISpannable::Probe(GetText().Get()));
    return NOERROR;
}
示例#11
0
/**
 * Convenience for {@link Selection#extendSelection}.
 */
ECode EditText::ExtendSelection(
    /* [in] */ Int32 index)
{
    Selection::ExtendSelection(ISpannable::Probe(GetText().Get()), index);
    return NOERROR;
}
示例#12
0
    void Field::AutoComplete() {
        //We want to complete in the middle of a command text with potentially multiple commands

        //Add slash prefix and get command text up to cursor
        if (GetText().empty() || (GetText()[0] != '/' && GetText()[0] != '\\')) {
            GetText().insert(GetText().begin(), '/');
            SetCursor(GetCursorPos() + 1);
        }
        std::string commandText = Str::UTF32To8(GetText().substr(1, GetCursorPos() - 1));

        //Split the command text and find the command to complete
        const char* commandStart = commandText.data();
        const char* commandEnd = commandText.data() + commandText.size();
        while (true) {
            const char* next = Cmd::SplitCommand(commandStart, commandEnd);
            if (next != commandEnd)
                commandStart = next;
            else
                break;
        }

        //Parse the arguments and get the list of candidates
        Cmd::Args args(std::string(commandStart, commandEnd));
        int argNum = args.Argc() - 1;
        std::string prefix;
        if (!args.Argc() || Str::cisspace(GetText()[GetCursorPos() - 1])) {
            argNum++;
        } else {
            prefix = args.Argv(argNum);
        }

        Cmd::CompletionResult candidates = Cmd::CompleteArgument(args, argNum);
        if (candidates.empty()) {
            return;
        }
        std::sort(candidates.begin(), candidates.end());
        candidates.erase(std::unique(candidates.begin(), candidates.end()), candidates.end());

        //Compute the longest common prefix of all the results
        int prefixSize = candidates[0].first.size();
        size_t maxCandidateLength = 0;
        for (auto& candidate : candidates) {
            prefixSize = std::min(prefixSize, Str::LongestIPrefixSize(candidate.first, candidates[0].first));
            maxCandidateLength = std::max(maxCandidateLength, candidate.first.length());
        }

        std::string completedArg(candidates[0].first, 0, prefixSize);

        //Help the user bash the TAB key, but not when completing paths
        if (candidates.size() == 1 && !Str::cisspace(GetText()[GetCursorPos()]) && !Str::IsSuffix("/", completedArg)) {
            completedArg += " ";
        }

        //Insert the completed arg
        std::u32string toInsert = Str::UTF8To32(completedArg);
        DeletePrev(prefix.size());
        GetText().insert(GetCursorPos(), toInsert);
        SetCursor(GetCursorPos() + toInsert.size());

        //Print the matches if it is ambiguous
        if (candidates.size() >= 2) {
            Com_Printf(S_COLOR_YELLOW "-> " S_COLOR_WHITE "%s\n", Str::UTF32To8(GetText()).c_str());
            for (const auto& candidate : candidates) {
                std::string filler(maxCandidateLength - candidate.first.length(), ' ');
                Com_Printf("   %s%s %s\n", candidate.first.c_str(), filler.c_str(), candidate.second.c_str());
            }
        }
    }
示例#13
0
 void Field::HistoryNext() {
     std::string current = Str::UTF32To8(GetText());
     NextLine(hist, current);
     SetText(Str::UTF8To32(current));
 }
示例#14
0
void CListBox::GetText(int nIndex, CString& rString) const
{
	ASSERT(::IsWindow(m_hWnd));
	GetText(nIndex, rString.GetBufferSetLength(GetTextLen(nIndex)));
	rString.ReleaseBuffer();
}
示例#15
0
文件: token.cpp 项目: AIDman/Kaldi
/*
 * Return true if the two tokens are equivalent in a 
 * Speech recognition way.
 */
bool Token::IsEquivalentTo(Token* token)
{
    string tok1;
    string tok2;
    
    if (segment->PerformCaseSensitiveAlignment()) //case sensitive
    {
        tok1 = GetText();
        tok2 = token->GetText();
    }
    else
    {
        tok1 = GetTextInLowerCase();
        tok2 = token->GetTextInLowerCase();
    }
	
	if (segment->AreFragmentsCorrect()) 
    {
		int otherFrag = token->GetFragmentStatus();
		
		if(fragment == NOT_FRAGMENT) 
        {
			if(otherFrag == NOT_FRAGMENT) 
            {
				return tok1 == tok2;
			}
            else if (otherFrag == BEGIN_FRAGMENT) 
            {
                return (tok1.find(tok2, 0) == 0);
			} 
            else 
            {
				return (tok1.find(tok2, tok1.size()-tok2.size()) != string::npos);					
			}
		}
        else if (fragment == BEGIN_FRAGMENT)
        {			
			if(otherFrag == NOT_FRAGMENT) 
            {
				return (tok2.find(tok1, 0) == 0);
			} 
            else if (otherFrag == BEGIN_FRAGMENT) 
            {
				 return ((tok1.find(tok2, 0) != string::npos) || (tok2.find(tok1, 0) != string::npos));
			}
            else 
            {
				return false;
			}
			
		} 
        else 
        { // fragment == END_FRAGMENT
			if(otherFrag == NOT_FRAGMENT)
            {
				return (tok2.find(tok1, tok2.size()-tok1.size()) != string::npos);
			} 
            else if (otherFrag == BEGIN_FRAGMENT) 
            {
				return false;
			} 
            else 
            {
				uint s1 = tok1.size();
				uint s2 = tok2.size();
				return (tok1.find(tok2, s1 - s2) != string::npos) || (tok2.find(tok1, s2 - s1) != string::npos);
			}
		}
	} 
    else 
    {
        return tok1 == tok2;
    }
}
示例#16
0
文件: UIEditBox.cpp 项目: 2asoft/xray
bool CUIEditBox::IsChanged(){
	return 0 != xr_strcmp(GetOptStringValue(),GetText());
}
示例#17
0
void ScriptEditCtrl::GetWindowText(CString& text)
{
	text = GetText();
}
//! 进行制作
BOOL GoodsTailorSystem::MakeGoods(const tagMakeInfo& MakeInfo)
{
	CPlayer *pPlayer = GetGame()->FindPlayer(MakeInfo.PlayerGuid);
	if(NULL == pPlayer)
		return FALSE;

	//! 验证合法性
	switch(MakeInfo.lType)
	{
	case eMT_FORM_GOODS:
		{
			CGoods *pGoods = pPlayer->FindGoodsByGuidInPack(MakeInfo.GoodsGuid);
			if(NULL == pGoods)
				return FALSE;
		}
		break;
	case eMT_FROM_NPC:
		{
			//! 地图判断
			if(MakeInfo.RegionGuid != pPlayer->GetRegionGUID())
				return FALSE;
			//! 距离判断
			if(MakeInfo.lRadius < abs(LONG(pPlayer->GetPosX() - MakeInfo.fPosX)) || MakeInfo.lRadius <  abs((LONG)(pPlayer->GetPosY() - MakeInfo.fPosY)))
				return FALSE;
		}
	    break;
	default:
	    return FALSE;
	}

	//! 开始制作
	if(NULL == MakeInfo.pGsOneMakeTable)
	{
		assert(NULL != MakeInfo.pGsOneMakeTable);
		Log4c::Error(ROOT_MODULE,"%-18s %s",__FUNCTION__,GetText("GS_GOODS_83"));//发生不该出现的错误,物品制作配方对象为空!
		return FALSE;
	}
	DWORD dwResult = MakeInfo.pGsOneMakeTable->MakeGoods(pPlayer);

	//! 处理结果
	if(eGTC_Succeed == dwResult)
	{
		switch(MakeInfo.lType)
		{
		case eMT_FORM_GOODS:
			{
				if(MakeInfo.bDelGoodsWhenFinish)
				{
					if(!pPlayer->DelGoods(MakeInfo.GoodsGuid, 1))
					{
                        //发生严重错误,物品制作已经完成,但消耗物品没有被删除成功,还有一种可能就是配置的消耗物中包含了触发制作的物品!
						Log4c::Error(ROOT_MODULE,"%-18s %s",__FUNCTION__,GetText("GS_GOODS_84"));
					}
				}
			}
			break;
		}
	}
	else
	{
		CMessage msg(MSG_S2C_MAKE_RESULT);
		msg.Add((BYTE)FALSE);
		msg.Add(dwResult);
		msg.SendToPlayer(pPlayer->GetExID(), false);
	}

	return (eGTC_Succeed == dwResult);
}
示例#19
0
wxObject *wxMenuXmlHandler::DoCreateResource()
{
    if (m_class == wxT("wxMenu"))
    {
        wxMenu *menu = m_instance ? wxStaticCast(m_instance, wxMenu)
                                  : new wxMenu(GetStyle());

        wxString title = GetText(wxT("label"));
        wxString help = GetText(wxT("help"));

        bool oldins = m_insideMenu;
        m_insideMenu = true;
        CreateChildren(menu, true/*only this handler*/);
        m_insideMenu = oldins;

        wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
        if (p_bar)
        {
            p_bar->Append(menu, title);
        }
        else
        {
            wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
            if (p_menu)
            {
                p_menu->Append(GetID(), title, menu, help);
                if (HasParam(wxT("enabled")))
                    p_menu->Enable(GetID(), GetBool(wxT("enabled")));
            }
        }

        return menu;
    }

    else
    {
        wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);

        if (m_class == wxT("separator"))
            p_menu->AppendSeparator();
        else if (m_class == wxT("break"))
            p_menu->Break();
        else /*wxMenuItem*/
        {
            int id = GetID();
            wxString label = GetText(wxT("label"));
            wxString accel = GetText(wxT("accel"), false);
            wxString fullLabel = label;
            if (!accel.empty())
                fullLabel << wxT("\t") << accel;

            wxItemKind kind = wxITEM_NORMAL;
            if (GetBool(wxT("radio")))
                kind = wxITEM_RADIO;
            if (GetBool(wxT("checkable")))
            {
                if ( kind != wxITEM_NORMAL )
                {
                    ReportParamError
                    (
                        "checkable",
                        "menu item can't have both <radio> and <checkable> properties"
                    );
                }

                kind = wxITEM_CHECK;
            }

            wxMenuItem *mitem = new wxMenuItem(p_menu, id, fullLabel,
                                               GetText(wxT("help")), kind);

#if (!defined(__WXMSW__) && !defined(__WXPM__)) || wxUSE_OWNER_DRAWN
            if (HasParam(wxT("bitmap")))
            {
                // currently only wxMSW has support for using different checked
                // and unchecked bitmaps for menu items
#ifdef __WXMSW__
                if (HasParam(wxT("bitmap2")))
                    mitem->SetBitmaps(GetBitmap(wxT("bitmap2"), wxART_MENU),
                                      GetBitmap(wxT("bitmap"), wxART_MENU));
                else
#endif // __WXMSW__
                    mitem->SetBitmap(GetBitmap(wxT("bitmap"), wxART_MENU));
            }
#endif
            p_menu->Append(mitem);
            mitem->Enable(GetBool(wxT("enabled"), true));
            if (kind == wxITEM_CHECK)
                mitem->Check(GetBool(wxT("checked")));
        }
        return NULL;
    }
}
void Dlg_AchievementsReporter::OnOK(HWND hwnd)
{

	m_hProblem2 = GetDlgItem(hwnd, IDC_RA_PROBLEMTYPE2);





	const auto bProblem1Sel{ Button_GetCheck(m_hProblem1) };
	const auto bProblem2Sel{ Button_GetCheck(m_hProblem2) };

	if ((bProblem1Sel == false) && (bProblem2Sel == false))
	{
		MessageBox(nullptr, TEXT("Please select a problem type."),
			TEXT("Warning"), MB_ICONWARNING);
		return;
	}
	// 0==?
	auto nProblemType{ bProblem1Sel ? 1 : bProblem2Sel ? 2 : 0 };
	auto sProblemTypeNice{ PROBLEM_STR.at(to_unsigned(nProblemType)) };

	std::string sBuggedIDs;
	sBuggedIDs.reserve(1024);

	int nReportCount = 0;

	const size_t nListSize = to_unsigned(ListView_GetItemCount(m_hList));
	for (size_t i = 0; i < nListSize; ++i)
	{
		if (ListView_GetCheckState(m_hList, i) != 0)
		{
			//	NASTY big assumption here...
			auto buffer{
				tfm::format("%d,",
				g_pActiveAchievements->GetAchievement(i).ID())
			};
			sBuggedIDs+=buffer;

			//ListView_GetItem( hList );	
			nReportCount++;
		}
	}

	// Needs another check
	if (sBuggedIDs == "")
	{
		// even with this it might be strange, there has to be a better way to do this...
		// The close button will still close it even though this warning will show up
		MessageBox(GetActiveWindow(),
			_T("You need to to select at least one achievement"),
			_T("Warning"), MB_OK);
		return;
	}

	if (nReportCount > 5)
	{
		if (MessageBox(nullptr,
			TEXT("You have over 5 achievements selected. Is this OK?"),
			TEXT("Warning"), MB_YESNO) == IDNO)
			return;
	}


	m_hComment = GetDlgItem(hwnd, IDC_RA_BROKENACHIEVEMENTREPORTCOMMENT);

	// Now I remember
	auto len{ GetTextLength(m_hComment)};
	std::string sBugReportComment;

	// This ones is extremly important or the capacity will change
	sBugReportComment.reserve(static_cast<std::size_t>(len));
	GetText(m_hComment, len, sBugReportComment.data());


	//	Intentionally MBCS
	auto sBugReportInFull{ tfm::format(
		"--New Bug Report--\n"
		"\n"
		"Game: %s\n"
		"Achievement IDs: %s\n"
		"Problem: %s\n"
		"Reporter: %s\n"
		"ROM Checksum: %s\n"
		"\n"
		"Comment: %s\n"
		"\n"
		"Is this OK?",
		g_pCurrentGameData->GameTitle(),
		sBuggedIDs,
		sProblemTypeNice,
		username(),
		g_sCurrentROMMD5,
		sBugReportComment.c_str()) // strange, it won't show itself as a regular string
	};

	if (MessageBox(nullptr, NativeStr(sBugReportInFull).c_str(),
		TEXT("Summary"), MB_YESNO) == IDNO)
		return;

	PostArgs args
	{
		{ 'u', cusername() },
		{ 't', user_token()},
		{ 'i', sBuggedIDs.c_str() },
		{ 'p', std::to_string(nProblemType) },
		{ 'n', sBugReportComment.c_str() },
		{ 'm', g_sCurrentROMMD5.c_str() }
	};

	Document doc;
	// Something is wrong with this function...
	if (RAWeb::DoBlockingRequest(RequestSubmitTicket, args, doc))
	{

		// really weird, success is in there but it's not
		// really bizzare need to check the contents of JSON and do a new approach

		//for (auto& i : doc.GetObjectA())
		//{
		//	RA_LOG("Type of member %s is %s\n", i.name.GetString(),
		//		i.value.GetType());
		//}




		if (doc["Success"].GetBool())
		{
			auto msg{
				"Submitted OK!\n"
				"\n"
				"Thank you for reporting that bug(s), and sorry it hasn't worked correctly.\n"
				"\n"
				"The development team will investigate this bug as soon as possible\n"
				"and we will send you a message on RetroAchievements.org\n"
				"as soon as we have a solution.\n"
				"\n"
				"Thanks again!"
			};

			MessageBox(hwnd, NativeStr(msg).c_str(), TEXT("Success!"), MB_OK);
			// this is so strange, the achievements get sent over but says it's failing
			IRA_Dialog::OnOK(hwnd);
			return;
		}
		else
		{
			auto buffer{ tfm::format(
				"Failed!\n"
				"\n"
				"Response From Server:\n"
				"\n"
				"Error code: %d", doc.GetParseError())
			};
			MessageBox(hwnd, NativeStr(buffer).c_str(), TEXT("Error from server!"), MB_OK);
			return;
		}
	}
	else
	{
		MessageBox(hwnd,
			TEXT("Failed!\n")
			TEXT("\n")
			TEXT("Cannot reach server... are you online?\n")
			TEXT("\n"),
			TEXT("Error!"), MB_OK);
		return;
	}
}
示例#21
0
void COptionListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    COptionListBoxItem *item;

    item = (COptionListBoxItem *)lpDrawItemStruct->itemData;
    ASSERT_KINDOF(COptionListBoxItem, item);

    CDC* pDC    = CDC::FromHandle(lpDrawItemStruct->hDC);

    if ((int)lpDrawItemStruct->itemID < 0)
    {
        // If there are no elements in the List Box
        // based on whether the list box has Focus or not
        // draw the Focus Rect or Erase it,
        if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
                (lpDrawItemStruct->itemState & ODS_FOCUS))
        {
            pDC->DrawFocusRect(&lpDrawItemStruct->rcItem);
        }
        else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
                 !(lpDrawItemStruct->itemState & ODS_FOCUS))
        {
            pDC->DrawFocusRect(&lpDrawItemStruct->rcItem);
        }
        return;
    }

    CRect  rcItem(lpDrawItemStruct->rcItem); // To draw the focus rect.
    CRect  rClient(rcItem); // Rect to highlight the Item
    CRect  rText(rcItem); // Rect To display the Text
    CPoint Pt( rcItem.left , rcItem.top ); // Point To draw the Image

    if(-1 != item->m_ImgIdx) {
        // if the page has an icon, adjust for it
        rText.left += 18;
    }

    if(FALSE == item->isGroup) {
        Pt.x += 16;
        rcItem.left += 16;
        rClient.left += 16;
        rText.left += 16;
    }

    rText.top += 2;

    COLORREF crText;
    CString strText;

    // Image information in the item data.
    int iImg = (int)lpDrawItemStruct->itemData;

    // If item selected, draw the highlight rectangle.
    // Or if item deselected, draw the rectangle using the window color.
    if ((lpDrawItemStruct->itemState & ODS_SELECTED) &&
            (lpDrawItemStruct->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
    {
        CBrush br(::GetSysColor(COLOR_HIGHLIGHT));
        pDC->FillRect(&rClient, &br);
    }
    else if (!(lpDrawItemStruct->itemState & ODS_SELECTED) &&
             (lpDrawItemStruct->itemAction & ODA_SELECT))
    {
        CBrush br(::GetSysColor(COLOR_WINDOW));
        pDC->FillRect(&rClient, &br);
    }

    // If the item has focus, draw the focus rect.
    // If the item does not have focus, erase the focus rect.
    if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
            (lpDrawItemStruct->itemState & ODS_FOCUS))
    {
        pDC->DrawFocusRect(&rcItem);
    }
    else if ((lpDrawItemStruct->itemAction & ODA_FOCUS) &&
             !(lpDrawItemStruct->itemState & ODS_FOCUS))
    {
        pDC->DrawFocusRect(&rcItem);
    }

    // To draw the Text set the background mode to Transparent.
    int iBkMode = pDC->SetBkMode(TRANSPARENT);

    if (lpDrawItemStruct->itemState & ODS_SELECTED)
        crText = pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
    else if (lpDrawItemStruct->itemState & ODS_DISABLED)
        crText = pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
    else
        crText = pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));

    // Get the item text.
    GetText(lpDrawItemStruct->itemID, strText);

    // Setup the text format.
    UINT nFormat = DT_LEFT | DT_SINGLELINE | DT_VCENTER;
    if (GetStyle() & LBS_USETABSTOPS)
        nFormat |= DT_EXPANDTABS;


    // if the ImageList is Existing and there is an associated Image
    // for the Item, draw the Image.
    if(-1 != item->m_ImgIdx) {
        m_ImageList.Draw(pDC, item->m_ImgIdx, Pt, ILD_TRANSPARENT);
    }

    //Draw the Text
    pDC->DrawText(strText, -1, &rText, nFormat | DT_CALCRECT);
    pDC->DrawText(strText, -1, &rText, nFormat);

    pDC->SetTextColor(crText);
    pDC->SetBkMode(iBkMode);
}
示例#22
0
void COptionsPage::SetOptionFromText(int ctrlId, int optionId)
{
	const wxString& value = GetText(ctrlId);
	m_pOptions->SetOption(optionId, value.ToStdWstring());
}
示例#23
0
	void CMenuElementUI::DoEvent(TEventUI& event)
	{
		if( event.Type == UIEVENT_MOUSEENTER )
		{
			CListContainerElementUI::DoEvent(event);
			if( m_pWindow ) return;
			bool hasSubMenu = false;
			for( int i = 0; i < GetCount(); ++i )
			{
				if( GetItemAt(i)->GetInterface(_T("MenuElement")) != NULL )
				{
					(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetVisible(true);
					(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetInternVisible(true);

					hasSubMenu = true;
				}
			}
			if( hasSubMenu )
			{
				m_pOwner->SelectItem(GetIndex(), true);
				CreateMenuWnd();
			}
			else
			{
				ContextMenuParam param;
				param.hWnd = m_pManager->GetPaintWindow();
				param.wParam = 2;
				CMenuWnd::GetGlobalContextMenuObserver().RBroadcast(param);
				m_pOwner->SelectItem(GetIndex(), true);
			}
			return;
		}

		if( event.Type == UIEVENT_BUTTONUP )
		{
			if( IsEnabled() ){
				CListContainerElementUI::DoEvent(event);

				if( m_pWindow ) return;

				bool hasSubMenu = false;
				for( int i = 0; i < GetCount(); ++i ) {
					if( GetItemAt(i)->GetInterface(_T("MenuElement")) != NULL ) {
						(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetVisible(true);
						(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetInternVisible(true);

						hasSubMenu = true;
					}
				}
				if( hasSubMenu )
				{
					CreateMenuWnd();
				}
				else
				{
					SetChecked(!GetChecked());

					MenuCmd* pMenuCmd = new MenuCmd();
					lstrcpy(pMenuCmd->szName, GetName().GetData());
					lstrcpy(pMenuCmd->szUserData, GetUserData().GetData());
					lstrcpy(pMenuCmd->szText, GetText().GetData());
					pMenuCmd->bChecked = GetChecked();

					ContextMenuParam param;
					param.hWnd = m_pManager->GetPaintWindow();
					param.wParam = 1;
					CMenuWnd::GetGlobalContextMenuObserver().RBroadcast(param);

					if (CMenuWnd::GetGlobalContextMenuObserver().GetManager() != NULL)
					{
						if (!PostMessage(CMenuWnd::GetGlobalContextMenuObserver().GetManager()->GetPaintWindow(), WM_MENUCLICK, (WPARAM)pMenuCmd, NULL))
						{
							delete pMenuCmd;
							pMenuCmd = NULL;
						}
					}
				}
			}

			return;
		}

		if ( event.Type == UIEVENT_KEYDOWN && event.chKey == VK_RIGHT )
		{
			if( m_pWindow ) return;
			bool hasSubMenu = false;
			for( int i = 0; i < GetCount(); ++i )
			{
				if( GetItemAt(i)->GetInterface(_T("MenuElement")) != NULL )
				{
					(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetVisible(true);
					(static_cast<CMenuElementUI*>(GetItemAt(i)->GetInterface(_T("MenuElement"))))->SetInternVisible(true);

					hasSubMenu = true;
				}
			}
			if( hasSubMenu )
			{
				m_pOwner->SelectItem(GetIndex(), true);
				CreateMenuWnd();
			}
			else
			{
				ContextMenuParam param;
				param.hWnd = m_pManager->GetPaintWindow();
				param.wParam = 2;
				CMenuWnd::GetGlobalContextMenuObserver().RBroadcast(param);
				m_pOwner->SelectItem(GetIndex(), true);
			}

			return;
		}

		CListContainerElementUI::DoEvent(event);
	}
示例#24
0
文件: HZIVR.cpp 项目: dragoncheng/ivr
//-----------------------------------------------------------------------------------------------------------
//	FSM 的定期处理函数
//-----------------------------------------------------------------------------------------------------------
int CHZIVRFSMItem::ProcessTimer(int nTimerUnitInMiliseconds)
{
	char sText[1024];
	int  n,ntot;
	if (m_proctime)
	{
		return 0;
	}
	m_proctime=true;
	

	switch(m_State)
	{
	case FSMSTATE_IDLE:
		//	glbStartRecordVoice(0);							// 开始对主叫录音
		m_RecordFlag=0;
		glbStopRecordVoice(0);
		glbStartPlayVoice(0,"SILENCE");						// 开始向主叫播音
		m_State=FSMSTATE_READYFORWELCOMEWORDTXT;						// 状态是“等待文本”状态
//		AppendText("欢迎使用股票语音服务系统,请在滴的一声后讲话,讲话时请用普通话,谢谢.",-1);	// 播放提示词
		break;

	case FSMSTATE_READYFORWELCOMEWORDTXT:							// 如果状态是“等待文本”
		ntot = _play_tts(m_Pid,"欢迎使用浙江电信号码百事通股票查询系统,进入股票名称智能语音查询,请按1;进入输入股票代码查询,请按2");
		if (ntot>0)
		{
			m_State=FSMSTATE_PLAYINGWELCOMEWORDTXT;					// 状态转为“播放状态”
			m_Timer=0;
			m_RecordDelay=1;
		}
		m_RecordFlag = 0;
		m_RecordMode = ERecordMode_RECORD;
		break;

	case FSMSTATE_READYFORVOICETXT:
		ntot = _play_tts(m_Pid,"欢迎使用浙江电信号码百事通股票自动语音查询系统,请在“都”的一声后用普通话讲出您要查询的股票名称,不要讲股票代码.谢谢.");
		if (ntot>0)
		{
			m_State = FSMSTATE_PLAYINGVOICETXT;
			m_Timer = 0;
			m_RecordDelay = 1;
		}
		m_RecordFlag = 0;
		break;

	case FSMSTATE_READYFORMANUALTXT:
		ntot = _play_tts(m_Pid,"欢迎使用浙江电信号码百事通股票自动查询系统,请输入你的股票代码,以井号键结束.");
		if (ntot>0)
		{
			m_State = FSMSTATE_PLAYINGMANUALTXT;
			m_Timer = 0;
			m_RecordDelay = 1;
		}
		m_RecordFlag = 0;
		break;

	case FSMSTATE_PLAYINGTXTFINISHED:
		{
			switch(m_RecordMode)
			{
				case ERecordMode_REVDTMF:
					glbStartRecvDTMF(0);							// 开始为主叫收 DTMF 号码
					m_State = FSMSTATE_WAITFORSTOCKNO;
					Log("FSM[%d] get dtmf code \r\n",m_Pid);
					break;

				case ERecordMode_RECORD:
					glbPlayStoredVoiceData(0,"RECORDTAG");
					m_State = FSMSTATE_PLAYINGRECORDMARK;
					Log("FSM[%d] playing recordtag \r\n",m_Pid);
					break;

				default:
					m_State = FSMSTATE_READYFORRECORD;
					Log("FSM[%d] playing voice finish \r\n",m_Pid);
					break;
			}
			m_RecordFlag = 0;
			m_Timer=0;
		}
		break;
	case FSMSTATE_READYFORSELECTMODE:
		glbStartRecvDTMF(0);							// 开始为主叫收 DTMF 号码
		m_State = FSMSTATE_WAITSELECTMODE;
		Log("FSM[%d] enter dtmf mode \r\n",m_Pid);
		break;

	case FSMSTATE_WAITSELECTMODE:
		m_Timer+=nTimerUnitInMiliseconds;
		if (m_Timer<60000) break;						// 等 60 秒
		return -1;								// 到了 60 秒没输入,返回 -1 ,业务结束

	case FSMSTATE_READYFORRECORDMARK:
		if (m_RecordDelay<=0)
		{
			glbPlayStoredVoiceData(0,"RECORDTAG");
			m_State=FSMSTATE_PLAYINGRECORDMARK;
			m_Timer=0;
			m_RecordDelay = 0;
		}
		else
		{
			m_RecordDelay--;
		}
		break;

	case FSMSTATE_PLAYINGRECORDMARK:
		m_Timer+=nTimerUnitInMiliseconds;
		if (m_Timer>=30000)							// 最多30秒
		{
			m_State=FSMSTATE_READYFORRECORD;
		}
		break;

	case FSMSTATE_READYFORRECORD:
		if (m_RecordMode != ERecordMode_REVDTMF)
		{
			switch(m_RecordFlag)
			{
				case 0:
					glbStartRecordVoice(0);							// 开始对主叫录音
					m_RecordFlag=1;
					break;
				case 1:
					break;
				default:
					m_RecordFlag=1;
			}
		}
		m_State=FSMSTATE_RECORDING;
		m_Timer=0;
		break;

	case FSMSTATE_RECORDING:
		m_State=FSMSTATE_READYFORRECEIVEDTXT;
		break;

	case FSMSTATE_WAITFORSTOCKNO:
		m_Timer+=nTimerUnitInMiliseconds;
		if (m_Timer<60000) break;						// 等 60 秒
		return -1;								// 到了 60 秒没输入,返回 -1 ,业务结束


	case FSMSTATE_READYFORRECEIVEDTXT:
		n=GetText(sText,sizeof(sText)-4);
		if (n>0)								// 若已有文本
		{
			ntot = _play_tts(m_Pid,sText);
			if (ntot>0)
			{
				m_State=FSMSTATE_PLAYINGRECEIVEDTXT;					// 状态转为“播放状态”
				m_Timer=0;
				m_RecordFlag = 0;
			}
		}
		break;
	case FSMSTATE_PLAYINGRECEIVEDTXT:
		m_Timer+=nTimerUnitInMiliseconds;
		if (m_Timer>=120000)							// 已过 2 分钟
		{
			m_State=FSMSTATE_IDLE;
		}
		break;
	}
	m_proctime = false;
	return 0;
}
示例#25
0
void ProcessMaterials()
{
  long mat, ptr, nmat, nbumat, i, TMS, iso, nuc;
  double T;

  /* Check burnup step */

  if ((long)RDB[DATA_BURN_STEP] > 0)
    Die(FUNCTION_NAME, "Should not be here");

  /* Pointer to material list */
  
  if ((mat = (long)RDB[DATA_PTR_M0]) < VALID_PTR)
    Error(0, "No material definitions");

  /***************************************************************************/

  /***** Finalize material compositions **************************************/
  
  fprintf(out, "Normalizing compositions and processing mixtures...\n");

  /* Calculate fractions */

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      IsotopeFractions(mat);
      mat = NextItem(mat);
    }

  /* Process mixtures */

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      ProcessMixture(mat, 0);
      mat = NextItem(mat);
    }

  fprintf(out, "OK.\n\n");

  /* Replace isotopic with atomic data in photon transport calculation */
  /* (NOTE: tätä kutsutaan myöhemmin myös tuolla alempana). */
  
  ReplacePhotonData();
  
  /***************************************************************************/
  
  /***** Sort composition for better memory management ***********************/

  /* Check if macroscopic cross sections are pregenerated (if */
  /* number of materials is large, the calculation hangs here) */

  if ((long)RDB[DATA_OPTI_RECONSTRUCT_MACROXS] == YES)
    {
      /* Use MPI task numbers to remember initial order */
  
      i = 0;
      
      mat = (long)RDB[DATA_PTR_M0];
      while (mat > VALID_PTR)
	{
	  /* Check divided and burn flags */
	  
	  if ((long)RDB[mat + MATERIAL_DIV_TYPE] == MAT_DIV_TYPE_PARENT)
	    WDB[mat + MATERIAL_MPI_ID] = 1E+12;
	  else if (!((long)RDB[mat + MATERIAL_OPTIONS] & OPT_BURN_MAT))
	    WDB[mat + MATERIAL_MPI_ID] = 1E+11;
	  else
	    WDB[mat + MATERIAL_MPI_ID] = (double)(i++);
	  
	  /* Next material */
	  
	  mat = NextItem(mat);
	}
      
      /* Use OpenMP thread number for sort */
      
      i = 0;
      
      mat = (long)RDB[DATA_PTR_M0];
      while (mat > VALID_PTR)
	{
	  /* Check divided and burn flags */
	  
	  if ((long)RDB[mat + MATERIAL_DIV_TYPE] == MAT_DIV_TYPE_PARENT)
	    WDB[mat + MATERIAL_OMP_ID] = 1E+12;
	  else if (!((long)RDB[mat + MATERIAL_OPTIONS] & OPT_BURN_MAT))
	    WDB[mat + MATERIAL_OMP_ID] = 1E+11;
	  else
	    {
	      /* Set id */
	  
	      WDB[mat + MATERIAL_OMP_ID] = (double)(i++);
	      
	      /* Check id */
	      
	      if (i == (long)RDB[DATA_OMP_MAX_THREADS])
		i = 0;
	    }
	  
	  /* Next material */
	  
	  mat = NextItem(mat);
	}
      
      /* Sort */
      
      mat = (long)RDB[DATA_PTR_M0];
      SortList(mat, MATERIAL_OMP_ID, SORT_MODE_ASCEND);
    }

  /***************************************************************************/

  /***** Allocate memory and process *****************************************/

  /* Process compositions of burnable materials */

  BurnMatCompositions();
  
  /* Put composition to divided materials */

  PutCompositions();

  /* Override material compositions */
  
  ReadMaterialComp();

  /* Process burnable materials */

  ProcessBurnMat();

  /* Calculate masses (to get the value on output) */

  CalculateMasses();

  /* Close composition lists */
  
  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    { 
      ptr = (long)RDB[mat + MATERIAL_PTR_COMP];
      CloseList(ptr);

      /* Tämä on lista alkuperäiseen nuklidikoostumukseen joka korvataan */
      /* alkuainekohtaisella koostumuksella fotonitransportmoodissa jos  */
      /* inputti on annettu neutronidatana (JLe 3.6.2015 / 2.1.24). */

      if ((ptr = (long)RDB[mat + MATERIAL_PTR_ORIG_NUC_COMP]) > VALID_PTR)
	CloseList(ptr);

      mat = NextItem(mat);
    }

  /* Check temperatures and TMS flags */

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      /* Get temperature */
	  
      T = RDB[mat + MATERIAL_DOPPLER_TEMP];

      /* Get TMS flag */

      if (RDB[mat + MATERIAL_TMS_MODE] != TMS_MODE_NONE)
	TMS = NUCLIDE_FLAG_TMS;
      else
	TMS = 0;
      
      /* Loop over composition */
      
      iso = (long)RDB[mat + MATERIAL_PTR_COMP];
      while (iso > VALID_PTR)
	{
	  /* Pointer to nuclide */

	  nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
	  CheckPointer(FUNCTION_NAME, "(nuc)", DATA_ARRAY, nuc);

	  /* Skip lost */

	  if (nuc == (long)RDB[DATA_PTR_NUCLIDE_LOST])
	    {
	      /* Next */

	      iso = NextItem(iso);

	      /* Cycle loop */

	      continue;
	    }
	  
	  /* Compare temperature */

	  if ((T > 0) && (T != RDB[nuc + NUCLIDE_TEMP]))
	    Die(FUNCTION_NAME, "Error in temperature: %s %s %E %E",
		GetText(mat + MATERIAL_PTR_NAME), 
		GetText(nuc + NUCLIDE_PTR_NAME), T, RDB[nuc + NUCLIDE_TEMP]);
	  
	  /* Check TMS flag */

	  if (TMS != ((long)RDB[nuc + NUCLIDE_TYPE_FLAGS] & NUCLIDE_FLAG_TMS))
	    Die(FUNCTION_NAME, "Error in TMS flag %s %ld %ld", 
		GetText(nuc + NUCLIDE_PTR_NAME), TMS, 
		((long)RDB[nuc + NUCLIDE_TYPE_FLAGS] & NUCLIDE_FLAG_TMS));

	  /* Check TMS limits */

	  if (TMS != NO)
	    {
	      /* Check minimum */

	      if (RDB[nuc + NUCLIDE_TMS_MIN_TEMP] > 
		  RDB[mat + MATERIAL_TMS_TMIN])
		Die(FUNCTION_NAME, "Error in TMS Tmin: %s %s %E %E",
		    GetText(mat + MATERIAL_PTR_NAME), 
		    GetText(nuc + NUCLIDE_PTR_NAME),
		    RDB[nuc + NUCLIDE_TMS_MIN_TEMP], 
		    RDB[mat + MATERIAL_TMS_TMIN]);

	      /* Check maximum */

	      if (RDB[nuc + NUCLIDE_TMS_MAX_TEMP] < 
		  RDB[mat + MATERIAL_TMS_TMAX])
		Die(FUNCTION_NAME, "Error in TMS Tmax: %s %s %E %E",
		    GetText(mat + MATERIAL_PTR_NAME), 
		    GetText(nuc + NUCLIDE_PTR_NAME),
		    RDB[nuc + NUCLIDE_TMS_MAX_TEMP], 
		    RDB[mat + MATERIAL_TMS_TMAX]);
	    }
	  
	  /* Next */

	  iso = NextItem(iso);
	}

      /* Next material */

      mat = NextItem(mat);
    }

  /* Allocate memory for reaction lists and macroscopic cross sections */

  AllocMacroXS();

  /* Sort composition to get initial order */

  if ((long)RDB[DATA_OPTI_RECONSTRUCT_MACROXS] == YES)
    {
      mat = (long)RDB[DATA_PTR_M0];
      SortList(mat, MATERIAL_MPI_ID, SORT_MODE_ASCEND);
    }

  /* Re-read compositions from restart file (JLe: tämä pitää lukea uudestaan  */
  /* siitä syystä että alialuejako tehdään vasta PutCompositions():issa, jota */
  /* kutsutaan tuolla ylempänä). */

  ReadRestartFile(RESTART_OVERRIDE);

  /* Replace isotopic with atomic data in photon transport calculation */
  /* (JLe: Tätä joudutaan kutsumaan uudestaan että myös alialueiden    */
  /* koostumukset menee oikein). */

  ReplacePhotonData();

  /* Check if decay source is used */

  if ((long)RDB[DATA_USE_DECAY_SRC] == YES)
    {
      /* Calculate activities (Aktiivisuudet lasketaan uudestaan */
      /* transportcycle.c:n lopussa.) */

      CalculateActivities();

      /* Process decay source */
      
      ProcessDecaySrc();
      
      /* Print gamma source (spectra for testing) */
      
      PrintGammaSpectra();
    }

  /* Process photon data if photon transport mode */

  if ((long)RDB[DATA_PHOTON_TRANSPORT_MODE] == YES) {

    /* Process photon attenuation data */

    ProcessPhotonAtt();

    /* Process TTB */

    if ((long)RDB[DATA_PHOTON_USE_TTB] == YES)
      ProcessTTB();

    /* Process atomic relaxation */

    ProcessRelaxation();
  }

  /***************************************************************************/
  
  /***** Assign MPI numbers to materials *************************************/

  /* NOTE: tää pitää miettiä uudestaan niin että toi järjestys menee */
  /* jotenkin fiksusti */

  /* Set MPI id's */

  i = 0;

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      /* Check burn-flag */

      if ((long)RDB[mat + MATERIAL_OPTIONS] & OPT_BURN_MAT)
	{
	  /* Set id (MSR-palamarutiinit pitää suorittaa yhdellä */
	  /* MPI-taskilla) */

	  if ((long)RDB[mat + MATERIAL_FLOW_IDX] == 0)
	    WDB[mat + MATERIAL_MPI_ID] = (double)(i++);
	  else
	    WDB[mat + MATERIAL_MPI_ID] = 0.0;

	  /* Check id */
	  
	  if (i == mpitasks)
	    i = 0;
	}
      else
	WDB[mat + MATERIAL_MPI_ID] = -1.0;
            
      /* Reset OpenMP thread number */

      WDB[mat + MATERIAL_OMP_ID] = -1.0;

      /* Next material */

      mat = NextItem(mat);
    }
  
  /***************************************************************************/
  
  /***** Count materials and set indexes for printout ************************/

  /* Reset counters */

  nmat = 0;
  nbumat = 0;

  /* Loop over materials */

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      /* Add total counter */

      nmat++;

      /* Put index */

      WDB[mat + MATERIAL_PROC_IDX] = (double)nmat;

      /* Check burn flag */
      
      if (((long)RDB[mat + MATERIAL_OPTIONS] & OPT_BURN_MAT) &&
	  ((long)RDB[mat + MATERIAL_DIV_TYPE] != MAT_DIV_TYPE_PARENT))
	{
	  /* Add burn counter */

	  nbumat++;

	  /* Put index */

	  WDB[mat + MATERIAL_BURN_IDX] = (double)nmat;
	}
      
      /* Next material */
      
      mat = NextItem(mat);
    }

  /* Put counters */

  WDB[DATA_N_MATERIALS] = (double)nmat;
  WDB[DATA_N_BURN_MATERIALS] = (double)nbumat;

  /***************************************************************************/

  /***** Calculate memory size and print summary *****************************/

  /* Calculated divided material total memory */

  mat = (long)RDB[DATA_PTR_M0];
  while (mat > VALID_PTR)
    {
      /* Check pointer to parent */

      if ((ptr = (long)RDB[mat + MATERIAL_DIV_PTR_PARENT]) > VALID_PTR)
	WDB[ptr + MATERIAL_TOT_DIV_MEM_SIZE] =
	  RDB[ptr + MATERIAL_TOT_DIV_MEM_SIZE] + RDB[mat + MATERIAL_MEM_SIZE];

      /* Next material */

      mat = NextItem(mat);
    }

  /* Print material data */
  
  PrintMaterialData();

  /***************************************************************************/
}
示例#26
0
文件: BoolValue.cpp 项目: jinjoh/NOOR
CValue* CBoolValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val)
/*
pre: the type of val is dtype
ret: a new object containing the result of applying operator op to val and
this object
*/
{
	CValue *ret;
	
	switch(dtype)
	{
	case VALUE_EMPTY_TYPE:
	case VALUE_BOOL_TYPE:
		{
			switch(op)
			{
			case VALUE_AND_OPERATOR:
				{
					ret = new CBoolValue (((CBoolValue *) val)->GetBool() && m_bool);
					break;
				}
			case VALUE_OR_OPERATOR:
				{
					ret = new CBoolValue (((CBoolValue *) val)->GetBool() || m_bool);
					break;
				}
			case VALUE_EQL_OPERATOR:
				{
					ret = new CBoolValue (((CBoolValue *) val)->GetBool() == m_bool);
					break;
				}
			case VALUE_NEQ_OPERATOR:
				{
					ret = new CBoolValue (((CBoolValue *) val)->GetBool() != m_bool);
					break;
				}
			case VALUE_NOT_OPERATOR:
				{
					return new CBoolValue (!m_bool);
					break;
				}
			default:
				{
					ret =  new CErrorValue(val->GetText() + op2str(op) +
						"[operator not allowed on booleans]");
					break;
				}
			}
			break;
		}
	case VALUE_STRING_TYPE:
		{
			switch(op)
			{
			case VALUE_ADD_OPERATOR:
				{
					ret = new CStringValue(val->GetText() + GetText(),"");
					break;
				}
			default:
				{
					ret =  new CErrorValue(val->GetText() + op2str(op) + "[Only + allowed on boolean and string]");
					break;
				}
			}
			break;
		}
	default:
		ret =  new CErrorValue("[type mismatch]" + op2str(op) + GetText());
	}

	return ret;
}
示例#27
0
void CNumericEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{	
	TCHAR tChar = static_cast<TCHAR>(nChar);

	int iStart, iEnd;
	GetSel(iStart, iEnd);	//获取输入位置

	
	CString strText = GetText();	//得到编辑框中的内容(输入前)
	CString strNumericText = GetNumericText(strText); //得到编辑框内容里的数字(输入前)
	int iDecimalPos = strText.Find(m_cDecimalPoint); //小数点位置

	int iNumericDecimalPos = strNumericText.Find(m_cDecimalPoint);
	int iLen = strText.GetLength();	//内容长度
	int iNumericLen = strNumericText.GetLength(); //内容中数字长度
	int iPrefixLen = m_strPrefix.GetLength();

	bool bNeedAdjustment = false;

	if (iStart < iPrefixLen && _istprint(tChar))
	{
		TCHAR cPrefix = m_strPrefix[iStart];

		if (cPrefix == tChar)
		{
			if (iLen > iStart)
			{
				iEnd = (iEnd == iLen ? iEnd : (iStart + 1));
				SetSel(iStart, iEnd);
				ReplaceSel(CString(tChar), TRUE);
			}
			else
			{
				CEdit::OnChar(nChar, nRepCnt, nFlags);
			}
		}
		else 
		{
			if ((_istdigit(tChar) || tChar == m_cNegativeSign || tChar == m_cDecimalPoint))
			{
				iEnd = (iEnd == iLen ? iEnd : (iPrefixLen));
				SetSel(iStart, iEnd);
				ReplaceSel(m_strPrefix.Mid(iStart), TRUE);

				CEdit::OnChar(nChar, nRepCnt, nFlags);
			}
		}
		
		return;
	}

	//检测是否输入减(负)号
	if (tChar == m_cNegativeSign && IsNegativeAllowed())
	{
		if (iStart == iPrefixLen)
		{
			if (!strNumericText.IsEmpty() && strNumericText[0] == m_cNegativeSign)
			{
				iEnd = (iEnd == iLen ? iEnd : (iStart + 1));
				SetSel(iStart, iEnd);
				ReplaceSel(CString(m_cNegativeSign), TRUE);
				return;
			}
		}
		else
		{
			if (strNumericText[0] == m_cNegativeSign)
			{
				SetSel(iPrefixLen, iPrefixLen + 1);
				ReplaceSel(_T(""), TRUE);
				SetSel(iStart - 1, iEnd - 1);
			}
			else
			{
				SetSel(iPrefixLen, iPrefixLen);
				ReplaceSel(CString(m_cNegativeSign), TRUE);
				SetSel(iStart + 1, iEnd + 1);
			}

			return;
		}
	}
	else
	{
		if (tChar == m_cDecimalPoint && m_iMaxDecimalPlaces > 0)
		{
			if (iDecimalPos >= 0)
			{
				if (iDecimalPos >= iStart && iDecimalPos < iEnd)
				{
					bNeedAdjustment = true;
				}
				else
				{
					SetSel(iDecimalPos + 1, iDecimalPos + 1);
				}
				return;
			}
			else
				bNeedAdjustment = true;
		}
	}

	if (_istdigit(tChar))
	{
		//判断是否超过范围
		bool bLimit = true;
		if (m_iMaxValue == 0 || m_iMaxValue - m_iMinValue == 0)
		{
			bLimit = false;
		}

		if (bLimit)
		{
			CString strNewNumericText = CString(strNumericText);

			if (strNewNumericText.IsEmpty())
			{
				strNewNumericText = _T("0");
			}

			strNewNumericText.Insert(iStart, tChar);

			int NewNumber = _wtoi(strNewNumericText);

			if (NewNumber > m_iMaxValue)
			{
				CString text;
				text.Format(GetResString(IDS_EDIT_RANGER), m_iMinValue, m_iMaxValue);
				MessageBox(text, _T("easyMule"), MB_OK);
				SetSel(0, -1);
				ReplaceSel(strNumericText, TRUE);
				return;
			}

			if (NewNumber < m_iMinValue)
			{
				CString text;
				text.Format(GetResString(IDS_EDIT_RANGER),  m_iMinValue, m_iMaxValue);
				MessageBox(text, _T("easyMule"), MB_OK);

				SetSel(0, -1);
				ReplaceSel(strNumericText, TRUE);
				return;
			}
		}

		if (iDecimalPos >= 0 && iDecimalPos < iStart)
		{
			if (strNumericText.Mid(iNumericDecimalPos + 1).GetLength() == m_iMaxDecimalPlaces)
			{
				if (iStart <= iDecimalPos + m_iMaxDecimalPlaces)
				{
					iEnd = (iEnd == iLen ? iEnd : (iStart + 1));
					SetSel(iStart, iEnd);
					ReplaceSel(CString(tChar), TRUE);
				}
				return;
			}
		}
		else
		{
			bool bIsNegative = (!strNumericText.IsEmpty() && strNumericText[0] == m_cNegativeSign);

			if (iStart == m_iMaxWholeDigits + bIsNegative + 0 + iPrefixLen)
			{
				if (/*m_uFlags & AddDecimalAfterMaxWholeDigits &&*/ m_iMaxDecimalPlaces > 0)
				{
					iEnd = (iEnd == iLen ? iEnd : (iStart + 2));
					SetSel(iStart, iEnd);
					ReplaceSel(CString(m_cDecimalPoint) + tChar, TRUE);
				}
				return;
			}

			if (strNumericText.Mid(0, iNumericDecimalPos >= 0 ? iNumericDecimalPos : iNumericLen).GetLength() == m_iMaxWholeDigits + bIsNegative)
			{
				/*if (strText[iStart] == m_cGroupSeparator)
				{
					nStart++;
				}*/

				iEnd = (iEnd == iLen ? iEnd : (iStart + 1));
				SetSel(iStart, iEnd);
				ReplaceSel(CString(tChar), TRUE);

				return;
			}

			bNeedAdjustment = true;
		}
	}
	else if (!_istprint(tChar))
	{
		bNeedAdjustment = true;

		if (tChar == 0x08)
		{
			CString strNewNumericText = CString(strNumericText);

			if (iEnd > 0)
			{
				strNewNumericText.Delete(iEnd - 1);
			}

			if (strNewNumericText.IsEmpty())
			{
				SetWindowText(strNewNumericText);
				MessageBox(_T("Please enter a Integer!"), _T("easyMue"), MB_OK);
				return;
			}

		}
	}
	else
	{
		return;
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
示例#28
0
文件: token.cpp 项目: AIDman/Kaldi
string Token::GetTextInLowerCase()
{
	string tmp = GetText();
	transform(tmp.begin(), tmp.end(), tmp.begin(), (int(*)(int))tolower);
	return tmp;
}
示例#29
0
文件: Settings.cpp 项目: pipetko/3RVX
std::wstring Settings::AudioDeviceID() {
    return GetText(XML_AUDIODEV);
}
示例#30
0
wxObject *wxToolBarAddOnXmlHandler::DoCreateResource()
{
    wxToolBar* toolbar=NULL;
    if (m_class == _T("tool"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: tool not within a toolbar!"));

        wxSize bitmapSize = m_toolbar->GetToolBitmapSize();

        if (GetPosition() != wxDefaultPosition)
        {
            m_toolbar->AddTool(GetID(),
            #if wxCHECK_VERSION(2, 9, 0)
                               wxEmptyString,
            #endif
                               GetCenteredBitmap(_T("bitmap"), wxART_TOOLBAR, bitmapSize),
                               GetCenteredBitmap(_T("bitmap2"), wxART_TOOLBAR, bitmapSize),
            #if !wxCHECK_VERSION(2, 9, 0)
                               GetBool(_T("toggle")),
                               GetPosition().x,
                               GetPosition().y,
                               NULL,
            #else
                               wxITEM_NORMAL,
            #endif
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));
           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        else
        {
            wxItemKind kind = wxITEM_NORMAL;
            if (GetBool(_T("radio")))
                kind = wxITEM_RADIO;
            if (GetBool(_T("toggle")))
            {
                wxASSERT_MSG( kind == wxITEM_NORMAL,
                              _("can't have both toggleable and radion button at once") );
                kind = wxITEM_CHECK;
            }
            m_toolbar->AddTool(GetID(),
                               GetText(_T("label")),
                               GetCenteredBitmap(_T("bitmap"), wxART_TOOLBAR, bitmapSize),
                               GetCenteredBitmap(_T("bitmap2"), wxART_TOOLBAR, bitmapSize),
                               kind,
                               GetText(_T("tooltip")),
                               GetText(_T("longhelp")));
           if (GetBool(_T("disabled")))
           {
               m_toolbar->Realize();
               m_toolbar->EnableTool(GetID(),false);
           }
        }
        return m_toolbar; // must return non-NULL
    }

    else if (m_class == _T("separator"))
    {
        wxCHECK_MSG(m_toolbar, NULL, _("Incorrect syntax of XRC resource: separator not within a toolbar!"));
        m_toolbar->AddSeparator();
        return m_toolbar; // must return non-NULL
    }

    else /*<object class="wxToolBar">*/
    {
        m_isAddon=(m_class == _T("wxToolBarAddOn"));
        if(m_isAddon)
        { // special case: Only add items to toolbar
          toolbar=(wxToolBar*)m_instance;
          // XRC_MAKE_INSTANCE(toolbar, wxToolBar);
        }
        else
        {
            int style = GetStyle(_T("style"), wxNO_BORDER | wxTB_HORIZONTAL);
            #ifdef __WXMSW__
            if (!(style & wxNO_BORDER)) style |= wxNO_BORDER;
            #endif

            XRC_MAKE_INSTANCE(toolbar, wxToolBar)

            toolbar->Create(m_parentAsWindow,
                             GetID(),
                             GetPosition(),
                             GetSize(),
                             style,
                             GetName());
            wxSize bmpsize = GetSize(_T("bitmapsize"));
            if (!(bmpsize == wxDefaultSize))
                toolbar->SetToolBitmapSize(bmpsize);
            wxSize margins = GetSize(_T("margins"));
            if (!(margins == wxDefaultSize))
                toolbar->SetMargins(margins.x, margins.y);
            long packing = GetLong(_T("packing"), -1);
            if (packing != -1)
                toolbar->SetToolPacking(packing);
            long separation = GetLong(_T("separation"), -1);
            if (separation != -1)
                toolbar->SetToolSeparation(separation);
        }

        wxXmlNode *children_node = GetParamNode(_T("object"));
        if (!children_node)
           children_node = GetParamNode(_T("object_ref"));

        if (children_node == NULL) return toolbar;

        m_isInside = TRUE;
        m_toolbar = toolbar;

        wxXmlNode *n = children_node;

        while (n)
        {
            if ((n->GetType() == wxXML_ELEMENT_NODE) &&
                (n->GetName() == _T("object") || n->GetName() == _T("object_ref")))
            {
                wxObject *created = CreateResFromNode(n, toolbar, NULL);
                wxControl *control = wxDynamicCast(created, wxControl);
                if (!IsOfClass(n, _T("tool")) &&
                    !IsOfClass(n, _T("separator")) &&
                    control != NULL &&
                    control != toolbar)
                {
                    wxLogDebug(_T("control=%p, parent=%p, toolbar=%p"), control, control->GetParent(), toolbar);
                    toolbar->AddControl(control);
                }
            }
            n = n->GetNext();
        }

        toolbar->Realize();

        m_isInside = FALSE;
        m_toolbar = NULL;

        if(!m_isAddon)
        {
            if (m_parentAsWindow && !GetBool(_T("dontattachtoframe")))
            {
                wxFrame *parentFrame = wxDynamicCast(m_parent, wxFrame);
                if (parentFrame)
                    parentFrame->SetToolBar(toolbar);
            }
        }
        m_isAddon=false;
        return toolbar;
    }
}