Beispiel #1
0
	virtual void OnDestroy()
	{
		HTREEITEM hItem = m_tree.GetRoot();
		while (hItem) {
			delete Tree_GetIDs(hItem);
			hItem = m_tree.GetNextSibling(hItem);
		}

		ImageList_Destroy(m_tree.GetImageList(TVSIL_NORMAL));
	}
Beispiel #2
0
	void InsertTag(HTREEITEM htiRoot, const TCHAR *tag, bool bSelect)
	{
		TVINSERTSTRUCT tvi = {0};
		tvi.hParent = htiRoot;
		tvi.hInsertAfter = TVI_LAST;
		tvi.itemex.mask = TVIF_TEXT|TVIF_PARAM;
		tvi.itemex.pszText = (TCHAR *)tag;
		tvi.itemex.lParam = (LPARAM)mir_tstrdup(tag);
		HTREEITEM hti = m_tvFilter.InsertItem(&tvi);
		if (bSelect) m_tvFilter.SelectItem(hti);
	}
Beispiel #3
0
	virtual void OnApply()
	{
		TVITEMEX tvi;
		tvi.hItem = m_nameOrder.GetRoot();
		int i = 0;
		while (tvi.hItem != NULL) {
			tvi.mask = TVIF_PARAM | TVIF_HANDLE;
			m_nameOrder.GetItem(&tvi);
			nameOrder[i++] = (BYTE)tvi.lParam;
			tvi.hItem = m_nameOrder.GetNextSibling(tvi.hItem);
		}
		db_set_blob(NULL, "Contact", "NameOrder", nameOrder, _countof(nameOrderDescr));
		CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)INVALID_HANDLE_VALUE, 0);
	}
Beispiel #4
0
	virtual void OnInitDialog()
	{
		int numSlots = GetNumberOfSlots();
		if (numSlots < (int)registeredExtraIcons.getCount()) {
			HWND label = GetDlgItem(m_hwnd, IDC_MAX_ICONS_L);
			SetWindowText(label, CMString(FORMAT, TranslateT("*only the first %d icons will be shown"), numSlots));
			ShowWindow(label, SW_SHOW);
		}

		int cx = g_iIconSX;
		HIMAGELIST hImageList = ImageList_Create(cx, cx, ILC_COLOR32 | ILC_MASK, 2, 2);

		HICON hBlankIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, cx, cx, 0);
		ImageList_AddIcon(hImageList, hBlankIcon);

		for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
			ExtraIcon *extra = registeredExtraIcons[i];

			HICON hIcon = IcoLib_GetIcon(extra->getDescIcon());
			if (hIcon == NULL)
				ImageList_AddIcon(hImageList, hBlankIcon);
			else {
				ImageList_AddIcon(hImageList, hIcon);
				IcoLib_ReleaseIcon(hIcon);
			}
		}
		m_tree.SetImageList(hImageList, TVSIL_NORMAL);
		DestroyIcon(hBlankIcon);

		for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
			ExtraIcon *extra = extraIconsBySlot[k];

			if (extra->getType() == EXTRAICON_TYPE_GROUP) {
				ExtraIconGroup *group = (ExtraIconGroup *)extra;
				intlist ids;
				for (int j = 0; j < group->m_items.getCount(); j++)
					ids.add(group->m_items[j]->getID());
				Tree_AddExtraIconGroup(ids, extra->isEnabled());
			}
			else Tree_AddExtraIcon((BaseExtraIcon *)extra, extra->isEnabled());
		}

		TVSORTCB sort = { 0 };
		sort.hParent = NULL;
		sort.lParam = 0;
		sort.lpfnCompare = CompareFunc;
		m_tree.SortChildrenCB(&sort, 0);
	}
Beispiel #5
0
	CContactOptsDlg() :
		CDlgBase(g_hInst, IDD_OPT_CONTACT),
		m_nameOrder(this, IDC_NAMEORDER)
	{
		m_nameOrder.SetFlags(MTREE_DND);
		m_nameOrder.OnBeginDrag = Callback(this, &CContactOptsDlg::OnBeginDrag);
	}
Beispiel #6
0
	void RebuildTree()
	{
		TVITEMEX tvi = { 0 };
		tvi.mask = TVIF_HANDLE | TVIF_PARAM;
		tvi.hItem = m_tvFilter.GetSelection();
		m_tvFilter.GetItem(&tvi);
		TCHAR *szActiveTag = mir_tstrdup((TCHAR *)tvi.lParam);

		m_tvFilter.DeleteAllItems();

		TVINSERTSTRUCT tvis = { 0 };
		tvis.hInsertAfter = TVI_LAST;
		tvis.itemex.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
		tvis.itemex.stateMask = tvis.itemex.state = TVIS_BOLD | TVIS_EXPANDED;
		tvis.itemex.pszText = TranslateT("All tags");

		PopulateTags(m_tvFilter.InsertItem(&tvis), szActiveTag);
		mir_free(szActiveTag);
	}
Beispiel #7
0
	virtual void OnInitDialog()
	{
		TVINSERTSTRUCT tvis;
		tvis.hParent = NULL;
		tvis.hInsertAfter = TVI_LAST;
		tvis.item.mask = TVIF_TEXT | TVIF_PARAM;
		for (int i = 0; i < _countof(nameOrderDescr); i++) {
			tvis.item.lParam = nameOrder[i];
			tvis.item.pszText = TranslateTS(nameOrderDescr[nameOrder[i]]);
			m_nameOrder.InsertItem(&tvis);
		}
	}
Beispiel #8
0
	virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
	{
		if (msg == WM_NOTIFY) {
			LPNMHDR lpnmhdr = (LPNMHDR)lParam;
			if (lpnmhdr->idFrom == IDC_EXTRAORDER && lpnmhdr->code == NM_RCLICK) {
				HTREEITEM hSelected = m_tree.GetDropHilight();
				if (hSelected != NULL && !m_tree.IsSelected(hSelected)) {
					m_tree.UnselectAll();
					m_tree.SelectItem(hSelected);
				}

				int sels = m_tree.GetNumSelected();
				if (sels > 1) {
					if (ShowPopup(0) == ID_GROUP) {
						GroupSelectedItems();
						NotifyChange();
					}
				}
				else if (sels == 1) {
					HTREEITEM hItem = m_tree.GetSelection();
					intlist *ids = Tree_GetIDs(hItem);
					if (ids->count > 1) {
						if (ShowPopup(1) == ID_UNGROUP) {
							UngroupSelectedItems();
							NotifyChange();
						}
					}
				}
			}
		}

		return CDlgBase::DlgProc(msg, wParam, lParam);
	}
Beispiel #9
0
	void PopulateTags(HTREEITEM htiRoot, TCHAR *szActiveTag)
	{
		LIST<TCHAR> tagSet(5, _tcscmp);
		for (int i = 0; i < m_proto->m_notes.getCount(); i++) {
			TCHAR *tags = m_proto->m_notes[i].GetTags();
			for (TCHAR *tag = tags; tag && *tag; tag = tag + lstrlen(tag) + 1)
			if (!tagSet.find(tag))
				tagSet.insert(tag);
		}

		bool selected = false;
		for (int j = 0; j < tagSet.getCount(); ++j) {
			bool select = !lstrcmp(szActiveTag, tagSet[j]);
			selected |= select;
			InsertTag(htiRoot, tagSet[j], select);
		}

		if (!selected)
			m_tvFilter.SelectItem(htiRoot);
	}
Beispiel #10
0
void CJabberDlgNotes::OnDestroy()
{
	m_tvFilter.DeleteAllItems();
	m_proto->m_pDlgNotes = NULL;
	CSuper::OnDestroy();
}
Beispiel #11
0
	virtual void OnApply()
	{
		// Store old slots
		int *oldSlots = new int[registeredExtraIcons.getCount()];
		int lastUsedSlot = -1;
		for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
			if (extraIconsByHandle[i] == registeredExtraIcons[i])
				oldSlots[i] = registeredExtraIcons[i]->getSlot();
			else
				// Remove old slot for groups to re-set images
				oldSlots[i] = -1;
			lastUsedSlot = MAX(lastUsedSlot, registeredExtraIcons[i]->getSlot());
		}
		lastUsedSlot = MIN(lastUsedSlot, GetNumberOfSlots());

		// Get user data and create new groups
		LIST<ExtraIconGroup> groups(1);

		BYTE pos = 0;
		int firstEmptySlot = 0;
		HTREEITEM ht = m_tree.GetRoot();
		TVITEMEX tvi;
		tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
		tvi.stateMask = TVIS_STATEIMAGEMASK;
		while (ht) {
			tvi.hItem = ht;
			m_tree.GetItem(&tvi);

			intlist*ids = (intlist*)tvi.lParam;
			if (ids == NULL || ids->count < 1)
				continue; // ???

			bool enabled = ((tvi.state & INDEXTOSTATEIMAGEMASK(3)) == INDEXTOSTATEIMAGEMASK(2));
			int slot = (enabled ? firstEmptySlot++ : -1);
			if (slot >= GetNumberOfSlots())
				slot = -1;

			if (ids->count == 1) {
				BaseExtraIcon *extra = registeredExtraIcons[ids->data[0] - 1];
				extra->setPosition(pos++);
				extra->setSlot(slot);
			}
			else {
				char name[128];
				mir_snprintf(name, "__group_%d", groups.getCount());

				ExtraIconGroup *group = new ExtraIconGroup(name);

				for (int i = 0; i < ids->count; i++) {
					BaseExtraIcon *extra = registeredExtraIcons[ids->data[i] - 1];
					extra->setPosition(pos++);

					group->addExtraIcon(extra);
				}

				group->setSlot(slot);
				groups.insert(group);
			}

			ht = m_tree.GetNextSibling(ht);
		}

		// Store data
		for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
			BaseExtraIcon *extra = registeredExtraIcons[i];

			char setting[512];
			mir_snprintf(setting, "Position_%s", extra->getName());
			db_set_w(NULL, MODULE_NAME, setting, extra->getPosition());

			mir_snprintf(setting, "Slot_%s", extra->getName());
			db_set_w(NULL, MODULE_NAME, setting, extra->getSlot());
		}

		CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)MODULE_NAME "Groups");
		db_set_w(NULL, MODULE_NAME "Groups", "Count", groups.getCount());
		for (int k = 0; k < groups.getCount(); k++) {
			ExtraIconGroup *group = groups[k];

			char setting[512];
			mir_snprintf(setting, "%d_count", k);
			db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->m_items.getCount());

			for (int j = 0; j < group->m_items.getCount(); j++) {
				BaseExtraIcon *extra = group->m_items[j];

				mir_snprintf(setting, "%d_%d", k, j);
				db_set_s(NULL, MODULE_NAME "Groups", setting, extra->getName());
			}
		}

		// Clean removed slots
		for (int j = firstEmptySlot; j <= lastUsedSlot; j++)
			RemoveExtraIcons(j);

		// Apply icons to new slots
		RebuildListsBasedOnGroups(groups);
		for (int n = 0; n < extraIconsBySlot.getCount(); n++) {
			ExtraIcon *extra = extraIconsBySlot[n];
			if (extra->getType() != EXTRAICON_TYPE_GROUP)
				if (oldSlots[((BaseExtraIcon *)extra)->getID() - 1] == extra->getSlot())
					continue;

			if (extra->isEnabled())
				extra->applyIcons();
		}

		delete[] oldSlots;
	}
Beispiel #12
0
	CExtraIconOptsDlg() :
		CDlgBase(g_hInst, IDD_EI_OPTIONS),
		m_tree(this, IDC_EXTRAORDER)
	{
		m_tree.SetFlags(MTREE_DND | MTREE_MULTISELECT);
	}