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.

253 lines
9.3 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: CAMSEL.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 9/28/1999
  12. *
  13. * DESCRIPTION: Camera selection page. Displays thumbnails, and lets the user select which
  14. * ones to download.
  15. *
  16. *******************************************************************************/
  17. #ifndef __CAMSEL_H_INCLUDED
  18. #define __CAMSEL_H_INCLUDED
  19. #include <windows.h>
  20. #include "acqmgrcw.h"
  21. #include "simarray.h"
  22. #include "gphelper.h"
  23. #include "itranhlp.h"
  24. #include "createtb.h"
  25. #include "wiavideo.h"
  26. class CCameraSelectionPage
  27. {
  28. private:
  29. //
  30. // Used for icon grouping
  31. //
  32. class CListviewGroupInfo
  33. {
  34. private:
  35. CSimpleStringWide m_strGroupName;
  36. int m_nGroupId;
  37. public:
  38. CListviewGroupInfo(void)
  39. : m_strGroupName(TEXT("")),
  40. m_nGroupId(-1)
  41. {
  42. }
  43. CListviewGroupInfo( const CListviewGroupInfo &other )
  44. : m_strGroupName(other.GroupName()),
  45. m_nGroupId(other.GroupId())
  46. {
  47. }
  48. CListviewGroupInfo( const CSimpleStringWide &strGroupName, int nGroupId=-1 )
  49. : m_strGroupName(strGroupName),
  50. m_nGroupId(nGroupId)
  51. {
  52. }
  53. ~CListviewGroupInfo(void)
  54. {
  55. }
  56. CListviewGroupInfo &operator=( const CListviewGroupInfo &other )
  57. {
  58. if (this != &other)
  59. {
  60. m_strGroupName = other.GroupName();
  61. m_nGroupId = other.GroupId();
  62. }
  63. return *this;
  64. }
  65. bool operator==( const CListviewGroupInfo &other )
  66. {
  67. return (other.GroupName() == m_strGroupName);
  68. }
  69. bool operator==( const CSimpleStringWide &strGroupName )
  70. {
  71. return (strGroupName == m_strGroupName);
  72. }
  73. CSimpleStringWide GroupName(void) const
  74. {
  75. return m_strGroupName;
  76. }
  77. int GroupId(void) const
  78. {
  79. return m_nGroupId;
  80. }
  81. };
  82. class CIconGroupList : public CSimpleDynamicArray<CListviewGroupInfo>
  83. {
  84. private:
  85. CIconGroupList( const CIconGroupList & );
  86. CIconGroupList& operator=( const CIconGroupList & );
  87. public:
  88. CIconGroupList(void)
  89. {
  90. }
  91. ~CIconGroupList(void)
  92. {
  93. }
  94. int Add( HWND hwndList, const CSimpleStringWide &strwGroupName )
  95. {
  96. int nResult = -1;
  97. CSimpleString strGroupName = CSimpleStringConvert::NaturalString(strwGroupName);
  98. if (strGroupName.Length())
  99. {
  100. LVGROUP LvGroup = {0};
  101. LvGroup.cbSize = sizeof(LvGroup);
  102. LvGroup.pszHeader = const_cast<LPTSTR>(strGroupName.String());
  103. LvGroup.mask = LVGF_HEADER | LVGF_ALIGN | LVGF_GROUPID | LVGF_STATE;
  104. LvGroup.uAlign = LVGA_HEADER_LEFT;
  105. LvGroup.iGroupId = Size();
  106. LvGroup.state = LVGS_NORMAL;
  107. nResult = static_cast<int>(ListView_InsertGroup( hwndList, Size(), &LvGroup ));
  108. WIA_TRACE((TEXT("ListView_InsertGroup on %s returned %d"), strGroupName.String(), nResult ));
  109. if (nResult >= 0)
  110. {
  111. Append( CListviewGroupInfo( strwGroupName, nResult ) );
  112. }
  113. }
  114. return nResult;
  115. }
  116. int GetGroupId( CWiaItem *pWiaItem, HWND hwndList )
  117. {
  118. WIA_PUSH_FUNCTION((TEXT("GetGroupId(%ws)"),pWiaItem->ItemName().String()));
  119. int nResult = -1;
  120. if (Size())
  121. {
  122. nResult = (*this)[0].GroupId();
  123. if (pWiaItem)
  124. {
  125. CWiaItem *pWiaItemParent = pWiaItem->Parent();
  126. if (pWiaItemParent)
  127. {
  128. CSimpleStringWide strwFolderName = pWiaItemParent->ItemName();
  129. if (strwFolderName.Length())
  130. {
  131. int nIndex = Find(strwFolderName);
  132. if (nIndex < 0)
  133. {
  134. CSimpleString strFolderName = CSimpleStringConvert::NaturalString(strwFolderName);
  135. if (strFolderName.Length())
  136. {
  137. LVGROUP LvGroup = {0};
  138. LvGroup.cbSize = sizeof(LvGroup);
  139. LvGroup.pszHeader = const_cast<LPTSTR>(strFolderName.String());
  140. LvGroup.mask = LVGF_HEADER | LVGF_ALIGN | LVGF_GROUPID | LVGF_STATE;
  141. LvGroup.uAlign = LVGA_HEADER_LEFT;
  142. LvGroup.iGroupId = Size();
  143. LvGroup.state = LVGS_NORMAL;
  144. nResult = static_cast<int>(ListView_InsertGroup( hwndList, Size(), &LvGroup ));
  145. WIA_TRACE((TEXT("ListView_InsertGroup on %s returned %d"), strFolderName.String(), nResult ));
  146. if (nResult >= 0)
  147. {
  148. Append( CListviewGroupInfo( strwFolderName, nResult ) );
  149. }
  150. }
  151. }
  152. else
  153. {
  154. nResult = (*this)[nIndex].GroupId();
  155. }
  156. }
  157. }
  158. }
  159. }
  160. return nResult;
  161. }
  162. };
  163. CIconGroupList m_GroupInfoList;
  164. // Private data
  165. HWND m_hWnd;
  166. CAcquisitionManagerControllerWindow *m_pControllerWindow;
  167. int m_nDefaultThumbnailImageListIndex;
  168. int m_nProgrammaticSetting;
  169. CGdiPlusHelper m_GdiPlusHelper;
  170. UINT m_nThreadNotificationMessage;
  171. UINT m_nWiaEventMessage;
  172. bool m_bThumbnailsRequested;
  173. HICON m_hIconAudioAnnotation;
  174. HICON m_hIconMiscellaneousAnnotation;
  175. CComPtr<IWiaAnnotationHelpers> m_pWiaAnnotationHelpers;
  176. CComPtr<IWiaVideo> m_pWiaVideo;
  177. ToolbarHelper::CToolbarBitmapInfo m_CameraSelectionButtonBarBitmapInfo;
  178. ToolbarHelper::CToolbarBitmapInfo m_CameraTakePictureButtonBarBitmapInfo;
  179. ToolbarHelper::CToolbarBitmapInfo m_CameraActionButtonBarBitmapInfo;
  180. HACCEL m_hAccelerators;
  181. private:
  182. // No implementation
  183. CCameraSelectionPage(void);
  184. CCameraSelectionPage( const CCameraSelectionPage & );
  185. CCameraSelectionPage &operator=( const CCameraSelectionPage & );
  186. private:
  187. // Constructor and destructor
  188. explicit CCameraSelectionPage( HWND hWnd );
  189. ~CCameraSelectionPage(void);
  190. private:
  191. int AddItem( HWND hwndList, CWiaItem *pWiaItem, bool bEnsureVisible=false );
  192. void AddEnumeratedItems( HWND hwndList, CWiaItem *pFirstItem );
  193. void PopulateListView(void);
  194. CWiaItem *GetItemFromListByIndex( HWND hwndList, int nItem );
  195. int FindItemListIndex( HWND hwndList, CWiaItem *pWiaItem );
  196. int AddThumbnailToListViewImageList( HWND hwndList, CWiaItem *pWiaItem, int nIndex );
  197. int GetSelectionIndices( CSimpleDynamicArray<int> &aIndices );
  198. void UpdateControls(void);
  199. void InitializeVideoCamera(void);
  200. void DrawAnnotationIcons( HDC hDC, CWiaItem *pWiaItem, HBITMAP hBitmap );
  201. void MyEnableToolbarButton( int nButtonId, bool bEnable );
  202. void RepaintAllThumbnails();
  203. private:
  204. // WM_COMMAND handlers
  205. void OnSelectAll( WPARAM, LPARAM );
  206. void OnClearAll( WPARAM, LPARAM );
  207. void OnProperties( WPARAM, LPARAM );
  208. void OnRotate( WPARAM, LPARAM );
  209. void OnTakePicture( WPARAM, LPARAM );
  210. void OnDelete( WPARAM, LPARAM );
  211. // WM_NOTIFY handlers
  212. LRESULT OnWizNext( WPARAM, LPARAM );
  213. LRESULT OnWizBack( WPARAM, LPARAM );
  214. LRESULT OnSetActive( WPARAM, LPARAM );
  215. LRESULT OnTranslateAccelerator( WPARAM, LPARAM );
  216. LRESULT OnGetToolTipDispInfo( WPARAM, LPARAM );
  217. // Message handlers
  218. LRESULT OnInitDialog( WPARAM, LPARAM );
  219. LRESULT OnDestroy( WPARAM, LPARAM );
  220. LRESULT OnCommand( WPARAM, LPARAM );
  221. LRESULT OnNotify( WPARAM, LPARAM );
  222. LRESULT OnThreadNotification( WPARAM, LPARAM );
  223. LRESULT OnEventNotification( WPARAM, LPARAM );
  224. LRESULT OnThumbnailListSelChange( WPARAM, LPARAM );
  225. LRESULT OnThumbnailListKeyDown( WPARAM, LPARAM );
  226. LRESULT OnShowWindow( WPARAM, LPARAM );
  227. LRESULT OnTimer( WPARAM wParam, LPARAM );
  228. LRESULT OnSysColorChange( WPARAM, LPARAM );
  229. LRESULT OnThemeChanged( WPARAM, LPARAM );
  230. LRESULT OnSettingChange( WPARAM, LPARAM );
  231. // Thread notification message handlers
  232. void OnNotifyDownloadThumbnail( UINT, CThreadNotificationMessage * );
  233. void OnNotifyDownloadImage( UINT, CThreadNotificationMessage * );
  234. public:
  235. static INT_PTR CALLBACK DialogProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam );
  236. };
  237. #endif __CAMSEL_H_INCLUDED