comparison win/dw.c @ 436:98d6c00fe11e

Fix bug with specifying fonts with modifiers; the modifiers were not being stripped. Still may not be sufficient; see comment in code. Drawing filled and hollow rectangles now work the same as under GTK.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 May 2003 04:52:34 +0000
parents f977c80a1dfa
children fac2afe7bda3
comparison
equal deleted inserted replaced
435:0b52875e1588 436:98d6c00fe11e
3404 HFONT _acquire_font(HWND handle, char *fontname) 3404 HFONT _acquire_font(HWND handle, char *fontname)
3405 { 3405 {
3406 HFONT hfont; 3406 HFONT hfont;
3407 int z, size = 9; 3407 int z, size = 9;
3408 LOGFONT lf; 3408 LOGFONT lf;
3409 char *myFontName;
3409 3410
3410 if(fontname == DefaultFont || !fontname[0]) 3411 if(fontname == DefaultFont || !fontname[0])
3411 hfont = GetStockObject(DEFAULT_GUI_FONT); 3412 hfont = GetStockObject(DEFAULT_GUI_FONT);
3412 else 3413 else
3413 { 3414 {
3435 lf.lfCharSet = DEFAULT_CHARSET; 3436 lf.lfCharSet = DEFAULT_CHARSET;
3436 lf.lfOutPrecision = 0; 3437 lf.lfOutPrecision = 0;
3437 lf.lfClipPrecision = 0; 3438 lf.lfClipPrecision = 0;
3438 lf.lfQuality = DEFAULT_QUALITY; 3439 lf.lfQuality = DEFAULT_QUALITY;
3439 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; 3440 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE;
3440 strcpy(lf.lfFaceName, &fontname[z+1]); 3441 /*
3442 * remove any font modifiers by truncating at the first space
3443 * - this may not be enough!; what about "Courier New" ???
3444 */
3445 myFontName = strdup(&fontname[z+1]);
3446 for(z=0;z<strlen(myFontName);z++)
3447 if(myFontName[z] == ' ')
3448 {
3449 myFontName[z]='\0';
3450 break;
3451 }
3452 strcpy(lf.lfFaceName, myFontName);
3453 free(myFontName);
3441 3454
3442 hfont = CreateFontIndirect(&lf); 3455 hfont = CreateFontIndirect(&lf);
3443 #if 0 3456 #if 0
3444 ReleaseDC(handle, hDC); 3457 ReleaseDC(handle, hDC);
3445 #endif 3458 #endif
6887 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height) 6900 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int fill, int x, int y, int width, int height)
6888 { 6901 {
6889 HDC hdcPaint; 6902 HDC hdcPaint;
6890 HPEN oldPen; 6903 HPEN oldPen;
6891 HBRUSH oldBrush; 6904 HBRUSH oldBrush;
6905 RECT Rect;
6892 int threadid = dw_thread_id(); 6906 int threadid = dw_thread_id();
6893 6907
6894 if(threadid < 0 || threadid >= THREAD_LIMIT) 6908 if(threadid < 0 || threadid >= THREAD_LIMIT)
6895 threadid = 0; 6909 threadid = 0;
6896 6910
6899 else if(pixmap) 6913 else if(pixmap)
6900 hdcPaint = pixmap->hdc; 6914 hdcPaint = pixmap->hdc;
6901 else 6915 else
6902 return; 6916 return;
6903 6917
6904 oldPen = SelectObject(hdcPaint, _hPen[threadid]); 6918 SetRect(&Rect, x, y, x + width , y + height );
6905 oldBrush = SelectObject(hdcPaint, _hBrush[threadid]); 6919 if(fill)
6906 Rectangle(hdcPaint, x, y, x + width, y + height); 6920 FillRect(hdcPaint, &Rect, _hBrush[threadid]);
6907 SelectObject(hdcPaint, oldPen); 6921 else
6908 SelectObject(hdcPaint, oldBrush); 6922 FrameRect(hdcPaint, &Rect, _hBrush[threadid]);
6909 if(!pixmap) 6923 if(!pixmap)
6910 ReleaseDC(handle, hdcPaint); 6924 ReleaseDC(handle, hdcPaint);
6911 } 6925 }
6912 6926
6913 /* Draw text on a window (preferably a render window). 6927 /* Draw text on a window (preferably a render window).