// Internal method to create the button item and configure the associated button control void CSideBarButton::_create() { m_hwnd = 0; m_isTopAligned = true; m_sz.cx = m_sz.cy = 0; m_hwnd = ::CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_TABSTOP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, 40, 40, m_sideBar->getScrollWnd(), reinterpret_cast<HMENU>(m_id), g_hInst, NULL); if (m_hwnd) { CustomizeButton(m_hwnd); ::SendMessage(m_hwnd, BUTTONSETASSIDEBARBUTTON, (WPARAM)this, 0); ::SendMessage(m_hwnd, BUTTONSETASFLATBTN, FALSE, 0); ::SendMessage(m_hwnd, BUTTONSETASTHEMEDBTN, TRUE, 0); ::SendMessage(m_hwnd, BUTTONSETCONTAINER, (LPARAM)m_sideBar->getContainer(), 0); m_buttonControl = (TSButtonCtrl *)::GetWindowLongPtr(m_hwnd, 0); if (m_id == IDC_SIDEBARUP || m_id == IDC_SIDEBARDOWN) ::SetParent(m_hwnd, m_sideBar->getContainer()->hwnd); } else delete this; }
// dialog procedure for handling the contact ignore dialog (available from the contact menu static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: { DWORD dwMask; ClcContact *contact = nullptr; int pCaps; HWND hwndAdd; hContact = lParam; SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)hContact); dwMask = db_get_dw(hContact, "Ignore", "Mask1", 0); SendMessage(hWnd, WM_USER + 100, hContact, dwMask); SendMessage(hWnd, WM_USER + 120, 0, 0); TranslateDialogDefault(hWnd); hwndAdd = GetDlgItem(hWnd, IDC_IGN_ADDPERMANENTLY); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_plugin.getInst(), NULL); CustomizeButton(hwndAdd, false, true, false); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT)); SetWindowText(hwndAdd, TranslateT("Add permanently")); EnableWindow(hwndAdd, db_get_b(hContact, "CList", "NotOnList", 0)); hwndAdd = GetDlgItem(hWnd, IDC_DSP_LOADDEFAULT); // CreateWindowEx(0, L"CLCButtonClass", L"FOO", WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD | WS_TABSTOP, 200, 276, 106, 24, hWnd, (HMENU)IDC_IGN_ADDPERMANENTLY, g_plugin.getInst(), NULL); CustomizeButton(hwndAdd, false, true, false); SendMessage(hwndAdd, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_OTHER_DELETE)); SetWindowText(hwndAdd, TranslateT("Revert to default")); EnableWindow(hwndAdd, TRUE); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Show always when available")); SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Hide always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Default (global setting)")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Never")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Always")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When space is available")); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_INSERTSTRING, -1, (LPARAM)TranslateT("When needed by status message")); if (cfg::clcdat) { Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr); if (contact && contact->type != CLCIT_CONTACT) { DestroyWindow(hWnd); return FALSE; } else { wchar_t szTitle[512]; DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0); BYTE bSecondLine = db_get_b(hContact, "CList", "CLN_2ndline", -1); mir_snwprintf(szTitle, TranslateT("Contact list display and ignore options for %s"), contact ? contact->szText : Clist_GetContactDisplayName(hContact)); SetWindowText(hWnd, szTitle); Window_SetSkinIcon_IcoLib(hWnd, SKINICON_OTHER_MIRANDA); pCaps = CallProtoService(contact ? contact->proto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_PRIORITY, db_get_b(hContact, "CList", "Priority", 0) ? BST_CHECKED : BST_UNCHECKED); Utils::enableDlgControl(hWnd, IDC_IGN_PRIORITY, TRUE); Utils::enableDlgControl(hWnd, IDC_AVATARDISPMODE, TRUE); Utils::enableDlgControl(hWnd, IDC_SECONDLINEMODE, TRUE); if (dwFlags & ECF_FORCEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 1, 0); else if (dwFlags & ECF_HIDEAVATAR) SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 2, 0); else SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); if (dwFlags & ECF_FORCEOVERLAY) CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_CHECKED); else if (dwFlags & ECF_HIDEOVERLAY) CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_UNCHECKED); else CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE); if (dwFlags & ECF_FORCELOCALTIME) CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_CHECKED); else if (dwFlags & ECF_HIDELOCALTIME) CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_UNCHECKED); else CheckDlgButton(hWnd, IDC_SHOWLOCALTIME1, BST_INDETERMINATE); if (bSecondLine == 0xff) SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); else SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, (WPARAM)(bSecondLine + 1), 0); } } WindowList_Add(hWindowListIGN, hWnd, hContact); ShowWindow(hWnd, SW_SHOWNORMAL); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_IGN_PRIORITY: SendMessage(g_clistApi.hwndContactTree, CLM_TOGGLEPRIORITYCONTACT, hContact, 0); return 0; case IDC_IGN_ALL: SendMessage(hWnd, WM_USER + 100, hContact, (LPARAM)0xffffffff); return 0; case IDC_IGN_NONE: SendMessage(hWnd, WM_USER + 100, hContact, 0); return 0; case IDC_IGN_ALWAYSONLINE: if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, BST_UNCHECKED); break; case IDC_IGN_ALWAYSOFFLINE: if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, BST_UNCHECKED); break; case IDC_HIDECONTACT: db_set_b(hContact, "CList", "Hidden", (BYTE)(IsDlgButtonChecked(hWnd, IDC_HIDECONTACT) ? 1 : 0)); break; case IDC_IGN_ADDPERMANENTLY: Contact_Add(hContact, hWnd); Utils::enableDlgControl(hWnd, IDC_IGN_ADDPERMANENTLY, db_get_b(hContact, "CList", "NotOnList", 0)); break; case IDC_DSP_LOADDEFAULT: SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_SETCURSEL, 0, 0); SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_SETCURSEL, 0, 0); CheckDlgButton(hWnd, IDC_OVERLAYICON, BST_INDETERMINATE); CheckDlgButton(hWnd, IDC_LOCALTIME, BST_INDETERMINATE); break; case IDOK: { DWORD newMask = 0; ClcContact *contact = nullptr; SendMessage(hWnd, WM_USER + 110, 0, (LPARAM)&newMask); db_set_dw(hContact, "Ignore", "Mask1", newMask); SendMessage(hWnd, WM_USER + 130, 0, 0); if (cfg::clcdat) { LRESULT iSel = SendDlgItemMessage(hWnd, IDC_AVATARDISPMODE, CB_GETCURSEL, 0, 0); DWORD dwFlags = db_get_dw(hContact, "CList", "CLN_Flags", 0), dwXMask = 0; LRESULT checked = 0; Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr); if (iSel != CB_ERR) { dwFlags &= ~(ECF_FORCEAVATAR | ECF_HIDEAVATAR); if (iSel == 1) dwFlags |= ECF_FORCEAVATAR; else if (iSel == 2) dwFlags |= ECF_HIDEAVATAR; if (contact) LoadAvatarForContact(contact); } dwFlags &= ~(ECF_FORCEOVERLAY | ECF_HIDEOVERLAY | ECF_FORCELOCALTIME | ECF_HIDELOCALTIME); checked = IsDlgButtonChecked(hWnd, IDC_OVERLAYICON); if (checked == BST_CHECKED) dwFlags |= ECF_FORCEOVERLAY; else if (checked == BST_UNCHECKED) dwFlags |= ECF_HIDEOVERLAY; checked = IsDlgButtonChecked(hWnd, IDC_SHOWLOCALTIME1); if (checked == BST_CHECKED) dwFlags |= ECF_FORCELOCALTIME; else if (checked == BST_UNCHECKED) dwFlags |= ECF_HIDELOCALTIME; db_set_dw(hContact, "CList", "CLN_Flags", dwFlags); if ((iSel = SendDlgItemMessage(hWnd, IDC_SECONDLINEMODE, CB_GETCURSEL, 0, 0)) != CB_ERR) { if (iSel == 0) { db_unset(hContact, "CList", "CLN_2ndline"); if (contact) contact->bSecondLine = cfg::dat.dualRowMode; } else { db_set_b(hContact, "CList", "CLN_2ndline", (BYTE)(iSel - 1)); if (contact) contact->bSecondLine = (BYTE)(iSel - 1); } } db_set_dw(hContact, "CList", "CLN_xmask", dwXMask); if (contact) { if (contact->pExtra) contact->pExtra->dwDFlags = dwFlags; } else { TExtraCache *p = cfg::getCache(hContact, nullptr); if (p) p->dwDFlags = dwFlags; } db_set_b(hContact, "CList", "Priority", (BYTE)(IsDlgButtonChecked(hWnd, IDC_IGN_PRIORITY) ? 1 : 0)); Clist_Broadcast(CLM_AUTOREBUILD, 0, 0); } } case IDCANCEL: DestroyWindow(hWnd); break; } break; case WM_USER + 100: // fill dialog (wParam = hContact, lParam = mask) CheckDlgButton(hWnd, IDC_IGN_MSGEVENTS, lParam & (1 << (IGNOREEVENT_MESSAGE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_FILEEVENTS, lParam & (1 << (IGNOREEVENT_FILE - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_URLEVENTS, lParam & (1 << (IGNOREEVENT_URL - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_AUTH, lParam & (1 << (IGNOREEVENT_AUTHORIZATION - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ADD, lParam & (1 << (IGNOREEVENT_YOUWEREADDED - 1)) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ONLINE, lParam & (1 << (IGNOREEVENT_USERONLINE - 1)) ? BST_CHECKED : BST_UNCHECKED); return 0; case WM_USER + 110: // retrieve value { DWORD *dwNewMask = (DWORD *)lParam, dwMask = 0; dwMask = (IsDlgButtonChecked(hWnd, IDC_IGN_MSGEVENTS) ? (1 << (IGNOREEVENT_MESSAGE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_FILEEVENTS) ? (1 << (IGNOREEVENT_FILE - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_URLEVENTS) ? (1 << (IGNOREEVENT_URL - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_AUTH) ? (1 << (IGNOREEVENT_AUTHORIZATION - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ADD) ? (1 << (IGNOREEVENT_YOUWEREADDED - 1)) : 0) | (IsDlgButtonChecked(hWnd, IDC_IGN_ONLINE) ? (1 << (IGNOREEVENT_USERONLINE - 1)) : 0); if (dwNewMask) *dwNewMask = dwMask; } return 0; case WM_USER + 120: // set visibility status { ClcContact *contact = nullptr; if (Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) { if (contact) { WORD wApparentMode = db_get_w(contact->hContact, contact->proto, "ApparentMode", 0); CheckDlgButton(hWnd, IDC_IGN_ALWAYSOFFLINE, wApparentMode == ID_STATUS_OFFLINE ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_IGN_ALWAYSONLINE, wApparentMode == ID_STATUS_ONLINE ? BST_CHECKED : BST_UNCHECKED); } } } return 0; case WM_USER + 130: // update apparent mode { ClcContact *contact = nullptr; if (Clist_FindItem(g_clistApi.hwndContactTree, cfg::clcdat, hContact, &contact, nullptr, nullptr)) { if (contact) { WORD wApparentMode = 0; if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSONLINE)) wApparentMode = ID_STATUS_ONLINE; else if (IsDlgButtonChecked(hWnd, IDC_IGN_ALWAYSOFFLINE)) wApparentMode = ID_STATUS_OFFLINE; ProtoChainSend(hContact, PSS_SETAPPARENTMODE, (WPARAM)wApparentMode, 0); SendMessage(hWnd, WM_USER + 120, 0, 0); } } } return 0; case WM_DESTROY: SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); WindowList_Remove(hWindowListIGN, hWnd); break; } return FALSE; }
UIButton * ControlsFactory::CreateButton(Vector2 pos, const WideString &buttonText, bool designers) { UIButton *btn = new UIButton(Rect(pos.x, pos.y, BUTTON_WIDTH, BUTTON_HEIGHT)); CustomizeButton(btn, buttonText, designers); return btn; }
void TSAPI BB_InitDlgButtons(TWindowData *dat) { RECT rect; int i; int lwidth = 0, rwidth = 0; RECT rcSplitter; POINT ptSplitter; int splitterY; BYTE gap = DPISCALEX_S(PluginConfig.g_iButtonsBarGap); BOOL isThemed = TRUE; int cx = 0, cy = 0; int lcount = LButtonsList.getCount(); int rcount = RButtonsList.getCount(); HWND hdlg = dat->hwnd; if (dat == 0 || hdlg == 0) { return; } if (CSkin::m_skinEnabled && !SkinItems[ID_EXTBKBUTTONSNPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSPRESSED].IGNORED && !SkinItems[ID_EXTBKBUTTONSMOUSEOVER].IGNORED) { isThemed = FALSE; } GetWindowRect(GetDlgItem(hdlg, (dat->bType == SESSIONTYPE_IM) ? IDC_SPLITTER : IDC_SPLITTERY), &rcSplitter); ptSplitter.x = 0; ptSplitter.y = rcSplitter.top; ScreenToClient(hdlg, &ptSplitter); GetClientRect(hdlg, &rect); splitterY = ptSplitter.y - DPISCALEY_S(1); HWND hwndBtn = NULL; for (i = 0; i < RButtonsList.getCount(); i++) { CustomButtonData *cbd = RButtonsList[i]; if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) { if (!cbd->bHidden) rwidth += cbd->iButtonWidth + gap; if (!cbd->bHidden && !cbd->bCanBeHidden) dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap; if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) { hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, rect.right - rwidth + gap, splitterY, cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL); CustomizeButton(hwndBtn); } if (!cbd->bSeparator && hwndBtn) { SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0); SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0); if (cbd->hIcon) SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon)); if (cbd->ptszTooltip) SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR); SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0); if (hwndBtn && cbd->dwArrowCID) SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0); if (hwndBtn && cbd->bPushButton) SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0); } } else if (GetDlgItem(hdlg, cbd->dwButtonCID)) DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID)); if (cbd->bDisabled) EnableWindow(hwndBtn, 0); if (cbd->bHidden) ShowWindow(hwndBtn, SW_HIDE); } hwndBtn = NULL; for (i = 0; i < LButtonsList.getCount(); i++) { CustomButtonData *cbd = LButtonsList[i]; if (((dat->bType == SESSIONTYPE_IM && cbd->bIMButton) || (dat->bType == SESSIONTYPE_CHAT && cbd->bChatButton))) { if (!cbd->bSeparator && !GetDlgItem(hdlg, cbd->dwButtonCID)) { hwndBtn = CreateWindowEx(0, _T("MButtonClass"), _T(""), WS_CHILD | WS_VISIBLE | WS_TABSTOP, 2 + lwidth, splitterY, cbd->iButtonWidth, DPISCALEY_S(22), hdlg, (HMENU)cbd->dwButtonCID, g_hInst, NULL); CustomizeButton(hwndBtn); } if (!cbd->bHidden) lwidth += cbd->iButtonWidth + gap; if (!cbd->bHidden && !cbd->bCanBeHidden) dat->iButtonBarReallyNeeds += cbd->iButtonWidth + gap; if (!cbd->bSeparator && hwndBtn) { SendMessage(hwndBtn, BUTTONSETASFLATBTN, TRUE, 0); SendMessage(hwndBtn, BUTTONSETASTHEMEDBTN, isThemed != 0, 0); if (cbd->hIcon) SendMessage(hwndBtn, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_GetIconByHandle(cbd->hIcon)); if (cbd->ptszTooltip) SendMessage(hwndBtn, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(cbd->ptszTooltip), BATF_TCHAR); SendMessage(hwndBtn, BUTTONSETCONTAINER, (LPARAM)dat->pContainer, 0); SendMessage(hwndBtn, BUTTONSETASTOOLBARBUTTON, TRUE, 0); if (hwndBtn && cbd->dwArrowCID) SendMessage(hwndBtn, BUTTONSETARROW, cbd->dwArrowCID, 0); if (hwndBtn && cbd->bPushButton) SendMessage(hwndBtn, BUTTONSETASPUSHBTN, TRUE, 0); } } else if (GetDlgItem(hdlg, cbd->dwButtonCID)) DestroyWindow(GetDlgItem(hdlg, cbd->dwButtonCID)); if (cbd->bDisabled) EnableWindow(hwndBtn, 0); if (cbd->bHidden) ShowWindow(hwndBtn, SW_HIDE); } dat->bbLSideWidth = lwidth; dat->bbRSideWidth = rwidth; }
UIButton * ControlsFactory::CreateButton(const Rect & rect, const WideString &buttonText, bool designers) { UIButton *btn = new UIButton(rect); CustomizeButton(btn, buttonText, designers); return btn; }