Mercurial > dwindows
comparison win/dw.c @ 1039:860d6e73f8bb
Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 26 May 2011 09:06:02 +0000 |
parents | c2013f1ef354 |
children | 05ff61fd60d7 |
comparison
equal
deleted
inserted
replaced
1038:2c2fcfeeffcc | 1039:860d6e73f8bb |
---|---|
4059 * handle: The window (widget) handle. | 4059 * handle: The window (widget) handle. |
4060 * fontname: Name and size of the font in the form "size.fontname" | 4060 * fontname: Name and size of the font in the form "size.fontname" |
4061 */ | 4061 */ |
4062 int API dw_window_set_font(HWND handle, char *fontname) | 4062 int API dw_window_set_font(HWND handle, char *fontname) |
4063 { | 4063 { |
4064 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 4064 HFONT hfont, oldfont; |
4065 HFONT hfont = _acquire_font(handle, fontname); | 4065 ColorInfo *cinfo; |
4066 ColorInfo *cinfo; | 4066 char tmpbuf[100]; |
4067 Box *thisbox; | 4067 |
4068 char tmpbuf[100]; | 4068 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
4069 | 4069 |
4070 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 4070 GetClassName(handle, tmpbuf, 99); |
4071 | 4071 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) |
4072 if (fontname) | 4072 { |
4073 { | 4073 /* groupbox */ |
4074 GetClassName(handle, tmpbuf, 99); | 4074 Box *thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
4075 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 ) | 4075 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
4076 { | 4076 { |
4077 /* groupbox */ | |
4078 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | |
4079 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | |
4080 { | |
4081 handle = thisbox->grouphwnd; | 4077 handle = thisbox->grouphwnd; |
4082 } | 4078 } |
4083 } | 4079 } |
4084 if(cinfo) | 4080 |
4085 { | 4081 /* This needs to be after we get the correct handle */ |
4086 strcpy(cinfo->fontname, fontname); | 4082 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); |
4087 if(!oldfont) | 4083 hfont = _acquire_font(handle, fontname); |
4088 oldfont = cinfo->hfont; | 4084 |
4089 cinfo->hfont = hfont; | 4085 if (fontname) |
4090 } | 4086 { |
4091 else | 4087 if(cinfo) |
4092 { | 4088 { |
4093 cinfo = calloc(1, sizeof(ColorInfo)); | 4089 strcpy(cinfo->fontname, fontname); |
4094 cinfo->fore = cinfo->back = -1; | 4090 if(!oldfont) |
4095 | 4091 oldfont = cinfo->hfont; |
4096 strcpy(cinfo->fontname, fontname); | 4092 cinfo->hfont = hfont; |
4097 | 4093 } |
4098 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | 4094 else |
4099 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); | 4095 { |
4100 } | 4096 cinfo = calloc(1, sizeof(ColorInfo)); |
4101 } | 4097 cinfo->fore = cinfo->back = -1; |
4102 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); | 4098 |
4103 if(oldfont) | 4099 strcpy(cinfo->fontname, fontname); |
4104 DeleteObject(oldfont); | 4100 |
4101 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | |
4102 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); | |
4103 } | |
4104 } | |
4105 SendMessage(handle, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE); | |
4106 if(oldfont) | |
4107 DeleteObject(oldfont); | |
4105 return 0; | 4108 return 0; |
4106 } | 4109 } |
4107 | 4110 |
4108 /* | 4111 /* |
4109 * Gets the font used by a specified window (widget) handle. | 4112 * Gets the font used by a specified window (widget) handle. |
4120 LOGFONT lf = { 0 }; | 4123 LOGFONT lf = { 0 }; |
4121 Box *thisbox; | 4124 Box *thisbox; |
4122 char tmpbuf[100]; | 4125 char tmpbuf[100]; |
4123 | 4126 |
4124 GetClassName(handle, tmpbuf, 99); | 4127 GetClassName(handle, tmpbuf, 99); |
4125 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 ) | 4128 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)+1) == 0 ) |
4126 { | 4129 { |
4127 /* groupbox */ | 4130 /* groupbox */ |
4128 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | 4131 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); |
4129 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | 4132 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) |
4130 { | 4133 { |
4501 NULL, | 4504 NULL, |
4502 DWInstance, | 4505 DWInstance, |
4503 NULL); | 4506 NULL); |
4504 | 4507 |
4505 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); | 4508 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); |
4506 fprintf(stderr,"in groupbox\n"); | |
4507 return hwndframe; | 4509 return hwndframe; |
4508 } | 4510 } |
4509 | 4511 |
4510 /* | 4512 /* |
4511 * Create a new MDI Frame to be packed. | 4513 * Create a new MDI Frame to be packed. |