1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef WIN8_METRO_DRIVER_IME_TEXT_STORE_DELEGATE_H_
6 #define WIN8_METRO_DRIVER_IME_TEXT_STORE_DELEGATE_H_
12 #include "base/basictypes.h"
13 #include "base/strings/string16.h"
15 namespace metro_viewer
{
19 namespace metro_driver
{
21 // A delegate which works together with virtual text stores.
22 // Objects that implement this delegate will receive notifications from a
23 // virtual text store whenever an IME updates the composition or commits text.
24 // Objects that implement this delegate are also responsible for calculating
25 // the character position of composition and caret position upon request.
26 class TextStoreDelegate
{
28 virtual ~TextStoreDelegate() {}
30 // Called when on-going composition is updated. An empty |text| represents
31 // that the composition is canceled.
32 virtual void OnCompositionChanged(
33 const base::string16
& text
,
34 int32 selection_start
,
36 const std::vector
<metro_viewer::UnderlineInfo
>& underlines
) = 0;
38 // Called when |text| is committed.
39 virtual void OnTextCommitted(const base::string16
& text
) = 0;
41 // Called when an IME requests the caret position. Objects that implement
42 // this method must return the caret position in screen coordinates.
43 virtual RECT
GetCaretBounds() = 0;
45 // Called when an IME requests the bounding box of an character whose
46 // index is |index| in the on-going composition. position. Objects that
47 // implement this method must return true and fill the character bounds into
48 // |rect| in screen coordinates.
49 // Should return false if |index| is invalid.
50 virtual bool GetCompositionCharacterBounds(uint32 index
, RECT
* rect
) = 0;
53 } // namespace metro_driver
55 #endif // WIN8_METRO_DRIVER_IME_TEXT_STORE_DELEGATE_H_