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

scim_attributes.h

Go to the documentation of this file.
00001 /** @file scim_attributes.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_attributes.h,v 1.10 2004/02/06 07:53:15 suzhe Exp $
00032  */
00033 
00034 
00035 #ifndef __SCIM_ATTRIBUTES_H
00036 #define __SCIM_ATTRIBUTES_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 attributes.
00050  */
00051 enum AttributeType
00052 {
00053     SCIM_ATTR_NONE,         ///< No attribute
00054     SCIM_ATTR_UNDERLINE,    ///< Draw a line under the text
00055     SCIM_ATTR_HIGHLIGHT,    ///< Draw the text in highlighted color
00056     SCIM_ATTR_REVERSE       ///< Draw the text in reverse color mode
00057 };
00058 
00059 /**
00060  * @brief Class to store the string attributes.
00061  *
00062  * The string attributes control the effect of the string
00063  * drawn by FrontEnds. There are currently four valid effects.
00064  * Please refer to scim::AttributeType for effect details.
00065  *
00066  * @sa scim::AttributeType scim::FrontEndBase
00067  */
00068 class Attribute
00069 {
00070     unsigned int  m_start;
00071     unsigned int  m_length;
00072 
00073     AttributeType m_type;
00074 
00075 public:
00076     /**
00077      * @brief Constructor
00078      * @param start - the start position in the string of this attribute.
00079      * @param length - the length of this attribute, the range is [start,start+length).
00080      * @param type - the type of this attribute.
00081      */
00082     Attribute (unsigned int  start = 0,
00083                unsigned int  length = 0,
00084                AttributeType type  = SCIM_ATTR_NONE) :
00085         m_start (start), m_length (length), m_type (type)
00086         { }
00087 
00088     /**
00089      * @brief Get the type of this attribute.
00090      * @return The type of this attribute.
00091      */
00092     AttributeType get_type () const { return m_type; }
00093 
00094     /**
00095      * @brief Get the start position of this attribute.
00096      * @return The start position of this attribute in the string.
00097      */
00098     unsigned int get_start () const { return m_start; }
00099 
00100     /**
00101      * @brief Get the length of this attribute.
00102      * @return The length of this attribute in the string.
00103      */
00104     unsigned int get_length () const { return m_length; }
00105 
00106     /**
00107      * @brief Get the end position of this attribute.
00108      * @return The end position of this attribute.
00109      */
00110     unsigned int get_end () const { return m_start + m_length; }
00111 
00112     /**
00113      * @brief Set the type of this attribute.
00114      * @param type - the new attribute type to be set.
00115      */
00116     void set_type (AttributeType type) { m_type = type; }
00117 
00118     /**
00119      * @brief Set the start position of this attribute.
00120      * @param start - the new start position in the string.
00121      */
00122     void set_start (unsigned int start) {
00123         m_start = start;
00124     }
00125 
00126     /**
00127      * @brief Set the length of this attribute.
00128      * @param length - the new length of this attribute.
00129      */
00130     void set_length (unsigned int length) {
00131         m_length = length;
00132     }
00133 };
00134 
00135 /**
00136  * @typedef typedef std::vector<Attribute> AttributeList
00137  * @brief The container to store a set of Attribute objects.
00138  *
00139  * You should use the STL container methods to manipulate its objects.
00140  */
00141 typedef std::vector<Attribute> AttributeList;
00142 
00143 /** @} */
00144 
00145 } // namespace scim
00146 
00147 #endif //__SCIM_ATTRIBUTES_H
00148 
00149 /*
00150 vi:ts=4:nowrap:ai:expandtab
00151 */

Generated on Fri May 7 17:27:25 2004 for scim by doxygen 1.3.6