Пример #1
0
void CZoomCombo::Init(HWND hWnd)
{
	if (hWnd)
	{
		ArriveAt(ZoomForum);
		m_hWnd = hWnd;
		ZoomForum.FillCombo(hWnd);
		Assimilate(&ZoomForum);
	}
	else
	{
		// only depart from forum if we ever joined forum
		if (m_hWnd)
		{
			m_hWnd = NULL;
			DepartFrom(ZoomForum);
		}
	}
}
Пример #2
0
bool MvcController::Validate()
{
    std::string const name = NameOfControlToDeferEvaluating();
    if(name.empty())
        {
        return true;
        }

    UpdateWindowUI();
    tn_range_base const& datum = ModelReference<tn_range_base>(name);
    std::string const& view_value = map_lookup(transfer_data_, name);
    std::string diagnosis(datum.diagnose_invalidity(view_value));
    DiagnosticsWindow().SetLabel(diagnosis);
    if(diagnosis.empty())
        {
        model_.Entity(name) = view_value;
        Assimilate("");
        }
    return diagnosis.empty();
}
Пример #3
0
void MvcController::UponUpdateUI(wxUpdateUIEvent& event)
{
    event.Skip();

    unit_test_idle_processing_completed_ = false;

    // Explicitly disregard any wxUpdateUIEvent received while this
    // application is not active: see
    //   http://lists.gnu.org/archive/html/lmi/2006-03/msg00006.html
    // for a discussion.
    if(!TheApp().IsActive())
        {
        return;
        }

    // A disabled window might have focus:
    //   http://lists.nongnu.org/archive/html/lmi/2005-11/msg00040.html
    // so make sure focus is valid now.
    EnsureOptimalFocus();

    // Exit immediately if nothing changed. The library calls this
    // function continually in idle time, and it's pointless to fret
    // over inputs that didn't change on this update because they've
    // already been handled. Complex processing of many inputs has
    // been observed to consume excessive CPU time when a malloc
    // debugger is running, so this optimization is significant.
    //
    // The early-exit condition cannot succeed until Assimilate() has
    // been called: therefore, Assimilate() is guaranteed to be called
    // here by the time the user can interact with the GUI.
    TransferDataFromWindow();
    if(cached_transfer_data_ == transfer_data_)
        {
        unit_test_idle_processing_completed_ = true;
        return;
        }
    cached_transfer_data_ = transfer_data_;

    DiagnosticsWindow().SetLabel("");
    std::vector<std::string> control_changes;
    std::string const name_to_ignore = NameOfControlToDeferEvaluating();
    typedef std::map<std::string,std::string>::const_iterator smci;
    for(smci i = transfer_data_.begin(); i != transfer_data_.end(); ++i)
        {
        std::string const& name        = i->first;
        std::string const& view_value  = i->second;
        std::string const& model_value = model_.Entity(name).str();
        if(name == name_to_ignore || ModelAndViewValuesEquivalent(name))
            {
            continue;
            }
        try
            {
            std::string change =
                  name + ":\n"
                + "    model: '" + model_value + "'\n"
                + "    view:  '" + view_value  + "'\n"
                ;
            control_changes.push_back(change);
            model_.Entity(name) = view_value;
            }
        catch(std::exception const& e)
            {
            DiagnosticsWindow().SetLabel(name + ": " + e.what());
            }
        }

    // wxEVT_UPDATE_UI events should occur frequently enough that two
    // control changes cannot be simultaneous.
    if(1 < control_changes.size())
        {
        warning() << "Contents of more than one control changed.\n";
        typedef std::vector<std::string>::const_iterator svci;
        for(svci i = control_changes.begin(); i != control_changes.end(); ++i)
            {
            warning() << *i;
            }
        warning() << LMI_FLUSH;
        }

    Assimilate(name_to_ignore);
}