示例#1
0
void IMContextImpl::set_lookup_table (const LookupTable &new_lookup_table)
{
    lookup_table.clear ();
    lookup_table.set_page_size (new_lookup_table.get_page_size ());
    lookup_table.show_cursor (new_lookup_table.is_cursor_visible ());
    lookup_table.fix_page_size (new_lookup_table.is_page_size_fixed ());
    for (int i = 0; i < new_lookup_table.number_of_candidates (); ++i) {
        const WideString &label = new_lookup_table.get_candidate (i);
        const AttributeList &attributes = new_lookup_table.get_attributes (i);
        lookup_table.append_candidate (label, attributes);
    }
    lookup_table.set_cursor_pos (new_lookup_table.get_cursor_pos ());
}
示例#2
0
static void slot_update_lookup_table(const LookupTable& table)
{
    std::vector<String> labels;
    std::vector<String> candidates;
    std::vector<String> attrs;
    size_t current_page_size = table.get_current_page_size();
    for (size_t i = 0; i < current_page_size; ++i) {
        labels.push_back(utf8_wcstombs(table.get_candidate_label(i)));
    }
    for (size_t i = 0; i < current_page_size; ++i) {
        candidates.push_back(utf8_wcstombs(table.get_candidate_in_current_page(i)));
        attrs.push_back(AttrList2String(table.get_attributes_in_current_page(i)));
    }
    bool hasprev = table.get_current_page_start();
    bool hasnext = table.get_current_page_start() + current_page_size < table.number_of_candidates();
    panel->UpdateLookupTable(labels, candidates, attrs, hasprev, hasnext);

    int cursor_pos = table.get_cursor_pos_in_current_page();
    panel->UpdateLookupTableCursor(cursor_pos);
}