wxString ClueListBox::OnGetItem(size_t n) const { if (! m_clues) return wxEmptyString; const size_t count = m_clues->size(); if (count <= n) return wxEmptyString; return wxString::Format( _T("<table border=0 cellspacing=0 cellpadding=0><tr>") _T("<td align=right valign=top width=%d>%s.</td>") _T("<td width=5></td>") _T("<td align=left valign=top>%s</td>") _T("</tr></table>"), GetNumberWidth(), (const wxChar *)puz2wx((*m_clues)[n].GetNumber()).c_str(), (const wxChar *)puz2wx((*m_clues)[n].GetText()).c_str() ); }
wxString MetadataCtrl::GetMeta(const wxString & str_, MyFrame * frame) { wxString str = str_.Lower(); if (str == _T("cluenumber")) { puz::Clue * clue = frame->GetFocusedClue(); if (clue) return puz2wx(clue->GetNumber()); else return wxEmptyString; } else if (str == _T("clue")) { puz::Clue * clue = frame->GetFocusedClue(); if (clue) return puz2wx(clue->GetText()); else return wxEmptyString; } else return puz2wx(frame->GetPuzzle().GetMeta(wx2puz(str))); }
int ClueListBox::GetNumberWidth() const { if (m_numberWidth == -1) { wxClientDC dc(wxConstCast(this, ClueListBox)); dc.SetFont(GetFont()); m_numberWidth = 0; puz::ClueList::const_iterator it; for (it = m_clues->begin(); it != m_clues->end(); ++it) m_numberWidth = std::max(m_numberWidth, dc.GetTextExtent(puz2wx(it->GetNumber())+_T(".")).GetWidth()); m_numberWidth = m_numberWidth * 1.2; } return m_numberWidth; }