void wxHeaderCtrl::DoSetCount(unsigned int count) { unsigned n; // first delete all old columns const unsigned countOld = GetShownColumnsCount(); for ( n = 0; n < countOld; n++ ) { if ( !Header_DeleteItem(GetHwnd(), 0) ) { wxLogLastError(wxT("Header_DeleteItem")); } } // update the column indices order array before changing m_numColumns DoResizeColumnIndices(m_colIndices, count); // and add the new ones m_numColumns = count; m_isHidden.resize(m_numColumns); for ( n = 0; n < count; n++ ) { const wxHeaderColumn& col = GetColumn(n); if ( col.IsShown() ) { m_isHidden[n] = false; DoInsertItem(col, n); } else // hidden initially { m_isHidden[n] = true; } } }
void DoDeleteRepStuff(HWND hwnd, LPINSERTITEM pfr) { int ret; if (pfr->NullHwd) ret = Header_DeleteItem(NULL, pfr->index); else ret = Header_DeleteItem(pfr->hwnd, pfr->index); wsprintf(szDbgMsg, "%d = Header_DeleteItem(index = %d)", ret, pfr->index); MyDebugMsg(DM_TRACE, "%s", (LPCSTR) szDbgMsg); SetDlgItemInt(hwnd, IDC_DELETERET, ret, TRUE) ; }
void Header::remove ( int index ) { const int result = Header_DeleteItem(handle(), index); if ( result == FALSE ) { const ::DWORD error = ::GetLastError(); UNCHECKED_WIN32C_ERROR(Header_DeleteItem, error); } }
void wxHeaderCtrl::DoUpdate(unsigned int idx) { // the native control does provide Header_SetItem() but it's inconvenient // to use it because it sends HDN_ITEMCHANGING messages and we'd have to // arrange not to block setting the width from there and the logic would be // more complicated as we'd have to reset the old values as well as setting // the new ones -- so instead just recreate the column const wxHeaderColumn& col = GetColumn(idx); if ( col.IsHidden() ) { // column is hidden now if ( !m_isHidden[idx] ) { // but it wasn't hidden before, so remove it if ( !Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx)) ) wxLogLastError(wxS("Header_DeleteItem()")); m_isHidden[idx] = true; } //else: nothing to do, updating hidden column doesn't have any effect } else // column is shown now { if ( m_isHidden[idx] ) { m_isHidden[idx] = false; } else // and it was shown before as well { // we need to remove the old column if ( !Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx)) ) wxLogLastError(wxS("Header_DeleteItem()")); } DoInsertItem(col, idx); } }
void playlist_view::rebuild_header(bool rebuild) { if (rebuild) { int n, t = Header_GetItemCount(wnd_header); { for (n = 0; n < t; n++) Header_DeleteItem(wnd_header, 0); } } uHDITEM hdi; memset(&hdi, 0, sizeof(HDITEM)); hdi.mask = (rebuild ? HDI_TEXT | HDI_FORMAT : 0) | HDI_WIDTH; hdi.fmt = HDF_LEFT | HDF_STRING; pfc::string8 name; { pfc::array_t<int, pfc::alloc_fast_aggressive> widths; get_column_widths(widths); const bit_array & p_mask = g_cache.active_get_columns_mask(); int n, t = columns.get_count(), i = 0;//,tw=g_playlist_entries.get_total_width(); for (n = 0; n < t; n++) { if (p_mask[n]) { if (rebuild) { alignment align = columns[n]->align; hdi.fmt = HDF_STRING | (align == ALIGN_CENTRE ? HDF_CENTER : (align == ALIGN_RIGHT ? HDF_RIGHT : HDF_LEFT)); name = columns[n]->name; hdi.cchTextMax = name.length(); hdi.pszText = const_cast<char*>(name.get_ptr()); } hdi.cxy = widths[i]; uHeader_InsertItem(wnd_header, i++, &hdi, rebuild); } } } }
void PopupListviewColumnsMenu( HWND hListview, LISTVIEW_COLUMN * ColumnList ) { HMENU hMenu = CreatePopupMenu(); MENUITEMINFO item; ZeroMemory(&item,sizeof(item)); // Build list of columns for (int col = 0; ColumnList[col].Title; ++col ) { item.cbSize = sizeof item; item.fMask = MIIM_ID | MIIM_STATE | MIIM_CHECKMARKS | MIIM_TYPE; item.wID = col + 1; // zero is used for errors or no selection item.fType = MFT_STRING; item.fState = ListView_GetColumnWidth( hListview, col ) ? MFS_CHECKED : 0; item.hbmpChecked = NULL; item.hbmpUnchecked = NULL; item.hbmpItem = HBMMENU_SYSTEM; item.dwTypeData = (TCHAR *) ColumnList[col].Title; InsertMenuItem( hMenu, col, true, &item ); } // add separator item.fType = MFT_SEPARATOR; InsertMenuItem( hMenu, col++, true, &item ); // add "more..." entry item.fType = MFT_STRING; item.fState = 0; item.dwTypeData = TEXT("More..."); item.wID = col + 1; // zero is used for errors or no selection InsertMenuItem( hMenu, col++, true, &item ); // create menu POINT pt; GetCursorPos( &pt ); int i = TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, 0, hListview, NULL ); if ( i > 0 ) { // process result --i; if ( i >= col - 1 ) { MessageBox( hListview, TEXT("More"), NULL, MB_OK ); } else { if ( ListView_GetColumnWidth(hListview,i) > 0 ) { // delete item ColumnList[i].Width = ListView_GetColumnWidth( hListview, i ); ListView_SetColumnWidth( hListview, i, 0 ); #if 0 HWND hHeader = ListView_GetHeader( hListview ); Header_DeleteItem( hHeader, i ); #endif } else { // insert item ListView_SetColumnWidth( hListview, i, ColumnList[i].Width ); #if 0 HWND hHeader = ListView_GetHeader( hListview ); HDITEM item = { 0 }; item.mask = HDI_TEXT | HDI_WIDTH; item.pszText = (TCHAR *) ColumnList[i].Title; item.cxy = ColumnList[i].Width; Header_InsertItem( hHeader, i, &item ); #endif } } } }