MCPcopy Create free account
hub / github.com/NetHack/NetHack / onPaint

Function onPaint

outdated/sys/wince/mhmsgwnd.c:482–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482void
483onPaint(HWND hWnd)
484{
485 PAINTSTRUCT ps;
486 HDC hdc;
487 PNHMessageWindow data;
488 RECT client_rt, draw_rt;
489 int FirstLine, LastLine;
490 int i, x, y;
491 HGDIOBJ oldFont;
492 TCHAR wbuf[MAXWINDOWTEXT + 2];
493 size_t wlen;
494 COLORREF OldBg, OldFg;
495
496 hdc = BeginPaint(hWnd, &ps);
497
498 OldBg = SetBkColor(hdc, mswin_get_color(NHW_MESSAGE, MSWIN_COLOR_BG));
499 OldFg = setMsgTextColor(hdc, 0);
500
501 data = (PNHMessageWindow) GetWindowLong(hWnd, GWL_USERDATA);
502
503 GetClientRect(hWnd, &client_rt);
504
505 if (!IsRectEmpty(&ps.rcPaint)) {
506 FirstLine = max(
507 0, data->yPos - (client_rt.bottom - ps.rcPaint.top) / data->yChar
508 + 1);
509 LastLine =
510 min(MSG_LINES - 1,
511 data->yPos
512 - (client_rt.bottom - ps.rcPaint.bottom) / data->yChar);
513 y = min(ps.rcPaint.bottom, client_rt.bottom - 2);
514 for (i = LastLine; i >= FirstLine; i--) {
515 if (i == MSG_LINES - 1) {
516 x = data->xChar * (2 - data->xPos);
517 } else {
518 x = data->xChar * (4 - data->xPos);
519 }
520
521 if (strlen(data->window_text[i].text) > 0) {
522 /* convert to UNICODE */
523 NH_A2W(data->window_text[i].text, wbuf, sizeof(wbuf));
524 wlen = _tcslen(wbuf);
525
526 /* calculate text height */
527 draw_rt.left = x;
528 draw_rt.right = client_rt.right;
529 draw_rt.top = y - data->yChar;
530 draw_rt.bottom = y;
531
532 oldFont = SelectObject(
533 hdc,
534 mswin_get_font(NHW_MESSAGE, data->window_text[i].attr,
535 hdc, FALSE));
536
537 setMsgTextColor(hdc, i < (MSG_LINES - data->lines_last_turn));
538#ifdef MSG_WRAP_TEXT
539 DrawText(hdc, wbuf, wlen, &draw_rt,

Callers 1

NHMessageWndProcFunction · 0.70

Calls 3

mswin_get_colorFunction · 0.85
setMsgTextColorFunction · 0.70
mswin_get_fontFunction · 0.70

Tested by

no test coverage detected