# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1322347640 0 # Node ID 943266c86aedc210a5e435ed83fa15f9225d5593 # Parent 614fb124d2e28c6bcb20f554c300dc235df96379 Refactoring OS/2 and Windows code... eliminating BubbleButton... BubbleButton was no longer really used in Windows since I switched to native tooltips... However parts of it were still hanging around. Merging BubbleButton into WindowData on OS/2 to prepare for generic tooltip support. More coming very soon. diff -r 614fb124d2e2 -r 943266c86aed dw.h --- a/dw.h Sat Nov 26 21:05:49 2011 +0000 +++ b/dw.h Sat Nov 26 22:47:20 2011 +0000 @@ -79,7 +79,6 @@ #define SIZEEXPAND 1 #define SPLITBAR_WIDTH 4 -#define BUBBLE_HELP_MAX 256 typedef struct _user_data { @@ -222,12 +221,15 @@ #define VK_LMENU VK_MENU #define VK_RMENU VK_MENU +#define BUBBLE_HELP_MAX 256 + typedef struct _window_data { PFNWP oldproc; UserData *root; HWND clickdefault; ULONG flags; void *data; + char bubbletext[BUBBLE_HELP_MAX]; } WindowData; typedef struct _hpixmap { @@ -688,20 +690,6 @@ struct _item *items; } Box; -typedef struct _bubblebutton { -#if defined(__WIN32__) || defined(WINNT) - ColorInfo cinfo; - int checkbox; - WNDPROC pOldProc; -#endif -#if defined(__OS2__) || defined(__EMX__) - PFNWP pOldProc; - UserData *root; - unsigned long id; - char bubbletext[BUBBLE_HELP_MAX]; -#endif -} BubbleButton; - #elif defined(__PHOTON__) #include #include diff -r 614fb124d2e2 -r 943266c86aed os2/dw.c --- a/os2/dw.c Sat Nov 26 21:05:49 2011 +0000 +++ b/os2/dw.c Sat Nov 26 22:47:20 2011 +0000 @@ -3669,15 +3669,13 @@ MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { - BubbleButton *bubble; + WindowData *blah = WinQueryWindowPtr(hwnd, QWL_USER); PFNWP oldproc; - bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER); - - if(!bubble) + if(!blah) return WinDefWindowProc(hwnd, msg, mp1, mp2); - oldproc = bubble->pOldProc; + oldproc = blah->oldproc; switch(msg) { @@ -3813,7 +3811,7 @@ case 0x041e: - if(!*bubble->bubbletext) + if(!*blah->bubbletext) break; if(hwndBubble) @@ -3858,14 +3856,14 @@ &ulColor); WinSetWindowText(hwndBubble, - (PSZ)bubble->bubbletext); + (PSZ)blah->bubbletext); WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); hpsTemp = WinGetPS(hwndBubble); GpiQueryTextBox(hpsTemp, - strlen(bubble->bubbletext), - (PCH)bubble->bubbletext, + strlen(blah->bubbletext), + (PCH)blah->bubbletext, TXTBOX_COUNT, txtPointl); WinReleasePS(hpsTemp); @@ -5554,8 +5552,7 @@ */ HWND API dw_button_new(char *text, ULONG id) { - BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); - + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_BUTTON, (PSZ)text, @@ -5567,11 +5564,9 @@ NULL, NULL); - bubble->id = id; - bubble->bubbletext[0] = '\0'; - bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); - - WinSetWindowPtr(tmp, QWP_USER, bubble); + blah->oldproc = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, blah); dw_window_set_font(tmp, DefaultFont); dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); return tmp; @@ -5620,7 +5615,7 @@ { char idbuf[256], *name = NULL; HWND tmp; - BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); + WindowData *blah = calloc(1, sizeof(WindowData)); HPOINTER icon = WinLoadPointer(HWND_DESKTOP, 0L, id); if(!icon) @@ -5642,12 +5637,11 @@ NULL, NULL); - bubble->id = id; - strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); - bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; - bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); - - WinSetWindowPtr(tmp, QWP_USER, bubble); + strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1); + blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; + blah->old = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, blah); if(icon) dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); @@ -5666,7 +5660,7 @@ */ HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) { - BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_BUTTON, NULL, @@ -5741,12 +5735,11 @@ } } - bubble->id = id; - strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); - bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; - bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); - - WinSetWindowPtr(tmp, QWP_USER, bubble); + strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1); + blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; + blah->oldproc = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, blah); if(icon) dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); @@ -5771,7 +5764,7 @@ HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) { FILE *fp; - BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_BUTTON, NULL, @@ -5841,12 +5834,11 @@ } } - bubble->id = id; - strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); - bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; - bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); - - WinSetWindowPtr(tmp, QWP_USER, bubble); + strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1); + blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; + blah->oldproc = WinSubclassWindow(tmp, _BtProc); + + WinSetWindowPtr(tmp, QWP_USER, blah); if(icon) dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); @@ -6008,7 +6000,7 @@ */ HWND API dw_checkbox_new(char *text, ULONG id) { - BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); + WindowData *blah = calloc(1, sizeof(WindowData)); HWND tmp = WinCreateWindow(HWND_OBJECT, WC_BUTTON, (PSZ)text, @@ -6019,10 +6011,9 @@ id, NULL, NULL); - bubble->id = id; - bubble->bubbletext[0] = '\0'; - bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); - WinSetWindowPtr(tmp, QWP_USER, bubble); + blah->bubbletext[0] = '\0'; + blah->oldproc = WinSubclassWindow(tmp, _BtProc); + WinSetWindowPtr(tmp, QWP_USER, blah); dw_window_set_font(tmp, DefaultFont); dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); return tmp; diff -r 614fb124d2e2 -r 943266c86aed win/dw.c --- a/win/dw.c Sat Nov 26 21:05:49 2011 +0000 +++ b/win/dw.c Sat Nov 26 22:47:20 2011 +0000 @@ -3392,12 +3392,10 @@ BOOL CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2) { - BubbleButton *bubble; + ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA); WNDPROC pOldProc; - bubble = (BubbleButton *)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - if ( !bubble ) + if ( !cinfo ) return DefWindowProc(hwnd, msg, mp1, mp2); /* We must save a pointer to the old @@ -3405,7 +3403,7 @@ * handler attached here destroys this * window it will then be invalid. */ - pOldProc = bubble->pOldProc; + pOldProc = cinfo->pOldProc; switch(msg) { @@ -3435,12 +3433,14 @@ /* Make sure it's the right window, and the right ID */ if(tmp->window == hwnd) { - if(bubble->checkbox) + int checkbox = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_checkbox")); + + if(checkbox) in_checkbox_handler = 1; clickfunc(tmp->window, tmp->data); - if(bubble->checkbox) + if(checkbox) in_checkbox_handler = 0; tmp = NULL; } @@ -5579,7 +5579,7 @@ */ HWND API dw_button_new(char *text, ULONG id) { - BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); HWND tmp = CreateWindow(BUTTONCLASSNAME, text, @@ -5590,10 +5590,10 @@ (HMENU)id, DWInstance, NULL); - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); - - SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + + SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); dw_window_set_font(tmp, DefaultFont); return tmp; } @@ -5607,7 +5607,7 @@ HWND API dw_bitmapbutton_new(char *text, ULONG id) { HWND tmp; - BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); HBITMAP hbitmap = LoadBitmap(DWInstance, MAKEINTRESOURCE(id)); HICON icon = LoadImage(DWInstance, MAKEINTRESOURCE(id), IMAGE_ICON, 0, 0, LR_SHARED); @@ -5622,10 +5622,10 @@ DWInstance, NULL); - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); - - SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + + SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); _create_tooltip(tmp, text); @@ -5652,12 +5652,12 @@ HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) { HWND tmp; - BubbleButton *bubble; + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); HBITMAP hbitmap = 0; HANDLE hicon = 0; int windowtype = 0; - if (!(bubble = calloc(1, sizeof(BubbleButton)))) + if (!cinfo) return 0; #ifdef GDIPLUS @@ -5681,10 +5681,10 @@ DWInstance, NULL); - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); - - SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + + SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); _create_tooltip(tmp, text); @@ -5711,15 +5711,16 @@ HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) { HWND tmp; - BubbleButton *bubble; + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); HBITMAP hbitmap = 0; HANDLE hicon = 0; char *file; FILE *fp; int windowtype = BS_BITMAP; - if ( !(bubble = calloc(1, sizeof(BubbleButton))) ) + if (!cinfo) return 0; + file = _tempnam( _dw_alternate_temp_dir, "dw" ); if ( file != NULL ) { @@ -5764,10 +5765,10 @@ DWInstance, NULL ); - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow( tmp, _BtProc ); - - SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)bubble ); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow( tmp, _BtProc ); + + SetWindowLongPtr( tmp, GWLP_USERDATA, (LONG_PTR)cinfo ); _create_tooltip(tmp, text); @@ -5854,10 +5855,10 @@ (HMENU)id, DWInstance, NULL); - BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); - SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); dw_window_set_font(tmp, DefaultFont); return tmp; } @@ -5944,7 +5945,7 @@ */ HWND API dw_checkbox_new(char *text, ULONG id) { - BubbleButton *bubble = calloc(1, sizeof(BubbleButton)); + ColorInfo *cinfo = calloc(1, sizeof(ColorInfo)); HWND tmp = CreateWindow(BUTTONCLASSNAME, text, WS_CHILD | BS_AUTOCHECKBOX | @@ -5954,10 +5955,10 @@ (HMENU)id, DWInstance, NULL); - bubble->checkbox = 1; - bubble->cinfo.fore = bubble->cinfo.back = -1; - bubble->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); - SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)bubble); + cinfo->fore = cinfo->back = -1; + cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _BtProc); + SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo); + dw_window_set_data(tmp, "_dw_checkbox", DW_INT_TO_POINTER(1)); dw_window_set_font(tmp, DefaultFont); return tmp; } @@ -7622,9 +7623,7 @@ if(strnicmp(tmpbuf, BUTTONCLASSNAME, strlen(BUTTONCLASSNAME)+1)==0) { - BubbleButton *bubble= (BubbleButton *)GetWindowLongPtr(handle, GWLP_USERDATA); - - if(bubble && !bubble->checkbox) + if(!dw_window_get_data(handle, "_dw_checkbox")) SendMessage(handle, BM_SETCHECK, 0, 0); } return TRUE; @@ -7637,9 +7636,7 @@ */ void API dw_checkbox_set(HWND handle, int value) { - BubbleButton *bubble= (BubbleButton *)GetWindowLongPtr(handle, GWLP_USERDATA); - - if(bubble && !bubble->checkbox) + if(!dw_window_get_data(handle, "_dw_checkbox")) { HWND parent = GetParent(handle);