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.

103 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TABWINDOW_H
  8. #define TABWINDOW_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <mxtk/mx.h>
  13. #include "utlvector.h"
  14. class CDrawHelper;
  15. //-----------------------------------------------------------------------------
  16. // Purpose: A custom tab control for handling expression class strings
  17. //-----------------------------------------------------------------------------
  18. class CTabWindow : public mxWindow
  19. {
  20. public:
  21. enum
  22. {
  23. COLOR_BG = 0,
  24. COLOR_FG,
  25. COLOR_FG_SELECTED,
  26. COLOR_HILITE,
  27. COLOR_HILITE_SELECTED,
  28. COLOR_TEXT,
  29. COLOR_TEXT_SELECTED,
  30. NUM_COLORS
  31. };
  32. CTabWindow( mxWindow *parent, int x, int y, int w, int h, int id = 0, int style = 0 );
  33. virtual ~CTabWindow ( void );
  34. virtual void redraw( void );
  35. virtual int handleEvent (mxEvent *event);
  36. // MANIPULATORS
  37. virtual void add (const char *item);
  38. virtual void select (int index);
  39. virtual void remove (int index);
  40. virtual void removeAll ();
  41. virtual void setPrefix( int item, char const *prefix );
  42. // ACCESSORS
  43. virtual int getItemCount () const;
  44. virtual int getSelectedIndex () const;
  45. virtual char const *getLabel( int item );
  46. virtual char const *getPrefix( int item );
  47. virtual void ShowRightClickMenu( int mx, int my ) = 0;
  48. void SetColor( int index, COLORREF clr );
  49. void SetInverted( bool invert );
  50. void SetRightJustify( bool rightjustify );
  51. int GetBestHeight( int width );
  52. void SetRowHeight( int rowheight );
  53. protected:
  54. void GetTabRect( const RECT& rcClient, RECT& tabRect, int tabNum );
  55. virtual void DrawTab( CDrawHelper& drawHelper, RECT& rcClient, int tabnum, bool selected = false );
  56. int RecomputeLayout( int windowWidth, bool dolayout = true );
  57. class CETItem
  58. {
  59. public:
  60. enum
  61. {
  62. MAX_ET_STRING_LENGTH = 64
  63. };
  64. char m_szString[ MAX_ET_STRING_LENGTH ];
  65. char m_szPrefix[ MAX_ET_STRING_LENGTH ];
  66. RECT rect;
  67. };
  68. int GetItemUnderMouse( int mx, int my );
  69. CUtlVector <CETItem> m_Items;
  70. int m_nRowsRequired;
  71. int m_nSelected;
  72. int m_nTabWidth;
  73. int m_nPixelDelta;
  74. bool m_bInverted;
  75. bool m_bRightJustify;
  76. COLORREF m_Colors[ NUM_COLORS ];
  77. int m_nRowHeight;
  78. };
  79. #endif // TABWINDOW_H