@@ -74,19 +74,6 @@ std::pair<UINT, UINT> ConvertAccelerator(const KeyboardAccelerator& accelerator)
7474
7575namespace nativeapi {
7676
77- // KeyboardAccelerator implementation
78- std::string KeyboardAccelerator::ToString () const {
79- std::string result;
80-
81- if (modifiers & Ctrl) result += " Ctrl+" ;
82- if (modifiers & Alt) result += " Alt+" ;
83- if (modifiers & Shift) result += " Shift+" ;
84- if (modifiers & Meta) result += " Win+" ;
85-
86- result += key;
87- return result;
88- }
89-
9077// MenuItem::Impl implementation
9178class MenuItem ::Impl {
9279 public:
@@ -215,7 +202,7 @@ void MenuItem::RemoveAccelerator() {
215202void MenuItem::SetEnabled (bool enabled) {
216203 pimpl_->enabled_ = enabled;
217204 if (pimpl_->parent_menu_ ) {
218- EnableMenuItem (pimpl_->parent_menu_ , pimpl_->menu_item_id_ ,
205+ EnableMenuItem (pimpl_->parent_menu_ , pimpl_->menu_item_id_ ,
219206 enabled ? MF_ENABLED : MF_GRAYED);
220207 }
221208}
@@ -237,7 +224,7 @@ bool MenuItem::IsVisible() const {
237224void MenuItem::SetState (MenuItemState state) {
238225 if (pimpl_->type_ == MenuItemType::Checkbox || pimpl_->type_ == MenuItemType::Radio) {
239226 pimpl_->state_ = state;
240-
227+
241228 if (pimpl_->parent_menu_ ) {
242229 UINT checkState = MF_UNCHECKED;
243230 if (state == MenuItemState::Checked) {
@@ -255,7 +242,7 @@ void MenuItem::SetState(MenuItemState state) {
255242 otherItem->GetRadioGroup () == pimpl_->radio_group_ ) {
256243 otherItem->pimpl_ ->state_ = MenuItemState::Unchecked;
257244 if (otherItem->pimpl_ ->parent_menu_ ) {
258- CheckMenuItem (otherItem->pimpl_ ->parent_menu_ ,
245+ CheckMenuItem (otherItem->pimpl_ ->parent_menu_ ,
259246 otherItem->pimpl_ ->menu_item_id_ , MF_UNCHECKED);
260247 }
261248 }
@@ -348,7 +335,7 @@ std::shared_ptr<Menu> Menu::Create() {
348335 if (!hmenu) {
349336 return nullptr ;
350337 }
351-
338+
352339 auto menu = std::shared_ptr<Menu>(new Menu ());
353340 menu->pimpl_ = std::make_unique<Impl>(hmenu);
354341 menu->id = g_next_menu_id++;
@@ -379,7 +366,7 @@ void Menu::AddItem(std::shared_ptr<MenuItem> item) {
379366 if (!item) return ;
380367
381368 pimpl_->items_ .push_back (item);
382-
369+
383370 UINT flags = MF_STRING;
384371 if (item->GetType () == MenuItemType::Separator) {
385372 flags = MF_SEPARATOR;
@@ -388,17 +375,17 @@ void Menu::AddItem(std::shared_ptr<MenuItem> item) {
388375 } else if (item->GetType () == MenuItemType::Radio) {
389376 flags |= MF_UNCHECKED;
390377 }
391-
378+
392379 UINT_PTR menuId = item->id ;
393380 HMENU subMenu = nullptr ;
394381 if (item->GetSubmenu ()) {
395382 subMenu = static_cast <HMENU>(item->GetSubmenu ()->GetNativeMenu ());
396383 flags |= MF_POPUP;
397384 menuId = reinterpret_cast <UINT_PTR>(subMenu);
398385 }
399-
386+
400387 AppendMenu (pimpl_->hmenu_ , flags, menuId, item->GetText ().c_str ());
401-
388+
402389 // Update the item's impl with menu info
403390 item->pimpl_ ->parent_menu_ = pimpl_->hmenu_ ;
404391 item->pimpl_ ->menu_item_id_ = static_cast <UINT>(item->id );
@@ -413,14 +400,14 @@ void Menu::InsertItem(size_t index, std::shared_ptr<MenuItem> item) {
413400 }
414401
415402 pimpl_->items_ .insert (pimpl_->items_ .begin () + index, item);
416-
403+
417404 UINT flags = MF_STRING | MF_BYPOSITION;
418405 if (item->GetType () == MenuItemType::Separator) {
419406 flags = MF_SEPARATOR | MF_BYPOSITION;
420407 }
421-
408+
422409 InsertMenu (pimpl_->hmenu_ , static_cast <UINT>(index), flags, item->id , item->GetText ().c_str ());
423-
410+
424411 item->pimpl_ ->parent_menu_ = pimpl_->hmenu_ ;
425412 item->pimpl_ ->menu_item_id_ = static_cast <UINT>(item->id );
426413}
@@ -513,16 +500,16 @@ std::shared_ptr<MenuItem> Menu::FindItemByText(const std::string& text, bool cas
513500
514501bool Menu::ShowAsContextMenu (double x, double y) {
515502 pimpl_->visible_ = true ;
516-
503+
517504 POINT pt = {static_cast <int >(x), static_cast <int >(y)};
518505 HWND hwnd = GetActiveWindow ();
519506 if (!hwnd) {
520507 hwnd = GetDesktopWindow ();
521508 }
522-
509+
523510 // Show the context menu
524511 TrackPopupMenu (pimpl_->hmenu_ , TPM_RIGHTBUTTON, pt.x , pt.y , 0 , hwnd, nullptr );
525-
512+
526513 pimpl_->visible_ = false ;
527514 return true ;
528515}
0 commit comments