Source code of Windows XP (NT5)
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.

186 lines
4.9 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: cdeviceview.h
  3. //
  4. // Desc: CDeviceView is a window class derived from CFlexWnd. It represents
  5. // the device view window in which the device and callouts are drawn.
  6. // Each CDeviceView only represents one view. A device that has more
  7. // than one view should have a corresponding number of CDeviceView for it.
  8. //
  9. // Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  10. //-----------------------------------------------------------------------------
  11. #ifdef FORWARD_DECLS
  12. enum DVIMAGE;
  13. class CDeviceView;
  14. #define DEFAULTVIEWSBWIDTH 11
  15. #else // FORWARD_DECLS
  16. #ifndef __CDEVICEVIEW_H__
  17. #define __CDEVICEVIEW_H__
  18. enum DVIMAGE {
  19. DVI_IMAGE,
  20. DVI_THUMB,
  21. DVI_SELTHUMB
  22. };
  23. class CDeviceView : public CFlexWnd
  24. {
  25. private:
  26. friend class CDeviceUI; // CDeviceUI has exclusive right to create/destroy views
  27. friend class CDIDeviceActionConfigPage;
  28. CDeviceView(CDeviceUI &ui);
  29. ~CDeviceView();
  30. CDeviceUI &m_ui;
  31. public:
  32. // Header information (for list view)
  33. BOOL CalculateHeaderRect(); // Compute rect used for headers.
  34. // control information
  35. int GetNumControls();
  36. CDeviceControl *GetControl(int nControl);
  37. CDeviceControl *GetControlFromOfs(DWORD dwOfs)
  38. { return GetControl(GetIndexFromOfs(dwOfs)); }
  39. // text information
  40. int GetNumTexts();
  41. CDeviceViewText *GetText(int nText);
  42. // text addition
  43. CDeviceViewText *NewText();
  44. CDeviceViewText *AddText(
  45. HFONT, COLORREF, COLORREF, const RECT &, LPCTSTR text);
  46. CDeviceViewText *AddText(
  47. HFONT, COLORREF, COLORREF, const POINT &, LPCTSTR text);
  48. CDeviceViewText *AddWrappedLineOfText(
  49. HFONT, COLORREF, COLORREF, LPCTSTR text);
  50. void SetImage(CBitmap *&refpbm);
  51. void SetImagePath(LPCTSTR tszPath);
  52. // imaging
  53. CBitmap *GetImage(DVIMAGE dvi);
  54. // editing
  55. //@@BEGIN_MSINTERNAL
  56. #ifdef DDKBUILD
  57. void SelectImages();
  58. void EditMenu(POINT point, CDeviceControl *pControl = NULL);
  59. #endif
  60. //@@END_MSINTERNAL
  61. void Remove(CDeviceControl *pControl);
  62. void RemoveAll(BOOL bUser = TRUE);
  63. BOOL DoesCalloutOtherThanSpecifiedExistForOffset(CDeviceControl *, DWORD);
  64. BOOL DoesCalloutExistForOffset(DWORD);
  65. BOOL IsUnassignedOffsetAvailable();
  66. int GetViewIndex();
  67. int GetIndexFromOfs(DWORD dwOfs); // For writing to INI
  68. //@@BEGIN_MSINTERNAL
  69. #ifdef DDKBUILD
  70. BOOL InMoveOverlayStateForControl(CDeviceControl *pControl);
  71. #endif
  72. //@@END_MSINTERNAL
  73. void MakeMissingImages();
  74. CDeviceControl *NewControl();
  75. protected:
  76. virtual void OnPaint(HDC hDC);
  77. //@@BEGIN_MSINTERNAL
  78. #ifdef DDKBUILD
  79. virtual LRESULT OnCommand(WORD wNotifyCode, WORD wID, HWND hWnd);
  80. #endif
  81. //@@END_MSINTERNAL
  82. virtual void OnMouseOver(POINT point, WPARAM fwKeys);
  83. virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  84. virtual void OnDoubleClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  85. virtual void OnWheel(POINT point, WPARAM wParam);
  86. virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  87. private:
  88. // helpers
  89. void Unpopulate(BOOL bInternalOnly = FALSE);
  90. // images/visualization
  91. CBitmap *m_pbmImage, *m_pbmThumb, *m_pbmSelThumb;
  92. LPTSTR m_ptszImagePath;
  93. CBitmap *GrabViewImage();
  94. //@@BEGIN_MSINTERNAL
  95. #ifdef DDKBUILD
  96. void ManualLoadImage(LPCTSTR tszPath);
  97. #endif
  98. //@@END_MSINTERNAL
  99. LPCTSTR GetImagePath() { return m_ptszImagePath; }
  100. // headers
  101. BOOL m_bControlHeaderClipped, m_bActionHeaderClipped; // Whether the header labels are clipped (flag for tooltip).
  102. RECT m_HeaderRectControl[2]; // 2 possible columns. Coord relative to parent's client space.
  103. RECT m_HeaderRectAction[2]; // 2 possible columns. Coord relative to parent's client space.
  104. // controls
  105. CArray<CDeviceControl *, CDeviceControl *&> m_arpControl;
  106. // text
  107. CArray<CDeviceViewText *, CDeviceViewText *&> m_arpText;
  108. POINT m_ptNextWLOText;
  109. // Special painting
  110. virtual void DoOnPaint(HDC hDC);
  111. BOOL m_bForcePaint; // This indicates that we need painting even if GetUpdateRect returns FALSE.
  112. // Sort assigned for keyboard devices
  113. void SwapControls(int i, int j);
  114. void SortAssigned(BOOL bSort);
  115. void SortCallouts(int iStart, int iEnd);
  116. // editting state machine
  117. int m_SuperState, m_State, m_SubState;
  118. int m_OldSuperState, m_OldState, m_OldSubState;
  119. CDeviceControl *m_pControlContext;
  120. //@@BEGIN_MSINTERNAL
  121. #ifdef DDKBUILD
  122. BOOL InEditState();
  123. void SetEditState(UINT cmd);
  124. void StateEvent(POINT point, BOOL bClick, BOOL bLeft, WPARAM nKeyState);
  125. void EndState();
  126. void IndicateState(BOOL bFirst = FALSE);
  127. void EndEditState();
  128. void SaveOrExport();
  129. BOOL WriteToINI();
  130. HRESULT ExportCodeTo(LPCTSTR tszFile);
  131. #endif
  132. //@@END_MSINTERNAL
  133. // scrolling (vertical only)
  134. BOOL m_bScrollEnable;
  135. int m_nScrollOffset;
  136. int m_nViewHeight;
  137. public:
  138. void EnableScrolling() {m_bScrollEnable = TRUE;}
  139. void ScrollToMakeControlVisible(const RECT &rc);
  140. void CalcDimensions();
  141. private:
  142. void DisableScrollBar();
  143. void EnableScrollBar();
  144. CFlexScrollBar m_sb;
  145. };
  146. #endif //__CDEVICEVIEW_H__
  147. #endif // FORWARD_DECLS