comparison os2/dw.c @ 1392:943266c86aed

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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 26 Nov 2011 22:47:20 +0000
parents 0512fbb08abf
children eb83c9830dfa
comparison
equal deleted inserted replaced
1391:614fb124d2e2 1392:943266c86aed
3667 * Abstract: Subclass procedure for buttons 3667 * Abstract: Subclass procedure for buttons
3668 */ 3668 */
3669 3669
3670 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 3670 MRESULT EXPENTRY _BtProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
3671 { 3671 {
3672 BubbleButton *bubble; 3672 WindowData *blah = WinQueryWindowPtr(hwnd, QWL_USER);
3673 PFNWP oldproc; 3673 PFNWP oldproc;
3674 3674
3675 bubble = (BubbleButton *)WinQueryWindowPtr(hwnd, QWL_USER); 3675 if(!blah)
3676
3677 if(!bubble)
3678 return WinDefWindowProc(hwnd, msg, mp1, mp2); 3676 return WinDefWindowProc(hwnd, msg, mp1, mp2);
3679 3677
3680 oldproc = bubble->pOldProc; 3678 oldproc = blah->oldproc;
3681 3679
3682 switch(msg) 3680 switch(msg)
3683 { 3681 {
3684 case WM_MOUSEMOVE: 3682 case WM_MOUSEMOVE:
3685 if(_wndproc(hwnd, msg, mp1, mp2)) 3683 if(_wndproc(hwnd, msg, mp1, mp2))
3811 } 3809 }
3812 break; 3810 break;
3813 3811
3814 case 0x041e: 3812 case 0x041e:
3815 3813
3816 if(!*bubble->bubbletext) 3814 if(!*blah->bubbletext)
3817 break; 3815 break;
3818 3816
3819 if(hwndBubble) 3817 if(hwndBubble)
3820 { 3818 {
3821 WinDestroyWindow(hwndBubble); 3819 WinDestroyWindow(hwndBubble);
3856 PP_BACKGROUNDCOLORINDEX, 3854 PP_BACKGROUNDCOLORINDEX,
3857 sizeof(ulColor), 3855 sizeof(ulColor),
3858 &ulColor); 3856 &ulColor);
3859 3857
3860 WinSetWindowText(hwndBubble, 3858 WinSetWindowText(hwndBubble,
3861 (PSZ)bubble->bubbletext); 3859 (PSZ)blah->bubbletext);
3862 3860
3863 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1); 3861 WinMapWindowPoints(hwnd, HWND_DESKTOP, &ptlWork, 1);
3864 3862
3865 hpsTemp = WinGetPS(hwndBubble); 3863 hpsTemp = WinGetPS(hwndBubble);
3866 GpiQueryTextBox(hpsTemp, 3864 GpiQueryTextBox(hpsTemp,
3867 strlen(bubble->bubbletext), 3865 strlen(blah->bubbletext),
3868 (PCH)bubble->bubbletext, 3866 (PCH)blah->bubbletext,
3869 TXTBOX_COUNT, 3867 TXTBOX_COUNT,
3870 txtPointl); 3868 txtPointl);
3871 WinReleasePS(hpsTemp); 3869 WinReleasePS(hpsTemp);
3872 3870
3873 lWidth = txtPointl[TXTBOX_TOPRIGHT].x - 3871 lWidth = txtPointl[TXTBOX_TOPRIGHT].x -
5552 * text: The text to be display by the static text widget. 5550 * text: The text to be display by the static text widget.
5553 * id: An ID to be used with dw_window_from_id() or 0L. 5551 * id: An ID to be used with dw_window_from_id() or 0L.
5554 */ 5552 */
5555 HWND API dw_button_new(char *text, ULONG id) 5553 HWND API dw_button_new(char *text, ULONG id)
5556 { 5554 {
5557 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 5555 WindowData *blah = calloc(1, sizeof(WindowData));
5558
5559 HWND tmp = WinCreateWindow(HWND_OBJECT, 5556 HWND tmp = WinCreateWindow(HWND_OBJECT,
5560 WC_BUTTON, 5557 WC_BUTTON,
5561 (PSZ)text, 5558 (PSZ)text,
5562 WS_VISIBLE, 5559 WS_VISIBLE,
5563 0,0,2000,1000, 5560 0,0,2000,1000,
5565 HWND_TOP, 5562 HWND_TOP,
5566 id, 5563 id,
5567 NULL, 5564 NULL,
5568 NULL); 5565 NULL);
5569 5566
5570 bubble->id = id; 5567 blah->oldproc = WinSubclassWindow(tmp, _BtProc);
5571 bubble->bubbletext[0] = '\0'; 5568
5572 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 5569 WinSetWindowPtr(tmp, QWP_USER, blah);
5573
5574 WinSetWindowPtr(tmp, QWP_USER, bubble);
5575 dw_window_set_font(tmp, DefaultFont); 5570 dw_window_set_font(tmp, DefaultFont);
5576 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 5571 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
5577 return tmp; 5572 return tmp;
5578 } 5573 }
5579 5574
5618 */ 5613 */
5619 HWND API dw_bitmapbutton_new(char *text, ULONG id) 5614 HWND API dw_bitmapbutton_new(char *text, ULONG id)
5620 { 5615 {
5621 char idbuf[256], *name = NULL; 5616 char idbuf[256], *name = NULL;
5622 HWND tmp; 5617 HWND tmp;
5623 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 5618 WindowData *blah = calloc(1, sizeof(WindowData));
5624 HPOINTER icon = WinLoadPointer(HWND_DESKTOP, 0L, id); 5619 HPOINTER icon = WinLoadPointer(HWND_DESKTOP, 0L, id);
5625 5620
5626 if(!icon) 5621 if(!icon)
5627 { 5622 {
5628 name = idbuf; 5623 name = idbuf;
5640 HWND_TOP, 5635 HWND_TOP,
5641 id, 5636 id,
5642 NULL, 5637 NULL,
5643 NULL); 5638 NULL);
5644 5639
5645 bubble->id = id; 5640 strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1);
5646 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); 5641 blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
5647 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; 5642 blah->old = WinSubclassWindow(tmp, _BtProc);
5648 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 5643
5649 5644 WinSetWindowPtr(tmp, QWP_USER, blah);
5650 WinSetWindowPtr(tmp, QWP_USER, bubble);
5651 5645
5652 if(icon) 5646 if(icon)
5653 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); 5647 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon);
5654 dw_window_set_data(tmp, "_dw_bitmapbutton", (void *)1); 5648 dw_window_set_data(tmp, "_dw_bitmapbutton", (void *)1);
5655 return tmp; 5649 return tmp;
5664 * DW pick the appropriate file extension. 5658 * DW pick the appropriate file extension.
5665 * (BMP on OS/2 or Windows, XPM on Unix) 5659 * (BMP on OS/2 or Windows, XPM on Unix)
5666 */ 5660 */
5667 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) 5661 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
5668 { 5662 {
5669 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 5663 WindowData *blah = calloc(1, sizeof(WindowData));
5670 HWND tmp = WinCreateWindow(HWND_OBJECT, 5664 HWND tmp = WinCreateWindow(HWND_OBJECT,
5671 WC_BUTTON, 5665 WC_BUTTON,
5672 NULL, 5666 NULL,
5673 WS_VISIBLE | BS_PUSHBUTTON | 5667 WS_VISIBLE | BS_PUSHBUTTON |
5674 BS_AUTOSIZE | BS_NOPOINTERFOCUS, 5668 BS_AUTOSIZE | BS_NOPOINTERFOCUS,
5739 } 5733 }
5740 _foreground = fore; 5734 _foreground = fore;
5741 } 5735 }
5742 } 5736 }
5743 5737
5744 bubble->id = id; 5738 strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1);
5745 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); 5739 blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
5746 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; 5740 blah->oldproc = WinSubclassWindow(tmp, _BtProc);
5747 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 5741
5748 5742 WinSetWindowPtr(tmp, QWP_USER, blah);
5749 WinSetWindowPtr(tmp, QWP_USER, bubble);
5750 5743
5751 if(icon) 5744 if(icon)
5752 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); 5745 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon);
5753 else 5746 else
5754 { 5747 {
5769 * len: length of str 5762 * len: length of str
5770 */ 5763 */
5771 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) 5764 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
5772 { 5765 {
5773 FILE *fp; 5766 FILE *fp;
5774 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 5767 WindowData *blah = calloc(1, sizeof(WindowData));
5775 HWND tmp = WinCreateWindow(HWND_OBJECT, 5768 HWND tmp = WinCreateWindow(HWND_OBJECT,
5776 WC_BUTTON, 5769 WC_BUTTON,
5777 NULL, 5770 NULL,
5778 WS_VISIBLE | BS_PUSHBUTTON | 5771 WS_VISIBLE | BS_PUSHBUTTON |
5779 BS_AUTOSIZE | BS_NOPOINTERFOCUS, 5772 BS_AUTOSIZE | BS_NOPOINTERFOCUS,
5839 } 5832 }
5840 _foreground = fore; 5833 _foreground = fore;
5841 } 5834 }
5842 } 5835 }
5843 5836
5844 bubble->id = id; 5837 strncpy(blah->bubbletext, text, BUBBLE_HELP_MAX - 1);
5845 strncpy(bubble->bubbletext, text, BUBBLE_HELP_MAX - 1); 5838 blah->bubbletext[BUBBLE_HELP_MAX - 1] = '\0';
5846 bubble->bubbletext[BUBBLE_HELP_MAX - 1] = '\0'; 5839 blah->oldproc = WinSubclassWindow(tmp, _BtProc);
5847 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 5840
5848 5841 WinSetWindowPtr(tmp, QWP_USER, blah);
5849 WinSetWindowPtr(tmp, QWP_USER, bubble);
5850 5842
5851 if(icon) 5843 if(icon)
5852 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon); 5844 dw_window_set_data(tmp, "_dw_button_icon", (void *)icon);
5853 else 5845 else
5854 { 5846 {
6006 * text: The text to be display by the static text widget. 5998 * text: The text to be display by the static text widget.
6007 * id: An ID to be used with dw_window_from_id() or 0L. 5999 * id: An ID to be used with dw_window_from_id() or 0L.
6008 */ 6000 */
6009 HWND API dw_checkbox_new(char *text, ULONG id) 6001 HWND API dw_checkbox_new(char *text, ULONG id)
6010 { 6002 {
6011 BubbleButton *bubble = calloc(sizeof(BubbleButton), 1); 6003 WindowData *blah = calloc(1, sizeof(WindowData));
6012 HWND tmp = WinCreateWindow(HWND_OBJECT, 6004 HWND tmp = WinCreateWindow(HWND_OBJECT,
6013 WC_BUTTON, 6005 WC_BUTTON,
6014 (PSZ)text, 6006 (PSZ)text,
6015 WS_VISIBLE | BS_AUTOCHECKBOX, 6007 WS_VISIBLE | BS_AUTOCHECKBOX,
6016 0,0,2000,1000, 6008 0,0,2000,1000,
6017 NULLHANDLE, 6009 NULLHANDLE,
6018 HWND_TOP, 6010 HWND_TOP,
6019 id, 6011 id,
6020 NULL, 6012 NULL,
6021 NULL); 6013 NULL);
6022 bubble->id = id; 6014 blah->bubbletext[0] = '\0';
6023 bubble->bubbletext[0] = '\0'; 6015 blah->oldproc = WinSubclassWindow(tmp, _BtProc);
6024 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc); 6016 WinSetWindowPtr(tmp, QWP_USER, blah);
6025 WinSetWindowPtr(tmp, QWP_USER, bubble);
6026 dw_window_set_font(tmp, DefaultFont); 6017 dw_window_set_font(tmp, DefaultFont);
6027 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 6018 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
6028 return tmp; 6019 return tmp;
6029 } 6020 }
6030 6021