comparison win/dw.c @ 452:cf00d6e2b3cc

Optimizations to the layout engine on OS/2 and Windows, eliminated 3 MUL and 3 ADD operations per loop (on average). Also always return a valid HFONT from _acquire_font().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 23 Jun 2003 16:52:21 +0000
parents 538b529052e0
children 031d762fc8d6
comparison
equal deleted inserted replaced
451:538b529052e0 452:cf00d6e2b3cc
996 thisbox->items[z].yratio = thisbox->yratio; 996 thisbox->items[z].yratio = thisbox->yratio;
997 } 997 }
998 998
999 if(thisbox->type == DW_VERT) 999 if(thisbox->type == DW_VERT)
1000 { 1000 {
1001 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) 1001 int itemwidth = (thisbox->items[z].pad*2) + thisbox->items[z].width;
1002 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); 1002
1003 if(itemwidth > uxmax)
1004 uxmax = itemwidth;
1003 if(thisbox->items[z].hsize != SIZEEXPAND) 1005 if(thisbox->items[z].hsize != SIZEEXPAND)
1004 { 1006 {
1005 if(((thisbox->items[z].pad*2) + thisbox->items[z].width) > upxmax) 1007 if(itemwidth > upxmax)
1006 upxmax = (thisbox->items[z].pad*2) + thisbox->items[z].width; 1008 upxmax = itemwidth;
1007 } 1009 }
1008 else 1010 else
1009 { 1011 {
1010 if(thisbox->items[z].pad*2 > upxmax) 1012 if(thisbox->items[z].pad*2 > upxmax)
1011 upxmax = thisbox->items[z].pad*2; 1013 upxmax = thisbox->items[z].pad*2;
1027 (*usedpadx) += thisbox->items[z].pad*2; 1029 (*usedpadx) += thisbox->items[z].pad*2;
1028 } 1030 }
1029 } 1031 }
1030 if(thisbox->type == DW_HORZ) 1032 if(thisbox->type == DW_HORZ)
1031 { 1033 {
1032 if((thisbox->items[z].height + (thisbox->items[z].pad*2)) > uymax) 1034 int itemheight = (thisbox->items[z].pad*2) + thisbox->items[z].height;
1033 uymax = (thisbox->items[z].height + (thisbox->items[z].pad*2)); 1035
1036 if(itemheight > uymax)
1037 uymax = itemheight;
1034 if(thisbox->items[z].vsize != SIZEEXPAND) 1038 if(thisbox->items[z].vsize != SIZEEXPAND)
1035 { 1039 {
1036 if(((thisbox->items[z].pad*2) + thisbox->items[z].height) > upymax) 1040 if(itemheight > upymax)
1037 upymax = (thisbox->items[z].pad*2) + thisbox->items[z].height; 1041 upymax = itemheight;
1038 } 1042 }
1039 else 1043 else
1040 { 1044 {
1041 if(thisbox->items[z].pad*2 > upymax) 1045 if(thisbox->items[z].pad*2 > upymax)
1042 upymax = thisbox->items[z].pad*2; 1046 upymax = thisbox->items[z].pad*2;
3404 SetParent(handle, newparent); 3408 SetParent(handle, newparent);
3405 } 3409 }
3406 3410
3407 HFONT _acquire_font(HWND handle, char *fontname) 3411 HFONT _acquire_font(HWND handle, char *fontname)
3408 { 3412 {
3409 HFONT hfont; 3413 HFONT hfont = 0;
3410 3414
3411 if(fontname == DefaultFont || !fontname[0]) 3415 if(fontname != DefaultFont && fontname[0])
3412 hfont = GetStockObject(DEFAULT_GUI_FONT);
3413 else
3414 { 3416 {
3415 int Italic, Bold; 3417 int Italic, Bold;
3416 char *myFontName; 3418 char *myFontName;
3417 int z, size = 9; 3419 int z, size = 9;
3418 LOGFONT lf; 3420 LOGFONT lf;
3457 hfont = CreateFontIndirect(&lf); 3459 hfont = CreateFontIndirect(&lf);
3458 #if 0 3460 #if 0
3459 ReleaseDC(handle, hDC); 3461 ReleaseDC(handle, hDC);
3460 #endif 3462 #endif
3461 } 3463 }
3464 if(!hfont)
3465 hfont = GetStockObject(DEFAULT_GUI_FONT);
3462 return hfont; 3466 return hfont;
3463 } 3467 }
3464 3468
3465 /* 3469 /*
3466 * Sets the font used by a specified window (widget) handle. 3470 * Sets the font used by a specified window (widget) handle.