Mercurial > hg > xemacs-beta
comparison src/toolbar.c @ 286:57709be46d1b r21-0b41
Import from CVS: tag r21-0b41
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:35:03 +0200 |
parents | 558f606b08ae |
children | 8626e4521993 |
comparison
equal
deleted
inserted
replaced
285:9a3756523c1b | 286:57709be46d1b |
---|---|
54 Lisp_Object Q_size; | 54 Lisp_Object Q_size; |
55 | 55 |
56 Lisp_Object Qinit_toolbar_from_resources; | 56 Lisp_Object Qinit_toolbar_from_resources; |
57 | 57 |
58 | 58 |
59 static Lisp_Object | |
60 mark_toolbar_data (Lisp_Object obj, void (*markobj) (Lisp_Object)) | |
61 { | |
62 struct toolbar_data *data = (struct toolbar_data *) XPNTR (obj); | |
63 ((markobj) (data->last_toolbar_buffer)); | |
64 return data->toolbar_buttons; | |
65 } | |
66 | |
67 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-data", toolbar_data, | |
68 mark_toolbar_data, internal_object_printer, | |
69 0, 0, 0, struct toolbar_data); | |
70 | |
71 static Lisp_Object | 59 static Lisp_Object |
72 mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 60 mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
73 { | 61 { |
74 struct toolbar_button *data = (struct toolbar_button *) XPNTR (obj); | 62 struct toolbar_button *data = (struct toolbar_button *) XPNTR (obj); |
75 ((markobj) (data->next)); | 63 ((markobj) (data->next)); |
599 } | 587 } |
600 | 588 |
601 void | 589 void |
602 mark_frame_toolbar_buttons_dirty (struct frame *f, enum toolbar_pos pos) | 590 mark_frame_toolbar_buttons_dirty (struct frame *f, enum toolbar_pos pos) |
603 { | 591 { |
604 Lisp_Object button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons; | 592 Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, pos); |
605 | 593 |
606 while (!NILP (button)) | 594 while (!NILP (button)) |
607 { | 595 { |
608 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | 596 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); |
609 tb->dirty = 1; | 597 tb->dirty = 1; |
619 Lisp_Object buttons, prev_button, first_button; | 607 Lisp_Object buttons, prev_button, first_button; |
620 Lisp_Object orig_toolbar = toolbar; | 608 Lisp_Object orig_toolbar = toolbar; |
621 int pushright_seen = 0; | 609 int pushright_seen = 0; |
622 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | 610 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
623 | 611 |
624 first_button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons; | 612 first_button = FRAME_TOOLBAR_BUTTONS (f, pos); |
625 buttons = prev_button = first_button; | 613 buttons = prev_button = first_button; |
626 | 614 |
627 /* Yes, we're being paranoid. */ | 615 /* Yes, we're being paranoid. */ |
628 GCPRO5 (toolbar, buttons, prev_button, first_button, orig_toolbar); | 616 GCPRO5 (toolbar, buttons, prev_button, first_button, orig_toolbar); |
629 | 617 |
722 } | 710 } |
723 | 711 |
724 static void | 712 static void |
725 set_frame_toolbar (struct frame *f, enum toolbar_pos pos) | 713 set_frame_toolbar (struct frame *f, enum toolbar_pos pos) |
726 { | 714 { |
727 Lisp_Object toolbar, buttons; | |
728 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); | 715 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); |
729 Lisp_Object buffer = w->buffer; | 716 Lisp_Object toolbar = w->toolbar[pos]; |
730 | 717 f->toolbar_buttons[pos] = (FRAME_REAL_TOOLBAR_VISIBLE (f, pos) |
731 if (!f->toolbar_changed | 718 ? compute_frame_toolbar_buttons (f, pos, toolbar) |
732 && !NILP (f->toolbar_data[pos]) | 719 : Qnil); |
733 && EQ (FRAME_TOOLBAR_DATA (f, pos)->last_toolbar_buffer, buffer)) | |
734 return; | |
735 | |
736 toolbar = w->toolbar[pos]; | |
737 | |
738 if (NILP (f->toolbar_data[pos])) | |
739 { | |
740 struct toolbar_data *td = alloc_lcrecord_type (struct toolbar_data, | |
741 lrecord_toolbar_data); | |
742 | |
743 td->last_toolbar_buffer = Qnil; | |
744 td->toolbar_buttons = Qnil; | |
745 XSETTOOLBAR_DATA (f->toolbar_data[pos], td); | |
746 } | |
747 | |
748 buttons = (FRAME_REAL_TOOLBAR_VISIBLE (f, pos) | |
749 ? compute_frame_toolbar_buttons (f, pos, toolbar) : Qnil); | |
750 | |
751 FRAME_TOOLBAR_DATA (f, pos)->last_toolbar_buffer = buffer; | |
752 FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons = buttons; | |
753 } | 720 } |
754 | 721 |
755 static void | 722 static void |
756 compute_frame_toolbars_data (struct frame *f, int first_time_p) | 723 compute_frame_toolbars_data (struct frame *f) |
757 { | 724 { |
758 set_frame_toolbar (f, TOP_TOOLBAR); | 725 set_frame_toolbar (f, TOP_TOOLBAR); |
759 set_frame_toolbar (f, BOTTOM_TOOLBAR); | 726 set_frame_toolbar (f, BOTTOM_TOOLBAR); |
760 set_frame_toolbar (f, LEFT_TOOLBAR); | 727 set_frame_toolbar (f, LEFT_TOOLBAR); |
761 set_frame_toolbar (f, RIGHT_TOOLBAR); | 728 set_frame_toolbar (f, RIGHT_TOOLBAR); |
763 | 730 |
764 void | 731 void |
765 update_frame_toolbars (struct frame *f) | 732 update_frame_toolbars (struct frame *f) |
766 { | 733 { |
767 struct device *d = XDEVICE (f->device); | 734 struct device *d = XDEVICE (f->device); |
768 Lisp_Object buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer; | 735 |
769 | 736 if (DEVICE_SUPPORTS_TOOLBARS_P (d) |
770 /* If the buffer of the selected window is not equal to the | 737 && (f->toolbar_changed || f->frame_changed || f->clear)) |
771 last_toolbar_buffer value for any of the toolbars, then the | 738 { |
772 toolbars need to be recomputed. */ | 739 int pos; |
773 if ((HAS_DEVMETH_P (d, output_frame_toolbars)) | 740 |
774 && (f->toolbar_changed || f->frame_changed || f->clear | 741 /* We're not officially "in redisplay", so we still have a |
775 || !EQ (FRAME_TOOLBAR_BUFFER (f, TOP_TOOLBAR), buffer) | 742 chance to re-layout toolbars and windows. This is done here, |
776 || !EQ (FRAME_TOOLBAR_BUFFER (f, BOTTOM_TOOLBAR), buffer) | 743 because toolbar is the only thing which currently might |
777 || !EQ (FRAME_TOOLBAR_BUFFER (f, LEFT_TOOLBAR), buffer) | 744 necesseritate this layout, as it is outside any windows. We |
778 || !EQ (FRAME_TOOLBAR_BUFFER (f, RIGHT_TOOLBAR), buffer))) | 745 take care not to change size if toolbar geometry is really |
779 { | 746 unchanged, as it will hose windows whose pixsizes are not |
780 int width, height; | 747 multiple of character sizes */ |
781 | 748 |
782 /* We're not officially "in redisplay", so we still have a chance | 749 for (pos = 0; pos < 4; pos++) |
783 to re-layout toolbars and windows. This is done here, because | 750 if (FRAME_REAL_TOOLBAR_SIZE (f, pos) |
784 toolbar is the only thing which currently might necesseritate | 751 != FRAME_CURRENT_TOOLBAR_SIZE (f, pos)) |
785 this layout, as it is outside any windows */ | 752 { |
786 pixel_to_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), | 753 int width, height; |
787 &width, &height); | 754 pixel_to_char_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), |
788 change_frame_size (f, height, width, 0); | 755 &width, &height); |
756 change_frame_size (f, height, width, 0); | |
757 break; | |
758 } | |
759 | |
760 for (pos = 0; pos < 4; pos++) | |
761 f->current_toolbar_size[pos] = FRAME_REAL_TOOLBAR_SIZE (f, pos); | |
789 | 762 |
790 /* Removed the check for the minibuffer here. We handle this | 763 /* Removed the check for the minibuffer here. We handle this |
791 more correctly now by consistently using | 764 more correctly now by consistently using |
792 FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW | 765 FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW |
793 throughout the toolbar code. */ | 766 throughout the toolbar code. */ |
794 compute_frame_toolbars_data (f, 0); | 767 compute_frame_toolbars_data (f); |
795 | 768 |
796 DEVMETH (d, output_frame_toolbars, (f)); | 769 DEVMETH (d, output_frame_toolbars, (f)); |
797 } | 770 } |
798 | 771 |
799 f->toolbar_changed = 0; | 772 f->toolbar_changed = 0; |
802 void | 775 void |
803 init_frame_toolbars (struct frame *f) | 776 init_frame_toolbars (struct frame *f) |
804 { | 777 { |
805 struct device *d = XDEVICE (f->device); | 778 struct device *d = XDEVICE (f->device); |
806 | 779 |
807 /* If there isn't any output routine, then this device type doesn't | 780 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) |
808 support toolbars. */ | |
809 if (HAS_DEVMETH_P (d, output_frame_toolbars)) | |
810 { | 781 { |
811 Lisp_Object frame; | 782 Lisp_Object frame; |
812 | 783 int pos; |
813 compute_frame_toolbars_data (f, 1); | 784 |
785 compute_frame_toolbars_data (f); | |
814 XSETFRAME (frame, f); | 786 XSETFRAME (frame, f); |
815 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)), | 787 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)), |
816 Qinit_toolbar_from_resources, | 788 Qinit_toolbar_from_resources, |
817 frame); | 789 frame); |
818 MAYBE_DEVMETH (d, initialize_frame_toolbars, (f)); | 790 MAYBE_DEVMETH (d, initialize_frame_toolbars, (f)); |
791 | |
792 /* We are here as far in frame creation so cached specifiers are | |
793 already recomputed, and possibly modified by resource | |
794 initialization. Remember current toolbar geometry so next | |
795 redisplay will not needlessly relayout toolbars. */ | |
796 for (pos = 0; pos < 4; pos++) | |
797 f->current_toolbar_size[pos] = FRAME_REAL_TOOLBAR_SIZE (f, pos); | |
819 } | 798 } |
820 } | 799 } |
821 | 800 |
822 void | 801 void |
823 init_device_toolbars (struct device *d) | 802 init_device_toolbars (struct device *d) |
824 { | 803 { |
825 Lisp_Object device; | 804 Lisp_Object device; |
826 | 805 |
827 XSETDEVICE (device, d); | 806 XSETDEVICE (device, d); |
828 if (HAS_DEVMETH_P (d, output_frame_toolbars)) | 807 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) |
829 call_critical_lisp_code (d, | 808 call_critical_lisp_code (d, |
830 Qinit_toolbar_from_resources, | 809 Qinit_toolbar_from_resources, |
831 device); | 810 device); |
832 } | 811 } |
833 | 812 |
834 void | 813 void |
835 init_global_toolbars (struct device *d) | 814 init_global_toolbars (struct device *d) |
836 { | 815 { |
837 if (HAS_DEVMETH_P (d, output_frame_toolbars)) | 816 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) |
838 call_critical_lisp_code (d, | 817 call_critical_lisp_code (d, |
839 Qinit_toolbar_from_resources, | 818 Qinit_toolbar_from_resources, |
840 Qglobal); | 819 Qglobal); |
841 } | 820 } |
842 | 821 |
920 { \ | 899 { \ |
921 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \ | 900 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \ |
922 if ((x_coord >= x) && (x_coord < (x + width))) \ | 901 if ((x_coord >= x) && (x_coord < (x + width))) \ |
923 { \ | 902 { \ |
924 if ((y_coord >= y) && (y_coord < (y + height))) \ | 903 if ((y_coord >= y) && (y_coord < (y + height))) \ |
925 return FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons; \ | 904 return FRAME_TOOLBAR_BUTTONS (f, pos); \ |
926 } \ | 905 } \ |
927 } while (0) | 906 } while (0) |
928 | 907 |
929 static Lisp_Object | 908 static Lisp_Object |
930 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord) | 909 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord) |