PrimitiveHistoryCombo.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // PrimitiveHistoryCombo.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "WorldEditor.h"
  16. #include "PrimitiveHistoryCombo.h"
  17. #ifdef _DEBUG
  18. #undef new
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CPrimitiveHistoryCombo
  25. CPrimitiveHistoryCombo::CPrimitiveHistoryCombo()
  26. {
  27. }
  28. CPrimitiveHistoryCombo::~CPrimitiveHistoryCombo()
  29. {
  30. }
  31. BEGIN_MESSAGE_MAP(CPrimitiveHistoryCombo, CComboBox)
  32. //{{AFX_MSG_MAP(CPrimitiveHistoryCombo)
  33. // NOTE - the ClassWizard will add and remove mapping macros here.
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CPrimitiveHistoryCombo message handlers
  38. void CPrimitiveHistoryCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
  39. {
  40. INDEX iItem = lpDrawItemStruct->itemID;
  41. BOOL bSelected = lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED);
  42. COLORREF clrfBcgColor;
  43. UINT ulEdgeType;
  44. if( bSelected)
  45. {
  46. clrfBcgColor = CLRF_CLR( 0xDFDFFF00UL);
  47. ulEdgeType = EDGE_SUNKEN;
  48. }
  49. else
  50. {
  51. clrfBcgColor = CLRF_CLR( C_WHITE);
  52. ulEdgeType = EDGE_RAISED;
  53. }
  54. CValuesForPrimitive *pVFP = (CValuesForPrimitive *) GetItemData( iItem);
  55. if( (ULONG) pVFP == CB_ERR) return;
  56. CDC *pDC = CDC::FromHandle( lpDrawItemStruct->hDC);
  57. RECT rectItem = lpDrawItemStruct->rcItem;
  58. pDC->SetBkMode( TRANSPARENT);
  59. pDC->SetBkColor( clrfBcgColor);
  60. pDC->FillSolidRect( &rectItem, clrfBcgColor);
  61. // polygon color
  62. RECT rectPolygon = rectItem;
  63. rectPolygon.top+=1;
  64. rectPolygon.bottom-=1;
  65. rectPolygon.left += 2;
  66. rectPolygon.right = rectPolygon.left+16;
  67. COLORREF clrfColor = CLRF_CLR( pVFP->vfp_colPolygonsColor);
  68. pDC->FillSolidRect( &rectPolygon, clrfColor);
  69. // sector color
  70. RECT rectSector = rectPolygon;
  71. rectSector.left += 16;
  72. rectSector.right += 16;
  73. clrfColor = CLRF_CLR( pVFP->vfp_colSectorsColor);
  74. pDC->FillSolidRect( &rectSector, clrfColor);
  75. RECT rectBorder = rectPolygon;
  76. rectBorder.right += 16;
  77. pDC->DrawEdge( &rectBorder, ulEdgeType, BF_RECT);
  78. // used for rendering from left to right
  79. PIX pixCursor = 38;
  80. UINT uiPrimitiveIconID;
  81. switch( pVFP->vfp_ptPrimitiveType)
  82. {
  83. case PT_CONUS:{ uiPrimitiveIconID = IDR_ICON_CONUS; break;}
  84. case PT_TORUS:{ uiPrimitiveIconID = IDR_ICON_TORUS; break;}
  85. case PT_STAIRCASES:
  86. {
  87. if( pVFP->vfp_bLinearStaircases) uiPrimitiveIconID = IDR_ICON_LINEAR_STAIRCASES;
  88. else uiPrimitiveIconID = IDR_ICON_SPIRAL_STAIRCASES;
  89. break;
  90. }
  91. case PT_SPHERE:{ uiPrimitiveIconID = IDR_ICON_SPHERE; break;}
  92. case PT_TERRAIN:{ uiPrimitiveIconID = IDR_ICON_TERRAIN; break;}
  93. }
  94. HICON hPrimitiveIcon = theApp.LoadIcon( uiPrimitiveIconID);
  95. pDC->DrawIcon( pixCursor, rectItem.top, hPrimitiveIcon);
  96. pixCursor += 22;
  97. UINT uiPrimitiveOperationID;
  98. switch( pVFP->vfp_csgtCSGOperation)
  99. {
  100. case CSG_ADD: { uiPrimitiveOperationID = IDR_ICON_ADD; break;}
  101. case CSG_ADD_REVERSE: { uiPrimitiveOperationID = IDR_ICON_ADD_REVERSE; break;}
  102. case CSG_REMOVE: { uiPrimitiveOperationID = IDR_ICON_REMOVE; break;}
  103. case CSG_REMOVE_REVERSE: { uiPrimitiveOperationID = IDR_ICON_REMOVE_REVERSE; break;}
  104. case CSG_SPLIT_SECTORS: { uiPrimitiveOperationID = IDR_ICON_SPLIT_SECTORS; break;}
  105. case CSG_SPLIT_POLYGONS: { uiPrimitiveOperationID = IDR_ICON_SPLIT_POLYGONS; break;}
  106. case CSG_JOIN_LAYERS: { uiPrimitiveOperationID = IDR_ICON_JOIN_LAYERS; break;}
  107. }
  108. HICON hOperationIcon = theApp.LoadIcon( uiPrimitiveOperationID);
  109. pDC->DrawIcon( pixCursor, rectItem.top, hOperationIcon);
  110. pixCursor += 22;
  111. HICON hRoomIcon;
  112. if( pVFP->vfp_bClosed) hRoomIcon = theApp.LoadIcon( IDR_ICON_ROOM);
  113. else hRoomIcon = theApp.LoadIcon( IDR_ICON_MATERIAL);
  114. pDC->DrawIcon( pixCursor, rectItem.top, hRoomIcon);
  115. pixCursor += 22;
  116. if( !pVFP->vfp_bOuter &&
  117. (pVFP->vfp_csgtCSGOperation != PT_SPHERE) &&
  118. (pVFP->vfp_csgtCSGOperation != PT_TERRAIN) )
  119. {
  120. HICON hOuterIcon;
  121. hOuterIcon = theApp.LoadIcon( IDR_ICON_INNER);
  122. pDC->DrawIcon( pixCursor, rectItem.top, hOuterIcon);
  123. pixCursor += 22;
  124. }
  125. if( pVFP->vfp_ptPrimitiveType == PT_STAIRCASES)
  126. {
  127. HICON hTopStairsIcon;
  128. if( pVFP->vfp_iTopShape == 0) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_STAIRS);
  129. else if( pVFP->vfp_iTopShape == 1) hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_SLOPE);
  130. else hTopStairsIcon = theApp.LoadIcon( IDR_ICON_TOP_CEILING);
  131. pDC->DrawIcon( pixCursor, rectItem.top, hTopStairsIcon);
  132. pixCursor += 22;
  133. HICON hBottomStairsIcon;
  134. if( pVFP->vfp_iTopShape == 0) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_STAIRS);
  135. else if( pVFP->vfp_iTopShape == 1) hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_SLOPE);
  136. else hBottomStairsIcon = theApp.LoadIcon( IDR_ICON_BOTTOM_FLOOR);
  137. pDC->DrawIcon( pixCursor, rectItem.top, hBottomStairsIcon);
  138. pixCursor += 22;
  139. }
  140. // obtain text of drawing item
  141. CString strText;
  142. GetLBText( iItem, strText);
  143. pDC->TextOut( pixCursor, rectItem.top, strText);
  144. }
  145. void CPrimitiveHistoryCombo::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
  146. {
  147. }