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.

219 lines
5.4 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: listitem.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: RickTu
  10. *
  11. * DATE: 12/06/00
  12. *
  13. * DESCRIPTION: Implements an item class that encapsulates each item in
  14. * the photo list. Each of these items is backed by
  15. * a CPhotoItem class.
  16. *
  17. *****************************************************************************/
  18. #include <precomp.h>
  19. #pragma hdrstop
  20. /*****************************************************************************
  21. CListItem -- constructors/desctructor
  22. <Notes>
  23. *****************************************************************************/
  24. CListItem::CListItem( CPhotoItem * pItem, LONG lFrame )
  25. : _pImageInner(NULL),
  26. _bSelectedForPrinting(FALSE),
  27. _lFrameIndex(-1),
  28. _bJustAdded(TRUE),
  29. _bIsCopyItem(FALSE)
  30. {
  31. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM, TEXT("CListItem::CListItem( CPhotoItem(%d), Frame(%d) )"),pItem,lFrame));
  32. if (pItem)
  33. {
  34. pItem->AddRef();
  35. _pImageInner = pItem;
  36. }
  37. _lFrameIndex= lFrame;
  38. }
  39. CListItem::~CListItem()
  40. {
  41. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM, TEXT("CListItem::~CListItem()")));
  42. //
  43. // Free reference to backing CPhotoItem
  44. //
  45. if (_pImageInner)
  46. {
  47. _pImageInner->Release();
  48. }
  49. }
  50. /*****************************************************************************
  51. CListItem::GetClassBitmap
  52. Returns default icon for class (.jpg, .bmp, etc) for this item...
  53. *****************************************************************************/
  54. HBITMAP CListItem::GetClassBitmap( const SIZE &sizeDesired )
  55. {
  56. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::GetClassBitmap( size = %d,%d "),sizeDesired.cx, sizeDesired.cy ));
  57. if (_pImageInner)
  58. {
  59. return _pImageInner->GetClassBitmap( sizeDesired );
  60. }
  61. return NULL;
  62. }
  63. /*****************************************************************************
  64. CListItem::GetThumbnailBitmap
  65. Given a desired size, return an HBITMAP of the thumbnail
  66. for a this item. The caller MUST free the HBITMAP returned
  67. from this function.
  68. *****************************************************************************/
  69. HBITMAP CListItem::GetThumbnailBitmap( const SIZE &sizeDesired )
  70. {
  71. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::GetThumbnailBitmap( size = %d,%d "),sizeDesired.cx, sizeDesired.cy ));
  72. if (_pImageInner)
  73. {
  74. return _pImageInner->GetThumbnailBitmap( sizeDesired, _lFrameIndex );
  75. }
  76. return NULL;
  77. }
  78. /*****************************************************************************
  79. CListItem::Render
  80. Renders the given item into the Graphics that is supplied...
  81. *****************************************************************************/
  82. HRESULT CListItem::Render( RENDER_OPTIONS * pRO )
  83. {
  84. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::Render()")));
  85. if (_pImageInner && pRO)
  86. {
  87. pRO->lFrame = _lFrameIndex;
  88. return _pImageInner->Render( pRO );
  89. }
  90. return E_FAIL;
  91. }
  92. /*****************************************************************************
  93. CListItem::GetPIDL
  94. Returns the backing pidl for this item...
  95. *****************************************************************************/
  96. LPITEMIDLIST CListItem::GetPIDL()
  97. {
  98. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::GetPIDL()")));
  99. if (_pImageInner)
  100. {
  101. return _pImageInner->GetPIDL();
  102. }
  103. return NULL;
  104. }
  105. /*****************************************************************************
  106. CListItem::GetFilename
  107. Returns a CSimpleStringWide that contains the file name with any
  108. frame information. Caller is responsible for freeing returned
  109. CSimpleStringWide.
  110. *****************************************************************************/
  111. CSimpleStringWide * CListItem::GetFilename()
  112. {
  113. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::GetFilename()")));
  114. if (_pImageInner)
  115. {
  116. CSimpleStringWide * str = new CSimpleStringWide( CSimpleStringConvert::WideString(CSimpleString(_pImageInner->GetFilename())) );
  117. LONG lFrameCount = 0;
  118. HRESULT hr = _pImageInner->GetImageFrameCount( &lFrameCount );
  119. if (str && (str->Length() > 0) && SUCCEEDED(hr) && (lFrameCount > 1))
  120. {
  121. //
  122. // Construct suffix for pages
  123. //
  124. CSimpleString strSuffix;
  125. strSuffix.Format( IDS_FRAME_SUFFIX, g_hInst, _lFrameIndex + 1 );
  126. //
  127. // add suffix onto the end of the string we had
  128. //
  129. str->Concat( CSimpleStringConvert::WideString( strSuffix ) );
  130. }
  131. return str;
  132. }
  133. return NULL;
  134. }
  135. /*****************************************************************************
  136. CListItem::GetFileSize
  137. returns the size of the file, if known
  138. *****************************************************************************/
  139. LONGLONG CListItem::GetFileSize()
  140. {
  141. WIA_PUSH_FUNCTION_MASK((TRACE_LIST_ITEM,TEXT("CListItem::GetFileSize()")));
  142. if (_pImageInner)
  143. {
  144. return _pImageInner->GetFileSize();
  145. }
  146. return 0;
  147. }