comparison win/dw.c @ 1449:632346743f46

Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change. Remove notebook page subclass and do the redrawing in _resize_box() itself. Fixed expandable boxes with no contents not consuming any space on OS/2, Windows and Mac. Added invalidated window redraw on entering dw_main() on OS/2, Windows and Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 14 Dec 2011 00:23:30 +0000
parents 508dde3dc398
children 145edf67013e
comparison
equal deleted inserted replaced
1448:508dde3dc398 1449:632346743f46
1120 { 1120 {
1121 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0) 1121 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
1122 _focus_check_box_back(thisbox, handle, 2, 0); 1122 _focus_check_box_back(thisbox, handle, 2, 0);
1123 } 1123 }
1124 } 1124 }
1125
1126 /* This function calculates how much space the widgets and boxes require 1125 /* This function calculates how much space the widgets and boxes require
1127 * and does expansion as necessary. 1126 * and does expansion as necessary.
1128 */ 1127 */
1129 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass) 1128 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass)
1130 { 1129 {
1197 _resize_box(tmp, depth, x, y, pass); 1196 _resize_box(tmp, depth, x, y, pass);
1198 1197
1199 /* Duplicate the values in the item list for use below */ 1198 /* Duplicate the values in the item list for use below */
1200 thisbox->items[z].width = tmp->minwidth; 1199 thisbox->items[z].width = tmp->minwidth;
1201 thisbox->items[z].height = tmp->minheight; 1200 thisbox->items[z].height = tmp->minheight;
1201
1202 /* If the box has no contents but is expandable... default the size to 1 */
1203 if(!thisbox->items[z].width && thisbox->items[z].hsize)
1204 thisbox->items[z].width = 1;
1205 if(!thisbox->items[z].height && thisbox->items[z].vsize)
1206 thisbox->items[z].height = 1;
1202 1207
1203 (*depth)--; 1208 (*depth)--;
1204 } 1209 }
1205 } 1210 }
1206 } 1211 }
1405 int type = (int)dw_window_get_data(handle, "_dw_type"); 1410 int type = (int)dw_window_get_data(handle, "_dw_type");
1406 1411
1407 MoveWindow(handle, currentx + pad, currenty + pad, 1412 MoveWindow(handle, currentx + pad, currenty + pad,
1408 width, height, FALSE); 1413 width, height, FALSE);
1409 1414
1410 if(percent) 1415 if(percent && width > 0 && height > 0)
1411 _handle_splitbar_resize(handle, *percent, type, width, height); 1416 _handle_splitbar_resize(handle, *percent, type, width, height);
1412 } 1417 }
1413 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0) 1418 else if(strnicmp(tmpbuf, STATICCLASSNAME, strlen(STATICCLASSNAME)+1)==0)
1414 { 1419 {
1415 /* Handle special case Vertically Center static text */ 1420 /* Handle special case Vertically Center static text */
1475 { 1480 {
1476 GetClientRect(handle,&rect); 1481 GetClientRect(handle,&rect);
1477 TabCtrl_AdjustRect(handle,FALSE,&rect); 1482 TabCtrl_AdjustRect(handle,FALSE,&rect);
1478 MoveWindow(array[pageid]->hwnd, rect.left, rect.top, 1483 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
1479 rect.right - rect.left, rect.bottom-rect.top, FALSE); 1484 rect.right - rect.left, rect.bottom-rect.top, FALSE);
1485 dw_window_redraw(array[pageid]->hwnd);
1480 } 1486 }
1481 } 1487 }
1482 /* So does the List View... handle delayed cursoring */ 1488 /* So does the List View... handle delayed cursoring */
1483 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10) 1489 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10)
1484 { 1490 {
2963 } 2969 }
2964 } 2970 }
2965 2971
2966 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y) 2972 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y)
2967 { 2973 {
2968 HWND handle1, handle2; 2974 HWND handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2969 Box *tmp; 2975 HWND handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
2976 Box *tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
2977
2978 ShowWindow(handle1, SW_HIDE);
2979 ShowWindow(handle2, SW_HIDE);
2970 2980
2971 if(type == DW_HORZ) 2981 if(type == DW_HORZ)
2972 { 2982 {
2973 int newx = x; 2983 int newx = x;
2974 float ratio = (float)percent/(float)100.0; 2984 float ratio = (float)percent/(float)100.0;
2975 2985
2976 handle1 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
2977 handle2 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
2978 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
2979
2980 newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2); 2986 newx = (int)((float)newx * ratio) - (SPLITBAR_WIDTH/2);
2981
2982 ShowWindow(handle1, SW_HIDE);
2983 ShowWindow(handle2, SW_HIDE);
2984 2987
2985 MoveWindow(handle1, 0, 0, newx, y, FALSE); 2988 MoveWindow(handle1, 0, 0, newx, y, FALSE);
2986 _do_resize(tmp, newx - 1, y - 1); 2989 _do_resize(tmp, newx - 1, y - 1);
2987 2990
2988 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA); 2991 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
2997 else 3000 else
2998 { 3001 {
2999 int newy = y; 3002 int newy = y;
3000 float ratio = (float)(100.0-percent)/(float)100.0; 3003 float ratio = (float)(100.0-percent)/(float)100.0;
3001 3004
3002 handle1 = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
3003 handle2 = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
3004 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
3005
3006 newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2); 3005 newy = (int)((float)newy * ratio) - (SPLITBAR_WIDTH/2);
3007
3008 ShowWindow(handle1, SW_HIDE);
3009 ShowWindow(handle2, SW_HIDE);
3010 3006
3011 MoveWindow(handle1, 0, y - newy, x, newy, FALSE); 3007 MoveWindow(handle1, 0, y - newy, x, newy, FALSE);
3012 _do_resize(tmp, x - 1, newy - 1); 3008 _do_resize(tmp, x - 1, newy - 1);
3013 3009
3014 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA); 3010 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
3704 void API dw_main(void) 3700 void API dw_main(void)
3705 { 3701 {
3706 MSG msg; 3702 MSG msg;
3707 3703
3708 _dwtid = dw_thread_id(); 3704 _dwtid = dw_thread_id();
3705 /* Make sure any queued redraws are handled */
3706 _dw_redraw(0, FALSE);
3709 3707
3710 while(GetMessage(&msg, NULL, 0, 0)) 3708 while(GetMessage(&msg, NULL, 0, 0))
3711 { 3709 {
3712 if(msg.hwnd == NULL && msg.message == WM_TIMER) 3710 if(msg.hwnd == NULL && msg.message == WM_TIMER)
3713 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); 3711 _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
6385 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); 6383 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
6386 return; 6384 return;
6387 } 6385 }
6388 6386
6389 GetClassName(box, tmpbuf, 99); 6387 GetClassName(box, tmpbuf, 99);
6390 6388
6391 /* If we are in a scrolled box... extract the interal box */ 6389 /* If we are in a scrolled box... extract the interal box */
6392 if(strnicmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0) 6390 if(strnicmp(tmpbuf, ScrollClassName, strlen(ScrollClassName)+1)==0)
6393 { 6391 {
6394 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA); 6392 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box, GWLP_USERDATA);
6395 if(cinfo) 6393 if(cinfo)
6865 if(pageid > -1 && array[pageid]) 6863 if(pageid > -1 && array[pageid])
6866 { 6864 {
6867 HWND tmpbox = dw_box_new(DW_VERT, 0); 6865 HWND tmpbox = dw_box_new(DW_VERT, 0);
6868 6866
6869 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0); 6867 dw_box_pack_start(tmpbox, page, 0, 0, TRUE, TRUE, 0);
6870 SubclassWindow(tmpbox, _wndproc);
6871 if(array[pageid]->hwnd) 6868 if(array[pageid]->hwnd)
6872 dw_window_destroy(array[pageid]->hwnd); 6869 dw_window_destroy(array[pageid]->hwnd);
6873 array[pageid]->hwnd = tmpbox; 6870 array[pageid]->hwnd = tmpbox;
6874 if(pageidx == dw_notebook_page_get(handle)) 6871 if(pageidx == dw_notebook_page_get(handle))
6875 { 6872 {
10209 if(mypercent) 10206 if(mypercent)
10210 *mypercent = percent; 10207 *mypercent = percent;
10211 10208
10212 dw_window_get_pos_size(handle, NULL, NULL, &width, &height); 10209 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
10213 10210
10214 _handle_splitbar_resize(handle, percent, type, width, height); 10211 if(width > 0 && height > 0)
10212 _handle_splitbar_resize(handle, percent, type, width, height);
10215 } 10213 }
10216 10214
10217 /* 10215 /*
10218 * Gets the position of a splitbar (pecentage). 10216 * Gets the position of a splitbar (pecentage).
10219 * Parameters: 10217 * Parameters: