46 QWmpVideoOverlay::QWmpVideoOverlay(IWMPPlayer4 *player, IOleObject *object, QWmpPlayerService *service) |
46 QWmpVideoOverlay::QWmpVideoOverlay(IWMPPlayer4 *player, IOleObject *object, QWmpPlayerService *service) |
47 : m_service(service) |
47 : m_service(service) |
48 , m_player(player) |
48 , m_player(player) |
49 , m_object(object) |
49 , m_object(object) |
50 , m_inPlaceObject(0) |
50 , m_inPlaceObject(0) |
51 , m_aspectRatioMode(QVideoWidget::KeepAspectRatio) |
51 , m_aspectRatioMode(Qt::KeepAspectRatio) |
52 , m_enabled(false) |
52 , m_enabled(false) |
53 { |
53 { |
54 HRESULT hr; |
54 HRESULT hr; |
55 |
55 |
56 if ((hr = m_object->QueryInterface( |
56 if ((hr = m_object->QueryInterface( |
118 MAP_PIX_TO_LOGHIM(rect.width(), GetDeviceCaps(gdc, LOGPIXELSX)), |
118 MAP_PIX_TO_LOGHIM(rect.width(), GetDeviceCaps(gdc, LOGPIXELSX)), |
119 MAP_PIX_TO_LOGHIM(rect.height(), GetDeviceCaps(gdc, LOGPIXELSY)) }; |
119 MAP_PIX_TO_LOGHIM(rect.height(), GetDeviceCaps(gdc, LOGPIXELSY)) }; |
120 |
120 |
121 m_object->SetExtent(DVASPECT_CONTENT, &hmSize); |
121 m_object->SetExtent(DVASPECT_CONTENT, &hmSize); |
122 |
122 |
123 RECT rcPos = { rect.left(), rect.top(), rect.right(), rect.bottom() }; |
123 RECT rcClip = { rect.left(), rect.top(), rect.right(), rect.bottom() }; |
124 m_inPlaceObject->SetObjectRects(&rcPos, &rcPos); |
124 |
|
125 if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { |
|
126 QSize size = m_sizeHint; |
|
127 size.scale(rect.width(), rect.height(), Qt::KeepAspectRatioByExpanding); |
|
128 |
|
129 QRect positionRect(QPoint(0, 0), size); |
|
130 positionRect.moveCenter(rect.center()); |
|
131 |
|
132 RECT rcPos = |
|
133 { |
|
134 positionRect.left(), |
|
135 positionRect.top(), |
|
136 positionRect.right(), |
|
137 positionRect.bottom() |
|
138 }; |
|
139 |
|
140 m_inPlaceObject->SetObjectRects(&rcPos, &rcClip); |
|
141 } else { |
|
142 m_inPlaceObject->SetObjectRects(&rcClip, &rcClip); |
|
143 } |
125 } |
144 } |
126 |
145 |
127 m_displayRect = rect; |
146 m_displayRect = rect; |
128 } |
147 } |
129 |
148 |
151 |
170 |
152 emit nativeSizeChanged(); |
171 emit nativeSizeChanged(); |
153 } |
172 } |
154 } |
173 } |
155 |
174 |
156 QVideoWidget::AspectRatioMode QWmpVideoOverlay::aspectRatioMode() const |
175 Qt::AspectRatioMode QWmpVideoOverlay::aspectRatioMode() const |
157 { |
176 { |
158 return m_aspectRatioMode; |
177 return m_aspectRatioMode; |
159 } |
178 } |
160 |
179 |
161 void QWmpVideoOverlay::setAspectRatioMode(QVideoWidget::AspectRatioMode mode) |
180 void QWmpVideoOverlay::setAspectRatioMode(Qt::AspectRatioMode mode) |
162 { |
181 { |
163 switch (mode) { |
182 m_aspectRatioMode = mode; |
164 case QVideoWidget::KeepAspectRatio: |
183 |
165 m_player->put_stretchToFit(FALSE); |
184 m_player->put_stretchToFit(mode != Qt::KeepAspectRatio); |
166 |
185 |
167 m_aspectRatioMode = mode; |
186 setDisplayRect(m_displayRect); |
168 break; |
|
169 case QVideoWidget::IgnoreAspectRatio: |
|
170 m_player->put_stretchToFit(TRUE); |
|
171 |
|
172 m_aspectRatioMode = mode; |
|
173 break; |
|
174 default: |
|
175 break; |
|
176 } |
|
177 } |
187 } |
178 |
188 |
179 void QWmpVideoOverlay::repaint() |
189 void QWmpVideoOverlay::repaint() |
180 { |
190 { |
181 } |
191 } |
281 |
291 |
282 QueryInterface(IID_IOleInPlaceFrame, reinterpret_cast<void **>(ppFrame)); |
292 QueryInterface(IID_IOleInPlaceFrame, reinterpret_cast<void **>(ppFrame)); |
283 QueryInterface(IID_IOleInPlaceUIWindow, reinterpret_cast<void **>(ppDoc)); |
293 QueryInterface(IID_IOleInPlaceUIWindow, reinterpret_cast<void **>(ppDoc)); |
284 |
294 |
285 if (m_enabled) { |
295 if (m_enabled) { |
286 QRect rect = displayRect(); |
296 SetRect(lprcClipRect, |
287 |
297 m_displayRect.left(), |
288 SetRect(lprcPosRect, rect.left(), rect.top(), rect.right(), rect.bottom()); |
298 m_displayRect.top(), |
289 SetRect(lprcClipRect, rect.left(), rect.top(), rect.right(), rect.bottom()); |
299 m_displayRect.right(), |
|
300 m_displayRect.bottom()); |
|
301 |
|
302 if (m_aspectRatioMode == Qt::KeepAspectRatioByExpanding) { |
|
303 QSize size = m_sizeHint; |
|
304 size.scale( |
|
305 m_displayRect.width(), |
|
306 m_displayRect.height(), |
|
307 Qt::KeepAspectRatioByExpanding); |
|
308 |
|
309 QRect positionRect(QPoint(0, 0), size); |
|
310 positionRect.moveCenter(m_displayRect.center()); |
|
311 |
|
312 SetRect(lprcPosRect, |
|
313 positionRect.left(), |
|
314 positionRect.top(), |
|
315 positionRect.right(), |
|
316 positionRect.bottom()); |
|
317 } else { |
|
318 *lprcPosRect = *lprcClipRect; |
|
319 } |
290 } else { |
320 } else { |
291 SetRectEmpty(lprcPosRect); |
321 SetRectEmpty(lprcPosRect); |
292 SetRectEmpty(lprcClipRect); |
322 SetRectEmpty(lprcClipRect); |
293 } |
323 } |
294 |
324 |