コード例 #1
0
ファイル: BROWSER.C プロジェクト: thearttrooper/KappaPC
short FitToScreen(HWND hWnd, BRDATA lpBrData)
{
    HMENU hMenu;
    WORD wRes;

    hMenu = GetMenu(hWnd);
    wRes = GetMenuState(hMenu, IDM_FIT, MF_BYCOMMAND);

    /* If item currently checked, uncheck it. Otherwise check it */
    if (wRes & MF_CHECKED)
        UpdateFitMenu(hWnd, lpBrData, FALSE);
    else
        UpdateFitMenu(hWnd, lpBrData, TRUE);

    /* Fix up the scroll bars */
    if (lpBrData->bFitToScreen)
    {
        SetScrollPos(hWnd, SB_VERT, MINPOS, TRUE);
        SetScrollPos(hWnd, SB_HORZ, MINPOS, TRUE);
    }
    else
    {
        SetScrollPos(hWnd, SB_VERT, lpBrData->vThumb, TRUE);
        SetScrollPos(hWnd, SB_HORZ, lpBrData->hThumb, TRUE);
    }

    /* Cause a repaint */
    UPDATE_SCREEN(hWnd);

    return TRUE;
}
コード例 #2
0
void
GLFitDirector::Receive
	(
	JBroadcaster*	sender,
	const Message&	message
	)
{
	if (sender == itsFitMenu && message.Is(JXMenu::kItemSelected))
		{
		const JXMenu::ItemSelected* selection =
			dynamic_cast<const JXMenu::ItemSelected*>(&message);
		assert( selection != NULL );
		HandleFitMenu(selection->GetIndex());
		}
	else if (sender == itsFitMenu && message.Is(JXMenu::kNeedsUpdate))
		{
		UpdateFitMenu();
		}
	else if (sender == itsPrefsMenu && message.Is(JXMenu::kItemSelected))
		{
		 const JXMenu::ItemSelected* selection =
			dynamic_cast<const JXMenu::ItemSelected*>(&message);
		assert( selection != NULL );
		HandlePrefsMenu(selection->GetIndex());
		}
	else if (sender == itsHelpMenu && message.Is(JXMenu::kItemSelected))
		{
		const JXMenu::ItemSelected* selection =
			dynamic_cast<const JXMenu::ItemSelected*>(&message);
		assert( selection != NULL );
		HandleHelpMenu(selection->GetIndex());
		}
	else if (sender == itsCurveList && message.Is(GLCurveNameList::kCurveSelected))
		{
		const GLCurveNameList::CurveSelected* info = 
			dynamic_cast<const GLCurveNameList::CurveSelected*>(&message);
		assert(info != NULL);
		JPlotDataBase& curve = itsPlot->GetCurve(info->GetIndex());

		RemoveFit();
		RemoveCurves();

		itsParameterTable->ClearValues();
		itsChiSq->SetText("");

		// add new curve.
		itsFitPlot->AddCurve(&curve, kJFalse, itsPlot->GetCurveName(info->GetIndex()));
		itsFitPlot->ProtectCurve(1, kJTrue);
		}
	else if (sender == itsFitList && message.Is(GLFitDescriptionList::kFitSelected))
		{
		const GLFitDescriptionList::FitSelected* info = 
			dynamic_cast<const GLFitDescriptionList::FitSelected*>(&message);
		assert(info != NULL);
		const GLFitDescription& fd	= GetFitManager()->GetFitDescription(info->GetIndex());
		itsParameterTable->SetFitDescription(fd);
		RemoveFit();
		itsChiSq->SetText("");
		JFunction* f;
		if (JParseFunction(fd.GetFitFunctionString(), const_cast<GLFitDescription&>(fd).GetVarList(), &f))
			{
			itsExprWidget->SetFunction(const_cast<GLFitDescription&>(fd).GetVarList(), f);
			itsExprWidget->Show();
			}		
		}
	else if (sender == itsFitList && message.Is(GLFitDescriptionList::kFitInitiated))
		{
		const GLFitDescriptionList::FitInitiated* info = 
			dynamic_cast<const GLFitDescriptionList::FitInitiated*>(&message);
		assert(info != NULL);
		const GLFitDescription& fd	= GetFitManager()->GetFitDescription(info->GetIndex());
		if (!itsParameterTable->BeginEditingStartValues())
			{
			Fit();
			AddHistoryText();
			}
		}
	else if (sender == itsParameterTable && message.Is(GLFitParameterTable::kValueChanged))
		{
		const GLFitParameterTable::ValueChanged* info =
			dynamic_cast<const GLFitParameterTable::ValueChanged*>(&message);
		assert(info != NULL);
		JIndex index;
		JBoolean ok	= itsFitList->GetCurrentFitIndex(&index);
		assert(ok);
		GLFitDescription& fd	= GetFitManager()->GetFitDescription(index);
		const JArray<JFloat>& parms	= itsParameterTable->GetStartValues();
		const JSize count	= parms.GetElementCount();
		for (JIndex i = 1; i <= count; i++)
			{
			fd.GetVarList()->SetValue(i + 1, parms.GetElement(i));
			}
		GetWindow()->Refresh();
		}
	else if (sender == itsNLFitDialog && message.Is(JXDialogDirector::kDeactivated))
		{
		const JXDialogDirector::Deactivated* info =
			dynamic_cast<const JXDialogDirector::Deactivated*>(&message);
		assert(info != NULL);
		if (info->Successful())
			{
			GLNonLinearFitDescription* fit	= 
				new GLNonLinearFitDescription(itsNLFitDialog->GetFitName(), 
					itsNLFitDialog->GetFunctionString(), 
					itsNLFitDialog->GetDerivativeString(),
					itsNLFitDialog->GetVarList().GetVariables());
			assert(fit != NULL);
			GetFitManager()->AddFitDescription(fit);
			}
		itsNLFitDialog	= NULL;	
		}
	else if (sender == itsPolyFitDialog && message.Is(JXDialogDirector::kDeactivated))
		{
		const JXDialogDirector::Deactivated* info =
			dynamic_cast<const JXDialogDirector::Deactivated*>(&message);
		assert(info != NULL);
		if (info->Successful())
			{
			JArray<JIndex> powers;
			itsPolyFitDialog->GetPowers(&powers);
			GLPolyFitDescription* fit	= 
				new GLPolyFitDescription(itsPolyFitDialog->GetFitName(), 
					powers);
			assert(fit != NULL);
			GetFitManager()->AddFitDescription(fit);
			}
		itsPolyFitDialog	= NULL;	
		}
	else if (sender == itsPrinter &&
			 message.Is(JPrinter::kPrintSetupFinished))
		{
		const JPrinter::PrintSetupFinished* info =
			dynamic_cast<const JPrinter::PrintSetupFinished*>(&message);
		assert(info != NULL);
		if (info->Successful())
			{
			Print();
			}
		}
	else
		{
		JXWindowDirector::Receive(sender, message);
		}
}