Mercurial > dwindows
comparison win/dw.c @ 1658:6fe1e91da477
Added DW_POINTER() macro for casting parameters to (void *)
Fixed issues with calculating buttons sizes with icons instead of bitmaps on OS/2 and Windows.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 16 Apr 2012 15:43:43 +0000 |
parents | 3d4066aab4e0 |
children | d06255e46ce2 |
comparison
equal
deleted
inserted
replaced
1657:f7db576f6d17 | 1658:6fe1e91da477 |
---|---|
3418 /* If we don't require themed drawing */ | 3418 /* If we don't require themed drawing */ |
3419 if(((cinfo->back != -1 && cinfo->back != DW_RGB_TRANSPARENT) || (parentcinfo && parentcinfo->back != -1)) | 3419 if(((cinfo->back != -1 && cinfo->back != DW_RGB_TRANSPARENT) || (parentcinfo && parentcinfo->back != -1)) |
3420 || !_dw_composition || !(GetWindowLongPtr(_toplevel_window(hwnd), GWL_EXSTYLE) & WS_EX_LAYERED)) | 3420 || !_dw_composition || !(GetWindowLongPtr(_toplevel_window(hwnd), GWL_EXSTYLE) & WS_EX_LAYERED)) |
3421 return _colorwndproc(hwnd, msg, mp1, mp2); | 3421 return _colorwndproc(hwnd, msg, mp1, mp2); |
3422 | 3422 |
3423 dw_debug("Parentcinfo %x parentcinfo->back %d\n", (int)parentcinfo, parentcinfo->back); | |
3424 | |
3425 pOldProc = cinfo->pOldProc; | 3423 pOldProc = cinfo->pOldProc; |
3426 | 3424 |
3427 switch(msg) | 3425 switch(msg) |
3428 { | 3426 { |
3429 case WM_PAINT: | 3427 case WM_PAINT: |
4548 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; | 4546 int thiswidth = 1, thisheight = 1, extrawidth = 0, extraheight = 0; |
4549 char *buf = dw_window_get_text(handle); | 4547 char *buf = dw_window_get_text(handle); |
4550 TCHAR tmpbuf[100] = {0}; | 4548 TCHAR tmpbuf[100] = {0}; |
4551 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 4549 static char testtext[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
4552 HBITMAP hbm = 0; | 4550 HBITMAP hbm = 0; |
4551 HICON hic = 0; | |
4553 | 4552 |
4554 GetClassName(handle, tmpbuf, 99); | 4553 GetClassName(handle, tmpbuf, 99); |
4555 | 4554 |
4556 /* If we have a string... | 4555 /* If we have a string... |
4557 * calculate the size with the current font. | 4556 * calculate the size with the current font. |
4563 dw_free(buf); | 4562 dw_free(buf); |
4564 } | 4563 } |
4565 | 4564 |
4566 /* Attempt to get bitmap from classes that can have them */ | 4565 /* Attempt to get bitmap from classes that can have them */ |
4567 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0) | 4566 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1) == 0) |
4568 hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0); | 4567 { |
4568 if(!(hbm = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0))) | |
4569 hic = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0); | |
4570 } | |
4569 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) | 4571 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1) == 0) |
4570 hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0); | 4572 { |
4573 if(!(hbm = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0))) | |
4574 hic = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0); | |
4575 } | |
4571 | 4576 |
4577 /* If we got an icon, pull out the internal bitmap */ | |
4578 if(hic && !hbm) | |
4579 { | |
4580 ICONINFO ii; | |
4581 | |
4582 if(GetIconInfo(hic, &ii)) | |
4583 hbm = ii.hbmMask ? ii.hbmMask : ii.hbmColor; | |
4584 } | |
4585 | |
4572 /* If we got an image... set the sizes appropriately */ | 4586 /* If we got an image... set the sizes appropriately */ |
4573 if(hbm) | 4587 if(hbm) |
4574 { | 4588 { |
4575 BITMAP bmi = { 0 }; | 4589 BITMAP bmi = { 0 }; |
4576 | 4590 |
6128 */ | 6142 */ |
6129 HWND API dw_bitmapbutton_new(char *text, ULONG id) | 6143 HWND API dw_bitmapbutton_new(char *text, ULONG id) |
6130 { | 6144 { |
6131 HWND tmp; | 6145 HWND tmp; |
6132 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); | 6146 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); |
6133 HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); | 6147 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, 0); |
6134 HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED); | 6148 HBITMAP hbitmap = icon ? 0 : LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); |
6135 | 6149 |
6136 tmp = CreateWindow(BUTTONCLASSNAME, | 6150 tmp = CreateWindow(BUTTONCLASSNAME, |
6137 NULL, | 6151 NULL, |
6138 WS_CHILD | BS_PUSHBUTTON | | 6152 WS_CHILD | BS_PUSHBUTTON | |
6139 WS_VISIBLE | WS_CLIPCHILDREN | | 6153 WS_VISIBLE | WS_CLIPCHILDREN | |