Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/shared/shared.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #ifndef _SHARED_DLL__SHARED_H_ | |
| 2 #define _SHARED_DLL__SHARED_H_ | |
| 3 | |
| 4 #include "../../pfc/pfc.h" | |
| 5 | |
| 6 #include <assert.h> | |
| 7 | |
| 8 // Global flag - whether it's OK to leak static objects as they'll be released anyway by process death | |
| 9 #define FB2K_LEAK_STATIC_OBJECTS PFC_LEAK_STATIC_OBJECTS | |
| 10 | |
| 11 #define FB2K_TARGET_MICROSOFT_STORE 0 | |
| 12 | |
| 13 #if defined(_WIN32) && ! FB2K_TARGET_MICROSOFT_STORE | |
| 14 #define FB2K_SUPPORT_CRASH_LOGS 1 | |
| 15 #endif | |
| 16 #ifndef FB2K_SUPPORT_CRASH_LOGS | |
| 17 #define FB2K_SUPPORT_CRASH_LOGS 0 | |
| 18 #endif | |
| 19 | |
| 20 #include <signal.h> | |
| 21 | |
| 22 | |
| 23 #ifdef _WIN32 | |
| 24 #include <windows.h> | |
| 25 #include <ddeml.h> | |
| 26 #include <commctrl.h> | |
| 27 #include <uxtheme.h> | |
| 28 //#include <tmschema.h> | |
| 29 #include <vssym32.h> | |
| 30 | |
| 31 #define SHARED_API /*NOTHROW*/ __stdcall | |
| 32 | |
| 33 #ifndef SHARED_EXPORTS | |
| 34 #define SHARED_EXPORT __declspec(dllimport) SHARED_API | |
| 35 #else | |
| 36 #define SHARED_EXPORT __declspec(dllexport) SHARED_API | |
| 37 #endif | |
| 38 | |
| 39 #else // _WIN32 | |
| 40 | |
| 41 #define SHARED_API | |
| 42 #define SHARED_EXPORT | |
| 43 | |
| 44 #endif // _WIN32 | |
| 45 | |
| 46 extern "C" { | |
| 47 | |
| 48 #ifdef _WIN32 | |
| 49 typedef HANDLE uSortString_t; | |
| 50 #else | |
| 51 typedef void* uSortString_t; | |
| 52 #endif | |
| 53 | |
| 54 // Implemented for non-Windows as well | |
| 55 void SHARED_EXPORT uOutputDebugString(const char * msg); | |
| 56 unsigned SHARED_EXPORT uCharLower(unsigned c); | |
| 57 unsigned SHARED_EXPORT uCharUpper(unsigned c); | |
| 58 int SHARED_EXPORT uStringCompare(const char * elem1, const char * elem2); | |
| 59 int SHARED_EXPORT uCharCompare(t_uint32 p_char1,t_uint32 p_char2); | |
| 60 uSortString_t SHARED_EXPORT uSortStringCreate(const char * src); | |
| 61 int SHARED_EXPORT uSortStringCompare(uSortString_t string1,uSortString_t string2); | |
| 62 int SHARED_EXPORT uSortStringCompareEx(uSortString_t string1,uSortString_t string2,uint32_t flags);//flags - see win32 CompareString | |
| 63 int SHARED_EXPORT uSortPathCompare(uSortString_t string1,uSortString_t string2); | |
| 64 void SHARED_EXPORT uSortStringFree(uSortString_t string); | |
| 65 pfc::eventHandle_t SHARED_EXPORT GetInfiniteWaitEvent(); | |
| 66 } // extern "C" | |
| 67 | |
| 68 #ifdef _WIN32 | |
| 69 extern "C" { | |
| 70 LRESULT SHARED_EXPORT uSendMessageText(HWND wnd,UINT msg,WPARAM wp,const char * text); | |
| 71 LRESULT SHARED_EXPORT uSendDlgItemMessageText(HWND wnd,UINT id,UINT msg,WPARAM wp,const char * text); | |
| 72 BOOL SHARED_EXPORT uGetWindowText(HWND wnd,pfc::string_base & out); | |
| 73 BOOL SHARED_EXPORT uSetWindowText(HWND wnd,const char * p_text); | |
| 74 BOOL SHARED_EXPORT uSetWindowTextEx(HWND wnd,const char * p_text,size_t p_text_length); | |
| 75 BOOL SHARED_EXPORT uGetDlgItemText(HWND wnd,UINT id,pfc::string_base & out); | |
| 76 BOOL SHARED_EXPORT uSetDlgItemText(HWND wnd,UINT id,const char * p_text); | |
| 77 BOOL SHARED_EXPORT uSetDlgItemTextEx(HWND wnd,UINT id,const char * p_text,size_t p_text_length); | |
| 78 BOOL SHARED_EXPORT uBrowseForFolder(HWND parent,const char * title,pfc::string_base & out); | |
| 79 BOOL SHARED_EXPORT uBrowseForFolderWithFile(HWND parent,const char * title,pfc::string_base & out,const char * p_file_to_find); | |
| 80 int SHARED_EXPORT uMessageBox(HWND wnd,const char * text,const char * caption,UINT type); | |
| 81 BOOL SHARED_EXPORT uAppendMenu(HMENU menu,UINT flags,UINT_PTR id,const char * content); | |
| 82 BOOL SHARED_EXPORT uInsertMenu(HMENU menu,UINT position,UINT flags,UINT_PTR id,const char * content); | |
| 83 int SHARED_EXPORT uStringCompare_ConvertNumbers(const char * elem1,const char * elem2); | |
| 84 HINSTANCE SHARED_EXPORT uLoadLibrary(const char * name); | |
| 85 HANDLE SHARED_EXPORT uCreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes,BOOL bManualReset,BOOL bInitialState, const char * lpName); | |
| 86 DWORD SHARED_EXPORT uGetModuleFileName(HMODULE hMod,pfc::string_base & out); | |
| 87 BOOL SHARED_EXPORT uSetClipboardString(const char * ptr); | |
| 88 BOOL SHARED_EXPORT uGetClipboardString(pfc::string_base & out); | |
| 89 BOOL SHARED_EXPORT uSetClipboardRawData(UINT format,const void * ptr,t_size size);//does not empty the clipboard | |
| 90 BOOL SHARED_EXPORT uGetClassName(HWND wnd,pfc::string_base & out); | |
| 91 t_size SHARED_EXPORT uCharLength(const char * src); | |
| 92 #ifdef DragQueryFile // don't declare if relevant Windows #include has been omitted, breaks on HDROP | |
| 93 BOOL SHARED_EXPORT uDragQueryFile(HDROP hDrop,UINT idx,pfc::string_base & out); | |
| 94 UINT SHARED_EXPORT uDragQueryFileCount(HDROP hDrop); | |
| 95 #endif | |
| 96 BOOL SHARED_EXPORT uGetTextExtentPoint32(HDC dc,const char * text,UINT cb,LPSIZE size);//note, cb is number of bytes, not actual unicode characters in the string (read: plain strlen() will do) | |
| 97 BOOL SHARED_EXPORT uExtTextOut(HDC dc,int x,int y,UINT flags,const RECT * rect,const char * text,UINT cb,const int * lpdx); | |
| 98 BOOL SHARED_EXPORT uTextOutColors(HDC dc,const char * src,UINT len,int x,int y,const RECT * clip,BOOL is_selected,DWORD default_color); | |
| 99 BOOL SHARED_EXPORT uTextOutColorsTabbed(HDC dc,const char * src,UINT src_len,const RECT * item,int border,const RECT * clip,BOOL selected,DWORD default_color,BOOL use_columns); | |
| 100 UINT SHARED_EXPORT uGetTextHeight(HDC dc); | |
| 101 UINT SHARED_EXPORT uGetFontHeight(HFONT font); | |
| 102 BOOL SHARED_EXPORT uChooseColor(DWORD * p_color,HWND parent,DWORD * p_custom_colors); | |
| 103 HCURSOR SHARED_EXPORT uLoadCursor(HINSTANCE hIns,const char * name); | |
| 104 HICON SHARED_EXPORT uLoadIcon(HINSTANCE hIns,const char * name); | |
| 105 HMENU SHARED_EXPORT uLoadMenu(HINSTANCE hIns,const char * name); | |
| 106 BOOL SHARED_EXPORT uGetEnvironmentVariable(const char * name,pfc::string_base & out); | |
| 107 HMODULE SHARED_EXPORT uGetModuleHandle(const char * name); | |
| 108 UINT SHARED_EXPORT uRegisterWindowMessage(const char * name); | |
| 109 BOOL SHARED_EXPORT uMoveFile(const char * src,const char * dst); | |
| 110 BOOL SHARED_EXPORT uDeleteFile(const char * fn); | |
| 111 DWORD SHARED_EXPORT uGetFileAttributes(const char * fn); | |
| 112 BOOL SHARED_EXPORT uFileExists(const char * fn); | |
| 113 BOOL SHARED_EXPORT uRemoveDirectory(const char * fn); | |
| 114 HANDLE SHARED_EXPORT uCreateFile(const char * p_path,DWORD p_access,DWORD p_sharemode,LPSECURITY_ATTRIBUTES p_security_attributes,DWORD p_createmode,DWORD p_flags,HANDLE p_template); | |
| 115 HANDLE SHARED_EXPORT uCreateFileMapping(HANDLE hFile,LPSECURITY_ATTRIBUTES lpFileMappingAttributes,DWORD flProtect,DWORD dwMaximumSizeHigh,DWORD dwMaximumSizeLow,const char * lpName); | |
| 116 BOOL SHARED_EXPORT uCreateDirectory(const char * fn,LPSECURITY_ATTRIBUTES blah); | |
| 117 HANDLE SHARED_EXPORT uCreateMutex(LPSECURITY_ATTRIBUTES blah,BOOL bInitialOwner,const char * name); | |
| 118 BOOL SHARED_EXPORT uGetLongPathName(const char * name,pfc::string_base & out);//may just fail to work on old windows versions, present on win98/win2k+ | |
| 119 BOOL SHARED_EXPORT uGetFullPathName(const char * name,pfc::string_base & out); | |
| 120 BOOL SHARED_EXPORT uSearchPath(const char * path, const char * filename, const char * extension, pfc::string_base & p_out); | |
| 121 BOOL SHARED_EXPORT uFixPathCaps(const char * path,pfc::string_base & p_out); | |
| 122 //BOOL SHARED_EXPORT uFixPathCapsQuick(const char * path,pfc::string_base & p_out); | |
| 123 void SHARED_EXPORT uGetCommandLine(pfc::string_base & out); | |
| 124 BOOL SHARED_EXPORT uGetTempPath(pfc::string_base & out); | |
| 125 BOOL SHARED_EXPORT uGetTempFileName(const char * path_name,const char * prefix,UINT unique,pfc::string_base & out); | |
| 126 | |
| 127 //! Win32 GetOpenFileName/GetSaveFileName wrapper. \n | |
| 128 //! Extension mask uses | instead of \0 for delimiter; "Text files|*.txt|foo files|*.foo" | |
| 129 BOOL SHARED_EXPORT uGetOpenFileName(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory,pfc::string_base & p_filename,BOOL b_save); | |
| 130 | |
| 131 HANDLE SHARED_EXPORT uLoadImage(HINSTANCE hIns,const char * name,UINT type,int x,int y,UINT flags); | |
| 132 UINT SHARED_EXPORT uRegisterClipboardFormat(const char * name); | |
| 133 BOOL SHARED_EXPORT uGetClipboardFormatName(UINT format,pfc::string_base & out); | |
| 134 BOOL SHARED_EXPORT uFormatSystemErrorMessage(pfc::string_base & p_out,DWORD p_code); | |
| 135 | |
| 136 // New in 1.1.12 | |
| 137 HANDLE SHARED_EXPORT CreateFileAbortable( __in LPCWSTR lpFileName, | |
| 138 __in DWORD dwDesiredAccess, | |
| 139 __in DWORD dwShareMode, | |
| 140 __in_opt LPSECURITY_ATTRIBUTES lpSecurityAttributes, | |
| 141 __in DWORD dwCreationDisposition, | |
| 142 __in DWORD dwFlagsAndAttributes, | |
| 143 // Template file handle NOT supported. | |
| 144 __in_opt HANDLE hAborter | |
| 145 ); | |
| 146 | |
| 147 | |
| 148 int SHARED_EXPORT uCompareString(DWORD flags,const char * str1,size_t len1,const char * str2,size_t len2); | |
| 149 | |
| 150 class NOVTABLE uGetOpenFileNameMultiResult : public pfc::list_base_const_t<const char*> | |
| 151 { | |
| 152 public: | |
| 153 inline t_size GetCount() {return get_count();} | |
| 154 inline const char * GetFileName(t_size index) {return get_item(index);} | |
| 155 virtual ~uGetOpenFileNameMultiResult() {} | |
| 156 }; | |
| 157 | |
| 158 typedef uGetOpenFileNameMultiResult * puGetOpenFileNameMultiResult; | |
| 159 | |
| 160 puGetOpenFileNameMultiResult SHARED_EXPORT uGetOpenFileNameMulti(HWND parent,const char * p_ext_mask,unsigned def_ext_mask,const char * p_def_ext,const char * p_title,const char * p_directory); | |
| 161 | |
| 162 // new in fb2k 1.1.1 | |
| 163 puGetOpenFileNameMultiResult SHARED_EXPORT uBrowseForFolderEx(HWND parent,const char * title, const char * initPath); | |
| 164 puGetOpenFileNameMultiResult SHARED_EXPORT uEvalKnownFolder(const GUID& id); | |
| 165 | |
| 166 | |
| 167 class NOVTABLE uFindFile | |
| 168 { | |
| 169 protected: | |
| 170 uFindFile() {} | |
| 171 public: | |
| 172 virtual BOOL FindNext()=0; | |
| 173 virtual const char * GetFileName()=0; | |
| 174 virtual t_uint64 GetFileSize()=0; | |
| 175 virtual DWORD GetAttributes()=0; | |
| 176 virtual FILETIME GetCreationTime()=0; | |
| 177 virtual FILETIME GetLastAccessTime()=0; | |
| 178 virtual FILETIME GetLastWriteTime()=0; | |
| 179 virtual ~uFindFile() {}; | |
| 180 inline bool IsDirectory() {return (GetAttributes() & FILE_ATTRIBUTE_DIRECTORY) ? true : false;} | |
| 181 }; | |
| 182 | |
| 183 typedef uFindFile * puFindFile; | |
| 184 | |
| 185 puFindFile SHARED_EXPORT uFindFirstFile(const char * path); | |
| 186 | |
| 187 HINSTANCE SHARED_EXPORT uShellExecute(HWND wnd,const char * oper,const char * file,const char * params,const char * dir,int cmd); | |
| 188 HWND SHARED_EXPORT uCreateStatusWindow(LONG style,const char * text,HWND parent,UINT id); | |
| 189 | |
| 190 BOOL SHARED_EXPORT uShellNotifyIcon(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip); | |
| 191 BOOL SHARED_EXPORT uShellNotifyIconEx(DWORD dwMessage,HWND wnd,UINT id,UINT callbackmsg,HICON icon,const char * tip,const char * balloon_title,const char * balloon_msg); | |
| 192 | |
| 193 HWND SHARED_EXPORT uCreateWindowEx(DWORD dwExStyle,const char * lpClassName,const char * lpWindowName,DWORD dwStyle,int x,int y,int nWidth,int nHeight,HWND hWndParent,HMENU hMenu,HINSTANCE hInstance,LPVOID lpParam); | |
| 194 | |
| 195 BOOL SHARED_EXPORT uGetSystemDirectory(pfc::string_base & out); | |
| 196 BOOL SHARED_EXPORT uGetWindowsDirectory(pfc::string_base & out); | |
| 197 BOOL SHARED_EXPORT uSetCurrentDirectory(const char * path); | |
| 198 BOOL SHARED_EXPORT uGetCurrentDirectory(pfc::string_base & out); | |
| 199 BOOL SHARED_EXPORT uExpandEnvironmentStrings(const char * src,pfc::string_base & out); | |
| 200 BOOL SHARED_EXPORT uGetUserName(pfc::string_base & out); | |
| 201 BOOL SHARED_EXPORT uGetShortPathName(const char * src,pfc::string_base & out); | |
| 202 | |
| 203 HSZ SHARED_EXPORT uDdeCreateStringHandle(DWORD ins,const char * src); | |
| 204 BOOL SHARED_EXPORT uDdeQueryString(DWORD ins,HSZ hsz,pfc::string_base & out); | |
| 205 UINT SHARED_EXPORT uDdeInitialize(LPDWORD pidInst,PFNCALLBACK pfnCallback,DWORD afCmd,DWORD ulRes); | |
| 206 BOOL SHARED_EXPORT uDdeAccessData_Text(HDDEDATA data,pfc::string_base & out); | |
| 207 | |
| 208 HIMAGELIST SHARED_EXPORT uImageList_LoadImage(HINSTANCE hi, const char * lpbmp, int cx, int cGrow, COLORREF crMask, UINT uType, UINT uFlags); | |
| 209 | |
| 210 #define uDdeFreeStringHandle DdeFreeStringHandle | |
| 211 #define uDdeCmpStringHandles DdeCmpStringHandles | |
| 212 #define uDdeKeepStringHandle DdeKeepStringHandle | |
| 213 #define uDdeUninitialize DdeUninitialize | |
| 214 #define uDdeNameService DdeNameService | |
| 215 #define uDdeFreeDataHandle DdeFreeDataHandle | |
| 216 | |
| 217 | |
| 218 typedef TVINSERTSTRUCTA uTVINSERTSTRUCT; | |
| 219 | |
| 220 HTREEITEM SHARED_EXPORT uTreeView_InsertItem(HWND wnd,const uTVINSERTSTRUCT * param); | |
| 221 LPARAM SHARED_EXPORT uTreeView_GetUserData(HWND wnd,HTREEITEM item); | |
| 222 bool SHARED_EXPORT uTreeView_GetText(HWND wnd,HTREEITEM item,pfc::string_base & out); | |
| 223 | |
| 224 #define uSetWindowsHookEx SetWindowsHookEx | |
| 225 #define uUnhookWindowsHookEx UnhookWindowsHookEx | |
| 226 #define uCallNextHookEx CallNextHookEx | |
| 227 | |
| 228 typedef TCITEMA uTCITEM; | |
| 229 int SHARED_EXPORT uTabCtrl_InsertItem(HWND wnd,t_size idx,const uTCITEM * item); | |
| 230 int SHARED_EXPORT uTabCtrl_SetItem(HWND wnd,t_size idx,const uTCITEM * item); | |
| 231 | |
| 232 int SHARED_EXPORT uGetKeyNameText(LONG lparam,pfc::string_base & out); | |
| 233 | |
| 234 void SHARED_EXPORT uFixAmpersandChars(const char * src,pfc::string_base & out);//for system tray icon | |
| 235 void SHARED_EXPORT uFixAmpersandChars_v2(const char * src,pfc::string_base & out);//for other controls | |
| 236 | |
| 237 #if FB2K_SUPPORT_CRASH_LOGS | |
| 238 t_size SHARED_EXPORT uPrintCrashInfo(LPEXCEPTION_POINTERS param,const char * extrainfo,char * out); | |
| 239 enum {uPrintCrashInfo_max_length = 1024}; | |
| 240 | |
| 241 void SHARED_EXPORT uPrintCrashInfo_Init(const char * name);//called only by the exe on startup | |
| 242 void SHARED_EXPORT uPrintCrashInfo_SetComponentList(const char * p_info);//called only by the exe on startup | |
| 243 void SHARED_EXPORT uPrintCrashInfo_AddEnvironmentInfo(const char * p_info);//called only by the exe on startup | |
| 244 void SHARED_EXPORT uPrintCrashInfo_SetDumpPath(const char * name);//called only by the exe on startup | |
| 245 | |
| 246 | |
| 247 #endif // FB2K_SUPPORT_CRASH_LOGS | |
| 248 | |
| 249 void SHARED_EXPORT uDumpCrashInfo(LPEXCEPTION_POINTERS param); | |
| 250 | |
| 251 BOOL SHARED_EXPORT uListBox_GetText(HWND listbox,UINT index,pfc::string_base & out); | |
| 252 | |
| 253 void SHARED_EXPORT uPrintfV(pfc::string_base & out,const char * fmt,va_list arglist); | |
| 254 static inline void uPrintf(pfc::string_base & out,const char * fmt,...) {va_list list;va_start(list,fmt);uPrintfV(out,fmt,list);va_end(list);} | |
| 255 | |
| 256 | |
| 257 class NOVTABLE uResource | |
| 258 { | |
| 259 public: | |
| 260 virtual const void * GetPointer() = 0; | |
| 261 virtual unsigned GetSize() = 0; | |
| 262 virtual ~uResource() {} | |
| 263 }; | |
| 264 | |
| 265 typedef uResource* puResource; | |
| 266 | |
| 267 puResource SHARED_EXPORT uLoadResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); | |
| 268 puResource SHARED_EXPORT LoadResourceEx(HMODULE hMod,const TCHAR * name,const TCHAR * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); | |
| 269 HRSRC SHARED_EXPORT uFindResource(HMODULE hMod,const char * name,const char * type,WORD wLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) ); | |
| 270 | |
| 271 BOOL SHARED_EXPORT uLoadString(HINSTANCE ins,UINT id,pfc::string_base & out); | |
| 272 | |
| 273 BOOL SHARED_EXPORT uGetMenuString(HMENU menu,UINT id,pfc::string_base & out,UINT flag); | |
| 274 BOOL SHARED_EXPORT uModifyMenu(HMENU menu,UINT id,UINT flags,UINT newitem,const char * data); | |
| 275 UINT SHARED_EXPORT uGetMenuItemType(HMENU menu,UINT position); | |
| 276 | |
| 277 | |
| 278 // New in 1.3.4 | |
| 279 // Load a system library safely - forcibly look in system directories, not elsewhere. | |
| 280 HMODULE SHARED_EXPORT LoadSystemLibrary(const TCHAR * name); | |
| 281 | |
| 282 void SHARED_EXPORT uPrintCrashInfo_OnEvent(const char * message, t_size length); | |
| 283 void SHARED_EXPORT uPrintCrashInfo_StartLogging(const char * path); | |
| 284 | |
| 285 }//extern "C" | |
| 286 | |
| 287 | |
| 288 inline char * uCharNext(char * src) {return src+uCharLength(src);} | |
| 289 inline const char * uCharNext(const char * src) {return src+uCharLength(src);} | |
| 290 | |
| 291 | |
| 292 inline pfc::string uGetWindowText(HWND wnd) { | |
| 293 pfc::string8 temp; | |
| 294 if (!uGetWindowText(wnd,temp)) temp = ""; | |
| 295 return temp; | |
| 296 } | |
| 297 | |
| 298 inline pfc::string uGetDlgItemText(HWND wnd,UINT id) { | |
| 299 pfc::string8 temp; | |
| 300 if (!uGetDlgItemText(wnd,id,temp)) temp = ""; | |
| 301 return temp; | |
| 302 } | |
| 303 | |
| 304 #define uMAKEINTRESOURCE(x) ((const char*)LOWORD(x)) | |
| 305 | |
| 306 //other | |
| 307 | |
| 308 #define uIsDialogMessage IsDialogMessage | |
| 309 #define uGetMessage GetMessage | |
| 310 #define uPeekMessage PeekMessage | |
| 311 #define uDispatchMessage DispatchMessage | |
| 312 | |
| 313 #define uCallWindowProc CallWindowProc | |
| 314 #define uDefWindowProc DefWindowProc | |
| 315 #define uGetWindowLong GetWindowLong | |
| 316 #define uSetWindowLong SetWindowLong | |
| 317 | |
| 318 #define uEndDialog EndDialog | |
| 319 #define uDestroyWindow DestroyWindow | |
| 320 #define uGetDlgItem GetDlgItem | |
| 321 #define uEnableWindow EnableWindow | |
| 322 #define uGetDlgItemInt GetDlgItemInt | |
| 323 #define uSetDlgItemInt SetDlgItemInt | |
| 324 | |
| 325 #define uSendMessage SendMessage | |
| 326 #define uSendDlgItemMessage SendDlgItemMessage | |
| 327 #define uSendMessageTimeout SendMessageTimeout | |
| 328 #define uSendNotifyMessage SendNotifyMessage | |
| 329 #define uSendMessageCallback SendMessageCallback | |
| 330 #define uPostMessage PostMessage | |
| 331 #define uPostThreadMessage PostThreadMessage | |
| 332 | |
| 333 | |
| 334 class uStringPrintf | |
| 335 { | |
| 336 public: | |
| 337 inline explicit uStringPrintf(const char * fmt,...) | |
| 338 { | |
| 339 va_list list; | |
| 340 va_start(list,fmt); | |
| 341 uPrintfV(m_data,fmt,list); | |
| 342 va_end(list); | |
| 343 } | |
| 344 inline operator const char * () const {return m_data.get_ptr();} | |
| 345 inline t_size length() const {return m_data.length();} | |
| 346 inline bool is_empty() const {return length() == 0;} | |
| 347 inline const char * get_ptr() const {return m_data.get_ptr();} | |
| 348 const char * toString() const {return get_ptr();} | |
| 349 private: | |
| 350 pfc::string8_fastalloc m_data; | |
| 351 }; | |
| 352 | |
| 353 inline LRESULT uButton_SetCheck(HWND wnd,UINT id,bool state) {return uSendDlgItemMessage(wnd,id,BM_SETCHECK,state ? BST_CHECKED : BST_UNCHECKED,0); } | |
| 354 inline bool uButton_GetCheck(HWND wnd,UINT id) {return uSendDlgItemMessage(wnd,id,BM_GETCHECK,0,0) == BST_CHECKED;} | |
| 355 | |
| 356 inline BOOL uGetLongPathNameEx(const char * name,pfc::string_base & out) | |
| 357 { | |
| 358 if (uGetLongPathName(name,out)) return TRUE; | |
| 359 return uGetFullPathName(name,out); | |
| 360 } | |
| 361 | |
| 362 #endif // _WIN32 | |
| 363 | |
| 364 extern "C" { | |
| 365 int SHARED_EXPORT stricmp_utf8(const char * p1,const char * p2) throw(); | |
| 366 int SHARED_EXPORT stricmp_utf8_ex(const char * p1,t_size len1,const char * p2,t_size len2) throw(); | |
| 367 int SHARED_EXPORT stricmp_utf8_stringtoblock(const char * p1,const char * p2,t_size p2_bytes) throw(); | |
| 368 int SHARED_EXPORT stricmp_utf8_partial(const char * p1,const char * p2,t_size num = ~0) throw(); | |
| 369 int SHARED_EXPORT stricmp_utf8_max(const char * p1,const char * p2,t_size p1_bytes) throw(); | |
| 370 t_size SHARED_EXPORT uReplaceStringAdd(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens); | |
| 371 t_size SHARED_EXPORT uReplaceCharAdd(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens); | |
| 372 //all lengths in uReplaceString functions are optional, set to -1 if parameters is a simple null-terminated string | |
| 373 void SHARED_EXPORT uAddStringLower(pfc::string_base & out,const char * src,t_size len = ~0); | |
| 374 void SHARED_EXPORT uAddStringUpper(pfc::string_base & out,const char * src,t_size len = ~0); | |
| 375 } | |
| 376 | |
| 377 class comparator_stricmp_utf8 { | |
| 378 public: | |
| 379 static int compare(const char * p_string1,const char * p_string2) throw() {return stricmp_utf8(p_string1,p_string2);} | |
| 380 }; | |
| 381 | |
| 382 inline void uStringLower(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringLower(out,src,len);} | |
| 383 inline void uStringUpper(pfc::string_base & out,const char * src,t_size len = ~0) {out.reset();uAddStringUpper(out,src,len);} | |
| 384 | |
| 385 inline t_size uReplaceString(pfc::string_base & out,const char * src,t_size src_len,const char * s1,t_size len1,const char * s2,t_size len2,bool casesens) | |
| 386 { | |
| 387 out.reset(); | |
| 388 return uReplaceStringAdd(out,src,src_len,s1,len1,s2,len2,casesens); | |
| 389 } | |
| 390 | |
| 391 inline t_size uReplaceChar(pfc::string_base & out,const char * src,t_size src_len,unsigned c1,unsigned c2,bool casesens) | |
| 392 { | |
| 393 out.reset(); | |
| 394 return uReplaceCharAdd(out,src,src_len,c1,c2,casesens); | |
| 395 } | |
| 396 | |
| 397 class string_lower | |
| 398 { | |
| 399 public: | |
| 400 explicit string_lower(const char * ptr,t_size p_count = ~0) {uAddStringLower(m_data,ptr,p_count);} | |
| 401 inline operator const char * () const {return m_data.get_ptr();} | |
| 402 inline t_size length() const {return m_data.length();} | |
| 403 inline bool is_empty() const {return length() == 0;} | |
| 404 inline const char * get_ptr() const {return m_data.get_ptr();} | |
| 405 private: | |
| 406 pfc::string8 m_data; | |
| 407 }; | |
| 408 | |
| 409 class string_upper | |
| 410 { | |
| 411 public: | |
| 412 explicit string_upper(const char * ptr,t_size p_count = ~0) {uAddStringUpper(m_data,ptr,p_count);} | |
| 413 inline operator const char * () const {return m_data.get_ptr();} | |
| 414 inline t_size length() const {return m_data.length();} | |
| 415 inline bool is_empty() const {return length() == 0;} | |
| 416 inline const char * get_ptr() const {return m_data.get_ptr();} | |
| 417 private: | |
| 418 pfc::string8 m_data; | |
| 419 }; | |
| 420 | |
| 421 #ifdef _WIN32 | |
| 422 struct t_font_description | |
| 423 { | |
| 424 enum | |
| 425 { | |
| 426 m_facename_length = LF_FACESIZE*2, | |
| 427 m_height_dpi = 480, | |
| 428 }; | |
| 429 | |
| 430 t_uint32 m_height; | |
| 431 t_uint32 m_weight; | |
| 432 t_uint8 m_italic; | |
| 433 t_uint8 m_charset; | |
| 434 char m_facename[m_facename_length]; | |
| 435 | |
| 436 bool operator==(const t_font_description & other) const {return g_equals(*this, other);} | |
| 437 bool operator!=(const t_font_description & other) const {return !g_equals(*this, other);} | |
| 438 | |
| 439 static bool g_equals(const t_font_description & v1, const t_font_description & v2) { | |
| 440 return v1.m_height == v2.m_height && v1.m_weight == v2.m_weight && v1.m_italic == v2.m_italic && v1.m_charset == v2.m_charset && pfc::strcmp_ex(v1.m_facename, m_facename_length, v2.m_facename, m_facename_length) == 0; | |
| 441 } | |
| 442 | |
| 443 HFONT SHARED_EXPORT create() const; | |
| 444 bool SHARED_EXPORT popup_dialog(HWND p_parent); | |
| 445 void SHARED_EXPORT from_font(HFONT p_font); | |
| 446 static t_font_description SHARED_EXPORT g_from_font(HFONT p_font); | |
| 447 static t_font_description SHARED_EXPORT g_from_logfont(LOGFONT const & lf); | |
| 448 static t_font_description SHARED_EXPORT g_from_system(int id = TMT_MENUFONT); | |
| 449 | |
| 450 template<typename t_stream,typename t_abort> void to_stream(t_stream p_stream,t_abort & p_abort) const; | |
| 451 template<typename t_stream,typename t_abort> void from_stream(t_stream p_stream,t_abort & p_abort); | |
| 452 }; | |
| 453 | |
| 454 /* relevant types not yet defined here */ template<typename t_stream,typename t_abort> void t_font_description::to_stream(t_stream p_stream,t_abort & p_abort) const { | |
| 455 p_stream->write_lendian_t(m_height,p_abort); | |
| 456 p_stream->write_lendian_t(m_weight,p_abort); | |
| 457 p_stream->write_lendian_t(m_italic,p_abort); | |
| 458 p_stream->write_lendian_t(m_charset,p_abort); | |
| 459 p_stream->write_string(m_facename,PFC_TABSIZE(m_facename),p_abort); | |
| 460 } | |
| 461 | |
| 462 /* relevant types not yet defined here */ template<typename t_stream,typename t_abort> void t_font_description::from_stream(t_stream p_stream,t_abort & p_abort) { | |
| 463 p_stream->read_lendian_t(m_height,p_abort); | |
| 464 p_stream->read_lendian_t(m_weight,p_abort); | |
| 465 p_stream->read_lendian_t(m_italic,p_abort); | |
| 466 p_stream->read_lendian_t(m_charset,p_abort); | |
| 467 pfc::string8 temp; | |
| 468 p_stream->read_string(temp,p_abort); | |
| 469 strncpy_s(m_facename,temp,PFC_TABSIZE(m_facename)); | |
| 470 } | |
| 471 | |
| 472 | |
| 473 struct t_modal_dialog_entry | |
| 474 { | |
| 475 HWND m_wnd_to_poke; | |
| 476 bool m_in_use; | |
| 477 }; | |
| 478 | |
| 479 extern "C" { | |
| 480 void SHARED_EXPORT ModalDialog_Switch(t_modal_dialog_entry & p_entry); | |
| 481 void SHARED_EXPORT ModalDialog_PokeExisting(); | |
| 482 bool SHARED_EXPORT ModalDialog_CanCreateNew(); | |
| 483 | |
| 484 HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd); | |
| 485 void SHARED_EXPORT PokeWindow(HWND p_wnd); | |
| 486 }; | |
| 487 | |
| 488 inline bool ModalDialogPrologue() { | |
| 489 bool rv = ModalDialog_CanCreateNew(); | |
| 490 if (!rv) ModalDialog_PokeExisting(); | |
| 491 return rv; | |
| 492 } | |
| 493 | |
| 494 //! The purpose of modal_dialog_scope is to help to avoid the modal dialog recursion problem. Current toplevel modal dialog handle is stored globally, so when creation of a new modal dialog is blocked, it can be activated to indicate the reason for the task being blocked. | |
| 495 class modal_dialog_scope { | |
| 496 public: | |
| 497 //! This constructor initializes the modal dialog scope with specified dialog handle. | |
| 498 inline modal_dialog_scope(HWND p_wnd) throw() : m_initialized(false) {initialize(p_wnd);} | |
| 499 //! This constructor leaves the scope uninitialized (you can call initialize() later with your window handle). | |
| 500 inline modal_dialog_scope() throw() : m_initialized(false) {} | |
| 501 inline ~modal_dialog_scope() throw() {deinitialize();} | |
| 502 | |
| 503 //! Returns whether creation of a new modal dialog is allowed (false when there's another one active).\n | |
| 504 //! NOTE: when calling context is already inside a modal dialog that you own, you should not be checking this before creating a new modal dialog. | |
| 505 inline static bool can_create() throw(){return ModalDialog_CanCreateNew();} | |
| 506 //! Activates the top-level modal dialog existing, if one exists. | |
| 507 inline static void poke_existing() throw() {ModalDialog_PokeExisting();} | |
| 508 | |
| 509 //! Initializes the scope with specified window handle. | |
| 510 void initialize(HWND p_wnd) throw() | |
| 511 { | |
| 512 if (!m_initialized) | |
| 513 { | |
| 514 m_initialized = true; | |
| 515 m_entry.m_in_use = true; | |
| 516 m_entry.m_wnd_to_poke = p_wnd; | |
| 517 ModalDialog_Switch(m_entry); | |
| 518 } | |
| 519 } | |
| 520 | |
| 521 void deinitialize() throw() | |
| 522 { | |
| 523 if (m_initialized) | |
| 524 { | |
| 525 ModalDialog_Switch(m_entry); | |
| 526 m_initialized = false; | |
| 527 } | |
| 528 } | |
| 529 | |
| 530 | |
| 531 | |
| 532 private: | |
| 533 modal_dialog_scope(const modal_dialog_scope & p_scope) = delete; | |
| 534 const modal_dialog_scope & operator=(const modal_dialog_scope &) = delete; | |
| 535 | |
| 536 t_modal_dialog_entry m_entry; | |
| 537 | |
| 538 bool m_initialized; | |
| 539 }; | |
| 540 | |
| 541 #endif // _WIN32 | |
| 542 | |
| 543 #include "audio_math.h" | |
| 544 #ifdef _WIN32 | |
| 545 #include "win32_misc.h" | |
| 546 #endif | |
| 547 | |
| 548 #include "fb2kdebug.h" | |
| 549 | |
| 550 #if FB2K_LEAK_STATIC_OBJECTS | |
| 551 #define FB2K_STATIC_OBJECT(TYPE, NAME) static TYPE & NAME = * new TYPE; | |
| 552 #else | |
| 553 #define FB2K_STATIC_OBJECT(TYPE, NAME) static TYPE NAME; | |
| 554 #endif | |
| 555 | |
| 556 | |
| 557 #ifdef _MSC_VER | |
| 558 #define FB2K_DEPRECATED __declspec(deprecated) | |
| 559 #else | |
| 560 #define FB2K_DEPRECATED | |
| 561 #endif | |
| 562 | |
| 563 | |
| 564 namespace fb2k { | |
| 565 #ifdef _WIN32 | |
| 566 typedef HWND hwnd_t; | |
| 567 typedef HICON hicon_t; | |
| 568 typedef HMENU hmenu_t; | |
| 569 typedef HFONT hfont_t; | |
| 570 #else | |
| 571 typedef void* hwnd_t; // Mac: bridged NSObject, context specific (NSWindow, NSView, NSViewController) | |
| 572 typedef void* hicon_t; | |
| 573 typedef void* hmenu_t; | |
| 574 typedef void* hfont_t; | |
| 575 #endif | |
| 576 | |
| 577 inline void messageBeep() { | |
| 578 #ifdef _WIN32 | |
| 579 MessageBeep(0); | |
| 580 #endif | |
| 581 } | |
| 582 } | |
| 583 | |
| 584 #ifdef __APPLE__ | |
| 585 #include "shared-apple.h" | |
| 586 #endif | |
| 587 | |
| 588 #ifndef _WIN32 | |
| 589 #include "shared-nix.h" | |
| 590 #endif | |
| 591 | |
| 592 | |
| 593 #endif //_SHARED_DLL__SHARED_H_ |
