The character entered via Unicode in Character Selector is now looked up in search results, brought into view and selected.
This commit is contained in:
parent
ff6a551c50
commit
26c899734b
@ -68,6 +68,19 @@ public:
|
|||||||
return m_chars;
|
return m_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Returns given character coordinates
|
||||||
|
///
|
||||||
|
/// \param[in] c Character
|
||||||
|
///
|
||||||
|
/// \returns Grid coordinates of selected character or (-1, -1) if character not found.
|
||||||
|
///
|
||||||
|
inline wxGridCellCoords GetCharacterCoords(wchar_t c) const
|
||||||
|
{
|
||||||
|
int i = m_chars.Find(c);
|
||||||
|
return i != wxNOT_FOUND ? wxGridCellCoords(i / m_numCols, i % m_numCols) : wxGridCellCoords(-1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxString GetToolTipText(int idx);
|
virtual wxString GetToolTipText(int idx);
|
||||||
|
|
||||||
|
@ -70,23 +70,25 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
|||||||
|
|
||||||
m_gridPreview->SetCellValue(wxString(1, m_char), 0, 0);
|
m_gridPreview->SetCellValue(wxString(1, m_char), 0, 0);
|
||||||
|
|
||||||
{
|
|
||||||
char chr[sizeof(ZRCola::character_db::character)] = {};
|
char chr[sizeof(ZRCola::character_db::character)] = {};
|
||||||
((ZRCola::character_db::character*)chr)->chr = m_char;
|
((ZRCola::character_db::character*)chr)->chr = m_char;
|
||||||
size_t start;
|
size_t start;
|
||||||
if (app->m_chr_db.idxChr.find(*(ZRCola::character_db::character*)chr, start)) {
|
if (app->m_chr_db.idxChr.find(*(ZRCola::character_db::character*)chr, start)) {
|
||||||
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[start];
|
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[start];
|
||||||
|
// Update characted rescription.
|
||||||
m_description->SetValue(wxString(chr.data, chr.desc_len));
|
m_description->SetValue(wxString(chr.data, chr.desc_len));
|
||||||
{
|
{
|
||||||
char cc[sizeof(ZRCola::chrcat_db::chrcat)] = {};
|
char cc[sizeof(ZRCola::chrcat_db::chrcat)] = {};
|
||||||
((ZRCola::chrcat_db::chrcat*)cc)->id = chr.cat;
|
((ZRCola::chrcat_db::chrcat*)cc)->id = chr.cat;
|
||||||
size_t start;
|
size_t start;
|
||||||
|
// Update character category.
|
||||||
if (app->m_cc_db.idxChrCat.find(*((ZRCola::chrcat_db::chrcat*)cc), start)) {
|
if (app->m_cc_db.idxChrCat.find(*((ZRCola::chrcat_db::chrcat*)cc), start)) {
|
||||||
const ZRCola::chrcat_db::chrcat &cat = app->m_cc_db.idxChrCat[start];
|
const ZRCola::chrcat_db::chrcat &cat = app->m_cc_db.idxChrCat[start];
|
||||||
m_category->SetValue(wxGetTranslation(wxString(cat.name, cat.name_len), wxT("ZRCola-zrcdb")));
|
m_category->SetValue(wxGetTranslation(wxString(cat.name, cat.name_len), wxT("ZRCola-zrcdb")));
|
||||||
} else
|
} else
|
||||||
m_category->SetValue(wxEmptyString);
|
m_category->SetValue(wxEmptyString);
|
||||||
}
|
}
|
||||||
|
// Update related characters.
|
||||||
m_gridRelated->SetCharacters(wxString(chr.data + chr.desc_len, chr.rel_len));
|
m_gridRelated->SetCharacters(wxString(chr.data + chr.desc_len, chr.rel_len));
|
||||||
} else {
|
} else {
|
||||||
m_description->SetValue(wxEmptyString);
|
m_description->SetValue(wxEmptyString);
|
||||||
@ -94,7 +96,13 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
|
|||||||
m_gridRelated->ClearGrid();
|
m_gridRelated->ClearGrid();
|
||||||
}
|
}
|
||||||
m_gridRelated->Scroll(0, 0);
|
m_gridRelated->Scroll(0, 0);
|
||||||
}
|
|
||||||
|
wxGridCellCoords coord(m_gridResults->GetCharacterCoords(m_char));
|
||||||
|
if (coord.GetRow() != -1 && coord.GetCol() != -1) {
|
||||||
|
m_gridResults->GoToCell(coord);
|
||||||
|
m_gridResults->SetGridCursor(coord);
|
||||||
|
} else
|
||||||
|
m_gridResults->ClearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unicodeChanged = false;
|
m_unicodeChanged = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user