1 /*******************************************************************************
2 *                         Goggles Music Manager                                *
3 ********************************************************************************
4 *           Copyright (C) 2006-2021 by Sander Jansen. All Rights Reserved      *
5 *                               ---                                            *
6 * This program is free software: you can redistribute it and/or modify         *
7 * it under the terms of the GNU General Public License as published by         *
8 * the Free Software Foundation, either version 3 of the License, or            *
9 * (at your option) any later version.                                          *
10 *                                                                              *
11 * This program is distributed in the hope that it will be useful,              *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of               *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                *
14 * GNU General Public License for more details.                                 *
15 *                                                                              *
16 * You should have received a copy of the GNU General Public License            *
17 * along with this program.  If not, see http://www.gnu.org/licenses.           *
18 ********************************************************************************/
19 #ifndef GMCOMMON_H
20 #define GMCOMMON_H
21 
22 #include "gmconfig.h"
23 
24 #include <new>
25 #include <fx.h>
26 
27 #define FOXVERSION ((FOX_LEVEL) + (FOX_MINOR*1000) + (FOX_MAJOR*100000))
28 #define FXVERSION(major,minor,release) ((release)+(minor*1000)+(major*100000))
29 
30 #ifdef HAVE_OPENGL
31 #include <epoxy/gl.h>
32 #include <epoxy/glx.h>
33 #include <fx3d.h>
34 #endif
35 
36 #include <FXArray.h>
37 #include <FXTextCodec.h>
38 #include <FXAutoPtr.h>
39 #include "fxext.h"
40 
41 /// for locale_t definition
42 #include <locale.h>
43 
44 #define TIME_MSEC(ms) (1000000LL*ms)
45 #define TIME_SEC(s) 	(1000000000LL*s)
46 #define TIME_MIN(m) 	TIME_SEC(60*m)
47 #define TIME_HOUR(h) 	TIME_MIN(60*h)
48 
49 #define NANOSECONDS_PER_SECOND  1000000000LL
50 #define NANOSECONDS_PER_MICROSECOND 1000LL
51 #define NANOSECONDS_PER_MILLISECOND 1000000LL
52 
53 constexpr FXTime operator"" _s(unsigned long long int value)
54 {
55   return value * NANOSECONDS_PER_SECOND;
56 }
57 
58 constexpr FXTime operator"" _ms(unsigned long long int value)
59 {
60   return value * NANOSECONDS_PER_MILLISECOND;
61 }
62 
63 
64 
65 //#define NO_FXGETTICKS 1
66 /// Some debugging macros
67 #if defined DEBUG && !defined(NO_FXGETTICKS)
68 #define GM_TICKS_START() FXTime end,start = fxgetticks();
69 #define GM_TICKS_END()  end = fxgetticks(); fxmessage("%20s:%20s:%15ld ticks.\n",__FILE__,__func__,end-start)
70 #define GM_DEBUG_PRINT(format, ...) fxmessage (format ,##__VA_ARGS__)
71 #else
72 #define GM_TICKS_START() ((void)0)
73 #define GM_TICKS_END() ((void)0)
74 #define GM_DEBUG_PRINT(arguments, ...) ((void)0)
75 #endif
76 
77 
78 typedef FXArray<FXString>     FXStringList;
79 typedef FXArray<FXint>        FXIntList;
80 typedef FXArray<FXlong>       FXLongList;
81 typedef FXAutoPtr<FXCursor>   FXCursorPtr;
82 typedef FXAutoPtr<FXIcon>     FXIconPtr;
83 typedef FXAutoPtr<FXImage>    FXImagePtr;
84 typedef FXAutoPtr<FXMenuPane> FXMenuPtr;
85 typedef FXAutoPtr<FXFont>     FXFontPtr;
86 typedef FXAutoPtr<FXPopup>    FXPopupPtr;
87 
88 extern const FXchar * fxtr(const FXchar *) FX_FORMAT(1);
89 
90 #define notr(x) x
91 #define fxtrformat(x) fxtr(x)
92 
93 // Best Image Scaler in FXImage
94 #define FOX_SCALE_BEST 2
95 
96 #endif
97 
98