Mercurial > dwindows
comparison os2/dw.c @ 22:6a246b3bb14f
Added tree widgets, fixed some delete event processing, fixed a layout bug
on OS/2 and Win32. Added another function to compat to deal with MSVC
runtime library conflicts.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 02 Aug 2001 09:57:21 +0000 |
parents | c6e76b796b28 |
children | 2932f9d2c7d5 |
comparison
equal
deleted
inserted
replaced
21:c6e76b796b28 | 22:6a246b3bb14f |
---|---|
53 FILE *f; | 53 FILE *f; |
54 | 54 |
55 void reopen(void) | 55 void reopen(void) |
56 { | 56 { |
57 fclose(f); | 57 fclose(f); |
58 f = fopen("dw.log", "at"); | 58 f = fopen("dw.log", "a+"); |
59 } | 59 } |
60 #endif | 60 #endif |
61 | 61 |
62 static LONG lColor[SPLITBAR_WIDTH] = | 62 static LONG lColor[SPLITBAR_WIDTH] = |
63 { | 63 { |
616 fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", | 616 fprintf(f, "FARK! depth %d\r\nwidth = %d, height = %d, nux = %d, nuy = %d, upx = %d, upy = %d xratio = %f, yratio = %f\r\n\r\n", |
617 *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); | 617 *depth, thisbox->items[z].width, thisbox->items[z].height, nux, nuy, tmp->upx, tmp->upy, tmp->xratio, tmp->yratio); |
618 reopen(); | 618 reopen(); |
619 } | 619 } |
620 #endif | 620 #endif |
621 | |
621 if(thisbox->type == BOXVERT) | 622 if(thisbox->type == BOXVERT) |
622 { | 623 { |
623 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) | 624 if((thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))!=0) |
624 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); | 625 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-((thisbox->items[z].pad*2)+(tmp->pad*2))))/((float)(thisbox->items[z].width-((thisbox->items[z].pad*2)+(tmp->pad*2)))); |
625 } | 626 } |
684 | 685 |
685 if(thisbox->type == BOXHORZ) | 686 if(thisbox->type == BOXHORZ) |
686 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)))); | 687 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)))); |
687 else | 688 else |
688 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); | 689 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); |
690 | |
691 if(thisbox->items[z].type == TYPEBOX) | |
692 { | |
693 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | |
694 | |
695 if(tmp) | |
696 { | |
697 tmp->parentxratio = thisbox->items[z].xratio; | |
698 tmp->parentyratio = thisbox->items[z].yratio; | |
699 } | |
700 } | |
701 | |
689 #ifdef DWDEBUG | 702 #ifdef DWDEBUG |
690 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", | 703 fprintf(f, "RATIO- xratio = %f, yratio = %f, width = %d, height = %d, pad = %d, box xratio = %f, box yratio = %f, parent xratio = %f, parent yratio = %f, minwidth = %d, minheight = %d, width = %d, height = %d, upx = %d, upy = %d\r\n\r\n", |
691 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); | 704 thisbox->items[z].xratio, thisbox->items[z].yratio, thisbox->items[z].width, thisbox->items[z].height, thisbox->items[z].pad, thisbox->xratio, thisbox->yratio, thisbox->parentxratio, thisbox->parentyratio, thisbox->minwidth, thisbox->minheight, thisbox->width, thisbox->height, thisbox->upx, thisbox->upy); |
692 reopen(); | 705 reopen(); |
693 #endif | 706 #endif |
1281 int (*closefunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; | 1294 int (*closefunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction; |
1282 | 1295 |
1283 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) | 1296 if(hWnd == tmp->window || hWnd == WinWindowFromID(tmp->window, FID_CLIENT)) |
1284 { | 1297 { |
1285 result = closefunc(tmp->window, tmp->data); | 1298 result = closefunc(tmp->window, tmp->data); |
1299 if(result) | |
1300 result = FALSE; | |
1286 tmp = NULL; | 1301 tmp = NULL; |
1287 } | 1302 } |
1288 } | 1303 } |
1289 break; | 1304 break; |
1290 case WM_PAINT: | 1305 case WM_PAINT: |
1595 } | 1610 } |
1596 break; | 1611 break; |
1597 } | 1612 } |
1598 break; | 1613 break; |
1599 case WM_CLOSE: | 1614 case WM_CLOSE: |
1600 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT)); | 1615 if(result == -1) |
1601 return (MRESULT)TRUE; | 1616 { |
1617 dw_window_destroy(WinQueryWindow(hWnd, QW_PARENT)); | |
1618 return (MRESULT)TRUE; | |
1619 } | |
1620 break; | |
1602 case WM_USER: | 1621 case WM_USER: |
1603 windowfunc = (void (*)(void *))mp1; | 1622 windowfunc = (void (*)(void *))mp1; |
1604 | 1623 |
1605 if(windowfunc) | 1624 if(windowfunc) |
1606 windowfunc((void *)mp2); | 1625 windowfunc((void *)mp2); |
1615 case WM_DESTROY: | 1634 case WM_DESTROY: |
1616 /* Free memory before destroying */ | 1635 /* Free memory before destroying */ |
1617 _free_window_memory(hWnd); | 1636 _free_window_memory(hWnd); |
1618 break; | 1637 break; |
1619 } | 1638 } |
1620 if(filterfunc && result != -1) | 1639 if(result != -1) |
1621 return (MRESULT)result; | 1640 return (MRESULT)result; |
1622 else | 1641 else |
1623 return WinDefWindowProc(hWnd, msg, mp1, mp2); | 1642 return WinDefWindowProc(hWnd, msg, mp1, mp2); |
1624 } | 1643 } |
1625 | 1644 |
1848 for(z=0;z<thisbox->count;z++) | 1867 for(z=0;z<thisbox->count;z++) |
1849 { | 1868 { |
1850 if(thisbox->items[z].type == TYPEBOX) | 1869 if(thisbox->items[z].type == TYPEBOX) |
1851 { | 1870 { |
1852 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); | 1871 Box *tmp = WinQueryWindowPtr(thisbox->items[z].hwnd, QWP_USER); |
1853 _changebox(tmp, percent, thisbox->type); | 1872 |
1873 if(tmp) | |
1874 _changebox(tmp, percent, thisbox->type); | |
1854 } | 1875 } |
1855 else | 1876 else |
1856 { | 1877 { |
1857 if(thisbox->items[z].hwnd == hwnd) | 1878 if(thisbox->items[z].hwnd == hwnd) |
1858 percent = (startSize*100)/usNewRB; | 1879 percent = (startSize*100)/usNewRB; |
2162 | 2183 |
2163 /* Get the OS/2 version. */ | 2184 /* Get the OS/2 version. */ |
2164 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG)); | 2185 DosQuerySysInfo(QSV_VERSION_MAJOR, QSV_MS_COUNT,(void *)aulBuffer, 4*sizeof(ULONG)); |
2165 | 2186 |
2166 #ifdef DWDEBUG | 2187 #ifdef DWDEBUG |
2167 f = fopen("dw.log", "wt"); | 2188 f = fopen("dw.log", "w"); |
2168 #endif | 2189 #endif |
2169 return rc; | 2190 return rc; |
2170 } | 2191 } |
2171 | 2192 |
2172 /* | 2193 /* |
2486 * handle: Handle to frame to be tracked. | 2507 * handle: Handle to frame to be tracked. |
2487 */ | 2508 */ |
2488 void dw_window_track(HWND handle) | 2509 void dw_window_track(HWND handle) |
2489 { | 2510 { |
2490 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); | 2511 WinSendMsg(handle, WM_TRACKFRAME, MPFROMSHORT(TF_MOVE), 0); |
2512 } | |
2513 | |
2514 /* | |
2515 * Changes the appearance of the mouse pointer. | |
2516 * Parameters: | |
2517 * handle: Handle to widget for which to change. | |
2518 * cursortype: ID of the pointer you want. | |
2519 */ | |
2520 void dw_window_pointer(HWND handle, int pointertype) | |
2521 { | |
2522 WinSetPointer(handle, | |
2523 WinQuerySysPointer(HWND_DESKTOP, | |
2524 pointertype, | |
2525 FALSE)); | |
2491 } | 2526 } |
2492 | 2527 |
2493 /* | 2528 /* |
2494 * Create a new Window Frame. | 2529 * Create a new Window Frame. |
2495 * Parameters: | 2530 * Parameters: |
2873 NULLHANDLE, | 2908 NULLHANDLE, |
2874 HWND_TOP, | 2909 HWND_TOP, |
2875 id, | 2910 id, |
2876 NULL, | 2911 NULL, |
2877 NULL); | 2912 NULL); |
2913 dw_window_set_font(tmp, DefaultFont); | |
2914 return tmp; | |
2915 } | |
2916 | |
2917 /* | |
2918 * Create a tree object to be packed. | |
2919 * Parameters: | |
2920 * id: An ID to be used for getting the resource from the | |
2921 * resource file. | |
2922 */ | |
2923 HWND dw_tree_new(ULONG id) | |
2924 { | |
2925 CNRINFO cnrinfo; | |
2926 HWND tmp = WinCreateWindow(HWND_OBJECT, | |
2927 WC_CONTAINER, | |
2928 NULL, | |
2929 WS_VISIBLE | CCS_READONLY | | |
2930 CCS_SINGLESEL | CCS_AUTOPOSITION, | |
2931 0,0,2000,1000, | |
2932 NULLHANDLE, | |
2933 HWND_TOP, | |
2934 id, | |
2935 NULL, | |
2936 NULL); | |
2937 | |
2938 cnrinfo.flWindowAttr = CV_TREE | CA_TREELINE; | |
2939 cnrinfo.slBitmapOrIcon.cx = 16; | |
2940 cnrinfo.slBitmapOrIcon.cy = 16; | |
2941 | |
2942 WinSendMsg(tmp, CM_SETCNRINFO, &cnrinfo, MPFROMLONG(CMA_FLWINDOWATTR | CMA_SLBITMAPORICON)); | |
2878 dw_window_set_font(tmp, DefaultFont); | 2943 dw_window_set_font(tmp, DefaultFont); |
2879 return tmp; | 2944 return tmp; |
2880 } | 2945 } |
2881 | 2946 |
2882 /* | 2947 /* |
4123 void dw_checkbox_set(HWND handle, int value) | 4188 void dw_checkbox_set(HWND handle, int value) |
4124 { | 4189 { |
4125 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); | 4190 WinSendMsg(handle,BM_SETCHECK,MPFROMSHORT(value),0); |
4126 } | 4191 } |
4127 | 4192 |
4193 typedef struct _CNRITEM | |
4194 { | |
4195 MINIRECORDCORE rc; | |
4196 HPOINTER hptrIcon; | |
4197 | |
4198 } CNRITEM, *PCNRITEM; | |
4199 | |
4200 /* | |
4201 * Inserts an item into a tree window (widget). | |
4202 * Parameters: | |
4203 * handle: Handle to the tree to be inserted. | |
4204 * title: The text title of the entry. | |
4205 * icon: Handle to coresponding icon. | |
4206 * parent: Parent handle or 0 if root. | |
4207 */ | |
4208 HWND dw_tree_insert(HWND handle, char *title, unsigned long icon, HWND parent) | |
4209 { | |
4210 ULONG cbExtra; | |
4211 PCNRITEM pci; | |
4212 RECORDINSERT ri; | |
4213 | |
4214 /* Calculate extra bytes needed for each record besides that needed for the | |
4215 * MINIRECORDCORE structure | |
4216 */ | |
4217 | |
4218 cbExtra = sizeof(CNRITEM) - sizeof(MINIRECORDCORE); | |
4219 | |
4220 /* Allocate memory for the parent record */ | |
4221 | |
4222 pci = WinSendMsg(handle, CM_ALLOCRECORD, MPFROMLONG(cbExtra), MPFROMSHORT(1)); | |
4223 | |
4224 /* Fill in the parent record data */ | |
4225 | |
4226 pci->rc.cb = sizeof(MINIRECORDCORE); | |
4227 pci->rc.pszIcon = title; | |
4228 pci->rc.hptrIcon = icon; | |
4229 | |
4230 pci->hptrIcon = icon; | |
4231 | |
4232 memset(&ri, 0, sizeof(RECORDINSERT)); | |
4233 | |
4234 ri.cb = sizeof(RECORDINSERT); | |
4235 ri.pRecordOrder = (PRECORDCORE)CMA_END; | |
4236 ri.pRecordParent = (PRECORDCORE)NULL; | |
4237 ri.zOrder = (USHORT)CMA_TOP; | |
4238 ri.cRecordsInsert = 1; | |
4239 ri.fInvalidateRecord = TRUE; | |
4240 | |
4241 /* We are about to insert the child records. Set the parent record to be | |
4242 * the one we just inserted. | |
4243 */ | |
4244 ri.pRecordParent = (PRECORDCORE)parent; | |
4245 | |
4246 /* Insert the record */ | |
4247 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pci), MPFROMP(&ri)); | |
4248 | |
4249 return (HWND)pci; | |
4250 } | |
4251 | |
4252 /* Some OS/2 specific container structs */ | |
4253 typedef struct _containerinfo { | |
4254 int count; | |
4255 void *data; | |
4256 HWND handle; | |
4257 } ContainerInfo; | |
4258 | |
4128 /* | 4259 /* |
4129 * Sets up the container columns. | 4260 * Sets up the container columns. |
4130 * Parameters: | 4261 * Parameters: |
4131 * handle: Handle to the container to be configured. | 4262 * handle: Handle to the container to be configured. |
4132 * flags: An array of unsigned longs with column flags. | 4263 * flags: An array of unsigned longs with column flags. |
4279 void *dw_container_alloc(HWND handle, int rowcount) | 4410 void *dw_container_alloc(HWND handle, int rowcount) |
4280 { | 4411 { |
4281 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0); | 4412 ULONG *flags = (ULONG *)WinQueryWindowPtr(handle, 0); |
4282 int z, size = 0, totalsize, count = 0; | 4413 int z, size = 0, totalsize, count = 0; |
4283 PRECORDCORE temp; | 4414 PRECORDCORE temp; |
4415 ContainerInfo *ci; | |
4284 void *blah; | 4416 void *blah; |
4285 | 4417 |
4286 if(!flags) | 4418 if(!flags) |
4287 return NULL; | 4419 return NULL; |
4288 | 4420 |
4317 { | 4449 { |
4318 temp->cb = totalsize; | 4450 temp->cb = totalsize; |
4319 temp = temp->preccNextRecord; | 4451 temp = temp->preccNextRecord; |
4320 } | 4452 } |
4321 | 4453 |
4322 return blah; | 4454 ci = malloc(sizeof(struct _containerinfo)); |
4455 | |
4456 ci->count = rowcount; | |
4457 ci->data = blah; | |
4458 ci->handle = handle; | |
4459 | |
4460 return (void *)ci; | |
4323 } | 4461 } |
4324 | 4462 |
4325 /* | 4463 /* |
4326 * Sets an item in specified row and column to the given data. | 4464 * Sets an item in specified row and column to the given data. |
4327 * Parameters: | 4465 * Parameters: |
4332 * data: Pointer to the data to be added. | 4470 * data: Pointer to the data to be added. |
4333 */ | 4471 */ |
4334 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) | 4472 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data) |
4335 { | 4473 { |
4336 ULONG totalsize, size = 0, *flags = (ULONG *)WinQueryWindowPtr(handle, 0); | 4474 ULONG totalsize, size = 0, *flags = (ULONG *)WinQueryWindowPtr(handle, 0); |
4337 int z; | 4475 int z, currentcount; |
4338 PRECORDCORE temp = (PRECORDCORE)pointer; | 4476 ContainerInfo *ci = (ContainerInfo *)pointer; |
4477 PRECORDCORE temp; | |
4478 CNRINFO cnr; | |
4339 void *dest; | 4479 void *dest; |
4480 | |
4481 if(!ci) | |
4482 return; | |
4340 | 4483 |
4341 if(!flags) | 4484 if(!flags) |
4342 return; | 4485 return; |
4486 | |
4487 temp = (PRECORDCORE)ci->data; | |
4488 | |
4489 WinSendMsg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))); | |
4490 currentcount = cnr.cRecords; | |
4343 | 4491 |
4344 /* Figure out the offsets to the items in the struct */ | 4492 /* Figure out the offsets to the items in the struct */ |
4345 for(z=0;z<column;z++) | 4493 for(z=0;z<column;z++) |
4346 { | 4494 { |
4347 if(flags[z] & DW_CFA_BITMAPORICON) | 4495 if(flags[z] & DW_CFA_BITMAPORICON) |
4356 size += sizeof(CTIME); | 4504 size += sizeof(CTIME); |
4357 } | 4505 } |
4358 | 4506 |
4359 totalsize = size + sizeof(RECORDCORE); | 4507 totalsize = size + sizeof(RECORDCORE); |
4360 | 4508 |
4361 for(z=0;z<row;z++) | 4509 for(z=0;z<(row-currentcount);z++) |
4362 temp = temp->preccNextRecord; | 4510 temp = temp->preccNextRecord; |
4363 | 4511 |
4364 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); | 4512 dest = (void *)(((ULONG)temp)+((ULONG)totalsize)); |
4365 | 4513 |
4366 if(flags[column] & DW_CFA_BITMAPORICON) | 4514 if(flags[column] & DW_CFA_BITMAPORICON) |
4403 { | 4551 { |
4404 dw_container_set_item(handle, pointer, column + 2, row, data); | 4552 dw_container_set_item(handle, pointer, column + 2, row, data); |
4405 } | 4553 } |
4406 | 4554 |
4407 /* | 4555 /* |
4556 * Sets the width of a column in the container. | |
4557 * Parameters: | |
4558 * handle: Handle to window (widget) of container. | |
4559 * column: Zero based column of width being set. | |
4560 * width: Width of column in pixels. | |
4561 */ | |
4562 void dw_container_set_column_width(HWND handle, int column, int width) | |
4563 { | |
4564 } | |
4565 | |
4566 /* | |
4408 * Sets the title of a row in the container. | 4567 * Sets the title of a row in the container. |
4409 * Parameters: | 4568 * Parameters: |
4410 * pointer: Pointer to the allocated memory in dw_container_alloc(). | 4569 * pointer: Pointer to the allocated memory in dw_container_alloc(). |
4411 * row: Zero based row of data being set. | 4570 * row: Zero based row of data being set. |
4412 * title: String title of the item. | 4571 * title: String title of the item. |
4413 */ | 4572 */ |
4414 void dw_container_set_row_title(void *pointer, int row, char *title) | 4573 void dw_container_set_row_title(void *pointer, int row, char *title) |
4415 { | 4574 { |
4416 PRECORDCORE temp = (PRECORDCORE)pointer; | 4575 ContainerInfo *ci = (ContainerInfo *)pointer; |
4417 int z; | 4576 PRECORDCORE temp = (PRECORDCORE)ci->data; |
4418 | 4577 int z, currentcount; |
4419 for(z=0;z<row;z++) | 4578 CNRINFO cnr; |
4579 | |
4580 WinSendMsg(ci->handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))); | |
4581 currentcount = cnr.cRecords; | |
4582 | |
4583 for(z=0;z<(row-currentcount);z++) | |
4420 temp = temp->preccNextRecord; | 4584 temp = temp->preccNextRecord; |
4421 | 4585 |
4422 temp->pszIcon = title; | 4586 temp->pszIcon = title; |
4423 temp->pszName = title; | 4587 temp->pszName = title; |
4424 temp->pszText = title; | 4588 temp->pszText = title; |
4432 * rowcount: The number of rows to be inserted. | 4596 * rowcount: The number of rows to be inserted. |
4433 */ | 4597 */ |
4434 void dw_container_insert(HWND handle, void *pointer, int rowcount) | 4598 void dw_container_insert(HWND handle, void *pointer, int rowcount) |
4435 { | 4599 { |
4436 RECORDINSERT recin; | 4600 RECORDINSERT recin; |
4601 ContainerInfo *ci = (ContainerInfo *)pointer; | |
4437 | 4602 |
4438 recin.cb = sizeof(RECORDINSERT); | 4603 recin.cb = sizeof(RECORDINSERT); |
4439 recin.pRecordOrder = (PRECORDCORE)CMA_END; | 4604 recin.pRecordOrder = (PRECORDCORE)CMA_END; |
4440 recin.pRecordParent = NULL; | 4605 recin.pRecordParent = NULL; |
4441 recin.zOrder = CMA_TOP; | 4606 recin.zOrder = CMA_TOP; |
4442 recin.fInvalidateRecord = TRUE; | 4607 recin.fInvalidateRecord = TRUE; |
4443 recin.cRecordsInsert = rowcount; | 4608 recin.cRecordsInsert = rowcount; |
4444 | 4609 |
4445 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(pointer), MPFROMP(&recin)); | 4610 WinSendMsg(handle, CM_INSERTRECORD, MPFROMP(ci->data), MPFROMP(&recin)); |
4446 } | 4611 } |
4447 | 4612 |
4448 /* | 4613 /* |
4449 * Removes all rows from a container. | 4614 * Removes all rows from a container. |
4450 * Parameters: | 4615 * Parameters: |
4451 * handle: Handle to the window (widget) to be cleared. | 4616 * handle: Handle to the window (widget) to be cleared. |
4452 */ | 4617 */ |
4453 void dw_container_clear(HWND handle) | 4618 void dw_container_clear(HWND handle) |
4454 { | 4619 { |
4455 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); | 4620 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)0L, MPFROM2SHORT(0, CMA_INVALIDATE | CMA_FREE)); |
4621 } | |
4622 | |
4623 /* | |
4624 * Removes the first x rows from a container. | |
4625 * Parameters: | |
4626 * handle: Handle to the window (widget) to be deleted from. | |
4627 * rowcount: The number of rows to be deleted. | |
4628 */ | |
4629 void dw_container_delete(HWND handle, int rowcount) | |
4630 { | |
4631 RECORDCORE *last, **prc = malloc(sizeof(RECORDCORE *) * rowcount); | |
4632 int current = 1; | |
4633 | |
4634 prc[0] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER)); | |
4635 | |
4636 while(last && current < rowcount) | |
4637 { | |
4638 prc[current] = last = (RECORDCORE *)WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)last, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER)); | |
4639 current++; | |
4640 } | |
4641 WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)prc, MPFROM2SHORT(current, CMA_INVALIDATE | CMA_FREE)); | |
4642 free(prc); | |
4643 } | |
4644 | |
4645 /* | |
4646 * Scrolls container up or down. | |
4647 * Parameters: | |
4648 * handle: Handle to the window (widget) to be scrolled. | |
4649 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or | |
4650 * DW_SCROLL_BOTTOM. (rows is ignored for last two) | |
4651 * rows: The number of rows to be scrolled. | |
4652 */ | |
4653 void dw_container_scroll(HWND handle, int direction, long rows) | |
4654 { | |
4655 switch(direction) | |
4656 { | |
4657 case DW_SCROLL_TOP: | |
4658 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(-10000000)); | |
4659 break; | |
4660 case DW_SCROLL_BOTTOM: | |
4661 WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL), MPFROMLONG(10000000)); | |
4662 break; | |
4663 } | |
4456 } | 4664 } |
4457 | 4665 |
4458 /* | 4666 /* |
4459 * Removes all rows from a container. | 4667 * Removes all rows from a container. |
4460 * Parameters: | 4668 * Parameters: |