Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.4 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: viewselwnd.cpp
  3. //
  4. // Desc: Implements CViewSelWnd class (derived from CFlexWnd). CViewSelWnd
  5. // is used by the page object when a device has more than one view.
  6. // CViewSelWnd displays one thumbnail for each view. The user can then
  7. // select which view he/she wants to see with the mouse.
  8. //
  9. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  10. //-----------------------------------------------------------------------------
  11. #include "common.hpp"
  12. CViewSelWnd::CViewSelWnd() :
  13. m_pUI(NULL), m_nOver(-1)
  14. {
  15. }
  16. CViewSelWnd::~CViewSelWnd()
  17. {
  18. }
  19. BOOL CViewSelWnd::Go(HWND hParent, int left, int bottom, CDeviceUI *pUI)
  20. {
  21. if (pUI == NULL)
  22. {
  23. assert(0);
  24. return FALSE;
  25. }
  26. m_pUI = pUI;
  27. int w = 2 + g_sizeThumb.cx * pUI->GetNumViews();
  28. int h = 2 + g_sizeThumb.cy;
  29. RECT rect = {left, bottom - h, left + w, bottom};
  30. if (!Create(hParent, rect, FALSE))
  31. return FALSE;
  32. assert(m_hWnd);
  33. if (!m_hWnd)
  34. return FALSE;
  35. SetWindowPos(m_hWnd, HWND_TOP, 0, 0, 0, 0,
  36. SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  37. SetCapture();
  38. return TRUE;
  39. }
  40. void CViewSelWnd::OnPaint(HDC hDC)
  41. {
  42. for (int i = 0; i < m_pUI->GetNumViews(); i++)
  43. {
  44. CBitmap *pbm = m_pUI->GetViewThumbnail(i, i == m_nOver);
  45. if (pbm != NULL)
  46. pbm->Draw(hDC, i * g_sizeThumb.cx + 1, 1);
  47. }
  48. CPaintHelper ph(m_pUI->m_uig, hDC);
  49. ph.SetPen(UIP_VIEWSELGRID);
  50. RECT rect;
  51. GetClientRect(&rect);
  52. ph.Rectangle(rect, UIR_OUTLINE);
  53. }
  54. void CViewSelWnd::OnMouseOver(POINT point, WPARAM fwKeys)
  55. {
  56. RECT rect;
  57. GetClientRect(&rect);
  58. InflateRect(&rect, -1, -1);
  59. if (PtInRect(&rect, point))
  60. m_nOver = point.x / g_sizeThumb.cx;
  61. else
  62. m_nOver = -1;
  63. Invalidate();
  64. }
  65. void CViewSelWnd::OnClick(POINT point, WPARAM fwKeys, BOOL bLeft)
  66. {
  67. if (!bLeft)
  68. return;
  69. OnMouseOver(point, fwKeys);
  70. if (m_nOver != -1)
  71. {
  72. DEVICEUINOTIFY uin;
  73. uin.msg = DEVUINM_SELVIEW;
  74. uin.from = DEVUINFROM_SELWND;
  75. uin.selview.nView = m_nOver;
  76. m_pUI->Notify(uin);
  77. }
  78. ReleaseCapture();
  79. Destroy();
  80. }
  81. LRESULT CViewSelWnd::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  82. {
  83. LRESULT lr = CFlexWnd::WndProc(hWnd, msg, wParam, lParam);
  84. switch (msg)
  85. {
  86. case WM_CAPTURECHANGED:
  87. Destroy();
  88. break;
  89. }
  90. return lr;
  91. }