Mercurial > dwindows
changeset 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 | a640714f9087 |
children | ed8851658015 |
files | dw.h win/dw.c |
diffstat | 2 files changed, 46 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/dw.h Sat Aug 04 01:14:17 2012 +0000 +++ b/dw.h Sat Aug 04 07:35:13 2012 +0000 @@ -503,11 +503,11 @@ #define DW_DT_CENTER SS_CENTER #define DW_DT_RIGHT SS_RIGHT #define DW_DT_TOP 0 -#define DW_DT_VCENTER SS_NOPREFIX +#define DW_DT_VCENTER (1 << 29) #define DW_DT_BOTTOM 0 #define DW_DT_HALFTONE 0 #define DW_DT_MNEMONIC 0 -#define DW_DT_WORDBREAK SS_LEFT +#define DW_DT_WORDBREAK (1 << 28) #define DW_DT_ERASERECT 0 #define DW_FCF_CLOSEBUTTON 0
--- a/win/dw.c Sat Aug 04 01:14:17 2012 +0000 +++ b/win/dw.c Sat Aug 04 07:35:13 2012 +0000 @@ -5979,8 +5979,8 @@ { HWND tmp = CreateWindow(STATICCLASSNAME, UTF8toWide(text), - SS_NOPREFIX | SS_NOTIFY | WS_VISIBLE | - WS_CHILD | WS_CLIPCHILDREN, + SS_NOPREFIX | SS_NOTIFY | SS_LEFTNOWORDWRAP | + WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN, 0,0,0,0, DW_HWND_OBJECT, (HMENU)id, @@ -7637,7 +7637,7 @@ ColorInfo *cinfo; TCHAR tmpbuf[100] = {0}; - if(!handle) + if(!handle || !mask) return; if(handle < (HWND)65536) @@ -7680,7 +7680,7 @@ tmp = currentstyle | mask; tmp ^= mask; - tmp |= style; + tmp |= style & mask; if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0) { @@ -7710,26 +7710,46 @@ } #endif } - else - { - /* We are using SS_NOPREFIX as a VCENTER flag */ - if(tmp & SS_NOPREFIX) - { - - if(cinfo) - cinfo->vcenter = 1; - else - { - cinfo = calloc(1, sizeof(ColorInfo)); - cinfo->fore = cinfo->back = -1; - cinfo->vcenter = 1; - - cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); - SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); - } - } - else if(cinfo) - cinfo->vcenter = 0; + else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0) + { + static ULONG halign = (SS_LEFTNOWORDWRAP | SS_RIGHT | SS_CENTER); + ULONG thismask = mask & ~(DW_DT_VCENTER | DW_DT_WORDBREAK); + ULONG thisstyle = style & ~(DW_DT_VCENTER | DW_DT_WORDBREAK); + ULONG type = style & mask & 0xFL; + + /* Need to filter out bits that shouldn't be set */ + tmp = currentstyle | thismask; + tmp ^= thismask; + tmp |= thisstyle & thismask; + + if(mask & DW_DT_VCENTER) + { + if(style & DW_DT_VCENTER) + { + if(cinfo) + cinfo->vcenter = 1; + else + { + cinfo = calloc(1, sizeof(ColorInfo)); + cinfo->fore = cinfo->back = -1; + cinfo->vcenter = 1; + + cinfo->pOldProc = SubclassWindow(handle, _colorwndproc); + SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo); + } + } + else if(cinfo) + cinfo->vcenter = 0; + } + /* Alignment style is 0 for word wrap */ + if((style & DW_DT_WORDBREAK) && (mask & DW_DT_WORDBREAK)) + tmp &= ~(0xFL); + else if(type == SS_LEFTNOWORDWRAP) + tmp = (tmp & ~(0xFL)) | SS_LEFTNOWORDWRAP; + else if(type == SS_CENTER) + tmp = (tmp & ~(0xFL)) | SS_CENTER; + else if(type == SS_RIGHT) + tmp = (tmp & ~(0xFL)) | SS_RIGHT; } SetWindowLong(handle, GWL_STYLE, tmp);