Example #1
0
void
DocInfoWindow::FrameResized(float newWidth, float newHeight)
{
	BTextControl *textControl = dynamic_cast<BTextControl*> (fTable->ChildAt(0));
	if (textControl) {
		float width, height;
		textControl->GetPreferredSize(&width, &height);

		int32 count = fKeyList->CountItems();
		float fieldsHeight = (height * count) + (2 * count);

		_AdjustScrollBar(height, fieldsHeight);

		while (textControl) {
			textControl->SetDivider(textControl->Bounds().Width() / 2.0);
			textControl = dynamic_cast<BTextControl*> (textControl->NextSibling());
		}
	}
}
Example #2
0
void
DocInfoWindow::_BuildTable(const BMessage& docInfo)
{
	_EmptyKeyList();

	while (fTable->ChildAt(0)) {
		BView *child = fTable->ChildAt(0);
		fTable->RemoveChild(child);
		delete child;
	}

	fTable->ScrollTo(0, 0);

#ifdef B_BEOS_VERSION_DANO
	const
#endif
	char *name;
	uint32 type;
	int32 count;

	float rowHeight = 20.0;
	float fieldsHeight = 2.0;
	float width = fTable->Bounds().Width() - 4.0;
	for (int32 i = 0; docInfo.GetInfo(B_STRING_TYPE, i, &name, &type, &count)
		== B_OK; i++) {
		if (type != B_STRING_TYPE)
			continue;

		BString value;
		BTextControl* textControl;
		if (docInfo.FindString(name, &value) == B_OK) {
			BRect rect(2.0, fieldsHeight, width, rowHeight);
			textControl = _AddFieldToTable(rect, name, value.String());

			rowHeight = textControl->Bounds().Height();
			fieldsHeight += rowHeight + 2.0;
		}
	}

	_AdjustScrollBar(rowHeight, fieldsHeight);
}
Example #3
0
void
DocInfoWindow::_AddKey(BMessage *msg, bool textControl)
{
	void *p;
	if (msg->FindPointer("source", &p) != B_OK || p == NULL)
		return;

	const char* key = NULL;
	if (textControl) {
		BTextControl *text = reinterpret_cast<BTextControl*>(p);
		key = text->Text();
	} else {
		BMenuItem *item = reinterpret_cast<BMenuItem*>(p);
		key = item->Label();
	}

	if (!_IsKeyValid(key))
		return;

	BMessage docInfo;
	_ReadFieldsFromTable(docInfo);

	if (!docInfo.HasString(key)) {
		// key is valid and is not in list already
		docInfo.AddString(key, "");

		float width = fTable->Bounds().Width() - 4.0;
		BTextControl *textControl =
			_AddFieldToTable(BRect(2.0, 0.0, width, 20.0), key, "");

		float rowHeight = textControl->Bounds().Height();
		int32 count = fKeyList->CountItems();
		float fieldsHeight = (rowHeight * count) + (2 * count);
		textControl->MoveTo(2.0, fieldsHeight - rowHeight);

		_AdjustScrollBar(rowHeight, fieldsHeight);
	}
}