6 #include <wx/confbase.h>
8 #include <wx/hashmap.h>
11 #include <wx/valtext.h>
13 #include "common__globals.h"
14 #include "images__pngFile.h"
15 #include "images__gifFile.h"
16 #include "common__object_file.h"
17 #include "common__validators.h"
23 #define t_size_of(t) (int)(sizeof(t)/sizeof(wxString))
26 /**\internal*****************
27 * Miscellanious facilities
28 * **************************
30 bool Frame_RestorePrevCoord( wxWindow
* it
, const wxString
& name
);
31 void Frame_SaveCoord( wxWindow
* it
, const wxString
& name
);
32 void Frame_DestroySavedCoord( const wxString
& name
);
34 // Shortcuts Saves/Write config for the EditFrame objects
35 wxString
ConfigEdit_Read( const wxString
& subpath
, const wxString
& def_val
= wxString() );
36 void ConfigEdit_Write( const wxString
& subpath
, const wxString
& val
);
38 void ClearMenu( wxMenu
* menu
);
39 void EnableItemsMenu( wxMenu
* menu
, bool b_enable
);
42 void OpenInExternalEditor( wxWindow
* parent
, const wxString
& filePath
);
44 /**\internal*****************
45 * Ob_objects facilities
46 * **************************
48 void Sort_ob_Object_ByName( ob_object
**& objs
, size_t count
);
49 void Sort_ob_Object_ByTag( ob_object
**& objs
, size_t count
, size_t num_tag
= 0 );
50 void Sort_ob_Object_ByTag( ob_anim
**& objs
, size_t count
, size_t num_tag
= 0 );
52 wxString
* Reverse_Null_StrArray( wxString
* tokens
, size_t tokens_size
);
54 wxArrayString
Tokenize( const wxString
& str
);
55 wxString
UnTokenize( ob_object
* _obj
);
57 // ... are <const char*>
59 wxArraystring__Add( wxArrayString
& arr_str
, size_t nb_str
, ... );
61 wxArrayString_Build( size_t nb_str
, ... );
64 /**\internal*****************
65 * Conversions facilities
66 * **************************
68 wxString
IntToStr( int i
);
69 wxString
IntToStr( size_t i
);
70 wxString
FloatToStr( const float f
);
71 inline wxString
BoolToStr(const bool b
){ return (b
? wxT("1") : wxT("0")); }
73 int StrToInt( const wxString
& str
, bool& ok
);
74 int StrToInt( const wxString
& str
);
75 unsigned int StrToUInt( const wxString
& str
, bool& ok
);
76 float StrToFloat(const wxString
& str
, bool& ok
);
77 float StrToFloat(const wxString
& str
);
79 bool IntToBool(const int i
);
80 bool StrToBool( const wxString
& str
);
84 /**\internal*****************
86 * **************************
89 bool StrIsObBool( const wxString
& str
);
90 bool StrIsInt( const wxString
& str
);
91 bool StrIsUInt( const wxString
& str
);
92 bool StrIsFloat( const wxString
& str
);
95 Concat_ArrayString( const wxArrayString
& arr1
, const wxArrayString
& arr2
);
97 ArrStrConcat( const wxArrayString
& arrStr
, const wxString
& separator
= wxString() );
99 StrSplit( const wxString
& str
, const wxString
& delim
, bool b_remove_emtpy
= true );
102 ArrayString_PrependAll( const wxArrayString
& arrStr
, const wxString
& _prefix
);
104 ArrayString_Join( const wxArrayString
& arrStr
, const wxString
& _jointure
);
106 void TabStringToArrayString( wxString
* tStr
, size_t nb
, wxArrayString
& arrStr
);
108 bool IsInArray(const wxString
& _t
, wxString
* arr
, size_t arr_tay
);
110 // Compare String with taking care of numbers in it
111 // Return -1 if s0 < s1 , 0 if s0 == s1, 1 else
112 int P_StrCmp( const wxString
& s0
, const wxString
& s1
);
113 bool IsEmpty( const wxString
& s
);
115 /**\internal*****************
117 * **************************
120 wxFileName
MyDirAppend( const wxFileName dataDirPath
, const wxString
& subDir
);
121 wxFileName
MyPathAppend( const wxFileName dataDirPath
, const wxString
& subPath
);
122 wxString
ObPath_To_FullPath( const wxString
& _subPath
);
123 wxFileName
GetObFile( const wxString
& _subPath
);
124 wxString
Convert_To_Ob_Path( const wxString
& _path
);
126 wxFileName
GetRessourceFile( const wxString
& _strFileName
);
127 wxString
GetRessourceFile_String( const wxString
& _strFileName
);
129 wxString
TryRepairObPath( const wxFileName
& _filename
);
131 bool SimpleBackUpFile( const wxString
& filePath
);
132 bool myBackUp( const wxString
& filePath
);
133 bool myMove(const wxString
& _src
,const wxString
& _dest
);
135 bool IsFileEmpty(const wxString
& _path
);
142 void Add_Repairable( const wxString
& _prop_name
, size_t _num_token
);
143 size_t Try_Repair(ob_object
* o
);
151 std::list
<struct d_s_i
> props
;
152 size_t RECURS_Repair(ob_object
* o
);
157 /**\internal*****************
159 * **************************
162 wxColour
MeltColor(wxColour _c0
, wxColour _c1
);
165 // Tool class to save some code reusing when an object hold an image
170 virtual ~Image_Holder();
172 virtual wxFileName
GetFileName() = 0;
175 imgFile
* Get_GIF_or_PNG();
178 int Get_ColorIndex( const int x
, const int y
);
187 Build_Remap( wxImage
* src
// The target image in wxImage format
188 , imgFile
* src2
// The target image in imgFile format
189 , imgFile
* remap_src
// The reamp src image
190 , imgFile
* remap_dest
// The reamp dest image
192 wxString
wxColour_ToStr( const wxColour
& c
);
193 wxColour
wxColour_FromStr( const wxString
& s
);
196 void Image_Rescale_To_Fit( wxImage
& img
, size_t w
, size_t h
);
198 /**\internal*****************
199 * LOGGINGS facilities
200 * **************************
203 enum {MYLOG_ERROR
= 0, MYLOG_WARNING
= 1, MYLOG_INFO
= 2, MYLOG_DEBUG
= 3 };
206 extern wxLogWindow
* guiLog
;
208 //const int max_log_level = wxLOG_Debug;
210 void MyLog( int level
, const wxString
& source
, const wxString
& message
);
211 void ObjectsLog( int level
, int num_line
, const wxString
& message
);
212 void EmptyLogKeeper();
214 class myLog
: public wxLog
217 virtual void DoLog(wxLogLevel level
, const wxChar
*msg
, time_t timestamp
);
219 extern myLog
*logger
;
223 /**\internal******************************
224 * Validations facilities
225 * Note : implemented in parsing.cpp
226 * ***************************************
235 ob_validator( _V
* _arr_glob_constraint
);
236 void Validate( const ob_object
* it
, wxString
* tokens
, const size_t tokens_size
);
238 _V
* arr_glob_constraint
;
242 WX_DECLARE_HASH_MAP( wxString
, ob_validator
*, wxStringHash
, wxStringEqual
, hash_constraints
);
243 extern hash_constraints entity_constraints
;
244 extern hash_constraints models_constraints
;
245 extern hash_constraints levels_constraints
;
248 #endif /*OB_TOOLS_H_*/