// Copyright (c) 2013 GitHub, Inc. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ATOM_BROWSER_API_ATOM_API_MENU_H_ #define ATOM_BROWSER_API_ATOM_API_MENU_H_ #include "base/memory/scoped_ptr.h" #include "browser/api/atom_api_event_emitter.h" #include "ui/base/models/simple_menu_model.h" namespace atom { namespace api { class Menu : public EventEmitter, public ui::SimpleMenuModel::Delegate { public: virtual ~Menu(); static Menu* Create(v8::Handle wrapper); static void Initialize(v8::Handle target); protected: explicit Menu(v8::Handle wrapper); // ui::SimpleMenuModel::Delegate implementations: virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; virtual bool GetAcceleratorForCommandId( int command_id, ui::Accelerator* accelerator) OVERRIDE; virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE; scoped_ptr model_; private: static v8::Handle New(const v8::Arguments &args); static v8::Handle InsertItem(const v8::Arguments &args); static v8::Handle InsertCheckItem(const v8::Arguments &args); static v8::Handle InsertRadioItem(const v8::Arguments &args); static v8::Handle InsertSeparator(const v8::Arguments &args); static v8::Handle InsertSubMenu(const v8::Arguments &args); static v8::Handle SetIcon(const v8::Arguments &args); static v8::Handle SetSublabel(const v8::Arguments &args); static v8::Handle Clear(const v8::Arguments &args); static v8::Handle GetIndexOfCommandId(const v8::Arguments &args); static v8::Handle GetItemCount(const v8::Arguments &args); static v8::Handle GetCommandIdAt(const v8::Arguments &args); static v8::Handle GetLabelAt(const v8::Arguments &args); static v8::Handle GetSublabelAt(const v8::Arguments &args); static v8::Handle IsItemCheckedAt(const v8::Arguments &args); static v8::Handle IsEnabledAt(const v8::Arguments &args); static v8::Handle IsVisibleAt(const v8::Arguments &args); DISALLOW_COPY_AND_ASSIGN(Menu); }; } // namespace api } // namespace atom #endif // ATOM_BROWSER_API_ATOM_API_MENU_H_