Ejemplo n.º 1
0
bool DrawsWidget::SetSet(wxString sset,
		wxString prefix,
		time_t time,
		PeriodType pt,
		int selected_draw) {

	DrawsSets* ds = m_cfg->GetConfigByPrefix(prefix);
	if (ds == NULL)
		return false;

	DrawSet *set = NULL;

	if (!sset.IsEmpty()) {
		for (DrawSetsHash::iterator i = ds->GetDrawsSets().begin();
				i != ds->GetDrawsSets().end();
				i++)
			if (i->second->GetName() == sset) {
				set = i->second;
				break;
			}
	}
	if (set == NULL)
		if ((set = m_draws_controller->GetSet()) == NULL) {
			SortedSetsArray ssa = ds->GetSortedDrawSetsNames();
			set = ssa[0];
		}

	if (set == NULL)
		return false;

	if (time <= 0)
		time = wxDateTime::Now().GetTicks();

	if (pt == PERIOD_T_OTHER)
		pt = m_draws_controller->GetPeriod();
	if (pt == PERIOD_T_OTHER)
		pt = PERIOD_T_YEAR;

	if (selected_draw < 0 || selected_draw >= (int)set->GetDraws()->size()) {
		if (m_draws_controller->GetSelectedDraw())
			selected_draw = m_draws_controller->GetSelectedDraw()->GetDrawNo();
		else
			selected_draw = 0;
	}

	m_draws_controller->Set(set, pt, time, selected_draw);

	return true;

}
Ejemplo n.º 2
0
void FrameManager::LoadConfig(DrawFrame *frame) {
	ConfigDialog *config_dialog = new ConfigDialog(frame, config_manager->GetConfigTitles(), DefinedDrawsSets::DEF_PREFIX);

	int ret = config_dialog->ShowModal();
	if (ret != wxID_OK) {
		config_dialog->Destroy();
		return;
	}

	wxString prefix = config_dialog->GetSelectedPrefix();

	if (prefix == DefinedDrawsSets::DEF_PREFIX) {
		DrawsSets *cfg = config_manager->GetConfigByPrefix(prefix);
		if (cfg == NULL || cfg->GetDrawsSets().size() == 0) {
			int ret = wxMessageBox(_("The are no user defined sets. Do you want to create one?"), _("Question"), wxICON_QUESTION | wxOK | wxCANCEL, frame);
			if (ret == wxOK)  {
				DrawPicker* dp = new DrawPicker(frame, config_manager, database_manager, remarks_handler);
				if (dp->NewSet(prefix, false) == wxID_OK)
					frame->AddDrawPanel(prefix, wxEmptyString, PERIOD_T_YEAR, 0);
				dp->Destroy();
			}
			config_dialog->Destroy();
			return;
		}
	}

	if (frame)
		frame->AddDrawPanel(prefix, wxEmptyString, PERIOD_T_YEAR, 0);
	else
		CreateFrame(prefix, wxEmptyString, PERIOD_T_YEAR, time_t(-1), wxDefaultSize, wxDefaultPosition);
	config_dialog->Destroy();
}