# HG changeset patch # User mhessling@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1050202775 0 # Node ID fa6aeb52d51acfb53d24e42b8848ab71c24f25b2 # Parent 0137c30f485ee23a0f434a3f555aeb73be1fdfdd 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 ;-) diff -r 0137c30f485e -r fa6aeb52d51a dwtest.c --- a/dwtest.c Fri Apr 11 13:58:05 2003 +0000 +++ b/dwtest.c Sun Apr 13 02:59:35 2003 +0000 @@ -46,6 +46,7 @@ stext, tree, container, + container_mle, pagebox, treebox, containerbox, @@ -54,7 +55,7 @@ buttonbox; HPIXMAP text1pm,text2pm; -unsigned long fileicon,foldericon; +unsigned long fileicon,foldericon,mle_point=-1; int font_width = 8; int font_height=12; @@ -386,6 +387,25 @@ return 0; } +int DWSIGNAL container_select_cb( HWND window, HTREEITEM item, char *text, void *data, void *itemdata ) +{ + char buf[200]; + char *str; + HWND statline = (HWND)data; + + 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 ); + dw_window_set_text( statline, buf); + mle_point = dw_mle_import( container_mle, buf, mle_point); + str = dw_container_query_start(container, DW_CRA_SELECTED); + while(str) + { + sprintf(buf,"Selected: %s\n", str); + mle_point = dw_mle_import( container_mle, buf, mle_point); + str = dw_container_query_next(container, DW_CRA_SELECTED); + } + return 0; +} + int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) { FILE *fp=fopen("log","a"); @@ -544,6 +564,7 @@ void container_add(void) { char *titles[3]; + char *names[3]; char buffer[100]; unsigned long flags[3] = { DW_CFA_ULONG | DW_CFA_RIGHT | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, DW_CFA_TIME | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR, @@ -575,6 +596,9 @@ for(z=0;z<3;z++) { + names[z] = (char *)malloc( 100 ); + /* yes, there is a memory leak here */ + sprintf(names[z],"Don't allocate from stack: Item: %d",z); size = z*100; sprintf(buffer, "Filename %d",z+1); if (z == 0 ) thisicon = foldericon; @@ -592,16 +616,19 @@ date.year = z+2000; dw_filesystem_set_item(container, containerinfo, 2, z, &date); - dw_container_set_row_title(containerinfo, z, "Don't allocate from the stack"); + dw_container_set_row_title(containerinfo, z, names[z]); } dw_container_insert(container, containerinfo, 3); dw_container_optimize(container); + container_mle = dw_mle_new( 111 ); + dw_box_pack_start( containerbox, container_mle, 500, 200, TRUE, TRUE, 0); + /* connect our event trappers... */ dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status); dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status); - dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)container_status); + dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(container_select_cb), (void *)container_status); } /* Beep every second */