Example #1
0
void DocHistory::SetDocument(const doc_id& di) {
	//wxASSERT(m_catalyst.IsOk(di));

	// Check if we are invalidating the view
	if (!di.IsOk()) {
		Clear();
		return;
	}

	if (m_sourceDoc != di) {
		cxLOCKDOC_WRITE(m_doc)
			doc.SetDocument(di);

			// Get the document
			m_document_id = di.IsDraft() ? doc.GetParent().document_id : di.document_id;
		cxENDLOCK

		m_sourceDoc = di;

		// Check if we need to rebuild the tree
		ReBuildTree();
	}

	Select(m_selectedNode);
	MakeItemVisible(m_selectedNode);
}
Example #2
0
void DocHistory::OnMouseLeftDown(wxMouseEvent& event) {
	const int y = event.GetY() + m_scrollPos;

	// Which node are we over?
	int node_id = -1;
	for (unsigned int i = 0; i < m_items.size(); ++i) {
		const int node_ypos = m_items[i].ypos;
		if (y >= node_ypos && y < (node_ypos + m_lineHeight)) {
			node_id = i;
			break;
		}
	}

	if (node_id != -1) {
		// We do not have to set the document now. We will recieve
		// a WIN_CHANGEDOC notifer if the documents actually gets
		// set on a page.

		// Do not return a reference. The events might modify
		// m_items underneath it.
		const doc_id hot_doc = m_items[node_id].doc;

		if (hot_doc.IsDraft()) {
			doc_id draft_head;
			cxLOCK_READ(m_catalyst)
				draft_head = catalyst.GetDraftHead(hot_doc.document_id);
			cxENDLOCK
			m_dispatcher.Notify(wxT("WIN_SETDOCUMENT"), &draft_head, m_source_win_id);
		}
		else m_dispatcher.Notify(wxT("WIN_SETDOCUMENT"), &hot_doc, m_source_win_id);
	}
}
Example #3
0
void DocHistory::OnVersionTreeSel(VersionTreeEvent& event) {
	wxASSERT(event.GetItem() >= 0 && event.GetItem() < m_items.size());

	// Do not return a reference. The events might modify
	// m_items underneath it.
	const doc_id hot_doc = m_items[event.GetItem()].doc;

	// We do not have to set the document now. We will recieve
	// a WIN_CHANGEDOC notifer if the documents actually gets
	// set on a page.

	if (hot_doc.IsDraft()) {
		doc_id draft_head;
		cxLOCK_READ(m_catalyst)
			draft_head = catalyst.GetDraftHead(hot_doc.document_id);
		cxENDLOCK
		m_dispatcher.Notify(wxT("WIN_SETDOCUMENT"), &draft_head, m_source_win_id);
	}
	else m_dispatcher.Notify(wxT("WIN_SETDOCUMENT"), &hot_doc, m_source_win_id);
}
Example #4
0
void RevTooltip::SetDocument(const doc_id& di, wxPoint pos) {
    Hide();

    cxLOCK_READ(m_catalyst)
    wxASSERT(catalyst.IsOk(di));

    m_docId = di;

    // Set the user info
    const unsigned int userId = catalyst.GetDocAuthor(m_docId);
    m_userPic->SetBitmap(catalyst.GetUserPic(userId));
    m_userName->SetLabel(catalyst.GetUserName(userId));
    if (userId == 0) m_userColor->Hide();
    else {
        m_userColor->SetBackgroundColour(catalyst.GetUserColor(userId));
        m_userColor->Show();
    }

    // Set the Label
    wxString label = catalyst.GetLabel(m_docId);
    if (!label.empty()) label += wxT(":");
    m_labelCtrl->SetLabel(label);

    // Set the Date
    const wxDateTime date = catalyst.GetDocDate(m_docId);
    const wxString age = catalyst.GetDocAge(m_docId);
    const wxString longdate = date.Format(wxT("%A, %B %d, %Y - %X ")) + wxString::Format(wxT("(%s)"),age.c_str());
    m_dateCtrl->SetLabel(longdate);

    // Set the Comment
    m_descCtrl->SetLabel(catalyst.GetDescription(m_docId));

    // Show paths to mirrors (if available)
    if (catalyst.IsMirrored(di)) {
        m_mainSizer->Show(m_mirrorSizer, true, true);

        wxArrayString paths;
        if (di.IsDraft()) catalyst.GetMirrorPathsForDraft(di, paths); // gets mirrors for all draft revisions
        else catalyst.GetMirrorPaths(di, paths);

        if (!paths.IsEmpty()) {
            wxString tip = paths[0];
            for (size_t i = 1; i < paths.GetCount(); ++i) {
                tip += wxT("\n");
                tip += paths[i];
            }
            m_mirrorlistCtrl->SetLabel(tip);
        }
        else wxASSERT(false);
    }
    else m_mainSizer->Show(m_mirrorSizer, false, true);
    cxENDLOCK

    m_mainSizer->Layout();
    m_mainSizer->SetSizeHints(m_mainPanel);
    m_mainSizer->SetSizeHints(this);

    // Get the size of the screen
    const int screen_x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
    const int screen_y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);

    // Get the size of the mouse cursor
    // BUG WORKAROUND: GetMetric gives how large it _can_ be (32*32) not
    // how large the actual visible image is.
    const int cursor_x = 16; // wxSystemSettings::GetMetric(wxSYS_CURSOR_X);
    const int cursor_y = 17; // wxSystemSettings::GetMetric(wxSYS_CURSOR_Y);

    const wxSize size = GetSize();

    // Calculate the correct placement
    // (pos is assumed to be upper left corner of cursor)
    if (pos.x + cursor_x + size.x > screen_x) pos.x -= size.x + 3;
    else pos.x += cursor_x;

    if (pos.y + cursor_y + size.y > screen_y) pos.y -= size.y + 3;
    else pos.y += cursor_y;

    Move(pos);
    Show();
}