1/*
2 * Copyright 2006-2007, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef ATTRIBUTE_LIST_VIEW_H
6#define ATTRIBUTE_LIST_VIEW_H
7
8
9#include <ListView.h>
10#include <Mime.h>
11#include <String.h>
12
13
14class AttributeItem : public BStringItem {
15	public:
16		AttributeItem(const char* name, const char* publicName, type_code type,
17			const char* displayAs, int32 alignment, int32 width, bool visible,
18			bool editable);
19		AttributeItem();
20		AttributeItem(const AttributeItem& other);
21		virtual ~AttributeItem();
22
23		virtual void DrawItem(BView* owner, BRect itemRect,
24			bool drawEverything = false);
25
26		const char* Name() const { return fName.String(); }
27		const char* PublicName() const { return Text(); }
28
29		type_code Type() const { return fType; }
30		const char* DisplayAs() const { return fDisplayAs.String(); }
31		int32 Alignment() const { return fAlignment; }
32		int32 Width() const { return fWidth; }
33		bool Visible() const { return fVisible; }
34		bool Editable() const { return fEditable; }
35
36		AttributeItem& operator=(const AttributeItem& other);
37
38		bool operator==(const AttributeItem& other) const;
39		bool operator!=(const AttributeItem& other) const;
40
41	private:
42		BString		fName;
43		type_code	fType;
44		BString		fDisplayAs;
45		int32		fAlignment;
46		int32		fWidth;
47		bool		fVisible;
48		bool		fEditable;
49};
50
51class AttributeListView : public BListView {
52	public:
53		AttributeListView(const char* name);
54		virtual ~AttributeListView();
55
56		void SetTo(BMimeType* type);
57
58		virtual void Draw(BRect updateRect);
59
60	private:
61		void _DeleteItems();
62};
63
64struct type_map {
65	const char*	name;
66	type_code	type;
67};
68
69extern const struct type_map kTypeMap[];
70
71struct display_as_map {
72	const char* name;
73	const char* identifier;
74	type_code	supported[8];
75};
76
77extern const struct display_as_map kDisplayAsMap[];
78
79AttributeItem* create_attribute_item(BMessage& attributes, int32 index);
80
81#endif	// ATTRIBUTE_LIST_VIEW_H
82