BOOL OnDrawItem(DRAWITEMSTRUCT *lps) { if (m_adding) return FALSE; if (lps->itemID == -1) return TRUE; if (!lps->itemData) return TRUE; HDC hdc = lps->hDC; CNoteItem *pNote = (CNoteItem *)lps->itemData; SetBkMode(hdc, TRANSPARENT); if (lps->itemState & ODS_SELECTED) { FillRect(hdc, &lps->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { FillRect(hdc, &lps->rcItem, GetSysColorBrush(COLOR_WINDOW)); SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); } if (lps->itemID) { RECT rcTmp = lps->rcItem; rcTmp.bottom = rcTmp.top+1; FillRect(hdc, &rcTmp, GetSysColorBrush(COLOR_BTNSHADOW)); } RECT rc = lps->rcItem; rc.left += 5; rc.right -= 5; rc.top += 2; SelectObject(hdc, m_hfntBold); rc.top += DrawText(hdc, pNote->GetTitle(), -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS); SelectObject(hdc, m_hfntNormal); if (pNote->GetFrom()) { TCHAR buf[256]; mir_sntprintf(buf, SIZEOF(buf), TranslateT("From: %s"), pNote->GetFrom()); rc.top += DrawText(hdc, buf, -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS); } rc.top += DrawText(hdc, pNote->GetText(), -1, &rc, DT_NOPREFIX|DT_WORDBREAK|DT_EXPANDTABS|DT_END_ELLIPSIS); SelectObject(hdc, m_hfntSmall); rc.top += DrawText(hdc, pNote->GetTagsStr(), -1, &rc, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS); rc.top += 5; int h = min(255, max(0, rc.bottom - rc.top)); if (SendMessage(m_hwnd, LB_GETITEMHEIGHT, lps->itemID, 0) != h) SendMessage(m_hwnd, LB_SETITEMHEIGHT, lps->itemID, h); return TRUE; }
void CJabberDlgNoteItem::OnInitDialog() { CSuper::OnInitDialog(); WindowSetIcon(m_hwnd, m_proto, "notes"); if (m_fnProcess) { CMString buf; if (m_fnProcess == &CJabberProto::ProcessIncomingNote) buf.Format(TranslateT("Incoming note from %s"), m_pNote->GetFrom()); else buf.Format(TranslateT("Send note to %s"), m_pNote->GetFrom()); SetWindowText(m_hwnd, buf); } m_txtTitle.SetText(m_pNote->GetTitle()); m_txtText.SetText(m_pNote->GetText()); m_txtTags.SetText(m_pNote->GetTagsStr()); }
BOOL OnMeasureItem(MEASUREITEMSTRUCT *lps) { if (m_adding) return FALSE; if (lps->itemID == -1) return TRUE; if (!lps->itemData) return TRUE; HDC hdc = GetDC(m_hwnd); CNoteItem *pNote = (CNoteItem *)lps->itemData; RECT rcTmp, rc; GetClientRect(m_hwnd, &rc); int maxHeight = rc.bottom - 10; rc.bottom = 0; SelectObject(hdc, m_hfntBold); rcTmp = rc; DrawText(hdc, pNote->GetTitle(), -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT); lps->itemHeight += rcTmp.bottom; SelectObject(hdc, m_hfntNormal); if (pNote->GetFrom()) { TCHAR buf[256]; mir_sntprintf(buf, SIZEOF(buf), TranslateT("From: %s"), pNote->GetFrom()); rcTmp = rc; DrawText(hdc, buf, -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT); lps->itemHeight += rcTmp.bottom; } rcTmp = rc; DrawText(hdc, pNote->GetText(), -1, &rcTmp, DT_NOPREFIX|DT_WORDBREAK|DT_EXPANDTABS|DT_END_ELLIPSIS|DT_CALCRECT); lps->itemHeight += rcTmp.bottom; SelectObject(hdc, m_hfntSmall); rcTmp = rc; DrawText(hdc, pNote->GetTagsStr(), -1, &rcTmp, DT_NOPREFIX|DT_SINGLELINE|DT_END_ELLIPSIS|DT_CALCRECT); lps->itemHeight += rcTmp.bottom; lps->itemHeight += 5; ReleaseDC(m_hwnd, hdc); lps->itemWidth = rc.right; lps->itemHeight = min(255, lps->itemHeight); // listbox can't make items taller then 255px return TRUE; }
void CJabberDlgNoteItem::OnInitDialog() { CSuper::OnInitDialog(); WindowSetIcon( m_hwnd, m_proto, "notes" ); if (m_fnProcess) { TCHAR buf[256]; if (m_fnProcess == &CJabberProto::ProcessIncomingNote) mir_sntprintf(buf, SIZEOF(buf), TranslateT("Incoming note from %s"), m_pNote->GetFrom()); else mir_sntprintf(buf, SIZEOF(buf), TranslateT("Send note to %s"), m_pNote->GetFrom()); SetWindowText(m_hwnd, buf); } m_txtTitle.SetText(m_pNote->GetTitle()); m_txtText.SetText(m_pNote->GetText()); m_txtTags.SetText(m_pNote->GetTagsStr()); }
void btnOk_OnClick(CCtrlButton *) { TCHAR *szTitle = m_txtTitle.GetText(); TCHAR *szText = m_txtText.GetText(); TCHAR *szTags = m_txtTags.GetText(); TCHAR *szFrom = mir_tstrdup(m_pNote->GetFrom()); m_pNote->SetData(szTitle, szFrom, szText, szTags); mir_free(szTitle); mir_free(szText); mir_free(szTags); mir_free(szFrom); m_autoClose = false; if (m_fnProcess) (m_proto->*m_fnProcess)(m_pNote, true); EndDialog(m_hwnd, TRUE); }