Mercurial > dwindows
comparison os2/dw.c @ 405:4c084ec3e176
Ok, so that last fix has some problems, this new fix is a hybrid of the
old fix and the new fix, I think it finally works as advertised. ;)
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 May 2003 00:33:33 +0000 |
parents | 720e61df8cf6 |
children | 765ec42ee2e4 |
comparison
equal
deleted
inserted
replaced
404:720e61df8cf6 | 405:4c084ec3e176 |
---|---|
1158 | 1158 |
1159 WinQueryClassName(handle, 99, tmpbuf); | 1159 WinQueryClassName(handle, 99, tmpbuf); |
1160 | 1160 |
1161 if(strncmp(tmpbuf, "#2", 3)==0) | 1161 if(strncmp(tmpbuf, "#2", 3)==0) |
1162 { | 1162 { |
1163 HWND frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); | |
1163 /* Make the combobox big enough to drop down. :) */ | 1164 /* Make the combobox big enough to drop down. :) */ |
1164 if(dw_window_get_data(handle, "_dw_dropped")) | 1165 WinSetWindowPos(handle, HWND_TOP, 0, -100, |
1165 WinSetWindowPos(handle, HWND_TOP, currentx + pad, (currenty + pad) - 100, | 1166 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); |
1166 width + vectorx, (height + vectory) + 100, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | 1167 WinSetWindowPos(frame, HWND_TOP, currentx + pad, currenty + pad, |
1167 else | 1168 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); |
1168 WinSetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, | |
1169 width + vectorx, height + vectory, SWP_MOVE | SWP_SIZE | SWP_ZORDER); | |
1170 | |
1171 } | 1169 } |
1172 else if(strncmp(tmpbuf, "#6", 3)==0) | 1170 else if(strncmp(tmpbuf, "#6", 3)==0) |
1173 { | 1171 { |
1174 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ | 1172 /* Entryfields on OS/2 have a thick border that isn't on Windows and GTK */ |
1175 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, | 1173 WinSetWindowPos(handle, HWND_TOP, (currentx + pad) + 3, (currenty + pad) + 3, |
1738 return (MRESULT)TRUE; | 1736 return (MRESULT)TRUE; |
1739 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); | 1737 _run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE); |
1740 break; | 1738 break; |
1741 case WM_SETFOCUS: | 1739 case WM_SETFOCUS: |
1742 _run_event(hWnd, msg, mp1, mp2); | 1740 _run_event(hWnd, msg, mp1, mp2); |
1743 break; | |
1744 case CBM_SHOWLIST: | |
1745 { | |
1746 int dropped = dw_window_get_data(hWnd, "_dw_dropped"); | |
1747 | |
1748 if(mp1) | |
1749 { | |
1750 if(!dropped) | |
1751 { | |
1752 SWP swp; | |
1753 | |
1754 WinQueryWindowPos(hWnd, &swp); | |
1755 WinSetWindowPos(hWnd, NULLHANDLE, swp.x, swp.y - 100, swp.cx, swp.cy + 100, SWP_MOVE | SWP_SIZE); | |
1756 dw_window_set_data(hWnd, "_dw_dropped", (void *)1); | |
1757 } | |
1758 } | |
1759 else | |
1760 { | |
1761 if(dropped) | |
1762 { | |
1763 SWP swp; | |
1764 | |
1765 WinQueryWindowPos(hWnd, &swp); | |
1766 WinSetWindowPos(hWnd, NULLHANDLE, swp.x, swp.y + 100, swp.cx, swp.cy - 100, SWP_MOVE | SWP_SIZE); | |
1767 dw_window_set_data(hWnd, "_dw_dropped", (void *)0); | |
1768 } | |
1769 } | |
1770 } | |
1771 break; | 1741 break; |
1772 case WM_PAINT: | 1742 case WM_PAINT: |
1773 { | 1743 { |
1774 HWND entry, parent = WinQueryWindow(hWnd, QW_PARENT); | 1744 HWND entry, parent = WinQueryWindow(hWnd, QW_PARENT); |
1775 HPS hpsPaint; | 1745 HPS hpsPaint; |
3472 * Parameters: | 3442 * Parameters: |
3473 * handle: The window handle to destroy. | 3443 * handle: The window handle to destroy. |
3474 */ | 3444 */ |
3475 int API dw_window_destroy(HWND handle) | 3445 int API dw_window_destroy(HWND handle) |
3476 { | 3446 { |
3477 HWND parent = WinQueryWindow(handle, QW_PARENT); | 3447 HWND frame, parent = WinQueryWindow(handle, QW_PARENT); |
3478 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); | 3448 Box *thisbox = WinQueryWindowPtr(parent, QWP_USER); |
3479 | 3449 |
3480 if(!handle) | 3450 if(!handle) |
3481 return -1; | 3451 return -1; |
3452 | |
3453 frame = (HWND)dw_window_get_data(handle, "_dw_combo_box"); | |
3482 | 3454 |
3483 if(parent != desktop && thisbox && thisbox->count) | 3455 if(parent != desktop && thisbox && thisbox->count) |
3484 { | 3456 { |
3485 int z, index = -1; | 3457 int z, index = -1; |
3486 Item *tmpitem, *thisitem = thisbox->items; | 3458 Item *tmpitem, *thisitem = thisbox->items; |
3509 thisbox->items = tmpitem; | 3481 thisbox->items = tmpitem; |
3510 free(thisitem); | 3482 free(thisitem); |
3511 thisbox->count--; | 3483 thisbox->count--; |
3512 _free_window_memory(handle); | 3484 _free_window_memory(handle); |
3513 } | 3485 } |
3514 return WinDestroyWindow(handle); | 3486 return WinDestroyWindow(frame ? frame : handle); |
3515 } | 3487 } |
3516 | 3488 |
3517 /* Causes entire window to be invalidated and redrawn. | 3489 /* Causes entire window to be invalidated and redrawn. |
3518 * Parameters: | 3490 * Parameters: |
3519 * handle: Toplevel window handle to be redrawn. | 3491 * handle: Toplevel window handle to be redrawn. |
4232 * id: An ID to be used with dw_window_from_id() or 0L. | 4204 * id: An ID to be used with dw_window_from_id() or 0L. |
4233 */ | 4205 */ |
4234 HWND API dw_combobox_new(char *text, ULONG id) | 4206 HWND API dw_combobox_new(char *text, ULONG id) |
4235 { | 4207 { |
4236 WindowData *blah = calloc(1, sizeof(WindowData)); | 4208 WindowData *blah = calloc(1, sizeof(WindowData)); |
4237 HWND tmp = WinCreateWindow(HWND_OBJECT, | 4209 HWND frame = WinCreateWindow(HWND_OBJECT, |
4210 WC_FRAME, | |
4211 NULL, | |
4212 WS_VISIBLE | WS_CLIPCHILDREN | | |
4213 FS_NOBYTEALIGN, | |
4214 0,0,2000,1000, | |
4215 NULLHANDLE, | |
4216 HWND_TOP, | |
4217 0L, | |
4218 NULL, | |
4219 NULL); | |
4220 HWND tmp = WinCreateWindow(frame, | |
4238 WC_COMBOBOX, | 4221 WC_COMBOBOX, |
4239 text, | 4222 text, |
4240 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, | 4223 WS_VISIBLE | CBS_DROPDOWN | WS_GROUP, |
4241 0,0,2000,1000, | 4224 0,0,2000,1000, |
4242 NULLHANDLE, | 4225 NULLHANDLE, |
4259 blah->oldproc = WinSubclassWindow(tmp, _comboproc); | 4242 blah->oldproc = WinSubclassWindow(tmp, _comboproc); |
4260 WinSetWindowPtr(tmp, QWP_USER, blah); | 4243 WinSetWindowPtr(tmp, QWP_USER, blah); |
4261 dw_window_set_font(tmp, DefaultFont); | 4244 dw_window_set_font(tmp, DefaultFont); |
4262 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); | 4245 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE); |
4263 dw_window_set_data(tmp, "_dw_comboentry", (void *)last); | 4246 dw_window_set_data(tmp, "_dw_comboentry", (void *)last); |
4247 dw_window_set_data(tmp, "_dw_combo_box", (void *)frame); | |
4264 return tmp; | 4248 return tmp; |
4265 } | 4249 } |
4266 | 4250 |
4267 /* | 4251 /* |
4268 * Create a new button window (widget) to be packed. | 4252 * Create a new button window (widget) to be packed. |
5009 if(thisbox) | 4993 if(thisbox) |
5010 { | 4994 { |
5011 int z; | 4995 int z; |
5012 Item *tmpitem, *thisitem = thisbox->items; | 4996 Item *tmpitem, *thisitem = thisbox->items; |
5013 char tmpbuf[100]; | 4997 char tmpbuf[100]; |
4998 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box"); | |
5014 | 4999 |
5015 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 5000 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
5016 | 5001 |
5017 for(z=0;z<thisbox->count;z++) | 5002 for(z=0;z<thisbox->count;z++) |
5018 { | 5003 { |
5054 | 5039 |
5055 /* Don't set the ownership if it's an entryfield or spinbutton */ | 5040 /* Don't set the ownership if it's an entryfield or spinbutton */ |
5056 WinQueryClassName(item, 99, tmpbuf); | 5041 WinQueryClassName(item, 99, tmpbuf); |
5057 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0) | 5042 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0) |
5058 WinSetOwner(item, box); | 5043 WinSetOwner(item, box); |
5059 WinSetParent(item, box, FALSE); | 5044 WinSetParent(frame ? frame : item, box, FALSE); |
5060 } | 5045 } |
5061 } | 5046 } |
5062 | 5047 |
5063 /* | 5048 /* |
5064 * Sets the size of a given window (widget). | 5049 * Sets the size of a given window (widget). |
7637 if(thisbox) | 7622 if(thisbox) |
7638 { | 7623 { |
7639 int z; | 7624 int z; |
7640 Item *tmpitem, *thisitem = thisbox->items; | 7625 Item *tmpitem, *thisitem = thisbox->items; |
7641 char tmpbuf[100]; | 7626 char tmpbuf[100]; |
7627 HWND frame = (HWND)dw_window_get_data(item, "_dw_combo_box"); | |
7642 | 7628 |
7643 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 7629 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
7644 | 7630 |
7645 for(z=0;z<thisbox->count;z++) | 7631 for(z=0;z<thisbox->count;z++) |
7646 { | 7632 { |
7682 | 7668 |
7683 WinQueryClassName(item, 99, tmpbuf); | 7669 WinQueryClassName(item, 99, tmpbuf); |
7684 /* Don't set the ownership if it's an entryfield or spinbutton */ | 7670 /* Don't set the ownership if it's an entryfield or spinbutton */ |
7685 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0) | 7671 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0) |
7686 WinSetOwner(item, box); | 7672 WinSetOwner(item, box); |
7687 WinSetParent(item, box, FALSE); | 7673 WinSetParent(frame ? frame : item, box, FALSE); |
7688 } | 7674 } |
7689 } | 7675 } |
7690 | 7676 |
7691 /* The following two functions graciously contributed by Peter Nielsen. */ | 7677 /* The following two functions graciously contributed by Peter Nielsen. */ |
7692 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) { | 7678 static ULONG _ParseBuildLevel (char* pchBuffer, ULONG ulSize) { |