Mercurial > emacs
comparison src/xdisp.c @ 35246:4e6bbe9c1780
(build_desired_tool_bar_string): Correct the computation
of the size needed for the tool bar string. For the last image,
use a `display' property that reaches to the end of the string.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 11 Jan 2001 19:32:55 +0000 |
parents | 13258951565d |
children | 5695de532559 |
comparison
equal
deleted
inserted
replaced
35245:be1c0993aea3 | 35246:4e6bbe9c1780 |
---|---|
7146 | 7146 |
7147 static void | 7147 static void |
7148 build_desired_tool_bar_string (f) | 7148 build_desired_tool_bar_string (f) |
7149 struct frame *f; | 7149 struct frame *f; |
7150 { | 7150 { |
7151 int i, size, size_needed, string_idx; | 7151 int i, size, size_needed; |
7152 struct gcpro gcpro1, gcpro2, gcpro3; | 7152 struct gcpro gcpro1, gcpro2, gcpro3; |
7153 Lisp_Object image, plist, props; | 7153 Lisp_Object image, plist, props; |
7154 | 7154 |
7155 image = plist = props = Qnil; | 7155 image = plist = props = Qnil; |
7156 GCPRO3 (image, plist, props); | 7156 GCPRO3 (image, plist, props); |
7161 /* The size of the string we might be able to reuse. */ | 7161 /* The size of the string we might be able to reuse. */ |
7162 size = (STRINGP (f->desired_tool_bar_string) | 7162 size = (STRINGP (f->desired_tool_bar_string) |
7163 ? XSTRING (f->desired_tool_bar_string)->size | 7163 ? XSTRING (f->desired_tool_bar_string)->size |
7164 : 0); | 7164 : 0); |
7165 | 7165 |
7166 /* Each image in the string we build is preceded by a space, | |
7167 and there is a space at the end. */ | |
7168 size_needed = f->n_tool_bar_items + 1; | |
7169 | |
7170 /* Reuse f->desired_tool_bar_string, if possible. */ | 7166 /* Reuse f->desired_tool_bar_string, if possible. */ |
7167 size_needed = f->n_tool_bar_items; | |
7171 if (size < size_needed) | 7168 if (size < size_needed) |
7172 f->desired_tool_bar_string = Fmake_string (make_number (size_needed), | 7169 f->desired_tool_bar_string = Fmake_string (make_number (size_needed), |
7173 make_number (' ')); | 7170 make_number (' ')); |
7174 else | 7171 else |
7175 { | 7172 { |
7179 } | 7176 } |
7180 | 7177 |
7181 /* Put a `display' property on the string for the images to display, | 7178 /* Put a `display' property on the string for the images to display, |
7182 put a `menu_item' property on tool-bar items with a value that | 7179 put a `menu_item' property on tool-bar items with a value that |
7183 is the index of the item in F's tool-bar item vector. */ | 7180 is the index of the item in F's tool-bar item vector. */ |
7184 for (i = 0, string_idx = 0; | 7181 for (i = 0; i < f->n_tool_bar_items; ++i) |
7185 i < f->n_tool_bar_items; | |
7186 ++i, string_idx += 1) | |
7187 { | 7182 { |
7188 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) | 7183 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) |
7189 | 7184 |
7190 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); | 7185 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); |
7191 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); | 7186 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); |
7192 int margin, relief, idx; | 7187 int margin, relief, idx, end; |
7193 extern Lisp_Object QCrelief, QCmargin, QCalgorithm, Qimage; | 7188 extern Lisp_Object QCrelief, QCmargin, QCalgorithm, Qimage; |
7194 extern Lisp_Object Qlaplace; | 7189 extern Lisp_Object Qlaplace; |
7195 | 7190 |
7196 /* If image is a vector, choose the image according to the | 7191 /* If image is a vector, choose the image according to the |
7197 button state. */ | 7192 button state. */ |
7260 display. Put a `menu-item' property on the string that gives | 7255 display. Put a `menu-item' property on the string that gives |
7261 the start of this item's properties in the tool-bar items | 7256 the start of this item's properties in the tool-bar items |
7262 vector. */ | 7257 vector. */ |
7263 image = Fcons (Qimage, plist); | 7258 image = Fcons (Qimage, plist); |
7264 props = list4 (Qdisplay, image, | 7259 props = list4 (Qdisplay, image, |
7265 Qmenu_item, make_number (i * TOOL_BAR_ITEM_NSLOTS)), | 7260 Qmenu_item, make_number (i * TOOL_BAR_ITEM_NSLOTS)); |
7266 Fadd_text_properties (make_number (string_idx), | 7261 |
7267 make_number (string_idx + 1), | 7262 /* Let the last image hide all remaining spaces in the tool bar |
7263 string. The string can be longer than needed when we reuse a | |
7264 previous string. */ | |
7265 if (i + 1 == f->n_tool_bar_items) | |
7266 end = XSTRING (f->desired_tool_bar_string)->size; | |
7267 else | |
7268 end = i + 1; | |
7269 Fadd_text_properties (make_number (i), make_number (end), | |
7268 props, f->desired_tool_bar_string); | 7270 props, f->desired_tool_bar_string); |
7269 #undef PROP | 7271 #undef PROP |
7270 } | 7272 } |
7271 | 7273 |
7272 UNGCPRO; | 7274 UNGCPRO; |