comparison src/toolbar.c @ 215:1f0dabaa0855 r20-4b6

Import from CVS: tag r20-4b6
author cvs
date Mon, 13 Aug 2007 10:07:35 +0200
parents 3d6bfa290dbd
children 51092a27c943
comparison
equal deleted inserted replaced
214:c5d88c05e1e9 215:1f0dabaa0855
38 #include "window.h" 38 #include "window.h"
39 39
40 Lisp_Object Vtoolbar[4]; 40 Lisp_Object Vtoolbar[4];
41 Lisp_Object Vtoolbar_size[4]; 41 Lisp_Object Vtoolbar_size[4];
42 Lisp_Object Vtoolbar_visible_p[4]; 42 Lisp_Object Vtoolbar_visible_p[4];
43 Lisp_Object Vtoolbar_border_width[4];
43 44
44 Lisp_Object Vdefault_toolbar, Vdefault_toolbar_visible_p; 45 Lisp_Object Vdefault_toolbar, Vdefault_toolbar_visible_p;
45 Lisp_Object Vdefault_toolbar_width, Vdefault_toolbar_height; 46 Lisp_Object Vdefault_toolbar_width, Vdefault_toolbar_height;
47 Lisp_Object Vdefault_toolbar_border_width;
46 48
47 Lisp_Object Vdefault_toolbar_position; 49 Lisp_Object Vdefault_toolbar_position;
48 Lisp_Object Vtoolbar_buttons_captioned_p; 50 Lisp_Object Vtoolbar_buttons_captioned_p;
49 51
50 Lisp_Object Qtoolbar_buttonp; 52 Lisp_Object Qtoolbar_buttonp;
273 set_specifier_fallback (Vtoolbar_size[cur], list1 (Fcons (Qnil, Qzero))); 275 set_specifier_fallback (Vtoolbar_size[cur], list1 (Fcons (Qnil, Qzero)));
274 set_specifier_fallback (Vtoolbar_size[new], 276 set_specifier_fallback (Vtoolbar_size[new],
275 new == TOP_TOOLBAR || new == BOTTOM_TOOLBAR 277 new == TOP_TOOLBAR || new == BOTTOM_TOOLBAR
276 ? Vdefault_toolbar_height 278 ? Vdefault_toolbar_height
277 : Vdefault_toolbar_width); 279 : Vdefault_toolbar_width);
280 set_specifier_fallback (Vtoolbar_border_width[cur],
281 list1 (Fcons (Qnil, Qzero)));
282 set_specifier_fallback (Vtoolbar_border_width[new],
283 Vdefault_toolbar_border_width);
278 set_specifier_fallback (Vtoolbar_visible_p[cur], 284 set_specifier_fallback (Vtoolbar_visible_p[cur],
279 list1 (Fcons (Qnil, Qt))); 285 list1 (Fcons (Qnil, Qt)));
280 set_specifier_fallback (Vtoolbar_visible_p[new], 286 set_specifier_fallback (Vtoolbar_visible_p[new],
281 Vdefault_toolbar_visible_p); 287 Vdefault_toolbar_visible_p);
282 Vdefault_toolbar_position = position; 288 Vdefault_toolbar_position = position;
590 device-dependent code. */ 596 device-dependent code. */
591 UNGCPRO; 597 UNGCPRO;
592 return retval; 598 return retval;
593 } 599 }
594 600
601 void
602 mark_frame_toolbar_buttons_dirty (struct frame *f, enum toolbar_pos pos)
603 {
604 Lisp_Object button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons;
605
606 while (!NILP (button))
607 {
608 struct toolbar_button *tb = XTOOLBAR_BUTTON (button);
609 tb->dirty = 1;
610 button = tb->next;
611 }
612 return;
613 }
614
595 static Lisp_Object 615 static Lisp_Object
596 compute_frame_toolbar_buttons (struct frame *f, enum toolbar_pos pos, 616 compute_frame_toolbar_buttons (struct frame *f, enum toolbar_pos pos,
597 Lisp_Object toolbar) 617 Lisp_Object toolbar)
598 { 618 {
599 Lisp_Object buttons, prev_button, first_button; 619 Lisp_Object buttons, prev_button, first_button;
862 int adjust = (for_layout ? 1 : 0); 882 int adjust = (for_layout ? 1 : 0);
863 883
864 /* The top and bottom toolbars take precedence over the left and 884 /* The top and bottom toolbars take precedence over the left and
865 right. */ 885 right. */
866 visible_top_toolbar_height = (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f) 886 visible_top_toolbar_height = (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)
867 ? FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) 887 ? FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) +
888 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f)
868 : 0); 889 : 0);
869 visible_bottom_toolbar_height = (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f) 890 visible_bottom_toolbar_height = (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)
870 ? FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) 891 ? FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) +
892 2 *
893 FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f)
871 : 0); 894 : 0);
872 895
873 /* We adjust the width and height by one to give us a narrow border 896 /* We adjust the width and height by one to give us a narrow border
874 at the outside edges. However, when we are simply determining 897 at the outside edges. However, when we are simply determining
875 toolbar location we don't want to do that. */ 898 toolbar location we don't want to do that. */
878 { 901 {
879 case TOP_TOOLBAR: 902 case TOP_TOOLBAR:
880 *x = 1; 903 *x = 1;
881 *y = 0; /* #### should be 1 if no menubar */ 904 *y = 0; /* #### should be 1 if no menubar */
882 *width = FRAME_PIXWIDTH (f) - 2; 905 *width = FRAME_PIXWIDTH (f) - 2;
883 *height = FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - adjust; 906 *height = FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) +
907 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) - adjust;
884 *vert = 0; 908 *vert = 0;
885 break; 909 break;
886 case BOTTOM_TOOLBAR: 910 case BOTTOM_TOOLBAR:
887 *x = 1; 911 *x = 1;
888 *y = FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f); 912 *y = FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) -
913 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f);
889 *width = FRAME_PIXWIDTH (f) - 2; 914 *width = FRAME_PIXWIDTH (f) - 2;
890 *height = FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) - adjust; 915 *height = FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) +
916 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f) - adjust;
891 *vert = 0; 917 *vert = 0;
892 break; 918 break;
893 case LEFT_TOOLBAR: 919 case LEFT_TOOLBAR:
894 *x = 1; 920 *x = 1;
895 *y = visible_top_toolbar_height; 921 *y = visible_top_toolbar_height;
896 *width = FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - adjust; 922 *width = FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) +
923 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) - adjust;
897 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height - 924 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
898 visible_bottom_toolbar_height - 1); 925 visible_bottom_toolbar_height - 1);
899 *vert = 1; 926 *vert = 1;
900 break; 927 break;
901 case RIGHT_TOOLBAR: 928 case RIGHT_TOOLBAR:
902 *x = FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f); 929 *x = FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) -
930 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f);
903 *y = visible_top_toolbar_height; 931 *y = visible_top_toolbar_height;
904 *width = FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) - adjust; 932 *width = FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) +
933 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f) - adjust;
905 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height - 934 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
906 visible_bottom_toolbar_height); 935 visible_bottom_toolbar_height);
907 *vert = 1; 936 *vert = 1;
908 break; 937 break;
909 default: 938 default:
1239 /* Let redisplay know that something has possibly changed. */ 1268 /* Let redisplay know that something has possibly changed. */
1240 MARK_TOOLBAR_CHANGED; 1269 MARK_TOOLBAR_CHANGED;
1241 } 1270 }
1242 1271
1243 static void 1272 static void
1273 toolbar_border_width_changed_in_frame (Lisp_Object specifier, struct frame *f,
1274 Lisp_Object oldval)
1275 {
1276 int pos;
1277
1278 for (pos = 0; pos < countof (Vtoolbar_border_width); pos++)
1279 {
1280 if (EQ (specifier, Vtoolbar_border_width[(enum toolbar_pos) pos]))
1281 break;
1282 }
1283
1284 assert (pos < countof (Vtoolbar_border_width));
1285
1286 MAYBE_FRAMEMETH (f, toolbar_border_width_changed_in_frame,
1287 (f, (enum toolbar_pos) pos, oldval));
1288
1289 /* Let redisplay know that something has possibly changed. */
1290 MARK_TOOLBAR_CHANGED;
1291 }
1292
1293 static void
1244 toolbar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f, 1294 toolbar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
1245 Lisp_Object oldval) 1295 Lisp_Object oldval)
1246 { 1296 {
1247 int pos; 1297 int pos;
1248 1298
1264 Lisp_Object oldval) 1314 Lisp_Object oldval)
1265 { 1315 {
1266 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position); 1316 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
1267 1317
1268 Fset_specifier_dirty_flag (Vtoolbar_size[pos]); 1318 Fset_specifier_dirty_flag (Vtoolbar_size[pos]);
1319
1320 /* Let redisplay know that something has possibly changed. */
1321 MARK_TOOLBAR_CHANGED;
1322 }
1323
1324 static void
1325 default_toolbar_border_width_changed_in_frame (Lisp_Object specifier,
1326 struct frame *f,
1327 Lisp_Object oldval)
1328 {
1329 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
1330
1331 Fset_specifier_dirty_flag (Vtoolbar_border_width[pos]);
1269 1332
1270 /* Let redisplay know that something has possibly changed. */ 1333 /* Let redisplay know that something has possibly changed. */
1271 MARK_TOOLBAR_CHANGED; 1334 MARK_TOOLBAR_CHANGED;
1272 } 1335 }
1273 1336
1695 elt = list1 (Fcons (Qnil, Qzero)); 1758 elt = list1 (Fcons (Qnil, Qzero));
1696 set_specifier_fallback (Vtoolbar_size[BOTTOM_TOOLBAR], elt); 1759 set_specifier_fallback (Vtoolbar_size[BOTTOM_TOOLBAR], elt);
1697 set_specifier_fallback (Vtoolbar_size[LEFT_TOOLBAR], elt); 1760 set_specifier_fallback (Vtoolbar_size[LEFT_TOOLBAR], elt);
1698 set_specifier_fallback (Vtoolbar_size[RIGHT_TOOLBAR], elt); 1761 set_specifier_fallback (Vtoolbar_size[RIGHT_TOOLBAR], elt);
1699 1762
1763 DEFVAR_SPECIFIER ("default-toolbar-border-width",
1764 &Vdefault_toolbar_border_width /*
1765 *Width of the border around the default toolbar.
1766 This is a specifier; use `set-specifier' to change it.
1767
1768 The position of the default toolbar is specified by the function
1769 `set-default-toolbar-position'. If the corresponding position-specific
1770 toolbar border width specifier (e.g. `top-toolbar-border-width' if
1771 `default-toolbar-position' is 'top) does not specify a border width in a
1772 particular domain (a window or a frame), then the value of
1773 `default-toolbar-border-width' in that domain, if any, will be used
1774 instead.
1775
1776 Internally, toolbar border width specifiers are instantiated in both
1777 window and frame domains, for different purposes. The value in the
1778 domain of a frame's selected window specifies the actual toolbar border
1779 width that you will see in that frame. The value in the domain of a
1780 frame itself specifies the toolbar border width that is used in frame
1781 geometry calculations. Changing the border width value in the frame
1782 domain will result in a size change in the frame itself, while changing
1783 the value in a window domain will not.
1784 */ );
1785 Vdefault_toolbar_border_width = Fmake_specifier (Qnatnum);
1786 set_specifier_caching (Vdefault_toolbar_border_width,
1787 slot_offset (struct window,
1788 default_toolbar_border_width),
1789 some_window_value_changed,
1790 slot_offset (struct frame,
1791 default_toolbar_border_width),
1792 default_toolbar_border_width_changed_in_frame);
1793
1794 DEFVAR_SPECIFIER ("top-toolbar-border-width",
1795 &Vtoolbar_border_width[TOP_TOOLBAR] /*
1796 *Border width of the top toolbar.
1797 This is a specifier; use `set-specifier' to change it.
1798
1799 See `default-toolbar-height' for more information.
1800 */ );
1801 Vtoolbar_border_width[TOP_TOOLBAR] = Fmake_specifier (Qnatnum);
1802 set_specifier_caching (Vtoolbar_border_width[TOP_TOOLBAR],
1803 slot_offset (struct window,
1804 toolbar_border_width[TOP_TOOLBAR]),
1805 some_window_value_changed,
1806 slot_offset (struct frame,
1807 toolbar_border_width[TOP_TOOLBAR]),
1808 toolbar_border_width_changed_in_frame);
1809
1810 DEFVAR_SPECIFIER ("bottom-toolbar-border-width",
1811 &Vtoolbar_border_width[BOTTOM_TOOLBAR] /*
1812 *Border width of the bottom toolbar.
1813 This is a specifier; use `set-specifier' to change it.
1814
1815 See `default-toolbar-height' for more information.
1816 */ );
1817 Vtoolbar_border_width[BOTTOM_TOOLBAR] = Fmake_specifier (Qnatnum);
1818 set_specifier_caching (Vtoolbar_border_width[BOTTOM_TOOLBAR],
1819 slot_offset (struct window,
1820 toolbar_border_width[BOTTOM_TOOLBAR]),
1821 some_window_value_changed,
1822 slot_offset (struct frame,
1823 toolbar_border_width[BOTTOM_TOOLBAR]),
1824 toolbar_border_width_changed_in_frame);
1825
1826 DEFVAR_SPECIFIER ("left-toolbar-border-width",
1827 &Vtoolbar_border_width[LEFT_TOOLBAR] /*
1828 *Border width of left toolbar.
1829 This is a specifier; use `set-specifier' to change it.
1830
1831 See `default-toolbar-height' for more information.
1832 */ );
1833 Vtoolbar_border_width[LEFT_TOOLBAR] = Fmake_specifier (Qnatnum);
1834 set_specifier_caching (Vtoolbar_border_width[LEFT_TOOLBAR],
1835 slot_offset (struct window,
1836 toolbar_border_width[LEFT_TOOLBAR]),
1837 some_window_value_changed,
1838 slot_offset (struct frame,
1839 toolbar_border_width[LEFT_TOOLBAR]),
1840 toolbar_border_width_changed_in_frame);
1841
1842 DEFVAR_SPECIFIER ("right-toolbar-border-width",
1843 &Vtoolbar_border_width[RIGHT_TOOLBAR] /*
1844 *Border width of right toolbar.
1845 This is a specifier; use `set-specifier' to change it.
1846
1847 See `default-toolbar-height' for more information.
1848 */ );
1849 Vtoolbar_border_width[RIGHT_TOOLBAR] = Fmake_specifier (Qnatnum);
1850 set_specifier_caching (Vtoolbar_border_width[RIGHT_TOOLBAR],
1851 slot_offset (struct window,
1852 toolbar_border_width[RIGHT_TOOLBAR]),
1853 some_window_value_changed,
1854 slot_offset (struct frame,
1855 toolbar_border_width[RIGHT_TOOLBAR]),
1856 toolbar_border_width_changed_in_frame);
1857
1858 /* #### this is ugly. */
1859 /* sb - even uglier to make this work without console tty support, ugh. */
1860 /* not if you get to copy it instead of writing it from scratch. --kyle */
1861 elt = Qnil;
1862 #ifdef HAVE_TTY
1863 elt = list1 (Fcons (list1 (Qtty), Qzero));
1864 #endif
1865 #ifdef HAVE_X_WINDOWS
1866 if (!EQ(elt, Qnil))
1867 elt = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_BORDER_WIDTH)), elt);
1868 else
1869 elt = list1 (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_BORDER_WIDTH)));
1870 #endif
1871 if (!EQ(elt, Qnil))
1872 set_specifier_fallback (Vdefault_toolbar_border_width, elt);
1873
1874 set_specifier_fallback (Vtoolbar_border_width[TOP_TOOLBAR], Vdefault_toolbar_border_width);
1875 elt = list1 (Fcons (Qnil, Qzero));
1876 set_specifier_fallback (Vtoolbar_border_width[BOTTOM_TOOLBAR], elt);
1877 set_specifier_fallback (Vtoolbar_border_width[LEFT_TOOLBAR], elt);
1878 set_specifier_fallback (Vtoolbar_border_width[RIGHT_TOOLBAR], elt);
1879
1700 DEFVAR_SPECIFIER ("default-toolbar-visible-p", &Vdefault_toolbar_visible_p /* 1880 DEFVAR_SPECIFIER ("default-toolbar-visible-p", &Vdefault_toolbar_visible_p /*
1701 *Whether the default toolbar is visible. 1881 *Whether the default toolbar is visible.
1702 This is a specifier; use `set-specifier' to change it. 1882 This is a specifier; use `set-specifier' to change it.
1703 1883
1704 The position of the default toolbar is specified by the function 1884 The position of the default toolbar is specified by the function