BOOL COXTreeItem::SetFont(int nCol, CFont* pFont) { if(nCol == 0) { if(pFont==NULL) { dwStateEx &= ~XTIS_HASFONT; return TRUE; } LOGFONT lf; if(!pFont->GetLogFont(&lf)) { return FALSE; } if((HFONT)m_font!=NULL) { m_font.DeleteObject(); } if(m_font.CreateFontIndirect(&lf)) { dwStateEx |= XTIS_HASFONT; return TRUE; } return FALSE; } else { COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) return FALSE; return pSubItem->SetFont(pFont); } }
BOOL CItemList::ModifySubItem(DWORD index, DWORD subitem, LPVOID data, HICON icon, DWORD type, DWORD flags ) { LPLISTSUBITEMINFO sitem = GetSubItem( index, subitem ); if ( sitem == NULL ) return FALSE; // Remove old data DeleteSubItemData( sitem ); // Zero memory // ZeroMemory( sitem, sizeof( LISTSUBITEMINFO ) ); // Save data sitem->type = type; sitem->flags = flags; sitem->icon = icon; switch( type ) { case SIT_TEXT : sitem->data = new char[ strlen( (char*)data ) + 2 ]; if ( sitem->data != NULL ) strcpy( (char*)sitem->data, (char*)data ); break; default: sitem->data = data; break; } // end switch return TRUE; }
void COXTreeItem::SetEditMode(UINT uMode,CStringArray& saTextEx,int nCol) { if(nCol == 0) { //set main item switch(uMode) { case OXET_EDIT: case OXET_NOEDIT: case OXET_COMBO: case OXET_CALENDAR: m_uEditMode = uMode; break; default: // Undefined edit mode found! ASSERT(FALSE); break; } m_saTextEx.RemoveAll(); for(int i=0;i < saTextEx.GetSize();i++) m_saTextEx.SetAtGrow(i,saTextEx[i]); } else { COXTreeSubItem *pSubItem = GetSubItem(nCol); ASSERT(pSubItem); if(pSubItem) pSubItem->SetEditMode(uMode,saTextEx); } }
BOOL COutlook2Ctrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (nHitTest == HTCLIENT) { CPoint point; ::GetCursorPos (&point); ScreenToClient (&point); if (m_iDragging || m_dragRect.PtInRect(point)) { SetCursor(hDragCur); return TRUE; } int f,i,s; int r = HitTest(f,i,s,point); if (r == 4) { COL2SubItem * ps = GetSubItem(f,i,s); if (ps->dwStyle == 2) // item is hotlinked { SetCursor(hHandCur); return TRUE; } } if (r == 1) { SetCursor(hHandCur); return TRUE; } } return OLCTRL2_BASE_CLASS::OnSetCursor(pWnd, nHitTest, message); }
int COXTreeItem::GetSubItemImage(int nCol) const { COXTreeSubItem *pSubItem = GetSubItem(nCol); if(pSubItem) return pSubItem->HasImage() ? pSubItem->nImage:-1; else return -1; }
LPCTSTR COXTreeItem::GetSubItemText(int nCol) const { COXTreeSubItem *pSubItem = GetSubItem(nCol); if(pSubItem) return pSubItem->sItem; else return _T(""); }
BOOL COXTreeItem::HasBackColor(int nCol) const { if(!nCol) return (BOOL)(dwStateEx & XTIS_HASBGCOLOR); COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) return FALSE; return pSubItem->HasBackColor(); }
BOOL COXTreeItem::HasFont(int nCol) const { if(!nCol) return (BOOL)(dwStateEx & XTIS_HASFONT); COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) return FALSE; return pSubItem->HasFont(); }
BOOL CItemList::SetSubItemFlags(DWORD index, DWORD subitem, DWORD flags ) { LPLISTSUBITEMINFO plsii = GetSubItem( index, subitem ); if ( plsii == NULL ) return FALSE; // Save data plsii->flags = flags; return TRUE; }
BOOL CItemList::SetSubItemBckColor(DWORD index, DWORD subitem, COLORREF rgb) { LPLISTSUBITEMINFO plsii = GetSubItem( index, subitem ); if ( plsii == NULL ) return FALSE; // Save data plsii->rgbbck = rgb; return TRUE; }
BOOL CItemList::SetSubItemIcon(DWORD index, DWORD subitem, HICON icon) { LPLISTSUBITEMINFO plsii = GetSubItem( index, subitem ); if ( plsii == NULL ) return FALSE; // Save data plsii->icon = icon; return TRUE; }
CStringArray& COXTreeItem::GetTextEx(int nCol) { if(nCol == 0) return m_saTextEx; COXTreeSubItem *pSubItem = GetSubItem(nCol); ASSERT(pSubItem); return pSubItem->GetTextEx(); }
UINT COXTreeItem::GetEditMode(int nCol) const { if(nCol == 0) return m_uEditMode; COXTreeSubItem *pSubItem = GetSubItem(nCol); ASSERT(pSubItem); if(pSubItem) return pSubItem->GetEditMode(); return 0; }
BOOL CItemList::SetSubItemData(DWORD item, DWORD subitem, DWORD data) { // Get sub item LPLISTSUBITEMINFO plsii = GetSubItem( item, subitem ); if ( plsii == NULL ) return FALSE; plsii->user = data; return TRUE; }
DWORD CItemList::FindString(DWORD dwCol, LPCTSTR pStr) { for( DWORD i = 0; i < m_dwPtr; i++ ) { LPLISTSUBITEMINFO plsii = GetSubItem( i, dwCol ); if ( plsii != NULL && plsii->type == SIT_TEXT && !strcmpi( (LPCTSTR)plsii->data, pStr ) ) return i; } // end for return MAXDWORD; }
void COXTreeItem::SetDrawEllipsis(UINT nEllipsisFormat, int nCol/*=0*/) { ASSERT(nEllipsisFormat==DT_END_ELLIPSIS || nEllipsisFormat==DT_PATH_ELLIPSIS || nEllipsisFormat==DT_WORD_ELLIPSIS); if(nCol==0) m_nEllipsisFormat = nEllipsisFormat; else { COXTreeSubItem *pSubItem = GetSubItem(nCol); ASSERT(pSubItem!=NULL); pSubItem->SetDrawEllipsis(nEllipsisFormat); } }
COLORREF COXTreeItem::GetItemBackColor(int nCol) const { ASSERT(HasBackColor(nCol)); if(!nCol) return m_clrBackground; COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) { ASSERT(FALSE); return 0; } return pSubItem->m_clrBackground; }
UINT COXTreeItem::GetDrawEllipsis(int nCol/*=0*/) const { if(nCol==0) return m_nEllipsisFormat; else { COXTreeSubItem *pSubItem = GetSubItem(nCol); if(pSubItem!=NULL) return pSubItem->GetDrawEllipsis(); else return DT_END_ELLIPSIS; } }
HBREADCRUMBITEM CBCGPBreadcrumb::GetSubItemByName (HBREADCRUMBITEM hParentItem, const CString& itemName) const { int n = GetSubItemsCount (hParentItem); for (int i = 0; i < n; ++i) { HBREADCRUMBITEM hSubItem = GetSubItem (hParentItem, i); if (GetItemText (hSubItem).CompareNoCase (itemName) == 0) { return hSubItem; } } return NULL; }
BOOL CItemList::GetSubItemData(DWORD item, DWORD subitem, LPDWORD pdwData) { // Sanity check if ( pdwData == NULL ) return FALSE; // Get sub item LPLISTSUBITEMINFO plsii = GetSubItem( item, subitem ); if ( plsii == NULL ) return FALSE; *pdwData = plsii->user; return TRUE; }
void COXTreeItem::SetTextEx(CStringArray& saText,int nCol) { if(nCol == 0) { m_saTextEx.RemoveAll(); for(int i=0;i < saText.GetSize();i++) m_saTextEx.SetAtGrow(i,saText[i]); } else { COXTreeSubItem *pSubItem = GetSubItem(nCol); ASSERT(pSubItem); pSubItem->SetTextEx(saText); } }
CFont* COXTreeItem::GetItemFont(int nCol) { if(!HasFont(nCol)) return NULL; if(!nCol) { return &m_font; } else { COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) return NULL; return &(pSubItem->m_font); } }
BOOL CItemList::GetSubItemText(DWORD item, DWORD subitem, LPSTR buf, DWORD size) { LPLISTSUBITEMINFO plsii = GetSubItem( item, subitem ); if ( plsii == NULL ) return FALSE; // Is it in fact text? if ( plsii->type != SIT_TEXT ) return FALSE; // Copy text string strncpy( buf, (char*)plsii->data, size ); // NULL terminate to be sure buf[ size - 1 ] = NULL; return TRUE; }
void COutlook2Ctrl::OnLButtonDown(UINT nFlags, CPoint point) { if (m_iSize <= 4 || m_dragRect.PtInRect(point)) { m_iDragoffset = m_iSize - point.x; m_iDragging = 1; SetCursor(hDragCur); SetCapture(); SetFocus(); CRect rc; GetClientRect(rc); OnInvertTracker(m_dragRect); return; } int f,i,s; int r = HitTest(f,i,s,point); if (r == 1) { SetCurFolder(f); } if (r == 4) { COL2SubItem * ps = GetSubItem(f,i,s); if (ps->dwStyle == 2 || ps->dwStyle == 3) // item is hotlinked or checkbox { AfxGetMainWnd()->SendMessage(WM_COMMAND, MAKELONG(ps->lParam, 0), (LPARAM) GetSafeHwnd()); InvalidateRect(rcInnerRect, FALSE); } if (ps->dwStyle == 0 || ps->dwStyle == 1) // item is radio or singlelist .. check before sending { COL2CCmdUI pui; pui.pSI = ps; pui.m_nID = ps->lParam; AfxGetMainWnd()->OnCmdMsg(pui.m_nID, CN_UPDATE_COMMAND_UI, &pui, NULL); if (!(pui.iRes & 2)) // not checked yet .. so let's do it AfxGetMainWnd()->SendMessage(WM_COMMAND, MAKELONG(ps->lParam, 0), (LPARAM) GetSafeHwnd()); InvalidateRect(rcInnerRect, FALSE); } } OLCTRL2_BASE_CLASS::OnLButtonDown(nFlags, point); }
BOOL COXTreeItem::SetSubItem(int nCol,UINT uMask,LPCTSTR lpszText,int nImage, CFont * pFont,COLORREF clr, COLORREF clrBack) { if(nCol == -1 || nCol == 0) { ASSERT(FALSE); return FALSE; } COXTreeSubItem *pSubItem = GetSubItem(nCol); if(!pSubItem) { pSubItem = new COXTreeSubItem(nCol); m_Items.Add(pSubItem); } ASSERT(pSubItem); if(uMask & OX_SUBITEM_IMAGE) { pSubItem->nImage = nImage; pSubItem->uFlags |= OX_SUBITEM_IMAGE; } if(uMask & OX_SUBITEM_TEXT) { pSubItem->sItem = lpszText; pSubItem->uFlags |= OX_SUBITEM_TEXT; } if(uMask & OX_SUBITEM_FONT) pSubItem->SetFont(pFont); if(uMask & OX_SUBITEM_COLOR) { pSubItem->m_clr = clr; pSubItem->uFlags |= OX_SUBITEM_COLOR; } if(uMask & OX_SUBITEM_BGCOLOR) { pSubItem->m_clrBackground = clrBack; pSubItem->uFlags |= OX_SUBITEM_BGCOLOR; } return TRUE; }
void COutlook2Ctrl::OnMouseMove(UINT nFlags, CPoint point) { if (m_iDragging == 1) { CRect rc1(m_dragRect); m_dragRect.SetRect(point.x-5 + m_iDragoffset, rc1.top, point.x + m_iDragoffset, rc1.bottom); if (rc1 != m_dragRect) { OnInvertTracker(rc1); OnInvertTracker(m_dragRect); } } else { int f,i,s; int r = HitTest(f,i,s,point); if (r == 1) { CClientDC dc(this); if (iHiFolder >= 0 && iHiFolder != f) { DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false); } if (iHiFolder != f) { iHiFolder = f; DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, true); } } if (r == 4) { COL2SubItem * ps = GetSubItem(f,i,s); CClientDC dc(this); if (pLastHilink && pLastHilink != ps) { DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false); } if (pLastHilink != ps) { pLastHilink = ps; DrawSubItem(&dc, GetFolder(f), GetItem(f,i), ps, true); iHilinkFolder = f; iHilinkItem = i; } } if (r == 0) { if (iHiFolder >= 0) { CClientDC dc(this); DrawButton(&dc, (COL2Folder *) m_Folders.GetAt(iHiFolder), iHiFolder == m_iSelectedFolder, false); iHiFolder = -1; } if (pLastHilink != NULL) { CClientDC dc(this); DrawSubItem(&dc, GetFolder(iHilinkFolder), GetItem(iHilinkFolder, iHilinkItem), pLastHilink, false); pLastHilink = NULL; } } } OLCTRL2_BASE_CLASS::OnMouseMove(nFlags, point); }