6class STileViewDataSetObserver :
public TObjRefImpl<ILvDataSetObserver> {
8 STileViewDataSetObserver(STileView *pView)
12 STDMETHOD_(
void, onChanged)(THIS) OVERRIDE;
14 STDMETHOD_(
void, onInvalidated)(THIS) OVERRIDE;
16 STDMETHOD_(
void, OnItemChanged)(THIS_
int iItem) OVERRIDE;
23void STileViewDataSetObserver::onChanged()
25 m_pOwner->onDataSetChanged();
28void STileViewDataSetObserver::onInvalidated()
30 m_pOwner->onDataSetInvalidated();
33void STileViewDataSetObserver::OnItemChanged(
int iItem)
35 m_pOwner->onItemDataChanged(iItem);
54 m_observer.Attach(
new STileViewDataSetObserver(
this));
55 m_dwUpdateInterval = 40;
56 m_evtSet.addEvent(EVENTID(EventLVSelChanging));
57 m_evtSet.addEvent(EVENTID(EventLVSelChanged));
70 SASSERT_MSGA(FALSE,
"error: A item locator is in need before setting adapter!!!");
75 SSLOGW() <<
"the new adapter is same to previous set adapter, same as notifyDatasetChanged";
88 for (
size_t i = 0; i < m_itemRecycle.GetCount(); i++)
90 SList<SItemPanel *> *lstItemPanels = m_itemRecycle.GetAt(i);
91 SPOSITION pos = lstItemPanels->GetHeadPosition();
94 SItemPanel *pItemPanel = lstItemPanels->GetNext(pos);
99 m_itemRecycle.RemoveAll();
102 SPOSITION pos = m_lstItems.GetHeadPosition();
105 ItemInfo ii = m_lstItems.GetNext(pos);
108 m_lstItems.RemoveAll();
126 for (
int i = 0; i <
m_adapter->getViewTypeCount(); i++)
128 m_itemRecycle.Add(
new SList<SItemPanel *>());
138 CSize size = rcClient.Size();
140 szView.cx = rcClient.Width();
144 m_wBarVisible = SSB_NULL;
146 if (size.cy < szView.cy)
149 m_wBarVisible |= SSB_VERT;
151 m_siVer.nMax = szView.cy - 1;
152 m_siVer.nPage = size.cy;
153 m_siVer.nPos = smin(m_siVer.nPos, m_siVer.nMax - (
int)m_siVer.nPage);
158 m_siVer.nPage = size.cy;
160 m_siVer.nMax = size.cy - 1;
164 SetScrollPos(TRUE, m_siVer.nPos, FALSE);
201 m_adapter->getView(iItem, pItem, &xmlNode);
249 int nLastBottom = rcClient.top +
m_tvItemLocator->GetMarginSize() + nOffset;
251 SPOSITION pos = m_lstItems.GetHeadPosition();
255 ItemInfo ii = m_lstItems.GetNext(pos);
257 rcItem.OffsetRect(rcClient.left, 0);
258 rcItem.MoveToY(nLastBottom);
263 if (SItemPanel::IsItemInClip(mtx, rcClip, rgnClip, rcItem))
265 ii.
pItem->Draw(pRT, rcItem);
276 int nOldPos = m_siVer.nPos;
277 __baseCls::OnScroll(bVertical, uCode, nPos);
278 int nNewPos = m_siVer.nPos;
279 if (nOldPos != nNewPos)
284 if (uCode == SB_THUMBTRACK)
304 int iNewLastVisible = iNewFirstVisible;
310 SPOSITION spos = m_lstItems.GetHeadPosition();
314 pItemInfos[i++] = m_lstItems.GetNext(spos);
317 m_lstItems.RemoveAll();
319 if (iNewFirstVisible != -1)
321 while (pos < m_siVer.nPos + (
int)m_siVer.nPage && iNewLastVisible < m_adapter->getCount())
324 if (iHoverItem == iNewLastVisible)
331 if (iNewLastVisible >= iOldFirstVisible && iNewLastVisible < iOldLastVisible)
334 int iItem = iNewLastVisible - iOldFirstVisible;
335 SASSERT(iItem >= 0 && iItem <= (iOldLastVisible - iOldFirstVisible));
338 ii = pItemInfos[iItem];
339 pItemInfos[iItem].
pItem = NULL;
342 BOOL bNewItem = FALSE;
346 SList<SItemPanel *> *lstRecycle = m_itemRecycle.GetAt(ii.
nType);
347 if (lstRecycle->IsEmpty())
356 ii.
pItem = lstRecycle->RemoveHead();
358 ii.
pItem->SetItemIndex(iNewLastVisible);
362 rcItem.MoveToXY(0, 0);
367 ii.
pItem->ModifyItemState(dwState, 0);
389 m_lstItems.AddTail(ii);
401 for (
int i = 0; i < (iOldLastVisible - iOldFirstVisible); i++)
410 ii.
pItem->DoFrameEvent(WM_MOUSELEAVE, 0, 0);
431 __baseCls::OnSize(nType, size);
448 SPOSITION pos = m_lstItems.GetHeadPosition();
451 ItemInfo ii = m_lstItems.GetNext(pos);
454 m_lstItems.RemoveAll();
456 for (
int i = 0; i < (int)m_itemRecycle.GetCount(); i++)
458 SList<SItemPanel *> *pLstTypeItems = m_itemRecycle[i];
459 SPOSITION pos = pLstTypeItems->GetHeadPosition();
462 SItemPanel *pItem = pLstTypeItems->GetNext(pos);
465 delete pLstTypeItems;
467 m_itemRecycle.RemoveAll();
468 __baseCls::OnDestroy();
486 rcItem.OffsetRect(rcClient.TopLeft());
488 rcItem.MoveToY(rcClient.top +
m_tvItemLocator->GetMarginSize() + nOffset);
494 int iPosition = (int)pItem->GetItemIndex();
495 if (iPosition < 0 || iPosition >=
m_adapter->getCount())
522 SPOSITION pos = m_lstItems.GetHeadPosition();
525 ItemInfo ii = m_lstItems.GetNext(pos);
526 CRect rcItem = ii.
pItem->GetItemRect();
527 if (rcItem.PtInRect(pt))
529 pt -= rcItem.TopLeft();
554 CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
559 pt.Offset(-rcItem.TopLeft());
560 lRet =
m_itemCapture->DoFrameEvent(uMsg, wParam, MAKELPARAM(pt.x, pt.y));
564 if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN)
566 __baseCls::ProcessSwndMessage(uMsg, wParam, lParam, lRet);
569 SItemPanel *pHover =
HitTest(pt);
576 nOldHover->DoFrameEvent(WM_MOUSELEAVE, 0, 0);
581 m_pHoverItem->DoFrameEvent(WM_MOUSEHOVER, wParam, MAKELPARAM(pt.x, pt.y));
587 m_pHoverItem->DoFrameEvent(uMsg, wParam, MAKELPARAM(pt.x, pt.y));
591 if (uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP)
593 __baseCls::ProcessSwndMessage(uMsg, wParam, lParam, lRet);
606 lRet = pItem->DoFrameEvent(uMsg, wParam, lParam);
618 __baseCls::OnMouseLeave();
640 pItem->DoFrameEvent(WM_KEYDOWN, nChar, MAKELONG(nFlags, nRepCnt));
648 int nNewSelItem = -1;
650 if (pOwner && (nChar == VK_ESCAPE || nChar == VK_RETURN))
652 pOwner->
SSendMessage(WM_KEYDOWN, nChar, MAKELONG(nFlags, nRepCnt));
689 if (nChar == VK_PRIOR || nChar == VK_HOME)
691 if (!m_lstItems.IsEmpty())
693 nNewSelItem = (int)(m_lstItems.GetHead().pItem->GetItemIndex());
696 else if (nChar == VK_NEXT || nChar == VK_END)
698 if (!m_lstItems.IsEmpty())
700 nNewSelItem = (int)(m_lstItems.GetTail().pItem->GetItemIndex());
705 if (nNewSelItem != -1)
708 SetSel(nNewSelItem, TRUE);
718 if (iItem < 0 || iItem >=
m_adapter->getCount())
729 if (rcItem.top < m_siVer.nPos)
732 OnScroll(TRUE, SB_THUMBPOSITION, rcItem.top);
734 if (rcItem.bottom > m_siVer.nPos + (
int)m_siVer.nPage)
737 OnScroll(TRUE, SB_THUMBPOSITION, rcItem.bottom - m_siVer.nPage);
746 CRect rcItem = pSelItem->GetItemRect();
747 CPoint pt2 = pt - rcItem.TopLeft();
748 if (pSelItem->DoFrameEvent(WM_MOUSEWHEEL, MAKEWPARAM(nFlags, zDelta), MAKELPARAM(pt2.x, pt2.y)))
753 return __baseCls::OnMouseWheel(nFlags, zDelta, pt);
767 SPOSITION pos = m_lstItems.GetHeadPosition();
770 ItemInfo ii = m_lstItems.GetNext(pos);
771 if ((
int)ii.
pItem->GetItemIndex() == iItem)
810 return __baseCls::UpdateToolTip(pt, tipInfo);
838 EventLVSelChanging evt(
this);
840 evt.iOldSel = nOldSel;
841 evt.iNewSel = nNewSel;
851 if (nOldSel == nNewSel)
874 EventLVSelChanged evt(
this);
875 evt.iOldSel = nOldSel;
876 evt.iNewSel = nNewSel;
885 return SC_WANTALLKEYS;
889 return SC_WANTARROWS | SC_WANTSYSKEY;
895 __baseCls::OnKillFocus(wndFocus);
911 __baseCls::OnSetFocus(wndOld);
926 int nScale = (int)wParam;
928 __baseCls::OnSetScale(uMsg, wParam, lParam);
938 bRet =
m_itemCapture->DoFrameEvent(WM_SETCURSOR, 0, MAKELPARAM(pt.x - rcItem.left, pt.y - rcItem.top)) != 0;
943 bRet =
m_pHoverItem->DoFrameEvent(WM_SETCURSOR, 0, MAKELPARAM(pt.x - rcItem.left, pt.y - rcItem.top)) != 0;
947 bRet = __baseCls::OnSetCursor(pt);
954 SItemPanel *pItemPanel = sobj_cast<SItemPanel>(pEvt->Sender());
955 int iItem = (int)pItemPanel->GetItemIndex();
965 __baseCls::OnColorize(cr);
971 __baseCls::OnScaleChanged(nScale);
980 HRESULT hret = __baseCls::OnLanguageChanged();
987 SPOSITION pos = m_lstItems.GetHeadPosition();
990 ItemInfo ii = m_lstItems.GetNext(pos);
993 for (UINT i = 0; i < m_itemRecycle.GetCount(); i++)
995 SList<SItemPanel *> *pLstTypeItems = m_itemRecycle[i];
996 SPOSITION pos = pLstTypeItems->GetHeadPosition();
999 SItemPanel *pItem = pLstTypeItems->GetNext(pos);
1007 __baseCls::OnShowWindow(bShow, nStatus);
1029 __baseCls::OnRebuildFont();
Definition of the STileView class.
A helper class to enable or disable private UI definitions for the host container.
Smart pointer class for managing COM-style reference-counted objects.
BOOL subscribeEvent(DWORD dwEventID, const IEvtSlot &subscriber)
订阅事件
void setMutedState(BOOL setting)
设置事件集的静音状态
void RestoreFocusedView()
Restores the focused view.
void ClearFocus()
Clears the focused window.
void StoreFocusedView()
Stores the focused view.
The SMatrix class holds a 3x3 matrix for transforming coordinates. SMatrix does not have a constructo...
Helper class for painting.
virtual CRect GetClientRect() const
Gets the client rectangle.
void ScrollUpdate()
Updates the scrollbar.
SAutoRefPtr< ILvDataSetObserver > m_observer
virtual void OnColorize(COLORREF cr)
Handles colorization.
void OnKeyDown(TCHAR nChar, UINT nRepCnt, UINT nFlags)
Handles the key down event.
virtual void OnRebuildFont()
Rebuilds the font.
BOOL m_bDatasetInvalidated
void UpdateScrollBar()
Updates the scroll bars.
virtual HRESULT OnLanguageChanged()
Handles language changes.
void onDataSetInvalidated()
Handles data set invalidation.
void OnPaint(IRenderTarget *pRT)
Handles the paint event.
virtual BOOL IsItemRedrawDelay() const
Checks if item redraw is delayed.
SAutoRefPtr< ILvAdapter > m_adapter
ILvAdapter * GetAdapter() SCONST OVERRIDE
Gets the adapter for the tile view.
SItemPanel * GetItemPanel(int iItem)
Gets the item panel by index.
void UpdateVisibleItems()
Updates the visible items.
void EnsureVisible(int iItem) OVERRIDE
Ensures the specified item is visible.
LRESULT OnSetScale(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles the set scale event.
IItemPanel * HitTest(const POINT *pt) SCONST OVERRIDE
Performs a hit test on the tile view.
void OnSize(UINT nType, CSize size)
Handles the size event.
void SetSel(int iItem, BOOL bNotify=FALSE) OVERRIDE
Sets the selected item.
void SetItemLocator(ITileViewItemLocator *pItemLocator) OVERRIDE
Sets the item locator for the tile view.
virtual int GetScrollLineSize(BOOL bVertical)
Gets the scroll line size.
void OnMouseLeave()
Handles the mouse leave event.
virtual BOOL CreateChildren(SXmlNode xmlNode)
Creates child windows from an XML node.
~STileView()
Destructor for STileView.
virtual UINT WINAPI OnGetDlgCode() const
Gets the dialog code for the window.
void UpdateVisibleItem(int iItem)
Updates a specific visible item.
void OnDestroy()
Handles the destroy event.
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles the mouse wheel event.
void onDataSetChanged()
Handles data set changes.
SOsrPanel * m_itemCapture
virtual BOOL OnSetCursor(const CPoint &pt)
Sets the cursor.
int GetSel() SCONST OVERRIDE
Gets the selected item.
void onItemDataChanged(int iItem)
Handles data changes for a specific item.
ITileViewItemLocator * GetItemLocator() SCONST OVERRIDE
Gets the item locator for the tile view.
void OnShowWindow(BOOL bShow, UINT nStatus)
Handles the show window event.
CRect CalcItemDrawRect(int iItem) const
Calculates the drawing rectangle for an item.
void OnSetFocus(SWND wndOld)
Handles the set focus event.
LRESULT OnKeyEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles key events.
SAutoRefPtr< ITileViewItemLocator > m_tvItemLocator
STileView()
Constructor for STileView.
BOOL OnItemClick(IEvtArgs *pEvt)
Handles item click events.
void OnKillFocus(SWND wndFocus)
Handles the kill focus event.
BOOL SetAdapter(ILvAdapter *adapter) OVERRIDE
Sets the adapter for the tile view.
virtual void OnScaleChanged(int nScale)
Handles scale changes.
virtual BOOL OnScroll(BOOL bVertical, UINT uCode, int nPos)
Handles scroll events.
SLayoutSize m_nMarginSize
virtual BOOL UpdateToolTip(CPoint pt, SwndToolTipInfo &tipInfo)
Updates the tooltip.
LRESULT OnMouseEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Handles mouse events.
void DispatchMessage2Items(UINT uMsg, WPARAM wParam, LPARAM lParam)
Dispatches messages to items.
virtual BOOL OnItemGetRect(const SOsrPanel *pItem, CRect &rcItem) const
Gets the rectangle of an item.
void RedrawItem(SOsrPanel *pItem)
Redraws a specific item.
virtual void OnItemSetCapture(SOsrPanel *pItem, BOOL bCapture)
Handles the capture of an item.
Base class for SOUI DUI windows.
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
void SetVisible(BOOL bVisible, BOOL bUpdate=FALSE) OVERRIDE
Sets the visibility of the window.
void UnlockUpdate() OVERRIDE
Unlocks updates to the window.
SWindow * GetOwner() const
Retrieves the current owner of the window.
BOOL Destroy() OVERRIDE
Destroys the window.
DWORD GetState() SCONST OVERRIDE
Retrieves the current state of the window.
void SDispatchMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0) OVERRIDE
Dispatches a message to the window.
int GetScale() SCONST OVERRIDE
Retrieves the scale factor of the window.
BOOL IsMsgHandled() const
Checks if the message is handled.
COLORREF GetColorizeColor() SCONST OVERRIDE
Retrieves the colorization color of the window.
BOOL IsVisible(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is visible.
ISwndContainer * GetContainer() OVERRIDE
Retrieves the container associated with this window.
void DoColorize(COLORREF cr) OVERRIDE
Applies colorization to the window.
virtual CRect GetClientRect() const
Retrieves the client rectangle of the window.
LRESULT SSendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0, BOOL *pbMsgHandled=NULL) OVERRIDE
Sends a message to the window.
virtual void BeforePaint(IRenderTarget *pRT, SPainter &painter)
Prepare rendering environment.
void InvalidateRect(LPCRECT lprect) OVERRIDE
Invalidates a specific rectangle area of the window.
void UpdateLayout() OVERRIDE
Updates the layout of the window.
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
SEventSet * GetEventSet()
Retrieves the event set associated with the window.
void Invalidate() OVERRIDE
Invalidates the entire window.
void SetMsgHandled(BOOL bHandled)
Sets the message handled flag.
void LockUpdate() OVERRIDE
Locks updates to the window.
SWND m_swnd
Member variables representing various properties of the window.
void Move(LPCRECT prect) OVERRIDE
Moves the window to a new position and size.
const wchar_t * as_string(const wchar_t *def=L"") const
Gets the attribute value as a string.
Class representing an XML node.
SXmlAttr attribute(const wchar_t *name, bool bCaseSensitive=false) const
Gets the attribute with the specified name.
SXmlNode child(const wchar_t *name, bool bCaseSensitive=false) const
Gets the child node, attribute, or next/previous sibling with the specified name.
SFocusManager * GetFocusManager()
Retrieves the focus manager.
Template class implementing the IObjRef interface.
long Release() override
Decrements the reference count and deletes the object if the count reaches zero.
Interface for rendering target objects.
HRESULT GetTransform(float matrix[9]) SCONST PURE
Retrieves the current coordinate transformation matrix.
HRESULT PushClipRect(LPCRECT pRect, UINT mode=RGN_AND) PURE
Push a rectangular clip region.
HRESULT PopClip() PURE
Pop the last clip region from the stack.
HRESULT GetClipBox(LPRECT prc) PURE
Get the bounding box of the current clip region.
HRESULT GetClipRegion(IRegionS **ppRegion) PURE
Get the current clip region.
BOOL OnReleaseSwndCapture() PURE
Releases the mouse capture from the Swnd object.
SWND OnSetSwndCapture(SWND swnd) PURE
Sets the Swnd object to capture the mouse.
Information about an item in the tile view.