From dcf326cfd523c135bd0be8f9a4bc2da6c78b2d23 Mon Sep 17 00:00:00 2001 From: Arnon Gilboa Date: Thu, 7 Jan 2010 11:02:50 +0200 Subject: spice: menu additons -functions: set_name, remove_command, remove_sub, clear -item state & enum -add state support in RedWindow insert_command & insert_menu --- client/windows/red_window.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'client/windows/red_window.cpp') diff --git a/client/windows/red_window.cpp b/client/windows/red_window.cpp index 47467194..2d415d1e 100644 --- a/client/windows/red_window.cpp +++ b/client/windows/red_window.cpp @@ -906,17 +906,24 @@ static void utf8_to_wchar(const std::string& src, std::wstring& dest) MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, (wchar_t *)dest.c_str(), len); } -static void insert_command(HMENU menu, const std::string& name, int id) +static void insert_command(HMENU menu, const std::string& name, int id, int state) { MENUITEMINFO item_info; item_info.cbSize = sizeof(item_info); - item_info.fMask = MIIM_TYPE | MIIM_ID; + item_info.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE; item_info.fType = MFT_STRING; std::wstring wname; utf8_to_wchar(name, wname); item_info.cch = wname.size(); item_info.dwTypeData = (wchar_t *)wname.c_str(); item_info.wID = id; + item_info.fState = MFS_ENABLED; + if (state & Menu::MENU_ITEM_STATE_CHECKED) { + item_info.fState |= MFS_CHECKED; + } + if (state & Menu::MENU_ITEM_STATE_DIM) { + item_info.fState |= MFS_DISABLED; + } InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &item_info); } @@ -969,10 +976,11 @@ static void insert_menu(Menu* menu, HMENU native, CommandMap& _commands_map) case Menu::MENU_ITEM_TYPE_COMMAND: { std::string name; int command_id; - menu->command_at(pos, name, command_id); + int state; + menu->command_at(pos, name, command_id, state); int sys_command = alloc_sys_cmd_id(); _commands_map[sys_command] = CommandInfo(menu, command_id); - insert_command(native, name, sys_command); + insert_command(native, name, sys_command, state); break; } case Menu::MENU_ITEM_TYPE_MENU: { -- cgit