Mercurial > dwindows
comparison win/dw.c @ 1682:ea749fb90f7e
Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
Enable antialiasing for rectangles on Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 29 Apr 2012 19:46:30 +0000 |
parents | e02101d1b8ba |
children | 19c34a1c1489 |
comparison
equal
deleted
inserted
replaced
1681:e02101d1b8ba | 1682:ea749fb90f7e |
---|---|
9763 * x: X coordinate. | 9763 * x: X coordinate. |
9764 * y: Y coordinate. | 9764 * y: Y coordinate. |
9765 */ | 9765 */ |
9766 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) | 9766 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y) |
9767 { | 9767 { |
9768 #ifdef GDIPLUS | |
9769 /* There doesn't seem to be an equivalent to SetPixel in GDI+ ... | |
9770 * so instead we call dw_draw_rect() with 1 for width and height. | |
9771 */ | |
9772 dw_draw_rect(handle, pixmap, DW_DRAW_FILL | DW_DRAW_NOAA, x, y, 1, 1); | |
9773 #else | |
9768 HDC hdcPaint; | 9774 HDC hdcPaint; |
9769 | 9775 |
9770 if(handle) | 9776 if(handle) |
9771 hdcPaint = GetDC(handle); | 9777 hdcPaint = GetDC(handle); |
9772 else if(pixmap) | 9778 else if(pixmap) |
9775 return; | 9781 return; |
9776 | 9782 |
9777 SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground)); | 9783 SetPixel(hdcPaint, x, y, (COLORREF)TlsGetValue(_foreground)); |
9778 if(!pixmap) | 9784 if(!pixmap) |
9779 ReleaseDC(handle, hdcPaint); | 9785 ReleaseDC(handle, hdcPaint); |
9786 #endif | |
9780 } | 9787 } |
9781 | 9788 |
9782 /* Draw a line on a window (preferably a render window). | 9789 /* Draw a line on a window (preferably a render window). |
9783 * Parameters: | 9790 * Parameters: |
9784 * handle: Handle to the window. | 9791 * handle: Handle to the window. |
9953 * width: Width of rectangle. | 9960 * width: Width of rectangle. |
9954 * height: Height of rectangle. | 9961 * height: Height of rectangle. |
9955 */ | 9962 */ |
9956 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height) | 9963 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height) |
9957 { | 9964 { |
9958 #ifdef GDIPLUS | 9965 #ifdef GDIPLUS |
9959 GpGraphics *graphics = NULL; | 9966 GpGraphics *graphics = NULL; |
9960 | 9967 |
9961 if(handle) | 9968 if(handle) |
9962 GdipCreateFromHWND(handle, &graphics); | 9969 GdipCreateFromHWND(handle, &graphics); |
9963 else if(pixmap) | 9970 else if(pixmap) |
9964 GdipCreateFromHDC(pixmap->hdc, &graphics); | 9971 GdipCreateFromHDC(pixmap->hdc, &graphics); |
9965 else | 9972 else |
9966 return; | 9973 return; |
9967 | 9974 |
9975 /* Enable antialiasing if the DW_DRAW_NOAA flag isn't set */ | |
9976 if(!(flags & DW_DRAW_NOAA)) | |
9977 GdipSetSmoothingMode(graphics, SmoothingModeAntiAlias); | |
9978 | |
9968 if(flags & DW_DRAW_FILL) | 9979 if(flags & DW_DRAW_FILL) |
9969 { | 9980 { |
9970 GpBrush *brush = TlsGetValue(_gpBrush); | 9981 GpBrush *brush = TlsGetValue(_gpBrush); |
9971 | 9982 |
9972 GdipFillRectangleI(graphics, brush, x, y, width, height); | 9983 GdipFillRectangleI(graphics, brush, x, y, width, height); |
10105 int mustdelete = 0; | 10116 int mustdelete = 0; |
10106 HFONT hFont = 0, oldFont = 0; | 10117 HFONT hFont = 0, oldFont = 0; |
10107 ColorInfo *cinfo = NULL; | 10118 ColorInfo *cinfo = NULL; |
10108 COLORREF background; | 10119 COLORREF background; |
10109 TCHAR *wtext = UTF8toWide(text); | 10120 TCHAR *wtext = UTF8toWide(text); |
10121 POINT pt; | |
10110 | 10122 |
10111 if(handle) | 10123 if(handle) |
10112 hdc = GetDC(handle); | 10124 hdc = GetDC(handle); |
10113 else if(pixmap) | 10125 else if(pixmap) |
10114 hdc = pixmap->hdc; | 10126 hdc = pixmap->hdc; |
10137 else | 10149 else |
10138 { | 10150 { |
10139 SetBkMode(hdc, OPAQUE); | 10151 SetBkMode(hdc, OPAQUE); |
10140 SetBkColor(hdc, background); | 10152 SetBkColor(hdc, background); |
10141 } | 10153 } |
10142 TextOut(hdc, x, y, wtext, (int)_tcslen(wtext)); | 10154 pt.x = x; |
10155 pt.y = y; | |
10156 #ifdef GDIPLUS1 | |
10157 LPtoDP(hdc, &pt, 1); | |
10158 #endif | |
10159 TextOut(hdc, pt.x, pt.y, wtext, (int)_tcslen(wtext)); | |
10143 if(oldFont) | 10160 if(oldFont) |
10144 SelectObject(hdc, oldFont); | 10161 SelectObject(hdc, oldFont); |
10145 if(mustdelete) | 10162 if(mustdelete) |
10146 DeleteObject(hFont); | 10163 DeleteObject(hFont); |
10147 if(!pixmap) | 10164 if(!pixmap) |