示例#1
0
文件: DocHistory.cpp 项目: lenoval/e
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);
	}
}
示例#2
0
wxPanel* SettingsDlg::CreateProfilePage(wxWindow* parent) {
	wxPanel* profilePage = new wxPanel(parent, wxID_ANY);
	wxFlexGridSizer* profileSizer = new wxFlexGridSizer(2, 2, 0, 0);
	profileSizer->AddGrowableCol(1); // col 2 is sizable

	wxStaticText* labelName = new wxStaticText(profilePage, wxID_ANY, _("Name:"));
	profileSizer->Add(labelName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
	
	cxLOCK_READ(m_catalyst)
		m_ctrlUserName = new wxTextCtrl(profilePage, wxID_ANY, catalyst.GetUserName(0));
		profileSizer->Add(m_ctrlUserName, 1, wxEXPAND|wxALL, 5);

		wxStaticText* labelPic = new wxStaticText(profilePage, wxID_ANY, _("Picture:"));
		profileSizer->Add(labelPic, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

		wxBoxSizer* picSizer = new wxBoxSizer(wxHORIZONTAL);
		m_ctrlUserPic = new wxStaticBitmap(profilePage, wxID_ANY, catalyst.GetUserPic(0));
		m_ctrlUserPic->SetBackgroundColour(*wxWHITE);
		picSizer->Add(m_ctrlUserPic, 0);

		wxButton* loadButton = new wxButton(profilePage, CTRL_LOADPIC, _("Load..."));
		picSizer->Add(loadButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 15);

		profileSizer->Add(picSizer, 0, wxALL, 5);
	cxENDLOCK

	profilePage->SetSizerAndFit(profileSizer);
	return profilePage;
}
示例#3
0
文件: DocHistory.cpp 项目: lenoval/e
// static notification handler
void DocHistory::OnUpdateRevision(DocHistory* self, void* data, int WXUNUSED(filter)) {
	if (!self->m_sourceDoc.IsOk()) return;
	const doc_id* const di = (doc_id*)data;
	wxASSERT(di->IsDraft());

	bool inSame;
	cxLOCK_READ(self->m_catalyst)
		inSame = catalyst.InSameHistory(self->m_sourceDoc, *di);
	cxENDLOCK

	if (inSame) {
		self->SetDocument(*di);
	}
}
示例#4
0
文件: DocHistory.cpp 项目: lenoval/e
// static notification handler
void DocHistory::OnDocUpdated(DocHistory* self, void* data, int WXUNUSED(filter)) {
	if (!self->m_sourceDoc.IsOk()) return;

	const doc_id& di = *(const doc_id*)data;

	bool isSameDoc;
	cxLOCK_READ(self->m_catalyst)
		isSameDoc = catalyst.InSameHistory(di, self->m_sourceDoc);
	cxENDLOCK

	if (isSameDoc) {
		self->ReBuildTree();
		self->m_isScrolling = false; // avoid moving old image if scrolling during update
		wxClientDC dc(self);
		self->DrawLayout(dc);
	}
}
示例#5
0
void PreviewDlg::LoadSettings(const CatalystWrapper& cw) {
	// Get saved position
	bool showOptions = false;
	bool doPipe = false;
	wxString pipeCmd = wxT("markdown.pl");
	cxLOCK_READ(cw)
		catalyst.GetSettingBool(wxT("prvw_showoptions"), showOptions);
		catalyst.GetSettingBool(wxT("prvw_dopipe"), doPipe);
		catalyst.GetSettingString(wxT("prvw_pipecmd"), pipeCmd);
	cxENDLOCK

	m_showOptions->SetValue(showOptions);
	if (showOptions) m_mainSizer->Show(m_optionSizer);
	else m_mainSizer->Hide(m_optionSizer);
	m_mainSizer->Layout();

	m_pipeCheck->SetValue(doPipe);
	m_cmdText->SetValue(pipeCmd);
	if (doPipe) m_pipeCmd = pipeCmd;
}
示例#6
0
文件: DocHistory.cpp 项目: lenoval/e
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);
}
示例#7
0
文件: DocHistory.cpp 项目: lenoval/e
void DocHistory::ReBuildTree() {
	if (m_document_id == -1) {
		wxASSERT(m_sourceDoc.IsDraft());
		// The draft has no parent (and can't have children)
		// So just add a single entry.
		m_items.clear();
		m_positions.clear();

		item new_item;
		new_item.doc = m_sourceDoc;
		cxLOCKDOC_READ(m_doc)
			new_item.date = doc.GetDate();
		cxENDLOCK
		new_item.parent = 0; // root is it's own parent
		new_item.ypos = 0;

		m_items.push_back(new_item);
		m_positions.push_back(0);
		m_selectedNode = 0;

		// Update timeline
		m_pTimeline->Clear();
		m_pTimeline->AddItem(new_item.date);

		// Update the VersionTree
		m_pTree->Clear();
		m_pTree->AddRoot();
	}
	else
	{
		m_items.clear();
		m_positions.clear();

		// Add the root
		const doc_id root(DOCUMENT, m_document_id, 0); // root is always zero
		item new_item;
		new_item.doc = root;
		cxLOCK_READ(m_catalyst)
			new_item.date = catalyst.GetDocDate(root);
			new_item.parent = 0; // root is it's own parent
			new_item.ypos = 0;
			m_items.push_back(new_item);
			if (m_sourceDoc == root) m_selectedNode = 0;
			else m_selectedNode = -1; // not yet set

			// Build the tree
			AddChildren(0, root, m_sourceDoc, catalyst);
		cxENDLOCK
		wxASSERT(m_selectedNode >= 0 && m_selectedNode < (int)m_items.size());

		// Update Timeline & VersionTree
		m_pTimeline->Clear();
		m_pTree->Clear();
		if (!m_items.empty()) {
			m_pTimeline->AddItem(new_item.date);
			m_pTree->AddRoot();
		}
		for(unsigned int i = 1; i < m_items.size(); ++i) {
			const int ypos = m_pTimeline->AddItem(m_items[i].date);
			m_pTree->AddNode(m_items[i].parent, ypos);
			m_items[i].ypos = ypos;
		}
	}

	m_pTree->CalculateLayout();

	m_treeHeight = m_items.empty() ? 0 : m_items.back().ypos + m_lineHeight;
}
示例#8
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();
}