librime: menu.h Source File

| librime 1.2 Rime Input Method Engine, the core library

menu.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-05-29 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_MENU_H_
8#define RIME_MENU_H_
9
10#include <rime_api.h>
11#include <rime/candidate.h>
12#include <rime/common.h>
13
14namespace rime {
15
16 struct Page {
17 int page_size = 0;
18 int page_no = 0;
19 bool is_last_page = false;
20 CandidateList candidates;
21};
22
23class Filter;
24class MergedTranslation;
25class Translation;
26
27 class Menu {
28 public:
29 RIME_DLL Menu();
30
31 RIME_DLL void AddTranslation(an<Translation> translation);
32 void AddFilter(Filter* filter);
33
34 RIME_DLL size_t Prepare(size_t candidate_count);
35 RIME_DLL Page* CreatePage(size_t page_size, size_t page_no);
36 an<Candidate> GetCandidateAt(size_t index);
37
38 // CAVEAT: returns the number of candidates currently obtained,
39 // rather than the total number of available candidates.
40 size_t candidate_count() const { return candidates_.size(); }
41
42 bool empty() const;
43
44 private:
45 an<MergedTranslation> merged_;
46 an<Translation> result_;
47 CandidateList candidates_;
48};
49
50} // namespace rime
51
52#endif // RIME_MENU_H_
candidate.h
common.h
rime_api.h
RIME_DLL
#define RIME_DLL
Definition rime_api.h:33
rime
Definition algebra.cc:12
rime::an
std::shared_ptr< T > an
Definition common.h:60
rime::CandidateList
vector< of< Candidate > > CandidateList
Definition candidate.h:52
rime::Filter
Definition filter.h:22
rime::Page
Definition menu.h:16
rime::Page::page_no
int page_no
Definition menu.h:18
rime::Page::page_size
int page_size
Definition menu.h:17
rime::Page::is_last_page
bool is_last_page
Definition menu.h:19
rime::Page::candidates
CandidateList candidates
Definition menu.h:20
rime::Menu::Menu
RIME_DLL Menu()
Definition menu.cc:15
rime::Menu::Prepare
RIME_DLL size_t Prepare(size_t candidate_count)
Definition menu.cc:26
rime::Menu::candidate_count
size_t candidate_count() const
Definition menu.h:40
rime::Menu::empty
bool empty() const
Definition menu.cc:67
rime::Menu::CreatePage
RIME_DLL Page * CreatePage(size_t page_size, size_t page_no)
Definition menu.cc:37
rime::Menu::AddFilter
void AddFilter(Filter *filter)
Definition menu.cc:22
rime::Menu::GetCandidateAt
an< Candidate > GetCandidateAt(size_t index)
Definition menu.cc:60
rime::Menu::AddTranslation
RIME_DLL void AddTranslation(an< Translation > translation)
Definition menu.cc:17
rime::Translation
Definition translation.h:17
rime::MergedTranslation
Definition translation.h:85