2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2004-2008 Carlo Wood <carlo@alinoe.com>
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #if !defined(__WXPM__) && !defined(__WXMSW__) // Otherwise already defined in wx/defs.h.
30 #include <inttypes.h> // Do_not_auto_remove (old gcc)
31 typedef uint32_t COLORREF
;
33 #include "Types.h" // Do_not_auto_remove (Needed for windows compilation)
34 typedef unsigned long COLORREF
;
38 inline int G_BLEND(int a
, int percentage
)
40 int result
= a
* percentage
/ 100;
41 return (result
> 255) ? 255 : result
;
45 #if !defined(__WXMSW__)
46 inline COLORREF
RGB(int a
, int b
, int c
)
49 result
= (c
& 0xff) << 16;
50 result
|= (b
& 0xff) << 8;
56 inline int GetBValue(COLORREF rgb
)
58 return (rgb
>> 16) & 0xff;
62 inline int GetGValue(COLORREF rgb
)
64 return (rgb
>> 8) & 0xff;
68 inline int GetRValue(COLORREF rgb
)
76 inline COLORREF
DarkenColour(COLORREF rgb
, int level
)
78 return RGB(GetRValue(rgb
) / level
, GetGValue(rgb
) / level
, GetBValue(rgb
) / level
);
84 #include <wx/colour.h> // Needed for wxColour
86 inline wxColour
BLEND( wxColour colour
, int percentage
)
88 int red
= G_BLEND( colour
.Red(), percentage
);
89 int green
= G_BLEND( colour
.Green(), percentage
);
90 int blue
= G_BLEND( colour
.Blue(), percentage
);
92 return wxColour( red
, green
, blue
);
96 inline wxColour
WxColourFromCr(COLORREF cr
)
98 return wxColour(GetRValue(cr
),GetGValue(cr
),GetBValue(cr
));
102 inline COLORREF
CrFromWxColour(wxColour col
)
104 return RGB(col
.Red(), col
.Green(), col
.Blue());
107 #endif /* wxUSE_GUI */
109 #define SYSCOLOR(x) (wxSystemSettings::GetColour(x))
113 // File_checked_for_headers