Chromium Embedded Framework (CEF)  122.1.5+gf09a9bc+chromium-122.0.6261.29
CefMenuModel Class Referenceabstract

Supports creation and modification of menus. More...

#include "include/cef_menu_model.h"

Inheritance diagram for CefMenuModel:
CefBaseRefCounted

Public Types

typedef cef_menu_item_type_t MenuItemType
 

Public Member Functions

virtual bool IsSubMenu ()=0
 Returns true if this menu is a submenu. More...
 
virtual bool Clear ()=0
 Clears the menu. More...
 
virtual size_t GetCount ()=0
 Returns the number of items in this menu. More...
 
virtual bool AddSeparator ()=0
 Add a separator to the menu. More...
 
virtual bool AddItem (int command_id, const CefString &label)=0
 Add an item to the menu. More...
 
virtual bool AddCheckItem (int command_id, const CefString &label)=0
 Add a check item to the menu. More...
 
virtual bool AddRadioItem (int command_id, const CefString &label, int group_id)=0
 Add a radio item to the menu. More...
 
virtual CefRefPtr< CefMenuModelAddSubMenu (int command_id, const CefString &label)=0
 Add a sub-menu to the menu. More...
 
virtual bool InsertSeparatorAt (size_t index)=0
 Insert a separator in the menu at the specified |index|. More...
 
virtual bool InsertItemAt (size_t index, int command_id, const CefString &label)=0
 Insert an item in the menu at the specified |index|. More...
 
virtual bool InsertCheckItemAt (size_t index, int command_id, const CefString &label)=0
 Insert a check item in the menu at the specified |index|. More...
 
virtual bool InsertRadioItemAt (size_t index, int command_id, const CefString &label, int group_id)=0
 Insert a radio item in the menu at the specified |index|. More...
 
virtual CefRefPtr< CefMenuModelInsertSubMenuAt (size_t index, int command_id, const CefString &label)=0
 Insert a sub-menu in the menu at the specified |index|. More...
 
virtual bool Remove (int command_id)=0
 Removes the item with the specified |command_id|. More...
 
virtual bool RemoveAt (size_t index)=0
 Removes the item at the specified |index|. More...
 
virtual int GetIndexOf (int command_id)=0
 Returns the index associated with the specified |command_id| or -1 if not found due to the command id not existing in the menu. More...
 
virtual int GetCommandIdAt (size_t index)=0
 Returns the command id at the specified |index| or -1 if not found due to invalid range or the index being a separator. More...
 
virtual bool SetCommandIdAt (size_t index, int command_id)=0
 Sets the command id at the specified |index|. More...
 
virtual CefString GetLabel (int command_id)=0
 Returns the label for the specified |command_id| or empty if not found. More...
 
virtual CefString GetLabelAt (size_t index)=0
 Returns the label at the specified |index| or empty if not found due to invalid range or the index being a separator. More...
 
virtual bool SetLabel (int command_id, const CefString &label)=0
 Sets the label for the specified |command_id|. More...
 
virtual bool SetLabelAt (size_t index, const CefString &label)=0
 Set the label at the specified |index|. More...
 
virtual MenuItemType GetType (int command_id)=0
 Returns the item type for the specified |command_id|. More...
 
virtual MenuItemType GetTypeAt (size_t index)=0
 Returns the item type at the specified |index|. More...
 
virtual int GetGroupId (int command_id)=0
 Returns the group id for the specified |command_id| or -1 if invalid. More...
 
virtual int GetGroupIdAt (size_t index)=0
 Returns the group id at the specified |index| or -1 if invalid. More...
 
virtual bool SetGroupId (int command_id, int group_id)=0
 Sets the group id for the specified |command_id|. More...
 
virtual bool SetGroupIdAt (size_t index, int group_id)=0
 Sets the group id at the specified |index|. More...
 
virtual CefRefPtr< CefMenuModelGetSubMenu (int command_id)=0
 Returns the submenu for the specified |command_id| or empty if invalid. More...
 
virtual CefRefPtr< CefMenuModelGetSubMenuAt (size_t index)=0
 Returns the submenu at the specified |index| or empty if invalid. More...
 
virtual bool IsVisible (int command_id)=0
 Returns true if the specified |command_id| is visible. More...
 
virtual bool IsVisibleAt (size_t index)=0
 Returns true if the specified |index| is visible. More...
 
virtual bool SetVisible (int command_id, bool visible)=0
 Change the visibility of the specified |command_id|. More...
 
virtual bool SetVisibleAt (size_t index, bool visible)=0
 Change the visibility at the specified |index|. More...
 
virtual bool IsEnabled (int command_id)=0
 Returns true if the specified |command_id| is enabled. More...
 
virtual bool IsEnabledAt (size_t index)=0
 Returns true if the specified |index| is enabled. More...
 
virtual bool SetEnabled (int command_id, bool enabled)=0
 Change the enabled status of the specified |command_id|. More...
 
virtual bool SetEnabledAt (size_t index, bool enabled)=0
 Change the enabled status at the specified |index|. More...
 
virtual bool IsChecked (int command_id)=0
 Returns true if the specified |command_id| is checked. More...
 
virtual bool IsCheckedAt (size_t index)=0
 Returns true if the specified |index| is checked. More...
 
virtual bool SetChecked (int command_id, bool checked)=0
 Check the specified |command_id|. More...
 
virtual bool SetCheckedAt (size_t index, bool checked)=0
 Check the specified |index|. More...
 
virtual bool HasAccelerator (int command_id)=0
 Returns true if the specified |command_id| has a keyboard accelerator assigned. More...
 
virtual bool HasAcceleratorAt (size_t index)=0
 Returns true if the specified |index| has a keyboard accelerator assigned. More...
 
virtual bool SetAccelerator (int command_id, int key_code, bool shift_pressed, bool ctrl_pressed, bool alt_pressed)=0
 Set the keyboard accelerator for the specified |command_id|. More...
 
virtual bool SetAcceleratorAt (size_t index, int key_code, bool shift_pressed, bool ctrl_pressed, bool alt_pressed)=0
 Set the keyboard accelerator at the specified |index|. More...
 
virtual bool RemoveAccelerator (int command_id)=0
 Remove the keyboard accelerator for the specified |command_id|. More...
 
virtual bool RemoveAcceleratorAt (size_t index)=0
 Remove the keyboard accelerator at the specified |index|. More...
 
virtual bool GetAccelerator (int command_id, int &key_code, bool &shift_pressed, bool &ctrl_pressed, bool &alt_pressed)=0
 Retrieves the keyboard accelerator for the specified |command_id|. More...
 
virtual bool GetAcceleratorAt (size_t index, int &key_code, bool &shift_pressed, bool &ctrl_pressed, bool &alt_pressed)=0
 Retrieves the keyboard accelerator for the specified |index|. More...
 
virtual bool SetColor (int command_id, cef_menu_color_type_t color_type, cef_color_t color)=0
 Set the explicit color for |command_id| and |color_type| to |color|. More...
 
virtual bool SetColorAt (int index, cef_menu_color_type_t color_type, cef_color_t color)=0
 Set the explicit color for |command_id| and |index| to |color|. More...
 
virtual bool GetColor (int command_id, cef_menu_color_type_t color_type, cef_color_t &color)=0
 Returns in |color| the color that was explicitly set for |command_id| and |color_type|. More...
 
virtual bool GetColorAt (int index, cef_menu_color_type_t color_type, cef_color_t &color)=0
 Returns in |color| the color that was explicitly set for |command_id| and |color_type|. More...
 
virtual bool SetFontList (int command_id, const CefString &font_list)=0
 Sets the font list for the specified |command_id|. More...
 
virtual bool SetFontListAt (int index, const CefString &font_list)=0
 Sets the font list for the specified |index|. More...
 
- Public Member Functions inherited from CefBaseRefCounted
virtual void AddRef () const =0
 Called to increment the reference count for the object. More...
 
virtual bool Release () const =0
 Called to decrement the reference count for the object. More...
 
virtual bool HasOneRef () const =0
 Returns true if the reference count is 1. More...
 
virtual bool HasAtLeastOneRef () const =0
 Returns true if the reference count is at least 1. More...
 

Static Public Member Functions

static CefRefPtr< CefMenuModelCreateMenuModel (CefRefPtr< CefMenuModelDelegate > delegate)
 Create a new MenuModel with the specified |delegate|. More...
 

Additional Inherited Members

- Protected Member Functions inherited from CefBaseRefCounted
virtual ~CefBaseRefCounted ()
 

Detailed Description

Supports creation and modification of menus.

See cef_menu_id_t for the command ids that have default implementations. All user-defined command ids should be between MENU_ID_USER_FIRST and MENU_ID_USER_LAST. The methods of this class can only be accessed on the browser process the UI thread.

Member Typedef Documentation

◆ MenuItemType

Member Function Documentation

◆ AddCheckItem()

virtual bool CefMenuModel::AddCheckItem ( int  command_id,
const CefString label 
)
pure virtual

Add a check item to the menu.

Returns true on success.

◆ AddItem()

virtual bool CefMenuModel::AddItem ( int  command_id,
const CefString label 
)
pure virtual

Add an item to the menu.

Returns true on success.

◆ AddRadioItem()

virtual bool CefMenuModel::AddRadioItem ( int  command_id,
const CefString label,
int  group_id 
)
pure virtual

Add a radio item to the menu.

Only a single item with the specified |group_id| can be checked at a time. Returns true on success.

◆ AddSeparator()

virtual bool CefMenuModel::AddSeparator ( )
pure virtual

Add a separator to the menu.

Returns true on success.

◆ AddSubMenu()

virtual CefRefPtr<CefMenuModel> CefMenuModel::AddSubMenu ( int  command_id,
const CefString label 
)
pure virtual

Add a sub-menu to the menu.

The new sub-menu is returned.

◆ Clear()

virtual bool CefMenuModel::Clear ( )
pure virtual

Clears the menu.

Returns true on success.

◆ CreateMenuModel()

static CefRefPtr<CefMenuModel> CefMenuModel::CreateMenuModel ( CefRefPtr< CefMenuModelDelegate delegate)
static

Create a new MenuModel with the specified |delegate|.

◆ GetAccelerator()

virtual bool CefMenuModel::GetAccelerator ( int  command_id,
int &  key_code,
bool &  shift_pressed,
bool &  ctrl_pressed,
bool &  alt_pressed 
)
pure virtual

Retrieves the keyboard accelerator for the specified |command_id|.

Returns true on success.

◆ GetAcceleratorAt()

virtual bool CefMenuModel::GetAcceleratorAt ( size_t  index,
int &  key_code,
bool &  shift_pressed,
bool &  ctrl_pressed,
bool &  alt_pressed 
)
pure virtual

Retrieves the keyboard accelerator for the specified |index|.

Returns true on success.

◆ GetColor()

virtual bool CefMenuModel::GetColor ( int  command_id,
cef_menu_color_type_t  color_type,
cef_color_t color 
)
pure virtual

Returns in |color| the color that was explicitly set for |command_id| and |color_type|.

If a color was not set then 0 will be returned in |color|. Returns true on success.

◆ GetColorAt()

virtual bool CefMenuModel::GetColorAt ( int  index,
cef_menu_color_type_t  color_type,
cef_color_t color 
)
pure virtual

Returns in |color| the color that was explicitly set for |command_id| and |color_type|.

Specify an |index| value of -1 to return the default color in |color|. If a color was not set then 0 will be returned in |color|. Returns true on success.

◆ GetCommandIdAt()

virtual int CefMenuModel::GetCommandIdAt ( size_t  index)
pure virtual

Returns the command id at the specified |index| or -1 if not found due to invalid range or the index being a separator.

◆ GetCount()

virtual size_t CefMenuModel::GetCount ( )
pure virtual

Returns the number of items in this menu.

◆ GetGroupId()

virtual int CefMenuModel::GetGroupId ( int  command_id)
pure virtual

Returns the group id for the specified |command_id| or -1 if invalid.

◆ GetGroupIdAt()

virtual int CefMenuModel::GetGroupIdAt ( size_t  index)
pure virtual

Returns the group id at the specified |index| or -1 if invalid.

◆ GetIndexOf()

virtual int CefMenuModel::GetIndexOf ( int  command_id)
pure virtual

Returns the index associated with the specified |command_id| or -1 if not found due to the command id not existing in the menu.

◆ GetLabel()

virtual CefString CefMenuModel::GetLabel ( int  command_id)
pure virtual

Returns the label for the specified |command_id| or empty if not found.

◆ GetLabelAt()

virtual CefString CefMenuModel::GetLabelAt ( size_t  index)
pure virtual

Returns the label at the specified |index| or empty if not found due to invalid range or the index being a separator.

◆ GetSubMenu()

virtual CefRefPtr<CefMenuModel> CefMenuModel::GetSubMenu ( int  command_id)
pure virtual

Returns the submenu for the specified |command_id| or empty if invalid.

◆ GetSubMenuAt()

virtual CefRefPtr<CefMenuModel> CefMenuModel::GetSubMenuAt ( size_t  index)
pure virtual

Returns the submenu at the specified |index| or empty if invalid.

◆ GetType()

virtual MenuItemType CefMenuModel::GetType ( int  command_id)
pure virtual

Returns the item type for the specified |command_id|.

◆ GetTypeAt()

virtual MenuItemType CefMenuModel::GetTypeAt ( size_t  index)
pure virtual

Returns the item type at the specified |index|.

◆ HasAccelerator()

virtual bool CefMenuModel::HasAccelerator ( int  command_id)
pure virtual

Returns true if the specified |command_id| has a keyboard accelerator assigned.

◆ HasAcceleratorAt()

virtual bool CefMenuModel::HasAcceleratorAt ( size_t  index)
pure virtual

Returns true if the specified |index| has a keyboard accelerator assigned.

◆ InsertCheckItemAt()

virtual bool CefMenuModel::InsertCheckItemAt ( size_t  index,
int  command_id,
const CefString label 
)
pure virtual

Insert a check item in the menu at the specified |index|.

Returns true on success.

◆ InsertItemAt()

virtual bool CefMenuModel::InsertItemAt ( size_t  index,
int  command_id,
const CefString label 
)
pure virtual

Insert an item in the menu at the specified |index|.

Returns true on success.

◆ InsertRadioItemAt()

virtual bool CefMenuModel::InsertRadioItemAt ( size_t  index,
int  command_id,
const CefString label,
int  group_id 
)
pure virtual

Insert a radio item in the menu at the specified |index|.

Only a single item with the specified |group_id| can be checked at a time. Returns true on success.

◆ InsertSeparatorAt()

virtual bool CefMenuModel::InsertSeparatorAt ( size_t  index)
pure virtual

Insert a separator in the menu at the specified |index|.

Returns true on success.

◆ InsertSubMenuAt()

virtual CefRefPtr<CefMenuModel> CefMenuModel::InsertSubMenuAt ( size_t  index,
int  command_id,
const CefString label 
)
pure virtual

Insert a sub-menu in the menu at the specified |index|.

The new sub-menu is returned.

◆ IsChecked()

virtual bool CefMenuModel::IsChecked ( int  command_id)
pure virtual

Returns true if the specified |command_id| is checked.

Only applies to check and radio items.

◆ IsCheckedAt()

virtual bool CefMenuModel::IsCheckedAt ( size_t  index)
pure virtual

Returns true if the specified |index| is checked.

Only applies to check and radio items.

◆ IsEnabled()

virtual bool CefMenuModel::IsEnabled ( int  command_id)
pure virtual

Returns true if the specified |command_id| is enabled.

◆ IsEnabledAt()

virtual bool CefMenuModel::IsEnabledAt ( size_t  index)
pure virtual

Returns true if the specified |index| is enabled.

◆ IsSubMenu()

virtual bool CefMenuModel::IsSubMenu ( )
pure virtual

Returns true if this menu is a submenu.

◆ IsVisible()

virtual bool CefMenuModel::IsVisible ( int  command_id)
pure virtual

Returns true if the specified |command_id| is visible.

◆ IsVisibleAt()

virtual bool CefMenuModel::IsVisibleAt ( size_t  index)
pure virtual

Returns true if the specified |index| is visible.

◆ Remove()

virtual bool CefMenuModel::Remove ( int  command_id)
pure virtual

Removes the item with the specified |command_id|.

Returns true on success.

◆ RemoveAccelerator()

virtual bool CefMenuModel::RemoveAccelerator ( int  command_id)
pure virtual

Remove the keyboard accelerator for the specified |command_id|.

Returns true on success.

◆ RemoveAcceleratorAt()

virtual bool CefMenuModel::RemoveAcceleratorAt ( size_t  index)
pure virtual

Remove the keyboard accelerator at the specified |index|.

Returns true on success.

◆ RemoveAt()

virtual bool CefMenuModel::RemoveAt ( size_t  index)
pure virtual

Removes the item at the specified |index|.

Returns true on success.

◆ SetAccelerator()

virtual bool CefMenuModel::SetAccelerator ( int  command_id,
int  key_code,
bool  shift_pressed,
bool  ctrl_pressed,
bool  alt_pressed 
)
pure virtual

Set the keyboard accelerator for the specified |command_id|.

|key_code| can be any virtual key or character value. Returns true on success.

◆ SetAcceleratorAt()

virtual bool CefMenuModel::SetAcceleratorAt ( size_t  index,
int  key_code,
bool  shift_pressed,
bool  ctrl_pressed,
bool  alt_pressed 
)
pure virtual

Set the keyboard accelerator at the specified |index|.

|key_code| can be any virtual key or character value. Returns true on success.

◆ SetChecked()

virtual bool CefMenuModel::SetChecked ( int  command_id,
bool  checked 
)
pure virtual

Check the specified |command_id|.

Only applies to check and radio items. Returns true on success.

◆ SetCheckedAt()

virtual bool CefMenuModel::SetCheckedAt ( size_t  index,
bool  checked 
)
pure virtual

Check the specified |index|.

Only applies to check and radio items. Returns true on success.

◆ SetColor()

virtual bool CefMenuModel::SetColor ( int  command_id,
cef_menu_color_type_t  color_type,
cef_color_t  color 
)
pure virtual

Set the explicit color for |command_id| and |color_type| to |color|.

Specify a |color| value of 0 to remove the explicit color. If no explicit color or default color is set for |color_type| then the system color will be used. Returns true on success.

◆ SetColorAt()

virtual bool CefMenuModel::SetColorAt ( int  index,
cef_menu_color_type_t  color_type,
cef_color_t  color 
)
pure virtual

Set the explicit color for |command_id| and |index| to |color|.

Specify a |color| value of 0 to remove the explicit color. Specify an |index| value of -1 to set the default color for items that do not have an explicit color set. If no explicit color or default color is set for |color_type| then the system color will be used. Returns true on success.

◆ SetCommandIdAt()

virtual bool CefMenuModel::SetCommandIdAt ( size_t  index,
int  command_id 
)
pure virtual

Sets the command id at the specified |index|.

Returns true on success.

◆ SetEnabled()

virtual bool CefMenuModel::SetEnabled ( int  command_id,
bool  enabled 
)
pure virtual

Change the enabled status of the specified |command_id|.

Returns true on success.

◆ SetEnabledAt()

virtual bool CefMenuModel::SetEnabledAt ( size_t  index,
bool  enabled 
)
pure virtual

Change the enabled status at the specified |index|.

Returns true on success.

◆ SetFontList()

virtual bool CefMenuModel::SetFontList ( int  command_id,
const CefString font_list 
)
pure virtual

Sets the font list for the specified |command_id|.

If |font_list| is empty the system font will be used. Returns true on success. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>", where:

  • FONT_FAMILY_LIST is a comma-separated list of font family names,
  • STYLES is an optional space-separated list of style names (case-sensitive "Bold" and "Italic" are supported), and
  • SIZE is an integer font size in pixels with the suffix "px".

Here are examples of valid font description strings:

  • "Arial, Helvetica, Bold Italic 14px"
  • "Arial, 14px"

◆ SetFontListAt()

virtual bool CefMenuModel::SetFontListAt ( int  index,
const CefString font_list 
)
pure virtual

Sets the font list for the specified |index|.

Specify an |index| value of -1 to set the default font. If |font_list| is empty the system font will be used. Returns true on success. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>", where:

  • FONT_FAMILY_LIST is a comma-separated list of font family names,
  • STYLES is an optional space-separated list of style names (case-sensitive "Bold" and "Italic" are supported), and
  • SIZE is an integer font size in pixels with the suffix "px".

Here are examples of valid font description strings:

  • "Arial, Helvetica, Bold Italic 14px"
  • "Arial, 14px"

◆ SetGroupId()

virtual bool CefMenuModel::SetGroupId ( int  command_id,
int  group_id 
)
pure virtual

Sets the group id for the specified |command_id|.

Returns true on success.

◆ SetGroupIdAt()

virtual bool CefMenuModel::SetGroupIdAt ( size_t  index,
int  group_id 
)
pure virtual

Sets the group id at the specified |index|.

Returns true on success.

◆ SetLabel()

virtual bool CefMenuModel::SetLabel ( int  command_id,
const CefString label 
)
pure virtual

Sets the label for the specified |command_id|.

Returns true on success.

◆ SetLabelAt()

virtual bool CefMenuModel::SetLabelAt ( size_t  index,
const CefString label 
)
pure virtual

Set the label at the specified |index|.

Returns true on success.

◆ SetVisible()

virtual bool CefMenuModel::SetVisible ( int  command_id,
bool  visible 
)
pure virtual

Change the visibility of the specified |command_id|.

Returns true on success.

◆ SetVisibleAt()

virtual bool CefMenuModel::SetVisibleAt ( size_t  index,
bool  visible 
)
pure virtual

Change the visibility at the specified |index|.

Returns true on success.


The documentation for this class was generated from the following file: