Esempio n. 1
0
void TableFrame::OnCellChanged( wxGridEvent& ev )
{
    TableInterface* ti = table_base->GetTableInt();
    if (ti->IsSetCellFromStringFail()) {
        wxMessageDialog dlg(this, ti->GetSetCellFromStringFailMsg(), "Warning",
                            wxOK | wxICON_INFORMATION);
        dlg.ShowModal();
        ev.Veto();
    }
    ev.Skip();
}
Esempio n. 2
0
void TableFrame::OnMouseEvent(wxMouseEvent& event)
{
    if (event.RightUp()) {
        const wxPoint& pos = event.GetPosition();
        wxMenu* optMenu = wxXmlResource::Get()->LoadMenu("ID_TABLE_VIEW_MENU_CONTEXT");
        
        TableInterface* ti = table_base->GetTableInt();
        SetEncodingCheckmarks(optMenu, ti->GetFontEncoding());
        PopupMenu(optMenu);
    }
}
Esempio n. 3
0
void TableFrame::OnGroupVariables( wxCommandEvent& event)
{
    using namespace std;
    TableInterface* ti = table_base->GetTableInt();
    vector<int> sel_cols;
    table_base->GetSelectedCols(sel_cols);
    vector<cid_to_pos_pair> cid_to_disp(sel_cols.size());
    for (int i=0; i<sel_cols.size(); i++) {
        cid_to_pos_pair p;
        p.cid = sel_cols[i];
        p.pos = grid->GetColPos(sel_cols[i]);
        cid_to_disp[i] = p;
    }
    sort(cid_to_disp.begin(), cid_to_disp.end(), cid_to_pos_pair::less_than);
    for (int i=0; i<sel_cols.size(); i++) {
        sel_cols[i] = cid_to_disp[i].cid;
    }

    vector<wxString> names(sel_cols.size());
    for (int i=0; i<sel_cols.size(); ++i) names[i]=ti->GetColName(sel_cols[i]);
    wxString grp_nm = ti->SuggestGroupName(names);
    if (sel_cols.size() > 0) {
        if (ti->GetTimeSteps() == 1 && sel_cols.size() > 1) {
            if (table_state->GetNumDisallowTimelineChanges() > 0) {
                wxString msg = table_state->GetDisallowTimelineChangesMsg();
                wxMessageDialog dlg (this, msg, "Warning",
                                     wxOK | wxICON_INFORMATION);
                dlg.ShowModal();
                return;
            }
        }
        ti->GroupCols(sel_cols, grp_nm, sel_cols[0]);
    }
    table_base->DeselectAllCols();
    grid->Refresh();
    GdaFrame::GetGdaFrame()->UpdateToolbarAndMenus();
}
Esempio n. 4
0
void TableFrame::DisplayPopupMenu( wxGridEvent& ev )
{
	wxMenu* optMenu = wxXmlResource::Get()->LoadMenu("ID_TABLE_VIEW_MENU_CONTEXT");
	
	TableInterface* ti = table_base->GetTableInt();
	SetEncodingCheckmarks(optMenu, ti->GetFontEncoding());
    
	popup_col = ev.GetCol();
	
	// Set Group item
	vector<int> sel_cols;
	table_base->GetSelectedCols(sel_cols);
	bool any_sel_time_variant = false;
	for (int i=0; i<sel_cols.size(); i++) {
		if (ti->IsColTimeVariant(sel_cols[i])) {
			any_sel_time_variant = true;
			break;
		}
	}
	bool all_sel_compatible = false;
	if (!any_sel_time_variant && sel_cols.size() > 1) {
		// check for compatible types
		all_sel_compatible = true;
		for (int i=0; i<sel_cols.size(); ++i) {
			if (!ti->IsColNumeric(sel_cols[i])) {
				all_sel_compatible = false;
				break;
			}
		}
	}
	// Set Rename item
	wxString rename_str(_("Rename Variable"));
	if (popup_col != -1) {
		rename_str << " \"" << ti->GetColName(popup_col) << "\"";
	}
	optMenu->FindItem(XRCID("ID_TABLE_RENAME_VARIABLE"))->SetItemLabel(rename_str);
	bool enable_rename = false;
	if (popup_col!=-1) {
		if (ti->IsColTimeVariant(popup_col)) {
			enable_rename = true;
		} else {
			enable_rename = ti->PermitRenameSimpleCol();
		}
	}
    
	optMenu->FindItem(XRCID("ID_TABLE_RENAME_VARIABLE"))->Enable(enable_rename);
		
	PopupMenu(optMenu, ev.GetPosition());
}