winStatsLabel.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file winStatsLabel.h
  10. * @author drose
  11. * @date 2004-01-07
  12. */
  13. #ifndef WINSTATSLABEL_H
  14. #define WINSTATSLABEL_H
  15. #include "pandatoolbase.h"
  16. #ifndef WIN32_LEAN_AND_MEAN
  17. #define WIN32_LEAN_AND_MEAN 1
  18. #endif
  19. #include <windows.h>
  20. class WinStatsMonitor;
  21. class WinStatsGraph;
  22. /**
  23. * A text label that will draw in color appropriate for a particular
  24. * collector. It also responds when the user double-clicks on it. This is
  25. * handy for putting colored labels on strip charts.
  26. */
  27. class WinStatsLabel {
  28. public:
  29. WinStatsLabel(WinStatsMonitor *monitor, WinStatsGraph *graph,
  30. int thread_index, int collector_index, bool use_fullname,
  31. bool align_right = true);
  32. ~WinStatsLabel();
  33. void setup(HWND parent_window);
  34. void set_pos(int x, int y, int width);
  35. void set_y_noupdate(int y);
  36. INLINE int get_x() const;
  37. INLINE int get_y() const;
  38. INLINE int get_width() const;
  39. INLINE int get_height() const;
  40. INLINE int get_ideal_width() const;
  41. INLINE int get_collector_index() const;
  42. void set_highlight(bool highlight);
  43. INLINE bool get_highlight() const;
  44. void update_color();
  45. void update_text(bool use_fullname);
  46. private:
  47. void set_mouse_within(bool mouse_within);
  48. void create_window(HWND parent_window);
  49. static void register_window_class(HINSTANCE application);
  50. static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  51. LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  52. WinStatsMonitor *_monitor;
  53. WinStatsGraph *_graph;
  54. int _thread_index;
  55. int _collector_index;
  56. std::string _text;
  57. std::string _tooltip_text;
  58. HWND _window;
  59. HWND _tooltip_window;
  60. COLORREF _fg_color;
  61. COLORREF _highlight_fg_color;
  62. HBRUSH _bg_brush = 0;
  63. HBRUSH _highlight_bg_brush = 0;
  64. int _x;
  65. int _y;
  66. int _width;
  67. int _height;
  68. int _ideal_width;
  69. bool _highlight;
  70. bool _mouse_within;
  71. bool _align_right;
  72. static int _left_margin, _right_margin;
  73. static int _top_margin, _bottom_margin;
  74. static bool _window_class_registered;
  75. static const char * const _window_class_name;
  76. };
  77. #include "winStatsLabel.I"
  78. #endif