Implemented ListCtrl::SetColumnWidth() wxLIST_AUTOSIZE
Fixed typo in configure Added docs for wxINTXX_SWAP_XX macros git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
f7770f09be
commit
0180dad680
@ -28,7 +28,7 @@ dnl WX_BINARY_AGE += 1
|
||||
dnl
|
||||
dnl if any functions have been added, do:
|
||||
dnl
|
||||
dnl WX_INTERFACE_AGE = 1
|
||||
dnl WX_INTERFACE_AGE = 0
|
||||
|
||||
WX_MAJOR_VERSION_NUMBER=2
|
||||
WX_MINOR_VERSION_NUMBER=1
|
||||
|
@ -1586,6 +1586,55 @@ function.
|
||||
|
||||
These macros are defined in wxWindows.
|
||||
|
||||
\membersection{wxINTXX\_SWAP\_ALWAYS}\label{intswapalways}
|
||||
|
||||
\func{wxInt32}{wxINT32\_SWAP\_ALWAYS}{\param{wxInt32 }{value}}
|
||||
|
||||
\func{wxUint32}{wxUINT32\_SWAP\_ALWAYS}{\param{wxUint32 }{value}}
|
||||
|
||||
\func{wxInt16}{wxINT16\_SWAP\_ALWAYS}{\param{wxInt16 }{value}}
|
||||
|
||||
\func{wxUint16}{wxUINT16\_SWAP\_ALWAYS}{\param{wxUint16 }{value}}
|
||||
|
||||
This macro will swap the bytes of the {\it value} variable from little
|
||||
endian to big endian or vice versa.
|
||||
|
||||
\membersection{wxINTXX\_SWAP\_ON\_BE}\label{intswaponbe}
|
||||
|
||||
\func{wxInt32}{wxINT32\_SWAP\_ON\_BE}{\param{wxInt32 }{value}}
|
||||
|
||||
\func{wxUint32}{wxUINT32\_SWAP\_ON\_BE}{\param{wxUint32 }{value}}
|
||||
|
||||
\func{wxInt16}{wxINT16\_SWAP\_ON\_BE}{\param{wxInt16 }{value}}
|
||||
|
||||
\func{wxUint16}{wxUINT16\_SWAP\_ON\_BE}{\param{wxUint16 }{value}}
|
||||
|
||||
This macro will swap the bytes of the {\it value} variable from little
|
||||
endian to big endian or vice versa if the program is compiled on a
|
||||
big-endian architecture (such as Sun work stations). If the program has
|
||||
been compiled on a little-endian architecture, the value will be unchanged.
|
||||
|
||||
Use these macros to read data from and write data to a file that stores
|
||||
data in little endian (Intel i386) format.
|
||||
|
||||
\membersection{wxINTXX\_SWAP\_ON\_LE}\label{intswaponle}
|
||||
|
||||
\func{wxInt32}{wxINT32\_SWAP\_ON\_LE}{\param{wxInt32 }{value}}
|
||||
|
||||
\func{wxUint32}{wxUINT32\_SWAP\_ON\_LE}{\param{wxUint32 }{value}}
|
||||
|
||||
\func{wxInt16}{wxINT16\_SWAP\_ON\_LE}{\param{wxInt16 }{value}}
|
||||
|
||||
\func{wxUint16}{wxUINT16\_SWAP\_ON\_LE}{\param{wxUint16 }{value}}
|
||||
|
||||
This macro will swap the bytes of the {\it value} variable from little
|
||||
endian to big endian or vice versa if the program is compiled on a
|
||||
little-endian architecture (such as Intel PCs). If the program has
|
||||
been compiled on a big-endian architecture, the value will be unchanged.
|
||||
|
||||
Use these macros to read data from and write data to a file that stores
|
||||
data in big endian format.
|
||||
|
||||
\membersection{CLASSINFO}\label{classinfo}
|
||||
|
||||
\func{wxClassInfo *}{CLASSINFO}{className}
|
||||
|
@ -26,12 +26,12 @@ the list wraps, unlike a wxListBox.}
|
||||
\twocolitem{\windowstyle{wxLC\_REPORT}}{single or multicolumn report view, with optional header.}
|
||||
\twocolitem{\windowstyle{wxLC\_ICON}}{Large icon view, with optional labels.}
|
||||
\twocolitem{\windowstyle{wxLC\_SMALL\_ICON}}{Small icon view, with optional labels.}
|
||||
\twocolitem{\windowstyle{wxLC\_ALIGN\_TOP}}{Icons align to the top (default).}
|
||||
\twocolitem{\windowstyle{wxLC\_ALIGN\_LEFT}}{Icons align to the left.}
|
||||
\twocolitem{\windowstyle{wxLC\_AUTOARRANGE}}{Icons arrange themselves.}
|
||||
\twocolitem{\windowstyle{wxLC\_USER\_TEXT}}{The application provides label text on demand, except for column headers.}
|
||||
\twocolitem{\windowstyle{wxLC\_ALIGN\_TOP}}{Icons align to the top. Win32 default, Win32 only. }
|
||||
\twocolitem{\windowstyle{wxLC\_ALIGN\_LEFT}}{Icons align to the left. }
|
||||
\twocolitem{\windowstyle{wxLC\_AUTOARRANGE}}{Icons arrange themselves. Win32 only. }
|
||||
\twocolitem{\windowstyle{wxLC\_USER\_TEXT}}{The application provides label text on demand, except for column headers. Win32 only. }
|
||||
\twocolitem{\windowstyle{wxLC\_EDIT\_LABELS}}{Labels are editable: the application will be notified when editing starts.}
|
||||
\twocolitem{\windowstyle{wxLC\_NO\_HEADER}}{No header in report mode.}
|
||||
\twocolitem{\windowstyle{wxLC\_NO\_HEADER}}{No header in report mode. Win32 only. }
|
||||
\twocolitem{\windowstyle{wxLC\_SINGLE\_SEL}}{Single selection.}
|
||||
\twocolitem{\windowstyle{wxLC\_SORT\_ASCENDING}}{Sort in ascending order (must still supply a comparison callback in SortItems.}
|
||||
\twocolitem{\windowstyle{wxLC\_SORT\_DESCENDING}}{Sort in descending order (must still supply a comparison callback in SortItems.}
|
||||
@ -111,7 +111,7 @@ Destructor, destroying the list control.
|
||||
|
||||
\func{bool}{Arrange}{\param{int }{flag = wxLIST\_ALIGN\_DEFAULT}}
|
||||
|
||||
Arranges the items in icon or small icon view. {\it flag} is one of:
|
||||
Arranges the items in icon or small icon view. This only has effect on Win32. {\it flag} is one of:
|
||||
|
||||
\twocolwidtha{5cm}
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
@ -455,6 +455,8 @@ information.
|
||||
Sets the column width.
|
||||
|
||||
{\it width} can be a width in pixels or wxLIST\_AUTOSIZE (-1) or wxLIST\_AUTOSIZE\_USEHEADER (-2).
|
||||
wxLIST\_AUTOSIZE will resize the column to the length of its longest item. wxLIST\_AUTOSIZE\_USEHEADER
|
||||
will resize the column to the length of the header (Win32) or 80 pixels (other platforms).
|
||||
|
||||
In small or normal icon view, {\it col} must be -1, and the column width is set for all columns.
|
||||
|
||||
@ -504,11 +506,11 @@ The {\bf m\_stateMask} and {\bf m\_state} members take flags from the following:
|
||||
|
||||
\twocolwidtha{5cm}
|
||||
\begin{twocollist}\itemsep=0pt
|
||||
\twocolitem{wxLIST\_STATE\_DONTCARE}{Don't care what the state is.}
|
||||
\twocolitem{wxLIST\_STATE\_DROPHILITED}{The item is highlighted to receive a drop event.}
|
||||
\twocolitem{wxLIST\_STATE\_DONTCARE}{Don't care what the state is. Win32 only. }
|
||||
\twocolitem{wxLIST\_STATE\_DROPHILITED}{The item is highlighted to receive a drop event. Win32 only. }
|
||||
\twocolitem{wxLIST\_STATE\_FOCUSED}{The item has the focus.}
|
||||
\twocolitem{wxLIST\_STATE\_SELECTED}{The item is selected.}
|
||||
\twocolitem{wxLIST\_STATE\_CUT}{The item is in the cut state.}
|
||||
\twocolitem{wxLIST\_STATE\_CUT}{The item is in the cut state. Win32 only. }
|
||||
\end{twocollist}
|
||||
|
||||
\func{long}{SetItem}{\param{long }{index}, \param{int }{col}, \param{const wxString\& }{label}, \param{int }{imageId = -1}}
|
||||
|
@ -145,8 +145,8 @@ enum {
|
||||
|
||||
// Autosize values for SetColumnWidth
|
||||
enum {
|
||||
wxLIST_AUTOSIZE = -1, // always 80 in wxGLC (what else?)
|
||||
wxLIST_AUTOSIZE_USEHEADER = -2
|
||||
wxLIST_AUTOSIZE = -1, // width of longest item
|
||||
wxLIST_AUTOSIZE_USEHEADER = -2 // always 80 in wxGLC
|
||||
};
|
||||
|
||||
// Flag values for GetItemRect
|
||||
|
@ -205,55 +205,62 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
void MyFrame::OnDeselectAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
int n = m_listCtrl->GetItemCount();
|
||||
int i;
|
||||
for(i = 0; i < n; i++)
|
||||
for (int i = 0; i < n; i++)
|
||||
m_listCtrl->SetItemState(i,0,wxLIST_STATE_SELECTED);
|
||||
}
|
||||
|
||||
void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
int n = m_listCtrl->GetItemCount();
|
||||
int i;
|
||||
for(i = 0; i < n; i++)
|
||||
for (int i = 0; i < n; i++)
|
||||
m_listCtrl->SetItemState(i,wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
|
||||
}
|
||||
|
||||
void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_listCtrl->DeleteAllItems();
|
||||
m_logWindow->Clear();
|
||||
m_listCtrl->SetSingleStyle(wxLC_LIST);
|
||||
m_listCtrl->DeleteAllItems();
|
||||
m_logWindow->Clear();
|
||||
m_listCtrl->SetSingleStyle(wxLC_LIST);
|
||||
m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL);
|
||||
m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_SMALL);
|
||||
|
||||
for ( int i=0; i < 30; i++)
|
||||
{
|
||||
wxChar buf[20];
|
||||
wxSprintf(buf, _T("Item %d"), i);
|
||||
m_listCtrl->InsertItem(i, buf);
|
||||
}
|
||||
for ( int i=0; i < 30; i++)
|
||||
{
|
||||
wxChar buf[20];
|
||||
wxSprintf(buf, _T("Item %d"), i);
|
||||
m_listCtrl->InsertItem(i, buf);
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
m_listCtrl->DeleteAllItems();
|
||||
m_logWindow->Clear();
|
||||
m_listCtrl->SetSingleStyle(wxLC_REPORT);
|
||||
m_listCtrl->DeleteAllItems();
|
||||
m_logWindow->Clear();
|
||||
|
||||
m_listCtrl->SetSingleStyle(wxLC_REPORT);
|
||||
m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL);
|
||||
m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
|
||||
|
||||
m_listCtrl->InsertColumn(0, "Column 1", wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(1, "Column 2", wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(0, "Column 1"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
|
||||
for ( int i=0; i < 30; i++)
|
||||
{
|
||||
wxChar buf[50];
|
||||
wxSprintf(buf, _T("Item %d, col 1"), i);
|
||||
long tmp = m_listCtrl->InsertItem(i, buf, 0);
|
||||
for ( int i=0; i < 30; i++)
|
||||
{
|
||||
wxChar buf[50];
|
||||
wxSprintf(buf, _T("This is item %d"), i);
|
||||
long tmp = m_listCtrl->InsertItem(i, buf, 0);
|
||||
|
||||
wxSprintf(buf, _T("Item %d, broad column 2"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 1, buf);
|
||||
}
|
||||
wxSprintf(buf, _T("Col 1, item %d"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 1, buf);
|
||||
|
||||
wxSprintf(buf, _T("Item %d in column 2"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 2, buf);
|
||||
}
|
||||
|
||||
m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
||||
m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
|
||||
m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
|
||||
}
|
||||
|
||||
void MyFrame::OnIconView(wxCommandEvent& WXUNUSED(event))
|
||||
|
@ -1695,7 +1695,44 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
|
||||
|
||||
m_dirty = TRUE;
|
||||
|
||||
wxNode *node = m_columns.Nth( col );
|
||||
wxNode *node = (wxNode*) NULL;
|
||||
|
||||
if (width == wxLIST_AUTOSIZE_USEHEADER) width = 80;
|
||||
if (width == wxLIST_AUTOSIZE)
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
dc.SetFont( GetFont() );
|
||||
int max = 10;
|
||||
node = m_lines.First();
|
||||
while (node)
|
||||
{
|
||||
wxListLineData *line = (wxListLineData*)node->Data();
|
||||
wxNode *n = line->m_items.Nth( col );
|
||||
if (n)
|
||||
{
|
||||
wxListItemData *item = (wxListItemData*)n->Data();
|
||||
int current = 0, ix = 0, iy = 0;
|
||||
long lx = 0, ly = 0;
|
||||
if (item->HasImage())
|
||||
{
|
||||
GetImageSize( item->GetImage(), ix, iy );
|
||||
current = ix + 5;
|
||||
}
|
||||
if (item->HasText())
|
||||
{
|
||||
wxString str;
|
||||
item->GetText( str );
|
||||
dc.GetTextExtent( str, &lx, &ly );
|
||||
current += lx;
|
||||
}
|
||||
if (current > max) max = current;
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
width = max+10;
|
||||
}
|
||||
|
||||
node = m_columns.Nth( col );
|
||||
if (node)
|
||||
{
|
||||
wxListHeaderData *column = (wxListHeaderData*)node->Data();
|
||||
|
Loading…
Reference in New Issue
Block a user