Example #1
0
void CListViewOrder::InitList(HWND hwndList)
{
	m_iColumnNumber = -1;
	m_bAscending = TRUE;
	_ASSERTE(g_pResManager != NULL);
	HWND hwndHeader = ListView_GetHeader(hwndList);
	Header_SetImageList(hwndHeader, g_pResManager->m_hSortArrows);
}
void playlist_view::g_update_sort()
{
	if (cfg_show_sort_arrows)
	{
		unsigned column;
		bool descending;
		bool b_sorted = g_cache.active_get_playlist_sort(column, &descending);
		if (b_sorted)
		{
			unsigned n, pcount = list_playlist.get_count();
			for (n=0; n<pcount; n++)
			{
				playlist_view * p_playlist = playlist_view::list_playlist.get_item(n);
				if (p_playlist->wnd_header)
				{
					HDITEM hdi;
					memset(&hdi, 0, sizeof(hdi));
					
					hdi.mask = HDI_FORMAT;
					Header_GetItem(p_playlist->wnd_header, column, &hdi);
					
					if (mmh::osversion::is_windows_xp_or_newer())
						hdi.fmt |= HDF_STRING | (descending ? 0x0200 : 0x0400);
					else
					{
						if (!g_imagelist) create_image_list();
						if (!Header_GetImageList(p_playlist->wnd_header))
							Header_SetImageList(p_playlist->wnd_header, g_imagelist);
						hdi.mask |= HDI_IMAGE;
						hdi.fmt |= HDF_STRING|HDF_IMAGE|( (hdi.fmt & HDF_RIGHT ) ? 0 : HDF_BITMAP_ON_RIGHT);
						if (descending)
						{
							hdi.iImage = 0;
						}
						else
						{
							hdi.iImage = 1;
						}
					}
					
					Header_SetItem(p_playlist->wnd_header, column, &hdi);
				}
			}
		}
	}
}
Example #3
0
void wxHeaderCtrl::DoInsertItem(const wxHeaderColumn& col, unsigned int idx)
{
    wxASSERT_MSG( !col.IsHidden(), "should only be called for shown columns" );

    wxHDITEM hdi;

    // notice that we need to store the string we use the pointer to until we
    // pass it to the control
    hdi.mask |= HDI_TEXT;
    wxWxCharBuffer buf = col.GetTitle().t_str();
    hdi.pszText = buf.data();
    hdi.cchTextMax = wxStrlen(buf);

    const wxBitmap bmp = col.GetBitmap();
    if ( bmp.IsOk() )
    {
        hdi.mask |= HDI_IMAGE;

        if ( bmp.IsOk() )
        {
            const int bmpWidth = bmp.GetWidth(),
                      bmpHeight = bmp.GetHeight();

            if ( !m_imageList )
            {
                m_imageList = new wxImageList(bmpWidth, bmpHeight);
                (void) // suppress mingw32 warning about unused computed value
                Header_SetImageList(GetHwnd(), GetHimagelistOf(m_imageList));
            }
            else // already have an image list
            {
                // check that all bitmaps we use have the same size
                int imageWidth,
                    imageHeight;
                m_imageList->GetSize(0, imageWidth, imageHeight);

                wxASSERT_MSG( imageWidth == bmpWidth && imageHeight == bmpHeight,
                              "all column bitmaps must have the same size" );
            }

            m_imageList->Add(bmp);
            hdi.iImage = m_imageList->GetImageCount() - 1;
        }
        else // no bitmap but we still need to update the item
        {
            hdi.iImage = I_IMAGENONE;
        }
    }

    if ( col.GetAlignment() != wxALIGN_NOT )
    {
        hdi.mask |= HDI_FORMAT | HDF_LEFT;
        switch ( col.GetAlignment() )
        {
            case wxALIGN_LEFT:
                hdi.fmt |= HDF_LEFT;
                break;

            case wxALIGN_CENTER:
            case wxALIGN_CENTER_HORIZONTAL:
                hdi.fmt |= HDF_CENTER;
                break;

            case wxALIGN_RIGHT:
                hdi.fmt |= HDF_RIGHT;
                break;

            default:
                wxFAIL_MSG( "invalid column header alignment" );
        }
    }

    if ( col.IsSortKey() )
    {
        hdi.mask |= HDI_FORMAT;
        hdi.fmt |= col.IsSortOrderAscending() ? HDF_SORTUP : HDF_SORTDOWN;
    }

    if ( col.GetWidth() != wxCOL_WIDTH_DEFAULT )
    {
        hdi.mask |= HDI_WIDTH;
        hdi.cxy = col.GetWidth();
    }

    hdi.mask |= HDI_ORDER;
    hdi.iOrder = MSWToNativeOrder(m_colIndices.Index(idx));

    if ( ::SendMessage(GetHwnd(), HDM_INSERTITEM,
                       MSWToNativeIdx(idx), (LPARAM)&hdi) == -1 )
    {
        wxLogLastError(wxT("Header_InsertItem()"));
    }
}