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 BTranslatorRoster; 14 class BPositionIO; 15 class BMenu; 16 17 18 class BTranslationUtils { 19 private: 20 BTranslationUtils(); 21 ~BTranslationUtils(); 22 BTranslationUtils(const BTranslationUtils &); 23 BTranslationUtils & operator=(const BTranslationUtils &); 24 25 public: 26 // bitmap functions 27 static BBitmap *GetBitmap(const char *name, BTranslatorRoster *roster = NULL); 28 static BBitmap *GetBitmap(uint32 type, int32 id, 29 BTranslatorRoster *roster = NULL); 30 static BBitmap *GetBitmap(uint32 type, const char *name, 31 BTranslatorRoster *roster = NULL); 32 static BBitmap *GetBitmapFile(const char *name, 33 BTranslatorRoster *roster = NULL); 34 static BBitmap *GetBitmap(const entry_ref *ref, 35 BTranslatorRoster *roster = NULL); 36 static BBitmap *GetBitmap(BPositionIO *stream, 37 BTranslatorRoster *roster = NULL); 38 39 // text functions 40 static status_t GetStyledText(BPositionIO* fromStream, BTextView* intoView, 41 BTranslatorRoster *roster = NULL); 42 static status_t GetStyledText(BPositionIO* fromStream, BTextView* intoView, 43 const char* encoding, BTranslatorRoster* roster = NULL); 44 static status_t PutStyledText(BTextView *fromView, BPositionIO *intoStream, 45 BTranslatorRoster *roster = NULL); 46 static status_t WriteStyledEditFile(BTextView *fromView, BFile *intoFile); 47 static status_t WriteStyledEditFile(BTextView *fromView, BFile *intoFile, 48 const char* encoding); 49 50 // misc. functions 51 static BMessage *GetDefaultSettings(translator_id forTranslator, 52 BTranslatorRoster *roster = NULL); 53 static BMessage *GetDefaultSettings(const char *translatorName, 54 int32 translatorVersion); 55 56 enum { 57 B_TRANSLATION_MENU = 'BTMN' 58 }; 59 static status_t AddTranslationItems(BMenu *intoMenu, uint32 fromType, 60 const BMessage *model = NULL, // default B_TRANSLATION_MENU 61 const char *translatorIdName = NULL, // default "be:translator" 62 const char *translatorTypeName = NULL, // default "be:type" 63 BTranslatorRoster *roster = NULL); 64 }; 65 66 #endif /* _TRANSLATION_UTILS_H */ 67 68