comparison src/toolbar.c @ 380:8626e4521993 r21-2-5

Import from CVS: tag r21-2-5
author cvs
date Mon, 13 Aug 2007 11:07:10 +0200
parents 57709be46d1b
children 74fd4e045ea6
comparison
equal deleted inserted replaced
379:76b7d63099ad 380:8626e4521993
57 57
58 58
59 static Lisp_Object 59 static Lisp_Object
60 mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object)) 60 mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object))
61 { 61 {
62 struct toolbar_button *data = (struct toolbar_button *) XPNTR (obj); 62 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
63 ((markobj) (data->next)); 63 markobj (data->next);
64 ((markobj) (data->frame)); 64 markobj (data->frame);
65 ((markobj) (data->up_glyph)); 65 markobj (data->up_glyph);
66 ((markobj) (data->down_glyph)); 66 markobj (data->down_glyph);
67 ((markobj) (data->disabled_glyph)); 67 markobj (data->disabled_glyph);
68 ((markobj) (data->cap_up_glyph)); 68 markobj (data->cap_up_glyph);
69 ((markobj) (data->cap_down_glyph)); 69 markobj (data->cap_down_glyph);
70 ((markobj) (data->cap_disabled_glyph)); 70 markobj (data->cap_disabled_glyph);
71 ((markobj) (data->callback)); 71 markobj (data->callback);
72 ((markobj) (data->enabled_p)); 72 markobj (data->enabled_p);
73 return data->help_string; 73 return data->help_string;
74 } 74 }
75 75
76 static void 76 static void
77 print_toolbar_button (Lisp_Object obj, Lisp_Object printcharfun, 77 print_toolbar_button (Lisp_Object obj, Lisp_Object printcharfun,
739 int pos; 739 int pos;
740 740
741 /* We're not officially "in redisplay", so we still have a 741 /* We're not officially "in redisplay", so we still have a
742 chance to re-layout toolbars and windows. This is done here, 742 chance to re-layout toolbars and windows. This is done here,
743 because toolbar is the only thing which currently might 743 because toolbar is the only thing which currently might
744 necesseritate this layout, as it is outside any windows. We 744 necessitate this layout, as it is outside any windows. We
745 take care not to change size if toolbar geometry is really 745 take care not to change size if toolbar geometry is really
746 unchanged, as it will hose windows whose pixsizes are not 746 unchanged, as it will hose windows whose pixsizes are not
747 multiple of character sizes */ 747 multiple of character sizes. */
748 748
749 for (pos = 0; pos < 4; pos++) 749 for (pos = 0; pos < 4; pos++)
750 if (FRAME_REAL_TOOLBAR_SIZE (f, pos) 750 if (FRAME_REAL_TOOLBAR_SIZE (f, pos)
751 != FRAME_CURRENT_TOOLBAR_SIZE (f, pos)) 751 != FRAME_CURRENT_TOOLBAR_SIZE (f, pos))
752 { 752 {
892 default: 892 default:
893 abort (); 893 abort ();
894 } 894 }
895 } 895 }
896 896
897 #define CHECK_TOOLBAR(pos) \ 897 #define CHECK_TOOLBAR(pos) do { \
898 do \ 898 if (FRAME_REAL_##pos##_VISIBLE (f)) \
899 { \ 899 { \
900 int x, y, width, height, vert; \
901 \
900 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \ 902 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \
901 if ((x_coord >= x) && (x_coord < (x + width))) \ 903 if ((x_coord >= x) && (x_coord < (x + width))) \
902 { \ 904 { \
903 if ((y_coord >= y) && (y_coord < (y + height))) \ 905 if ((y_coord >= y) && (y_coord < (y + height))) \
904 return FRAME_TOOLBAR_BUTTONS (f, pos); \ 906 return FRAME_TOOLBAR_BUTTONS (f, pos); \
905 } \ 907 } \
906 } while (0) 908 } \
909 } while (0)
907 910
908 static Lisp_Object 911 static Lisp_Object
909 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord) 912 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord)
910 { 913 {
911 int x, y, width, height, vert; 914 CHECK_TOOLBAR (TOP_TOOLBAR);
912 915 CHECK_TOOLBAR (BOTTOM_TOOLBAR);
913 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) 916 CHECK_TOOLBAR (LEFT_TOOLBAR);
914 CHECK_TOOLBAR (TOP_TOOLBAR); 917 CHECK_TOOLBAR (RIGHT_TOOLBAR);
915 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
916 CHECK_TOOLBAR (BOTTOM_TOOLBAR);
917 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
918 CHECK_TOOLBAR (LEFT_TOOLBAR);
919 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
920 CHECK_TOOLBAR (RIGHT_TOOLBAR);
921 918
922 return Qnil; 919 return Qnil;
923 } 920 }
924 #undef CHECK_TOOLBAR 921 #undef CHECK_TOOLBAR
925 922
928 level. */ 925 level. */
929 Lisp_Object 926 Lisp_Object
930 toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord) 927 toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
931 { 928 {
932 Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord); 929 Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord);
933
934 if (NILP (buttons))
935 return Qnil;
936 930
937 while (!NILP (buttons)) 931 while (!NILP (buttons))
938 { 932 {
939 struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons); 933 struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons);
940 934
951 } 945 }
952 946
953 buttons = tb->next; 947 buttons = tb->next;
954 } 948 }
955 949
956 /* We must be over a blank in the toolbar. */ 950 /* We are not over a toolbar or we are over a blank in the toolbar. */
957 return Qnil; 951 return Qnil;
958 } 952 }
959 953
960 954
961 /************************************************************************/ 955 /************************************************************************/
962 /* Toolbar specifier type */ 956 /* Toolbar specifier type */
963 /************************************************************************/ 957 /************************************************************************/
964 958
965 DEFINE_SPECIFIER_TYPE (toolbar); 959 DEFINE_SPECIFIER_TYPE (toolbar);
966 960
967 #define CTB_ERROR(msg) \ 961 #define CTB_ERROR(msg) do { \
968 do \ 962 maybe_signal_simple_error (msg, button, Qtoolbar, errb); \
969 { \ 963 RETURN_SANS_WARNINGS Qnil; \
970 maybe_signal_simple_error (msg, button, Qtoolbar, errb); \ 964 } while (0)
971 RETURN__ Qnil; \
972 } \
973 while (0)
974 965
975 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */ 966 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */
976 static Lisp_Object 967 static Lisp_Object
977 check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key, 968 check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key,
978 Lisp_Object val, Error_behavior errb) 969 Lisp_Object val, Error_behavior errb)
979 { 970 {
980 if (!KEYWORDP (key)) 971 if (!KEYWORDP (key))
981 { 972 {
982 maybe_signal_simple_error_2 ("not a keyword", key, button, Qtoolbar, 973 maybe_signal_simple_error_2 ("Not a keyword", key, button, Qtoolbar,
983 errb); 974 errb);
984 return Qnil; 975 return Qnil;
985 } 976 }
986 977
987 if (EQ (key, Q_style)) 978 if (EQ (key, Q_style))
988 { 979 {
989 if (!EQ (val, Q2D) 980 if (!EQ (val, Q2D)
990 && !EQ (val, Q3D) 981 && !EQ (val, Q3D)
991 && !EQ (val, Q2d) 982 && !EQ (val, Q2d)
992 && !EQ (val, Q3d)) 983 && !EQ (val, Q3d))
993 CTB_ERROR ("unrecognized toolbar blank style"); 984 CTB_ERROR ("Unrecognized toolbar blank style");
994 985
995 return Q_style; 986 return Q_style;
996 } 987 }
997 else if (EQ (key, Q_size)) 988 else if (EQ (key, Q_size))
998 { 989 {
1137 1128
1138 if (NILP (instantiator)) 1129 if (NILP (instantiator))
1139 return; 1130 return;
1140 1131
1141 if (!CONSP (instantiator)) 1132 if (!CONSP (instantiator))
1142 signal_simple_error ("toolbar spec must be list or nil", instantiator); 1133 signal_simple_error ("Toolbar spec must be list or nil", instantiator);
1143 1134
1144 for (rest = instantiator; !NILP (rest); rest = XCDR (rest)) 1135 for (rest = instantiator; !NILP (rest); rest = XCDR (rest))
1145 { 1136 {
1146 if (!CONSP (rest)) 1137 if (!CONSP (rest))
1147 signal_simple_error ("bad list in toolbar spec", instantiator); 1138 signal_simple_error ("Bad list in toolbar spec", instantiator);
1148 1139
1149 if (NILP (XCAR (rest))) 1140 if (NILP (XCAR (rest)))
1150 { 1141 {
1151 if (pushright_seen) 1142 if (pushright_seen)
1152 error 1143 error
1153 ("more than one partition (nil) in instantiator description"); 1144 ("More than one partition (nil) in instantiator description");
1154 else 1145 else
1155 pushright_seen = 1; 1146 pushright_seen = 1;
1156 } 1147 }
1157 else 1148 else
1158 Fcheck_toolbar_button_syntax (XCAR (rest), Qnil); 1149 Fcheck_toolbar_button_syntax (XCAR (rest), Qnil);
1198 static void 1189 static void
1199 toolbar_specs_changed (Lisp_Object specifier, struct window *w, 1190 toolbar_specs_changed (Lisp_Object specifier, struct window *w,
1200 Lisp_Object oldval) 1191 Lisp_Object oldval)
1201 { 1192 {
1202 /* This could be smarter but I doubt that it would make any 1193 /* This could be smarter but I doubt that it would make any
1203 noticable difference given the infrequency with which this is 1194 noticeable difference given the infrequency with which this is
1204 probably going to be called. 1195 probably going to be called.
1205 */ 1196 */
1206 MARK_TOOLBAR_CHANGED; 1197 MARK_TOOLBAR_CHANGED;
1207 } 1198 }
1208 1199
1270 static void 1261 static void
1271 toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w, 1262 toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w,
1272 Lisp_Object oldval) 1263 Lisp_Object oldval)
1273 { 1264 {
1274 /* This could be smarter but I doubt that it would make any 1265 /* This could be smarter but I doubt that it would make any
1275 noticable difference given the infrequency with which this is 1266 noticeable difference given the infrequency with which this is
1276 probably going to be called. */ 1267 probably going to be called. */
1277 MARK_TOOLBAR_CHANGED; 1268 MARK_TOOLBAR_CHANGED;
1278 } 1269 }
1279 1270
1280 1271