Exemplo n.º 1
0
void CColumnTreeView::UpdateColumns()
{
	m_cxTotal = 0;

	HDITEM hditem;
	hditem.mask = HDI_WIDTH;
	int nCnt = m_Header.GetItemCount();
	if (nCnt > 16)
		nCnt = 16;

	// get column widths from the header control
	for (int i=0; i<nCnt; i++)
	{
		if (m_Header.GetItem(i, &hditem))
		{
			m_cxTotal += m_arrColWidths[i] = hditem.cxy;
			if (i==0)
				m_Tree.m_cxFirstCol = hditem.cxy;
		}
	}
	m_Tree.m_cxTotal = m_cxTotal;

	UpdateScroller();
	RepositionControls();
}
Exemplo n.º 2
0
void CColumnTreeView::OnSize(UINT nType, int cx, int cy)
{
	CView::OnSize(nType, cx, cy);

	UpdateScroller();
	RepositionControls();
}
Exemplo n.º 3
0
void
DataView::FrameResized(float width, float height)
{
	if (fFitFontSize) {
		// adapt the font size to fit in the view's bounds
		float oldSize = FontSize();
		BFont font = be_fixed_font;
		float steps = 0.5f;

		float size;
		for (size = 1.f; size < 100; size += steps) {
			font.SetSize(size);
			float charWidth = font.StringWidth("w");
			if (charWidth * (kBlockSize * 4 + fPositionLength + 6) + 2 * kHorizontalSpace > width)
				break;

			if (size > 6)
				steps = 1.0f;
		}
		size -= steps;
		font.SetSize(size);

		if (oldSize != size) {
			SetFont(&font);
			Invalidate();
		}
	}

	UpdateScroller();
}
Exemplo n.º 4
0
void
DataView::FrameResized(float width, float height)
{
	if (fFitFontSize) {
		// adapt the font size to fit in the view's bounds
		float oldSize = FontSize();
		float steps = 0.5f;

		float size;
		for (size = 1.f; size < 100; size += steps) {
			int32 preferredWidth = WidthForFontSize(size);
			if (preferredWidth > width)
				break;

			if (size > 6)
				steps = 1.0f;
		}
		size -= steps;

		if (oldSize != size) {
			BFont font = be_fixed_font;
			font.SetSize(size);
			SetFont(&font);

			Invalidate();
		}
	}

	UpdateScroller();
}
Exemplo n.º 5
0
void
DataView::SetFontSize(float point)
{
	bool fit = (point == 0.0f);
	if (fit) {
		if (!fFitFontSize)
			SendNotices(kDataViewPreferredSize);
		fFitFontSize = fit;

		FrameResized(Bounds().Width(), Bounds().Height());
		return;
	}

	fFitFontSize = false;

	BFont font = be_fixed_font;
	font.SetSize(point);

	SetFont(&font);
	UpdateScroller();
	Invalidate();

	SendNotices(kDataViewPreferredSize);
}
Exemplo n.º 6
0
void
DataView::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kMsgUpdateData:
		case kMsgDataEditorUpdate:
			UpdateFromEditor(message);
			break;

		case kMsgDataEditorParameterChange:
		{
			int32 viewSize;
			off_t offset;
			if (message->FindInt64("offset", &offset) == B_OK) {
				fOffset = offset;
				SetSelection(0, 0);
				MakeVisible(0);
			}
			if (message->FindInt32("view_size", &viewSize) == B_OK) {
				fDataSize = viewSize;
				fData = (uint8 *)realloc(fData, fDataSize);
				UpdateScroller();
				SendNotices(kDataViewPreferredSize);
			}
			if (message->FindInt64("file_size", &offset) == B_OK)
				UpdateFromEditor();
			break;
		}

		case kMsgBaseType:
		{
			int32 type;
			if (message->FindInt32("base", &type) != B_OK)
				break;

			SetBase((base_type)type);
			break;
		}

		case kMsgSetSelection:
		{
			int64 start, end;
			if (message->FindInt64("start", &start) != B_OK
				|| message->FindInt64("end", &end) != B_OK)
				break;

			SetSelection(start, end);
			break;
		}

		case B_SELECT_ALL:
			SetSelection(0, fDataSize - 1);
			break;

		case B_COPY:
			Copy();
			break;

		case B_PASTE:
			Paste();
			break;

		case B_UNDO:
			fEditor.Undo();
			break;

		case B_REDO:
			fEditor.Redo();
			break;

		case B_MIME_DATA:
			if (AcceptsDrop(message)) {
				const void *data;
				ssize_t size;
				if (message->FindData("text/plain", B_MIME_TYPE, &data, &size) == B_OK
					|| message->FindData(B_FILE_MIME_TYPE, B_MIME_TYPE, &data, &size) == B_OK) {
					if (fEditor.Replace(fOffset + fStart, (const uint8 *)data, size) != B_OK)
						SetSelection(fStoredStart, fStoredEnd);

					fDragMessageSize = -1;
				}
			}
			break;

		default:
			BView::MessageReceived(message);
	}
}