CtrlEnumCombo.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. // CtrlEnumCombo.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "CtrlEnumCombo.h"
  16. #ifdef _DEBUG
  17. #undef new
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CCtrlEnumCombo
  24. CCtrlEnumCombo::CCtrlEnumCombo()
  25. {
  26. }
  27. CCtrlEnumCombo::~CCtrlEnumCombo()
  28. {
  29. }
  30. void CCtrlEnumCombo::SetDialogPtr( CPropertyComboBar *pDialog)
  31. {
  32. m_pDialog = pDialog;
  33. }
  34. BEGIN_MESSAGE_MAP(CCtrlEnumCombo, CComboBox)
  35. //{{AFX_MSG_MAP(CCtrlEnumCombo)
  36. ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
  37. ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropdown)
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CCtrlEnumCombo message handlers
  42. void CCtrlEnumCombo::OnSelchange()
  43. {
  44. theApp.GetDocument()->SetModifiedFlag( TRUE);
  45. // update dialog data (to reflect data change)
  46. m_pDialog->UpdateData( TRUE);
  47. m_pDialog->SetIntersectingEntityClassName();
  48. m_pDialog->ArrangeControls();
  49. m_pDialog->UpdateData( FALSE);
  50. }
  51. void CCtrlEnumCombo::OnDropdown()
  52. {
  53. INDEX ctItems = GetCount();
  54. if( ctItems == CB_ERR) return;
  55. CRect rectCombo;
  56. GetWindowRect( &rectCombo);
  57. PIX pixScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
  58. PIX pixMaxHeight = pixScreenHeight - rectCombo.top;
  59. m_pDialog->ScreenToClient( &rectCombo);
  60. PIX pixNewHeight = GetItemHeight(0)*(ctItems+2);
  61. rectCombo.bottom = rectCombo.top + ClampUp( pixNewHeight, pixMaxHeight);
  62. MoveWindow( rectCombo);
  63. }