# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1326420148 0 # Node ID 1c6593b0ce45b0c59753e649f7af2895ba3bdbb0 # Parent 2827274226988304b07d95bc188ddd79ad460a58 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go. diff -r 282727422698 -r 1c6593b0ce45 dw.h --- a/dw.h Thu Jan 12 18:56:30 2012 +0000 +++ b/dw.h Fri Jan 13 02:02:28 2012 +0000 @@ -1428,6 +1428,12 @@ #define DWSIGNAL API +/* Constants for sizing scrolled widgets */ +#define _DW_SCROLLED_MIN_WIDTH 100 +#define _DW_SCROLLED_MIN_HEIGHT 75 +#define _DW_SCROLLED_MAX_WIDTH 500 +#define _DW_SCROLLED_MAX_HEIGHT 400 + /* Let other APIs know what types we've defined, * Regina REXX in particular, on Unix. */ diff -r 282727422698 -r 1c6593b0ce45 win/dw.c --- a/win/dw.c Thu Jan 12 18:56:30 2012 +0000 +++ b/win/dw.c Fri Jan 13 02:02:28 2012 +0000 @@ -4477,11 +4477,58 @@ /* Entryfields and MLE */ else if(strnicmp(tmpbuf, EDITCLASSNAME, strlen(EDITCLASSNAME)+1) == 0) { - if((GetWindowLong(handle, GWL_STYLE) & ES_MULTILINE)) - { + LONG style = GetWindowLong(handle, GWL_STYLE); + if((style & ES_MULTILINE)) + { + unsigned long bytes; + int height, width; + char *buf, *ptr; + int basicwidth; + + if(style & ES_AUTOHSCROLL) + thisheight = GetSystemMetrics(SM_CYHSCROLL) + 8; + else + thisheight = 8; + basicwidth = thiswidth = GetSystemMetrics(SM_CXVSCROLL) + 8; + + dw_mle_get_size(handle, &bytes, NULL); + + ptr = buf = _alloca(bytes + 2); + dw_mle_export(handle, buf, 0, (int)bytes); + strcat(buf, "\n"); + /* MLE */ - thiswidth = 500; - thisheight = 200; + while(ptr = strstr(buf, "\n")) + { + ptr[0] = 0; + width = 0; + if(strlen(buf)) + dw_font_text_extents_get(handle, NULL, buf, &width, &height); + else + dw_font_text_extents_get(handle, NULL, testtext, NULL, &height); + + width += basicwidth; + + if(!(style & ES_AUTOHSCROLL) && width > _DW_SCROLLED_MAX_WIDTH) + { + thiswidth = _DW_SCROLLED_MAX_WIDTH; + thisheight += height * (width / _DW_SCROLLED_MAX_WIDTH); + } + else + { + if(width > thiswidth) + thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width; + } + thisheight += height; + buf = &ptr[1]; + } + + if(thiswidth < _DW_SCROLLED_MIN_WIDTH) + thiswidth = _DW_SCROLLED_MIN_WIDTH; + if(thisheight < _DW_SCROLLED_MIN_HEIGHT) + thisheight = _DW_SCROLLED_MIN_HEIGHT; + if(thisheight > _DW_SCROLLED_MAX_HEIGHT) + thisheight = _DW_SCROLLED_MAX_HEIGHT; } else { @@ -4495,8 +4542,8 @@ else if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)== 0 || strnicmp(tmpbuf, WC_TREEVIEW, strlen(WC_TREEVIEW)+1)== 0) { - thiswidth = 500; - thisheight = 200; + thiswidth = _DW_SCROLLED_MAX_WIDTH; + thisheight = _DW_SCROLLED_MAX_HEIGHT; } /* Buttons */ else if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1) == 0) @@ -7834,7 +7881,7 @@ */ void API dw_mle_set_word_wrap(HWND handle, int state) { - /* If ES_AUTOHSCROLL is not set and there is not + /* If ES_AUTOHSCROLL is not set and there is no * horizontal scrollbar it word wraps. */ if(state)