Mercurial > dwindows
comparison os2/dw.c @ 1423:1bb1865fed9d
Revert experimental GTK2 change and add OS/2 support for auto-redrawing and auto-calculating bitmaps and bitmap buttons.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 03 Dec 2011 03:31:43 +0000 |
parents | f4fc4ea92511 |
children | 36d0e26a5dea |
comparison
equal
deleted
inserted
replaced
1422:131bedf41332 | 1423:1bb1865fed9d |
---|---|
230 { | 230 { |
231 window = window; /* keep compiler happy */ | 231 window = window; /* keep compiler happy */ |
232 key = key; /* keep compiler happy */ | 232 key = key; /* keep compiler happy */ |
233 data = data; /* keep compiler happy */ | 233 data = data; /* keep compiler happy */ |
234 return TRUE; | 234 return TRUE; |
235 } | |
236 | |
237 /* Internal function to queue a window redraw */ | |
238 void _dw_redraw(HWND window, int skip) | |
239 { | |
240 static HWND lastwindow = 0; | |
241 | |
242 if(skip && !window) | |
243 return; | |
244 | |
245 if(lastwindow != window && lastwindow) | |
246 { | |
247 dw_window_redraw(lastwindow); | |
248 } | |
249 lastwindow = window; | |
235 } | 250 } |
236 | 251 |
237 /* Find the desktop window handle */ | 252 /* Find the desktop window handle */ |
238 HWND _toplevel_window(HWND handle) | 253 HWND _toplevel_window(HWND handle) |
239 { | 254 { |
3255 | 3270 |
3256 if(tmp) | 3271 if(tmp) |
3257 tmp = tmp->next; | 3272 tmp = tmp->next; |
3258 | 3273 |
3259 } | 3274 } |
3275 if(result != -1) | |
3276 { | |
3277 /* Make sure any queued redraws are handled */ | |
3278 _dw_redraw(0, FALSE); | |
3279 /* Then finally return */ | |
3280 } | |
3260 return (MRESULT)result; | 3281 return (MRESULT)result; |
3261 } | 3282 } |
3262 | 3283 |
3263 /* Gets a DW_RGB value from the three spinbuttons */ | 3284 /* Gets a DW_RGB value from the three spinbuttons */ |
3264 unsigned long _dw_color_spin_get(HWND window) | 3285 unsigned long _dw_color_spin_get(HWND window) |
4700 thiswidth = 150; | 4721 thiswidth = 150; |
4701 extraheight = 4; | 4722 extraheight = 4; |
4702 if(thisheight < 18) | 4723 if(thisheight < 18) |
4703 thisheight = 18; | 4724 thisheight = 18; |
4704 } | 4725 } |
4726 /* Bitmap/Static */ | |
4727 else if(strncmp(tmpbuf, "#5", 3)==0) | |
4728 { | |
4729 int bmwidth = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_width")); | |
4730 int bmheight = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_height")); | |
4731 | |
4732 if(bmwidth > 0 && bmheight > 0) | |
4733 { | |
4734 thiswidth = bmwidth; | |
4735 thisheight = bmheight; | |
4736 } | |
4737 } | |
4738 /* Ranged: Slider/Percent/Scrollbar */ | |
4739 else if(strncmp(tmpbuf, "#38", 4)== 0 || | |
4740 strncmp(tmpbuf, "#8", 3)== 0) | |
4741 { | |
4742 /* Check for vertical scrollbar */ | |
4743 if(strncmp(tmpbuf, "#8", 3)== 0 && | |
4744 WinQueryWindowULong(handle, QWL_STYLE) & SBS_VERT) | |
4745 { | |
4746 thiswidth = 14; | |
4747 thisheight = 100; | |
4748 } | |
4749 else | |
4750 { | |
4751 thiswidth = 100; | |
4752 thisheight = 14; | |
4753 } | |
4754 } | |
4705 /* Spinbutton */ | 4755 /* Spinbutton */ |
4706 else if(strncmp(tmpbuf, "#32", 4)==0) | 4756 else if(strncmp(tmpbuf, "#32", 4)==0) |
4707 { | 4757 { |
4708 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); | 4758 dw_font_text_extents_get(handle, NULL, testtext, NULL, &thisheight); |
4709 thiswidth = 50; | 4759 thiswidth = 50; |
4718 /* Button */ | 4768 /* Button */ |
4719 else if(strncmp(tmpbuf, "#3", 3)==0) | 4769 else if(strncmp(tmpbuf, "#3", 3)==0) |
4720 { | 4770 { |
4721 ULONG style = WinQueryWindowULong(handle, QWL_STYLE); | 4771 ULONG style = WinQueryWindowULong(handle, QWL_STYLE); |
4722 | 4772 |
4723 if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON) | 4773 /* Handle bitmap buttons */ |
4774 if(dw_window_get_data(handle, "_dw_bitmapbutton")) | |
4775 { | |
4776 WNDPARAMS wp; | |
4777 BTNCDATA bcd; | |
4778 | |
4779 wp.fsStatus = WPM_CTLDATA; | |
4780 wp.cbCtlData = sizeof(BTNCDATA); | |
4781 wp.pCtlData = &bcd; | |
4782 | |
4783 /* Query the button's bitmap */ | |
4784 if(WinSendMsg(handle, WM_QUERYWINDOWPARAMS, (MPARAM)&wp, MPVOID) && bcd.hImage) | |
4785 { | |
4786 BITMAPINFOHEADER2 bmp; | |
4787 bmp.cbFix = sizeof(BITMAPINFOHEADER2); | |
4788 /* Get the parameters of the bitmap */ | |
4789 if(GpiQueryBitmapInfoHeader(bcd.hImage, &bmp)) | |
4790 { | |
4791 thiswidth = bmp.cx; | |
4792 thisheight = bmp.cy; | |
4793 } | |
4794 } | |
4795 } | |
4796 else if(style & BS_AUTOCHECKBOX || style & BS_AUTORADIOBUTTON) | |
4724 { | 4797 { |
4725 extrawidth = 24; | 4798 extrawidth = 24; |
4726 extraheight = 4; | 4799 extraheight = 4; |
4727 } | 4800 } |
4728 else | 4801 else |
4753 { | 4826 { |
4754 Item *item = _box_item(handle); | 4827 Item *item = _box_item(handle); |
4755 | 4828 |
4756 /* Check to see if any of the sizes need to be recalculated */ | 4829 /* Check to see if any of the sizes need to be recalculated */ |
4757 if(item && (item->origwidth == -1 || item->origheight == -1)) | 4830 if(item && (item->origwidth == -1 || item->origheight == -1)) |
4831 { | |
4758 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); | 4832 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); |
4833 /* Queue a redraw on the top-level window */ | |
4834 _dw_redraw(_toplevel_window(handle), TRUE); | |
4835 } | |
4759 return DW_ERROR_NONE; | 4836 return DW_ERROR_NONE; |
4760 } | 4837 } |
4761 return DW_ERROR_UNKNOWN; | 4838 return DW_ERROR_UNKNOWN; |
4762 } | 4839 } |
4763 | 4840 |
6426 WinSetWindowBits(handle,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f); | 6503 WinSetWindowBits(handle,QWL_STYLE,SS_BITMAP,SS_BITMAP | 0x7f); |
6427 WinSendMsg( handle, SM_SETHANDLE, MPFROMP(hbm), NULL ); | 6504 WinSendMsg( handle, SM_SETHANDLE, MPFROMP(hbm), NULL ); |
6428 if ( id ) | 6505 if ( id ) |
6429 WinReleasePS(hps); | 6506 WinReleasePS(hps); |
6430 dw_window_set_data(handle, "_dw_bitmap", (void *)hbm); | 6507 dw_window_set_data(handle, "_dw_bitmap", (void *)hbm); |
6508 | |
6509 /* If we changed the bitmap... */ | |
6510 { | |
6511 Item *item = _box_item(handle); | |
6512 | |
6513 /* Check to see if any of the sizes need to be recalculated */ | |
6514 if(item && (item->origwidth == -1 || item->origheight == -1)) | |
6515 { | |
6516 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); | |
6517 /* Queue a redraw on the top-level window */ | |
6518 _dw_redraw(_toplevel_window(handle), TRUE); | |
6519 } | |
6520 } | |
6431 } | 6521 } |
6432 | 6522 |
6433 /* | 6523 /* |
6434 * Sets the bitmap used for a given static window. | 6524 * Sets the bitmap used for a given static window. |
6435 * Parameters: | 6525 * Parameters: |
6514 { | 6604 { |
6515 Item *item = _box_item(handle); | 6605 Item *item = _box_item(handle); |
6516 | 6606 |
6517 /* Check to see if any of the sizes need to be recalculated */ | 6607 /* Check to see if any of the sizes need to be recalculated */ |
6518 if(item && (item->origwidth == -1 || item->origheight == -1)) | 6608 if(item && (item->origwidth == -1 || item->origheight == -1)) |
6609 { | |
6519 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); | 6610 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); |
6611 /* Queue a redraw on the top-level window */ | |
6612 _dw_redraw(_toplevel_window(handle), TRUE); | |
6613 } | |
6520 } | 6614 } |
6521 } | 6615 } |
6522 | 6616 |
6523 /* | 6617 /* |
6524 * Sets the text used for a given window's floating bubble help. | 6618 * Sets the text used for a given window's floating bubble help. |
6786 WinQueryClassName(item, 99, (PCH)tmpbuf); | 6880 WinQueryClassName(item, 99, (PCH)tmpbuf); |
6787 /* Don't set the ownership if it's an entryfield or spinbutton */ | 6881 /* Don't set the ownership if it's an entryfield or spinbutton */ |
6788 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) | 6882 if(strncmp(tmpbuf, "#6", 3)!=0 && strncmp(tmpbuf, "#32", 4)!=0 && strncmp(tmpbuf, "#2", 3)!=0) |
6789 WinSetOwner(item, box); | 6883 WinSetOwner(item, box); |
6790 WinSetParent(frame ? frame : item, box, FALSE); | 6884 WinSetParent(frame ? frame : item, box, FALSE); |
6885 /* Queue a redraw on the top-level window */ | |
6886 _dw_redraw(_toplevel_window(item), TRUE); | |
6791 } | 6887 } |
6792 } | 6888 } |
6793 | 6889 |
6794 /* | 6890 /* |
6795 * Pack windows (widgets) into a box at an arbitrary location. | 6891 * Pack windows (widgets) into a box at an arbitrary location. |