xref: /haiku/src/preferences/locale/LanguageListView.h (revision 922e7ba1f3228e6f28db69b0ded8f86eb32dea17)
1 /*
2  * Copyright 2006-2010, Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  *		Adrien Destugues <pulkomandy@gmail.com>
8  *		Axel Dörfler, axeld@pinc-software.de
9  *		Oliver Tappe <zooey@hirschkaefer.de>
10  */
11 #ifndef LANGUAGE_LIST_VIEW_H
12 #define LANGUAGE_LIST_VIEW_H
13 
14 
15 #include <OutlineListView.h>
16 #include <StringItem.h>
17 #include <String.h>
18 
19 
20 class LanguageListItem : public BStringItem {
21 public:
22 							LanguageListItem(const char* text,
23 								const char* id, const char* langCode,
24 								const char* countryCode = NULL);
25 							LanguageListItem(const LanguageListItem& other);
26 	virtual					~LanguageListItem();
27 
28 			const BString&	ID() const { return fID; }
29 			const BString&	Code() const { return fCode; }
30 
31 	virtual	void			DrawItem(BView* owner, BRect frame,
32 								bool complete = false);
33 
34 	virtual void			Update(BView* owner, const BFont* font);
35 
36 private:
37 			BString			fID;
38 			BString			fCode;
39 			BBitmap*		fIcon;
40 };
41 
42 
43 class LanguageListView : public BOutlineListView {
44 public:
45 							LanguageListView(const char* name,
46 								list_view_type type);
47 	virtual					~LanguageListView();
48 
49 			LanguageListItem* ItemForLanguageID(const char* code,
50 								int32* _index = NULL) const;
51 			LanguageListItem* ItemForLanguageCode(const char* code,
52 								int32* _index = NULL) const;
53 
54 			void			SetDeleteMessage(BMessage* message);
55 			void			SetDragMessage(BMessage* message);
56 
57 	virtual	bool 			InitiateDrag(BPoint point, int32 index,
58 								bool wasSelected);
59 	virtual	void 			MouseMoved(BPoint where, uint32 transit,
60 								const BMessage* dragMessage);
61 	virtual	void 			AttachedToWindow();
62 	virtual	void 			MessageReceived(BMessage* message);
63 	virtual	void			KeyDown(const char* bytes, int32 numBytes);
64 
65 private:
66 			bool			_AcceptsDragMessage(const BMessage* message) const;
67 
68 private:
69 			int32			fDropIndex;
70 			BMessage*		fDeleteMessage;
71 			BMessage*		fDragMessage;
72 };
73 
74 
75 #endif	// LANGUAGE_LIST_VIEW_H
76