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.

258 lines
6.4 KiB

  1. /******************************************************************************
  2. * File: CDeviceUI.h
  3. *
  4. * Desc:
  5. *
  6. * CDeviceUI is a helper that holds all the views and a bunch of
  7. * information for a specific device. It has a CFlexWnd whose
  8. * handler it sets to the CDeviceView for the current view,
  9. * thus reusing one window to implement multiple pages.
  10. *
  11. * All CDeviceViews and CDeviceControls have a reference to the CDeviceUI
  12. * that created them (m_ui). Thus, they also have access to the
  13. * CUIGlobals, since CDeviceUI has a reference to them (m_ui.m_uig).
  14. * CDeviceUI also provides the following read-only public variables
  15. * for convenience, all referring to the device this CDeviceUI
  16. * represents:
  17. *
  18. * const DIDEVICEINSTANCEW &m_didi;
  19. * const LPDIRECTINPUTDEVICE8W &m_lpDID;
  20. * const DIDEVOBJSTRUCT &m_os;
  21. *
  22. * See usefuldi.h for a description of DIDEVOBJSTRUCT.
  23. *
  24. * CDeviceUI communicates to the rest of the UI via the CDeviceUINotify
  25. * abstract base class. Another class (in our case CDIDeviceActionConfigPage)
  26. * must derive from CDeviceUINotify, and define the DeviceUINotify() and
  27. * IsControlMapped() virtual functions. This derived class must be passed as
  28. * the last parameter to CDeviceUI's Init() function. All the views and
  29. * controls within the views notify the UI of user actions via m_ui.Notify(),
  30. * so that all actionformat manipulation can be done in the page class. The
  31. * views and controls themselves never touch the actionformat. See the
  32. * DEVICEUINOTIFY structure below for information on the parameter passed
  33. * through Notify()/DeviceUINotify().
  34. *
  35. * Copyright (C) 1999-2000 Microsoft Corporation. All Rights Reserved.
  36. *
  37. ***************************************************************************/
  38. #ifdef FORWARD_DECLS
  39. struct DEVICEUINOTIFY;
  40. struct UIDELETENOTE;
  41. class CDeviceUINotify;
  42. class CDeviceUI;
  43. #else // FORWARD_DECLS
  44. #ifndef __CDEVICEUI_H__
  45. #define __CDEVICEUI_H__
  46. enum {
  47. DEVUINM_NUMVIEWSCHANGED,
  48. DEVUINM_ONCONTROLDESTROY,
  49. DEVUINM_MOUSEOVER,
  50. DEVUINM_CLICK,
  51. DEVUINM_DOUBLECLICK,
  52. DEVUINM_SELVIEW,
  53. DEVUINM_INVALID,
  54. DEVUINM_UNASSIGNCALLOUT,
  55. DEVUINM_RENEWDEVICE
  56. };
  57. enum {
  58. DEVUINFROM_CONTROL,
  59. DEVUINFROM_THUMBNAIL,
  60. DEVUINFROM_SELWND,
  61. DEVUINFROM_VIEWWND,
  62. DEVUINFROM_INVALID
  63. };
  64. struct DEVICEUINOTIFY {
  65. DEVICEUINOTIFY() : msg(DEVUINM_INVALID), from(DEVUINFROM_INVALID) {}
  66. int msg;
  67. int from;
  68. union {
  69. struct {
  70. CDeviceControl *pControl;
  71. } control;
  72. struct {
  73. CDeviceView *pView;
  74. BOOL bSelected;
  75. } thumbnail;
  76. struct {
  77. int dummy;
  78. } selwnd;
  79. struct {
  80. int dummy;
  81. } viewwnd;
  82. };
  83. union {
  84. struct {
  85. int nView;
  86. } selview;
  87. struct {
  88. POINT point;
  89. } mouseover;
  90. struct {
  91. BOOL bLeftButton;
  92. } click;
  93. };
  94. };
  95. enum UIDELETENOTETYPE {
  96. UIDNT_VIEW,
  97. UIDNT_CONTROL,
  98. };
  99. struct UIDELETENOTE {
  100. UIDELETENOTETYPE eType;
  101. int nViewIndex;
  102. int nControlIndex;
  103. DWORD dwObjID;
  104. };
  105. typedef void (*DEVCTRLCALLBACK)(CDeviceControl *, LPVOID, BOOL);
  106. class CDeviceUINotify
  107. {
  108. public:
  109. virtual void DeviceUINotify(const DEVICEUINOTIFY &) = 0;
  110. virtual BOOL IsControlMapped(CDeviceControl *) = 0;
  111. };
  112. class CDeviceUI
  113. {
  114. public:
  115. CDeviceUI(CUIGlobals &uig, IDIConfigUIFrameWindow &uif);
  116. ~CDeviceUI();
  117. // intialization
  118. HRESULT Init(const DIDEVICEINSTANCEW &didi, LPDIRECTINPUTDEVICE8W lpDID, HWND hWnd, CDeviceUINotify *pNotify);
  119. // view state
  120. void SetView(int nView);
  121. void SetView(CDeviceView *pView);
  122. CDeviceView *GetView(int nView);
  123. CDeviceView *GetCurView();
  124. int GetViewIndex(CDeviceView *pView);
  125. int GetCurViewIndex();
  126. int GetNumViews() {return m_arpView.GetSize();}
  127. void NextView() {SetView((GetCurViewIndex() + 1) % GetNumViews());}
  128. void PrevView() {SetView((GetCurViewIndex() - 1 + GetNumViews()) % GetNumViews());}
  129. // gets the thumbnail for the specified view,
  130. // using the selected version if the view is selected
  131. CBitmap *GetViewThumbnail(int nView);
  132. // gets the thumbnail for the specified view,
  133. // specifiying whether or not we want the selected version
  134. CBitmap *GetViewThumbnail(int nView, BOOL bSelected);
  135. // for view/control to notify
  136. void Notify(const DEVICEUINOTIFY &uin)
  137. {if (m_pNotify != NULL) m_pNotify->DeviceUINotify(uin);}
  138. // device control access
  139. void SetAllControlCaptionsTo(LPCTSTR tszCaption);
  140. void SetCaptionForControlsAtOffset(DWORD dwOffset, LPCTSTR tszCaption, BOOL bFixed = FALSE);
  141. void DoForAllControls(DEVCTRLCALLBACK callback, LPVOID pVoid, BOOL bFixed = FALSE);
  142. void DoForAllControlsAtOffset(DWORD dwOffset, DEVCTRLCALLBACK callback, LPVOID pVoid, BOOL bFixed = FALSE);
  143. // page querying
  144. BOOL IsControlMapped(CDeviceControl *);
  145. // other
  146. void GetDeviceInstanceGuid(GUID &rGuid) {rGuid = m_didi.guidInstance;}
  147. // editing
  148. void SetEditMode(BOOL bEdit = TRUE);
  149. BOOL InEditMode() {return m_bInEditMode;}
  150. void Remove(CDeviceView *pView);
  151. void RemoveAll();
  152. #define NVT_USER 1
  153. #define NVT_POPULATE 2
  154. #define NVT_REQUIREATLEASTONE 3
  155. CDeviceView *NewView();
  156. CDeviceView *UserNewView();
  157. void RequireAtLeastOneView();
  158. //@@BEGIN_MSINTERNAL
  159. #ifdef DDKBUILD
  160. void SetStateIndication(LPCTSTR) {}
  161. void EndStateIndication() {}
  162. BOOL WriteToINI();
  163. #endif
  164. //@@END_MSINTERNAL
  165. void SetDevice(LPDIRECTINPUTDEVICE8W lpDID); // Sets the device object that we are using
  166. //@@BEGIN_MSINTERNAL
  167. #ifdef DDKBUILD
  168. // deletion noting
  169. void NoteDeleteView(CDeviceView *pView);
  170. void NoteDeleteView(int nView);
  171. void NoteDeleteControl(CDeviceControl *pControl);
  172. void NoteDeleteControl(int nView, int nControl, DWORD dwObjID);
  173. void NoteDeleteAllControlsForView(CDeviceView *pView);
  174. void NoteDeleteAllViews();
  175. // deletion querying
  176. int GetNumDeleteNotes();
  177. BOOL GetDeleteNote(UIDELETENOTE &uidn, int i);
  178. void ClearDeleteNotes();
  179. // deletion debugging
  180. void DumpDeleteNotes();
  181. #endif
  182. //@@END_MSINTERNAL
  183. // drawing
  184. void Invalidate();
  185. // clearing
  186. void Unpopulate();
  187. private:
  188. // delete notes
  189. CArray<UIDELETENOTE, UIDELETENOTE &> m_DeleteNotes;
  190. // who we're going to notify
  191. CDeviceUINotify *m_pNotify;
  192. HWND m_hWnd;
  193. // view state
  194. CArray<CDeviceView *, CDeviceView *&> m_arpView;
  195. CDeviceView *m_pCurView;
  196. BOOL m_bInEditMode;
  197. RECT m_ViewRect;
  198. void NumViewsChanged();
  199. // device globals...
  200. public:
  201. // full access to ui globals and frame
  202. CUIGlobals &m_uig;
  203. IDIConfigUIFrameWindow &m_UIFrame;
  204. // read only public access versions
  205. const DIDEVICEINSTANCEW &m_didi;
  206. const LPDIRECTINPUTDEVICE8W &m_lpDID;
  207. const DIDEVOBJSTRUCT &m_os;
  208. private:
  209. // private versions
  210. DIDEVICEINSTANCEW m_priv_didi;
  211. LPDIRECTINPUTDEVICE8W m_priv_lpDID;
  212. DIDEVOBJSTRUCT m_priv_os;
  213. };
  214. #endif //__CDEVICEUI_H__
  215. #endif // FORWARD_DECLS