comparison win/dw.c @ 191:634625c3239d

Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a problem with dw_window_set_font() on notebook controls.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 17 Jan 2003 20:31:06 +0000
parents f55677513954
children 37bee5b50bcb
comparison
equal deleted inserted replaced
190:f4c9fa77136a 191:634625c3239d
363 if(data) 363 if(data)
364 free(data); 364 free(data);
365 } 365 }
366 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL)+1)==0) /* Notebook */ 366 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL)+1)==0) /* Notebook */
367 { 367 {
368 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 368 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
369 369
370 if(array) 370 if(array)
371 { 371 {
372 int z, refid = -1; 372 int z, refid = -1;
373 373
400 400
401 SetWindowLong(handle, GWL_USERDATA, 0); 401 SetWindowLong(handle, GWL_USERDATA, 0);
402 free(thiscinfo); 402 free(thiscinfo);
403 } 403 }
404 return TRUE; 404 return TRUE;
405 }
406
407 /* Convert to our internal color scheme */
408 ULONG _internal_color(ULONG color)
409 {
410 if(color < 18)
411 return DW_RGB(_red[color], _green[color], _blue[color]);
412 return color;
405 } 413 }
406 414
407 /* This function returns 1 if the window (widget) handle 415 /* This function returns 1 if the window (widget) handle
408 * passed to it is a valid window that can gain input focus. 416 * passed to it is a valid window that can gain input focus.
409 */ 417 */
559 return 1; 567 return 1;
560 } 568 }
561 } 569 }
562 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ 570 else if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */
563 { 571 {
564 NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); 572 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
565 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); 573 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
566 574
567 if(pageid > -1 && array && array[pageid]) 575 if(pageid > -1 && array && array[pageid])
568 { 576 {
569 Box *notebox; 577 Box *notebox;
662 670
663 GetClassName(box->items[z].hwnd, tmpbuf, 99); 671 GetClassName(box->items[z].hwnd, tmpbuf, 99);
664 672
665 if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */ 673 if(strnicmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) /* Notebook */
666 { 674 {
667 NotebookPage **array = (NotebookPage **)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); 675 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
668 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd); 676 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
669 677
670 if(pageid > -1 && array && array[pageid]) 678 if(pageid > -1 && array && array[pageid])
671 { 679 {
672 Box *notebox; 680 Box *notebox;
1142 1150
1143 /* Notebook dialog requires additional processing */ 1151 /* Notebook dialog requires additional processing */
1144 if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0) 1152 if(strncmp(tmpbuf, WC_TABCONTROL, strlen(WC_TABCONTROL))==0)
1145 { 1153 {
1146 RECT rect; 1154 RECT rect;
1147 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 1155 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
1148 int pageid = TabCtrl_GetCurSel(handle); 1156 int pageid = TabCtrl_GetCurSel(handle);
1149 1157
1150 if(pageid > -1 && array && array[pageid]) 1158 if(pageid > -1 && array && array[pageid])
1151 { 1159 {
1152 GetClientRect(handle,&rect); 1160 GetClientRect(handle,&rect);
1570 NMHDR FAR *tem=(NMHDR FAR *)mp2; 1578 NMHDR FAR *tem=(NMHDR FAR *)mp2;
1571 1579
1572 if(tem->code == TCN_SELCHANGING) 1580 if(tem->code == TCN_SELCHANGING)
1573 { 1581 {
1574 int num=TabCtrl_GetCurSel(tem->hwndFrom); 1582 int num=TabCtrl_GetCurSel(tem->hwndFrom);
1575 NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA); 1583 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
1576 1584
1577 if(num > -1 && array && array[num]) 1585 if(num > -1 && array && array[num])
1578 SetParent(array[num]->hwnd, DW_HWND_OBJECT); 1586 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
1579 1587
1580 } 1588 }
1581 else if(tem->code == TCN_SELCHANGE) 1589 else if(tem->code == TCN_SELCHANGE)
1582 { 1590 {
1583 int num=TabCtrl_GetCurSel(tem->hwndFrom); 1591 int num=TabCtrl_GetCurSel(tem->hwndFrom);
1584 NotebookPage **array = (NotebookPage **)GetWindowLong(tem->hwndFrom, GWL_USERDATA); 1592 NotebookPage **array = (NotebookPage **)dw_window_get_data(tem->hwndFrom, "_dw_array");
1585 1593
1586 if(num > -1 && array && array[num]) 1594 if(num > -1 && array && array[num])
1587 SetParent(array[num]->hwnd, tem->hwndFrom); 1595 SetParent(array[num]->hwnd, tem->hwndFrom);
1588 1596
1589 _resize_notebook_page(tem->hwndFrom, num); 1597 _resize_notebook_page(tem->hwndFrom, num);
2793 * during switching of notebook pages. 2801 * during switching of notebook pages.
2794 */ 2802 */
2795 void _resize_notebook_page(HWND handle, int pageid) 2803 void _resize_notebook_page(HWND handle, int pageid)
2796 { 2804 {
2797 RECT rect; 2805 RECT rect;
2798 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 2806 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
2799 2807
2800 if(array && array[pageid]) 2808 if(array && array[pageid])
2801 { 2809 {
2802 Box *box = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA); 2810 Box *box = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
2803 2811
3296 3304
3297 GetClassName(handle, tmpbuf, 99); 3305 GetClassName(handle, tmpbuf, 99);
3298 3306
3299 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0) 3307 if(strnicmp(tmpbuf, WC_LISTVIEW, strlen(WC_LISTVIEW))==0)
3300 { 3308 {
3309 fore = _internal_color(fore);
3310 back = _internal_color(back);
3311
3301 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore), 3312 ListView_SetTextColor(handle, RGB(DW_RED_VALUE(fore),
3302 DW_GREEN_VALUE(fore), 3313 DW_GREEN_VALUE(fore),
3303 DW_BLUE_VALUE(fore))); 3314 DW_BLUE_VALUE(fore)));
3304 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back), 3315 ListView_SetTextBkColor(handle, RGB(DW_RED_VALUE(back),
3305 DW_GREEN_VALUE(back), 3316 DW_GREEN_VALUE(back),
3556 0,0,2000,1000, 3567 0,0,2000,1000,
3557 DW_HWND_OBJECT, 3568 DW_HWND_OBJECT,
3558 (HMENU)id, 3569 (HMENU)id,
3559 DWInstance, 3570 DWInstance,
3560 NULL); 3571 NULL);
3561 SetWindowLong(tmp, GWL_USERDATA, (ULONG)array); 3572 dw_window_set_data(tmp, "_dw_array", (void *)array);
3562 dw_window_set_font(tmp, DefaultFont); 3573 dw_window_set_font(tmp, DefaultFont);
3563 return tmp; 3574 return tmp;
3564 } 3575 }
3565 3576
3566 /* 3577 /*
4562 * flags: Any additional page creation flags. 4573 * flags: Any additional page creation flags.
4563 * front: If TRUE page is added at the beginning. 4574 * front: If TRUE page is added at the beginning.
4564 */ 4575 */
4565 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) 4576 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
4566 { 4577 {
4567 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4578 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4568 4579
4569 if(array) 4580 if(array)
4570 { 4581 {
4571 int z, refid = -1; 4582 int z, refid = -1;
4572 4583
4614 * text: Pointer to the text to set. 4625 * text: Pointer to the text to set.
4615 */ 4626 */
4616 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text) 4627 void API dw_notebook_page_set_text(HWND handle, ULONG pageidx, char *text)
4617 { 4628 {
4618 4629
4619 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4630 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4620 int pageid; 4631 int pageid;
4621 4632
4622 if(!array) 4633 if(!array)
4623 return; 4634 return;
4624 4635
4651 * pageid: Page ID in the notebook which is being packed. 4662 * pageid: Page ID in the notebook which is being packed.
4652 * page: Box handle to be packed. 4663 * page: Box handle to be packed.
4653 */ 4664 */
4654 void API dw_notebook_pack(HWND handle, ULONG pageidx, HWND page) 4665 void API dw_notebook_pack(HWND handle, ULONG pageidx, HWND page)
4655 { 4666 {
4656 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4667 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4657 int pageid; 4668 int pageid;
4658 4669
4659 if(!array) 4670 if(!array)
4660 return; 4671 return;
4661 4672
4684 * handle: Handle to the notebook widget. 4695 * handle: Handle to the notebook widget.
4685 * pageid: ID of the page to be destroyed. 4696 * pageid: ID of the page to be destroyed.
4686 */ 4697 */
4687 void API dw_notebook_page_destroy(HWND handle, unsigned int pageidx) 4698 void API dw_notebook_page_destroy(HWND handle, unsigned int pageidx)
4688 { 4699 {
4689 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4700 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4690 int newid = -1, z, pageid; 4701 int newid = -1, z, pageid;
4691 4702
4692 if(!array) 4703 if(!array)
4693 return; 4704 return;
4694 4705
4732 * Parameters: 4743 * Parameters:
4733 * handle: Handle to the notebook widget. 4744 * handle: Handle to the notebook widget.
4734 */ 4745 */
4735 unsigned int API dw_notebook_page_query(HWND handle) 4746 unsigned int API dw_notebook_page_query(HWND handle)
4736 { 4747 {
4737 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4748 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4738 int physid = TabCtrl_GetCurSel(handle); 4749 int physid = TabCtrl_GetCurSel(handle);
4739 4750
4740 if(physid > -1 && physid < 256 && array && array[physid]) 4751 if(physid > -1 && physid < 256 && array && array[physid])
4741 return array[physid]->realid; 4752 return array[physid]->realid;
4742 return -1; 4753 return -1;
4748 * handle: Handle to the notebook widget. 4759 * handle: Handle to the notebook widget.
4749 * pageid: ID of the page to be made visible. 4760 * pageid: ID of the page to be made visible.
4750 */ 4761 */
4751 void API dw_notebook_page_set(HWND handle, unsigned int pageidx) 4762 void API dw_notebook_page_set(HWND handle, unsigned int pageidx)
4752 { 4763 {
4753 NotebookPage **array = (NotebookPage **)GetWindowLong(handle, GWL_USERDATA); 4764 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4754 int pageid; 4765 int pageid;
4755 4766
4756 if(!array) 4767 if(!array)
4757 return; 4768 return;
4758 4769
6209 int threadid = dw_thread_id(); 6220 int threadid = dw_thread_id();
6210 6221
6211 if(threadid < 0 || threadid >= THREAD_LIMIT) 6222 if(threadid < 0 || threadid >= THREAD_LIMIT)
6212 threadid = 0; 6223 threadid = 0;
6213 6224
6225 value = _internal_color(value);
6226
6214 DeleteObject(_hPen[threadid]); 6227 DeleteObject(_hPen[threadid]);
6215 DeleteObject(_hBrush[threadid]); 6228 DeleteObject(_hBrush[threadid]);
6216 _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); 6229 _foreground[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
6217 _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]); 6230 _hPen[threadid] = CreatePen(PS_SOLID, 1, _foreground[threadid]);
6218 _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]); 6231 _hBrush[threadid] = CreateSolidBrush(_foreground[threadid]);
6228 { 6241 {
6229 int threadid = dw_thread_id(); 6242 int threadid = dw_thread_id();
6230 6243
6231 if(threadid < 0 || threadid >= THREAD_LIMIT) 6244 if(threadid < 0 || threadid >= THREAD_LIMIT)
6232 threadid = 0; 6245 threadid = 0;
6246
6247 value = _internal_color(value);
6233 6248
6234 _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); 6249 _background[threadid] = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value));
6235 } 6250 }
6236 6251
6237 /* Draw a point on a window (preferably a render window). 6252 /* Draw a point on a window (preferably a render window).