void QUimInputContext::candidateActivate( int nr, int displayLimit ) { QValueList<uim_candidate> list; list.clear(); #if !UIM_QT_USE_NEW_PAGE_HANDLING cwin->activateCandwin( displayLimit ); /* set candidates */ uim_candidate cand; for ( int i = 0; i < nr; i++ ) { cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i ); list.append( cand ); } cwin->setCandidates( displayLimit, list ); #else /* !UIM_QT_USE_NEW_PAGE_HANDLING */ nrPages = displayLimit ? ( nr - 1 ) / displayLimit + 1 : 1; pageFilled.clear(); for ( int i = 0; i < nrPages; i++ ) pageFilled.append( false ); cwin->setNrCandidates( nr, displayLimit ); // set page candidates prepare_page_candidates( 0 ); cwin->setPage( 0 ); #endif /* !UIM_QT_USE_NEW_PAGE_HANDLING */ cwin->popup(); candwinIsActive = true; }
int InputContext::prepare_page_candidates_by_index(int index) { int page; page = mDisplayLimit ? index / mDisplayLimit : 0; prepare_page_candidates(page); return page; }
void InputContext::candidate_update() { Canddisp *disp = canddisp_singleton(); #if !UIM_XIM_USE_NEW_PAGE_HANDLING disp->activate(active_candidates, mDisplayLimit); #else prepare_page_candidates(current_page); disp->set_nr_candidates(mNumCandidates, mDisplayLimit); disp->set_page_candidates(current_page, mCandidateSlot[current_page]); disp->show_page(current_page); #endif disp->select(current_cand_selection, need_hilite_selected_cand); disp->show(); }
void QUimInputContext::candidateShiftPage( bool forward ) { #if UIM_QT_USE_NEW_PAGE_HANDLING int new_page, index; index = forward ? cwin->pageIndex + 1 : cwin->pageIndex - 1; if ( index < 0 ) new_page = nrPages - 1; else if ( index >= nrPages ) new_page = 0; else new_page = index; prepare_page_candidates( new_page ); #endif cwin->shiftPage( forward ); }
void QUimInputContext::candidateSelect( int index ) { #if UIM_QT_USE_NEW_PAGE_HANDLING int new_page; if ( index >= cwin->nrCandidates ) index = 0; if ( index >= 0 && cwin->displayLimit ) new_page = index / cwin->displayLimit; else new_page = cwin->pageIndex; prepare_page_candidates( new_page ); #endif cwin->setIndex( index ); }
void InputContext::candidate_shift_page(int direction) { int new_page; int new_index; if (mDisplayLimit) { if (direction) new_page = current_page + 1; else new_page = current_page - 1; if (new_page < 0) current_page = mNumPage - 1; else if (new_page >= mNumPage) current_page = 0; else current_page = new_page; new_index = (current_page * mDisplayLimit) + (current_cand_selection % mDisplayLimit); #if !UIM_XIM_USE_NEW_PAGE_HANDLING if (new_index >= active_candidates.size()) current_cand_selection = active_candidates.size() - 1; #else if (new_index >= mNumCandidates) current_cand_selection = mNumCandidates - 1; #endif else current_cand_selection = new_index; #if UIM_XIM_USE_NEW_PAGE_HANDLING Canddisp *disp = canddisp_singleton(); prepare_page_candidates(current_page); disp->set_page_candidates(current_page, mCandidateSlot[current_page]); #endif } candidate_select(current_cand_selection); if (need_hilite_selected_cand) uim_set_candidate_index(mUc, current_cand_selection); }
void InputContext::candidate_activate(int nr, int display_limit) { int i; #if !UIM_XIM_USE_NEW_PAGE_HANDLING const char *cand_str; const char *heading_label; const char *annotation_str; char *str; #else std::vector<CandList>::iterator slot_it; #endif std::vector<const char *> candidates; std::vector<const char *>::iterator it; #if UIM_XIM_USE_DELAY timer_cancel(); #endif Canddisp *disp = canddisp_singleton(); mDisplayLimit = display_limit; if (display_limit) mNumPage = (nr - 1) / display_limit + 1; #if !UIM_XIM_USE_NEW_PAGE_HANDLING /* remove old data */ if (!active_candidates.empty()) { for (it = active_candidates.begin(); it != active_candidates.end(); ++it) free((char *)*it); } active_candidates.clear(); for (i = 0; i < nr; i++) { uim_candidate cand; cand = uim_get_candidate(mUc, i, display_limit ? i % display_limit : i); cand_str = uim_candidate_get_cand_str(cand); heading_label = uim_candidate_get_heading_label(cand); annotation_str = uim_candidate_get_annotation(cand); if (cand_str && heading_label && annotation_str) { str = (char *)malloc(strlen(cand_str) + strlen(heading_label) + strlen(annotation_str) + 3); sprintf(str, "%s\a%s\a%s", heading_label, cand_str, annotation_str); candidates.push_back((const char *)str); } else { fprintf(stderr, "Warning: cand_str at %d is NULL\n", i); candidates.push_back((const char *)strdup("\a\a")); } uim_candidate_free(cand); } disp->activate(candidates, display_limit); active_candidates = candidates; #else /* !UIM_XIM_USE_NEW_PAGE_HANDLING */ mNumCandidates = nr; /* remove old data */ for (slot_it = mCandidateSlot.begin(); slot_it != mCandidateSlot.end(); ++slot_it) { if (*slot_it != (CandList)0) { for (it = (*slot_it).begin(); it != (*slot_it).end(); ++it) free((char *)*it); } } mCandidateSlot.clear(); /* setup dummy data */ for (i = 0; i < mNumPage; i++) mCandidateSlot.push_back((CandList)0); prepare_page_candidates(0); disp->set_nr_candidates(nr, display_limit); disp->set_page_candidates(0, mCandidateSlot[0]); disp->show_page(0); #endif /* !UIM_XIM_USE_NEW_PAGE_HANDLING */ mCandwinActive = true; current_cand_selection = 0; current_page = 0; need_hilite_selected_cand = false; }