Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 406:b8cc9ab3f761 r21-2-33
Import from CVS: tag r21-2-33
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:17:09 +0200 |
parents | 2f8bb876ab1d |
children | 501cfd01ee6d |
comparison
equal
deleted
inserted
replaced
405:0e08f63c74d2 | 406:b8cc9ab3f761 |
---|---|
262 { | 262 { |
263 rd = *ip++; | 263 rd = *ip++; |
264 gr = *ip++; | 264 gr = *ip++; |
265 bl = *ip++; | 265 bl = *ip++; |
266 conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)]; | 266 conv.val = pixarray[QUANT_GET_COLOR(qtable,rd,gr,bl)]; |
267 #if WORDS_BIGENDIAN | 267 #ifdef WORDS_BIGENDIAN |
268 if (outimg->byte_order == MSBFirst) | 268 if (outimg->byte_order == MSBFirst) |
269 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q]; | 269 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q]; |
270 else | 270 else |
271 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q]; | 271 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q]; |
272 #else | 272 #else |
337 bl = *ip++ << (bbits - 8); | 337 bl = *ip++ << (bbits - 8); |
338 else | 338 else |
339 bl = *ip++ >> (8 - bbits); | 339 bl = *ip++ >> (8 - bbits); |
340 | 340 |
341 conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift); | 341 conv.val = (rd << rshift) | (gr << gshift) | (bl << bshift); |
342 #if WORDS_BIGENDIAN | 342 #ifdef WORDS_BIGENDIAN |
343 if (outimg->byte_order == MSBFirst) | 343 if (outimg->byte_order == MSBFirst) |
344 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q]; | 344 for (q = 4-byte_cnt; q < 4; q++) *dp++ = conv.cp[q]; |
345 else | 345 else |
346 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q]; | 346 for (q = 3; q >= 4-byte_cnt; q--) *dp++ = conv.cp[q]; |
347 #else | 347 #else |
2187 /* First get the items if they have changed since this is a | 2187 /* First get the items if they have changed since this is a |
2188 structural change. As such it will nuke all added values so we | 2188 structural change. As such it will nuke all added values so we |
2189 need to update most other things after the items have changed.*/ | 2189 need to update most other things after the items have changed.*/ |
2190 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) | 2190 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) |
2191 { | 2191 { |
2192 /* Pick up the items we recorded earlier. We do this here so | 2192 Lisp_Object image_instance; |
2193 that the callbacks get set up with the new items. */ | 2193 |
2194 IMAGE_INSTANCE_WIDGET_ITEMS (p) = | 2194 XSETIMAGE_INSTANCE (image_instance, p); |
2195 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p); | |
2196 IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p) = Qnil; | |
2197 | |
2198 wv = gui_items_to_widget_values | 2195 wv = gui_items_to_widget_values |
2199 (IMAGE_INSTANCE_WIDGET_ITEMS (p)); | 2196 (image_instance, IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (p)); |
2200 wv->change = STRUCTURAL_CHANGE; | 2197 wv->change = STRUCTURAL_CHANGE; |
2201 /* now modify the widget */ | 2198 /* now modify the widget */ |
2202 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), | 2199 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), |
2203 wv, True); | 2200 wv, True); |
2204 free_widget_value_tree (wv); | 2201 free_widget_value_tree (wv); |
2209 | 2206 |
2210 if (!wv) | 2207 if (!wv) |
2211 return; | 2208 return; |
2212 | 2209 |
2213 /* Possibly update the colors and font */ | 2210 /* Possibly update the colors and font */ |
2214 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) | 2211 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (p) |
2215 || | 2212 || |
2216 XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (p))->faces_changed | 2213 XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (p))->faces_changed |
2217 || | 2214 || |
2218 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) | 2215 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) |
2219 { | 2216 { |
2232 } | 2229 } |
2233 | 2230 |
2234 /* Possibly update the size. */ | 2231 /* Possibly update the size. */ |
2235 if (IMAGE_INSTANCE_SIZE_CHANGED (p) | 2232 if (IMAGE_INSTANCE_SIZE_CHANGED (p) |
2236 || | 2233 || |
2237 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p)) | 2234 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (p) |
2235 || | |
2236 IMAGE_INSTANCE_TEXT_CHANGED (p)) | |
2238 { | 2237 { |
2239 assert (IMAGE_INSTANCE_X_WIDGET_ID (p) && | 2238 assert (IMAGE_INSTANCE_X_WIDGET_ID (p) && |
2240 IMAGE_INSTANCE_X_CLIPWIDGET (p)) ; | 2239 IMAGE_INSTANCE_X_CLIPWIDGET (p)) ; |
2241 | 2240 |
2242 if (IMAGE_INSTANCE_X_WIDGET_ID (p)->core.being_destroyed | 2241 if (IMAGE_INSTANCE_X_WIDGET_ID (p)->core.being_destroyed |
2501 wid = lw_create_widget (type, wv->name, id, wv, IMAGE_INSTANCE_X_CLIPWIDGET (ii), | 2500 wid = lw_create_widget (type, wv->name, id, wv, IMAGE_INSTANCE_X_CLIPWIDGET (ii), |
2502 False, 0, popup_selection_callback, 0); | 2501 False, 0, popup_selection_callback, 0); |
2503 | 2502 |
2504 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid; | 2503 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = (void*)wid; |
2505 IMAGE_INSTANCE_X_WIDGET_LWID (ii) = id; | 2504 IMAGE_INSTANCE_X_WIDGET_LWID (ii) = id; |
2506 #if 0 | |
2507 /* Resize the widget here so that the values do not get copied by | |
2508 lwlib. */ | |
2509 ac = 0; | |
2510 XtSetArg (al [ac], XtNwidth, | |
2511 (Dimension)IMAGE_INSTANCE_SUBWINDOW_WIDTH (ii)); ac++; | |
2512 XtSetArg (al [ac], XtNheight, | |
2513 (Dimension)IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii)); ac++; | |
2514 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac); | |
2515 #endif | |
2516 /* because the EmacsManager is the widgets parent we have to | 2505 /* because the EmacsManager is the widgets parent we have to |
2517 offset the redisplay of the widget by the amount the text | 2506 offset the redisplay of the widget by the amount the text |
2518 widget is inside the manager. */ | 2507 widget is inside the manager. */ |
2519 ac = 0; | 2508 ac = 0; |
2520 XtSetArg (al [ac], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (ii)); ac++; | 2509 XtSetArg (al [ac], XtNx, &IMAGE_INSTANCE_X_WIDGET_XOFFSET (ii)); ac++; |
2552 int dest_mask, Lisp_Object domain) | 2541 int dest_mask, Lisp_Object domain) |
2553 { | 2542 { |
2554 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2543 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2555 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2544 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2556 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); | 2545 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); |
2557 widget_value* wv = xmalloc_widget_value (); | 2546 widget_value* wv = gui_items_to_widget_values (image_instance, gui); |
2558 | |
2559 button_item_to_widget_value (gui, wv, 1, 1); | |
2560 | 2547 |
2561 if (!NILP (glyph)) | 2548 if (!NILP (glyph)) |
2562 { | 2549 { |
2563 if (!IMAGE_INSTANCEP (glyph)) | 2550 if (!IMAGE_INSTANCEP (glyph)) |
2564 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); | 2551 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); |
2581 #endif | 2568 #endif |
2582 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac); | 2569 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, ac); |
2583 } | 2570 } |
2584 } | 2571 } |
2585 | 2572 |
2573 /* Update a button's clicked state. | |
2574 | |
2575 #### This is overkill, but it works. Right now this causes all | |
2576 button instances to flash for some reason buried deep in lwlib. In | |
2577 theory this should be the Right Thing to do since lwlib should only | |
2578 merge in changed values - and if nothing has changed then nothing | |
2579 should get done. This may be because of the args stuff, | |
2580 i.e. although the arg contents may be the same the args look | |
2581 different and so are re-applied to the widget. */ | |
2582 static void | |
2583 x_button_update (Lisp_Object image_instance) | |
2584 { | |
2585 /* This function can GC if IN_REDISPLAY is false. */ | |
2586 Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance); | |
2587 widget_value* wv = | |
2588 gui_items_to_widget_values (image_instance, | |
2589 IMAGE_INSTANCE_WIDGET_ITEMS (p)); | |
2590 | |
2591 /* now modify the widget */ | |
2592 lw_modify_all_widgets (IMAGE_INSTANCE_X_WIDGET_LWID (p), | |
2593 wv, True); | |
2594 free_widget_value_tree (wv); | |
2595 } | |
2596 | |
2586 /* get properties of a button */ | 2597 /* get properties of a button */ |
2587 static Lisp_Object | 2598 static Lisp_Object |
2588 x_button_property (Lisp_Object image_instance, Lisp_Object prop) | 2599 x_button_property (Lisp_Object image_instance, Lisp_Object prop) |
2589 { | 2600 { |
2590 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2601 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2607 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2618 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2608 int dest_mask, Lisp_Object domain) | 2619 int dest_mask, Lisp_Object domain) |
2609 { | 2620 { |
2610 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2621 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2611 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2622 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2612 widget_value* wv = xmalloc_widget_value (); | 2623 widget_value* wv = gui_items_to_widget_values (image_instance, gui); |
2613 | |
2614 button_item_to_widget_value (gui, wv, 1, 1); | |
2615 | 2624 |
2616 x_widget_instantiate (image_instance, instantiator, pointer_fg, | 2625 x_widget_instantiate (image_instance, instantiator, pointer_fg, |
2617 pointer_bg, dest_mask, domain, "progress", wv); | 2626 pointer_bg, dest_mask, domain, "progress", wv); |
2618 } | 2627 } |
2619 | 2628 |
2621 static void | 2630 static void |
2622 x_progress_gauge_update (Lisp_Object image_instance) | 2631 x_progress_gauge_update (Lisp_Object image_instance) |
2623 { | 2632 { |
2624 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2633 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2625 | 2634 |
2626 if (IMAGE_INSTANCE_WIDGET_PERCENT_CHANGED (ii)) | 2635 if (IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) |
2627 { | 2636 { |
2628 Arg al [1]; | 2637 Arg al [1]; |
2629 /* #### I'm not convinced we should store this in the plist. */ | 2638 Lisp_Object val; |
2630 Lisp_Object val = Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), | 2639 #ifdef ERROR_CHECK_GLYPHS |
2631 Q_percent, Qnil); | 2640 assert (GUI_ITEMP (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))); |
2641 #endif | |
2642 val = XGUI_ITEM (IMAGE_INSTANCE_WIDGET_PENDING_ITEMS (ii))->value; | |
2632 XtSetArg (al[0], XtNvalue, XINT (val)); | 2643 XtSetArg (al[0], XtNvalue, XINT (val)); |
2633 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 1); | 2644 XtSetValues (IMAGE_INSTANCE_X_WIDGET_ID (ii), al, 1); |
2634 } | 2645 } |
2635 } | 2646 } |
2636 | 2647 |
2640 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2651 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2641 int dest_mask, Lisp_Object domain) | 2652 int dest_mask, Lisp_Object domain) |
2642 { | 2653 { |
2643 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2654 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2644 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2655 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2645 widget_value* wv = xmalloc_widget_value (); | 2656 widget_value* wv = gui_items_to_widget_values (image_instance, gui); |
2646 | |
2647 button_item_to_widget_value (gui, wv, 1, 1); | |
2648 | 2657 |
2649 x_widget_instantiate (image_instance, instantiator, pointer_fg, | 2658 x_widget_instantiate (image_instance, instantiator, pointer_fg, |
2650 pointer_bg, dest_mask, domain, "text-field", wv); | 2659 pointer_bg, dest_mask, domain, "text-field", wv); |
2651 } | 2660 } |
2652 | 2661 |
2662 /* This is not done generically because of sizing problems under | 2671 /* This is not done generically because of sizing problems under |
2663 mswindows. */ | 2672 mswindows. */ |
2664 widget_instantiate (image_instance, instantiator, pointer_fg, | 2673 widget_instantiate (image_instance, instantiator, pointer_fg, |
2665 pointer_bg, dest_mask, domain); | 2674 pointer_bg, dest_mask, domain); |
2666 | 2675 |
2667 wv = gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii)); | 2676 wv = gui_items_to_widget_values (image_instance, |
2677 IMAGE_INSTANCE_WIDGET_ITEMS (ii)); | |
2668 | 2678 |
2669 x_widget_instantiate (image_instance, instantiator, pointer_fg, | 2679 x_widget_instantiate (image_instance, instantiator, pointer_fg, |
2670 pointer_bg, dest_mask, domain, "combo-box", wv); | 2680 pointer_bg, dest_mask, domain, "combo-box", wv); |
2671 } | 2681 } |
2672 #endif | 2682 #endif |
2676 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2686 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2677 int dest_mask, Lisp_Object domain) | 2687 int dest_mask, Lisp_Object domain) |
2678 { | 2688 { |
2679 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2689 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2680 widget_value * wv = | 2690 widget_value * wv = |
2681 gui_items_to_widget_values (IMAGE_INSTANCE_WIDGET_ITEMS (ii)); | 2691 gui_items_to_widget_values (image_instance, |
2692 IMAGE_INSTANCE_WIDGET_ITEMS (ii)); | |
2682 | 2693 |
2683 update_tab_widget_face (wv, ii, | 2694 update_tab_widget_face (wv, ii, |
2684 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); | 2695 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii)); |
2685 | 2696 |
2686 x_widget_instantiate (image_instance, instantiator, pointer_fg, | 2697 x_widget_instantiate (image_instance, instantiator, pointer_fg, |
2687 pointer_bg, dest_mask, domain, "tab-control", wv); | 2698 pointer_bg, dest_mask, domain, "tab-control", wv); |
2688 } | 2699 } |
2689 | 2700 |
2690 /* set the properties of a tab control */ | 2701 /* set the properties of a tab control */ |
2691 static void | 2702 static void |
2692 x_tab_control_update (Lisp_Object image_instance) | 2703 x_tab_control_update (Lisp_Object image_instance) |
2693 { | 2704 { |
2694 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2705 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2695 | 2706 |
2696 /* Possibly update the face. */ | 2707 /* Possibly update the face. */ |
2697 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii) | 2708 if (IMAGE_INSTANCE_WIDGET_FACE_CHANGED (ii) |
2698 || | 2709 || |
2699 XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii))->faces_changed | 2710 XFRAME (IMAGE_INSTANCE_SUBWINDOW_FRAME (ii))->faces_changed |
2700 || | 2711 || |
2701 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) | 2712 IMAGE_INSTANCE_WIDGET_ITEMS_CHANGED (ii)) |
2702 { | 2713 { |
2719 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 2730 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
2720 int dest_mask, Lisp_Object domain) | 2731 int dest_mask, Lisp_Object domain) |
2721 { | 2732 { |
2722 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); | 2733 Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); |
2723 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); | 2734 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); |
2724 widget_value* wv = xmalloc_widget_value (); | 2735 widget_value* wv = gui_items_to_widget_values (image_instance, gui); |
2725 | |
2726 button_item_to_widget_value (gui, wv, 1, 1); | |
2727 | 2736 |
2728 x_widget_instantiate (image_instance, instantiator, pointer_fg, | 2737 x_widget_instantiate (image_instance, instantiator, pointer_fg, |
2729 pointer_bg, dest_mask, domain, "button", wv); | 2738 pointer_bg, dest_mask, domain, "button", wv); |
2730 } | 2739 } |
2731 #endif /* HAVE_WIDGETS */ | 2740 #endif /* HAVE_WIDGETS */ |
2793 #ifdef HAVE_WIDGETS | 2802 #ifdef HAVE_WIDGETS |
2794 /* button widget */ | 2803 /* button widget */ |
2795 INITIALIZE_DEVICE_IIFORMAT (x, button); | 2804 INITIALIZE_DEVICE_IIFORMAT (x, button); |
2796 IIFORMAT_HAS_DEVMETHOD (x, button, property); | 2805 IIFORMAT_HAS_DEVMETHOD (x, button, property); |
2797 IIFORMAT_HAS_DEVMETHOD (x, button, instantiate); | 2806 IIFORMAT_HAS_DEVMETHOD (x, button, instantiate); |
2807 IIFORMAT_HAS_DEVMETHOD (x, button, update); | |
2798 | 2808 |
2799 INITIALIZE_DEVICE_IIFORMAT (x, widget); | 2809 INITIALIZE_DEVICE_IIFORMAT (x, widget); |
2800 IIFORMAT_HAS_DEVMETHOD (x, widget, property); | 2810 IIFORMAT_HAS_DEVMETHOD (x, widget, property); |
2801 /* progress gauge */ | 2811 /* progress gauge */ |
2802 INITIALIZE_DEVICE_IIFORMAT (x, progress_gauge); | 2812 INITIALIZE_DEVICE_IIFORMAT (x, progress_gauge); |