comparison dwtest.c @ 1306:dbd507f42947

Added dw_debug() logging function which will output a message to the debugging console. On Windows this uses OutputDebugMessage(), on Mac it uses NSLog() ... The other platforms currently just dump it to stderr. Maybe more enhancements to come.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 03 Nov 2011 23:34:10 +0000
parents 4bc8b6ffbe1e
children 03f0bc85e7be
comparison
equal deleted inserted replaced
1305:18a31ab94e3d 1306:dbd507f42947
608 } 608 }
609 609
610 int DWSIGNAL browse_folder_callback(HWND window, void *data) 610 int DWSIGNAL browse_folder_callback(HWND window, void *data)
611 { 611 {
612 char *tmp = dw_file_browse("Pick a folder", ".", "c", DW_DIRECTORY_OPEN ); 612 char *tmp = dw_file_browse("Pick a folder", ".", "c", DW_DIRECTORY_OPEN );
613 printf("Folder picked: %s\n", tmp ? tmp : "None"); 613 dw_debug("Folder picked: %s\n", tmp ? tmp : "None");
614 return 0; 614 return 0;
615 } 615 }
616 616
617 int DWSIGNAL button_callback(HWND window, void *data) 617 int DWSIGNAL button_callback(HWND window, void *data)
618 { 618 {
779 str = dw_container_query_next(container, DW_CRA_SELECTED); 779 str = dw_container_query_next(container, DW_CRA_SELECTED);
780 } 780 }
781 /* Make the last inserted point the cursor location */ 781 /* Make the last inserted point the cursor location */
782 dw_mle_set_cursor(container_mle, mle_point); 782 dw_mle_set_cursor(container_mle, mle_point);
783 /* set the details of item 0 to new data */ 783 /* set the details of item 0 to new data */
784 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container), 784 dw_debug("In cb: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container),
785 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(fileicon)); 785 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(fileicon));
786 dw_filesystem_change_file(container, 0, "new data", fileicon); 786 dw_filesystem_change_file(container, 0, "new data", fileicon);
787 size = 999; 787 size = 999;
788 fprintf(stderr,"In cb: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container), 788 dw_debug("In cb: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container),
789 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(fileicon)); 789 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(fileicon));
790 dw_filesystem_change_item(container, 1, 0, &size); 790 dw_filesystem_change_item(container, 1, 0, &size);
791 return 0; 791 return 0;
792 } 792 }
793 793
794 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata ) 794 int DWSIGNAL switch_page_cb( HWND window, unsigned long page_num, void *itemdata )
795 { 795 {
796 FILE *fp=fopen("log","a"); 796 dw_debug("DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", DW_POINTER_TO_UINT(window),
797 if ( fp ) 797 DW_POINTER_TO_UINT(page_num), DW_POINTER_TO_UINT(itemdata) );
798 {
799 fprintf(fp,"DW_SIGNAL_SWITCH_PAGE: Window: %x PageNum: %u Itemdata: %x\n", DW_POINTER_TO_UINT(window),
800 DW_POINTER_TO_UINT(page_num), DW_POINTER_TO_UINT(itemdata) );
801 fclose(fp);
802 }
803 return 0; 798 return 0;
804 } 799 }
805 800
806 int DWSIGNAL column_click_cb( HWND window, int column_num, void *data ) 801 int DWSIGNAL column_click_cb( HWND window, int column_num, void *data )
807 { 802 {
833 return 0; 828 return 0;
834 } 829 }
835 830
836 int DWSIGNAL combobox_select_event_callback(HWND window, int index) 831 int DWSIGNAL combobox_select_event_callback(HWND window, int index)
837 { 832 {
838 fprintf(stderr,"got combobox_select_event for index: %d, iteration: %d\n", index, iteration++); 833 dw_debug("got combobox_select_event for index: %d, iteration: %d\n", index, iteration++);
839 return FALSE; 834 return FALSE;
840 } 835 }
841 836
842 void archive_add(void) 837 void archive_add(void)
843 { 838 {
1121 sprintf(names[z],"Don't allocate from stack: Item: %d",z); 1116 sprintf(names[z],"Don't allocate from stack: Item: %d",z);
1122 size = z*100; 1117 size = z*100;
1123 sprintf(buffer, "Filename %d",z+1); 1118 sprintf(buffer, "Filename %d",z+1);
1124 if (z == 0 ) thisicon = foldericon; 1119 if (z == 0 ) thisicon = foldericon;
1125 else thisicon = fileicon; 1120 else thisicon = fileicon;
1126 fprintf(stderr,"Initial: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container), 1121 dw_debug("Initial: container: %x containerinfo: %x icon: %x\n", DW_POINTER_TO_INT(container),
1127 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(thisicon)); 1122 DW_POINTER_TO_INT(containerinfo), DW_POINTER_TO_INT(thisicon));
1128 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon); 1123 dw_filesystem_set_file(container, containerinfo, z, buffer, thisicon);
1129 dw_filesystem_set_item(container, containerinfo, 0, z, &thisicon); 1124 dw_filesystem_set_item(container, containerinfo, 0, z, &thisicon);
1130 dw_filesystem_set_item(container, containerinfo, 1, z, &size); 1125 dw_filesystem_set_item(container, containerinfo, 1, z, &size);
1131 1126
1132 time.seconds = z+10; 1127 time.seconds = z+10;
1231 dw_window_set_text( combobox, "initial value"); 1226 dw_window_set_text( combobox, "initial value");
1232 */ 1227 */
1233 dw_signal_connect( combobox1, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); 1228 dw_signal_connect( combobox1, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL );
1234 #if 0 1229 #if 0
1235 /* add LOTS of items */ 1230 /* add LOTS of items */
1236 fprintf(stderr,"before appending 100 items to combobox using dw_listbox_append()\n"); 1231 dw_debug("before appending 100 items to combobox using dw_listbox_append()\n");
1237 for( i = 0; i < 100; i++ ) 1232 for( i = 0; i < 100; i++ )
1238 { 1233 {
1239 sprintf( buf, "item %d", i); 1234 sprintf( buf, "item %d", i);
1240 dw_listbox_append( combobox1, buf ); 1235 dw_listbox_append( combobox1, buf );
1241 } 1236 }
1242 fprintf(stderr,"after appending 100 items to combobox\n"); 1237 dw_debug("after appending 100 items to combobox\n");
1243 #endif 1238 #endif
1244 1239
1245 combobox2 = dw_combobox_new( "joe", 0 ); /* no point in specifying an initial value */ 1240 combobox2 = dw_combobox_new( "joe", 0 ); /* no point in specifying an initial value */
1246 dw_box_pack_start( combox, combobox2, 200, 20, TRUE, FALSE, 0); 1241 dw_box_pack_start( combox, combobox2, 200, 20, TRUE, FALSE, 0);
1247 /* 1242 /*
1248 dw_window_set_text( combobox, "initial value"); 1243 dw_window_set_text( combobox, "initial value");
1249 */ 1244 */
1250 dw_signal_connect( combobox2, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL ); 1245 dw_signal_connect( combobox2, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(combobox_select_event_callback), NULL );
1251 /* add LOTS of items */ 1246 /* add LOTS of items */
1252 fprintf(stderr,"before appending 500 items to combobox using dw_listbox_list_append()\n"); 1247 dw_debug("before appending 500 items to combobox using dw_listbox_list_append()\n");
1253 text = (char **)malloc(500*sizeof(char *)); 1248 text = (char **)malloc(500*sizeof(char *));
1254 for( i = 0; i < 500; i++ ) 1249 for( i = 0; i < 500; i++ )
1255 { 1250 {
1256 text[i] = (char *)malloc( 50 ); 1251 text[i] = (char *)malloc( 50 );
1257 sprintf( text[i], "item %d", i); 1252 sprintf( text[i], "item %d", i);
1258 } 1253 }
1259 dw_listbox_list_append( combobox2, text, 500 ); 1254 dw_listbox_list_append( combobox2, text, 500 );
1260 fprintf(stderr,"after appending 500 items to combobox\n"); 1255 dw_debug("after appending 500 items to combobox\n");
1261 for( i = 0; i < 500; i++ ) 1256 for( i = 0; i < 500; i++ )
1262 { 1257 {
1263 free(text[i]); 1258 free(text[i]);
1264 } 1259 }
1265 free(text); 1260 free(text);
1382 { 1377 {
1383 int pos, range; 1378 int pos, range;
1384 1379
1385 pos = dw_scrollbox_get_pos( scrollbox, DW_VERT ); 1380 pos = dw_scrollbox_get_pos( scrollbox, DW_VERT );
1386 range = dw_scrollbox_get_range( scrollbox, DW_VERT ); 1381 range = dw_scrollbox_get_range( scrollbox, DW_VERT );
1387 fprintf( stderr, "Pos %d Range %d\n", pos, range ); 1382 dw_debug("Pos %d Range %d\n", pos, range );
1388 return 0; 1383 return 0;
1389 } 1384 }
1390 1385
1391 void scrollbox_add(void) 1386 void scrollbox_add(void)
1392 { 1387 {