Mercurial > dwindows
comparison win/dw.c @ 88:58d8139fe0a2
Added vertical center logic for static text controls on windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 16 Apr 2002 19:10:16 +0000 |
parents | 1eb72c0e8c79 |
children | ec311fe773da |
comparison
equal
deleted
inserted
replaced
87:1eb72c0e8c79 | 88:58d8139fe0a2 |
---|---|
1100 if(thisbox->items[z].hsize != SIZEEXPAND) | 1100 if(thisbox->items[z].hsize != SIZEEXPAND) |
1101 vectorx = 0; | 1101 vectorx = 0; |
1102 | 1102 |
1103 GetClassName(handle, tmpbuf, 99); | 1103 GetClassName(handle, tmpbuf, 99); |
1104 | 1104 |
1105 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) | 1105 if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME)+1)==0) |
1106 { | 1106 { |
1107 /* Handle special case Combobox */ | 1107 /* Handle special case Combobox */ |
1108 MoveWindow(handle, currentx + pad, currenty + pad, | 1108 MoveWindow(handle, currentx + pad, currenty + pad, |
1109 width + vectorx, (height + vectory) + 400, TRUE); | 1109 width + vectorx, (height + vectory) + 400, TRUE); |
1110 } | 1110 } |
1111 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS))==0) | 1111 else if(strnicmp(tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1)==0) |
1112 { | 1112 { |
1113 /* Handle special case Spinbutton */ | 1113 /* Handle special case Spinbutton */ |
1114 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | 1114 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); |
1115 | 1115 |
1116 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad, | 1116 MoveWindow(handle, currentx + pad + ((width + vectorx) - 20), currenty + pad, |
1118 | 1118 |
1119 if(cinfo) | 1119 if(cinfo) |
1120 { | 1120 { |
1121 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, | 1121 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad, |
1122 (width + vectorx) - 20, height + vectory, TRUE); | 1122 (width + vectorx) - 20, height + vectory, TRUE); |
1123 } | |
1124 } | |
1125 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) | |
1126 { | |
1127 /* Handle special case Vertically Center static text */ | |
1128 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | |
1129 | |
1130 if(cinfo && cinfo->vcenter) | |
1131 { | |
1132 /* We are centered so calculate a new position */ | |
1133 char tmpbuf[1024]; | |
1134 int textheight, diff, total = height + vectory; | |
1135 | |
1136 GetWindowText(handle, tmpbuf, 1023); | |
1137 | |
1138 /* Figure out how big the text is */ | |
1139 dw_font_text_extents(handle, 0, tmpbuf, 0, &textheight); | |
1140 | |
1141 diff = (total - textheight) / 2; | |
1142 | |
1143 MoveWindow(handle, currentx + pad, currenty + pad + diff, | |
1144 width + vectorx, height + vectory - diff, TRUE); | |
1145 } | |
1146 else | |
1147 { | |
1148 MoveWindow(handle, currentx + pad, currenty + pad, | |
1149 width + vectorx, height + vectory, TRUE); | |
1123 } | 1150 } |
1124 } | 1151 } |
1125 else | 1152 else |
1126 { | 1153 { |
1127 /* Everything else */ | 1154 /* Everything else */ |
3086 { | 3113 { |
3087 HFONT hfont; | 3114 HFONT hfont; |
3088 int z, size = 9; | 3115 int z, size = 9; |
3089 LOGFONT lf; | 3116 LOGFONT lf; |
3090 | 3117 |
3091 if(fontname == DefaultFont) | 3118 if(fontname == DefaultFont || !fontname[0]) |
3092 hfont = GetStockObject(DEFAULT_GUI_FONT); | 3119 hfont = GetStockObject(DEFAULT_GUI_FONT); |
3093 else | 3120 else |
3094 { | 3121 { |
3095 #if 0 | 3122 #if 0 |
3096 HDC hDC = GetDC(handle); | 3123 HDC hDC = GetDC(handle); |
4396 * height: New height in pixels. | 4423 * height: New height in pixels. |
4397 */ | 4424 */ |
4398 void dw_window_set_style(HWND handle, ULONG style, ULONG mask) | 4425 void dw_window_set_style(HWND handle, ULONG style, ULONG mask) |
4399 { | 4426 { |
4400 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE); | 4427 ULONG tmp, currentstyle = GetWindowLong(handle, GWL_STYLE); |
4428 ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA); | |
4401 | 4429 |
4402 tmp = currentstyle | mask; | 4430 tmp = currentstyle | mask; |
4403 tmp ^= mask; | 4431 tmp ^= mask; |
4404 tmp |= style; | 4432 tmp |= style; |
4433 | |
4434 | |
4435 /* We are using SS_NOPREFIX as a VCENTER flag */ | |
4436 if(tmp & SS_NOPREFIX) | |
4437 { | |
4438 | |
4439 if(cinfo) | |
4440 cinfo->vcenter = 1; | |
4441 else | |
4442 { | |
4443 cinfo = calloc(1, sizeof(ColorInfo)); | |
4444 cinfo->fore = cinfo->back = -1; | |
4445 cinfo->vcenter = 1; | |
4446 | |
4447 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); | |
4448 SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo); | |
4449 } | |
4450 } | |
4451 else if(cinfo) | |
4452 cinfo->vcenter = 0; | |
4405 | 4453 |
4406 SetWindowLong(handle, GWL_STYLE, tmp); | 4454 SetWindowLong(handle, GWL_STYLE, tmp); |
4407 } | 4455 } |
4408 | 4456 |
4409 /* Finds the physical ID from the reference ID */ | 4457 /* Finds the physical ID from the reference ID */ |
6195 */ | 6243 */ |
6196 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) | 6244 void dw_font_text_extents(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height) |
6197 { | 6245 { |
6198 HDC hdc; | 6246 HDC hdc; |
6199 int mustdelete = 0; | 6247 int mustdelete = 0; |
6200 HFONT hFont, oldFont; | 6248 HFONT hFont = NULL, oldFont; |
6201 SIZE sz; | 6249 SIZE sz; |
6202 | 6250 |
6203 if(handle) | 6251 if(handle) |
6204 hdc = GetDC(handle); | 6252 hdc = GetDC(handle); |
6205 else if(pixmap) | 6253 else if(pixmap) |