18 bool WinStatsLabelStack::_window_class_registered =
false;
19 const char *
const WinStatsLabelStack::_window_class_name =
"stack";
25 WinStatsLabelStack() {
32 _highlight_label = -1;
39 ~WinStatsLabelStack() {
42 DestroyWindow(_window);
53 DestroyWindow(_window);
57 create_window(parent_window);
61 for (li = _labels.begin(); li != _labels.end(); ++li) {
63 label->
setup(_window);
73 return (_window != 0);
80 set_pos(
int x,
int y,
int width,
int height) {
85 SetWindowPos(_window, 0, x, y, _width, _height,
86 SWP_NOZORDER | SWP_SHOWWINDOW);
90 for (li = _labels.begin(); li != _labels.end(); ++li) {
143 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
144 return _labels[label_index]->get_y() +
get_y();
152 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), 0);
153 return _labels[label_index]->get_height();
161 nassertr(label_index >= 0 && label_index < (
int)_labels.size(), -1);
162 return _labels[label_index]->get_collector_index();
171 for (li = _labels.begin(); li != _labels.end(); ++li) {
183 int thread_index,
int collector_index,
bool use_fullname) {
185 if (!_labels.empty()) {
190 new WinStatsLabel(monitor, graph, thread_index, collector_index, use_fullname);
192 label->
setup(_window);
197 int label_index = (int)_labels.size();
198 _labels.push_back(label);
208 return _labels.size();
218 if (_highlight_label != collector_index) {
219 _highlight_label = collector_index;
221 for (li = _labels.begin(); li != _labels.end(); ++li) {
232 void WinStatsLabelStack::
233 create_window(HWND parent_window) {
238 HINSTANCE application = GetModuleHandle(
nullptr);
239 register_window_class(application);
242 CreateWindow(_window_class_name,
"label stack", WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
244 parent_window,
nullptr, application, 0);
246 nout <<
"Could not create Label Stack window!\n";
250 SetWindowLongPtr(_window, 0, (LONG_PTR)
this);
257 void WinStatsLabelStack::
258 register_window_class(HINSTANCE application) {
259 if (_window_class_registered) {
265 ZeroMemory(&wc,
sizeof(WNDCLASS));
267 wc.lpfnWndProc = (WNDPROC)static_window_proc;
268 wc.hInstance = application;
269 wc.hCursor = LoadCursor(
nullptr, IDC_ARROW);
270 wc.lpszMenuName =
nullptr;
271 wc.lpszClassName = _window_class_name;
276 if (!RegisterClass(&wc)) {
277 nout <<
"Could not register Label Stack window class!\n";
281 _window_class_registered =
true;
287 LONG WINAPI WinStatsLabelStack::
288 static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
290 if (
self !=
nullptr && self->_window == hwnd) {
291 return self->window_proc(hwnd, msg, wparam, lparam);
293 return DefWindowProc(hwnd, msg, wparam, lparam);
300 LONG WinStatsLabelStack::
301 window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
306 HDC hdc = BeginPaint(hwnd, &ps);
308 RECT rect = { 0, 0, _width, _height };
309 FillRect(hdc, &rect, (HBRUSH)COLOR_BACKGROUND);
318 return DefWindowProc(hwnd, msg, wparam, lparam);