1
/** @file scim_lookup_table.cpp
2
* implementation of class LookupTable.
6
* Smart Pinyin Input Method
8
* Copyright (c) 2005 James Su <suzhe@tsinghua.org.cn>
10
* $Id: scim_native_lookup_table.cpp,v 1.1.1.1 2005/01/06 13:30:58 suzhe Exp $
14
#define Uses_STL_AUTOPTR
15
#define Uses_STL_FUNCTIONAL
16
#define Uses_STL_VECTOR
17
#define Uses_STL_IOSTREAM
18
#define Uses_STL_FSTREAM
19
#define Uses_STL_ALGORITHM
21
#define Uses_STL_UTILITY
22
#define Uses_STL_IOMANIP
24
#define Uses_SCIM_UTILITY
25
#define Uses_SCIM_IMENGINE
26
#define Uses_SCIM_ICONV
27
#define Uses_SCIM_CONFIG_BASE
28
#define Uses_SCIM_CONFIG_PATH
29
#define Uses_SCIM_LOOKUP_TABLE
32
#include "scim_pinyin_private.h"
33
#include "scim_phrase.h"
34
#include "scim_native_lookup_table.h"
36
//implementation of NativeLookupTable
37
NativeLookupTable::NativeLookupTable (int page_size)
38
: LookupTable (page_size)
40
std::vector <WideString> labels;
41
char buf [2] = { 0, 0 };
42
for (int i = 0; i < 9; ++i) {
44
labels.push_back (utf8_mbstowcs (buf));
47
labels.push_back (utf8_mbstowcs (buf));
49
set_candidate_labels (labels);
53
NativeLookupTable::append_entry (const WideString &entry)
55
if (entry.length () > 0) {
56
m_strings.push_back (entry);
63
NativeLookupTable::append_entry (const Phrase& entry)
65
if (entry.is_enable ()) {
66
m_phrases.push_back (entry);
73
NativeLookupTable::append_entry (const ucs4_t& entry)
76
m_chars.push_back (entry);
83
NativeLookupTable::get_candidate (int index) const
85
if (index < 0 || index >= (int) number_of_candidates ())
88
if (index < (int) m_strings.size ()) {
89
return m_strings [index];
90
} else if (index < (int) (m_strings.size () + m_phrases.size ())) {
91
return m_phrases [index - m_strings.size ()].get_content ();
93
return WideString (m_chars.begin () + index - m_strings.size () - m_phrases.size (),
94
m_chars.begin () + index - m_strings.size () - m_phrases.size () + 1);
100
NativeLookupTable::get_attributes (int index) const
105
if (index >= 0 && index < (int) m_strings.size ())
106
attrs.push_back (Attribute (0, m_strings [index].length (), SCIM_ATTR_FOREGROUND, SCIM_RGB_COLOR(32, 32, 255)));
113
vi:ts=4:nowrap:ai:expandtab