comparison src/glyphs-widget.c @ 454:d7a9135ec789 r21-2-42

Import from CVS: tag r21-2-42
author cvs
date Mon, 13 Aug 2007 11:40:54 +0200
parents abe6d1db359e
children c33ae14dd6d0
comparison
equal deleted inserted replaced
453:270b05afd845 454:d7a9135ec789
292 static void 292 static void
293 widget_update (Lisp_Object image_instance, Lisp_Object instantiator) 293 widget_update (Lisp_Object image_instance, Lisp_Object instantiator)
294 { 294 {
295 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance); 295 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
296 struct image_instantiator_methods* meths; 296 struct image_instantiator_methods* meths;
297 struct gcpro gcpro1;
297 298
298 Lisp_Object text = find_keyword_in_vector (instantiator, Q_text); 299 Lisp_Object text = find_keyword_in_vector (instantiator, Q_text);
300 Lisp_Object desc = find_keyword_in_vector (instantiator, Q_descriptor);
301 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
302 Lisp_Object descriptor_item = Qnil;
303
304 GCPRO1 (descriptor_item);
305
299 /* Pick up any generic properties that we might need to keep hold 306 /* Pick up any generic properties that we might need to keep hold
300 of. */ 307 of.
308 #### This is potentially bogus because it is changing the items
309 in place rather than in the pending items. */
301 if (!NILP (text)) 310 if (!NILP (text))
302 { 311 {
303 IMAGE_INSTANCE_WIDGET_TEXT (ii) = text; 312 IMAGE_INSTANCE_WIDGET_TEXT (ii) = text;
304 IMAGE_INSTANCE_TEXT_CHANGED (ii) = 1; 313 IMAGE_INSTANCE_TEXT_CHANGED (ii) = 1;
305 } 314 }
306 315
316 /* Retrieve the gui item information. This is easy if we have been
317 provided with a vector, more difficult if we have just been given
318 keywords.
319
320 #### This is inconsistent with instantiation in that you have to
321 have the :descriptor keyword for updates in order to recognise
322 changes. */
323 if (VECTORP (desc))
324 {
325 descriptor_item = gui_parse_item_keywords_no_errors (desc);
326 }
327 else
328 {
329 /* Since we are updating the instantiator could be incomplete
330 and hence the gui item descriptor not well formed. We
331 therefore try updating and discard the results if nothing
332 changed. */
333 descriptor_item = copy_gui_item (IMAGE_INSTANCE_WIDGET_ITEM (ii));
334 if (!update_gui_item_keywords (descriptor_item, instantiator))
335 descriptor_item = Qnil;
336 }
337
338 /* Record new items for update. *_redisplay will do the
339 rest. */
340 if (!EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qlayout)
341 &&
342 !EQ (IMAGE_INSTANCE_WIDGET_TYPE (ii), Qnative_layout))
343 {
344 if (!NILP (items))
345 {
346 if (NILP (descriptor_item))
347 descriptor_item = IMAGE_INSTANCE_WIDGET_ITEM (ii);
348
349 check_valid_item_list (items);
350 #ifdef DEBUG_WIDGET_OUTPUT
351 stderr_out ("items for widget %p updated\n",
352 IMAGE_INSTANCE_SUBWINDOW_ID (ii));
353 #endif
354 /* Don't set the actual items since we might decide not to use
355 the new ones (because nothing has really changed). If we did
356 set them and didn't use them then we would get into whole
357 heaps of trouble when the old items get GC'd. */
358 descriptor_item = Fcons (descriptor_item, parse_gui_item_tree_children (items));
359 }
360 /* If the descriptor was updated but not the items we need to fill
361 in the `new' items. */
362 else if (!NILP (descriptor_item)
363 &&
364 CONSP (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
365 {
366 descriptor_item = Fcons
367 (descriptor_item,
368 copy_gui_item_tree (XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))));
369 }
370 }
371
372 if (!NILP (descriptor_item))
373 {
374 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) = descriptor_item;
375 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
376 }
377
378 UNGCPRO;
379
307 /* Now try device specific methods first ... */ 380 /* Now try device specific methods first ... */
308 meths = decode_device_ii_format (image_instance_device (image_instance), 381 meths = decode_device_ii_format (image_instance_device (image_instance),
309 IMAGE_INSTANCE_WIDGET_TYPE (ii), 382 IMAGE_INSTANCE_WIDGET_TYPE (ii),
310 ERROR_ME_NOT); 383 ERROR_ME_NOT);
311 MAYBE_IIFORMAT_METH (meths, update, (image_instance, instantiator)); 384 MAYBE_IIFORMAT_METH (meths, update, (image_instance, instantiator));
568 641
569 /* retrieve the fg and bg colors */ 642 /* retrieve the fg and bg colors */
570 if (!NILP (face)) 643 if (!NILP (face))
571 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Fget_face (face)); 644 SET_IMAGE_INSTANCE_WIDGET_FACE (ii, Fget_face (face));
572 645
573 /* retrieve the gui item information. This is easy if we have been 646 /* Retrieve the gui item information. This is easy if we have been
574 provided with a vector, more difficult if we have just been given 647 provided with a vector, more difficult if we have just been given
575 keywords */ 648 keywords. Note that standard gui descriptor shortcuts will not work
576 if (STRINGP (desc) || NILP (desc)) 649 because of keyword parsing.
650
651 #### This is bogus in that descriptor and items share the same slot,
652 we should rationalize. */
653 if (VECTORP (desc))
654 {
655 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
656 gui_parse_item_keywords_no_errors (desc);
657 }
658 else
577 { 659 {
578 /* big cheat - we rely on the fact that a gui item looks like an instantiator */ 660 /* big cheat - we rely on the fact that a gui item looks like an instantiator */
579 IMAGE_INSTANCE_WIDGET_ITEMS (ii) = 661 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
580 gui_parse_item_keywords_no_errors (instantiator); 662 widget_gui_parse_item_keywords (instantiator);
581 IMAGE_INSTANCE_WIDGET_TEXT (ii) = desc; 663 }
582 }
583 else
584 IMAGE_INSTANCE_WIDGET_ITEMS (ii) =
585 gui_parse_item_keywords_no_errors (desc);
586 664
587 /* Pick up the orientation before we do our first layout. */ 665 /* Pick up the orientation before we do our first layout. */
588 if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical)) 666 if (EQ (orient, Qleft) || EQ (orient, Qright) || EQ (orient, Qvertical))
589 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL; 667 IMAGE_INSTANCE_SUBWINDOW_ORIENT (ii) = LAYOUT_VERTICAL;
590 668
771 } 849 }
772 else 850 else
773 { 851 {
774 if (height) *height = th; 852 if (height) *height = th;
775 if (width) *width = tw; 853 if (width) *width = tw;
776 }
777 }
778
779 /* Update the contents of a tab control. */
780 static void
781 tab_control_update (Lisp_Object image_instance,
782 Lisp_Object instantiator)
783 {
784 Lisp_Object items = find_keyword_in_vector (instantiator, Q_items);
785 /* Record new items for update. *_tab_control_redisplay will do the
786 rest. */
787 if (!NILP (items))
788 {
789 Lisp_Image_Instance* ii = XIMAGE_INSTANCE (image_instance);
790 check_valid_item_list (items);
791 #ifdef DEBUG_WIDGET_OUTPUT
792 stderr_out ("tab control %p updated\n", IMAGE_INSTANCE_SUBWINDOW_ID (ii));
793 #endif
794 /* Don't set the actual items since we might decide not to use
795 the new ones (because nothing has really changed). If we did
796 set them and didn't use them then we would get into whole
797 heaps of trouble when the old items get GC'd. */
798 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) =
799 Fcons (XCAR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)),
800 parse_gui_item_tree_children (items));
801 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
802 } 854 }
803 } 855 }
804 856
805 /* Determine whether only the order has changed for a tab. */ 857 /* Determine whether only the order has changed for a tab. */
806 int tab_control_order_only_changed (Lisp_Object image_instance) 858 int tab_control_order_only_changed (Lisp_Object image_instance)
836 if (!found) 888 if (!found)
837 break; 889 break;
838 } 890 }
839 } 891 }
840 return found; 892 return found;
841 }
842
843 /* Set the properties of a progress gauge */
844 static void
845 progress_gauge_update (Lisp_Object image_instance,
846 Lisp_Object instantiator)
847 {
848 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
849 Lisp_Object value = find_keyword_in_vector (instantiator, Q_value);
850
851 if (!NILP (value))
852 {
853 CHECK_INT (value);
854 #ifdef DEBUG_WIDGET_OUTPUT
855 stderr_out ("progress gauge value set to %ld\n", XINT (value));
856 #endif
857 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii) =
858 copy_gui_item_tree (IMAGE_INSTANCE_WIDGET_ITEMS (ii));
859 #ifdef ERROR_CHECK_GLYPHS
860 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)));
861 #endif
862 if (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii)))
863 XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value = value;
864
865 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii) = 1;
866 }
867 } 893 }
868 894
869 895
870 /***************************************************************************** 896 /*****************************************************************************
871 * widget layout * 897 * widget layout *
1478 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, validate, widget); 1504 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, validate, widget);
1479 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, possible_dest_types, widget); 1505 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, possible_dest_types, widget);
1480 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, instantiate, widget); 1506 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, instantiate, widget);
1481 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, post_instantiate, widget); 1507 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, post_instantiate, widget);
1482 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, governing_domain, subwindow); 1508 IIFORMAT_HAS_SHARED_METHOD (progress_gauge, governing_domain, subwindow);
1483 IIFORMAT_HAS_METHOD (progress_gauge, update);
1484 VALID_WIDGET_KEYWORDS (progress_gauge); 1509 VALID_WIDGET_KEYWORDS (progress_gauge);
1485 VALID_GUI_KEYWORDS (progress_gauge); 1510 VALID_GUI_KEYWORDS (progress_gauge);
1486 1511
1487 IIFORMAT_VALID_KEYWORD (progress_gauge, Q_value, check_valid_int); 1512 IIFORMAT_VALID_KEYWORD (progress_gauge, Q_value, check_valid_int);
1488 } 1513 }
1493 IIFORMAT_HAS_SHARED_METHOD (tree_view, validate, combo_box); 1518 IIFORMAT_HAS_SHARED_METHOD (tree_view, validate, combo_box);
1494 IIFORMAT_HAS_SHARED_METHOD (tree_view, possible_dest_types, widget); 1519 IIFORMAT_HAS_SHARED_METHOD (tree_view, possible_dest_types, widget);
1495 IIFORMAT_HAS_SHARED_METHOD (tree_view, instantiate, widget); 1520 IIFORMAT_HAS_SHARED_METHOD (tree_view, instantiate, widget);
1496 IIFORMAT_HAS_SHARED_METHOD (tree_view, post_instantiate, widget); 1521 IIFORMAT_HAS_SHARED_METHOD (tree_view, post_instantiate, widget);
1497 IIFORMAT_HAS_SHARED_METHOD (tree_view, governing_domain, subwindow); 1522 IIFORMAT_HAS_SHARED_METHOD (tree_view, governing_domain, subwindow);
1498 IIFORMAT_HAS_SHARED_METHOD (tree_view, update, tab_control);
1499 IIFORMAT_HAS_METHOD (tree_view, query_geometry); 1523 IIFORMAT_HAS_METHOD (tree_view, query_geometry);
1500 VALID_WIDGET_KEYWORDS (tree_view); 1524 VALID_WIDGET_KEYWORDS (tree_view);
1501 VALID_GUI_KEYWORDS (tree_view); 1525 VALID_GUI_KEYWORDS (tree_view);
1502 IIFORMAT_VALID_KEYWORD (tree_view, Q_items, check_valid_item_list); 1526 IIFORMAT_VALID_KEYWORD (tree_view, Q_items, check_valid_item_list);
1503 } 1527 }
1509 IIFORMAT_HAS_SHARED_METHOD (tab_control, possible_dest_types, widget); 1533 IIFORMAT_HAS_SHARED_METHOD (tab_control, possible_dest_types, widget);
1510 IIFORMAT_HAS_SHARED_METHOD (tab_control, instantiate, widget); 1534 IIFORMAT_HAS_SHARED_METHOD (tab_control, instantiate, widget);
1511 IIFORMAT_HAS_SHARED_METHOD (tab_control, post_instantiate, widget); 1535 IIFORMAT_HAS_SHARED_METHOD (tab_control, post_instantiate, widget);
1512 IIFORMAT_HAS_SHARED_METHOD (tab_control, governing_domain, subwindow); 1536 IIFORMAT_HAS_SHARED_METHOD (tab_control, governing_domain, subwindow);
1513 IIFORMAT_HAS_METHOD (tab_control, query_geometry); 1537 IIFORMAT_HAS_METHOD (tab_control, query_geometry);
1514 IIFORMAT_HAS_METHOD (tab_control, update);
1515 VALID_WIDGET_KEYWORDS (tab_control); 1538 VALID_WIDGET_KEYWORDS (tab_control);
1516 VALID_GUI_KEYWORDS (tab_control); 1539 VALID_GUI_KEYWORDS (tab_control);
1517 IIFORMAT_VALID_KEYWORD (tab_control, Q_orientation, 1540 IIFORMAT_VALID_KEYWORD (tab_control, Q_orientation,
1518 check_valid_tab_orientation); 1541 check_valid_tab_orientation);
1519 IIFORMAT_VALID_KEYWORD (tab_control, Q_items, check_valid_item_list); 1542 IIFORMAT_VALID_KEYWORD (tab_control, Q_items, check_valid_item_list);