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_VIEW_DELEGATE_H_ 38 #define CEF_INCLUDE_VIEWS_CEF_VIEW_DELEGATE_H_ 39 #pragma once 40 41 #include "include/cef_base.h" 42 43 class CefView; 44 45 /// 46 // Implement this interface to handle view events. The methods of this class 47 // will be called on the browser process UI thread unless otherwise indicated. 48 /// 49 /*--cef(source=client)--*/ 50 class CefViewDelegate : public virtual CefBaseRefCounted { 51 public: 52 /// 53 // Return the preferred size for |view|. The Layout will use this information 54 // to determine the display size. 55 /// 56 /*--cef()--*/ GetPreferredSize(CefRefPtr<CefView> view)57 virtual CefSize GetPreferredSize(CefRefPtr<CefView> view) { 58 return CefSize(); 59 } 60 61 /// 62 // Return the minimum size for |view|. 63 /// 64 /*--cef()--*/ GetMinimumSize(CefRefPtr<CefView> view)65 virtual CefSize GetMinimumSize(CefRefPtr<CefView> view) { return CefSize(); } 66 67 /// 68 // Return the maximum size for |view|. 69 /// 70 /*--cef()--*/ GetMaximumSize(CefRefPtr<CefView> view)71 virtual CefSize GetMaximumSize(CefRefPtr<CefView> view) { return CefSize(); } 72 73 /// 74 // Return the height necessary to display |view| with the provided |width|. 75 // If not specified the result of GetPreferredSize().height will be used by 76 // default. Override if |view|'s preferred height depends upon the width 77 // (for example, with Labels). 78 /// 79 /*--cef()--*/ GetHeightForWidth(CefRefPtr<CefView> view,int width)80 virtual int GetHeightForWidth(CefRefPtr<CefView> view, int width) { 81 return 0; 82 } 83 84 /// 85 // Called when the parent of |view| has changed. If |view| is being added to 86 // |parent| then |added| will be true. If |view| is being removed from 87 // |parent| then |added| will be false. If |view| is being reparented the 88 // remove notification will be sent before the add notification. Do not modify 89 // the view hierarchy in this callback. 90 /// 91 /*--cef()--*/ OnParentViewChanged(CefRefPtr<CefView> view,bool added,CefRefPtr<CefView> parent)92 virtual void OnParentViewChanged(CefRefPtr<CefView> view, 93 bool added, 94 CefRefPtr<CefView> parent) {} 95 96 /// 97 // Called when a child of |view| has changed. If |child| is being added to 98 // |view| then |added| will be true. If |child| is being removed from |view| 99 // then |added| will be false. If |child| is being reparented the remove 100 // notification will be sent to the old parent before the add notification is 101 // sent to the new parent. Do not modify the view hierarchy in this callback. 102 /// 103 /*--cef()--*/ OnChildViewChanged(CefRefPtr<CefView> view,bool added,CefRefPtr<CefView> child)104 virtual void OnChildViewChanged(CefRefPtr<CefView> view, 105 bool added, 106 CefRefPtr<CefView> child) {} 107 108 /// 109 // Called when |view| is added or removed from the CefWindow. 110 /// 111 /*--cef()--*/ OnWindowChanged(CefRefPtr<CefView> view,bool added)112 virtual void OnWindowChanged(CefRefPtr<CefView> view, bool added) {} 113 114 /// 115 // Called when the layout of |view| has changed. 116 /// 117 /*--cef()--*/ OnLayoutChanged(CefRefPtr<CefView> view,const CefRect & new_bounds)118 virtual void OnLayoutChanged(CefRefPtr<CefView> view, 119 const CefRect& new_bounds) {} 120 121 /// 122 // Called when |view| gains focus. 123 /// 124 /*--cef()--*/ OnFocus(CefRefPtr<CefView> view)125 virtual void OnFocus(CefRefPtr<CefView> view) {} 126 127 /// 128 // Called when |view| loses focus. 129 /// 130 /*--cef()--*/ OnBlur(CefRefPtr<CefView> view)131 virtual void OnBlur(CefRefPtr<CefView> view) {} 132 }; 133 134 #endif // CEF_INCLUDE_VIEWS_CEF_WINDOW_DELEGATE_H_ 135