Mercurial > dwindows
comparison os2/dw.c @ 554:6707adaa093d
Added some more intellegent code to determine the best icon size when using
bitmap buttons with icons instead of bitmaps.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 11 Apr 2004 08:18:44 +0000 |
parents | 788299414ae0 |
children | 1a210e2f214b |
comparison
equal
deleted
inserted
replaced
553:788299414ae0 | 554:6707adaa093d |
---|---|
29 #endif | 29 #endif |
30 #include <sys/time.h> | 30 #include <sys/time.h> |
31 #include "dw.h" | 31 #include "dw.h" |
32 | 32 |
33 #define QWP_USER 0 | 33 #define QWP_USER 0 |
34 | |
35 /* The toolkit headers don't seem to have this */ | |
36 BOOL APIENTRY WinStretchPointer(HPS hps, LONG x, LONG y, LONG cx, LONG cy, HPOINTER hptr, ULONG fs); | |
34 | 37 |
35 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); | 38 MRESULT EXPENTRY _run_event(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); |
36 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); | 39 MRESULT EXPENTRY _wndproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2); |
37 void _do_resize(Box *thisbox, int x, int y); | 40 void _do_resize(Box *thisbox, int x, int y); |
38 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); | 41 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); |
3011 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap"); | 3014 HPIXMAP pixmap = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap"); |
3012 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled"); | 3015 HPIXMAP disable = (HPIXMAP)dw_window_get_data(hwnd, "_dw_hpixmap_disabled"); |
3013 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon"); | 3016 HPOINTER icon = (HPOINTER)dw_window_get_data(hwnd, "_dw_button_icon"); |
3014 MRESULT res; | 3017 MRESULT res; |
3015 unsigned long width, height; | 3018 unsigned long width, height; |
3016 int x, y; | 3019 int x = 5, y = 5; |
3017 | 3020 |
3018 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height); | 3021 dw_window_get_pos_size(hwnd, NULL, NULL, &width, &height); |
3019 | 3022 |
3020 if(!oldproc) | 3023 if(!oldproc) |
3021 res = WinDefWindowProc(hwnd, msg, mp1, mp2); | 3024 res = WinDefWindowProc(hwnd, msg, mp1, mp2); |
3023 | 3026 |
3024 if(icon) | 3027 if(icon) |
3025 { | 3028 { |
3026 ULONG halftone = DP_NORMAL; | 3029 ULONG halftone = DP_NORMAL; |
3027 HPS hps = WinGetPS(hwnd); | 3030 HPS hps = WinGetPS(hwnd); |
3031 POINTERINFO pi; | |
3032 int cx, cy; | |
3028 | 3033 |
3029 if(dw_window_get_data(hwnd, "_dw_disabled")) | 3034 if(dw_window_get_data(hwnd, "_dw_disabled")) |
3030 halftone = DP_HALFTONED; | 3035 halftone = DP_HALFTONED; |
3031 | 3036 |
3032 x = (width - 16)/2; | 3037 cx = width - 10; |
3033 y = (height - 16)/2; | 3038 cy = height - 10; |
3034 | 3039 |
3035 WinDrawPointer(hps, x + indent, y - indent, icon, halftone | DP_MINI); | 3040 if(WinQueryPointerInfo(icon, &pi)) |
3041 { | |
3042 BITMAPINFOHEADER sl; | |
3043 int newcx = cx, newcy = cy; | |
3044 | |
3045 /* Check the mini icon first */ | |
3046 if(GpiQueryBitmapParameters(pi.hbmMiniColor, &sl)) | |
3047 { | |
3048 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) | |
3049 { | |
3050 newcx = sl.cx; | |
3051 newcy = sl.cy; | |
3052 } | |
3053 } | |
3054 /* Check the normal icon second */ | |
3055 if(GpiQueryBitmapParameters(pi.hbmColor, &sl)) | |
3056 { | |
3057 if(sl.cx && sl.cy && cx > sl.cx && cy > sl.cy) | |
3058 { | |
3059 newcx = sl.cx; | |
3060 newcy = sl.cy; | |
3061 } | |
3062 } | |
3063 cx = newcx; cy = newcy; | |
3064 x = (width - cx)/2; | |
3065 y = (height - cy)/2; | |
3066 } | |
3067 WinStretchPointer(hps, x + indent, y - indent, cx, cy, icon, halftone); | |
3036 WinReleasePS(hps); | 3068 WinReleasePS(hps); |
3037 } | 3069 } |
3038 else if(pixmap) | 3070 else if(pixmap) |
3039 { | 3071 { |
3040 x = (width - pixmap->width)/2; | 3072 x = (width - pixmap->width)/2; |
3041 y = (height - pixmap->height)/2; | 3073 y = (height - pixmap->height)/2; |
3042 | |
3043 | 3074 |
3044 if(disable && dw_window_get_data(hwnd, "_dw_disabled")) | 3075 if(disable && dw_window_get_data(hwnd, "_dw_disabled")) |
3045 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, disable, 0, 0); | 3076 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, disable, 0, 0); |
3046 else | 3077 else |
3047 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, pixmap, 0, 0); | 3078 dw_pixmap_bitblt(hwnd, 0, x + indent, y + indent, pixmap->width, pixmap->height, 0, pixmap, 0, 0); |