Mercurial > dwindows
comparison win/dw.c @ 67:ab9b0fa6c66e
Focus fixes and removal of several hack in the OS/2 code base.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 22 Jan 2002 10:55:20 +0000 |
parents | a6801a2260af |
children | 8d6100960adf |
comparison
equal
deleted
inserted
replaced
66:664a274a46a6 | 67:ab9b0fa6c66e |
---|---|
3003 void dw_window_reparent(HWND handle, HWND newparent) | 3003 void dw_window_reparent(HWND handle, HWND newparent) |
3004 { | 3004 { |
3005 SetParent(handle, newparent); | 3005 SetParent(handle, newparent); |
3006 } | 3006 } |
3007 | 3007 |
3008 HFONT _aquire_font(char *fontname) | 3008 HFONT _acquire_font(HWND handle, char *fontname) |
3009 { | 3009 { |
3010 HFONT hfont; | 3010 HFONT hfont; |
3011 int z, size = 9; | 3011 int z, size = 9; |
3012 LOGFONT lf; | 3012 LOGFONT lf; |
3013 | 3013 |
3014 if(fontname == DefaultFont) | 3014 if(fontname == DefaultFont) |
3015 hfont = GetStockObject(DEFAULT_GUI_FONT); | 3015 hfont = GetStockObject(DEFAULT_GUI_FONT); |
3016 else | 3016 else |
3017 { | 3017 { |
3018 #if 0 | |
3019 HDC hDC = GetDC(handle); | |
3020 #endif | |
3018 for(z=0;z<strlen(fontname);z++) | 3021 for(z=0;z<strlen(fontname);z++) |
3019 { | 3022 { |
3020 if(fontname[z]=='.') | 3023 if(fontname[z]=='.') |
3021 break; | 3024 break; |
3022 } | 3025 } |
3023 size = atoi(fontname) + 5; | 3026 size = atoi(fontname) + 5; |
3024 | 3027 |
3028 #if 0 | |
3029 lf.lfHeight = -MulDiv(size, GetDeviceCaps(hDC, LOGPIXELSY), 72); | |
3030 #endif | |
3025 lf.lfHeight = size; | 3031 lf.lfHeight = size; |
3026 lf.lfWidth = 0; | 3032 lf.lfWidth = 0; |
3027 lf.lfEscapement = 0; | 3033 lf.lfEscapement = 0; |
3028 lf.lfOrientation = 0; | 3034 lf.lfOrientation = 0; |
3029 lf.lfItalic = 0; | 3035 lf.lfItalic = 0; |
3036 lf.lfQuality = DEFAULT_QUALITY; | 3042 lf.lfQuality = DEFAULT_QUALITY; |
3037 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; | 3043 lf.lfPitchAndFamily = DEFAULT_PITCH | FW_DONTCARE; |
3038 strcpy(lf.lfFaceName, &fontname[z+1]); | 3044 strcpy(lf.lfFaceName, &fontname[z+1]); |
3039 | 3045 |
3040 hfont = CreateFontIndirect(&lf); | 3046 hfont = CreateFontIndirect(&lf); |
3047 #if 0 | |
3048 ReleaseDC(handle, hDC); | |
3049 #endif | |
3041 } | 3050 } |
3042 return hfont; | 3051 return hfont; |
3043 } | 3052 } |
3044 | 3053 |
3045 /* | 3054 /* |
3048 * handle: The window (widget) handle. | 3057 * handle: The window (widget) handle. |
3049 * fontname: Name and size of the font in the form "size.fontname" | 3058 * fontname: Name and size of the font in the form "size.fontname" |
3050 */ | 3059 */ |
3051 int dw_window_set_font(HWND handle, char *fontname) | 3060 int dw_window_set_font(HWND handle, char *fontname) |
3052 { | 3061 { |
3053 HFONT hfont = _aquire_font(fontname); | 3062 HFONT hfont = _acquire_font(handle, fontname); |
3054 ColorInfo *cinfo; | 3063 ColorInfo *cinfo; |
3055 | 3064 |
3056 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 3065 cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
3057 | 3066 |
3058 if(fontname) | 3067 if(fontname) |
3071 | 3080 |
3072 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | 3081 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); |
3073 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); | 3082 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); |
3074 } | 3083 } |
3075 } | 3084 } |
3076 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, FALSE); | 3085 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); |
3077 return 0; | 3086 return 0; |
3078 } | 3087 } |
3079 | 3088 |
3080 /* | 3089 /* |
3081 * Sets the colors used by a specified window (widget) handle. | 3090 * Sets the colors used by a specified window (widget) handle. |
5419 int z; | 5428 int z; |
5420 static HWND lasthwnd = NULL; | 5429 static HWND lasthwnd = NULL; |
5421 | 5430 |
5422 if(!hSmall || !hLarge) | 5431 if(!hSmall || !hLarge) |
5423 { | 5432 { |
5424 hSmall = ImageList_Create(16, 16, ILC_COLOR16, ICON_INDEX_LIMIT, 0); | 5433 hSmall = ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0); |
5425 hLarge = ImageList_Create(32, 32, ILC_COLOR16, ICON_INDEX_LIMIT, 0); | 5434 hLarge = ImageList_Create(32, 32, ILC_COLOR16 | ILC_MASK, ICON_INDEX_LIMIT, 0); |
5426 } | 5435 } |
5427 for(z=0;z<ICON_INDEX_LIMIT;z++) | 5436 for(z=0;z<ICON_INDEX_LIMIT;z++) |
5428 { | 5437 { |
5429 if(!lookup[z]) | 5438 if(!lookup[z]) |
5430 { | 5439 { |
5937 else | 5946 else |
5938 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA); | 5947 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA); |
5939 | 5948 |
5940 if(cinfo) | 5949 if(cinfo) |
5941 { | 5950 { |
5942 hFont = _aquire_font(cinfo->fontname); | 5951 hFont = _acquire_font(handle, cinfo->fontname); |
5943 mustdelete = 1; | 5952 mustdelete = 1; |
5944 } | 5953 } |
5945 } | 5954 } |
5946 oldFont = SelectObject(hdc, hFont); | 5955 oldFont = SelectObject(hdc, hFont); |
5947 SetTextColor(hdc, _foreground[threadid]); | 5956 SetTextColor(hdc, _foreground[threadid]); |
5984 else | 5993 else |
5985 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA); | 5994 cinfo = (ColorInfo *)GetWindowLong(pixmap->handle, GWL_USERDATA); |
5986 | 5995 |
5987 if(cinfo) | 5996 if(cinfo) |
5988 { | 5997 { |
5989 hFont = _aquire_font(cinfo->fontname); | 5998 hFont = _acquire_font(handle, cinfo->fontname); |
5990 mustdelete = 1; | 5999 mustdelete = 1; |
5991 } | 6000 } |
5992 } | 6001 } |
5993 oldFont = SelectObject(hdc, hFont); | 6002 oldFont = SelectObject(hdc, hFont); |
5994 | 6003 |