clean up PYConfig.h/cc
[platform/upstream/ibus-libpinyin.git] / src / PYText.h
1 /* vim:set et ts=4 sts=4:
2  *
3  * ibus-pinyin - The Chinese PinYin engine for IBus
4  *
5  * Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #ifndef __PY_TEXT_H_
22 #define __PY_TEXT_H_
23
24 #include <string>
25 #include <ibus.h>
26 #include "PYObject.h"
27
28 namespace PY {
29
30 class Text : Object {
31 public:
32     Text (IBusText *text)
33         : Object (text) { }
34     Text (const gchar *str)
35         : Object (ibus_text_new_from_string (str)) { }
36
37     Text (const std::string & str)
38         : Object (ibus_text_new_from_string (str.c_str ())) { }
39
40     Text (gunichar ch)
41         : Object (ibus_text_new_from_unichar (ch)) { }
42
43     void appendAttribute (guint type, guint value, guint start, guint end)
44     {
45         ibus_text_append_attribute (get<IBusText> (), type, value, start, end);
46     }
47
48     const gchar *text (void) const
49     {
50         return get<IBusText> ()->text;
51     }
52
53     operator IBusText * (void) const
54     {
55         return get<IBusText> ();
56     }
57 };
58
59 class StaticText : public Text {
60 public:
61     StaticText (const gchar *str)
62         : Text (ibus_text_new_from_static_string (str)) { }
63
64     StaticText (const std::string & str)
65         : Text (ibus_text_new_from_static_string (str.c_str ())) { }
66
67     StaticText (gunichar ch)
68         : Text (ch) { }
69
70     operator IBusText * (void) const
71     {
72         return Text::operator IBusText * ();
73     }
74 };
75
76 };
77
78 #endif