comparison src/menubar-msw.c @ 373:6240c7796c7a r21-2b2

Import from CVS: tag r21-2b2
author cvs
date Mon, 13 Aug 2007 11:04:06 +0200
parents cc15677e0335
children 8626e4521993
comparison
equal deleted inserted replaced
372:49e1ed2d7ed8 373:6240c7796c7a
121 /* 121 /*
122 * This returns Windows-style menu item string: 122 * This returns Windows-style menu item string:
123 * "Left Flush\tRight Flush" 123 * "Left Flush\tRight Flush"
124 */ 124 */
125 static char* 125 static char*
126 displayable_menu_item (struct gui_item* pgui_item) 126 displayable_menu_item (struct gui_item* pgui_item, int bar_p)
127 { 127 {
128 /* We construct the name in a static buffer. That's fine, beause 128 /* We construct the name in a static buffer. That's fine, beause
129 menu items longer than 128 chars are probably programming errors, 129 menu items longer than 128 chars are probably programming errors,
130 and better be caught than displayed! */ 130 and better be caught than displayed! */
131 131
133 unsigned int ll, lr; 133 unsigned int ll, lr;
134 134
135 /* Left flush part of the string */ 135 /* Left flush part of the string */
136 ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH); 136 ll = gui_item_display_flush_left (pgui_item, buf, MAX_MENUITEM_LENGTH);
137 137
138 /* Right flush part */ 138 /* Right flush part, unless we're at the top-level where it's not allowed */
139 assert (MAX_MENUITEM_LENGTH > ll + 1); 139 if (!bar_p)
140 lr = gui_item_display_flush_right (pgui_item, buf + ll + 1, 140 {
141 MAX_MENUITEM_LENGTH - ll - 1); 141 assert (MAX_MENUITEM_LENGTH > ll + 1);
142 if (lr) 142 lr = gui_item_display_flush_right (pgui_item, buf + ll + 1,
143 buf [ll] = '\t'; 143 MAX_MENUITEM_LENGTH - ll - 1);
144 if (lr)
145 buf [ll] = '\t';
146 }
144 147
145 return buf; 148 return buf;
146 } 149 }
147 150
148 /* 151 /*
221 return 0; 224 return 0;
222 } 225 }
223 226
224 static void 227 static void
225 populate_menu_add_item (HMENU menu, Lisp_Object path, 228 populate_menu_add_item (HMENU menu, Lisp_Object path,
226 Lisp_Object hash_tab, Lisp_Object item, int flush_right) 229 Lisp_Object hash_tab, Lisp_Object item,
230 int flush_right, int bar_p)
227 { 231 {
228 MENUITEMINFO item_info; 232 MENUITEMINFO item_info;
229 233
230 item_info.cbSize = sizeof (item_info); 234 item_info.cbSize = sizeof (item_info);
231 item_info.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID; 235 item_info.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
269 displayed item won't have an arrow indicating that it is a 273 displayed item won't have an arrow indicating that it is a
270 popup. So we go ahead a little bit more and create a popup */ 274 popup. So we go ahead a little bit more and create a popup */
271 submenu = create_empty_popup_menu(); 275 submenu = create_empty_popup_menu();
272 276
273 item_info.fMask |= MIIM_SUBMENU; 277 item_info.fMask |= MIIM_SUBMENU;
274 item_info.dwTypeData = displayable_menu_item (&gui_item); 278 item_info.dwTypeData = displayable_menu_item (&gui_item, bar_p);
275 item_info.hSubMenu = submenu; 279 item_info.hSubMenu = submenu;
276 280
277 if (!(item_info.fState & MFS_GRAYED)) 281 if (!(item_info.fState & MFS_GRAYED))
278 { 282 {
279 /* Now add the full submenu path as a value to the hash table, 283 /* Now add the full submenu path as a value to the hash table,
330 gui_item.suffix); 334 gui_item.suffix);
331 Fputhash (id, gui_item.callback, hash_tab); 335 Fputhash (id, gui_item.callback, hash_tab);
332 336
333 item_info.wID = (UINT) XINT(id); 337 item_info.wID = (UINT) XINT(id);
334 item_info.fType |= MFT_STRING; 338 item_info.fType |= MFT_STRING;
335 item_info.dwTypeData = displayable_menu_item (&gui_item); 339 item_info.dwTypeData = displayable_menu_item (&gui_item, bar_p);
336 340
337 UNGCPRO; /* gui_item */ 341 UNGCPRO; /* gui_item */
338 } 342 }
339 else 343 else
340 { 344 {
341 signal_simple_error ("Mailformed menu item descriptor", item); 345 signal_simple_error ("Malformed menu item descriptor", item);
342 } 346 }
343 347
344 if (flush_right) 348 if (flush_right)
345 item_info.fType |= MFT_RIGHTJUSTIFY; 349 item_info.fType |= MFT_RIGHTJUSTIFY;
346 350
406 if (!populate_p) 410 if (!populate_p)
407 checksum = HASH2 (checksum, LISP_HASH (Qnil)); 411 checksum = HASH2 (checksum, LISP_HASH (Qnil));
408 } 412 }
409 else if (populate_p) 413 else if (populate_p)
410 populate_menu_add_item (menu, path, hash_tab, 414 populate_menu_add_item (menu, path, hash_tab,
411 XCAR (item_desc), flush_right); 415 XCAR (item_desc), flush_right, bar_p);
412 else 416 else
413 checksum = HASH2 (checksum, 417 checksum = HASH2 (checksum,
414 checksum_menu_item (XCAR (item_desc))); 418 checksum_menu_item (XCAR (item_desc)));
415 } 419 }
416 420