Previous 15994 Revisions Next

r7932 Thursday 29th April, 2010 at 13:09:50 UTC by Robbbert
Reverting r7914 which caused newui to mostly crash at start.
[src/mess/osd/windows]menu.c winutils.c winutils.h

src/mess/osd/windows/winutils.c
r7931r7932
219219      ScrollWindowEx(window, 0, si.nPos - scroll_pos, NULL, NULL, NULL, NULL, SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE);
220220   }
221221}
222
223
224
225//============================================================
226//  win_append_menu_utf8
227//============================================================
228
229BOOL win_append_menu_utf8(HMENU menu, UINT flags, UINT_PTR id, const char *item)
230{
231   BOOL result;
232   const TCHAR *t_item = (const TCHAR*)item;
233   TCHAR *t_str = NULL;
234
235   // only convert string when it's no a bitmap
236   if (!(flags & MF_BITMAP) && item) {
237      t_str = tstring_from_utf8(item);
238      t_item = t_str;
239   }
240
241   result = AppendMenu(menu, flags, id, t_item);
242
243   if (t_str)
244      osd_free(t_str);
245
246   return result;
247}
src/mess/osd/windows/winutils.h
r7931r7932
4848
4949void win_scroll_window(HWND window, WPARAM wparam, int scroll_bar, int scroll_delta_line);
5050
51BOOL win_append_menu_utf8(HMENU menu, UINT flags, UINT_PTR id, const char *item);
52
5351#endif // WINUTILS_H
src/mess/osd/windows/menu.c
r7931r7932
13161316
13171317
13181318
1319//============================================================
1320//  append_menu_utf8
1321//============================================================
13191322
1323static void append_menu_utf8(HMENU menu, UINT flags, UINT_PTR id, const char *str)
1324{
1325   TCHAR *t_str = str ? tstring_from_utf8(str) : NULL;
1326   AppendMenu(menu, flags, id, t_str);
1327   if (t_str)
1328      global_free(t_str);
1329}
1330
1331
1332
1333
13201334//============================================================
13211335//  remove_menu_items
13221336//============================================================
r7931r7932
13801394               for (setting = field->settinglist; setting != NULL; setting = setting->next)
13811395               {
13821396                  command = ID_INPUT_0 + serial_number_from_input_item(machine, port, field, setting);
1383                  win_append_menu_utf8(submenu, MF_STRING, command, setting->name);
1397                  append_menu_utf8(submenu, MF_STRING, command, setting->name);
13841398               }
13851399
13861400               // tack on the final items and the menu item
13871401               command = ID_INPUT_0 + serial_number_from_input_item(machine, port, field, NULL);
13881402               AppendMenu(submenu, MF_SEPARATOR, 0, NULL);
13891403               AppendMenu(submenu, MF_STRING, command, TEXT("&Configure..."));
1390               win_append_menu_utf8(joystick_menu, MF_STRING | MF_POPUP, (UINT_PTR) submenu, field->name);
1404               append_menu_utf8(joystick_menu, MF_STRING | MF_POPUP, (UINT_PTR) submenu, field->name);
13911405               child_count++;
13921406            }
13931407         }
r7931r7932
14041418         for (i = 0; i < joystick_count; i++)
14051419         {
14061420            snprintf(buf, ARRAY_LENGTH(buf), "Joystick %i", i + 1);
1407            win_append_menu_utf8(joystick_menu, MF_STRING, ID_JOYSTICK_0 + i, buf);
1421            append_menu_utf8(joystick_menu, MF_STRING, ID_JOYSTICK_0 + i, buf);
14081422            child_count++;
14091423         }
14101424      }
r7931r7932
14621476   HMENU device_menu;
14631477   HMENU sub_menu;
14641478   UINT_PTR new_item;
1479   UINT flags;
14651480   UINT flags_for_exists;
14661481   UINT flags_for_writing;
14671482   running_device *img;
r7931r7932
16001615   // then set up the actual devices
16011616   for ( img = window->machine->devicelist.first();  img != NULL;  img =  img->next)
16021617   {
1603      if (is_image_device(img))
1618      if (is_image_device( img))
16041619      {
16051620         image_device_info info = image_device_getinfo(window->machine->config, img);
16061621
r7931r7932
16151630            flags_for_writing |= MF_GRAYED;
16161631
16171632         sub_menu = CreateMenu();
1618         win_append_menu_utf8(sub_menu, MF_STRING,      new_item + DEVOPTION_OPEN,      "Mount...");
1633         append_menu_utf8(sub_menu, MF_STRING,      new_item + DEVOPTION_OPEN,      "Mount...");
16191634
16201635         if (info.creatable)
1621            win_append_menu_utf8(sub_menu, MF_STRING,   new_item + DEVOPTION_CREATE,   "Create...");
1636            append_menu_utf8(sub_menu, MF_STRING,   new_item + DEVOPTION_CREATE,   "Create...");
16221637
1623         win_append_menu_utf8(sub_menu, flags_for_exists,   new_item + DEVOPTION_CLOSE,   "Unmount");
1638         append_menu_utf8(sub_menu, flags_for_exists,   new_item + DEVOPTION_CLOSE,   "Unmount");
16241639
16251640         if ((img->type == CASSETTE) && !strcmp(info.file_extensions, "wav"))
16261641         {
16271642            cassette_state state;
16281643            state = (cassette_state)(image_exists(img) ? (cassette_get_state(img) & CASSETTE_MASK_UISTATE) : CASSETTE_STOPPED);
1629            win_append_menu_utf8(sub_menu, MF_SEPARATOR, 0, NULL);
1630            win_append_menu_utf8(sub_menu, flags_for_exists   | ((state == CASSETTE_STOPPED)   ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_STOPPAUSE,   "Pause/Stop");
1631            win_append_menu_utf8(sub_menu, flags_for_exists   | ((state == CASSETTE_PLAY)      ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_PLAY,         "Play");
1632            win_append_menu_utf8(sub_menu, flags_for_writing   | ((state == CASSETTE_RECORD)   ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_RECORD,      "Record");
1633            win_append_menu_utf8(sub_menu, flags_for_exists,                                          new_item + DEVOPTION_CASSETTE_REWIND,      "Rewind");
1634            win_append_menu_utf8(sub_menu, flags_for_exists,                                          new_item + DEVOPTION_CASSETTE_FASTFORWARD,   "Fast Forward");
1644            append_menu_utf8(sub_menu, MF_SEPARATOR, 0, NULL);
1645            append_menu_utf8(sub_menu, flags_for_exists   | ((state == CASSETTE_STOPPED)   ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_STOPPAUSE,   "Pause/Stop");
1646            append_menu_utf8(sub_menu, flags_for_exists   | ((state == CASSETTE_PLAY)      ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_PLAY,         "Play");
1647            append_menu_utf8(sub_menu, flags_for_writing   | ((state == CASSETTE_RECORD)   ? MF_CHECKED : 0),   new_item + DEVOPTION_CASSETTE_RECORD,      "Record");
1648            append_menu_utf8(sub_menu, flags_for_exists,                                          new_item + DEVOPTION_CASSETTE_REWIND,      "Rewind");
1649            append_menu_utf8(sub_menu, flags_for_exists,                                          new_item + DEVOPTION_CASSETTE_FASTFORWARD,   "Fast Forward");
16351650         }
16361651         s = image_exists(img) ? image_filename(img) : "[empty slot]";
1652         flags = MF_POPUP;
16371653
16381654         snprintf(buf, ARRAY_LENGTH(buf), "%s: %s", image_typename_id(img), s);
1639         win_append_menu_utf8(device_menu, MF_POPUP, (UINT_PTR)sub_menu, buf);
1655         append_menu_utf8(device_menu, flags, (UINT_PTR) sub_menu, buf);
16401656      }
16411657   }
16421658}
r7931r7932
21922208   for(i = 0; i < frameskip_level_count(); i++)
21932209   {
21942210      snprintf(buf, ARRAY_LENGTH(buf), "%i", i);
2195      win_append_menu_utf8(frameskip_menu, MF_STRING, ID_FRAMESKIP_0 + i, buf);
2211      append_menu_utf8(frameskip_menu, MF_STRING, ID_FRAMESKIP_0 + i, buf);
21962212   }
21972213
21982214   // set the help menu to refer to this machine

Previous 15994 Revisions Next


© 1998-2018 The MESS Team