• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // ---------------------------------------------------------------------------
31 //
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
35 //
36 
37 #ifndef CEF_INCLUDE_VIEWS_CEF_LABEL_BUTTON_H_
38 #define CEF_INCLUDE_VIEWS_CEF_LABEL_BUTTON_H_
39 #pragma once
40 
41 #include "include/cef_image.h"
42 #include "include/views/cef_button.h"
43 #include "include/views/cef_button_delegate.h"
44 
45 class CefMenuButton;
46 
47 ///
48 // LabelButton is a button with optional text and/or icon. Methods must be
49 // called on the browser process UI thread unless otherwise indicated.
50 ///
51 /*--cef(source=library)--*/
52 class CefLabelButton : public CefButton {
53  public:
54   ///
55   // Create a new LabelButton. A |delegate| must be provided to handle the
56   // button click. |text| will be shown on the LabelButton and used as the
57   // default accessible name.
58   ///
59   /*--cef(optional_param=text)--*/
60   static CefRefPtr<CefLabelButton> CreateLabelButton(
61       CefRefPtr<CefButtonDelegate> delegate,
62       const CefString& text);
63 
64   ///
65   // Returns this LabelButton as a MenuButton or NULL if this is not a
66   // MenuButton.
67   ///
68   /*--cef()--*/
69   virtual CefRefPtr<CefMenuButton> AsMenuButton() = 0;
70 
71   ///
72   // Sets the text shown on the LabelButton. By default |text| will also be used
73   // as the accessible name.
74   ///
75   /*--cef()--*/
76   virtual void SetText(const CefString& text) = 0;
77 
78   ///
79   // Returns the text shown on the LabelButton.
80   ///
81   /*--cef()--*/
82   virtual CefString GetText() = 0;
83 
84   ///
85   // Sets the image shown for |button_state|. When this Button is drawn if no
86   // image exists for the current state then the image for
87   // CEF_BUTTON_STATE_NORMAL, if any, will be shown.
88   ///
89   /*--cef(optional_param=image)--*/
90   virtual void SetImage(cef_button_state_t button_state,
91                         CefRefPtr<CefImage> image) = 0;
92 
93   ///
94   // Returns the image shown for |button_state|. If no image exists for that
95   // state then the image for CEF_BUTTON_STATE_NORMAL will be returned.
96   ///
97   /*--cef()--*/
98   virtual CefRefPtr<CefImage> GetImage(cef_button_state_t button_state) = 0;
99 
100   ///
101   // Sets the text color shown for the specified button |for_state| to |color|.
102   ///
103   /*--cef()--*/
104   virtual void SetTextColor(cef_button_state_t for_state,
105                             cef_color_t color) = 0;
106 
107   ///
108   // Sets the text colors shown for the non-disabled states to |color|.
109   ///
110   /*--cef()--*/
111   virtual void SetEnabledTextColors(cef_color_t color) = 0;
112 
113   ///
114   // Sets the font list. The format is "<FONT_FAMILY_LIST>,[STYLES] <SIZE>",
115   // where:
116   // - FONT_FAMILY_LIST is a comma-separated list of font family names,
117   // - STYLES is an optional space-separated list of style names (case-sensitive
118   //   "Bold" and "Italic" are supported), and
119   // - SIZE is an integer font size in pixels with the suffix "px".
120   //
121   // Here are examples of valid font description strings:
122   // - "Arial, Helvetica, Bold Italic 14px"
123   // - "Arial, 14px"
124   ///
125   /*--cef()--*/
126   virtual void SetFontList(const CefString& font_list) = 0;
127 
128   ///
129   // Sets the horizontal alignment; reversed in RTL. Default is
130   // CEF_HORIZONTAL_ALIGNMENT_CENTER.
131   ///
132   /*--cef()--*/
133   virtual void SetHorizontalAlignment(cef_horizontal_alignment_t alignment) = 0;
134 
135   ///
136   // Reset the minimum size of this LabelButton to |size|.
137   ///
138   /*--cef()--*/
139   virtual void SetMinimumSize(const CefSize& size) = 0;
140 
141   ///
142   // Reset the maximum size of this LabelButton to |size|.
143   ///
144   /*--cef()--*/
145   virtual void SetMaximumSize(const CefSize& size) = 0;
146 };
147 
148 #endif  // CEF_INCLUDE_VIEWS_CEF_LABEL_BUTTON_H_
149