comparison src/toolbar-x.c @ 282:c42ec1d1cded r21-0b39

Import from CVS: tag r21-0b39
author cvs
date Mon, 13 Aug 2007 10:33:18 +0200
parents c5d627a313b1
children 57709be46d1b
comparison
equal deleted inserted replaced
281:090b52736db2 282:c42ec1d1cded
654 FRAME_PIXHEIGHT (f)); 654 FRAME_PIXHEIGHT (f));
655 } 655 }
656 656
657 657
658 static void 658 static void
659 x_toolbar_size_changed_in_frame_1 (struct frame *f, enum toolbar_pos pos,
660 Lisp_Object old_visibility)
661 {
662 XtWidgetGeometry req, repl;
663 int newval;
664 int oldval = FRAME_X_OLD_TOOLBAR_SIZE (f, pos);
665
666 if (NILP (f->toolbar_visible_p[pos]))
667 newval = 0;
668 else if (!f->init_finished && !INTP (f->toolbar_size[pos]))
669 /* the size might not be set at all if we're in the process of
670 creating the frame. Otherwise it better be, and we'll crash
671 out if not. */
672 newval = 0;
673 else
674 {
675 Lisp_Object frame;
676
677 XSETFRAME (frame, f);
678 newval = XINT (Fspecifier_instance (Vtoolbar_size[pos], frame, Qzero,
679 Qnil));
680 }
681
682 if (oldval == newval)
683 return;
684
685 /* We want the text area to stay the same size. So, we query the
686 current size and then adjust it for the change in the toolbar
687 size. */
688
689 in_specifier_change_function++;
690
691 if (!in_resource_setting)
692 /* mirror the value in the frame resources, unless already done. */
693 Xt_SET_VALUE (FRAME_X_CONTAINER_WIDGET (f),
694 pos == TOP_TOOLBAR ? XtNtopToolBarHeight :
695 pos == BOTTOM_TOOLBAR ? XtNbottomToolBarHeight :
696 pos == LEFT_TOOLBAR ? XtNleftToolBarWidth :
697 XtNrightToolBarWidth,
698 newval);
699
700 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f)))
701 {
702 int change = newval - oldval;
703 Lisp_Object new_visibility = f->toolbar_visible_p[pos];
704
705 req.request_mode = 0;
706 /* the query-geometry method looks at the current value of
707 f->toolbar_size[pos], so temporarily set it back to the old
708 one. If we were called because of a visibility change we
709 also have to temporarily restore its old status as well. */
710 f->toolbar_size[pos] = make_int (oldval);
711 if (!EQ (old_visibility, Qzero))
712 f->toolbar_visible_p[pos] = old_visibility;
713 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
714 f->toolbar_size[pos] = make_int (newval);
715 if (!EQ (old_visibility, Qzero))
716 f->toolbar_visible_p[pos] = new_visibility;
717
718 if (change < 0)
719 {
720 x_clear_toolbar (f, pos, change);
721 mark_frame_toolbar_buttons_dirty (f, pos);
722 }
723 if (pos == LEFT_TOOLBAR || pos == RIGHT_TOOLBAR)
724 repl.width += change;
725 else
726 repl.height += change;
727
728 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
729 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
730 repl.height);
731 }
732 /* #### should this go within XtIsRealized()? probably not ... */
733 FRAME_X_OLD_TOOLBAR_SIZE (f, pos) = newval;
734 in_specifier_change_function--;
735 }
736
737 static void
738 x_toolbar_size_changed_in_frame (struct frame *f, enum toolbar_pos pos,
739 Lisp_Object oldval)
740 {
741 x_toolbar_size_changed_in_frame_1 (f, pos, Qzero);
742 }
743
744 static void
745 x_toolbar_visible_p_changed_in_frame (struct frame *f, enum toolbar_pos pos,
746 Lisp_Object oldval)
747 {
748 x_toolbar_size_changed_in_frame_1 (f, pos, oldval);
749 }
750
751 static void
752 x_toolbar_border_width_changed_in_frame (struct frame *f, enum toolbar_pos pos,
753 Lisp_Object lispoldval)
754 {
755 XtWidgetGeometry req, repl;
756 int newval, oldval;
757
758 if (NILP (f->toolbar_visible_p[pos]) || ZEROP (f->toolbar_size[pos]))
759 {
760 return;
761 }
762 else if (!f->init_finished && !INTP (f->toolbar_border_width[pos]))
763 /* the size might not be set at all if we're in the process of
764 creating the frame. Otherwise it better be, and we'll crash
765 out if not. */
766 {
767 newval = 0;
768 }
769 else
770 {
771 Lisp_Object frame;
772
773 XSETFRAME (frame, f);
774 newval = XINT (Fspecifier_instance (Vtoolbar_border_width[pos],
775 frame, Qzero, Qnil));
776 }
777
778 if (INTP (lispoldval))
779 oldval = XINT (lispoldval);
780 else
781 oldval = 0;
782
783 if (oldval == newval)
784 return;
785
786 /* We want the text area to stay the same size. So, we query the
787 current size and then adjust it for the change in the toolbar
788 size. */
789
790 in_specifier_change_function++;
791
792 if (!in_resource_setting)
793 /* mirror the value in the frame resources, unless already done. */
794 Xt_SET_VALUE (FRAME_X_TEXT_WIDGET (f),
795 pos == TOP_TOOLBAR ? XtNtopToolBarBorderWidth :
796 pos == BOTTOM_TOOLBAR ? XtNbottomToolBarBorderWidth :
797 pos == LEFT_TOOLBAR ? XtNleftToolBarBorderWidth :
798 XtNrightToolBarBorderWidth,
799 newval);
800
801 if (XtIsRealized (FRAME_X_CONTAINER_WIDGET (f)))
802 {
803 int change = 2 * (newval - oldval);
804
805 req.request_mode = 0;
806
807 /*
808 * We want the current size, not the future size, so briefly
809 * reset the border width value so the query method returns
810 * the correct value.
811 */
812 f->toolbar_border_width[pos] = make_int (oldval);
813 XtQueryGeometry (FRAME_X_CONTAINER_WIDGET (f), &req, &repl);
814 f->toolbar_border_width[pos] = make_int (newval);
815
816 if (change < 0)
817 {
818 x_clear_toolbar (f, pos, change);
819 mark_frame_toolbar_buttons_dirty (f, pos);
820 }
821 if (pos == LEFT_TOOLBAR || pos == RIGHT_TOOLBAR)
822 repl.width += change;
823 else
824 repl.height += change;
825
826 MARK_FRAME_WINDOWS_STRUCTURE_CHANGED (f);
827 EmacsManagerChangeSize (FRAME_X_CONTAINER_WIDGET (f), repl.width,
828 repl.height);
829 }
830 in_specifier_change_function--;
831 }
832
833 static void
834 x_initialize_frame_toolbar_gcs (struct frame *f) 659 x_initialize_frame_toolbar_gcs (struct frame *f)
835 { 660 {
836 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f); 661 EmacsFrame ef = (EmacsFrame) FRAME_X_TEXT_WIDGET (f);
837 EmacsFramePart *efp = &(ef->emacs_frame); 662 EmacsFramePart *efp = &(ef->emacs_frame);
838 XGCValues gcv; 663 XGCValues gcv;
969 CONSOLE_HAS_METHOD (x, initialize_frame_toolbars); 794 CONSOLE_HAS_METHOD (x, initialize_frame_toolbars);
970 CONSOLE_HAS_METHOD (x, free_frame_toolbars); 795 CONSOLE_HAS_METHOD (x, free_frame_toolbars);
971 CONSOLE_HAS_METHOD (x, output_toolbar_button); 796 CONSOLE_HAS_METHOD (x, output_toolbar_button);
972 CONSOLE_HAS_METHOD (x, redraw_exposed_toolbars); 797 CONSOLE_HAS_METHOD (x, redraw_exposed_toolbars);
973 CONSOLE_HAS_METHOD (x, redraw_frame_toolbars); 798 CONSOLE_HAS_METHOD (x, redraw_frame_toolbars);
974 CONSOLE_HAS_METHOD (x, toolbar_size_changed_in_frame); 799 }
975 CONSOLE_HAS_METHOD (x, toolbar_border_width_changed_in_frame);
976 CONSOLE_HAS_METHOD (x, toolbar_visible_p_changed_in_frame);
977 }