comparison win/dw.c @ 1790:209c57a14b09

Rewrite dw_window_set_style() on Windows to properly handle the static control. Apparently the first few style bits are not bits at all, they are a number of individual values, so combining them like bits causes all sorts of havok.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 04 Aug 2012 07:35:13 +0000
parents 86ace55df07b
children b0bdec1b820c
comparison
equal deleted inserted replaced
1789:a640714f9087 1790:209c57a14b09
5977 */ 5977 */
5978 HWND API dw_text_new(char *text, ULONG id) 5978 HWND API dw_text_new(char *text, ULONG id)
5979 { 5979 {
5980 HWND tmp = CreateWindow(STATICCLASSNAME, 5980 HWND tmp = CreateWindow(STATICCLASSNAME,
5981 UTF8toWide(text), 5981 UTF8toWide(text),
5982 SS_NOPREFIX | SS_NOTIFY | WS_VISIBLE | 5982 SS_NOPREFIX | SS_NOTIFY | SS_LEFTNOWORDWRAP |
5983 WS_CHILD | WS_CLIPCHILDREN, 5983 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
5984 0,0,0,0, 5984 0,0,0,0,
5985 DW_HWND_OBJECT, 5985 DW_HWND_OBJECT,
5986 (HMENU)id, 5986 (HMENU)id,
5987 DWInstance, 5987 DWInstance,
5988 NULL); 5988 NULL);
7635 { 7635 {
7636 ULONG tmp, currentstyle; 7636 ULONG tmp, currentstyle;
7637 ColorInfo *cinfo; 7637 ColorInfo *cinfo;
7638 TCHAR tmpbuf[100] = {0}; 7638 TCHAR tmpbuf[100] = {0};
7639 7639
7640 if(!handle) 7640 if(!handle || !mask)
7641 return; 7641 return;
7642 7642
7643 if(handle < (HWND)65536) 7643 if(handle < (HWND)65536)
7644 { 7644 {
7645 char buffer[31] = {0}; 7645 char buffer[31] = {0};
7678 } 7678 }
7679 #endif 7679 #endif
7680 7680
7681 tmp = currentstyle | mask; 7681 tmp = currentstyle | mask;
7682 tmp ^= mask; 7682 tmp ^= mask;
7683 tmp |= style; 7683 tmp |= style & mask;
7684 7684
7685 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) 7685 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
7686 { 7686 {
7687 tmp = tmp & 0xffff0000; 7687 tmp = tmp & 0xffff0000;
7688 #ifdef AEROGLASS 7688 #ifdef AEROGLASS
7708 _DwmExtendFrameIntoClientArea(handle, &mar); 7708 _DwmExtendFrameIntoClientArea(handle, &mar);
7709 } 7709 }
7710 } 7710 }
7711 #endif 7711 #endif
7712 } 7712 }
7713 else 7713 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
7714 { 7714 {
7715 /* We are using SS_NOPREFIX as a VCENTER flag */ 7715 static ULONG halign = (SS_LEFTNOWORDWRAP | SS_RIGHT | SS_CENTER);
7716 if(tmp & SS_NOPREFIX) 7716 ULONG thismask = mask & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
7717 { 7717 ULONG thisstyle = style & ~(DW_DT_VCENTER | DW_DT_WORDBREAK);
7718 7718 ULONG type = style & mask & 0xFL;
7719 if(cinfo) 7719
7720 cinfo->vcenter = 1; 7720 /* Need to filter out bits that shouldn't be set */
7721 else 7721 tmp = currentstyle | thismask;
7722 tmp ^= thismask;
7723 tmp |= thisstyle & thismask;
7724
7725 if(mask & DW_DT_VCENTER)
7726 {
7727 if(style & DW_DT_VCENTER)
7722 { 7728 {
7723 cinfo = calloc(1, sizeof(ColorInfo)); 7729 if(cinfo)
7724 cinfo->fore = cinfo->back = -1; 7730 cinfo->vcenter = 1;
7725 cinfo->vcenter = 1; 7731 else
7726 7732 {
7727 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); 7733 cinfo = calloc(1, sizeof(ColorInfo));
7728 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); 7734 cinfo->fore = cinfo->back = -1;
7735 cinfo->vcenter = 1;
7736
7737 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
7738 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
7739 }
7729 } 7740 }
7730 } 7741 else if(cinfo)
7731 else if(cinfo) 7742 cinfo->vcenter = 0;
7732 cinfo->vcenter = 0; 7743 }
7744 /* Alignment style is 0 for word wrap */
7745 if((style & DW_DT_WORDBREAK) && (mask & DW_DT_WORDBREAK))
7746 tmp &= ~(0xFL);
7747 else if(type == SS_LEFTNOWORDWRAP)
7748 tmp = (tmp & ~(0xFL)) | SS_LEFTNOWORDWRAP;
7749 else if(type == SS_CENTER)
7750 tmp = (tmp & ~(0xFL)) | SS_CENTER;
7751 else if(type == SS_RIGHT)
7752 tmp = (tmp & ~(0xFL)) | SS_RIGHT;
7733 } 7753 }
7734 7754
7735 SetWindowLong(handle, GWL_STYLE, tmp); 7755 SetWindowLong(handle, GWL_STYLE, tmp);
7736 } 7756 }
7737 7757