7#include "core/SItemPanel.h"
9#pragma warning(disable : 4018)
13SOsrPanel::SOsrPanel(IHostProxy *pFrameHost, IItemContainer *pItemContainer)
14 : m_pHostProxy(pFrameHost)
15 , m_pItemContainer(pItemContainer)
21 SASSERT(m_pHostProxy);
22 SASSERT(m_pItemContainer);
23 m_evtSet.addEvent(EVENTID(EventItemPanelClick));
24 m_evtSet.addEvent(EVENTID(EventItemPanelRclick));
25 m_evtSet.addEvent(EVENTID(EventItemPanelClickUp));
26 m_evtSet.addEvent(EVENTID(EventItemPanelRclickUp));
27 m_evtSet.addEvent(EVENTID(EventItemPanelDbclick));
28 m_evtSet.addEvent(EVENTID(EventItemPanelHover));
29 m_evtSet.addEvent(EVENTID(EventItemPanelLeave));
32void SOsrPanel::OnFinalRelease()
36 m_pHostProxy->GetHostContainer()->UnregisterTimelineHandler(
this);
37 __baseCls::OnFinalRelease();
40BOOL SOsrPanel::InitFromXml(THIS_
IXmlNode *pNode)
42 BOOL bRet = __baseCls::InitFromXml(pNode);
50LRESULT SOsrPanel::DoFrameEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
61 EventItemPanelHover evt(
this);
70 EventItemPanelLeave evt(
this);
76 EventItemPanelClick evt(
this);
84 EventItemPanelRclick evt(
this);
90 case WM_LBUTTONDBLCLK:
92 EventItemPanelDbclick evt(
this);
100 EventItemPanelClickUp evt(
this);
108 EventItemPanelRclickUp evt(
this);
120 if (uMsg == WM_LBUTTONUP && !isMute)
125 if (uMsg == WM_LBUTTONUP && !isMute)
135BOOL SOsrPanel::OnFireEvent(IEvtArgs *evt)
137 return m_pHostProxy->OnHostFireEvent(evt);
140void SOsrPanel::GetContainerRect(RECT *ret)
const
143 m_pItemContainer->OnItemGetRect(
this, rcItem);
147void SOsrPanel::UpdateRegion(
IRegionS *rgn)
149 CRect rc = GetItemRect();
150 rgn->
Offset(rc.TopLeft());
151 m_pHostProxy->GetHostContainer()->UpdateRegion(rgn);
154void SOsrPanel::OnRedraw(LPCRECT rc, BOOL bClip)
156 if (m_pHostProxy->IsHostUpdateLocked())
159 CRect rcItem = GetItemRect();
160 if (!rcItem.IsRectNull() && m_pHostProxy->IsHostVisible())
162 if (m_pItemContainer->IsItemRedrawDelay())
165 rc2.OffsetRect(rcItem.TopLeft());
166 rc2.IntersectRect(rc2, rcItem);
167 CRect rcHostClient = m_pHostProxy->GetHostRect();
168 rc2.IntersectRect(rc2, rcHostClient);
169 m_pHostProxy->InvalidateHostRect(&rc2, bClip);
173 SAutoRefPtr<IRegionS> rgn;
174 GETRENDERFACTORY->CreateRegion(&rgn);
175 rgn->CombineRect(rc, RGN_COPY);
181BOOL SOsrPanel::OnReleaseSwndCapture()
185 m_pItemContainer->OnItemSetCapture(
this, FALSE);
189SWND SOsrPanel::OnSetSwndCapture(SWND swnd)
191 m_pItemContainer->OnItemSetCapture(
this, TRUE);
195HWND SOsrPanel::GetHostHwnd()
197 return m_pHostProxy->GetHostContainer()->GetHostHwnd();
200LPCWSTR SOsrPanel::GetTranslatorContext()
const
202 return m_pHostProxy->GetHostContainer()->GetTranslatorContext();
205BOOL SOsrPanel::IsTranslucent()
const
207 return m_pHostProxy->GetHostContainer()->IsTranslucent();
210BOOL SOsrPanel::IsSendWheel2Hover()
const
212 return m_pHostProxy->GetHostContainer()->IsSendWheel2Hover();
215BOOL SOsrPanel::UpdateWindow(BOOL bForce)
217 return m_pHostProxy->GetHostContainer()->UpdateWindow(bForce);
220void SOsrPanel::UpdateTooltip()
222 return m_pHostProxy->GetHostContainer()->UpdateTooltip();
224void SOsrPanel::SetToolTip(LPCRECT rc, UINT tipAlign, LPCTSTR pszTip)
229 m_pItemContainer->OnItemGetRect(
this, rc2);
230 rc2.OffsetRect(rc->left, rc->top);
231 return m_pHostProxy->GetHostContainer()->SetToolTip(&rc2, tipAlign, pszTip);
235 return m_pHostProxy->GetHostContainer()->SetToolTip(rc, tipAlign, pszTip);
239void SOsrPanel::ModifyItemState(DWORD dwStateAdd, DWORD dwStateRemove)
244SWND SOsrPanel::SwndFromPoint(CPoint &pt,
bool bIncludeMsgTransparent)
257 BeforePaint(pRT, painter);
260 SAutoRefPtr<IRegionS> rgn;
277BOOL SOsrPanel::NeedRedrawWhenStateChange()
282CRect SOsrPanel::GetItemRect()
const
285 m_pItemContainer->OnItemGetRect(
this, rcItem);
288void SOsrPanel::SetItemCapture(BOOL bCapture)
290 m_pItemContainer->OnItemSetCapture(
this, bCapture);
295 CRect rcItem = GetItemRect();
312 pt -= rcItem.TopLeft();
316 tipInfo.
rcTarget.OffsetRect(rcItem.TopLeft());
323 return m_pHostProxy->GetHostContainer()->GetMsgLoop();
326IScriptModule *SOsrPanel::GetScriptModule()
328 return m_pHostProxy->GetHostContainer()->GetScriptModule();
331void SOsrPanel::FrameToHost(RECT *rc)
const
333 CRect rcItem = GetItemRect();
334 ::OffsetRect(rc, rcItem.left, rcItem.top);
343 if (fontText == NULL)
344 fontText = GETUIDEF->GetFont(FF_DEFAULTFONT, GetScale());
345 if (crText == CR_INVALID)
346 crText = RGBA(0, 0, 0, 255);
351void SOsrPanel::OnShowWindow(BOOL bShow, UINT nStatus)
353 __baseCls::OnShowWindow(bShow, nStatus);
355 m_pHostProxy->GetHostContainer()->RegisterTimelineHandler(
this);
357 m_pHostProxy->GetHostContainer()->UnregisterTimelineHandler(
this);
360void SOsrPanel::OnDestroy()
362 m_pHostProxy->GetHostContainer()->UnregisterTimelineHandler(
this);
363 __baseCls::OnDestroy();
366int SOsrPanel::GetScale()
const
368 return m_pHostProxy->GetHostContainer()->GetScale();
371void SOsrPanel::EnableIME(BOOL bEnable)
373 m_pHostProxy->GetHostContainer()->EnableIME(bEnable);
376void SOsrPanel::OnUpdateCursor()
378 m_pHostProxy->GetHostContainer()->OnUpdateCursor();
381void SOsrPanel::EnableHostPrivateUiDef(THIS_ BOOL bEnable)
383 return m_pHostProxy->GetHostContainer()->EnableHostPrivateUiDef(bEnable);
386BOOL SOsrPanel::IsItemInClip(
const SMatrix &mtx,
const CRect &rcClip,
const IRegionS *clipRgn,
const CRect &rcItem)
391 rc.IntersectRect(rcClip, rcItem);
392 return !rc.IsRectEmpty() && (!clipRgn || clipRgn->
RectInRegion(rcItem));
395LPARAM SOsrPanel::GetItemIndex()
const
397 return m_lpItemIndex;
400void SOsrPanel::SetItemIndex(LPARAM lp)
405void SOsrPanel::SetItemData(LPARAM dwData)
410LPARAM SOsrPanel::GetItemData()
const
415void SOsrPanel::PtToHost(THIS_ POINT *pt)
const
417 CRect rcItem = GetItemRect();
418 pt->x += rcItem.left;
424 __baseCls::RequestRelayout(hSource, bSourceResizable);
427 m_pHostProxy->OnLayoutDirty();
431BOOL SOsrPanel::PostTask(THIS_ IRunnable *runable, BOOL bAsync)
433 return m_pHostProxy->GetHostContainer()->PostTask(runable, bAsync);
436int SOsrPanel::RemoveTasksForObject(THIS_
void *pObj)
438 return m_pHostProxy->GetHostContainer()->RemoveTasksForObject(pObj);
442SItemPanel *SItemPanel::Create(IHostProxy *pFrameHost,
SXmlNode xmlNode, IItemContainer *pItemContainer)
444 SItemPanel *pItem =
new SItemPanel(pFrameHost, pItemContainer);
445 pItem->InitFromXml(&xmlNode);
450SItemPanel::SItemPanel(IHostProxy *pFrameHost, IItemContainer *pItemContainer)
451 : TOsrPanelProxy<IItemPanel>(pFrameHost, pItemContainer)
453 , m_crHover(CR_INVALID)
454 , m_crSelBk(RGBA(0, 0, 128, 255))
458void SItemPanel::SetSkin(
ISkinObj *pSkin)
463void SItemPanel::SetColor(COLORREF crBk, COLORREF crSelBk)
469COLORREF SItemPanel::GetBkgndColor()
const
482BOOL SItemPanel::OnFireEvent(IEvtArgs *evt)
484 EventOfPanel evt2(m_pHostProxy->GetHost());
487 return m_pHostProxy->OnHostFireEvent(&evt2);
void setMutedState(BOOL setting)
设置事件集的静音状态
BOOL isMuted(void) const
检查事件集是否被静音
The SMatrix class holds a 3x3 matrix for transforming coordinates. SMatrix does not have a constructo...
BOOL isIdentity() SCONST OVERRIDE
Checks if the matrix is the identity matrix.
void dirtyMatrixTypeCache()
Testing routine; the matrix's type cache should never need to be manually invalidated during normal u...
void SetSwndDefAttr(IObject *pObject) const
Sets default attributes for a given object.
Helper class for painting.
SAutoRefPtr< IFontS > oldFont
static SApplication * getSingletonPtr(void)
static int GetDefIndex(DWORD dwState, bool checkAsPushdown=false)
Gets the default index for a given state.
BOOL FireEvent(IEvtArgs *evt) OVERRIDE
Fires an event.
virtual BOOL UpdateToolTip(CPoint pt, SwndToolTipInfo &tipInfo)
Handle tooltip updates.
DWORD GetState() SCONST OVERRIDE
Retrieves the current state of the window.
SWND SwndFromPoint(POINT *pt, BOOL bIncludeMsgTransparent=FALSE) SCONST OVERRIDE
Retrieves the window handle at a specified point.
BOOL IsLayoutDirty() SCONST OVERRIDE
Checks if the layout is dirty.
BOOL IsVisible(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is visible.
LRESULT SSendMessage(UINT uMsg, WPARAM wParam=0, LPARAM lParam=0, BOOL *pbMsgHandled=NULL) OVERRIDE
Sends a message to the window.
void UpdateLayout() OVERRIDE
Updates the layout of the window.
virtual void AfterPaint(IRenderTarget *pRT, SPainter &painter)
Restore rendering environment.
BOOL IsDisabled(BOOL bCheckParent=FALSE) SCONST OVERRIDE
Checks if the window is disabled.
SEventSet * GetEventSet()
Retrieves the event set associated with the window.
SAutoRefPtr< ISkinObj > m_pBgSkin
void RedrawRegion(IRenderTarget *pRT, IRegionS *pRgn)
Renders the content of the window and its child windows onto the RenderTarget.
void RequestRelayout() OVERRIDE
Requests a relayout of the window.
void SetMsgHandled(BOOL bHandled)
Sets the message handled flag.
virtual SStringT GetToolTipText()
Retrieves the tooltip text of the window.
BOOL FireCommand() OVERRIDE
Fires a command event.
DWORD ModifyState(DWORD dwStateAdd, DWORD dwStateRemove, BOOL bUpdate=FALSE) OVERRIDE
Modifies the state of the window.
const SwndStyle & GetStyle() const
Retrieves the style of the window.
SWND m_swnd
Member variables representing various properties of the window.
static SWindow * GetWindow(SWND swnd)
Retrieves the SWindow pointer from a given handle.
Class representing an XML node.
void BuildWndTreeZorder() OVERRIDE
Rebuilds the window tree's z-order.
void SetRoot(SWindow *pRoot)
Sets the root window of the container.
virtual LRESULT DoFrameEvent(UINT uMsg, WPARAM wParam, LPARAM lParam)
Processes frame events.
BOOL OnReleaseSwndCapture() OVERRIDE
Releases the window capture.
SWND OnSetSwndCapture(SWND swnd) OVERRIDE
Sets the window capture.
IFontPtr GetTextFont(int iState)
Retrieves the text font for a specific state.
COLORREF GetTextColor(int iState)
Retrieves the text color for a specific state.
Interface for message loops.
void Offset(POINT pt) PURE
Offsets the region by a specified amount.
BOOL RectInRegion(LPCRECT lprect) SCONST PURE
Checks if a rectangle intersects with the region.
Interface for rendering target objects.
HRESULT GetTransform(float matrix[9]) SCONST PURE
Retrieves the current coordinate transformation matrix.
HRESULT SelectObject(IRenderObj *pObj, IRenderObj **pOldObj=NULL) PURE
Selects a new rendering object and optionally retrieves the previous one.
void EndDraw() PURE
End a drawing operation.
void BeginDraw() PURE
Start a drawing operation.
HRESULT OffsetViewportOrg(int xOff, int yOff, LPPOINT lpPoint=NULL) PURE
Offset the viewport origin.
HRESULT GetClipRegion(IRegionS **ppRegion) PURE
Get the current clip region.
COLORREF SetTextColor(COLORREF color) PURE
Sets the current text color.
Interface for Skin Objects.