Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

scim_attribute.h

Go to the documentation of this file.
00001 /** @file scim_attribute.h 00002 * @brief Definition of scim::Attribute and scim::AttributeList 00003 * 00004 * Provide class scim::Attribute to control the 00005 * drawing effect of strings. 00006 */ 00007 00008 /* 00009 * Smart Common Input Method 00010 * 00011 * Copyright (c) 2004 James Su <suzhe@turbolinux.com.cn> 00012 * Copyright (c) 2003 James Su <suzhe@turbolinux.com.cn> 00013 * Copyright (c) 2002 James Su <suzhe@turbolinux.com.cn> 00014 * 00015 * 00016 * This library is free software; you can redistribute it and/or 00017 * modify it under the terms of the GNU Lesser General Public 00018 * License as published by the Free Software Foundation; either 00019 * version 2 of the License, or (at your option) any later version. 00020 * 00021 * This library is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU Lesser General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU Lesser General Public 00027 * License along with this program; if not, write to the 00028 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00029 * Boston, MA 02111-1307 USA 00030 * 00031 * $Id: scim_attribute.h,v 1.3 2004/06/06 02:32:28 suzhe Exp $ 00032 */ 00033 00034 00035 #ifndef __SCIM_ATTRIBUTE_H 00036 #define __SCIM_ATTRIBUTE_H 00037 00038 namespace scim { 00039 00040 /** 00041 * @addtogroup Helper 00042 * 00043 * The helper classes and functions, including Attribute, IConvert, LookupTable etc. 00044 * 00045 * @{ 00046 */ 00047 00048 /** 00049 * @brief Enum values of the valid attribute type. 00050 */ 00051 enum AttributeType 00052 { 00053 SCIM_ATTR_NONE, ///< No attribute. 00054 SCIM_ATTR_DECORATE, ///< A decorate attribute, eg. underline etc. 00055 SCIM_ATTR_FOREGROUND, ///< A foreground color attribute, in RGB format. 00056 SCIM_ATTR_BACKGROUND ///< A background color attribute, in RGB format. 00057 }; 00058 00059 const unsigned int SCIM_ATTR_DECORATE_NONE = 0; ///< No decorate 00060 const unsigned int SCIM_ATTR_DECORATE_UNDERLINE = 1; ///< Draw a line under the text 00061 const unsigned int SCIM_ATTR_DECORATE_HIGHLIGHT = 2; ///< Draw the text in highlighted color 00062 const unsigned int SCIM_ATTR_DECORATE_REVERSE = 4; ///< Draw the text in reverse color mode 00063 00064 #define SCIM_RGB_COLOR(RED,GREEN,BLUE) ((unsigned int)(((RED)<<16) + ((GREEN)<<8) + (BLUE))) 00065 #define SCIM_RGB_COLOR_RED(COLOR) ((unsigned int)((COLOR>>16) & 0x00ff)) 00066 #define SCIM_RGB_COLOR_GREEN(COLOR) ((unsigned int)((COLOR>>8) & 0x00ff)) 00067 #define SCIM_RGB_COLOR_BLUE(COLOR) ((unsigned int)((COLOR) & 0x00ff)) 00068 00069 /** 00070 * @brief Class to store the string attributes. 00071 * 00072 * The string attributes control the effect of the string 00073 * drawn by FrontEnds. There are currently four valid types. 00074 * 00075 * A attribute could be one of the following types: 00076 * - SCIM_ATTR_NONE No attribute 00077 * - SCIM_ATTR_DECORATE Decorate attribute, eg. underline, highlight etc. 00078 * - SCIM_ATTR_FOREGROUND Foreground color attribute, in RGB format. 00079 * - SCIM_ATTR_BACKGROUND Background color attribute, in RGB format. 00080 * 00081 * For a DECORATE attribute, it can be one of the following values: 00082 * - SCIM_ATTR_DECORATE_NONE No decorate 00083 * - SCIM_ATTR_DECORATE_UNDERLINE Underline 00084 * - SCIM_ATTR_DECORATE_HIGHLIGHT Highlight 00085 * - SCIM_ATTR_DECORATE_REVERSE Reverse 00086 * 00087 * For a FOREGROUND or BACKGROUND attribute, it's a RGB color value generated with 00088 * SCIM_RGB_COLOR (red,green,blue) macro. 00089 * You may use SCIM_RGB_COLOR_RED, SCIM_RGB_COLOR_GREEN and SCIM_RGB_COLOR_BLUE to extract 00090 * the RGB color later. 00091 */ 00092 class Attribute 00093 { 00094 unsigned int m_start; 00095 unsigned int m_length; 00096 00097 AttributeType m_type; 00098 unsigned int m_value; 00099 00100 public: 00101 /** 00102 * @brief Constructor 00103 * 00104 * @param start - the start position in the string of this attribute. 00105 * @param length - the length of this attribute, the range is [start,start+length). 00106 * @param type - the type of this attribute. 00107 * @param value - the value of this attribute. 00108 */ 00109 Attribute (unsigned int start = 0, 00110 unsigned int length = 0, 00111 AttributeType type = SCIM_ATTR_NONE, 00112 unsigned int value = 0) : 00113 m_start (start), m_length (length), m_type (type), m_value (value) 00114 { } 00115 00116 /** 00117 * @brief Get the type of this attribute. 00118 * 00119 * @return The type of this attribute. 00120 */ 00121 AttributeType get_type () const { return m_type; } 00122 00123 /** 00124 * @brief Get the value of this attribute. 00125 * 00126 * @return The value of this attribute. 00127 */ 00128 unsigned int get_value () const { return m_value; } 00129 00130 /** 00131 * @brief Get the start position of this attribute. 00132 * @return The start position of this attribute in the string. 00133 */ 00134 unsigned int get_start () const { return m_start; } 00135 00136 /** 00137 * @brief Get the length of this attribute. 00138 * @return The length of this attribute in the string. 00139 */ 00140 unsigned int get_length () const { return m_length; } 00141 00142 /** 00143 * @brief Get the end position of this attribute. 00144 * @return The end position of this attribute. 00145 */ 00146 unsigned int get_end () const { return m_start + m_length; } 00147 00148 /** 00149 * @brief Set the type of this attribute. 00150 * @param type - the new attribute type to be set. 00151 */ 00152 void set_type (AttributeType type) { m_type = type; } 00153 00154 /** 00155 * @brief Set the value of this attribute. 00156 * @param value - the new attribute value to be set. 00157 */ 00158 void set_value (unsigned int value) { m_value = value; } 00159 00160 /** 00161 * @brief Set the start position of this attribute. 00162 * @param start - the new start position in the string. 00163 */ 00164 void set_start (unsigned int start) { m_start = start; } 00165 00166 /** 00167 * @brief Set the length of this attribute. 00168 * @param length - the new length of this attribute. 00169 */ 00170 void set_length (unsigned int length) { m_length = length; } 00171 }; 00172 00173 /** 00174 * @typedef typedef std::vector<Attribute> AttributeList 00175 * @brief The container to store a set of Attribute objects. 00176 * 00177 * You should use the STL container methods to manipulate its objects. 00178 */ 00179 typedef std::vector<Attribute> AttributeList; 00180 00181 /** @} */ 00182 00183 } // namespace scim 00184 00185 #endif //__SCIM_ATTRIBUTE_H 00186 00187 /* 00188 vi:ts=4:nowrap:ai:expandtab 00189 */

Generated on Thu Dec 30 21:03:17 2004 for scim by doxygen 1.3.8