Beispiel #1
0
int LoadSkinIcons(void)
{
	TCHAR modulePath[MAX_PATH];
	GetModuleFileName(g_hInst, modulePath, _countof(modulePath));

	char iconName[MAX_PATH];
	SKINICONDESC sid = { 0 };
	sid.defaultFile.t = modulePath;
	sid.flags = SIDF_PATH_TCHAR;
	sid.pszName = iconName;

	// Add main icons to list
	for (int i = 0; i < _countof(mainIcons); i++) {
		mir_snprintf(iconName, "%s%d", mainIconsFmt, i);
		sid.section.a = mainIcons[i].section == NULL ? (char*)LPGEN("Main icons") : (char*)mainIcons[i].section;
		sid.description.a = (char*)mainIcons[i].description;
		sid.iDefaultIndex = mainIcons[i].resource_id;
		mainIcons[i].hIcolib = IcoLib_AddIcon(&sid, 0);
	}

	// Add global icons to list
	sid.section.a = PROTOCOLS_PREFIX "/" LPGEN("Global");

	// Asterisk is used, to avoid conflict with proto-plugins
	// 'coz users can't rename it to name with '*'
	for (int i = 0; i < _countof(statusIcons); i++) {
		mir_snprintf(iconName, "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, i);
		sid.pszName = iconName;
		sid.description.a = (char*)statusIcons[i].description;
		sid.iDefaultIndex = statusIcons[i].resource_id;
		statusIcons[i].hIcolib = IcoLib_AddIcon(&sid, 0);
	}
	return 0;
}
Beispiel #2
0
static int TSAPI SetupIconLibConfig()
{
	int j = 2, version = 0;

	TCHAR szFilename[MAX_PATH];
	_tcsncpy(szFilename, _T("icons\\tabsrmm_icons.dll"), MAX_PATH);
	g_hIconDLL = LoadLibrary(szFilename);
	if (g_hIconDLL == 0) {
		CWarning::show(CWarning::WARN_ICONPACKMISSING, CWarning::CWF_NOALLOWHIDE | MB_ICONERROR | MB_OK);
		return 0;
	}

	GetModuleFileName(g_hIconDLL, szFilename, MAX_PATH);
	Chat_AddIcons();
	version = GetIconPackVersion(g_hIconDLL);
	FreeLibrary(g_hIconDLL);
	g_hIconDLL = 0;

	SKINICONDESC sid = { 0 };
	sid.defaultFile.t = szFilename;
	sid.flags = SIDF_PATH_TCHAR;

	for (int n = 0; n < _countof(ICONBLOCKS); n++) {
		sid.section.a = ICONBLOCKS[n].szSection;
		for (int i = 0; i < ICONBLOCKS[n].nItems; i++) {
			sid.pszName = ICONBLOCKS[n].idesc[i].szName;
			sid.description.a = ICONBLOCKS[n].idesc[i].szDesc;
			sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId;        // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem)

			if (n > 0 && n < 4)
				PluginConfig.g_buttonBarIconHandles[j++] = IcoLib_AddIcon(&sid);
			else
				IcoLib_AddIcon(&sid);
		}
	}

	sid.section.a = LPGEN("Message Sessions")"/"LPGEN("Default");
	sid.pszName = "tabSRMM_clock_symbol";
	sid.description.a = LPGEN("Clock symbol (for the info panel clock)");
	sid.iDefaultIndex = -IDI_CLOCK;
	IcoLib_AddIcon(&sid);

	_tcsncpy(szFilename, _T("plugins\\tabsrmm.dll"), MAX_PATH);

	sid.pszName = "tabSRMM_overlay_disabled";
	sid.description.a = LPGEN("Feature disabled (used as overlay)");
	sid.iDefaultIndex = -IDI_FEATURE_DISABLED;
	IcoLib_AddIcon(&sid);

	sid.pszName = "tabSRMM_overlay_enabled";
	sid.description.a = LPGEN("Feature enabled (used as overlay)");
	sid.iDefaultIndex = -IDI_FEATURE_ENABLED;
	IcoLib_AddIcon(&sid);
	return 1;
}
void CSkypeProto::InitIcons()
{
	TCHAR szFile[MAX_PATH];
	GetModuleFileName(g_hInstance, szFile, MAX_PATH);

	char szSettingName[100];
	TCHAR szSectionName[100];

	SKINICONDESC sid = { 0 };
	sid.flags = SIDF_ALL_TCHAR;
	sid.defaultFile.t = szFile;
	sid.pszName = szSettingName;
	sid.section.t = szSectionName;

	mir_sntprintf(szSectionName, _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE));
	for (int i = 0; i < _countof(Icons); i++)
	{
		mir_snprintf(szSettingName, "%s_%s", MODULE, Icons[i].Name);

		sid.description.t = Icons[i].Description;
		sid.iDefaultIndex = -Icons[i].IconId;
		Icons[i].Handle = IcoLib_AddIcon(&sid);
	}

}
Beispiel #4
0
static int icolib_AddIcon(lua_State *L)
{
    const char *name = luaL_checkstring(L, 1);
    ptrT description(mir_utf8decodeT(luaL_checkstring(L, 2)));
    ptrT section(mir_utf8decodeT(luaL_optstring(L, 3, MODULE)));
    ptrT filePath(mir_utf8decodeT(lua_tostring(L, 4)));

    if (filePath == NULL)
    {
        filePath = (TCHAR*)mir_calloc(MAX_PATH + 1);
        GetModuleFileName(g_hInstance, filePath, MAX_PATH);
    }

    SKINICONDESC si = { 0 };
    si.flags = SIDF_ALL_TCHAR;
    si.pszName = mir_utf8decodeA(name);
    si.description.t = description;
    si.section.t = section;
    si.defaultFile.t = filePath;
    si.hDefaultIcon = GetIcon(IDI_SCRIPT);

    HANDLE res = IcoLib_AddIcon(&si, g_mLua->GetHLangpack());
    lua_pushlightuserdata(L, res);

    return 1;
}
Beispiel #5
0
static void Icon2button(TTBButton *but, HANDLE &hIcoLib, HICON &hIcon, bool bIsUp)
{
	HANDLE hSrc = bIsUp ? but->hIconHandleUp : but->hIconHandleDn;
	if (hSrc == NULL) {
		hIcoLib = NULL, hIcon = NULL;
		return;
	}

	hIcoLib = IcoLib_IsManaged((HICON)hSrc);
	if (!hIcoLib) {
		char buf[256];
		mir_snprintf(buf, "toptoolbar_%s%s", but->name, bIsUp ? (but->hIconDn ? "%s_up" : "%s") : "%s_dn");

		SKINICONDESC sid = { 0 };
		sid.section.a = "Toolbar";
		sid.pszName = buf;
		sid.defaultFile.a = NULL;
		mir_snprintf(buf, "%s%s", but->name, bIsUp ? "" : " (pressed)");
		sid.description.a = buf;
		sid.hDefaultIcon = bIsUp ? but->hIconUp : but->hIconDn;
		hIcoLib = IcoLib_AddIcon(&sid);
	}

	hIcon = IcoLib_GetIconByHandle(hIcoLib);
}
Beispiel #6
0
		void addIcon(const TCHAR* szSection, const TCHAR* szDescription, const char* szIconName, const char* szDefaultFile, int iDefaultIndex)
		{
			SKINICONDESC sid = { 0 };
			sid.section.t = const_cast<TCHAR*>(szSection);
			sid.description.t = const_cast<TCHAR*>(szDescription);
			sid.pszName = const_cast<char*>(szIconName);
			sid.defaultFile.a = const_cast<char*>(szDefaultFile);
			sid.iDefaultIndex = iDefaultIndex;
			sid.flags = SIDF_TCHAR;
			IcoLib_AddIcon(&sid);
		}
Beispiel #7
0
static HANDLE AddIcon(char* szIcoName)
{
	TCHAR tszPath[MAX_PATH];
	GetModuleFileName(hinstance, tszPath, _countof(tszPath));

	SKINICONDESC sid = { 0 };
	sid.flags = SIDF_PATH_TCHAR;
	sid.section.a = "Quick Messages";
	sid.description.a = szIcoName;
	sid.pszName = szIcoName;
	sid.defaultFile.t = tszPath;
	sid.iDefaultIndex = -IDI_QICON;
	return IcoLib_AddIcon(&sid);
}
static int MO_RegisterIcon(TMO_IntMenuItem *pmi, void*)
{
	TCHAR *uname = (pmi->UniqName) ? mir_a2t(pmi->UniqName) : mir_tstrdup(pmi->CustomName),
		*descr = GetMenuItemText(pmi);

	if (!uname && !descr)
		return FALSE;

	if (!pmi->hIcolibItem) {
		HICON hIcon = ImageList_GetIcon(pmi->parent->m_hMenuIcons, pmi->iconId, 0);

		TCHAR sectionName[256];
		mir_sntprintf(sectionName, LPGENT("Menu icons") _T("/%s"), TranslateTS(pmi->parent->ptszDisplayName));

		char iconame[256];
		mir_snprintf(iconame, "genmenu_%s_%s", pmi->parent->pszName, uname && *uname ? uname : descr);

		// remove '&'
		if (descr) {
			descr = NEWTSTR_ALLOCA(descr);

			for (TCHAR *p = descr; *p; p++) {
				if ((p = _tcschr(p, '&')) == NULL)
					break;

				memmove(p, p + 1, sizeof(TCHAR)*(mir_tstrlen(p + 1) + 1));
				if (*p == '\0')
					p++;
			}
		}

		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_TCHAR;
		sid.section.t = sectionName;
		sid.pszName = iconame;
		sid.description.t = descr;
		sid.hDefaultIcon = hIcon;
		pmi->hIcolibItem = IcoLib_AddIcon(&sid, 0);

		Safe_DestroyIcon(hIcon);
		if (hIcon = IcoLib_GetIcon(iconame)) {
			ImageList_ReplaceIcon(pmi->parent->m_hMenuIcons, pmi->iconId, hIcon);
			IcoLib_ReleaseIcon(hIcon);
		}
	}

	mir_free(uname);
	return FALSE;
}
Beispiel #9
0
/**
 * This function manually registers a single icon from the default icon library.
 *
 * @param		szIconID		- This is the uniquely identifying string for an icon. 
 *								  This string is the setting name in the database and should 
 *								  only use ASCII characters.
 * @param		szDescription	- This is the description displayed in the options dialog.
 * @param		szSection		- This is the subsection, where the icon is organized in the options dialog.
 * @param		szDefaultFile	- This is the validated path to the default icon file.
 * @param		idIcon			- This is the ResourceID of the icon in the default file.
 * @param		Size			- This is the desired size of the icon to load.
 *								  0:	default size for small icons (16x16)
 *								  1:	default size for normal icons (32x32)
 * @param		hDefIcon		- This is the default icon to use if the default icon
 *								  file does not exist and no custom icon is set up in the config.
 *
 * @return	This function returns the HANDLE of the icon item.
 **/
static HANDLE IcoLib_RegisterIconHandleEx(LPSTR szIconID, LPSTR szDescription, LPSTR szSection, LPTSTR szDefaultFile, int idIcon, int Size, HICON hDefIcon)
{
	HANDLE hIconHandle = NULL;

	if (szIconID && szDescription && szSection) {
		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_ALL_TCHAR;
		sid.pszName = szIconID;
		sid.description.t = mir_a2t(szDescription);
		sid.section.t = mir_a2t(szSection);

		if (sid.description.t && sid.section.t) {
			switch (Size) {
			// small icons (16x16)
			case 0:
				sid.cx = GetSystemMetrics(SM_CXSMICON);
				sid.cy = GetSystemMetrics(SM_CYSMICON);
				break;

			// normal icons (32x32)
			case 1:
				sid.cx = GetSystemMetrics(SM_CXICON);
				sid.cy = GetSystemMetrics(SM_CYICON);
				break;

			// custom icon size
			default:
				sid.cx = sid.cy = Size;
				break;
			}

			sid.defaultFile.t = szDefaultFile;
			if (sid.defaultFile.t && sid.defaultFile.t[0])
				sid.iDefaultIndex = -idIcon;
			else {
				sid.hDefaultIcon = hDefIcon;
				sid.iDefaultIndex = -1;
			}
			hIconHandle = IcoLib_AddIcon(&sid);
		}
		MIR_FREE(sid.description.t);
		MIR_FREE(sid.section.t);
	}
	return hIconHandle;
}
Beispiel #10
0
void InitIcons(void)
{
	char szId[20];

	/* register icons */
	SKINICONDESC sid = { 0 };
	sid.pszName = szId;
	sid.cx = GetSystemMetrics(SM_CXSMICON);
	sid.cy = GetSystemMetrics(SM_CYSMICON);
	sid.flags = SIDF_SORTED;
	sid.section.a = "Country Flags";

	/* all those flag icons do not need any transparency mask (flags are always opaque),
	 * storing them in a large bitmap to reduce file size */
	HIMAGELIST himl = ImageList_LoadImage(hInst,MAKEINTRESOURCE(IDB_FLAGS),sid.cx,0,CLR_NONE,IMAGE_BITMAP,LR_CREATEDIBSECTION);
	if (himl != NULL) {
		phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
		if (phIconHandles != NULL) {
			for (int i=0; i < nCountriesCount; ++i) {
				sid.description.a = (char*)countries[i].szName;

				/* create identifier */
				mir_snprintf(szId, (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i","flags_", countries[i].id); /* buffer safe */
				int index = CountryNumberToBitmapIndex(countries[i].id);
				/* create icon */
				HICON hIcon = ImageList_GetIcon(himl,index,ILD_NORMAL);
				if (hIcon) {
					sid.hDefaultIcon = ResizeIconCentered(hIcon,sid.cx,sid.cy);
					DestroyIcon(hIcon);
				}
				else sid.hDefaultIcon = NULL;
				index = CountryNumberToIndex(countries[i].id);
				phIconHandles[index] = IcoLib_AddIcon(&sid);
				if (sid.hDefaultIcon != NULL)
					DestroyIcon(sid.hDefaultIcon);
			}
		}
		ImageList_Destroy(himl);
	}

	/* create services */
	CreateServiceFunction(MS_FLAGS_LOADFLAGICON, ServiceLoadFlagIcon);
	CreateServiceFunction(MS_FLAGS_CREATEMERGEDFLAGICON, ServiceCreateMergedFlagIcon);
}
Beispiel #11
0
void __fastcall Prepare(KN_FP_MASK* mask, bool bEnable)
{
	mask->szMaskUpper = NULL;

	if (mask->hIcolibItem)
		IcoLib_RemoveIcon(mask->szIconName);
	mask->hIcolibItem = NULL;

	if (!mask->szMask || !bEnable)
		return;

	size_t iMaskLen = mir_tstrlen(mask->szMask) + 1;
	LPTSTR pszNewMask = (LPTSTR)HeapAlloc(hHeap, HEAP_NO_SERIALIZE, iMaskLen * sizeof(TCHAR));
	_tcscpy_s(pszNewMask, iMaskLen, mask->szMask);
	_tcsupr_s(pszNewMask, iMaskLen);
	mask->szMaskUpper = pszNewMask;

	TCHAR destfile[MAX_PATH];
	if (mask->iIconIndex == IDI_NOTFOUND || mask->iIconIndex == IDI_UNKNOWN || mask->iIconIndex == IDI_UNDETECTED)
		GetModuleFileName(g_hInst, destfile, MAX_PATH);
	else {
		_tcsncpy_s(destfile, g_szSkinLib, _TRUNCATE);

		struct _stat64i32 stFileInfo;
		if (_tstat(destfile, &stFileInfo) == -1)
			return;
	}

	LPTSTR SectName = getSectionName(mask->iSectionFlag);
	if (SectName == NULL)
		return;

	SKINICONDESC sid = { 0 };
	sid.flags = SIDF_ALL_TCHAR;
	sid.section.t = SectName;
	sid.pszName = mask->szIconName;
	sid.description.t = mask->szClientDescription;
	sid.defaultFile.t = destfile;
	sid.iDefaultIndex = -mask->iIconIndex;
	mask->hIcolibItem = IcoLib_AddIcon(&sid);
}
Beispiel #12
0
MIR_CORE_DLL(void) Icon_RegisterT(HINSTANCE hInst, const TCHAR *szSection, IconItemT *pIcons, size_t iCount, char *prefix, int _hLang)
{
	TCHAR szFile[MAX_PATH];
	GetModuleFileName(hInst, szFile, MAX_PATH);

	SKINICONDESC sid = { 0 };
	sid.defaultFile.t = szFile;
	sid.section.t = (TCHAR*)szSection;
	sid.flags = SIDF_ALL_TCHAR;

	for (unsigned i = 0; i < iCount; i++) {
		char szSetting[100];
		if (prefix) {
			mir_snprintf(szSetting, "%s_%s", prefix, pIcons[i].szName);
			sid.pszName = szSetting;
		}
		else sid.pszName = pIcons[i].szName;

		sid.cx = sid.cy = pIcons[i].size;
		sid.description.t = pIcons[i].tszDescr;
		sid.iDefaultIndex = -pIcons[i].defIconID;
		pIcons[i].hIcolib = IcoLib_AddIcon(&sid, _hLang);
	}
}
Beispiel #13
0
// Called when all the modules are loaded
static int ModulesLoaded(WPARAM, LPARAM)
{
	variables_enabled = ServiceExists(MS_VARS_FORMATSTRING);

	// Folders plugin support
	if (hDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Dictionaries"), DICTIONARIES_FOLDER)) {
		dictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hDictionariesFolder, dictionariesFolder, MAX_PATH, _T("."));
	}
	else dictionariesFolder = Utils_ReplaceVarsT(DICTIONARIES_FOLDER);

	if (hCustomDictionariesFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Custom Dictionaries"), CUSTOM_DICTIONARIES_FOLDER)) {
		customDictionariesFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hCustomDictionariesFolder, customDictionariesFolder, MAX_PATH, _T("."));
	}
	else customDictionariesFolder = Utils_ReplaceVarsT(CUSTOM_DICTIONARIES_FOLDER);

	if (hFlagsDllFolder = FoldersRegisterCustomPathT(LPGEN("Spell Checker"), LPGEN("Flags DLL"), FLAGS_DLL_FOLDER)) {
		flagsDllFolder = (TCHAR *)mir_alloc(sizeof(TCHAR) * MAX_PATH);
		FoldersGetCustomPathT(hFlagsDllFolder, flagsDllFolder, MAX_PATH, _T("."));
	}
	else flagsDllFolder = Utils_ReplaceVarsT(FLAGS_DLL_FOLDER);

	InitOptions();

	GetAvaibleDictionaries(languages, dictionariesFolder, customDictionariesFolder);

	LoadOptions();

	if (opts.use_flags) {
		// Load flags dll
		TCHAR flag_file[MAX_PATH];
		mir_sntprintf(flag_file, _T("%s\\flags_icons.dll"), flagsDllFolder);
		HMODULE hFlagsDll = LoadLibraryEx(flag_file, NULL, LOAD_LIBRARY_AS_DATAFILE);

		TCHAR path[MAX_PATH];
		GetModuleFileName(hInst, path, MAX_PATH);

		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_ALL_TCHAR | SIDF_SORTED;
		sid.section.t = LPGENT("Spell Checker") _T("/") LPGENT("Flags");

		// Get language flags
		for (int i = 0; i < languages.getCount(); i++) {
			Dictionary *p = languages[i];
			sid.description.t = p->full_name;

			char lang[32];
			mir_snprintf(lang, "spell_lang_%d", i);
			sid.pszName = lang;

			HICON hFlag = NULL, hFlagIcoLib = NULL;
			if (hFlagsDll != NULL)
				hFlag = (HICON)LoadImage(hFlagsDll, p->language, IMAGE_ICON, 16, 16, 0);

			if (hFlag != NULL) {
				sid.hDefaultIcon = hFlag;
				sid.defaultFile.t = NULL;
				sid.iDefaultIndex = 0;
			}
			else {
				hFlagIcoLib = IcoLib_GetIcon("spellchecker_unknown");
				sid.hDefaultIcon = hFlagIcoLib;
				sid.defaultFile.t = NULL;
				sid.iDefaultIndex = 0;
			}

			// Oki, lets add to IcoLib, then
			p->hIcolib = IcoLib_AddIcon(&sid);

			if (hFlag != NULL)
				DestroyIcon(hFlag);
			else
				IcoLib_ReleaseIcon(hFlagIcoLib);
		}
		FreeLibrary(hFlagsDll);
	}

	for (int j = 0; j < languages.getCount(); j++) {
		Dictionary *dict = languages[j];

		TCHAR filename[MAX_PATH];
		mir_sntprintf(filename, _T("%s\\%s.ar"), customDictionariesFolder, dict->language);
		dict->autoReplace = new AutoReplaceMap(filename, dict);

		if (mir_tstrcmp(dict->language, opts.default_language) == 0)
			dict->load();
	}

	HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
	HookEvent(ME_MSG_WINDOWEVENT, MsgWindowEvent);
	HookEvent(ME_MSG_WINDOWPOPUP, MsgWindowPopup);
	HookEvent(ME_MSG_ICONPRESSED, IconPressed);

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = MODULE_NAME;
	sid.hIconDisabled = IcoLib_GetIcon("spellchecker_disabled");
	sid.flags = MBF_TCHAR | MBF_HIDDEN;

	for (int i = 0; i < languages.getCount(); i++) {
		sid.dwId = i;

		TCHAR tmp[128];
		mir_sntprintf(tmp, _T("%s - %s"), TranslateT("Spell Checker"), languages[i]->full_name);
		sid.tszTooltip = tmp;
		sid.hIcon = (opts.use_flags) ? IcoLib_GetIconByHandle(languages[i]->hIcolib) : IcoLib_GetIcon("spellchecker_enabled");
		Srmm_AddIcon(&sid);
	}

	HOTKEYDESC hkd = { sizeof(hkd) };
	hkd.pszName = "Spell Checker/Toggle";
	hkd.pszSection = LPGEN("Spell Checker");
	hkd.pszDescription = LPGEN("Enable/disable spell checker");
	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_ALT, 'S');
	hkd.lParam = HOTKEY_ACTION_TOGGLE;
	Hotkey_Register(&hkd);

	loaded = TRUE;

	return 0;
}
Beispiel #14
0
void InitIcons()
{
	// all those flag icons storing in a large 24bit opaque bitmap to reduce file size
	FIBITMAP *dib = LoadResource(IDB_FLAGSPNG, _T("PNG"));
	if (dib == NULL)
		return;

	if (FIP->FI_GetBPP(dib) != ILC_COLOR32)
		if (NULL == (dib = ConvertTo(dib, ILC_COLOR32, 0)))
			return;

	// create new dib
	FIBITMAP *dib_ico = FIP->FI_Allocate(FIP->FI_GetWidth(dib), 16, ILC_COLOR32, 0, 0, 0);
	if (dib_ico == NULL) {
		FIP->FI_Unload(dib);
		return;
	}

	UINT h = FIP->FI_GetHeight(dib_ico);
	UINT w = FIP->FI_GetWidth(dib_ico);
	UINT t = ((h - FIP->FI_GetHeight(dib)) / 2) + 1;
	UINT b = t + FIP->FI_GetHeight(dib);

	// copy dib to new dib_ico (centered)
	if (FIP->FI_Paste(dib_ico, dib, 0, t - 1, 255 + 1)) {
		FIP->FI_Unload(dib);	dib = NULL;

		// Calculate the number of bytes per pixel (3 for 24-bit or 4 for 32-bit)
		int bytespp = FIP->FI_GetLine(dib_ico) / w;
		// set alpha schannel
		for (unsigned y = 0; y < h; y++) {
			BYTE *bits = FIP->FI_GetScanLine(dib_ico, y);
			for (unsigned x = 0; x < w; x++) {
				bits[FI_RGBA_ALPHA] = (y < t || y >= b) ? 0 : 255;
				// jump to next pixel
				bits += bytespp;
			}
		}
	}
	else {
		FIP->FI_Unload(dib);
		FIP->FI_Unload(dib_ico);
		return;
	}

	HBITMAP hScrBM = FIP->FI_CreateHBITMAPFromDIB(dib_ico);
	FIP->FI_Unload(dib_ico);
	if (!hScrBM)
		return;

	// create ImageList
	HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, nCountriesCount);
	ImageList_Add(himl, hScrBM, NULL);
	DeleteObject(hScrBM);
	hScrBM = NULL;

	if (himl != NULL) {
		phIconHandles = (HANDLE*)mir_alloc(nCountriesCount*sizeof(HANDLE));
		if (phIconHandles != NULL) {
			char szId[20];
			SKINICONDESC sid = { 0 };
			sid.section.t = LPGENT("Country flags");
			sid.pszName = szId; // name to refer to icon when playing and in db
			sid.flags = SIDF_SORTED | SIDF_TCHAR;

			for (int i=0; i < nCountriesCount; i++) {
				sid.description.t = mir_a2t(LPGEN(countries[i].szName));
				/* create identifier */
				mir_snprintf(szId, _countof(szId), (countries[i].id == 0xFFFF) ? "%s0x%X" : "%s%i", "flags_", countries[i].id); /* buffer safe */
				int index = CountryNumberToBitmapIndex(countries[i].id);
				/* create icon */
				sid.hDefaultIcon = ImageList_ExtractIcon(NULL, himl, index);
				index = CountryNumberToIndex(countries[i].id);

				phIconHandles[index] = IcoLib_AddIcon(&sid);
				if (sid.hDefaultIcon != NULL)
					DestroyIcon(sid.hDefaultIcon);
				mir_free(sid.description.t); sid.description.t = NULL;
			}
		}
		ImageList_Destroy(himl);
	}

	// create services
	CreateServiceFunction(MS_FLAGS_LOADFLAGICON,ServiceLoadFlagIcon);
	CreateServiceFunction(MS_FLAGS_CREATEMERGEDFLAGICON,ServiceCreateMergedFlagIcon);
}
Beispiel #15
0
/**
 * name:	Icon
 * class:	CPsTreeItem
 * desc:	load the icon, add to icolib if required and add to imagelist of treeview
 * params:	hIml			- treeview's imagelist to add the icon to
 *			odp				- pointer to OPTIONSDIALOGPAGE providing the information about the icon to load
 *			hDefaultIcon	- default icon to use
 * return: nothing
 **/
int CPsTreeItem::Icon(HIMAGELIST hIml, OPTIONSDIALOGPAGE *odp, BYTE bInitIconsOnly)
{
	// check parameter
	if (!_pszName || !odp)
		return 1;

	// load the icon if no icolib is installed or creating the required settingname failed
	LPCSTR pszIconName = IconKey();

	// use icolib to handle icons
	HICON hIcon = IcoLib_GetIcon(pszIconName);
	if (!hIcon) {
		bool bNeedFree = false;

		SKINICONDESC sid = { 0 };
		sid.flags = SIDF_ALL_TCHAR;
		sid.pszName = (LPSTR)pszIconName;
		sid.description.t = _ptszLabel;
		sid.section.t = LPGENT(SECT_TREE);

		// the item to insert brings along an icon?
		if (odp->flags & ODPF_ICON) {
			// is it uinfoex item?
			if (odp->hInstance == ghInst) {

				// the pszGroup holds the iconfile for items added by uinfoex
				sid.defaultFile.t = odp->ptszGroup;

				// icon library exists?
				if (sid.defaultFile.t)
					sid.iDefaultIndex = (INT_PTR)odp->hIcon;
				// no valid icon library
				else {
					bNeedFree = true;
					sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL);
					sid.iDefaultIndex = -1;
				}
			}
			// default icon is delivered by the page to add
			else {
				if (odp->hIcon)
					sid.hDefaultIcon = odp->hIcon;
				else
					sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL), bNeedFree = true;
				sid.iDefaultIndex = -1;
			}
		}
		// no icon to add, use default
		else {
			sid.iDefaultIndex = -1;
			sid.hDefaultIcon = ProtoIcon();
			if (!sid.hDefaultIcon)
				sid.hDefaultIcon = ImageList_GetIcon(hIml, 0, ILD_NORMAL), bNeedFree = true;
		}
		// add file to icolib
		IcoLib_AddIcon(&sid);

		if (!bInitIconsOnly)
			hIcon = IcoLib_GetIcon(pszIconName);
		if (bNeedFree)
			DestroyIcon(sid.hDefaultIcon);
	}
	
	if (!bInitIconsOnly && hIml) {
		// set custom icon to image list
		if (hIcon) return ((_iImage = ImageList_AddIcon(hIml, hIcon)) == -1);
		_iImage = 0;
	}
	else
		_iImage = -1;
	return 0;
}
Beispiel #16
0
MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
{
	char iconName[MAX_PATH];
	INT_PTR caps2;
	if (szProto == NULL)
		caps2 = -1;
	else if ((caps2 = CallProtoServiceInt(NULL, szProto, PS_GETCAPS, PFLAGNUM_2, 0)) == CALLSERVICE_NOTFOUND)
		caps2 = 0;

	if (IsStatusConnecting(status)) {
		mir_snprintf(iconName, "%s%d", mainIconsFmt, 7);
		return IcoLib_GetIcon(iconName, big);
	}

	int statusIndx = -1;
	for (int i = 0; i < _countof(statusIcons); i++)
		if (statusIcons[i].id == status) {
			statusIndx = i;
			break;
		}

	if (statusIndx == -1)
		return NULL;

	if (!szProto) {
		// Only return a protocol specific icon if there is only one protocol
		// Otherwise return the global icon. This affects the global status menu mainly.
		if (accounts.getCount() == 1) {
			// format: core_status_%proto%statusindex
			mir_snprintf(iconName, "%s%s%d", statusIconsFmt, szProto, statusIndx);

			HICON hIcon = IcoLib_GetIcon(iconName, big);
			if (hIcon)
				return hIcon;
		}

		// format: core_status_%s%d
		mir_snprintf(iconName, "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
		return IcoLib_GetIcon(iconName, big);
	}

	// format: core_status_%s%d
	mir_snprintf(iconName, "%s%s%d", statusIconsFmt, szProto, statusIndx);
	HICON hIcon = IcoLib_GetIcon(iconName, big);
	if (hIcon == NULL && (caps2 == 0 || (caps2 & statusIcons[statusIndx].pf2))) {
		PROTOACCOUNT *pa = Proto_GetAccount(szProto);
		if (pa) {
			TCHAR szPath[MAX_PATH], szFullPath[MAX_PATH], *str;
			GetModuleFileName(NULL, szPath, _countof(szPath));

			// Queried protocol isn't in list, adding
			TCHAR tszSection[MAX_PATH];
			mir_sntprintf(tszSection, _T(PROTOCOLS_PREFIX)_T("/%s"), pa->tszAccountName);

			SKINICONDESC sid = { 0 };
			sid.section.t = tszSection;
			sid.flags = SIDF_ALL_TCHAR;

			str = _tcsrchr(szPath, '\\');
			if (str != NULL)
				*str = 0;
			mir_sntprintf(szFullPath, _T("%s\\Icons\\proto_%S.dll"), szPath, pa->szProtoName);
			if (GetFileAttributes(szFullPath) != INVALID_FILE_ATTRIBUTES)
				sid.defaultFile.t = szFullPath;
			else {
				mir_sntprintf(szFullPath, _T("%s\\Plugins\\%S.dll"), szPath, szProto);
				if (int(ExtractIconEx(szFullPath, statusIcons[statusIndx].resource_id, NULL, &hIcon, 1)) > 0) {
					DestroyIcon(hIcon);
					sid.defaultFile.t = szFullPath;
					hIcon = NULL;
				}

				if (sid.defaultFile.a == NULL) {
					if (str != NULL)
						*str = '\\';
					sid.defaultFile.t = szPath;
				}
			}

			// Add global icons to list
			int lowidx, highidx;
			if (caps2 == 0)
				lowidx = statusIndx, highidx = statusIndx + 1;
			else
				lowidx = 0, highidx = _countof(statusIcons);

			for (int i = lowidx; i < highidx; i++) {
				if (caps2 == 0 || (caps2 & statusIcons[i].pf2)) {
					// format: core_%s%d
					mir_snprintf(iconName, "%s%s%d", statusIconsFmt, szProto, i);
					sid.pszName = iconName;
					sid.description.t = cli.pfnGetStatusModeDescription(statusIcons[i].id, 0);
					sid.iDefaultIndex = statusIcons[i].resource_id;
					IcoLib_AddIcon(&sid, 0);
				}
			}
		}

		// format: core_status_%s%d
		mir_snprintf(iconName, "%s%s%d", statusIconsFmt, szProto, statusIndx);
		hIcon = IcoLib_GetIcon(iconName, big);
		if (hIcon)
			return hIcon;
	}

	if (hIcon == NULL) {
		mir_snprintf(iconName, "%s%s%d", statusIconsFmt, GLOBAL_PROTO_NAME, statusIndx);
		hIcon = IcoLib_GetIcon(iconName, big);
	}

	return hIcon;
}
Beispiel #17
0
CSteamProto::CSteamProto(const char* protoName, const TCHAR* userName)
	: PROTO<CSteamProto>(protoName, userName),
	hAuthProcess(1), hMessageProcess(1)
{
	CreateProtoService(PS_CREATEACCMGRUI, &CSteamProto::OnAccountManagerInit);

	m_idleTS = 0;
	isTerminated = false;
	m_hQueueThread = NULL;
	m_pollingConnection = NULL;
	m_hPollingThread = NULL;

	// icons
	wchar_t filePath[MAX_PATH];
	GetModuleFileName(g_hInstance, filePath, MAX_PATH);

	wchar_t sectionName[100];
	mir_sntprintf(sectionName, _T("%s/%s"), LPGENT("Protocols"), LPGENT(MODULE));

	char settingName[100];
	mir_snprintf(settingName, "%s_%s", MODULE, "main");

	SKINICONDESC sid = { 0 };
	sid.flags = SIDF_ALL_TCHAR;
	sid.defaultFile.t = filePath;
	sid.pszName = settingName;
	sid.section.t = sectionName;
	sid.description.t = LPGENT("Protocol icon");
	sid.iDefaultIndex = -IDI_STEAM;
	IcoLib_AddIcon(&sid);

	mir_snprintf(settingName, "%s_%s", MODULE, "gaming");
	sid.description.t = LPGENT("Gaming icon");
	sid.iDefaultIndex = -IDI_GAMING;
	IcoLib_AddIcon(&sid);

	// temporary DB settings
	db_set_resident(m_szModuleName, "XStatusId");
	db_set_resident(m_szModuleName, "XStatusName");
	db_set_resident(m_szModuleName, "XStatusMsg");
	db_set_resident(m_szModuleName, "IdleTS");
	db_set_resident(m_szModuleName, "GameID");
	db_set_resident(m_szModuleName, "ServerIP");
	db_set_resident(m_szModuleName, "ServerID");

	SetAllContactsStatus(ID_STATUS_OFFLINE);

	// services
	CreateServiceFunction(MODULE"/MenuChoose", CSteamProto::MenuChooseService);

	// avatar API
	CreateProtoService(PS_GETAVATARINFO, &CSteamProto::GetAvatarInfo);
	CreateProtoService(PS_GETAVATARCAPS, &CSteamProto::GetAvatarCaps);
	CreateProtoService(PS_GETMYAVATAR, &CSteamProto::GetMyAvatar);

	// custom status API
	CreateProtoService(PS_GETCUSTOMSTATUSEX, &CSteamProto::OnGetXStatusEx);
	CreateProtoService(PS_GETCUSTOMSTATUSICON, &CSteamProto::OnGetXStatusIcon);
	CreateProtoService(PS_GETADVANCEDSTATUSICON, &CSteamProto::OnRequestAdvStatusIconIdx);

	// netlib support
	TCHAR name[128];
	mir_sntprintf(name, TranslateT("%s connection"), m_tszUserName);

	NETLIBUSER nlu = { sizeof(nlu) };
	nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
	nlu.ptszDescriptiveName = name;
	nlu.szSettingsModule = m_szModuleName;
	m_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);

	requestQueue = new RequestQueue(m_hNetlibUser);
}