Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / chromeos / ime / ibus_text.h
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.
4
5 #ifndef CHROMEOS_IME_IBUS_TEXT_H_
6 #define CHROMEOS_IME_IBUS_TEXT_H_
7
8 #include <string>
9 #include <vector>
10 #include "base/basictypes.h"
11 #include "chromeos/chromeos_export.h"
12
13 namespace chromeos {
14
15 class CHROMEOS_EXPORT IBusText {
16  public:
17   enum IBusTextUnderlineType {
18     IBUS_TEXT_UNDERLINE_SINGLE = 1,
19     IBUS_TEXT_UNDERLINE_DOUBLE = 2,
20     IBUS_TEXT_UNDERLINE_ERROR  = 4,
21   };
22
23   struct UnderlineAttribute {
24     IBusTextUnderlineType type;
25     uint32 start_index;  // The inclusive start index.
26     uint32 end_index;  // The exclusive end index.
27   };
28
29   // Accessors
30   IBusText();
31   virtual ~IBusText();
32
33   const std::string& text() const { return text_; }
34   void set_text(const std::string& text) { text_ = text; }
35
36   const std::vector<UnderlineAttribute>& underline_attributes() const {
37     return underline_attributes_;
38   }
39
40   std::vector<UnderlineAttribute>* mutable_underline_attributes() {
41     return &underline_attributes_;
42   }
43
44   uint32 selection_start() const { return selection_start_; }
45   void set_selection_start(uint32 selection_start) {
46     selection_start_ = selection_start;
47   }
48
49   uint32 selection_end() const { return selection_end_; }
50   void set_selection_end(uint32 selection_end) {
51     selection_end_ = selection_end;
52   }
53
54   void CopyFrom(const IBusText& obj);
55
56  private:
57   std::string text_;
58   std::vector<UnderlineAttribute> underline_attributes_;
59   uint32 selection_start_;
60   uint32 selection_end_;
61
62   DISALLOW_COPY_AND_ASSIGN(IBusText);
63 };
64
65 }  // namespace chromeos
66
67 #endif  // CHROMEOS_IME_IBUS_TEXT_H_