Team Fortress 2 Source Code as on 22/4/2020
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.

67 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Defines an autoselection combo box that color codes the text
  4. // based on whether the current selection represents a single entity,
  5. // multiple entities, or an unresolved entity targetname.
  6. //
  7. // The fonts are as follows:
  8. //
  9. // Single entity black, normal weight
  10. // Multiple entities black, bold
  11. // Unresolved red, normal weight
  12. //
  13. // $NoKeywords: $
  14. //=============================================================================//
  15. #ifndef TARGETNAMECOMBO_H
  16. #define TARGETNAMECOMBO_H
  17. #ifdef _WIN32
  18. #pragma once
  19. #endif
  20. #include <afxtempl.h>
  21. #include "FilteredComboBox.h"
  22. #include "utldict.h"
  23. class CTargetNameComboBox : public CFilteredComboBox, protected CFilteredComboBox::ICallbacks
  24. {
  25. typedef CFilteredComboBox BaseClass;
  26. public:
  27. CTargetNameComboBox( CFilteredComboBox::ICallbacks *pCallbacks );
  28. ~CTargetNameComboBox(void);
  29. // For dynamic creation.
  30. static CTargetNameComboBox* Create( CFilteredComboBox::ICallbacks *pCallbacks, DWORD dwStyle, RECT rect, CWnd *pParentWnd, UINT nID );
  31. // Initialize the control with the entity list you want it to represent.
  32. void SetEntityList(const CMapEntityList *pEntityList);
  33. // Gets the list of entities with this name. The data is valid until the next SetEntityList call.
  34. CMapEntityList* GetSubEntityList( const char *pName );
  35. protected:
  36. // CFilteredComboBox::ICallbacks
  37. virtual void OnTextChanged( const char *pText );
  38. void FreeSubLists(void);
  39. void CreateFonts();
  40. protected:
  41. CUtlDict<CMapEntityList*,int> m_EntityLists;
  42. const CMapEntityList *m_pEntityList;
  43. CTypedPtrList<CPtrList, CMapEntityList *> m_SubLists;
  44. CFilteredComboBox::ICallbacks *m_pPassThru;
  45. CFont m_BoldFont; // Bold font used when there are multiple matches.
  46. DECLARE_MESSAGE_MAP()
  47. };
  48. #endif // TARGETNAMECOMBO_H