comparison os2/dw.c @ 2081:24875681eec5

Added htmlEngine to DWEnv
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 31 May 2020 05:25:18 +0000
parents b4b49d29b940
children 94ea915bd917
comparison
equal deleted inserted replaced
2080:8f08d4c9d3fc 2081:24875681eec5
289 /* Internal function to queue a window redraw */ 289 /* Internal function to queue a window redraw */
290 void _dw_redraw(HWND window, int skip) 290 void _dw_redraw(HWND window, int skip)
291 { 291 {
292 static HWND lastwindow = 0; 292 static HWND lastwindow = 0;
293 HWND redraw = lastwindow; 293 HWND redraw = lastwindow;
294 294
295 if(skip && !window) 295 if(skip && !window)
296 return; 296 return;
297 297
298 lastwindow = window; 298 lastwindow = window;
299 if(redraw != lastwindow && redraw) 299 if(redraw != lastwindow && redraw)
438 dw_window_set_data(handle, "_dw_hps", NULL); 438 dw_window_set_data(handle, "_dw_hps", NULL);
439 dw_window_set_data(handle, "_dw_hdc", NULL); 439 dw_window_set_data(handle, "_dw_hdc", NULL);
440 dw_window_set_data(handle, "_dw_hpixmap", NULL); 440 dw_window_set_data(handle, "_dw_hpixmap", NULL);
441 dw_window_set_data(handle, "_dw_hpixmap_disabled", NULL); 441 dw_window_set_data(handle, "_dw_hpixmap_disabled", NULL);
442 dw_window_set_data(handle, "_dw_button_icon", NULL); 442 dw_window_set_data(handle, "_dw_button_icon", NULL);
443 443
444 if(icon) 444 if(icon)
445 WinDestroyPointer(icon); 445 WinDestroyPointer(icon);
446 446
447 if(pixmap) 447 if(pixmap)
448 dw_pixmap_destroy(pixmap); 448 dw_pixmap_destroy(pixmap);
572 572
573 /* Free the data associated with the ID */ 573 /* Free the data associated with the ID */
574 if(menuid >= 30000) 574 if(menuid >= 30000)
575 { 575 {
576 char buffer[31] = {0}; 576 char buffer[31] = {0};
577 577
578 sprintf(buffer, "_dw_id%d", menuid); 578 sprintf(buffer, "_dw_id%d", menuid);
579 dw_window_set_data( hwndApp, buffer, NULL ); 579 dw_window_set_data( hwndApp, buffer, NULL );
580 sprintf(buffer, "_dw_checkable%d", menuid); 580 sprintf(buffer, "_dw_checkable%d", menuid);
581 dw_window_set_data( hwndApp, buffer, NULL ); 581 dw_window_set_data( hwndApp, buffer, NULL );
582 sprintf(buffer, "_dw_ischecked%d", menuid); 582 sprintf(buffer, "_dw_ischecked%d", menuid);
583 dw_window_set_data( hwndApp, buffer, NULL ); 583 dw_window_set_data( hwndApp, buffer, NULL );
584 sprintf(buffer, "_dw_isdisabled%d", menuid); 584 sprintf(buffer, "_dw_isdisabled%d", menuid);
585 dw_window_set_data( hwndApp, buffer, NULL ); 585 dw_window_set_data( hwndApp, buffer, NULL );
586 } 586 }
587 587
588 /* Check any submenus */ 588 /* Check any submenus */
589 if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi)) 589 if(WinSendMsg(menu, MM_QUERYITEM, MPFROMSHORT(menuid), MPFROMP(&mi))
590 && mi.hwndSubMenu) 590 && mi.hwndSubMenu)
591 _free_menu_data(mi.hwndSubMenu); 591 _free_menu_data(mi.hwndSubMenu);
592 } 592 }
693 return 1; 693 return 1;
694 } 694 }
695 else 695 else
696 { 696 {
697 int type = _validate_focus(box->items[z].hwnd); 697 int type = _validate_focus(box->items[z].hwnd);
698 698
699 /* Special case notebook, can focus and contains items */ 699 /* Special case notebook, can focus and contains items */
700 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 700 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
701 return 1; 701 return 1;
702 if(box->items[z].hwnd == handle) 702 if(box->items[z].hwnd == handle)
703 { 703 {
704 if(lasthwnd == handle && firsthwnd) 704 if(lasthwnd == handle && firsthwnd)
705 WinSetFocus(HWND_DESKTOP, firsthwnd); 705 WinSetFocus(HWND_DESKTOP, firsthwnd);
727 return 1; 727 return 1;
728 } 728 }
729 } 729 }
730 730
731 lasthwnd = box->items[z].hwnd; 731 lasthwnd = box->items[z].hwnd;
732 732
733 if(!firsthwnd) 733 if(!firsthwnd)
734 firsthwnd = lasthwnd; 734 firsthwnd = lasthwnd;
735 } 735 }
736 else 736 else
737 { 737 {
775 return 1; 775 return 1;
776 } 776 }
777 } 777 }
778 } 778 }
779 /* Special case notebook, can focus and contains items */ 779 /* Special case notebook, can focus and contains items */
780 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem)) 780 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
781 return 1; 781 return 1;
782 } 782 }
783 } 783 }
784 return 0; 784 return 0;
785 } 785 }
1059 * These will be used to find the widest or 1059 * These will be used to find the widest or
1060 * tallest items in a box. 1060 * tallest items in a box.
1061 */ 1061 */
1062 int uymax = 0, uxmax = 0; 1062 int uymax = 0, uxmax = 0;
1063 int upymax = 0, upxmax = 0; 1063 int upymax = 0, upxmax = 0;
1064 1064
1065 /* Reset the box sizes */ 1065 /* Reset the box sizes */
1066 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2; 1066 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2;
1067 1067
1068 if(thisbox->grouphwnd) 1068 if(thisbox->grouphwnd)
1069 { 1069 {
1093 else 1093 else
1094 thisbox->grouppady = 6; 1094 thisbox->grouppady = 6;
1095 1095
1096 thisbox->grouppadx = 6; 1096 thisbox->grouppadx = 6;
1097 } 1097 }
1098 1098
1099 thisbox->minwidth += thisbox->grouppadx; 1099 thisbox->minwidth += thisbox->grouppadx;
1100 thisbox->usedpadx += thisbox->grouppadx; 1100 thisbox->usedpadx += thisbox->grouppadx;
1101 thisbox->minheight += thisbox->grouppady; 1101 thisbox->minheight += thisbox->grouppady;
1102 thisbox->usedpady += thisbox->grouppady; 1102 thisbox->usedpady += thisbox->grouppady;
1103 } 1103 }
1104 1104
1105 /* Count up all the space for all items in the box */ 1105 /* Count up all the space for all items in the box */
1106 for(z=0;z<thisbox->count;z++) 1106 for(z=0;z<thisbox->count;z++)
1107 { 1107 {
1108 int itempad, itemwidth, itemheight; 1108 int itempad, itemwidth, itemheight;
1109 1109
1110 if(thisbox->items[z].type == TYPEBOX) 1110 if(thisbox->items[z].type == TYPEBOX)
1111 { 1111 {
1112 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 1112 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
1113 1113
1114 if(tmp) 1114 if(tmp)
1115 { 1115 {
1116 /* On the first pass calculate the box contents */ 1116 /* On the first pass calculate the box contents */
1117 if(pass == 1) 1117 if(pass == 1)
1118 { 1118 {
1119 (*depth)++; 1119 (*depth)++;
1120 1120
1121 /* Save the newly calculated values on the box */ 1121 /* Save the newly calculated values on the box */
1122 _resize_box(tmp, depth, x, y, pass); 1122 _resize_box(tmp, depth, x, y, pass);
1123 1123
1124 /* Duplicate the values in the item list for use below */ 1124 /* Duplicate the values in the item list for use below */
1125 thisbox->items[z].width = tmp->minwidth; 1125 thisbox->items[z].width = tmp->minwidth;
1126 thisbox->items[z].height = tmp->minheight; 1126 thisbox->items[z].height = tmp->minheight;
1127 1127
1128 /* If the box has no contents but is expandable... default the size to 1 */ 1128 /* If the box has no contents but is expandable... default the size to 1 */
1129 if(!thisbox->items[z].width && thisbox->items[z].hsize) 1129 if(!thisbox->items[z].width && thisbox->items[z].hsize)
1130 thisbox->items[z].width = 1; 1130 thisbox->items[z].width = 1;
1131 if(!thisbox->items[z].height && thisbox->items[z].vsize) 1131 if(!thisbox->items[z].height && thisbox->items[z].vsize)
1132 thisbox->items[z].height = 1; 1132 thisbox->items[z].height = 1;
1133 1133
1134 (*depth)--; 1134 (*depth)--;
1135 } 1135 }
1136 } 1136 }
1137 } 1137 }
1138 1138
1139 /* Precalculate these values, since they will 1139 /* Precalculate these values, since they will
1140 * be used used repeatedly in the next section. 1140 * be used used repeatedly in the next section.
1141 */ 1141 */
1142 itempad = thisbox->items[z].pad * 2; 1142 itempad = thisbox->items[z].pad * 2;
1143 itemwidth = thisbox->items[z].width + itempad; 1143 itemwidth = thisbox->items[z].width + itempad;
1144 itemheight = thisbox->items[z].height + itempad; 1144 itemheight = thisbox->items[z].height + itempad;
1145 1145
1146 /* Calculate the totals and maximums */ 1146 /* Calculate the totals and maximums */
1147 if(thisbox->type == DW_VERT) 1147 if(thisbox->type == DW_VERT)
1148 { 1148 {
1149 if(itemwidth > uxmax) 1149 if(itemwidth > uxmax)
1150 uxmax = itemwidth; 1150 uxmax = itemwidth;
1151 1151
1152 if(thisbox->items[z].hsize != SIZEEXPAND) 1152 if(thisbox->items[z].hsize != SIZEEXPAND)
1153 { 1153 {
1154 if(itemwidth > upxmax) 1154 if(itemwidth > upxmax)
1155 upxmax = itemwidth; 1155 upxmax = itemwidth;
1156 } 1156 }
1197 if(thisbox->grouphwnd) 1197 if(thisbox->grouphwnd)
1198 { 1198 {
1199 currentx += 3; 1199 currentx += 3;
1200 currenty += thisbox->grouppady - 3; 1200 currenty += thisbox->grouppady - 3;
1201 } 1201 }
1202 1202
1203 /* The second pass is for actual placement. */ 1203 /* The second pass is for actual placement. */
1204 if(pass > 1) 1204 if(pass > 1)
1205 { 1205 {
1206 for(z=0;z<(thisbox->count);z++) 1206 for(z=0;z<(thisbox->count);z++)
1207 { 1207 {
1214 if(thisbox->items[z].hsize == SIZEEXPAND) 1214 if(thisbox->items[z].hsize == SIZEEXPAND)
1215 { 1215 {
1216 if(thisbox->type == DW_HORZ) 1216 if(thisbox->type == DW_HORZ)
1217 { 1217 {
1218 int expandablex = thisbox->minwidth - thisbox->usedpadx; 1218 int expandablex = thisbox->minwidth - thisbox->usedpadx;
1219 1219
1220 if(expandablex) 1220 if(expandablex)
1221 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx)); 1221 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
1222 } 1222 }
1223 else 1223 else
1224 width = x - (itempad + thispad + thisbox->grouppadx); 1224 width = x - (itempad + thispad + thisbox->grouppadx);
1226 if(thisbox->items[z].vsize == SIZEEXPAND) 1226 if(thisbox->items[z].vsize == SIZEEXPAND)
1227 { 1227 {
1228 if(thisbox->type == DW_VERT) 1228 if(thisbox->type == DW_VERT)
1229 { 1229 {
1230 int expandabley = thisbox->minheight - thisbox->usedpady; 1230 int expandabley = thisbox->minheight - thisbox->usedpady;
1231 1231
1232 if(expandabley) 1232 if(expandabley)
1233 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady)); 1233 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
1234 } 1234 }
1235 else 1235 else
1236 height = y - (itempad + thispad + thisbox->grouppady); 1236 height = y - (itempad + thispad + thisbox->grouppady);
1240 if(width > 0 && height > 0) 1240 if(width > 0 && height > 0)
1241 { 1241 {
1242 int pad = thisbox->items[z].pad; 1242 int pad = thisbox->items[z].pad;
1243 HWND handle = thisbox->items[z].hwnd; 1243 HWND handle = thisbox->items[z].hwnd;
1244 char tmpbuf[100] = {0}; 1244 char tmpbuf[100] = {0};
1245 1245
1246 WinQueryClassName(handle, 99, (PCH)tmpbuf); 1246 WinQueryClassName(handle, 99, (PCH)tmpbuf);
1247 1247
1248 if(strncmp(tmpbuf, "#2", 3)==0) 1248 if(strncmp(tmpbuf, "#2", 3)==0)
1249 { 1249 {
1250 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); 1250 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box");
1341 else 1341 else
1342 { 1342 {
1343 /* Everything else */ 1343 /* Everything else */
1344 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad, 1344 _MySetWindowPos(handle, thisbox->hwnd, HWND_TOP, currentx + pad, currenty + pad,
1345 width, height, SWP_MOVE | SWP_SIZE | SWP_ZORDER); 1345 width, height, SWP_MOVE | SWP_SIZE | SWP_ZORDER);
1346 1346
1347 /* After placing a box... place its components */ 1347 /* After placing a box... place its components */
1348 if(thisbox->items[z].type == TYPEBOX) 1348 if(thisbox->items[z].type == TYPEBOX)
1349 { 1349 {
1350 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER); 1350 Box *boxinfo = WinQueryWindowPtr(handle, QWP_USER);
1351 1351
1380 if(x != 0 && y != 0) 1380 if(x != 0 && y != 0)
1381 { 1381 {
1382 if(thisbox) 1382 if(thisbox)
1383 { 1383 {
1384 int depth = 0; 1384 int depth = 0;
1385 1385
1386 /* Calculate space requirements */ 1386 /* Calculate space requirements */
1387 _resize_box(thisbox, &depth, x, y, 1); 1387 _resize_box(thisbox, &depth, x, y, 1);
1388 1388
1389 /* Finally place all the boxes and controls */ 1389 /* Finally place all the boxes and controls */
1390 _resize_box(thisbox, &depth, x, y, 2); 1390 _resize_box(thisbox, &depth, x, y, 2);
1391 } 1391 }
1392 } 1392 }
1393 } 1393 }
4195 return FALSE; 4195 return FALSE;
4196 } 4196 }
4197 } 4197 }
4198 break; 4198 break;
4199 } 4199 }
4200 4200
4201 /* Make sure windows are up-to-date */ 4201 /* Make sure windows are up-to-date */
4202 if(retval != -1) 4202 if(retval != -1)
4203 _dw_redraw(0, FALSE); 4203 _dw_redraw(0, FALSE);
4204 if(!oldproc) 4204 if(!oldproc)
4205 return WinDefWindowProc(hwnd, msg, mp1, mp2); 4205 return WinDefWindowProc(hwnd, msg, mp1, mp2);
4323 _shift_focus(hwnd, _DW_DIRECTION_FORWARD); 4323 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
4324 return FALSE; 4324 return FALSE;
4325 } 4325 }
4326 break; 4326 break;
4327 } 4327 }
4328 4328
4329 if(oldproc) 4329 if(oldproc)
4330 return oldproc(hwnd, msg, mp1, mp2); 4330 return oldproc(hwnd, msg, mp1, mp2);
4331 4331
4332 return WinDefWindowProc(hwnd, msg, mp1, mp2); 4332 return WinDefWindowProc(hwnd, msg, mp1, mp2);
4333 } 4333 }
4383 4383
4384 /* Setup the private data directory */ 4384 /* Setup the private data directory */
4385 if(argc > 0 && argv[0]) 4385 if(argc > 0 && argv[0])
4386 { 4386 {
4387 char *pos = strrchr(argv[0], '\\'); 4387 char *pos = strrchr(argv[0], '\\');
4388 4388
4389 /* Just to be safe try the unix style */ 4389 /* Just to be safe try the unix style */
4390 if(!pos) 4390 if(!pos)
4391 pos = strrchr(argv[0], '/'); 4391 pos = strrchr(argv[0], '/');
4392 4392
4393 if(pos) 4393 if(pos)
4394 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); 4394 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0]));
4395 } 4395 }
4396 /* If that failed... just get the current directory */ 4396 /* If that failed... just get the current directory */
4397 if(!_dw_exec_dir[0]) 4397 if(!_dw_exec_dir[0])
4398 _getcwd(_dw_exec_dir, MAX_PATH); 4398 _getcwd(_dw_exec_dir, MAX_PATH);
4399 4399
4400 if(newthread) 4400 if(newthread)
4401 { 4401 {
4402 #ifdef UNICODE 4402 #ifdef UNICODE
4403 UniChar *kbd; 4403 UniChar *kbd;
4404 UniChar suCodepage[MAX_CP_SPEC]; /* conversion specifier */ 4404 UniChar suCodepage[MAX_CP_SPEC]; /* conversion specifier */
4500 /* Make sure any queued redraws are handled */ 4500 /* Make sure any queued redraws are handled */
4501 _dw_redraw(0, FALSE); 4501 _dw_redraw(0, FALSE);
4502 4502
4503 /* Set the running flag to TRUE */ 4503 /* Set the running flag to TRUE */
4504 _dw_main_running = TRUE; 4504 _dw_main_running = TRUE;
4505 4505
4506 /* Run the loop until the flag is unset... or error */ 4506 /* Run the loop until the flag is unset... or error */
4507 while(_dw_main_running && WinGetMsg(dwhab, &qmsg, 0, 0, 0)) 4507 while(_dw_main_running && WinGetMsg(dwhab, &qmsg, 0, 0, 0))
4508 { 4508 {
4509 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) 4509 if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE)
4510 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); 4510 _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2);
4918 4918
4919 if(menu && WinIsWindow(dwhab, menu)) 4919 if(menu && WinIsWindow(dwhab, menu))
4920 return dw_menu_delete_item((HMENUI)menu, handle); 4920 return dw_menu_delete_item((HMENUI)menu, handle);
4921 return DW_ERROR_UNKNOWN; 4921 return DW_ERROR_UNKNOWN;
4922 } 4922 }
4923 4923
4924 parent = WinQueryWindow(handle, QW_PARENT); 4924 parent = WinQueryWindow(handle, QW_PARENT);
4925 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); 4925 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box");
4926 4926
4927 if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE) 4927 if((menu = WinWindowFromID(handle, FID_MENU)) != NULLHANDLE)
4928 _free_menu_data(menu); 4928 _free_menu_data(menu);
5041 * fontname: Font name in Dynamic Windows format. 5041 * fontname: Font name in Dynamic Windows format.
5042 */ 5042 */
5043 void API dw_font_set_default(const char *fontname) 5043 void API dw_font_set_default(const char *fontname)
5044 { 5044 {
5045 char *oldfont = DefaultFont; 5045 char *oldfont = DefaultFont;
5046 5046
5047 DefaultFont = strdup(fontname); 5047 DefaultFont = strdup(fontname);
5048 free(oldfont); 5048 free(oldfont);
5049 } 5049 }
5050 5050
5051 /* Internal function to return a pointer to an item struct 5051 /* Internal function to return a pointer to an item struct
5052 * with information about the packing information regarding object. 5052 * with information about the packing information regarding object.
5053 */ 5053 */
5054 Item *_box_item(HWND handle) 5054 Item *_box_item(HWND handle)
5055 { 5055 {
5056 HWND parent = WinQueryWindow(handle, QW_PARENT); 5056 HWND parent = WinQueryWindow(handle, QW_PARENT);
5057 Box *thisbox = (Box *)WinQueryWindowPtr(parent, QWP_USER); 5057 Box *thisbox = (Box *)WinQueryWindowPtr(parent, QWP_USER);
5058 5058
5059 /* If it is a desktop window let WM_DESTROY handle it */ 5059 /* If it is a desktop window let WM_DESTROY handle it */
5060 if(parent != HWND_DESKTOP) 5060 if(parent != HWND_DESKTOP)
5061 { 5061 {
5062 if(thisbox && thisbox->count) 5062 if(thisbox && thisbox->count)
5063 { 5063 {
5074 return NULL; 5074 return NULL;
5075 } 5075 }
5076 5076
5077 /* Internal function to calculate the widget's required size.. 5077 /* Internal function to calculate the widget's required size..
5078 * These are the general rules for widget sizes: 5078 * These are the general rules for widget sizes:
5079 * 5079 *
5080 * Render/Unspecified: 1x1 5080 * Render/Unspecified: 1x1
5081 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h 5081 * Scrolled(Container,Tree,MLE): Guessed size clamped to min and max in dw.h
5082 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight) 5082 * Entryfield/Combobox/Spinbutton: 150x(maxfontheight)
5083 * Spinbutton: 50x(maxfontheight) 5083 * Spinbutton: 50x(maxfontheight)
5084 * Text/Status: (textwidth)x(textheight) 5084 * Text/Status: (textwidth)x(textheight)
5091 char tmpbuf[100] = {0}, *buf = dw_window_get_text(handle); 5091 char tmpbuf[100] = {0}, *buf = dw_window_get_text(handle);
5092 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 5092 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
5093 5093
5094 WinQueryClassName(handle, 99, (PCH)tmpbuf); 5094 WinQueryClassName(handle, 99, (PCH)tmpbuf);
5095 5095
5096 /* If we have a string... 5096 /* If we have a string...
5097 * calculate the size with the current font. 5097 * calculate the size with the current font.
5098 */ 5098 */
5099 if(buf) 5099 if(buf)
5100 { 5100 {
5101 if(*buf) 5101 if(*buf)
5102 dw_font_text_extents_get(handle, NULL, buf, &thiswidth, &thisheight); 5102 dw_font_text_extents_get(handle, NULL, buf, &thiswidth, &thisheight);
5103 dw_free(buf); 5103 dw_free(buf);
5104 } 5104 }
5105 5105
5106 /* Combobox */ 5106 /* Combobox */
5107 if(strncmp(tmpbuf, "#2", 3)==0) 5107 if(strncmp(tmpbuf, "#2", 3)==0)
5108 { 5108 {
5109 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); 5109 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight);
5110 thiswidth = 150; 5110 thiswidth = 150;
5238 else if(strncmp(tmpbuf, "#7", 3)==0) 5238 else if(strncmp(tmpbuf, "#7", 3)==0)
5239 { 5239 {
5240 char buf[1025] = {0}; 5240 char buf[1025] = {0};
5241 int x, count = dw_listbox_count(handle); 5241 int x, count = dw_listbox_count(handle);
5242 int basicwidth = thiswidth = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL) + 8; 5242 int basicwidth = thiswidth = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL) + 8;
5243 5243
5244 thisheight = 8; 5244 thisheight = 8;
5245 5245
5246 for(x=0;x<count;x++) 5246 for(x=0;x<count;x++)
5247 { 5247 {
5248 int height, width = 0; 5248 int height, width = 0;
5249 5249
5250 dw_listbox_get_text(handle, x, buf, 1024); 5250 dw_listbox_get_text(handle, x, buf, 1024);
5251 5251
5252 if(strlen(buf)) 5252 if(strlen(buf))
5253 dw_font_text_extents_get(handle, NULL, buf, &width, &height); 5253 dw_font_text_extents_get(handle, NULL, buf, &width, &height);
5254 else 5254 else
5255 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height); 5255 dw_font_text_extents_get(handle, NULL, testtext, NULL, &height);
5256 5256
5257 width += basicwidth; 5257 width += basicwidth;
5258 5258
5259 if(width > thiswidth) 5259 if(width > thiswidth)
5260 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width; 5260 thiswidth = width > _DW_SCROLLED_MAX_WIDTH ? _DW_SCROLLED_MAX_WIDTH : width;
5261 thisheight += height; 5261 thisheight += height;
5262 } 5262 }
5263 5263
5264 if(thiswidth < _DW_SCROLLED_MIN_WIDTH) 5264 if(thiswidth < _DW_SCROLLED_MIN_WIDTH)
5265 thiswidth = _DW_SCROLLED_MIN_WIDTH; 5265 thiswidth = _DW_SCROLLED_MIN_WIDTH;
5266 if(thisheight < _DW_SCROLLED_MIN_HEIGHT) 5266 if(thisheight < _DW_SCROLLED_MIN_HEIGHT)
5267 thisheight = _DW_SCROLLED_MIN_HEIGHT; 5267 thisheight = _DW_SCROLLED_MIN_HEIGHT;
5268 if(thisheight > _DW_SCROLLED_MAX_HEIGHT) 5268 if(thisheight > _DW_SCROLLED_MAX_HEIGHT)
5384 } 5384 }
5385 /* Button */ 5385 /* Button */
5386 else if(strncmp(tmpbuf, "#3", 3)==0) 5386 else if(strncmp(tmpbuf, "#3", 3)==0)
5387 { 5387 {
5388 ULONG style = WinQueryWindowULong(handle, QWL_STYLE); 5388 ULONG style = WinQueryWindowULong(handle, QWL_STYLE);
5389 5389
5390 if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON) 5390 if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON)
5391 { 5391 {
5392 extrawidth = 24; 5392 extrawidth = 24;
5393 extraheight = 4; 5393 extraheight = 4;
5394 } 5394 }
5462 extraheight += 4; 5462 extraheight += 4;
5463 } 5463 }
5464 } 5464 }
5465 } 5465 }
5466 5466
5467 /* Set the requested sizes */ 5467 /* Set the requested sizes */
5468 if(width) 5468 if(width)
5469 *width = thiswidth + extrawidth; 5469 *width = thiswidth + extrawidth;
5470 if(height) 5470 if(height)
5471 *height = thisheight + extraheight; 5471 *height = thisheight + extraheight;
5472 } 5472 }
5482 HWND group = (HWND)dw_window_get_data(handle, "_dw_buddy"); 5482 HWND group = (HWND)dw_window_get_data(handle, "_dw_buddy");
5483 /* If we changed the font... */ 5483 /* If we changed the font... */
5484 if(!WinSetPresParam(group ? group : handle, PP_FONTNAMESIZE, strlen(fontname)+1, (void *)fontname)) 5484 if(!WinSetPresParam(group ? group : handle, PP_FONTNAMESIZE, strlen(fontname)+1, (void *)fontname))
5485 { 5485 {
5486 Item *item = _box_item(handle); 5486 Item *item = _box_item(handle);
5487 5487
5488 /* Check to see if any of the sizes need to be recalculated */ 5488 /* Check to see if any of the sizes need to be recalculated */
5489 if(item && (item->origwidth == -1 || item->origheight == -1)) 5489 if(item && (item->origwidth == -1 || item->origheight == -1))
5490 { 5490 {
5491 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 5491 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
5492 /* Queue a redraw on the top-level window */ 5492 /* Queue a redraw on the top-level window */
5493 _dw_redraw(_toplevel_window(handle), TRUE); 5493 _dw_redraw(_toplevel_window(handle), TRUE);
5494 } 5494 }
5495 return DW_ERROR_NONE; 5495 return DW_ERROR_NONE;
5496 } 5496 }
6030 SignalHandler *tmp = Root; 6030 SignalHandler *tmp = Root;
6031 6031
6032 while(tmp) 6032 while(tmp)
6033 { 6033 {
6034 if(tmp->id == id) 6034 if(tmp->id == id)
6035 return TRUE; 6035 return TRUE;
6036 tmp = tmp->next; 6036 tmp = tmp->next;
6037 } 6037 }
6038 return FALSE; 6038 return FALSE;
6039 } 6039 }
6040 6040
6075 miSubMenu.afAttribute |= MIA_DISABLED; 6075 miSubMenu.afAttribute |= MIA_DISABLED;
6076 6076
6077 if (title && *title) 6077 if (title && *title)
6078 { 6078 {
6079 /* Code to autogenerate a menu ID if not specified or invalid 6079 /* Code to autogenerate a menu ID if not specified or invalid
6080 * First pool is smaller for transient popup menus 6080 * First pool is smaller for transient popup menus
6081 */ 6081 */
6082 if(id == (ULONG)-1) 6082 if(id == (ULONG)-1)
6083 { 6083 {
6084 static ULONG tempid = 61000; 6084 static ULONG tempid = 61000;
6085 6085
6086 tempid++; 6086 tempid++;
6087 id = tempid; 6087 id = tempid;
6088 6088
6089 if(tempid > 65500) 6089 if(tempid > 65500)
6090 tempid = 61000; 6090 tempid = 61000;
6091 } 6091 }
6092 /* Special internal case */ 6092 /* Special internal case */
6093 else if(id > 60000 && check == -1) 6093 else if(id > 60000 && check == -1)
6096 } 6096 }
6097 /* Second pool is larger for more static windows */ 6097 /* Second pool is larger for more static windows */
6098 else if(!id || id >= 30000) 6098 else if(!id || id >= 30000)
6099 { 6099 {
6100 static ULONG menuid = 30000; 6100 static ULONG menuid = 30000;
6101 6101
6102 do 6102 do
6103 { 6103 {
6104 menuid++; 6104 menuid++;
6105 if(menuid > 60000) 6105 if(menuid > 60000)
6106 menuid = 30000; 6106 menuid = 30000;
6226 /* 6226 /*
6227 * Deletes the menu item specified 6227 * Deletes the menu item specified
6228 * Parameters: 6228 * Parameters:
6229 * menu: The handle to the menu in which the item was appended. 6229 * menu: The handle to the menu in which the item was appended.
6230 * id: Menuitem id. 6230 * id: Menuitem id.
6231 * Returns: 6231 * Returns:
6232 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. 6232 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
6233 */ 6233 */
6234 int API dw_menu_delete_item(HMENUI menux, unsigned long id) 6234 int API dw_menu_delete_item(HMENUI menux, unsigned long id)
6235 { 6235 {
6236 if(id < 65536 && menux) 6236 if(id < 65536 && menux)
7446 dw_window_set_data(handle, "_dw_bitmapbutton", DW_POINTER(1)); 7446 dw_window_set_data(handle, "_dw_bitmapbutton", DW_POINTER(1));
7447 /* Make sure we invalidate the button so it redraws */ 7447 /* Make sure we invalidate the button so it redraws */
7448 WinQueryWindowRect(handle, &rect); 7448 WinQueryWindowRect(handle, &rect);
7449 WinInvalidateRect(handle, &rect, TRUE); 7449 WinInvalidateRect(handle, &rect, TRUE);
7450 } 7450 }
7451 7451
7452 /* If we changed the bitmap... */ 7452 /* If we changed the bitmap... */
7453 { 7453 {
7454 Item *item = _box_item(handle); 7454 Item *item = _box_item(handle);
7455 7455
7456 /* Check to see if any of the sizes need to be recalculated */ 7456 /* Check to see if any of the sizes need to be recalculated */
7457 if(item && (item->origwidth == -1 || item->origheight == -1)) 7457 if(item && (item->origwidth == -1 || item->origheight == -1))
7458 { 7458 {
7459 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 7459 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
7460 /* Queue a redraw on the top-level window */ 7460 /* Queue a redraw on the top-level window */
7461 _dw_redraw(_toplevel_window(handle), TRUE); 7461 _dw_redraw(_toplevel_window(handle), TRUE);
7462 } 7462 }
7463 } 7463 }
7464 } 7464 }
7630 HWND entryfield = (HWND)dw_window_get_data(handle, "_dw_buddy"); 7630 HWND entryfield = (HWND)dw_window_get_data(handle, "_dw_buddy");
7631 WinSetWindowText(entryfield ? entryfield : handle, (PSZ)text); 7631 WinSetWindowText(entryfield ? entryfield : handle, (PSZ)text);
7632 /* If we changed the text... */ 7632 /* If we changed the text... */
7633 { 7633 {
7634 Item *item = _box_item(handle); 7634 Item *item = _box_item(handle);
7635 7635
7636 /* Check to see if any of the sizes need to be recalculated */ 7636 /* Check to see if any of the sizes need to be recalculated */
7637 if(item && (item->origwidth == -1 || item->origheight == -1)) 7637 if(item && (item->origwidth == -1 || item->origheight == -1))
7638 { 7638 {
7639 int newwidth, newheight; 7639 int newwidth, newheight;
7640 7640
7641 _control_size(handle, &newwidth, &newheight); 7641 _control_size(handle, &newwidth, &newheight);
7642 7642
7643 /* Only update the item and redraw the window if it changed */ 7643 /* Only update the item and redraw the window if it changed */
7644 if((item->origwidth == -1 && item->width != newwidth) || 7644 if((item->origwidth == -1 && item->width != newwidth) ||
7645 (item->origheight == -1 && item->height != newheight)) 7645 (item->origheight == -1 && item->height != newheight))
7646 { 7646 {
7647 if(item->origwidth == -1) 7647 if(item->origwidth == -1)
7704 7704
7705 if(handle < 65536) 7705 if(handle < 65536)
7706 { 7706 {
7707 char buffer[30]; 7707 char buffer[30];
7708 HMENUI mymenu; 7708 HMENUI mymenu;
7709 7709
7710 sprintf(buffer, "_dw_id%ld", handle); 7710 sprintf(buffer, "_dw_id%ld", handle);
7711 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer); 7711 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer);
7712 7712
7713 if(mymenu && WinIsWindow(dwhab, mymenu)) 7713 if(mymenu && WinIsWindow(dwhab, mymenu))
7714 dw_menu_item_set_state(mymenu, handle, DW_MIS_DISABLED); 7714 dw_menu_item_set_state(mymenu, handle, DW_MIS_DISABLED);
7715 return; 7715 return;
7716 } 7716 }
7717 7717
7769 7769
7770 if(handle < 65536) 7770 if(handle < 65536)
7771 { 7771 {
7772 char buffer[30]; 7772 char buffer[30];
7773 HMENUI mymenu; 7773 HMENUI mymenu;
7774 7774
7775 sprintf(buffer, "_dw_id%ld", handle); 7775 sprintf(buffer, "_dw_id%ld", handle);
7776 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer); 7776 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer);
7777 7777
7778 if(mymenu && WinIsWindow(dwhab, mymenu)) 7778 if(mymenu && WinIsWindow(dwhab, mymenu))
7779 dw_menu_item_set_state(mymenu, handle, DW_MIS_ENABLED); 7779 dw_menu_item_set_state(mymenu, handle, DW_MIS_ENABLED);
7780 return; 7780 return;
7781 } 7781 }
7782 7782
7828 7828
7829 /* Internal box packing function called by the other 3 functions */ 7829 /* Internal box packing function called by the other 3 functions */
7830 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname) 7830 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, char *funcname)
7831 { 7831 {
7832 Box *thisbox; 7832 Box *thisbox;
7833 7833
7834 /* 7834 /*
7835 * If you try and pack an item into itself VERY bad things can happen; like at least an 7835 * If you try and pack an item into itself VERY bad things can happen; like at least an
7836 * infinite loop on GTK! Lets be safe! 7836 * infinite loop on GTK! Lets be safe!
7837 */ 7837 */
7838 if(box == item) 7838 if(box == item)
7851 else 7851 else
7852 { 7852 {
7853 box = WinWindowFromID(box, FID_CLIENT); 7853 box = WinWindowFromID(box, FID_CLIENT);
7854 } 7854 }
7855 } 7855 }
7856 7856
7857 thisbox = WinQueryWindowPtr(box, QWP_USER); 7857 thisbox = WinQueryWindowPtr(box, QWP_USER);
7858 7858
7859 if(thisbox) 7859 if(thisbox)
7860 { 7860 {
7861 int z, x = 0; 7861 int z, x = 0;
7868 thisbox->count = 0; 7868 thisbox->count = 0;
7869 if(index < 0) 7869 if(index < 0)
7870 index = 0; 7870 index = 0;
7871 if(index > thisbox->count) 7871 if(index > thisbox->count)
7872 index = thisbox->count; 7872 index = thisbox->count;
7873 7873
7874 tmpitem = calloc(sizeof(Item), (thisbox->count+1)); 7874 tmpitem = calloc(sizeof(Item), (thisbox->count+1));
7875 7875
7876 for(z=0;z<thisbox->count;z++) 7876 for(z=0;z<thisbox->count;z++)
7877 { 7877 {
7878 if(z == index) 7878 if(z == index)
7904 tmpitem[index].origwidth = tmpitem[index].width = width; 7904 tmpitem[index].origwidth = tmpitem[index].width = width;
7905 tmpitem[index].origheight = tmpitem[index].height = height; 7905 tmpitem[index].origheight = tmpitem[index].height = height;
7906 tmpitem[index].pad = pad; 7906 tmpitem[index].pad = pad;
7907 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC; 7907 tmpitem[index].hsize = hsize ? SIZEEXPAND : SIZESTATIC;
7908 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC; 7908 tmpitem[index].vsize = vsize ? SIZEEXPAND : SIZESTATIC;
7909 7909
7910 /* If either of the parameters are -1 ... calculate the size */ 7910 /* If either of the parameters are -1 ... calculate the size */
7911 if(width == -1 || height == -1) 7911 if(width == -1 || height == -1)
7912 _control_size(item, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL); 7912 _control_size(item, width == -1 ? &tmpitem[index].width : NULL, height == -1 ? &tmpitem[index].height : NULL);
7913 7913
7914 thisbox->items = tmpitem; 7914 thisbox->items = tmpitem;
7940 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure. 7940 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
7941 */ 7941 */
7942 int API dw_box_unpack(HWND handle) 7942 int API dw_box_unpack(HWND handle)
7943 { 7943 {
7944 HWND parent = WinQueryWindow(handle, QW_PARENT); 7944 HWND parent = WinQueryWindow(handle, QW_PARENT);
7945 7945
7946 if(parent != desktop) 7946 if(parent != desktop)
7947 { 7947 {
7948 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); 7948 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER);
7949 7949
7950 /* If the parent box has items... 7950 /* If the parent box has items...
7951 * try to remove it from the layout 7951 * try to remove it from the layout
7952 */ 7952 */
7953 if(thisbox && thisbox->count) 7953 if(thisbox && thisbox->count)
7954 { 7954 {
7955 int z, index = -1; 7955 int z, index = -1;
7956 Item *tmpitem = NULL, *thisitem = thisbox->items; 7956 Item *tmpitem = NULL, *thisitem = thisbox->items;
7957 7957
7958 if(!thisitem) 7958 if(!thisitem)
7959 thisbox->count = 0; 7959 thisbox->count = 0;
7960 7960
7961 for(z=0;z<thisbox->count;z++) 7961 for(z=0;z<thisbox->count;z++)
7962 { 7962 {
7963 if(thisitem[z].hwnd == handle) 7963 if(thisitem[z].hwnd == handle)
7964 index = z; 7964 index = z;
7965 } 7965 }
7987 free(thisitem); 7987 free(thisitem);
7988 if(tmpitem) 7988 if(tmpitem)
7989 thisbox->count--; 7989 thisbox->count--;
7990 else 7990 else
7991 thisbox->count = 0; 7991 thisbox->count = 0;
7992 7992
7993 /* If it isn't padding, reset the parent */ 7993 /* If it isn't padding, reset the parent */
7994 if(handle) 7994 if(handle)
7995 WinSetParent(handle, HWND_OBJECT, FALSE); 7995 WinSetParent(handle, HWND_OBJECT, FALSE);
7996 /* Queue a redraw on the top-level window */ 7996 /* Queue a redraw on the top-level window */
7997 _dw_redraw(_toplevel_window(parent), TRUE); 7997 _dw_redraw(_toplevel_window(parent), TRUE);
8010 * Handle to the removed item on success, 0 on failure or padding. 8010 * Handle to the removed item on success, 0 on failure or padding.
8011 */ 8011 */
8012 HWND API dw_box_unpack_at_index(HWND box, int index) 8012 HWND API dw_box_unpack_at_index(HWND box, int index)
8013 { 8013 {
8014 Box *thisbox = WinQueryWindowPtr(box, QWP_USER); 8014 Box *thisbox = WinQueryWindowPtr(box, QWP_USER);
8015 8015
8016 /* Try to remove it from the layout */ 8016 /* Try to remove it from the layout */
8017 if(thisbox && index > -1 && index < thisbox->count) 8017 if(thisbox && index > -1 && index < thisbox->count)
8018 { 8018 {
8019 int z; 8019 int z;
8020 Item *tmpitem = NULL, *thisitem = thisbox->items; 8020 Item *tmpitem = NULL, *thisitem = thisbox->items;
8040 free(thisitem); 8040 free(thisitem);
8041 if(tmpitem) 8041 if(tmpitem)
8042 thisbox->count--; 8042 thisbox->count--;
8043 else 8043 else
8044 thisbox->count = 0; 8044 thisbox->count = 0;
8045 8045
8046 /* If it isn't padding, reset the parent */ 8046 /* If it isn't padding, reset the parent */
8047 if(handle) 8047 if(handle)
8048 WinSetParent(handle, HWND_OBJECT, FALSE); 8048 WinSetParent(handle, HWND_OBJECT, FALSE);
8049 /* Queue a redraw on the top-level window */ 8049 /* Queue a redraw on the top-level window */
8050 _dw_redraw(_toplevel_window(box), TRUE); 8050 _dw_redraw(_toplevel_window(box), TRUE);
8056 /* 8056 /*
8057 * Pack windows (widgets) into a box at an arbitrary location. 8057 * Pack windows (widgets) into a box at an arbitrary location.
8058 * Parameters: 8058 * Parameters:
8059 * box: Window handle of the box to be packed into. 8059 * box: Window handle of the box to be packed into.
8060 * item: Window handle of the item to pack. 8060 * item: Window handle of the item to pack.
8061 * index: 0 based index of packed items. 8061 * index: 0 based index of packed items.
8062 * width: Width in pixels of the item or -1 to be self determined. 8062 * width: Width in pixels of the item or -1 to be self determined.
8063 * height: Height in pixels of the item or -1 to be self determined. 8063 * height: Height in pixels of the item or -1 to be self determined.
8064 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. 8064 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
8065 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8065 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
8066 * pad: Number of pixels of padding around the item. 8066 * pad: Number of pixels of padding around the item.
8081 * vsize: TRUE if the window (widget) should expand vertically to fill space given. 8081 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
8082 * pad: Number of pixels of padding around the item. 8082 * pad: Number of pixels of padding around the item.
8083 */ 8083 */
8084 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 8084 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
8085 { 8085 {
8086 /* 65536 is the table limit on GTK... 8086 /* 65536 is the table limit on GTK...
8087 * seems like a high enough value we will never hit it here either. 8087 * seems like a high enough value we will never hit it here either.
8088 */ 8088 */
8089 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()"); 8089 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()");
8090 } 8090 }
8091 8091
8119 int depth = 0; 8119 int depth = 0;
8120 RECTL rect = { 0 }; 8120 RECTL rect = { 0 };
8121 8121
8122 /* Calculate space requirements */ 8122 /* Calculate space requirements */
8123 _resize_box(thisbox, &depth, *width, *height, 1); 8123 _resize_box(thisbox, &depth, *width, *height, 1);
8124 8124
8125 rect.xRight = thisbox->minwidth; 8125 rect.xRight = thisbox->minwidth;
8126 rect.yTop = thisbox->minheight; 8126 rect.yTop = thisbox->minheight;
8127 8127
8128 /* Take into account the window border and menu here */ 8128 /* Take into account the window border and menu here */
8129 WinCalcFrameRect(handle, &rect, FALSE); 8129 WinCalcFrameRect(handle, &rect, FALSE);
8130 8130
8131 if(*width < 1) *width = rect.xRight - rect.xLeft; 8131 if(*width < 1) *width = rect.xRight - rect.xLeft;
8132 if(*height < 1) *height = rect.yTop - rect.yBottom; 8132 if(*height < 1) *height = rect.yTop - rect.yBottom;
8133 } 8133 }
8134 } 8134 }
8135 8135
8143 void API dw_window_set_size(HWND handle, ULONG width, ULONG height) 8143 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
8144 { 8144 {
8145 /* Attempt to auto-size */ 8145 /* Attempt to auto-size */
8146 if ( width < 1 || height < 1 ) 8146 if ( width < 1 || height < 1 )
8147 _get_window_for_size(handle, &width, &height); 8147 _get_window_for_size(handle, &width, &height);
8148 8148
8149 /* Finally set the size */ 8149 /* Finally set the size */
8150 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SIZE); 8150 WinSetWindowPos(handle, NULLHANDLE, 0, 0, width, height, SWP_SIZE);
8151 } 8151 }
8152 8152
8153 /* 8153 /*
8164 WinQueryClassName(handle, 99, (PCH)tmpbuf); 8164 WinQueryClassName(handle, 99, (PCH)tmpbuf);
8165 8165
8166 if(strncmp(tmpbuf, "#1", 3)==0) 8166 if(strncmp(tmpbuf, "#1", 3)==0)
8167 { 8167 {
8168 HWND box = WinWindowFromID(handle, FID_CLIENT); 8168 HWND box = WinWindowFromID(handle, FID_CLIENT);
8169 8169
8170 if(box) 8170 if(box)
8171 { 8171 {
8172 unsigned long thiswidth = 0, thisheight = 0; 8172 unsigned long thiswidth = 0, thisheight = 0;
8173 8173
8174 /* Get the size with the border */ 8174 /* Get the size with the border */
8175 _get_window_for_size(handle, &thiswidth, &thisheight); 8175 _get_window_for_size(handle, &thiswidth, &thisheight);
8176 8176
8177 /* Return what was requested */ 8177 /* Return what was requested */
8178 if(width) *width = (int)thiswidth; 8178 if(width) *width = (int)thiswidth;
8179 if(height) *height = (int)thisheight; 8179 if(height) *height = (int)thisheight;
8180 } 8180 }
8181 else 8181 else
8182 { 8182 {
8183 Box *thisbox = WinQueryWindowPtr(handle, QWP_USER); 8183 Box *thisbox = WinQueryWindowPtr(handle, QWP_USER);
8184 8184
8185 if(thisbox) 8185 if(thisbox)
8186 { 8186 {
8187 int depth = 0; 8187 int depth = 0;
8188 8188
8189 /* Calculate space requirements */ 8189 /* Calculate space requirements */
8190 _resize_box(thisbox, &depth, 0, 0, 1); 8190 _resize_box(thisbox, &depth, 0, 0, 1);
8191 8191
8192 /* Return what was requested */ 8192 /* Return what was requested */
8193 if(width) *width = thisbox->minwidth; 8193 if(width) *width = thisbox->minwidth;
8194 if(height) *height = thisbox->minheight; 8194 if(height) *height = thisbox->minheight;
8195 } 8195 }
8196 } 8196 }
8243 /* Convert the coordinates based on gravity */ 8243 /* Convert the coordinates based on gravity */
8244 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height) 8244 void _handle_gravity(HWND handle, long *x, long *y, unsigned long width, unsigned long height)
8245 { 8245 {
8246 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz")); 8246 int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz"));
8247 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert")); 8247 int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert"));
8248 8248
8249 /* Do any gravity calculations */ 8249 /* Do any gravity calculations */
8250 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM) 8250 if(horz || (vert & 0xf) != DW_GRAV_BOTTOM)
8251 { 8251 {
8252 long newx = *x, newy = *y; 8252 long newx = *x, newy = *y;
8253 8253
8254 /* Handle horizontal center gravity */ 8254 /* Handle horizontal center gravity */
8255 if((horz & 0xf) == DW_GRAV_CENTER) 8255 if((horz & 0xf) == DW_GRAV_CENTER)
8256 newx += ((dw_screen_width() / 2) - (width / 2)); 8256 newx += ((dw_screen_width() / 2) - (width / 2));
8257 /* Handle right gravity */ 8257 /* Handle right gravity */
8258 else if((horz & 0xf) == DW_GRAV_RIGHT) 8258 else if((horz & 0xf) == DW_GRAV_RIGHT)
8260 /* Handle vertical center gravity */ 8260 /* Handle vertical center gravity */
8261 if((vert & 0xf) == DW_GRAV_CENTER) 8261 if((vert & 0xf) == DW_GRAV_CENTER)
8262 newy += ((dw_screen_height() / 2) - (height / 2)); 8262 newy += ((dw_screen_height() / 2) - (height / 2));
8263 else if((vert & 0xf) == DW_GRAV_TOP) 8263 else if((vert & 0xf) == DW_GRAV_TOP)
8264 newy = dw_screen_height() - height - *y; 8264 newy = dw_screen_height() - height - *y;
8265 8265
8266 /* Save the new values */ 8266 /* Save the new values */
8267 *x = newx; 8267 *x = newx;
8268 *y = newy; 8268 *y = newy;
8269 } 8269 }
8270 /* Adjust the values to avoid WarpCenter/XCenter/eCenter if requested */ 8270 /* Adjust the values to avoid WarpCenter/XCenter/eCenter if requested */
8271 if(_WinQueryDesktopWorkArea && (horz | vert) & DW_GRAV_OBSTACLES) 8271 if(_WinQueryDesktopWorkArea && (horz | vert) & DW_GRAV_OBSTACLES)
8272 { 8272 {
8273 RECTL rect; 8273 RECTL rect;
8274 8274
8325 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height) 8325 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height)
8326 { 8326 {
8327 /* Attempt to auto-size */ 8327 /* Attempt to auto-size */
8328 if ( width < 1 || height < 1 ) 8328 if ( width < 1 || height < 1 )
8329 _get_window_for_size(handle, &width, &height); 8329 _get_window_for_size(handle, &width, &height);
8330 8330
8331 _handle_gravity(handle, &x, &y, width, height); 8331 _handle_gravity(handle, &x, &y, width, height);
8332 /* Finally set the size */ 8332 /* Finally set the size */
8333 WinSetWindowPos(handle, NULLHANDLE, x, y, width, height, SWP_MOVE | SWP_SIZE); 8333 WinSetWindowPos(handle, NULLHANDLE, x, y, width, height, SWP_MOVE | SWP_SIZE);
8334 } 8334 }
8335 8335
8367 { 8367 {
8368 if(handle < 65536) 8368 if(handle < 65536)
8369 { 8369 {
8370 char buffer[30]; 8370 char buffer[30];
8371 HMENUI mymenu; 8371 HMENUI mymenu;
8372 8372
8373 sprintf(buffer, "_dw_id%ld", handle); 8373 sprintf(buffer, "_dw_id%ld", handle);
8374 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer); 8374 mymenu = (HMENUI)dw_window_get_data(hwndApp, buffer);
8375 8375
8376 if(mymenu && WinIsWindow(dwhab, mymenu)) 8376 if(mymenu && WinIsWindow(dwhab, mymenu))
8377 dw_menu_item_set_state(mymenu, handle, style & mask); 8377 dw_menu_item_set_state(mymenu, handle, style & mask);
8378 } 8378 }
8379 else 8379 else
8380 WinSetWindowBits(handle, QWL_STYLE, style, mask); 8380 WinSetWindowBits(handle, QWL_STYLE, style, mask);
8893 { 8893 {
8894 int mypos = (((float)position)/100)*range; 8894 int mypos = (((float)position)/100)*range;
8895 8895
8896 if(mypos >= range) 8896 if(mypos >= range)
8897 mypos = range - 1; 8897 mypos = range - 1;
8898 8898
8899 _dw_int_set(handle, mypos); 8899 _dw_int_set(handle, mypos);
8900 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos); 8900 WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)mypos);
8901 } 8901 }
8902 } 8902 }
8903 8903
9804 { 9804 {
9805 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER); 9805 WindowData *blah = (WindowData *)WinQueryWindowPtr(handle, QWP_USER);
9806 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0; 9806 ULONG totalsize, size = 0, *flags = blah ? blah->data : 0;
9807 int z, count = 0; 9807 int z, count = 0;
9808 char *oldtitle = (char *)temp->pszIcon; 9808 char *oldtitle = (char *)temp->pszIcon;
9809 9809
9810 if(!flags) 9810 if(!flags)
9811 return; 9811 return;
9812 9812
9813 while(flags[count]) 9813 while(flags[count])
9814 count++; 9814 count++;
9815 9815
9816 /* Empty and free the title memory */ 9816 /* Empty and free the title memory */
9817 temp->pszIcon = temp->pszText = NULL; 9817 temp->pszIcon = temp->pszText = NULL;
9818 if(oldtitle) 9818 if(oldtitle)
9819 free(oldtitle); 9819 free(oldtitle);
9820 9820
9821 /* Figure out the offsets to the items in the struct */ 9821 /* Figure out the offsets to the items in the struct */
9822 for(z=0;z<count;z++) 9822 for(z=0;z<count;z++)
9823 { 9823 {
9824 if(flags[z] & DW_CFA_BITMAPORICON) 9824 if(flags[z] & DW_CFA_BITMAPORICON)
9825 size += sizeof(HPOINTER); 9825 size += sizeof(HPOINTER);
10071 char *oldtitle = (char *)pCore->pszIcon; 10071 char *oldtitle = (char *)pCore->pszIcon;
10072 char *newtitle = title ? strdup(title) : NULL; 10072 char *newtitle = title ? strdup(title) : NULL;
10073 pCore->pszName = pCore->pszIcon = (PSZ)newtitle; 10073 pCore->pszName = pCore->pszIcon = (PSZ)newtitle;
10074 10074
10075 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_NOREPOSITION | CMA_TEXTCHANGED)); 10075 WinSendMsg(handle, CM_INVALIDATERECORD, (MPARAM)&pCore, MPFROM2SHORT(1, CMA_NOREPOSITION | CMA_TEXTCHANGED));
10076 10076
10077 if(oldtitle) 10077 if(oldtitle)
10078 free(oldtitle); 10078 free(oldtitle);
10079 return; 10079 return;
10080 } 10080 }
10081 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); 10081 pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
11459 HPS hpsdest; 11459 HPS hpsdest;
11460 HPS hpssrc; 11460 HPS hpssrc;
11461 POINTL ptl[4]; 11461 POINTL ptl[4];
11462 int dheight, sheight; 11462 int dheight, sheight;
11463 int count = 3; 11463 int count = 3;
11464 11464
11465 /* Do some sanity checks */ 11465 /* Do some sanity checks */
11466 if((srcheight == -1 || srcwidth == -1) && srcheight != srcwidth) 11466 if((srcheight == -1 || srcwidth == -1) && srcheight != srcwidth)
11467 return DW_ERROR_GENERAL; 11467 return DW_ERROR_GENERAL;
11468 11468
11469 if(dest) 11469 if(dest)
11919 if(DosFreeMem(ptr) != NO_ERROR) 11919 if(DosFreeMem(ptr) != NO_ERROR)
11920 return -1; 11920 return -1;
11921 return 0; 11921 return 0;
11922 } 11922 }
11923 11923
11924 /* 11924 /*
11925 * Generally an internal function called from a newly created 11925 * Generally an internal function called from a newly created
11926 * thread to setup the Dynamic Windows environment for the thread. 11926 * thread to setup the Dynamic Windows environment for the thread.
11927 * However it is exported so language bindings can call it when 11927 * However it is exported so language bindings can call it when
11928 * they create threads that require access to Dynamic Windows. 11928 * they create threads that require access to Dynamic Windows.
11929 */ 11929 */
11933 HMQ thishmq = WinCreateMsgQueue(thishab, 0); 11933 HMQ thishmq = WinCreateMsgQueue(thishab, 0);
11934 void **threadinfo = (void **)malloc(sizeof(void *) * 2); 11934 void **threadinfo = (void **)malloc(sizeof(void *) * 2);
11935 11935
11936 threadinfo[0] = (void *)thishab; 11936 threadinfo[0] = (void *)thishab;
11937 threadinfo[1] = (void *)thishmq; 11937 threadinfo[1] = (void *)thishmq;
11938 11938
11939 #ifndef __WATCOMC__ 11939 #ifndef __WATCOMC__
11940 *_threadstore() = (void *)threadinfo; 11940 *_threadstore() = (void *)threadinfo;
11941 #endif 11941 #endif
11942 11942
11943 #ifdef UNICODE 11943 #ifdef UNICODE
11950 void API _dw_init_thread(void) 11950 void API _dw_init_thread(void)
11951 { 11951 {
11952 _dw_init_thread2(); 11952 _dw_init_thread2();
11953 } 11953 }
11954 11954
11955 /* 11955 /*
11956 * Generally an internal function called from a terminating 11956 * Generally an internal function called from a terminating
11957 * thread to cleanup the Dynamic Windows environment for the thread. 11957 * thread to cleanup the Dynamic Windows environment for the thread.
11958 * However it is exported so language bindings can call it when 11958 * However it is exported so language bindings can call it when
11959 * they exit threads that require access to Dynamic Windows. 11959 * they exit threads that require access to Dynamic Windows.
11960 */ 11960 */
11967 11967
11968 if(threadinfo) 11968 if(threadinfo)
11969 { 11969 {
11970 HAB thishab = (HAB)threadinfo[0]; 11970 HAB thishab = (HAB)threadinfo[0];
11971 HMQ thishmq = (HMQ)threadinfo[1]; 11971 HMQ thishmq = (HMQ)threadinfo[1];
11972 11972
11973 WinDestroyMsgQueue(thishmq); 11973 WinDestroyMsgQueue(thishmq);
11974 WinTerminate(thishab); 11974 WinTerminate(thishab);
11975 free(threadinfo); 11975 free(threadinfo);
11976 } 11976 }
11977 } 11977 }
12401 * or NULL if none is necessary. 12401 * or NULL if none is necessary.
12402 * Returns: 12402 * Returns:
12403 * A handle to the notification which can be used to attach a "clicked" event if desired, 12403 * A handle to the notification which can be used to attach a "clicked" event if desired,
12404 * or NULL if it fails or notifications are not supported by the system. 12404 * or NULL if it fails or notifications are not supported by the system.
12405 * Remarks: 12405 * Remarks:
12406 * This will create a system notification that will show in the notifaction panel 12406 * This will create a system notification that will show in the notifaction panel
12407 * on supported systems, which may be clicked to perform another task. 12407 * on supported systems, which may be clicked to perform another task.
12408 */ 12408 */
12409 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...) 12409 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...)
12410 { 12410 {
12411 return NULL; 12411 return NULL;
12456 else if (i == 10) 12456 else if (i == 10)
12457 env->MinorVersion = 1; 12457 env->MinorVersion = 1;
12458 } 12458 }
12459 strcpy(env->buildDate, __DATE__); 12459 strcpy(env->buildDate, __DATE__);
12460 strcpy(env->buildTime, __TIME__); 12460 strcpy(env->buildTime, __TIME__);
12461 strcpy(env->htmlEngine, "N/A");
12461 env->DWMajorVersion = DW_MAJOR_VERSION; 12462 env->DWMajorVersion = DW_MAJOR_VERSION;
12462 env->DWMinorVersion = DW_MINOR_VERSION; 12463 env->DWMinorVersion = DW_MINOR_VERSION;
12463 #ifdef VER_REV 12464 #ifdef VER_REV
12464 env->DWSubVersion = VER_REV; 12465 env->DWSubVersion = VER_REV;
12465 #else 12466 #else
12923 id = id; 12924 id = id;
12924 dw_debug("HTML widget not available; OS/2 currently does not support it.\n"); 12925 dw_debug("HTML widget not available; OS/2 currently does not support it.\n");
12925 return 0; 12926 return 0;
12926 } 12927 }
12927 12928
12928 typedef struct _dwprint 12929 typedef struct _dwprint
12929 { 12930 {
12930 HDC hdc; 12931 HDC hdc;
12931 char *printername; 12932 char *printername;
12932 int (API_FUNC drawfunc)(HPRINT, HPIXMAP, int, void *); 12933 int (API_FUNC drawfunc)(HPRINT, HPIXMAP, int, void *);
12933 void *drawdata; 12934 void *drawdata;
13043 PPRINTERINFO pRes ; /* Check the default printer for now... want a printer list in the future */ 13044 PPRINTERINFO pRes ; /* Check the default printer for now... want a printer list in the future */
13044 int cb = PrfQueryProfileString(HINI_PROFILE, (PSZ)"PM_SPOOLER", (PSZ)"PRINTER", (PSZ)"", printername, 32); 13045 int cb = PrfQueryProfileString(HINI_PROFILE, (PSZ)"PM_SPOOLER", (PSZ)"PRINTER", (PSZ)"", printername, 32);
13045 13046
13046 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint)))) 13047 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint))))
13047 return NULL; 13048 return NULL;
13048 13049
13049 print->drawfunc = (int (API_FUNC)(HPRINT, HPIXMAP, int, void *))drawfunc; 13050 print->drawfunc = (int (API_FUNC)(HPRINT, HPIXMAP, int, void *))drawfunc;
13050 print->drawdata = drawdata; 13051 print->drawdata = drawdata;
13051 print->jobname = strdup(jobname ? jobname : "Dynamic Windows Print Job"); 13052 print->jobname = strdup(jobname ? jobname : "Dynamic Windows Print Job");
13052 print->startpage = 1; 13053 print->startpage = 1;
13053 print->endpage = pages; 13054 print->endpage = pages;
13217 { 13218 {
13218 DWPrint *p = print; 13219 DWPrint *p = print;
13219 HPIXMAP pixmap; 13220 HPIXMAP pixmap;
13220 int x, result = DW_ERROR_UNKNOWN; 13221 int x, result = DW_ERROR_UNKNOWN;
13221 SIZEL sizl = { 0, 0 }; 13222 SIZEL sizl = { 0, 0 };
13222 13223
13223 if(!p) 13224 if(!p)
13224 return result; 13225 return result;
13225 13226
13226 if (!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 13227 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
13227 return result; 13228 return result;
13228 13229
13229 /* Start the job */ 13230 /* Start the job */
13230 DevEscape(p->hdc, DEVESC_STARTDOC, strlen(p->jobname), (PBYTE)p->jobname, NULL, NULL); 13231 DevEscape(p->hdc, DEVESC_STARTDOC, strlen(p->jobname), (PBYTE)p->jobname, NULL, NULL);
13269 * print: Handle to the print object returned by dw_print_new(). 13270 * print: Handle to the print object returned by dw_print_new().
13270 */ 13271 */
13271 void API dw_print_cancel(HPRINT print) 13272 void API dw_print_cancel(HPRINT print)
13272 { 13273 {
13273 DWPrint *p = print; 13274 DWPrint *p = print;
13274 13275
13275 if(p) 13276 if(p)
13276 p->drawfunc = NULL; 13277 p->drawfunc = NULL;
13277 } 13278 }
13278 13279
13279 /* 13280 /*
13297 return _user_dir; 13298 return _user_dir;
13298 } 13299 }
13299 13300
13300 /* 13301 /*
13301 * Returns a pointer to a static buffer which containes the 13302 * Returns a pointer to a static buffer which containes the
13302 * private application data directory. 13303 * private application data directory.
13303 */ 13304 */
13304 char * API dw_app_dir(void) 13305 char * API dw_app_dir(void)
13305 { 13306 {
13306 return _dw_exec_dir; 13307 return _dw_exec_dir;
13307 } 13308 }
13614 while(tmp) 13615 while(tmp)
13615 { 13616 {
13616 if(((window < 65536 && tmp->id == window) || tmp->window == window) && tmp->message == message) 13617 if(((window < 65536 && tmp->id == window) || tmp->window == window) && tmp->message == message)
13617 { 13618 {
13618 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction; 13619 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction;
13619 13620
13620 if(discfunc) 13621 if(discfunc)
13621 { 13622 {
13622 discfunc(tmp->window, tmp->data); 13623 discfunc(tmp->window, tmp->data);
13623 } 13624 }
13624 13625
13625 if(prev) 13626 if(prev)
13626 { 13627 {
13627 prev->next = tmp->next; 13628 prev->next = tmp->next;
13628 free(tmp); 13629 free(tmp);
13629 tmp = prev->next; 13630 tmp = prev->next;
13655 while(tmp) 13656 while(tmp)
13656 { 13657 {
13657 if((window < 65536 && tmp->id == window) || tmp->window == window) 13658 if((window < 65536 && tmp->id == window) || tmp->window == window)
13658 { 13659 {
13659 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction; 13660 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction;
13660 13661
13661 if(discfunc) 13662 if(discfunc)
13662 { 13663 {
13663 discfunc(tmp->window, tmp->data); 13664 discfunc(tmp->window, tmp->data);
13664 } 13665 }
13665 13666
13666 if(prev) 13667 if(prev)
13667 { 13668 {
13668 prev->next = tmp->next; 13669 prev->next = tmp->next;
13669 free(tmp); 13670 free(tmp);
13670 tmp = prev->next; 13671 tmp = prev->next;
13697 while(tmp) 13698 while(tmp)
13698 { 13699 {
13699 if(((window < 65536 && tmp->id == window) || tmp->window == window) && tmp->data == data) 13700 if(((window < 65536 && tmp->id == window) || tmp->window == window) && tmp->data == data)
13700 { 13701 {
13701 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction; 13702 void (API_FUNC discfunc)(HWND, void *) = (void (API_FUNC)(HWND, void *))tmp->discfunction;
13702 13703
13703 if(discfunc) 13704 if(discfunc)
13704 { 13705 {
13705 discfunc(tmp->window, tmp->data); 13706 discfunc(tmp->window, tmp->data);
13706 } 13707 }
13707 13708
13708 if(prev) 13709 if(prev)
13709 { 13710 {
13710 prev->next = tmp->next; 13711 prev->next = tmp->next;
13711 free(tmp); 13712 free(tmp);
13712 tmp = prev->next; 13713 tmp = prev->next;