Example #1
0
status_t
PTextView::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BTextView *backend = (BTextView*)fView;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("LineCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountLines());
	else if (str.ICompare("Selectable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsSelectable());
	else if (str.ICompare("CurrentLine") == 0)
		((IntProperty*)prop)->SetValue(backend->CurrentLine());
	else if (str.ICompare("TabWidth") == 0)
		((FloatProperty*)prop)->SetValue(backend->TabWidth());
	else if (str.ICompare("TextRect") == 0)
		((RectProperty*)prop)->SetValue(backend->TextRect());
	else if (str.ICompare("MaxBytes") == 0)
		((IntProperty*)prop)->SetValue(backend->MaxBytes());
	else if (str.ICompare("UseWordWrap") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesWordWrap());
	else if (str.ICompare("HideTyping") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsTypingHidden());
	else if (str.ICompare("Editable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsEditable());
	else if (str.ICompare("ColorSpace") == 0)
		((IntProperty*)prop)->SetValue(backend->ColorSpace());
	else if (str.ICompare("TextLength") == 0)
		((IntProperty*)prop)->SetValue(backend->TextLength());
	else if (str.ICompare("Text") == 0)
		((StringProperty*)prop)->SetValue(backend->Text());
	else if (str.ICompare("Resizable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsResizable());
	else if (str.ICompare("Alignment") == 0)
		((EnumProperty*)prop)->SetValue(backend->Alignment());
	else if (str.ICompare("Undoable") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesUndo());
	else if (str.ICompare("AutoIndent") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesAutoindent());
	else if (str.ICompare("Stylable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsStylable());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::GetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}