comparison dwtest.c @ 348:fa6aeb52d51a

Added MLE for the container page to show what is going on in the item-select callback. Lists currently selected items. Not sure how to do newlines properly under windows ;-)
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 13 Apr 2003 02:59:35 +0000
parents 81fae15885d7
children 5d3f2e2dcc6b
comparison
equal deleted inserted replaced
347:0137c30f485e 348:fa6aeb52d51a
44 container_status, 44 container_status,
45 tree_status, 45 tree_status,
46 stext, 46 stext,
47 tree, 47 tree,
48 container, 48 container,
49 container_mle,
49 pagebox, 50 pagebox,
50 treebox, 51 treebox,
51 containerbox, 52 containerbox,
52 textbox1, textbox2, textboxA, 53 textbox1, textbox2, textboxA,
53 gap_box, 54 gap_box,
54 buttonbox; 55 buttonbox;
55 56
56 HPIXMAP text1pm,text2pm; 57 HPIXMAP text1pm,text2pm;
57 unsigned long fileicon,foldericon; 58 unsigned long fileicon,foldericon,mle_point=-1;
58 59
59 int font_width = 8; 60 int font_width = 8;
60 int font_height=12; 61 int font_height=12;
61 int font_gap = 2; 62 int font_gap = 2;
62 int rows=100,width1=6,cols=80; 63 int rows=100,width1=6,cols=80;
384 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata ); 385 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata );
385 dw_window_set_text( statline, buf); 386 dw_window_set_text( statline, buf);
386 return 0; 387 return 0;
387 } 388 }
388 389
390 int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata )
391 {
392 char buf[200];
393 char *str;
394 HWND statline = (HWND)data;
395
396 sprintf(buf,"\nDW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x\n", (unsigned int)window, (unsigned int)item, text, (unsigned int)itemdata );
397 dw_window_set_text( statline, buf);
398 mle_point = dw_mle_import( container_mle, buf, mle_point);
399 str = dw_container_query_start(container, DW_CRA_SELECTED);
400 while(str)
401 {
402 sprintf(buf,"Selected: %s\n", str);
403 mle_point = dw_mle_import( container_mle, buf, mle_point);
404 str = dw_container_query_next(container, DW_CRA_SELECTED);
405 }
406 return 0;
407 }
408
389 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) 409 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata )
390 { 410 {
391 FILE *fp=fopen("log","a"); 411 FILE *fp=fopen("log","a");
392 fprintf(fp,"DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", (unsigned int)window, (unsigned int)page_num, (unsigned int)itemdata ); 412 fprintf(fp,"DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", (unsigned int)window, (unsigned int)page_num, (unsigned int)itemdata );
393 fclose(fp); 413 fclose(fp);
542 } 562 }
543 563
544 void container_add(void) 564 void container_add(void)
545 { 565 {
546 char *titles[3]; 566 char *titles[3];
567 char *names[3];
547 char buffer[100]; 568 char buffer[100];
548 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, 569 unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR,
549 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, 570 DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR,
550 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR }; 571 DW_CFA_DATE | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR };
551 void *containerinfo; 572 void *containerinfo;
573 dw_filesystem_setup(container, flags, titles, 3); 594 dw_filesystem_setup(container, flags, titles, 3);
574 containerinfo = dw_container_alloc(container, 3); 595 containerinfo = dw_container_alloc(container, 3);
575 596
576 for(z=0;z<3;z++) 597 for(z=0;z<3;z++)
577 { 598 {
599 names[z] = (char *)malloc( 100 );
600 /* yes, there is a memory leak here */
601 sprintf(names[z],"Don't allocate from stack: Item: %d",z);
578 size = z*100; 602 size = z*100;
579 sprintf(buffer, "Filename %d",z+1); 603 sprintf(buffer, "Filename %d",z+1);
580 if (z == 0 ) thisicon = foldericon; 604 if (z == 0 ) thisicon = foldericon;
581 else thisicon = fileicon; 605 else thisicon = fileicon;
582 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); 606 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon);
590 date.day = z+10; 614 date.day = z+10;
591 date.month = z+10; 615 date.month = z+10;
592 date.year = z+2000; 616 date.year = z+2000;
593 dw_filesystem_set_item(container, containerinfo, 2, z, &date); 617 dw_filesystem_set_item(container, containerinfo, 2, z, &date);
594 618
595 dw_container_set_row_title(containerinfo, z, "Don't allocate from the stack"); 619 dw_container_set_row_title(containerinfo, z, names[z]);
596 } 620 }
597 621
598 dw_container_insert(container, containerinfo, 3); 622 dw_container_insert(container, containerinfo, 3);
599 dw_container_optimize(container); 623 dw_container_optimize(container);
624
625 container_mle = dw_mle_new( 111 );
626 dw_box_pack_start( containerbox, container_mle, 500, 200, TRUE, TRUE, 0);
600 627
601 /* connect our event trappers... */ 628 /* connect our event trappers... */
602 dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status); 629 dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status);
603 dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status); 630 dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status);
604 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)container_status); 631 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), (void *)container_status);
605 } 632 }
606 633
607 /* Beep every second */ 634 /* Beep every second */
608 int DWSIGNAL timer_callback(void *data) 635 int DWSIGNAL timer_callback(void *data)
609 { 636 {