-------------------------------------------------------------------------*/
| 659 | } |
| 660 | /*-------------------------------------------------------------------------*/ |
| 661 | void |
| 662 | onPaint(HWND hWnd) |
| 663 | { |
| 664 | PNHCmdWindow data; |
| 665 | PAINTSTRUCT ps; |
| 666 | HDC hDC; |
| 667 | int x, y; |
| 668 | TCHAR wbuf[BUFSZ]; |
| 669 | HGDIOBJ saveFont; |
| 670 | BITMAP bm; |
| 671 | int cell_index; |
| 672 | |
| 673 | /* get window data */ |
| 674 | data = (PNHCmdWindow) GetWindowLong(hWnd, GWL_USERDATA); |
| 675 | |
| 676 | hDC = BeginPaint(hWnd, &ps); |
| 677 | |
| 678 | if (!IsRectEmpty(&ps.rcPaint)) { |
| 679 | HGDIOBJ oldBr; |
| 680 | HBRUSH hbrPattern; |
| 681 | COLORREF OldBg, OldFg; |
| 682 | HPEN hPen; |
| 683 | HGDIOBJ hOldPen; |
| 684 | |
| 685 | saveFont = SelectObject(hDC, data->font[NH_CMDPAD_FONT_NORMAL]); |
| 686 | OldBg = SetBkColor(hDC, mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_BG)); |
| 687 | OldFg = |
| 688 | SetTextColor(hDC, mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_FG)); |
| 689 | |
| 690 | GetObject(data->images, sizeof(BITMAP), (LPVOID) &bm); |
| 691 | |
| 692 | hbrPattern = CreatePatternBrush(data->images); |
| 693 | hPen = CreatePen(PS_SOLID, 1, |
| 694 | mswin_get_color(NHW_KEYPAD, MSWIN_COLOR_FG)); |
| 695 | |
| 696 | for (x = 0, cell_index = 0; |
| 697 | x < nhcmdlayout_rows(data->layout_current); x++) |
| 698 | for (y = 0; y < nhcmdlayout_columns(data->layout_current); |
| 699 | y++, cell_index++) { |
| 700 | RECT cell_rt; |
| 701 | POINT pt[5]; |
| 702 | PNHCmdPadCell p_cell_data; |
| 703 | |
| 704 | p_cell_data = |
| 705 | nhcmdlayout_cell_direct(data->layout_current, cell_index); |
| 706 | |
| 707 | /* calculate the cell rectangle */ |
| 708 | cell_rt.left = data->cells[cell_index].orig.x; |
| 709 | cell_rt.top = data->cells[cell_index].orig.y; |
| 710 | cell_rt.right = data->cells[cell_index].orig.x |
| 711 | + data->cell_size.cx * p_cell_data->mult; |
| 712 | cell_rt.bottom = |
| 713 | data->cells[cell_index].orig.y + data->cell_size.cy; |
| 714 | |
| 715 | /* draw border */ |
| 716 | hOldPen = SelectObject(hDC, hPen); |
| 717 | pt[0].x = cell_rt.left; |
| 718 | pt[0].y = cell_rt.top; |
no test coverage detected