CefLabelButton
Header: cef_label_button.h
Category: Views Framework
Overview
Browser-process UI toolkit: windows, panels, layouts, buttons, textfields, and their delegates.
CefLabelButton
Source File: include/views/cef_label_button.h
Process / Thread Context: Browser Process / UI Thread.
Purpose: A button with optional text and/or icon. The most commonly used
Methods
static CefRefPtr<CefLabelButton> CreateLabelButton(CefRefPtr<CefButtonDelegate> delegate, const CefString& text)
Parameters:
delegate: ACefButtonDelegateto handle clicks. Required.text: Initial text shown on the button; also used as the default
Return Value: A new LabelButton.
Usage Instruction: Static factory.
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefMenuButton> AsMenuButton() = 0
Parameters:
- none.
Return Value: This button as a CefMenuButton, or NULL.
Usage Instruction: Down-cast helper.
Threading Constraint: Browser process UI thread.
virtual void SetText(const CefString& text) = 0
Parameters:
text: The new button text.
Return Value: void. Also updates the accessible name by default.
Usage Instruction: Change the label at runtime.
Threading Constraint: Browser process UI thread.
virtual CefString GetText() = 0
Parameters:
- none.
Return Value: Current button text.
Usage Instruction: Read the label.
Threading Constraint: Browser process UI thread.
virtual void SetImage(cef_button_state_t button_state, CefRefPtr<CefImage> image) = 0
Parameters:
button_state: The state for which this image applies.image: The image to display (may be NULL).
Return Value: void. If no image exists for the current state, the
Usage Instruction: Provide per-state icons (normal/hovered/pressed).
Threading Constraint: Browser process UI thread.
virtual CefRefPtr<CefImage> GetImage(cef_button_state_t button_state) = 0
Parameters:
button_state: The state whose image is requested.
Return Value: The image for that state, or the normal-state image.
Usage Instruction: Read the current images.
Threading Constraint: Browser process UI thread.
virtual void SetTextColor(cef_button_state_t for_state, cef_color_t color) = 0
Parameters:
for_state: The state to apply the color to.color: The text color.
Return Value: void.
Usage Instruction: Per-state text colors.
Threading Constraint: Browser process UI thread.
virtual void SetEnabledTextColors(cef_color_t color) = 0
Parameters:
color: The color to apply to all non-disabled states.
Return Value: void.
Usage Instruction: Convenience for setting all enabled-state colors at
Threading Constraint: Browser process UI thread.
virtual void SetFontList(const CefString& font_list) = 0
Parameters:
font_list: A font description string of the form
Return Value: void.
Usage Instruction: Change the button's font.
Threading Constraint: Browser process UI thread.
virtual void SetHorizontalAlignment(cef_horizontal_alignment_t alignment) = 0
Parameters:
alignment: One ofCEF_HORIZONTAL_ALIGNMENT_LEFT,_CENTER,_RIGHT.
Return Value: void.
Usage Instruction: Align text within the button bounds.
Threading Constraint: Browser process UI thread.
virtual void SetMinimumSize(const CefSize& size) = 0
Parameters:
size: The new minimum size.
Return Value: void.
Usage Instruction: Override the default minimum size.
Threading Constraint: Browser process UI thread.
virtual void SetMaximumSize(const CefSize& size) = 0
Parameters:
size: The new maximum size.
Return Value: void.
Usage Instruction: Constrain the maximum size.
Threading Constraint: Browser process UI thread.
Usage Example
auto btn = CefLabelButton::CreateLabelButton(new SaveButtonDelegate(), "Save");
btn->SetFontList("Segoe UI, 14px");
btn->SetTextColor(CEF_BUTTON_STATE_HOVERED, cef_color_set_argb(255, 0, 120, 215));
btn->SetImage(CEF_BUTTON_STATE_NORMAL, LoadIcon("save.png"));
btn->SetHorizontalAlignment(CEF_HORIZONTAL_ALIGNMENT_CENTER);
btn->SetMinimumSize(CefSize(80, 30));
panel->AddChildView(btn);