| 79 |
cycrow |
1 |
//************************************************************************
|
|
|
2 |
//
|
|
|
3 |
// LCDCollection.cpp
|
|
|
4 |
//
|
|
|
5 |
// The CLCDCollection class is a generic collection of CLCDBase objects.
|
|
|
6 |
//
|
|
|
7 |
// Logitech LCD SDK
|
|
|
8 |
//
|
|
|
9 |
// Copyright 2005 Logitech Inc.
|
|
|
10 |
//************************************************************************
|
|
|
11 |
|
|
|
12 |
#include "LCDCollection.h"
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
//************************************************************************
|
|
|
16 |
//
|
|
|
17 |
// CLCDCollection::CLCDCollection
|
|
|
18 |
//
|
|
|
19 |
//************************************************************************
|
|
|
20 |
|
|
|
21 |
CLCDCollection::CLCDCollection(void)
|
|
|
22 |
{
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
//************************************************************************
|
|
|
27 |
//
|
|
|
28 |
// CLCDCollection::~CLCDCollection
|
|
|
29 |
//
|
|
|
30 |
//************************************************************************
|
|
|
31 |
|
|
|
32 |
CLCDCollection::~CLCDCollection(void)
|
|
|
33 |
{
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
//************************************************************************
|
|
|
38 |
//
|
|
|
39 |
// CLCDCollection::AddObject
|
|
|
40 |
//
|
|
|
41 |
//************************************************************************
|
|
|
42 |
|
|
|
43 |
BOOL CLCDCollection::AddObject(CLCDBase* pObject)
|
|
|
44 |
{
|
|
|
45 |
//TODO: handle addition of same object twice...
|
|
|
46 |
m_Objects.push_back(pObject);
|
|
|
47 |
return TRUE;
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
//************************************************************************
|
|
|
52 |
//
|
|
|
53 |
// CLCDCollection::RemoveObject
|
|
|
54 |
//
|
|
|
55 |
//************************************************************************
|
|
|
56 |
|
|
|
57 |
BOOL CLCDCollection::RemoveObject(CLCDBase* pObject)
|
|
|
58 |
{
|
|
|
59 |
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
|
|
|
60 |
while(it != m_Objects.end())
|
|
|
61 |
{
|
|
|
62 |
if (*it == pObject)
|
|
|
63 |
{
|
|
|
64 |
m_Objects.erase(it);
|
|
|
65 |
break;
|
|
|
66 |
}
|
|
|
67 |
++it;
|
|
|
68 |
}
|
|
|
69 |
return FALSE;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
//************************************************************************
|
|
|
74 |
//
|
|
|
75 |
// CLCDCollection::OnDraw
|
|
|
76 |
//
|
|
|
77 |
//************************************************************************
|
|
|
78 |
|
|
|
79 |
void CLCDCollection::OnDraw(CLCDGfx &rGfx)
|
|
|
80 |
{
|
|
|
81 |
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
|
|
|
82 |
while(it != m_Objects.end())
|
|
|
83 |
{
|
|
|
84 |
CLCDBase *pObject = *it;
|
|
|
85 |
LCDUIASSERT(NULL != pObject);
|
|
|
86 |
|
|
|
87 |
if (!pObject->IsVisible())
|
|
|
88 |
{
|
|
|
89 |
++it;
|
|
|
90 |
continue;
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
// create the clip region
|
|
|
94 |
HRGN hRgn = CreateRectRgn(pObject->GetOrigin().x, pObject->GetOrigin().y,
|
|
|
95 |
pObject->GetOrigin().x + pObject->GetWidth(),
|
|
|
96 |
pObject->GetOrigin().y + pObject->GetHeight());
|
|
|
97 |
|
|
|
98 |
// ensure that controls only draw within their specified region
|
|
|
99 |
SelectClipRgn(rGfx.GetHDC(), hRgn);
|
|
|
100 |
|
|
|
101 |
// free the region (a copy is used in the call above)
|
|
|
102 |
DeleteObject(hRgn);
|
|
|
103 |
|
|
|
104 |
// offset the control at its origin so controls use (0,0)
|
|
|
105 |
POINT ptPrevViewportOrg = { 0, 0 };
|
|
|
106 |
SetViewportOrgEx(rGfx.GetHDC(),
|
|
|
107 |
pObject->GetOrigin().x,
|
|
|
108 |
pObject->GetOrigin().y,
|
|
|
109 |
&ptPrevViewportOrg);
|
|
|
110 |
|
|
|
111 |
// allow controls to supply additional translation
|
|
|
112 |
// this allows controls to move freely within the confined viewport
|
|
|
113 |
OffsetViewportOrgEx(rGfx.GetHDC(),
|
|
|
114 |
pObject->GetLogicalOrigin().x,
|
|
|
115 |
pObject->GetLogicalOrigin().y,
|
|
|
116 |
NULL);
|
|
|
117 |
|
|
|
118 |
pObject->OnDraw(rGfx);
|
|
|
119 |
|
|
|
120 |
// set the clipping region to nothing
|
|
|
121 |
SelectClipRgn(rGfx.GetHDC(), NULL);
|
|
|
122 |
|
|
|
123 |
// restore the viewport origin
|
|
|
124 |
SetViewportOrgEx(rGfx.GetHDC(),
|
|
|
125 |
ptPrevViewportOrg.x,
|
|
|
126 |
ptPrevViewportOrg.y,
|
|
|
127 |
NULL);
|
|
|
128 |
|
|
|
129 |
// restore the viewport origin offset
|
|
|
130 |
OffsetViewportOrgEx(rGfx.GetHDC(), 0, 0, NULL);
|
|
|
131 |
|
|
|
132 |
++it;
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
//************************************************************************
|
|
|
138 |
//
|
|
|
139 |
// CLCDCollection::OnUpdate
|
|
|
140 |
//
|
|
|
141 |
//************************************************************************
|
|
|
142 |
|
|
|
143 |
void CLCDCollection::OnUpdate(DWORD dwTimestamp)
|
|
|
144 |
{
|
|
|
145 |
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
|
|
|
146 |
while(it != m_Objects.end())
|
|
|
147 |
{
|
|
|
148 |
CLCDBase *pObject = *it;
|
|
|
149 |
LCDUIASSERT(NULL != pObject);
|
|
|
150 |
pObject->OnUpdate(dwTimestamp);
|
|
|
151 |
++it;
|
|
|
152 |
}
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
//************************************************************************
|
|
|
157 |
//
|
|
|
158 |
// CLCDCollection::ResetUpdate
|
|
|
159 |
//
|
|
|
160 |
//************************************************************************
|
|
|
161 |
|
|
|
162 |
void CLCDCollection::ResetUpdate(void)
|
|
|
163 |
{
|
|
|
164 |
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
|
|
|
165 |
while(it != m_Objects.end())
|
|
|
166 |
{
|
|
|
167 |
CLCDBase *pObject = *it;
|
|
|
168 |
LCDUIASSERT(NULL != pObject);
|
|
|
169 |
pObject->ResetUpdate();
|
|
|
170 |
++it;
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
//************************************************************************
|
|
|
176 |
//
|
|
|
177 |
// CLCDCollection::Show
|
|
|
178 |
//
|
|
|
179 |
//************************************************************************
|
|
|
180 |
|
|
|
181 |
void CLCDCollection::Show(BOOL bShow)
|
|
|
182 |
{
|
|
|
183 |
LCD_OBJECT_LIST::iterator it = m_Objects.begin();
|
|
|
184 |
while(it != m_Objects.end())
|
|
|
185 |
{
|
|
|
186 |
CLCDBase *pObject = *it;
|
|
|
187 |
LCDUIASSERT(NULL != pObject);
|
|
|
188 |
pObject->Show(bShow);
|
|
|
189 |
++it;
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
CLCDBase::Show(bShow);
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
//** end of LCDCollection.cpp ********************************************
|