xref: /haiku/src/apps/people/PersonView.h (revision 964b6e8090e0172180c456a93dcbc1454b79f252)
1 /*
2  * Copyright 2010, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT license.
4  *
5  * Authors:
6  *		Robert Polic
7  *		Stephan Aßmus <superstippi@gmx.de>
8  *
9  * Copyright 1999, Be Incorporated.   All Rights Reserved.
10  * This file may be used under the terms of the Be Sample Code License.
11  */
12 #ifndef PERSON_VIEW_H
13 #define PERSON_VIEW_H
14 
15 
16 #include <GridView.h>
17 #include <ObjectList.h>
18 #include <String.h>
19 
20 
21 class AttributeTextControl;
22 class BFile;
23 class BPopUpMenu;
24 class PictureView;
25 
26 enum {
27 	M_SAVE			= 'save',
28 	M_REVERT		= 'rvrt',
29 	M_SELECT		= 'slct',
30 	M_GROUP_MENU	= 'grmn',
31 };
32 
33 
34 class PersonView : public BGridView {
35 public:
36 								PersonView(const char* name,
37 									const char* categoryAttribute,
38 									const entry_ref* ref);
39 	virtual						~PersonView();
40 
41 	virtual	void				MakeFocus(bool focus = true);
42 	virtual	void				MessageReceived(BMessage* message);
43 	virtual void				Draw(BRect updateRect);
44 
45 			void				AddAttribute(const char* label,
46 									const char* attribute);
47 
48 			void				BuildGroupMenu();
49 
50 			void				CreateFile(const entry_ref* ref);
51 
52 			bool				IsSaved() const;
53 			void				Save();
54 
55 			const char*			AttributeValue(const char* attribute) const;
56 			void				SetAttribute(const char* attribute, bool update);
57 			void				SetAttribute(const char* attribute,
58 									const char* value, bool update);
59 
60 			void				UpdatePicture(const entry_ref* ref);
61 
62 			bool				IsTextSelected() const;
63 
64 private:
65 			const entry_ref*	fRef;
66 			time_t				fLastModificationTime;
67 			BPopUpMenu*			fGroups;
68 			typedef BObjectList<AttributeTextControl> AttributeList;
69 			AttributeList		fControls;
70 
71 			BString				fCategoryAttribute;
72 			PictureView*		fPictureView;
73 			bool				fSaving;
74 };
75 
76 #endif // PERSON_VIEW_H
77