comparison dwtest.c @ 311:24c1dfffe97e

Unified the callback functions for tree and container widgets.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 31 Mar 2003 09:57:45 +0000
parents 77105fe19c1f
children ff8f23594b15
comparison
equal deleted inserted replaced
310:77105fe19c1f 311:24c1dfffe97e
344 /* Redraw the window */ 344 /* Redraw the window */
345 draw_file( current_row, current_col); 345 draw_file( current_row, current_col);
346 return TRUE; 346 return TRUE;
347 } 347 }
348 348
349 int DWSIGNAL container_select_cb( HWND window, char *text, void *data ) 349 int DWSIGNAL item_enter_cb( HWND window, char *text, void *data )
350 { 350 {
351 char buf[100]; 351 char buf[200];
352 HWND statline = (HWND)data; 352 HWND statline = (HWND)data;
353 353
354 sprintf(buf,"container-select: Window: %d Text: %s", window, text ); 354 sprintf(buf,"DW_SIGNAL_ITEM_ENTER: Window: %x Text: %s Data:", window, text, data );
355 dw_window_set_text( statline, buf); 355 dw_window_set_text( statline, buf);
356 return 0; 356 return 0;
357 } 357 }
358 358
359 int DWSIGNAL container_context_cb( HWND window, char *text, int x, int y, void *data ) 359 int DWSIGNAL item_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata )
360 { 360 {
361 char buf[100]; 361 char buf[200];
362 HWND statline = (HWND)data; 362 HWND statline = (HWND)data;
363 363
364 sprintf(buf,"container-context: Window: %d Text: %s x: %d y: %d", window, text, x, y ); 364 sprintf(buf,"DW_SIGNAL_ITEM_CONTEXT: Window: %x Text: %s x: %d y: %d Itemdata: %x", window, text, x, y, itemdata );
365 dw_window_set_text( statline, buf); 365 dw_window_set_text( statline, buf);
366 return 0; 366 return 0;
367 } 367 }
368 368
369 int DWSIGNAL tree_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata ) 369 int DWSIGNAL list_select_cb( HWND window, int item, void *data )
370 { 370 {
371 char buf[100]; 371 char buf[200];
372 HWND statline = (HWND)data; 372 HWND statline = (HWND)data;
373 373
374 sprintf(buf,"tree-context: Window: %d Text: %s x: %d y: %d", window, text, x, y ); 374 sprintf(buf,"DW_SIGNAL_LIST_SELECT: Window: %d Item: %d", window, item );
375 dw_window_set_text( statline, buf); 375 dw_window_set_text( statline, buf);
376 return 0; 376 return 0;
377 } 377 }
378 378
379 int DWSIGNAL item_select_cb( HWND window, int item, void *data ) 379 int DWSIGNAL item_select_cb( HWND window, HWND item, char *text, void *data, void *itemdata )
380 { 380 {
381 char buf[100]; 381 char buf[200];
382 HWND statline = (HWND)data; 382 HWND statline = (HWND)data;
383 383
384 sprintf(buf,"item-seelct: Window: %d Item: %d", window, item ); 384 sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", window, item, text, itemdata );
385 dw_window_set_text( statline, buf);
386 return 0;
387 }
388
389 int DWSIGNAL tree_select_cb( HWND window, HWND item, char *text, void *itemdata, void *data )
390 {
391 char buf[100];
392 HWND statline = (HWND)data;
393
394 sprintf(buf,"tree-select: Window: %d Item: %d Text: %s", window, item, text );
395 dw_window_set_text( statline, buf); 385 dw_window_set_text( statline, buf);
396 return 0; 386 return 0;
397 } 387 }
398 388
399 void archive_add(void) 389 void archive_add(void)
444 /* Set some nice fonts and colors */ 434 /* Set some nice fonts and colors */
445 dw_window_set_color(lbbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); 435 dw_window_set_color(lbbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY);
446 dw_window_set_color(buttonbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY); 436 dw_window_set_color(buttonbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY);
447 dw_window_set_color(okbutton, DW_CLR_PALEGRAY, DW_CLR_DARKCYAN); 437 dw_window_set_color(okbutton, DW_CLR_PALEGRAY, DW_CLR_DARKCYAN);
448 438
449 dw_signal_connect(browsebutton, "clicked", DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1); 439 dw_signal_connect(browsebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1);
450 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1); 440 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1);
451 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); 441 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
452 } 442 }
453 443
454 444
455 void text_add(void) 445 void text_add(void)
456 { 446 {
501 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth ); 491 text2pm = dw_pixmap_new( textbox2, font_width*cols, font_height*rows, depth );
502 492
503 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height); 493 dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height);
504 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); 494 dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows);
505 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); 495 dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows);
506 dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); 496 dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL);
507 dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL); 497 dw_signal_connect(textbox2, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL);
508 dw_signal_connect(textbox2, "configure_event", DW_SIGNAL_FUNC(configure_event), text2pm); 498 dw_signal_connect(textbox2, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(configure_event), text2pm);
509 dw_signal_connect(hscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); 499 dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
510 dw_signal_connect(vscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status); 500 dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
511 501
512 dw_signal_connect(mainwindow, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), NULL); 502 dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL);
513 } 503 }
514 504
515 void tree_add(void) 505 void tree_add(void)
516 { 506 {
517 HWND t1,t2,t3,t4,t5,t6; 507 HWND t1,t2,t3,t4,t5,t6;
537 t4 = dw_tree_insert(tree, "tree file 2", fileicon, t1, NULL ); 527 t4 = dw_tree_insert(tree, "tree file 2", fileicon, t1, NULL );
538 t5 = dw_tree_insert(tree, "tree file 3", fileicon, t2, NULL ); 528 t5 = dw_tree_insert(tree, "tree file 3", fileicon, t2, NULL );
539 t6 = dw_tree_insert(tree, "tree file 4", fileicon, t2, NULL ); 529 t6 = dw_tree_insert(tree, "tree file 4", fileicon, t2, NULL );
540 530
541 /* set up our signal trappers... */ 531 /* set up our signal trappers... */
542 /* looks odd, we use a container-context signal on a tree widget! */ 532 dw_signal_connect(tree, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)tree_status);
543 dw_signal_connect(tree, "container-context", DW_SIGNAL_FUNC(container_context_cb), tree_status); 533 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)tree_status);
544 dw_signal_connect(tree, "tree-select", DW_SIGNAL_FUNC(tree_select_cb), tree_status);
545 /* also odd; the tree-context doesn't seem to do anything. In fact GTK complains that
546 * tree-context is invalid in a tree widget
547 */
548 dw_signal_connect(tree, "tree-context", DW_SIGNAL_FUNC(tree_context_cb), tree_status);
549 } 534 }
550 535
551 void container_add(void) 536 void container_add(void)
552 { 537 {
553 char *titles[3]; 538 char *titles[3];
604 589
605 dw_container_insert(container, containerinfo, 3); 590 dw_container_insert(container, containerinfo, 3);
606 dw_container_optimize(container); 591 dw_container_optimize(container);
607 592
608 /* connect our event trappers... */ 593 /* connect our event trappers... */
609 dw_signal_connect(container, "container-select", DW_SIGNAL_FUNC(container_select_cb), container_status); 594 dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status);
610 dw_signal_connect(container, "container-context", DW_SIGNAL_FUNC(container_context_cb), container_status); 595 dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status);
611 /* NOTE that even though we are trapping a tree-select on a container, we have to set 596 dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)container_status);
612 * a container-select callback handler, otherwise dwindows will crash, because
613 * the prototypes for tree-select and container-select callback handlers are different
614 */
615 dw_signal_connect(container, "tree-select", DW_SIGNAL_FUNC(container_select_cb), container_status);
616 } 597 }
617 598
618 /* Beep every second */ 599 /* Beep every second */
619 int DWSIGNAL timer_callback(void *data) 600 int DWSIGNAL timer_callback(void *data)
620 { 601 {
666 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE ); 647 notebookpage4 = dw_notebook_page_new( notebook, 1, FALSE );
667 dw_notebook_pack( notebook, notebookpage4, notebookbox4 ); 648 dw_notebook_pack( notebook, notebookpage4, notebookbox4 );
668 dw_notebook_page_set_text( notebook, notebookpage4, "container"); 649 dw_notebook_page_set_text( notebook, notebookpage4, "container");
669 container_add(); 650 container_add();
670 651
671 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); 652 dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
672 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0); 653 timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0);
673 dw_window_set_usize(mainwindow, 640, 480); 654 dw_window_set_usize(mainwindow, 640, 480);
674 dw_window_show(mainwindow); 655 dw_window_show(mainwindow);
675 656
676 dw_main(); 657 dw_main();