winStatsLabel.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. ~WinStatsLabel();
  32. void setup(HWND parent_window);
  33. void set_pos(int x, int y, int width);
  34. int get_x() const;
  35. int get_y() const;
  36. int get_width() const;
  37. int get_height() const;
  38. int get_ideal_width() const;
  39. int get_collector_index() const;
  40. void set_highlight(bool highlight);
  41. bool get_highlight() const;
  42. private:
  43. void set_mouse_within(bool mouse_within);
  44. void create_window(HWND parent_window);
  45. static void register_window_class(HINSTANCE application);
  46. static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  47. LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
  48. WinStatsMonitor *_monitor;
  49. WinStatsGraph *_graph;
  50. int _thread_index;
  51. int _collector_index;
  52. std::string _text;
  53. HWND _window;
  54. COLORREF _bg_color;
  55. COLORREF _fg_color;
  56. HBRUSH _bg_brush;
  57. HBRUSH _highlight_brush;
  58. int _x;
  59. int _y;
  60. int _width;
  61. int _height;
  62. int _ideal_width;
  63. bool _highlight;
  64. bool _mouse_within;
  65. static int _left_margin, _right_margin;
  66. static int _top_margin, _bottom_margin;
  67. static bool _window_class_registered;
  68. static const char * const _window_class_name;
  69. };
  70. #endif