I have a problem try to resize wxStaticText to the size of a wxListCtrl-column. For ech column i created a wxStaticText and set the positions and size of the statictext.
Here's an example:
I resized the first column and then set the width of the underlying wxstatictext to the columnsize....but the wxstatictext was not resized, it's not visible...the position is the same. but if i resize the main window after that, the size and positions are correct. any idea?
Here's the code and an image:
Code: Select all
// inserts a new footer
void CDataView::InsertFooter(int index, wxString sTxtSymbol, int pos, int type, int alignment)
{
m_nFootAlign[index] = alignment;
m_nFootColumn[index] = index;
m_nFootSymbolPos[index] = pos;
m_nFootType[index] = type;
m_sFootSymbol.Add(sTxtSymbol);
m_lblFooter[index] = new wxStaticText(this, wxID_ANY, _(""), wxDefaultPosition, wxDefaultSize, alignment);
}
// size and positioning of footers
void CDataView::FitFooters()
{
int totalwidth = 0, x = 0, colwidth = 0, footpos = 0;
wxPoint position;
totalwidth = m_lcData->GetSize().GetWidth();
for(x=0; x <= (m_lcData->GetColumnCount()-1); x++)
{
colwidth = m_lcData->GetColumnWidth(x);
m_lblFooter[x]->SetLabel(_T("ugag"));
m_lblFooter[x]->SetSize(colwidth, -1);
position.x = footpos;
position.y = m_lcData->GetSize().GetHeight();
m_lblFooter[x]->SetPosition(position);
footpos+=colwidth;
}
}
/*!
* wxEVT_SIZE event handler for ID_LcData
*/
void CDataView::OnSizeList( wxSizeEvent& event )
{
////@begin wxEVT_SIZE event handler for ID_LcData in CDataView.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_SIZE event handler for ID_LcData in CDataView.
FitFooters();
}
/*!
* wxEVT_COMMAND_LIST_COL_END_DRAG event handler for ID_LcData
*/
void CDataView::OnLcDataColEndDrag( wxListEvent& event )
{
////@begin wxEVT_COMMAND_LIST_COL_END_DRAG event handler for ID_LcData in CDataView.
// Before editing this code, remove the block markers.
event.Skip();
////@end wxEVT_COMMAND_LIST_COL_END_DRAG event handler for ID_LcData in CDataView.
FitFooters();
}
After resizing the column:
You can see that the position is wrong
so...i resized the mainwindow and it's ok...that's the look i want after resizing the columns:
I hope you understand.
Thank you!