1 /* 2 * Copyright 2002-2009, 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 <GraphicsDefs.h> 10 #include <SupportDefs.h> 11 #include <TranslationDefs.h> 12 13 14 class BBitmap; 15 class BFile; 16 class BMenu; 17 class BMessage; 18 class BPositionIO; 19 class BTextView; 20 class BTranslatorRoster; 21 struct entry_ref; 22 23 24 class BTranslationUtils { 25 BTranslationUtils(); 26 BTranslationUtils( 27 const BTranslationUtils& other); 28 ~BTranslationUtils(); 29 30 BTranslationUtils& operator=(const BTranslationUtils& other); 31 32 public: 33 enum { 34 B_TRANSLATION_MENU = 'BTMN' 35 }; 36 37 static BBitmap* GetBitmap(const char* name, 38 BTranslatorRoster* roster = NULL); 39 static BBitmap* GetBitmap(uint32 type, int32 id, 40 BTranslatorRoster* roster = NULL); 41 static BBitmap* GetBitmap(uint32 type, const char* name, 42 BTranslatorRoster* roster = NULL); 43 static BBitmap* GetBitmapFile(const char* name, 44 BTranslatorRoster* roster = NULL); 45 static BBitmap* GetBitmap(const entry_ref* ref, 46 BTranslatorRoster* roster = NULL); 47 static BBitmap* GetBitmap(BPositionIO* stream, 48 BTranslatorRoster* roster = NULL); 49 50 static void SetBitmapColorSpace(color_space space); 51 static color_space BitmapColorSpace(); 52 53 static status_t GetStyledText(BPositionIO* fromStream, 54 BTextView* intoView, 55 BTranslatorRoster* roster = NULL); 56 static status_t GetStyledText(BPositionIO* fromStream, 57 BTextView* intoView, const char* encoding, 58 BTranslatorRoster* roster = NULL); 59 static status_t PutStyledText(BTextView* fromView, 60 BPositionIO* intoStream, 61 BTranslatorRoster* roster = NULL); 62 static status_t WriteStyledEditFile(BTextView* fromView, 63 BFile* intoFile); 64 static status_t WriteStyledEditFile(BTextView* fromView, 65 BFile* intoFile, const char* encoding); 66 67 static BMessage* GetDefaultSettings(translator_id translator, 68 BTranslatorRoster* roster = NULL); 69 static BMessage* GetDefaultSettings(const char* name, 70 int32 version); 71 72 static status_t AddTranslationItems(BMenu* intoMenu, 73 uint32 fromType, 74 const BMessage* model = NULL, 75 const char* idName = NULL, 76 const char* typeName = NULL, 77 BTranslatorRoster* roster = NULL); 78 79 private: 80 static translator_info* _BuildTranslatorInfo(const translator_id id, 81 const translation_format* format); 82 static int _CompareTranslatorInfoByName(const translator_info* info1, 83 const translator_info* info2); 84 85 static color_space sBitmapSpace; 86 }; 87 88 89 #endif // _TRANSLATION_UTILS_H 90