xref: /haiku/headers/os/translation/TranslationUtils.h (revision ed6250c95736c0b55da79d6e9dd01369532260c0)
1 /*
2  * Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _TRANSLATION_UTILS_H
6 #define _TRANSLATION_UTILS_H
7 
8 
9 #include <TranslationDefs.h>
10 #include <SupportDefs.h>
11 
12 class BBitmap;
13 class BFile;
14 class BMenu;
15 class BMessage;
16 class BPositionIO;
17 class BTextView;
18 class BTranslatorRoster;
19 struct entry_ref;
20 
21 
22 class BTranslationUtils {
23 	private:
24 		BTranslationUtils();
25 		~BTranslationUtils();
26 		BTranslationUtils(const BTranslationUtils &);
27 		BTranslationUtils & operator=(const BTranslationUtils &);
28 
29 	public:
30 		// bitmap functions
31 		static BBitmap *GetBitmap(const char *name, BTranslatorRoster *roster = NULL);
32 		static BBitmap *GetBitmap(uint32 type, int32 id,
33 			BTranslatorRoster *roster = NULL);
34 		static BBitmap *GetBitmap(uint32 type, const char *name,
35 			BTranslatorRoster *roster = NULL);
36 		static BBitmap *GetBitmapFile(const char *name,
37 			BTranslatorRoster *roster = NULL);
38 		static BBitmap *GetBitmap(const entry_ref *ref,
39 			BTranslatorRoster *roster = NULL);
40 		static BBitmap *GetBitmap(BPositionIO *stream,
41 			BTranslatorRoster *roster = NULL);
42 
43 		// text functions
44 		static status_t GetStyledText(BPositionIO* fromStream, BTextView* intoView,
45 			BTranslatorRoster *roster = NULL);
46 		static status_t GetStyledText(BPositionIO* fromStream, BTextView* intoView,
47 			const char* encoding, BTranslatorRoster* roster = NULL);
48 		static status_t PutStyledText(BTextView *fromView, BPositionIO *intoStream,
49 			BTranslatorRoster *roster = NULL);
50 		static status_t WriteStyledEditFile(BTextView *fromView, BFile *intoFile);
51 		static status_t WriteStyledEditFile(BTextView *fromView, BFile *intoFile,
52 			const char* encoding);
53 
54 		// misc. functions
55 		static BMessage *GetDefaultSettings(translator_id forTranslator,
56 			BTranslatorRoster *roster = NULL);
57 		static BMessage *GetDefaultSettings(const char *translatorName,
58 			int32 translatorVersion);
59 
60 		enum {
61 			B_TRANSLATION_MENU = 'BTMN'
62 		};
63 		static status_t AddTranslationItems(BMenu *intoMenu, uint32 fromType,
64 			const BMessage *model = NULL,			// default B_TRANSLATION_MENU
65 			const char *translatorIdName = NULL,	// default "be:translator"
66 			const char *translatorTypeName = NULL,	// default "be:type"
67 			BTranslatorRoster *roster = NULL);
68 };
69 
70 #endif /* _TRANSLATION_UTILS_H */
71 
72