wxExtend
Additional templates and function helpers for wxWidgets
Loading...
Searching...
No Matches
common.h
1/*
2 ​​​SPDX-License-Identifier: GPL-3.0-or-later
3 Copyright © 2015-2022 Amebis
4 Copyright © 2016 GÉANT
5*/
6
7#if !defined(__wxEXTEND_common_h__)
8#define __wxEXTEND_common_h__
9
12
16#define wxEXTEND_VERSION 0x01050300
17
18#define wxEXTEND_VERSION_MAJ 1
19#define wxEXTEND_VERSION_MIN 5
20#define wxEXTEND_VERSION_REV 3
21#define wxEXTEND_VERSION_BUILD 0
22
23#define wxEXTEND_VERSION_STR "1.5.3"
24#define wxEXTEND_BUILD_YEAR_STR "2022"
25
26#define wxExtendVersion "15"
27
28
29#if !defined(RC_INVOKED) && !defined(__midl)
30
31#define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h.
32#include <Windows.h>
33
34#include <codeanalysis\warnings.h>
35#ifndef WXWIDGETS_CODE_ANALYSIS_WARNINGS
36#define WXWIDGETS_CODE_ANALYSIS_WARNINGS ALL_CODE_ANALYSIS_WARNINGS 26812 26814
37#endif
38
39#pragma warning(push)
40#pragma warning(disable: WXWIDGETS_CODE_ANALYSIS_WARNINGS)
41#include <wx/config.h>
42#include <wx/debug.h>
43#include <wx/defs.h>
44#include <wx/intl.h>
45#pragma warning(pop)
46
50#ifndef WXEXTEND_API
51#if defined(WXMAKINGDLL_WXEXTEND)
52#define WXEXTEND_API __declspec(dllexport)
53#elif defined(WXUSINGDLL)
54#define WXEXTEND_API __declspec(dllimport)
55#else
56#define WXEXTEND_API
57#endif
58#endif
59
60
64#if wxDEBUG_LEVEL
65#define wxVERIFY_MSG(cond, msg) \
66 wxSTATEMENT_MACRO_BEGIN \
67 if ( !(cond) && wxTheAssertHandler && \
68 (wxOnAssert(__FILE__, __LINE__, __WXFUNCTION__, \
69 #cond, msg), wxTrapInAssert) ) \
70 { \
71 wxTrapInAssert = false; \
72 wxTrap(); \
73 } \
74 wxSTATEMENT_MACRO_END
75#endif
76
77
81#if wxDEBUG_LEVEL
82#define wxVERIFY(cond) wxVERIFY_MSG(cond, (const char*)NULL)
83#else
84#define wxVERIFY(cond) (cond)
85#endif
86
87
96{
97 ANIMATIONINFO ai = { sizeof(ai) };
98 wxCHECK(SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0), false);
99 return ai.iMinAnimate ? true : false;
100}
101
102
115inline bool wxModifyStyleEx(_In_ WXHWND hWnd, _In_ DWORD dwRemove, _In_ DWORD dwAdd, _In_ UINT nFlags = 0)
116{
117 wxASSERT(IsWindow(hWnd));
118
119 const DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
120 const DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
121 if(dwStyle == dwNewStyle)
122 return false;
123
124 SetWindowLong(hWnd, GWL_EXSTYLE, dwNewStyle);
125 if(nFlags != 0)
126 SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
127
128 return true;
129}
130
131
145#pragma warning(suppress: 26812) // wxLanguage is unscoped
146inline bool wxInitializeLocale(wxLocale &locale, wxLanguage *language = NULL)
147{
148 // Read language from configuration.
149 wxLanguage lang_code = wxLANGUAGE_DEFAULT;
150 wxString lang;
151 if (wxConfigBase::Get()->Read(wxT("Language"), &lang)) {
152 const wxLanguageInfo *lang_info = wxLocale::FindLanguageInfo(lang);
153 lang_code = lang_info ? (wxLanguage)lang_info->Language : wxLANGUAGE_DEFAULT;
154 }
155
156 if (language)
157 *language = lang_code;
158
159 if (wxLocale::IsAvailable(lang_code)) {
160 // Language is "available". Well... Known actually.
161 wxString sPath;
162 if (wxConfigBase::Get()->Read(wxT("LocalizationRepositoryPath"), &sPath))
163 locale.AddCatalogLookupPathPrefix(sPath);
164 return locale.Init(lang_code);
165 }
166
167 return false;
168}
169
170#endif // !defined(RC_INVOKED) && !defined(__midl)
171
173
174#endif // !defined(__wxEXTEND_common_h__)
bool wxGetDoWndAnimation()
Returns whether windows animation is enabled.
Definition common.h:95
bool wxModifyStyleEx(WXHWND hWnd, DWORD dwRemove, DWORD dwAdd, UINT nFlags=0)
Modifies window extended style.
Definition common.h:115
bool wxInitializeLocale(wxLocale &locale, wxLanguage *language=NULL)
Inizializes wxWidgets localization scheme.
Definition common.h:146