Exemple #1
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 = { sizeof(sid) };
	sid.ptszDefaultFile = szFilename;
	sid.flags = SIDF_PATH_TCHAR;

	for (int n=0; n < SIZEOF(ICONBLOCKS); n++) {
		sid.pszSection = ICONBLOCKS[n].szSection;
		for (int i=0; i < ICONBLOCKS[n].nItems; i++) {
			sid.pszName = ICONBLOCKS[n].idesc[i].szName;
			sid.pszDescription = 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++] = Skin_AddIcon(&sid);
			else
				Skin_AddIcon(&sid);
		}
	}

	sid.pszSection = LPGEN("Message Sessions")"/"LPGEN("Default");
	sid.pszName = "tabSRMM_clock_symbol";
	sid.pszDescription = LPGEN("Clock symbol (for the info panel clock)");
	sid.iDefaultIndex = -IDI_CLOCK;
	Skin_AddIcon(&sid);

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

	sid.pszName = "tabSRMM_overlay_disabled";
	sid.pszDescription = LPGEN("Feature disabled (used as overlay)");
	sid.iDefaultIndex = -IDI_FEATURE_DISABLED;
	Skin_AddIcon(&sid);

	sid.pszName = "tabSRMM_overlay_enabled";
	sid.pszDescription = LPGEN("Feature enabled (used as overlay)");
	sid.iDefaultIndex = -IDI_FEATURE_ENABLED;
	Skin_AddIcon(&sid);
	return 1;
}
static HICON LoadTransportIcon(char *filename,int i,char *IconName,TCHAR *SectName,TCHAR *Description,int internalidx, BOOL * needFree)
{
	char szPath[MAX_PATH],szMyPath[MAX_PATH], szFullPath[MAX_PATH],*str;
	BOOL has_proto_icon=FALSE;
	if (needFree) *needFree=FALSE;
	GetModuleFileNameA(NULL, szPath, MAX_PATH);
	str=strrchr(szPath,'\\');
	if (str != NULL) *str=0;
	mir_snprintf(szMyPath, sizeof(szMyPath), "%s\\Icons\\%s", szPath, filename);
	mir_snprintf(szFullPath, sizeof(szFullPath), "%s\\Icons\\%s,%d", szPath, filename, i);
	BOOL nf;
	HICON hi=ExtractIconFromPath(szFullPath,&nf);
	if (hi) has_proto_icon=TRUE;
	if (hi && nf) DestroyIcon(hi);
	if (IconName != NULL && SectName != NULL)  {
		SKINICONDESC sid = { sizeof(sid) };
		sid.hDefaultIcon = (has_proto_icon) ? NULL : LoadSkinnedProtoIcon(0, -internalidx);
		sid.ptszSection = SectName;
		sid.pszName = IconName;
		sid.ptszDescription = Description;
		sid.pszDefaultFile = szMyPath;
		sid.iDefaultIndex = i;
		sid.flags = SIDF_TCHAR;
		Skin_AddIcon(&sid);
	}
	return Skin_GetIcon(IconName);
}
void CDropbox::InitializeIcons()
{
	wchar_t filePath[MAX_PATH];
	GetModuleFileName(g_hInstance, filePath, MAX_PATH);

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

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

	SKINICONDESC sid = { 0 };
	sid.cbSize = sizeof(SKINICONDESC);
	sid.flags = SIDF_ALL_TCHAR;
	sid.ptszDefaultFile = filePath;
	sid.pszName = settingName;
	sid.ptszSection = sectionName;
	sid.ptszDescription = LPGENT("Protocol icon");
	sid.iDefaultIndex = -IDI_DROPBOX;
	/*HANDLE hIcon = */Skin_AddIcon(&sid);
}
Exemple #4
0
HANDLE RegisterNotification(POPUPNOTIFICATION *notification)
{
 	POPUPTREEDATA *ptd = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA));
	ptd->signature = PopupNotificationData_SIGNATURE;
	ptd->typ = 1;
	ptd->pszTreeRoot = mir_a2t(notification->lpzGroup);
	ptd->pszDescription = mir_a2t(notification->lpzName);
	ptd->notification = *notification;
	if (!ptd->notification.lpzLAction) ptd->notification.lpzLAction = POPUP_ACTION_NOTHING;
	if (!ptd->notification.lpzRAction) ptd->notification.lpzRAction = POPUP_ACTION_DISMISS;
	LoadNotificationSettings(ptd, "PopupNotifications");

	// ugly hack to make reset always possible
	SaveNotificationSettings(ptd,"PopupNotifications");

	FontID fontid = {0};
	fontid.cbSize = sizeof(fontid);
	mir_snprintf(fontid.group, sizeof(fontid.group), PU_FNT_AND_COLOR"/%s", notification->lpzGroup);
	lstrcpyA(fontid.dbSettingsGroup, "PopupNotifications");
	fontid.flags = FIDF_DEFAULTVALID;
	fontid.deffontsettings.charset = DEFAULT_CHARSET;
	fontid.deffontsettings.colour = ptd->notification.colorText;
	fontid.deffontsettings.size = -11;
	lstrcpynA(fontid.deffontsettings.szFace, "MS Shell Dlg", SIZEOF(fontid.deffontsettings.szFace));
	fontid.deffontsettings.style = 0;
	mir_snprintf(fontid.name, SIZEOF(fontid.name), "%s (colors only)", notification->lpzName);
	mir_snprintf(fontid.prefix, SIZEOF(fontid.prefix), "{%s/%s}text", notification->lpzGroup, notification->lpzName);
	fontid.deffontsettings.style = 0;
	FontRegister(&fontid);

	ColourID colourid = {0};
	colourid.cbSize = sizeof(colourid);
	mir_snprintf(colourid.group, sizeof(colourid.group), PU_FNT_AND_COLOR"/%s", notification->lpzGroup);
	lstrcpyA(colourid.dbSettingsGroup, "PopupNotifications");
	mir_snprintf(colourid.name, SIZEOF(colourid.name), "%s (colors only)", notification->lpzName);
	mir_snprintf(colourid.setting, SIZEOF(colourid.setting), "{%s/%s}backColor", notification->lpzGroup, notification->lpzName);
	colourid.defcolour = ptd->notification.colorBack;
	ColourRegister(&colourid);

	char section[MAXMODULELABELLENGTH], setting[MAXMODULELABELLENGTH];
	mir_snprintf(section, sizeof(section), "Popups/%s", notification->lpzGroup);
	mir_snprintf(setting, sizeof(setting), MODULNAME"_%s_%s", notification->lpzGroup, notification->lpzName);

	SKINICONDESC sid = { sizeof(sid) };
	sid.pszSection = section;
	sid.cx = sid.cy = 16;
	sid.pszName = setting;
	sid.pszDescription = notification->lpzName;
	sid.hDefaultIcon = notification->lchIcon;
	Skin_AddIcon(&sid);

	gTreeData.insert(ptd);
	return (HANDLE)ptd;
}
Exemple #5
0
static HANDLE AddIcon(char* szIcoName)
{
	TCHAR tszPath[MAX_PATH];
	GetModuleFileName(hinstance, tszPath, SIZEOF(tszPath));

	SKINICONDESC sid = { sizeof(sid) };
	sid.flags = SIDF_PATH_TCHAR;
	sid.pszSection = "Quick Messages";
	sid.cx = sid.cy = 16;
	sid.pszDescription = szIcoName;
	sid.pszName = szIcoName;
	sid.ptszDefaultFile = tszPath;
	sid.iDefaultIndex = -IDI_QICON;
	return Skin_AddIcon(&sid);
}
Exemple #6
0
HANDLE IcoLib_AddIconRes(const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDesc,HINSTANCE hInst,WORD idRes,BOOL fLarge)
{
	TCHAR szFileName[MAX_PATH];
	GetModuleFileName(hInst,szFileName,SIZEOF(szFileName));

	SKINICONDESC sid = { sizeof(sid) };
	sid.pszName = (char*)pszDbName;
	sid.ptszSection = (TCHAR*)pszSection;
	sid.ptszDescription = (TCHAR*)pszDesc;
	sid.ptszDefaultFile = szFileName;
	sid.iDefaultIndex = -idRes;
	sid.cx = GetSystemMetrics(fLarge?SM_CXICON:SM_CXSMICON);
	sid.cy = GetSystemMetrics(fLarge?SM_CYICON:SM_CYSMICON);
	sid.flags = SIDF_SORTED | SIDF_ALL_TCHAR;
	return Skin_AddIcon(&sid);
}
Exemple #7
0
		void addIcon(const TCHAR* szSection, const TCHAR* szDescription, const char* szIconName, HICON hDefaultIcon, int cx /* = 16 */, int cy /* = 16 */)
		{
			SKINICONDESC sid;

			sid.cbSize = sizeof(sid);
			sid.ptszSection = const_cast<TCHAR*>(szSection);
			sid.ptszDescription = const_cast<TCHAR*>(szDescription);
			sid.pszName = const_cast<char*>(szIconName);
			sid.pszDefaultFile = NULL;
			sid.iDefaultIndex = 0;
			sid.hDefaultIcon = hDefaultIcon;
			sid.cx = cx;
			sid.cy = cy;
			sid.flags = SIDF_TCHAR;
			Skin_AddIcon(&sid);
		}
Exemple #8
0
void InitIcons(void)
{
	HINSTANCE hNewIconInst = NULL;

	if (g_hFolders) {
		TCHAR pathname[MAX_PATH];
		FoldersGetCustomPathExT(g_hFolders, pathname, MAX_PATH, "icons\\");
		if (hNewIconInst == NULL)
			hNewIconInst = LoadIconsPack(pathname);
	}

	if (hNewIconInst == NULL)
		hNewIconInst = LoadIconsPack("icons\\secureim_icons.dll");

	if (hNewIconInst == NULL)
		hNewIconInst = LoadIconsPack("plugins\\secureim_icons.dll");

	if (hNewIconInst == NULL)
		g_hIconInst = g_hInst;
	else
		g_hIconInst = hNewIconInst;

	TCHAR tszPath[MAX_PATH];
	GetModuleFileName(g_hIconInst, tszPath, SIZEOF(tszPath));

	SKINICONDESC sid = { sizeof(sid) };
	sid.pszSection = "SecureIM";
	sid.ptszDefaultFile = tszPath;

	for (int i = 0; i < SIZEOF(icons); i++) {
		sid.pszSection = icons[i].section;
		sid.pszName = icons[i].name;
		sid.pszDescription = icons[i].text;
		sid.iDefaultIndex = -icons[i].key;
		HANDLE hIcolib = Skin_AddIcon(&sid);

		HICON hIcon = Skin_GetIconByHandle(hIcolib);
		if (icons[i].tbl == TBL_IEC)
			g_hIEC[icons[i].idx] = hIcon;
		else if (icons[i].tbl == TBL_ICO)
			g_hICO[icons[i].idx] = hIcon;
		else if (icons[i].tbl == TBL_POP)
			g_hPOP[icons[i].idx] = hIcon;
	}

	HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
}
Exemple #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 = { sizeof(sid) };
		sid.flags = SIDF_ALL_TCHAR;
		sid.pszName = szIconID;
		sid.ptszDescription = mir_a2t(szDescription);
		sid.ptszSection = mir_a2t(szSection);

		if (sid.ptszDescription && sid.ptszSection) {
			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.ptszDefaultFile = szDefaultFile;
			if (sid.ptszDefaultFile && sid.ptszDefaultFile[0])
				sid.iDefaultIndex = -idIcon;
			else {
				sid.hDefaultIcon = hDefIcon;
				sid.iDefaultIndex = -1;
			}
			hIconHandle = Skin_AddIcon(&sid);
		}
		MIR_FREE(sid.ptszDescription);
		MIR_FREE(sid.ptszSection);
	}
	return hIconHandle;
}
void CIconPool::RegisterIcon(const char *name, TCHAR *filename, int iconid, TCHAR *szSection, TCHAR *szDescription)
{
	char szSettingName[128];
	mir_snprintf(szSettingName, SIZEOF(szSettingName), "jabber_%s", name);

	CPoolItem *item = new CPoolItem;
	item->m_name = mir_strdup(name);
	item->m_szIcolibName = mir_strdup(szSettingName);

	SKINICONDESC sid = { sizeof(sid) };
	sid.ptszDefaultFile = filename;
	sid.pszName = szSettingName;
	sid.ptszSection = szSection;
	sid.ptszDescription = szDescription;
	sid.flags = SIDF_ALL_TCHAR;
	sid.iDefaultIndex = iconid;
	item->m_hIcolibItem = Skin_AddIcon(&sid);

	m_items.insert(item);
}
Exemple #11
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)
{
	HICON hIcon;

	// 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
	if (!(hIcon = Skin_GetIcon(pszIconName))) {
		bool bNeedFree = false;

		SKINICONDESC sid = { sizeof(sid) };
		sid.flags = SIDF_ALL_TCHAR;
		sid.cx = GetSystemMetrics(SM_CXSMICON);
		sid.cy = GetSystemMetrics(SM_CYSMICON);
		sid.pszName = (LPSTR)pszIconName;
		sid.ptszDescription = _ptszLabel;
		sid.ptszSection = 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.ptszDefaultFile = odp->ptszGroup;

				// icon library exists?
				if (sid.ptszDefaultFile)
					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
		Skin_AddIcon(&sid);

		if (!bInitIconsOnly)
			hIcon = Skin_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;
}