1 #ifndef __BL_TOOLS_H__
2 #define __BL_TOOLS_H__
3
4 #include <GraphicsDefs.h>
5 #include <SupportDefs.h>
6 #include <Message.h>
7
8 void
9 Debug_Error(const char * pc_Message, status_t err=B_ERROR);
10
11 void
12 Debug_Info(const char * pc_Message);
13
14 void
15 Debug_Alert(const char * pc_Message);
16
17 #define DPRINT(c) Debug_Info(c)
18
19
20 void
21 ASSERT(bool b_True,const char *pc_Message=NULL);
22
23 #define DEBUG_INFO(message) Debug_Info(message)
24
25
26 #define RGB_SET(c,r,g,b) {c.red=r;c.green=g;c.blue=b;c.alpha=255;}
27 #define RGBA_SET(c,r,g,b,a) {c.red=r;c.green=g;c.blue=b;c.alpha=a;}
28
29
30 #define DELETE(_p) {if(_p) delete _p; _p = NULL;}
31
32 class BL_String;
33
34 class BL_Object{
35 public:
36 BL_Object(){};
37 virtual ~BL_Object(){};
38 };
39
40 #include <List.h>
41
42 #define BL_COLLECTION_ITEMS_IS_VOID 0
43 #define BL_COLLECTION_ITEMS_IS_STRING 1
44 #define BL_COLLECTION_ITEMS_IS_LIST 2
45 #define BL_COLLECTION_ITEMS_IS_BLOBJECT 3
46
47 class BL_Collection:public BList{
48 public:
49 BL_Collection(bool b_DeleteItems=false);
50 virtual ~BL_Collection();
51 void DeleteItems();
52 void RemoveList(BL_Collection &lo_Item);
53 void RemoveList(BL_Collection *plo_Item);
54 void DeleteItem(void *pu_Item);
55 void DeleteItemAt(int i_Index);
56
57 virtual bool AddItem(void *pu_Item);
58 bool AddItem(BString * ps_Item);
59 bool AddItem(BL_String * ps_Item);
60 bool AddItem(BList * pl_Item);
61 bool AddItem(BL_Object * po_Item);
62 virtual bool AddList(BList *pl_List);
63 virtual bool AddList(BL_Collection *pl_List);
64 virtual bool AddList(BL_Collection *pl_List,int i_Index);
65
66 virtual bool AddItem(void *pu_Item, int32 atIndex);
67 virtual bool AddItem(BL_Object *po_Item, int32 atIndex);
68 virtual bool AddItem(BString *ps_Item, int32 atIndex);
69
70 BL_String* StringAt(int i_Index);
71
72 void* LastItem();
73 void* FirstItem();
74
75 protected:
76 bool bDeleteItems;
77 int iItemsType;
78 };
79
80 class BL_List: public BL_Collection{
81 public:
82 BL_List(bool b_DeleteItems=true);
83
84 };
85
86 #include <String.h>
87
88 class BL_String:public BString{
89 public:
90 BL_String(const char *pc_Text);
91 BL_String(const BString & s_Source);
92 BL_String();
93 virtual ~BL_String();
94
95 int ComparePos(BL_String & s_Friend,int i_SelfPos,int i_FriendPos);
96 virtual void operator=(const char* pc_Value);
97 virtual void operator=(int64 i_Value);
98 virtual void operator=(BString & s_Value);
99 int32 CountChar(char c_Value);
100 BL_String* SetDigits(char c_Digit=',',char c_DecPointChar='.');
101
102 int32 Int32();
103 float Float();
104
105 void RTrim(char c_Byte=' ');
106 void LTrim(char c_Byte=' ');
107
108 status_t GetFromMessage(BMessage *po_Message,const char *pc_Name);
109
110 int32 LengthUTF8() const;
111 void RemoveUTF8(int32 i_FromChar, int32 i_CharsCount);
112 void AppendUTF8(const char *source, int32 i_CharsCount);
113 const char* StringUTF8(int32 i_FromChar)const;
114 void InsertUTF8(const char *pc_Value, int32 i_CharsCount,int32 i_CharPos);
115
116 };
117
118 int32 PCharCharPosInBytes_UTF8(const char *pc_Source,int32 i_Char);
119 int32 PCharCharsInBytes_UTF8(const char *pc_Source,int32 i_Chars);
120 char* PCharFindLastChar(char *pc_Line,char c_Char);
121
122
123 void BL_System_TranslError(status_t u_Error,BL_String & s_Text);
124 void BL_System_TypeToString(uint32 i_Type,BL_String & s);
125 void BL_Int_Swap(void *pi);
126
127 #define BL_KEY_PLUS 58
128 #define BL_KEY_MINUS 37
129 #define BL_KEY_MUL 36
130
131
132 #include <Bitmap.h>
133
134 #define BL_MIME_FOLDER "application/x-vnd.Be-directory"
135 #define BL_MIME_BOOKMARK "application/x-vnd.Be-bookmark"
136 #define BL_MIME_FILE "application/octet-stream"
137 #define BL_MIME_FONT "application/x-vnd.Be-FDEM"
138
139 BBitmap* BL_Load_SIconFromMIME(const char *pc_MIME);
140
141 void BL_Get_SList_FromMessage(BMessage & o_Message,const char *pc_Name,BL_List & ls_Result);
142
143
144 #include <Autolock.h>
145
146 #define LOCK_WINDOW() BAutolock oLock(Window())
147
148 #endif