comparison os2/dw.c @ 60:61869769c050

Sync with the latest DW code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 29 Nov 2001 15:10:39 +0000
parents 5c66a108aa47
children 4a02842f8074
comparison
equal deleted inserted replaced
59:286ffd8e8ed8 60:61869769c050
746 } 746 }
747 747
748 if(pass > 1 && *depth > 0) 748 if(pass > 1 && *depth > 0)
749 { 749 {
750 if(thisbox->type == BOXVERT) 750 if(thisbox->type == BOXVERT)
751 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 751 {
752 if((thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
753 thisbox->items[z].xratio = 1.0;
754 else
755 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minwidth-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
756 }
752 else 757 else
753 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 758 {
759 if(thisbox->minwidth-thisbox->upx == 0)
760 thisbox->items[z].xratio = 1.0;
761 else
762 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
763 }
754 764
755 if(thisbox->type == BOXHORZ) 765 if(thisbox->type == BOXHORZ)
756 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2)))); 766 {
767 if((thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))) == 0)
768 thisbox->items[z].yratio = 1.0;
769 else
770 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))))/((float)(thisbox->minheight-((thisbox->items[z].pad*2)+(thisbox->parentpad*2))));
771 }
757 else 772 else
758 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); 773 {
774 if(thisbox->minheight-thisbox->upy == 0)
775 thisbox->items[z].yratio = 1.0;
776 else
777 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
778 }
759 779
760 if(thisbox->items[z].type == TYPEBOX) 780 if(thisbox->items[z].type == TYPEBOX)
761 { 781 {
762 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); 782 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER);
763 783
2754 { 2774 {
2755 WinQuerySwitchEntry(hswitch, &swcntrl); 2775 WinQuerySwitchEntry(hswitch, &swcntrl);
2756 swcntrl.uchVisibility = SWL_VISIBLE; 2776 swcntrl.uchVisibility = SWL_VISIBLE;
2757 WinChangeSwitchEntry(hswitch, &swcntrl); 2777 WinChangeSwitchEntry(hswitch, &swcntrl);
2758 } 2778 }
2779 if(WinWindowFromID(handle, FID_CLIENT))
2780 {
2781 WindowData *blah = WinQueryWindowPtr(handle, QWP_USER);
2782
2783 if(blah && !(blah->flags & DW_OS2_NEW_WINDOW))
2784 {
2785 ULONG cx = dw_screen_width(), cy = dw_screen_height();
2786 int newx, newy, changed = 0;
2787 SWP swp;
2788
2789 blah->flags |= DW_OS2_NEW_WINDOW;
2790
2791 WinQueryWindowPos(handle, &swp);
2792
2793 newx = swp.x;
2794 newy = swp.y;
2795
2796 if((swp.x+swp.cx) > cx)
2797 {
2798 newx = (cx - swp.cx)/2;
2799 changed = 1;
2800 }
2801 if((swp.y+swp.cy) > cy)
2802 {
2803 newy = (cy - swp.cy)/2;
2804 changed = 1;
2805 }
2806 if(changed)
2807 WinSetWindowPos(handle, NULLHANDLE, newx, newy, 0, 0, SWP_MOVE);
2808 }
2809 }
2759 return rc; 2810 return rc;
2760
2761 } 2811 }
2762 2812
2763 /* 2813 /*
2764 * Minimizes or Iconifies a top-level window. 2814 * Minimizes or Iconifies a top-level window.
2765 * Parameters: 2815 * Parameters:
3009 */ 3059 */
3010 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle) 3060 HWND dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3011 { 3061 {
3012 HWND hwndclient = 0, hwndframe; 3062 HWND hwndclient = 0, hwndframe;
3013 Box *newbox = calloc(1, sizeof(Box)); 3063 Box *newbox = calloc(1, sizeof(Box));
3014 PFNWP *blah = malloc(sizeof(PFNWP)); 3064 WindowData *blah = calloc(1, sizeof(WindowData));
3015 3065
3016 newbox->pad = 0; 3066 newbox->pad = 0;
3017 newbox->type = BOXVERT; 3067 newbox->type = BOXVERT;
3018 newbox->count = 0; 3068 newbox->count = 0;
3019 3069
3022 if(flStyle & DW_FCF_TITLEBAR) 3072 if(flStyle & DW_FCF_TITLEBAR)
3023 newbox->titlebar = 1; 3073 newbox->titlebar = 1;
3024 else 3074 else
3025 flStyle |= FCF_TITLEBAR; 3075 flStyle |= FCF_TITLEBAR;
3026 3076
3077 if(!(flStyle & FCF_SHELLPOSITION))
3078 blah->flags |= DW_OS2_NEW_WINDOW;
3079
3027 hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient); 3080 hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient);
3028 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR); 3081 newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
3029 if(!newbox->titlebar && newbox->hwndtitle) 3082 if(!newbox->titlebar && newbox->hwndtitle)
3030 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE); 3083 WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
3031 *blah = WinSubclassWindow(hwndframe, _sizeproc); 3084 blah->oldproc = WinSubclassWindow(hwndframe, _sizeproc);
3032 WinSetWindowPtr(hwndframe, QWP_USER, blah); 3085 WinSetWindowPtr(hwndframe, QWP_USER, blah);
3033 WinSetWindowPtr(hwndclient, QWP_USER, newbox); 3086 WinSetWindowPtr(hwndclient, QWP_USER, newbox);
3034 3087
3035 return hwndframe; 3088 return hwndframe;
3036 } 3089 }
3488 * Parameters: 3541 * Parameters:
3489 * id: An ID to be used with WinWindowFromID() or 0L. 3542 * id: An ID to be used with WinWindowFromID() or 0L.
3490 */ 3543 */
3491 HWND dw_mle_new(ULONG id) 3544 HWND dw_mle_new(ULONG id)
3492 { 3545 {
3546 WindowData *blah = calloc(1, sizeof(WindowData));
3493 HWND tmp = WinCreateWindow(HWND_OBJECT, 3547 HWND tmp = WinCreateWindow(HWND_OBJECT,
3494 WC_MLE, 3548 WC_MLE,
3495 "", 3549 "",
3496 WS_VISIBLE | 3550 WS_VISIBLE |
3497 MLS_BORDER | MLS_IGNORETAB | 3551 MLS_BORDER | MLS_IGNORETAB |
3502 id, 3556 id,
3503 NULL, 3557 NULL,
3504 NULL); 3558 NULL);
3505 dw_window_set_font(tmp, DefaultFont); 3559 dw_window_set_font(tmp, DefaultFont);
3506 dw_window_set_font(tmp, DefaultFont); 3560 dw_window_set_font(tmp, DefaultFont);
3561 blah->oldproc = WinSubclassWindow(tmp, _comboentryproc);
3562 WinSetWindowPtr(tmp, QWP_USER, blah);
3507 return tmp; 3563 return tmp;
3508 } 3564 }
3509 3565
3510 /* 3566 /*
3511 * Create a new Entryfield window (widget) to be packed. 3567 * Create a new Entryfield window (widget) to be packed.
3780 * text: The text to be display by the static text widget. 3836 * text: The text to be display by the static text widget.
3781 * id: An ID to be used with WinWindowFromID() or 0L. 3837 * id: An ID to be used with WinWindowFromID() or 0L.
3782 */ 3838 */
3783 HWND dw_checkbox_new(char *text, ULONG id) 3839 HWND dw_checkbox_new(char *text, ULONG id)
3784 { 3840 {
3785 PFNWP *blah = malloc(sizeof(PFNWP)); 3841 BubbleButton *bubble = malloc(sizeof(BubbleButton));
3786 HWND tmp = WinCreateWindow(HWND_OBJECT, 3842 HWND tmp = WinCreateWindow(HWND_OBJECT,
3787 WC_BUTTON, 3843 WC_BUTTON,
3788 text, 3844 text,
3789 WS_VISIBLE | BS_AUTOCHECKBOX, 3845 WS_VISIBLE | BS_AUTOCHECKBOX,
3790 0,0,2000,1000, 3846 0,0,2000,1000,
3793 id, 3849 id,
3794 NULL, 3850 NULL,
3795 NULL); 3851 NULL);
3796 dw_window_set_font(tmp, DefaultFont); 3852 dw_window_set_font(tmp, DefaultFont);
3797 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY); 3853 dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_PALEGRAY);
3798 *blah = WinSubclassWindow(tmp, _entryproc); 3854 bubble->id = id;
3799 WinSetWindowPtr(tmp, QWP_USER, blah); 3855 bubble->bubbletext[0] = '\0';
3856 bubble->pOldProc = WinSubclassWindow(tmp, _BtProc);
3857 WinSetWindowPtr(tmp, QWP_USER, bubble);
3800 return tmp; 3858 return tmp;
3801 } 3859 }
3802 3860
3803 /* 3861 /*
3804 * Create a new listbox window (widget) to be packed. 3862 * Create a new listbox window (widget) to be packed.
4719 { 4777 {
4720 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); 4778 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0);
4721 } 4779 }
4722 4780
4723 /* 4781 /*
4782 * Inserts an item into a tree window (widget) after another item.
4783 * Parameters:
4784 * handle: Handle to the tree to be inserted.
4785 * item: Handle to the item to be positioned after.
4786 * title: The text title of the entry.
4787 * icon: Handle to coresponding icon.
4788 * parent: Parent handle or 0 if root.
4789 * itemdata: Item specific data.
4790 */
4791 HWND dw_tree_insert_after(HWND handle, HWND item, char *title, unsigned long icon, HWND parent, void *itemdata)
4792 {
4793 ULONG cbExtra;
4794 PCNRITEM pci;
4795 RECORDINSERT ri;
4796
4797 if(!item)
4798 item = CMA_FIRST;
4799
4800 /* Calculate extra bytes needed for each record besides that needed for the
4801 * MINIRECORDCORE structure
4802 */
4803
4804 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE);
4805
4806 /* Allocate memory for the parent record */
4807
4808 pci = WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1));
4809
4810 /* Fill in the parent record data */
4811
4812 pci->rc.cb = sizeof(MINIRECORDCORE);
4813 pci->rc.pszIcon = strdup(title);
4814 pci->rc.hptrIcon = icon;
4815
4816 pci->hptrIcon = icon;
4817 pci->user = itemdata;
4818
4819 memset(&ri, 0, sizeof(RECORDINSERT));
4820
4821 ri.cb = sizeof(RECORDINSERT);
4822 ri.pRecordOrder = (PRECORDCORE)item;
4823 ri.pRecordParent = (PRECORDCORE)NULL;
4824 ri.zOrder = (USHORT)CMA_TOP;
4825 ri.cRecordsInsert = 1;
4826 ri.fInvalidateRecord = TRUE;
4827
4828 /* We are about to insert the child records. Set the parent record to be
4829 * the one we just inserted.
4830 */
4831 ri.pRecordParent = (PRECORDCORE)parent;
4832
4833 /* Insert the record */
4834 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri));
4835
4836 return (HWND)pci;
4837 }
4838
4839 /*
4724 * Inserts an item into a tree window (widget). 4840 * Inserts an item into a tree window (widget).
4725 * Parameters: 4841 * Parameters:
4726 * handle: Handle to the tree to be inserted. 4842 * handle: Handle to the tree to be inserted.
4727 * title: The text title of the entry. 4843 * title: The text title of the entry.
4728 * icon: Handle to coresponding icon. 4844 * icon: Handle to coresponding icon.
4729 * parent: Parent handle or 0 if root. 4845 * parent: Parent handle or 0 if root.
4730 * itemdata: Item specific data. 4846 * itemdata: Item specific data.
4731 */ 4847 */
4732 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata) 4848 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent, void *itemdata)
4733 { 4849 {
4734 ULONG cbExtra; 4850 return dw_tree_insert_after(handle, (HWND)CMA_END, title, icon, parent, itemdata);
4735 PCNRITEM pci;
4736 RECORDINSERT ri;
4737
4738 /* Calculate extra bytes needed for each record besides that needed for the
4739 * MINIRECORDCORE structure
4740 */
4741
4742 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE);
4743
4744 /* Allocate memory for the parent record */
4745
4746 pci = WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1));
4747
4748 /* Fill in the parent record data */
4749
4750 pci->rc.cb = sizeof(MINIRECORDCORE);
4751 pci->rc.pszIcon = strdup(title);
4752 pci->rc.hptrIcon = icon;
4753
4754 pci->hptrIcon = icon;
4755 pci->user = itemdata;
4756
4757 memset(&ri, 0, sizeof(RECORDINSERT));
4758
4759 ri.cb = sizeof(RECORDINSERT);
4760 ri.pRecordOrder = (PRECORDCORE)CMA_END;
4761 ri.pRecordParent = (PRECORDCORE)NULL;
4762 ri.zOrder = (USHORT)CMA_TOP;
4763 ri.cRecordsInsert = 1;
4764 ri.fInvalidateRecord = TRUE;
4765
4766 /* We are about to insert the child records. Set the parent record to be
4767 * the one we just inserted.
4768 */
4769 ri.pRecordParent = (PRECORDCORE)parent;
4770
4771 /* Insert the record */
4772 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri));
4773
4774 return (HWND)pci;
4775 } 4851 }
4776 4852
4777 /* 4853 /*
4778 * Sets the text and icon of an item in a tree window (widget). 4854 * Sets the text and icon of an item in a tree window (widget).
4779 * Parameters: 4855 * Parameters:
4882 4958
4883 if(!item) 4959 if(!item)
4884 return; 4960 return;
4885 4961
4886 if(pci->rc.pszIcon) 4962 if(pci->rc.pszIcon)
4963 {
4887 free(pci->rc.pszIcon); 4964 free(pci->rc.pszIcon);
4965 pci->rc.pszIcon = 0;
4966 }
4888 4967
4889 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE)); 4968 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE));
4890 } 4969 }
4891 4970
4892 /* Some OS/2 specific container structs */ 4971 /* Some OS/2 specific container structs */