void CContainerItem::UpdateFromServerExtent() { CSize size; if (GetCachedExtent(&size)) { // OLE returns the extent in HIMETRIC units -- we need pixels CClientDC dc(NULL); dc.HIMETRICtoDP(&size); // Only invalidate if it has actually changed, and also // only if it is not in-place active. When in-place active, the // container item size should sync with the "window size" of the // object. Only when not in-place active should the container // item size should sync with the natural size of the object. if ((size != m_rect.Size()) && !IsInPlaceActive()) { // invalidate old, update, invalidate new InvalidateItem(); m_rect.bottom = m_rect.top + size.cy; m_rect.right = m_rect.left + size.cx; InvalidateItem(); // mark document as modified GetDocument()->SetModifiedFlag(); } } }
static void OnSpKeyDown(WPARAM wParam, LPARAM lParam) { switch(wParam){ case VK_TAB: if(!IsWindowVisible(g_hWnd)){ OnListUpdate(); } else{ if(!g_Shift){ g_WndList->MoveCursor(1); } else{ g_WndList->MoveCursor(-1); } InvalidateItem(); } break; case VK_ESCAPE: case VK_KANJI: HideWindow(); break; case VK_UP: g_WndList->MoveCursor(-1); InvalidateItem(); break; case VK_DOWN: g_WndList->MoveCursor(1); InvalidateItem(); break; case VK_LSHIFT: case VK_RSHIFT: g_Shift = TRUE; break; } }
// SetItemFocused void DragSortableListView::SetItemFocused(int32 index) { InvalidateItem(fFocusedIndex); InvalidateItem(index); fFocusedIndex = index; }
BOOL CContainerItem::OnChangeItemPosition(const CRect& rectPos) { ASSERT_VALID(this); // During in-place activation CContainerItem::OnChangeItemPosition // is called by the server to change the position of the in-place // window. Usually, this is a result of the data in the server // document changing such that the extent has changed or as a result // of in-place resizing. // // The default here is to call the base class, which will call // COleClientItem::SetItemRects to move the item // to the new position. if (!COleClientItem::OnChangeItemPosition(rectPos)) return FALSE; InvalidateItem(); m_rect = rectPos; InvalidateItem(); // mark document as dirty GetDocument()->SetModifiedFlag(); return TRUE; }
void _ArpControllerRangeList::SelectionChanged() { inherited::SelectionChanged(); int32 selection = CurrentSelection(); BMessage update('iupd'); if (selection >= 0) { BListItem* item; for (int32 k = 0; (item = ItemAt(k)); k++) { _ArpControllerRangeItem* ccItem = dynamic_cast<_ArpControllerRangeItem*>(item); if (ccItem) { if ( IsItemSelected(k) ) { update.AddInt32(mSettingsKey.String(), k); if ( !ccItem->IsActive() ) { ccItem->SetActive(true); InvalidateItem(k); } } else { if ( ccItem->IsActive() ) { ccItem->SetActive(false); InvalidateItem(k); } } } } } if (mTarget) { mTarget->Implementation().SendConfiguration(&update); mTarget->Settings().Update(update); } }
void CPlugToolBar::OnMouseMove(UINT nFlags, CPoint point) { BOOL bOutside; int i; i = ItemFromPoint (point, bOutside); if (bOutside) { if (m_iMayBeSelected != -1) { InvalidateItem (m_iMayBeSelected); ReleaseCapture (); } m_iMayBeSelected = m_iPressed = -1; return; } CRect rcItem; GetItemRect (i, &rcItem); CPoint pt (rcItem.left + (rcItem.right - rcItem.left) / 2 - 32/2, rcItem.top + 5); rcItem.left = pt.x; rcItem.top = pt.y; rcItem.right = pt.x + 32; rcItem.bottom = pt.y + 32; if (!PtInRect (&rcItem, point)) { if (m_iMayBeSelected != -1) { InvalidateItem (m_iMayBeSelected); ReleaseCapture (); } m_iMayBeSelected = m_iPressed = -1; return; } if (m_iMayBeSelected == i) return; else if (m_iMayBeSelected != -1) { InvalidateItem (m_iMayBeSelected); ReleaseCapture (); } m_iMayBeSelected = i; m_iPressed = -1; InvalidateItem (i); SetCapture (); CListBox::OnMouseMove(nFlags, point); }
/***************************************************************************** * PlaylistView::SetCurrent *****************************************************************************/ void PlaylistView::SetCurrent( int32 index ) { if ( fCurrentIndex != index ) { InvalidateItem( fCurrentIndex ); fCurrentIndex = index; InvalidateItem( fCurrentIndex ); } }
void MimeTypeListView::_MakeTypesUnique(MimeTypeItem* underItem) { SortItemsUnder(underItem, underItem != NULL, &MimeTypeItem::Compare); bool lastItemSame = false; MimeTypeItem* last = NULL; int32 index = 0; uint32 level = 0; if (underItem != NULL) { index = FullListIndexOf(underItem) + 1; level = underItem->OutlineLevel() + 1; } for (; index < FullListCountItems(); index++) { MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(FullListItemAt(index)); if (item == NULL) continue; if (item->OutlineLevel() < level) { // left sub-tree break; } item->SetText(item->Description()); if (last == NULL || MimeTypeItem::CompareLabels(last, item)) { if (lastItemSame) { last->AddSubtype(); if (Window()) InvalidateItem(IndexOf(last)); } lastItemSame = false; last = item; continue; } lastItemSame = true; last->AddSubtype(); if (Window()) InvalidateItem(IndexOf(last)); last = item; } if (lastItemSame) { last->AddSubtype(); if (Window()) InvalidateItem(IndexOf(last)); } }
void CFX_ListCtrl::SetCaret(int32_t nItemIndex) { if (!IsValid(nItemIndex)) return; if (IsMultipleSel()) { int32_t nOldIndex = m_nCaretIndex; if (nOldIndex != nItemIndex) { m_nCaretIndex = nItemIndex; InvalidateItem(nOldIndex); InvalidateItem(nItemIndex); } } }
void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, bool bSelected) { if (!IsValid(nItemIndex)) return; if (bSelected != IsItemSelected(nItemIndex)) { if (bSelected) { SetItemSelect(nItemIndex, true); InvalidateItem(nItemIndex); } else { SetItemSelect(nItemIndex, false); InvalidateItem(nItemIndex); } } }
void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) { if (!IsValid(nItemIndex)) return; if (m_nSelItem != nItemIndex) { if (m_nSelItem >= 0) { SetItemSelect(m_nSelItem, false); InvalidateItem(m_nSelItem); } SetItemSelect(nItemIndex, true); InvalidateItem(nItemIndex); m_nSelItem = nItemIndex; } }
void PrefListView::MouseDown(BPoint point) { BPoint cursor; ulong m_buttons; GetMouse(&cursor,&m_buttons); if (!(m_buttons & 0x2)) BOutlineListView::MouseDown(point); else { // right mouse button is for popup only :-) BMessage msg(MSG_LIST_POPUP); msg.AddPoint("point", point); int32 index = IndexOf(point); msg.AddInt32("index", index); if (index>0) { DeselectAll(); Select(index); InvalidateItem(index); } Window()->PostMessage( &msg ); } }
void CFX_ListCtrl::SetPlateRect(const CFX_FloatRect& rect) { CFX_ListContainer::SetPlateRect(rect); m_ptScrollPos.x = rect.left; SetScrollPos(CFX_PointF(rect.left, rect.top)); ReArrange(0); InvalidateItem(-1); }
// completely invalidate the cache void Clear() { for ( size_t n = 0; n < SIZE; n++ ) { InvalidateItem(n); } }
void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) { if (!IsFloatEqual(m_ptScrollPos.y, fy)) { CFX_FloatRect rcPlate = GetPlateRect(); CFX_FloatRect rcContent = GetContentRectInternal(); if (rcPlate.Height() > rcContent.Height()) { fy = rcPlate.top; } else { if (IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) { fy = rcContent.bottom + rcPlate.Height(); } else if (IsFloatBigger(fy, rcContent.top)) { fy = rcContent.top; } } m_ptScrollPos.y = fy; InvalidateItem(-1); if (m_pNotify) { if (!m_bNotifyFlag) { m_bNotifyFlag = true; m_pNotify->IOnSetScrollPosY(fy); m_bNotifyFlag = false; } } } }
void CFX_ListCtrl::Empty() { for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) delete m_aListItems.GetAt(i); m_aListItems.RemoveAll(); InvalidateItem(-1); }
void CPlugToolBar::OnLButtonDown(UINT , CPoint ) { if (m_iMayBeSelected != -1) { m_iPressed = m_iMayBeSelected; InvalidateItem (m_iPressed); } }
void JobListView::UpdateJob(Job* job) { JobItem* item = FindJob(job); if (item) { item->Update(); InvalidateItem(IndexOf(item)); } }
BOOL CTDCTaskListCtrl::InvalidateTask(DWORD dwTaskID, BOOL bUpdate) { if ((dwTaskID == 0) || !m_lcTasks.IsWindowVisible()) return TRUE; // nothing to do int nItem = FindListItem(m_lcTasks, dwTaskID); return InvalidateItem(nItem, bUpdate); }
void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) { if (!IsValid(nItemIndex)) return; if (bSelected != IsItemSelected(nItemIndex)) { if (bSelected) { SetItemSelect(nItemIndex,TRUE); InvalidateItem(nItemIndex); } else { SetItemSelect(nItemIndex,FALSE); InvalidateItem(nItemIndex); } } }
/***************************************************************************** * PlaylistView::SetPlaying *****************************************************************************/ void PlaylistView::SetPlaying( bool playing ) { if ( fPlaying != playing ) { fPlaying = playing; InvalidateItem( fCurrentIndex ); } }
void InterfacesListView::_HandleNetworkMessage(BMessage* message) { const char* name; int32 opcode; message->PrintToStream(); if (message->FindInt32("opcode", &opcode) != B_OK) return; if (message->FindString("interface", &name) != B_OK && message->FindString("device", &name) != B_OK) return; if (strcmp(name, "loop") == 0) return; InterfaceListItem* item = FindItem(name); if (item == NULL) printf("InterfaceListItem %s not found!\n", name); switch (opcode) { case B_NETWORK_INTERFACE_CHANGED: case B_NETWORK_DEVICE_LINK_CHANGED: if (item != NULL) InvalidateItem(IndexOf(item)); break; case B_NETWORK_INTERFACE_ADDED: if (item != NULL) InvalidateItem(IndexOf(item)); else AddItem(new InterfaceListItem(name)); break; case B_NETWORK_INTERFACE_REMOVED: if (item != NULL) { RemoveItem(item); delete item; } break; } }
void BComboBox::ChoiceListView::MouseMoved(BPoint where, uint32 /*transit*/, const BMessage */*dragMessage*/) { if (fTrackingMouseDown) { float h = LineHeight(); int32 oldIndex = fSelIndex; fSelIndex = (int32)floor(where.y / h); int32 choices = fParent->fChoiceList->CountChoices(); if (fSelIndex < 0 || fSelIndex >= choices) fSelIndex = -1; if (oldIndex != fSelIndex) { InvalidateItem(oldIndex); InvalidateItem(fSelIndex); } } }
void CPlugToolBar::OnLButtonUp(UINT , CPoint ) { if (m_iPressed != -1) { int i = m_iPressed; m_iPressed = -1; InvalidateItem (i); OnClickItem (i); } }
// forget the cached value of the item(s) between the given ones (inclusive) void InvalidateRange(size_t from, size_t to) { for ( size_t n = 0; n < SIZE; n++ ) { if ( m_items[n] >= from && m_items[n] <= to ) { InvalidateItem(n); } } }
void CPlugToolBar::OnCaptureChanged(CWnd *pWnd) { int i = m_iMayBeSelected; m_iPressed = m_iMayBeSelected = -1; if (i != -1) InvalidateItem (i); CListBox::OnCaptureChanged(pWnd); }
/** Adds or removes items from the selection. Returns number of changes. */ int32 AlbumView::Select(int32 index, int32 count, bool enabled) { int32 n = 0; for (int i = index; i < index + count ;i++) { AlbumItem *item = ItemAt(i); if (IsItemVisible(item) && item->IsSelected() != enabled) { item->Select(enabled); InvalidateItem(item); n++; } } return n; }
/*********************************************************** * Pulse ***********************************************************/ void HListView::Pulse() { register int32 count = fPointerList.CountItems(); while (count > 0) { HListItem* item = cast_as(ItemAt(--count), HListItem); item->RefreshTime(); if (item->IsDirty()) { InvalidateItem(IndexOf(item)); item->SetDirty(false); } } }
void CContainerItem::OnChange(OLE_NOTIFICATION nCode, DWORD dwParam) { ASSERT_VALID(this); COleClientItem::OnChange(nCode, dwParam); // When an item is being edited (either in-place or fully open) // it sends OnChange notifications for changes in the state of the // item or visual appearance of its content. switch (nCode) { case OLE_CHANGED: InvalidateItem(); UpdateFromServerExtent(); break; case OLE_CHANGED_STATE: case OLE_CHANGED_ASPECT: InvalidateItem(); break; } }
int32 AlbumView::DeselectAll() { int32 n = 0; AlbumItem *item = NULL; for (int i = 0; (item = ItemAt(i)); i++) { if (!item->IsSelected()) continue; item->Select(false); InvalidateItem(item); n++; } fLastSelected = -1; return n; }