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.

89 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef ATTRIBUTETEXTENTRY_H
  9. #define ATTRIBUTETEXTENTRY_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "vgui_controls/TextEntry.h"
  14. #include "tier1/utlvector.h"
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CDmElement;
  19. class CAttributeTextPanel;
  20. class KeyValues;
  21. namespace vgui
  22. {
  23. class IScheme;
  24. class Label;
  25. class Menu;
  26. }
  27. //-----------------------------------------------------------------------------
  28. // CAttributeTextEntry
  29. //-----------------------------------------------------------------------------
  30. class CAttributeTextEntry : public vgui::TextEntry
  31. {
  32. DECLARE_CLASS_SIMPLE( CAttributeTextEntry, vgui::TextEntry );
  33. public:
  34. CAttributeTextEntry( Panel *parent, const char *panelName );
  35. virtual bool GetSelectedRange(int& cx0,int& cx1)
  36. {
  37. return BaseClass::GetSelectedRange( cx0, cx1 );
  38. }
  39. protected:
  40. CAttributeTextPanel *GetParentAttributePanel();
  41. virtual void OnMouseWheeled( int delta );
  42. // We'll only create an "undo" record if the values differ upon focus change
  43. virtual void OnSetFocus();
  44. virtual void OnKillFocus();
  45. virtual void OnKeyCodeTyped( vgui::KeyCode code );
  46. virtual void OnPanelDropped( CUtlVector< KeyValues * >& data );
  47. virtual bool GetDropContextMenu( vgui::Menu *menu, CUtlVector< KeyValues * >& msglist );
  48. virtual bool IsDroppable( CUtlVector< KeyValues * >& msglist );
  49. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  50. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
  51. private:
  52. enum
  53. {
  54. MAX_TEXT_LENGTH = 1024
  55. };
  56. template<class T> void ApplyMouseWheel( T newValue, T originalValue );
  57. void StoreInitialValue( bool bForce = false );
  58. void WriteValueToAttribute();
  59. void WriteInitialValueToAttribute();
  60. bool m_bValueStored;
  61. char m_szOriginalText[ MAX_TEXT_LENGTH ];
  62. union
  63. {
  64. float m_flOriginalValue;
  65. int m_nOriginalValue;
  66. bool m_bOriginalValue;
  67. };
  68. };
  69. // ----------------------------------------------------------------------------
  70. #endif // ATTRIBUTETEXTENTRY_H