diff options
author | George Hazan <ghazan@miranda.im> | 2019-10-21 15:07:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-10-21 15:07:36 +0300 |
commit | ed524786b80787a7c09993846b3e31d188ed41e9 (patch) | |
tree | 5c1b5f357b54c5cdb363754be5665b607510deb7 /plugins/NewStory/src/templates.cpp | |
parent | 99718e58c342b757ac30d89379d6ef399e1ce4c9 (diff) |
NewStory: options code reordering
Diffstat (limited to 'plugins/NewStory/src/templates.cpp')
-rw-r--r-- | plugins/NewStory/src/templates.cpp | 225 |
1 files changed, 0 insertions, 225 deletions
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp index facf75277a..7e978ab3f4 100644 --- a/plugins/NewStory/src/templates.cpp +++ b/plugins/NewStory/src/templates.cpp @@ -412,228 +412,3 @@ void vfOther(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData*) // %M: the message string itself TplSetVar(vars, 'M', _T("Unknown Event"), false); } - -// Option dialog - -INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static int CurrentTemplate; - switch (msg) { - case WM_INITDIALOG: - CurrentTemplate = -1; - { - HTREEITEM hGroup = 0; - HTREEITEM hFirst = 0; - - HIMAGELIST himgTree = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 1, 1); - TreeView_SetImageList(GetDlgItem(hwnd, IDC_TEMPLATES), himgTree, TVSIL_NORMAL); - - ImageList_AddIcon(himgTree, g_plugin.getIcon(ICO_TPLGROUP)); - - for (int i = 0; i < TPL_COUNT; i++) { - if (!i || lstrcmp(templates[i].group, templates[i - 1].group)) { - if (hGroup) - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); - - TVINSERTSTRUCT tvis; - tvis.hParent = 0; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.state = tvis.item.stateMask = TVIS_BOLD; - tvis.item.iSelectedImage = tvis.item.iImage = 0; - tvis.item.pszText = templates[i].group; - tvis.item.lParam = -1; - hGroup = TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); - - if (!hFirst) hFirst = hGroup; - } - - TVINSERTSTRUCT tvis; - tvis.hParent = hGroup; - tvis.hInsertAfter = TVI_LAST; - tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.pszText = templates[i].title; - tvis.item.iSelectedImage = tvis.item.iImage = - ImageList_AddIcon(himgTree, g_plugin.getIcon(templates[i].icon)); - tvis.item.lParam = i; - TreeView_InsertItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvis); - } - - if (hGroup) - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), hGroup, TVE_EXPAND); - - TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); - TreeView_EnsureVisible(GetDlgItem(hwnd, IDC_TEMPLATES), hFirst); - } - SendMessage(GetDlgItem(hwnd, IDC_DISCARD), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), BUTTONSETASFLATBTN, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_VARHELP), BUTTONSETASFLATBTN, 0, 0); - - SendMessage(GetDlgItem(hwnd, IDC_DISCARD), BUTTONADDTOOLTIP, (WPARAM)Translate("Cancel Edit"), 0); - SendMessage(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), BUTTONADDTOOLTIP, (WPARAM)Translate("Update Preview"), 0); - SendMessage(GetDlgItem(hwnd, IDC_VARHELP), BUTTONADDTOOLTIP, (WPARAM)Translate("Help on Variables"), 0); - - SendMessage(GetDlgItem(hwnd, IDC_DISCARD), BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_RESET)); - SendMessage(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_PREVIEW)); - SendMessage(GetDlgItem(hwnd, IDC_VARHELP), BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_plugin.getIcon(ICO_VARHELP)); - - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_EDITTEMPLATE: - SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0); - - case IDC_UPDATEPREVIEW: - if (templates[CurrentTemplate].tmpValue) - free(templates[CurrentTemplate].tmpValue); - { - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[CurrentTemplate].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); - GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue, length); - - HistoryArray::ItemData item; - item.hContact = db_find_first(); - while (item.hContact && !item.hEvent) { - item.hEvent = db_event_first(item.hContact); - if (!item.hEvent) - item.hContact = db_find_next(item.hContact); - } - - if (item.hContact && item.hEvent) { - item.load(ELM_DATA); - TCHAR *preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item); - SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), preview); - // SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), preview); - SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("$hit :)")); - free(preview); - } - else { - SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), _T("")); - SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), _T("")); - } - } - break; - - case IDC_DISCARD: - if (templates[CurrentTemplate].tmpValue) - free(templates[CurrentTemplate].tmpValue); - templates[CurrentTemplate].tmpValue = 0; - if (templates[CurrentTemplate].value) - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value); - else - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue); - - PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); - break; - } - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - for (int i = 0; i < TPL_COUNT; i++) { - if (templates[i].tmpValue) { - if (templates[i].tmpValue) - free(templates[i].tmpValue); - } - } - return TRUE; - - case PSN_APPLY: - for (int i = 0; i < TPL_COUNT; i++) { - if (templates[i].tmpValue) { - if (templates[i].value) - free(templates[i].value); - templates[i].value = templates[i].tmpValue; - templates[i].tmpValue = 0; - } - } - SaveTemplates(); - return TRUE; - } - break; - - case IDC_TEMPLATES: - switch (((LPNMHDR)lParam)->code) { - case TVN_SELCHANGED: - case TVN_SELCHANGING: - { - LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam; - - TVITEM tvi; - tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_TEMPLATES)); - tvi.mask = TVIF_PARAM; - TreeView_GetItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvi); - - if ((tvi.lParam < 0) || (tvi.lParam >= TPL_COUNT)) { - EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), FALSE); - /* HTREEITEM hItem = TreeView_GetChild(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem); - if (hItem) - { - TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem, TVE_EXPAND); - TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hItem); - }*/ - break; - } - else { - EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), TRUE); - } - - if ((lpnmtv->itemOld.mask&TVIF_HANDLE) && lpnmtv->itemOld.hItem && (lpnmtv->itemOld.hItem != lpnmtv->itemNew.hItem) && (lpnmtv->itemOld.lParam >= 0) && (lpnmtv->itemOld.lParam < TPL_COUNT)) { - if (templates[lpnmtv->itemOld.lParam].tmpValue) - free(templates[lpnmtv->itemOld.lParam].tmpValue); - int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1; - templates[lpnmtv->itemOld.lParam].tmpValue = (TCHAR *)malloc(length * sizeof(TCHAR)); - GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[lpnmtv->itemOld.lParam].tmpValue, length); - } - - CurrentTemplate = tvi.lParam; - - if (templates[CurrentTemplate].tmpValue) - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue); - else if (templates[CurrentTemplate].value) - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value); - else - SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue); - - PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0); - } - break; - - case TVN_KEYDOWN: - case NM_CLICK: - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - - /* - { - TVHITTESTINFO hti; - hti.pt.x = (short)LOWORD(GetMessagePos()); - hti.pt.y = (short)HIWORD(GetMessagePos()); - ScreenToClient(((LPNMHDR)lParam)->hwndFrom,&hti.pt); - if(TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom,&hti)) - if(hti.flags&TVHT_ONITEMSTATEICON) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - */ - - } - break; - } - break; - } - return FALSE; -} |