////////////////////////////////
// Sets display by frame or not
void BaseGrid::SetByFrame (bool state) {
	// Check if it's already the same
	if (byFrame == state) return;
	byFrame = state;
	SetColumnWidths();
	Refresh(false);
}
void DictionaryListCtrl::SetType(ListType t)
{
    m_type = t;
    for (int i = GetColumnCount() - 1; i >= 0; --i) {
        DeleteColumn(i);
    }
    InsertColumn(0, _("Filename"));
    if (m_type == wxLOCAL) {
        InsertColumn(1, _("Size"));
        SetColumnWidths(60);
    } else {
        SetColumnWidths(0);
    }
    SetFont(wxFont(8, 76, 90, 90, false, wxEmptyString));
    RefreshItems(0, GetItemCount());
}
///////////////
// Constructor
BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxWindow(parent, id, pos, size, style, name)
{
	// Misc variables
	lastRow = -1;
	yPos = 0;
	extendRow = -1;
	bmp = NULL;
	holding = false;

	// Set font
	wxString fontname = Options.AsText(_T("Font Face"));
	if (fontname.IsEmpty()) fontname = _T("Tahoma");
	font.SetFaceName(fontname);
	font.SetPointSize(Options.AsInt(_T("Grid font size")));
	font.SetWeight(wxFONTWEIGHT_NORMAL);

	// Set line height
	{
		wxClientDC dc(this);
		dc.SetFont(font);
		int fw,fh;
		dc.GetTextExtent(_T("#TWFfgGhH"), &fw, &fh, NULL, NULL, &font);
		lineHeight = fh+4;
	}

	// Set scrollbar
	scrollBar = new wxScrollBar(this,GRID_SCROLLBAR,wxDefaultPosition,wxDefaultSize,wxSB_VERTICAL);
	scrollBar->SetScrollbar(0,10,100,10);
	
	// Set column widths
	SetColumnWidths();
}
void DictionaryListCtrl::ClearDictionaries()
{
    m_items.Clear();
    SetItemCount(0);
    RefreshItems(0, 0);
    DeleteAllItems();
    SetColumnWidths(wxLIST_AUTOSIZE_USEHEADER);
}
void DictionaryListCtrl::SetDictionaries(DictionaryArray items)
{
    m_items = items;
    DeleteAllItems();
    SetItemCount(m_items.GetCount());
    RefreshItems(0, GetItemCount());
    SetColumnWidths(wxLIST_AUTOSIZE);
}
Beispiel #6
0
void MyResizableListCtrl::OnSize( wxSizeEvent &event )
{
    // Call our custom width setting function.
    SetColumnWidths();
    // REQURED event.Skip() call to allow this event to propagate
    // upwards so others can do what they need to do in response to
    // this size event.
    event.Skip();
}
Beispiel #7
0
void BaseGrid::OnShowColMenu(wxCommandEvent &event) {
	int item = event.GetId() - MENU_SHOW_COL;
	showCol[item] = !showCol[item];

	std::vector<bool> map(showCol, showCol + columns);
	OPT_SET("Subtitle/Grid/Column")->SetListBool(map);

	SetColumnWidths();
	Refresh(false);
}
Beispiel #8
0
void BaseGrid::OnSubtitlesCommit(int type) {
	if (type == AssFile::COMMIT_NEW)
		UpdateMaps(true);
	else if (type & AssFile::COMMIT_ORDER || type & AssFile::COMMIT_DIAG_ADDREM)
		UpdateMaps(false);

	if (type & AssFile::COMMIT_DIAG_META) {
		SetColumnWidths();
		Refresh(false);
		return;
	}
	if (type & AssFile::COMMIT_DIAG_TIME)
		Refresh(false);
		//RefreshRect(wxRect(time_cols_x, 0, time_cols_w, GetClientSize().GetHeight()), false);
	else if (type & AssFile::COMMIT_DIAG_TEXT)
		RefreshRect(wxRect(text_col_x, 0, text_col_w, GetClientSize().GetHeight()), false);
}
Beispiel #9
0
void BaseGrid::OnSubtitlesOpen() {
	BeginBatch();
	ClearMaps();
	UpdateMaps();

	if (GetRows()) {
		int row = context->ass->GetScriptInfoAsInt("Active Line");
		if (row < 0 || row >= GetRows())
			row = 0;

		SetActiveLine(GetDialogue(row));
		SelectRow(row);
	}

	ScrollTo(context->ass->GetScriptInfoAsInt("Scroll Position"));

	EndBatch();
	SetColumnWidths();
}
Beispiel #10
0
void CRGXMainWndGrid::OnInitialUpdate()
{
	CGXGridWnd/*CGXRecordWnd*/::OnInitialUpdate();  // Creates all objects and links them to the grid

	//GetParam()->EnableUndo(FALSE);
	//SetAccelArrowKey(TRUE);

	SetRowCount(256);
	SetColCount(17);

	//SetStyleRange(CGXRange(2, 2), CGXStyle()
	//		.SetControl(GX_IDS_CTRL_TEXTFIT)
	//		.SetChoiceList(_T("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight"))
	//	);
	//GetParam()->EnableUndo(TRUE);

	// HUOM !
	//initialisointi voidaan tehdä myös view-luokan (CPanttiView) OnInitialUpdate():ssa


	pLainaRS->m_pDatabase = theApp.GetDatabase();

	this->GetParam()->EnableSelection(FALSE);

	SetColumnWidths();
	//ChangeStandardStyle(CGXStyle()
	//	.SetControl(GX_IDS_CTRL_STATIC)
	//	.SetReadOnly(TRUE));
	//
	// --- test ---
	setGridReadOnly(TRUE);
	/*SetStyleRange(CGXRange().SetCols(0,7),
								CGXStyle().SetReadOnly(TRUE));
	SetStyleRange(CGXRange().SetCols(8,8),
								CGXStyle().SetReadOnly(FALSE).SetInterior(RGB(192,192,192)));
	SetStyleRange(CGXRange().SetCols(9,17),
								CGXStyle().SetReadOnly(TRUE));
	*/
  }
Beispiel #11
0
void BaseGrid::UpdateStyle() {
	wxString fontname = lagi_wxString(OPT_GET("Subtitle/Grid/Font Face")->GetString());
	if (fontname.empty()) fontname = "Tahoma";
	font.SetFaceName(fontname);
	font.SetPointSize(OPT_GET("Subtitle/Grid/Font Size")->GetInt());
	font.SetWeight(wxFONTWEIGHT_NORMAL);

	// Set line height
	{
		wxClientDC dc(this);
		dc.SetFont(font);
		int fw,fh;
		dc.GetTextExtent("#TWFfgGhH", &fw, &fh, nullptr, nullptr, &font);
		lineHeight = fh + 4;
	}

	// Set row brushes
	assert(sizeof(rowColors) / sizeof(rowColors[0]) >= COLOR_LEFT_COL);
	rowColors[COLOR_DEFAULT].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Background")->GetColor()));
	rowColors[COLOR_HEADER].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Header")->GetColor()));
	rowColors[COLOR_SELECTION].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColor()));
	rowColors[COLOR_COMMENT].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Comment")->GetColor()));
	rowColors[COLOR_VISIBLE].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Inframe")->GetColor()));
	rowColors[COLOR_SELECTED_COMMENT].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Selected Comment")->GetColor()));
	rowColors[COLOR_LEFT_COL].SetColour(to_wx(OPT_GET("Colour/Subtitle Grid/Left Column")->GetColor()));

	// Set column widths
	std::vector<bool> column_array(OPT_GET("Subtitle/Grid/Column")->GetListBool());
	assert(column_array.size() == (size_t)columns);
	for (int i = 0; i < columns; ++i) showCol[i] = column_array[i];
	SetColumnWidths();

	// Update
	AdjustScrollbar();
	Refresh();
}
///////////
// On size
void BaseGrid::OnSize(wxSizeEvent &event) {
	AdjustScrollbar();
	SetColumnWidths();
	Refresh(false);
}
Beispiel #13
0
void BaseGrid::UpdateMaps(bool preserve_selected_rows) {
	BeginBatch();
	int active_row = line_index_map[active_line];

	std::vector<int> sel_rows;
	if (preserve_selected_rows) {
		sel_rows.reserve(selection.size());
		transform(selection.begin(), selection.end(), back_inserter(sel_rows),
			[this](AssDialogue *diag) { return GetDialogueIndex(diag); });
	}

	index_line_map.clear();
	line_index_map.clear();

	for (auto curdiag : context->ass->Line | agi::of_type<AssDialogue>()) {
		line_index_map[curdiag] = (int)index_line_map.size();
		index_line_map.push_back(curdiag);
}

	if (preserve_selected_rows) {
		Selection sel;

		// If the file shrank enough that no selected rows are left, select the
		// last row
		if (sel_rows.empty())
			sel_rows.push_back(index_line_map.size() - 1);
		else if (sel_rows[0] >= (int)index_line_map.size())
			sel_rows[0] = index_line_map.size() - 1;

		for (int row : sel_rows) {
			if (row >= (int)index_line_map.size()) break;
			sel.insert(index_line_map[row]);
		}

		SetSelectedSet(sel);
	}
	else {
		Selection lines;
		copy(index_line_map.begin(), index_line_map.end(), inserter(lines, lines.begin()));
		Selection new_sel;
		// Remove lines which no longer exist from the selection
		set_intersection(selection.begin(), selection.end(),
			lines.begin(), lines.end(),
			inserter(new_sel, new_sel.begin()));

		SetSelectedSet(new_sel);
	}

	// Force a reannounce of the active line if it hasn't changed, as it isn't
	// safe to touch the active line while processing a commit event which would
	// cause this function to be called
	AssDialogue *line = active_line;
	active_line = 0;

	// The active line may have ceased to exist; pick a new one if so
	if (line_index_map.size() && line_index_map.find(line) == line_index_map.end()) {
		if (active_row < (int)index_line_map.size()) {
			SetActiveLine(index_line_map[active_row]);
		}
		else if (preserve_selected_rows && !selection.empty()) {
			SetActiveLine(index_line_map[sel_rows[0]]);
		}
		else {
			SetActiveLine(index_line_map.back());
		}
	}
	else {
		SetActiveLine(line);
	}

	if (selection.empty() && active_line) {
		Selection sel;
		sel.insert(active_line);
		SetSelectedSet(sel);
	}

	EndBatch();

	SetColumnWidths();

	Refresh(false);
}
Beispiel #14
0
void BaseGrid::SetByFrame(bool state) {
	if (byFrame == state) return;
	byFrame = state;
	SetColumnWidths();
	Refresh(false);
}