parent
155fb03c5a
commit
5d732522fe
@ -61,6 +61,7 @@ wxZRColaCharGrid::~wxZRColaCharGrid()
|
|||||||
|
|
||||||
void wxZRColaCharGrid::Init()
|
void wxZRColaCharGrid::Init()
|
||||||
{
|
{
|
||||||
|
m_regenerate = false;
|
||||||
m_isResizing = false;
|
m_isResizing = false;
|
||||||
m_toolTipIdx = (size_t)-1;
|
m_toolTipIdx = (size_t)-1;
|
||||||
}
|
}
|
||||||
@ -69,15 +70,12 @@ void wxZRColaCharGrid::Init()
|
|||||||
void wxZRColaCharGrid::SetCharacters(const wxString &chars)
|
void wxZRColaCharGrid::SetCharacters(const wxString &chars)
|
||||||
{
|
{
|
||||||
m_chars = chars;
|
m_chars = chars;
|
||||||
|
m_regenerate = true;
|
||||||
|
|
||||||
// Build and set new grid data.
|
// Invoke OnSize(), which will populate the grid.
|
||||||
size_t char_len = m_chars.Length();
|
wxSizeEvent e(GetSize(), m_windowId);
|
||||||
int rows = std::max<int>((char_len + m_numCols - 1) / m_numCols, 1);
|
e.SetEventObject(this);
|
||||||
wxGridStringTable *table = new wxGridStringTable(rows, m_numCols);
|
HandleWindowEvent(e);
|
||||||
for (int r = 0, i = 0; r < rows; r++)
|
|
||||||
for (int c = 0; c < m_numCols; c++, i++)
|
|
||||||
table->SetValue(r, c, i < char_len ? wxString(1, m_chars[i]) : wxEmptyString);
|
|
||||||
SetTable(table, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -134,13 +132,14 @@ void wxZRColaCharGrid::OnSize(wxSizeEvent& event)
|
|||||||
|
|
||||||
BeginBatch();
|
BeginBatch();
|
||||||
|
|
||||||
if (cols != m_numCols) {
|
if (m_regenerate || cols != m_numCols) {
|
||||||
// Build and set new grid data.
|
// Build and set new grid data.
|
||||||
wxGridStringTable *table = new wxGridStringTable(rows, cols);
|
wxGridStringTable *table = new wxGridStringTable(rows, cols);
|
||||||
for (int r = 0, i = 0; r < rows; r++)
|
for (int r = 0, i = 0; r < rows; r++)
|
||||||
for (int c = 0; c < cols; c++, i++)
|
for (int c = 0; c < cols; c++, i++)
|
||||||
table->SetValue(r, c, i < char_len ? wxString(1, m_chars[i]) : wxEmptyString);
|
table->SetValue(r, c, i < char_len ? wxString(1, m_chars[i]) : wxEmptyString);
|
||||||
SetTable(table, true);
|
SetTable(table, true);
|
||||||
|
m_regenerate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int c = 0; c < cols; c++)
|
for (int c = 0; c < cols; c++)
|
||||||
|
@ -84,6 +84,7 @@ protected:
|
|||||||
wxString m_chars; ///< Array of Unicode characters to display in the grid
|
wxString m_chars; ///< Array of Unicode characters to display in the grid
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_regenerate; ///< Force regenerate grid table
|
||||||
bool m_isResizing; ///< Prevents nesting of OnSize() method.
|
bool m_isResizing; ///< Prevents nesting of OnSize() method.
|
||||||
wxTimer m_timerToolTip; ///< Timer for displaying tooltip
|
wxTimer m_timerToolTip; ///< Timer for displaying tooltip
|
||||||
size_t m_toolTipIdx; ///< Index of cell for tooltip display
|
size_t m_toolTipIdx; ///< Index of cell for tooltip display
|
||||||
|
Loading…
x
Reference in New Issue
Block a user