void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int i; wxRadioButton *current; // define the position int x_current, y_current; int x_offset, y_offset; int widthOld, heightOld; GetSize( &widthOld, &heightOld ); GetPosition( &x_current, &y_current ); x_offset = x; y_offset = y; if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { if (x == wxDefaultCoord) x_offset = x_current; if (y == wxDefaultCoord) y_offset = y_current; } // define size int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth[128], eachHeight[128]; int totWidth, totHeight; GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); eachWidth[i] = eachWidth[i] + RADIO_SIZE; eachHeight[i] = wxMax( eachHeight[i], bestSizeRadio.y ); if (maxWidth < eachWidth[i]) maxWidth = eachWidth[i]; if (maxHeight < eachHeight[i]) maxHeight = eachHeight[i]; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); // Determine the full size in case we need to use it as fallback. wxSize sz; if ( (width == wxDefaultCoord && (sizeFlags & wxSIZE_AUTO_WIDTH)) || (height == wxDefaultCoord && (sizeFlags & wxSIZE_AUTO_HEIGHT)) ) { sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; } // change the width / height only when specified if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) width = sz.x; else width = widthOld; } if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) height = sz.y; else height = heightOld; } wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO ); // But now recompute the full size again because it could have changed. // This notably happens if the previous full size was too small to fully // fit the box margins. sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; // arrange radio buttons int x_start, y_start; x_start = ( width - sz.x ) / 2; y_start = ( height - sz.y ) / 2; x_offset = x_start; y_offset = y_start; current = m_radioButtonCycle; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0 ; i < (int)m_noItems; i++) { // not to do for the zero button! if ((i > 0) && ((i % GetMajorDim()) == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { x_offset += maxWidth + charWidth; y_offset = y_start; } else { x_offset = x_start; y_offset += maxHeight + space; } } current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i] ); current = current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) y_offset += maxHeight + space; else x_offset += maxWidth + charWidth; } }
BOOL CBGridCtrl::SortTextItems(int nCol, BOOL bAscending, int low, int high) { if (nCol >= GetColumnCount()) return FALSE;//大图象列表 if (high == -1) high =m_nRealRow-1; int lo = low; int hi = high; if( hi <= lo ) return FALSE; double niMid=GetItemTextV((lo+hi)/2, nCol); double nistr; while( lo <= hi ) { if( bAscending ) { nistr=GetItemTextV(lo, nCol); while (lo < high && nistr<niMid) { ++lo; nistr=GetItemTextV(lo, nCol); } } else { nistr=GetItemTextV(lo, nCol); while ((lo < high && nistr>niMid)) { ++lo; nistr=GetItemTextV(lo, nCol); } } if( bAscending ) { nistr=GetItemTextV(hi, nCol); while (hi > low && nistr>niMid) { --hi; nistr=GetItemTextV(hi, nCol); } } else { nistr=GetItemTextV(hi,nCol); while (hi > low && nistr<niMid) { --hi; nistr=GetItemTextV(hi, nCol); } } if (lo <= hi) { if (GetItemTextV(lo, nCol) != GetItemTextV(hi, nCol)) { SwapMx(m_pDoc->m_pStockBigBillData->m_pMapData[lo -1],m_pDoc->m_pStockBigBillData->m_pMapData[hi -1] ); UINT nRowHeight = m_arRowHeights[lo]; m_arRowHeights[lo] = m_arRowHeights[hi]; m_arRowHeights[hi] = nRowHeight; } ++lo; --hi; } } if( low < hi )// This code may be used in compiled form in any way you SortTextItems(nCol, bAscending, low, hi); if( lo < high ) SortTextItems(nCol, bAscending, lo, high); return TRUE; }
void CGameListCtrl::AutomaticColumnWidth() { wxRect rc(GetClientRect()); if (GetColumnCount() == 1) { SetColumnWidth(0, rc.GetWidth()); } else if (GetColumnCount() > 0) { int resizable = rc.GetWidth() - ( GetColumnWidth(COLUMN_PLATFORM) + GetColumnWidth(COLUMN_BANNER) + GetColumnWidth(COLUMN_ID) + GetColumnWidth(COLUMN_COUNTRY) + GetColumnWidth(COLUMN_SIZE) + GetColumnWidth(COLUMN_EMULATION_STATE)); // We hide the Maker column if the window is too small // Use ShowColumn() instead of SetColumnWidth because // the maker column may have been autohidden and the // therefore the content needs to be restored. if (resizable > 425) { if (SConfig::GetInstance().m_showMakerColumn && SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 3); ShowColumn(COLUMN_MAKER, resizable / 3); SetColumnWidth(COLUMN_FILENAME, resizable / 3); } else if (SConfig::GetInstance().m_showMakerColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); ShowColumn(COLUMN_MAKER, resizable / 2); } else if (SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); SetColumnWidth(COLUMN_FILENAME, resizable / 2); } else { SetColumnWidth(COLUMN_TITLE, resizable); } } else { if (SConfig::GetInstance().m_showFileNameColumn) { SetColumnWidth(COLUMN_TITLE, resizable / 2); SetColumnWidth(COLUMN_FILENAME, resizable / 2); } else { SetColumnWidth(COLUMN_TITLE, resizable); } HideColumn(COLUMN_MAKER); } } }
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int i; wxRadioButton *current; // define the position int x_current, y_current; int x_offset, y_offset; int widthOld, heightOld; GetSize( &widthOld, &heightOld ); GetPosition( &x_current, &y_current ); x_offset = x; y_offset = y; if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { if (x == wxDefaultCoord) x_offset = x_current; if (y == wxDefaultCoord) y_offset = y_current; } // define size int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth[128], eachHeight[128]; int totWidth, totHeight; GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); eachWidth[i] = eachWidth[i] + RADIO_SIZE; eachHeight[i] = wxMax( eachHeight[i], bestSizeRadio.y ); if (maxWidth < eachWidth[i]) maxWidth = eachWidth[i]; if (maxHeight < eachHeight[i]) maxHeight = eachHeight[i]; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ; // change the width / height only when specified if ( width == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_WIDTH ) width = sz.x; else width = widthOld; } if ( height == wxDefaultCoord ) { if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) height = sz.y; else height = heightOld; } wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO ); // arrange radio buttons int x_start, y_start; x_start = ( width - sz.x ) / 2; y_start = ( height - sz.y ) / 2; x_offset = x_start; y_offset = y_start; current = m_radioButtonCycle; for (i = 0 ; i < (int)m_noItems; i++) { // not to do for the zero button! if ((i > 0) && ((i % GetMajorDim()) == 0)) { if (m_windowStyle & wxRA_SPECIFY_ROWS) { x_offset += maxWidth + charWidth; y_offset = y_start; } else { x_offset = x_start; y_offset += maxHeight + space; } } current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i] ); current = current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) y_offset += maxHeight + space; else x_offset += maxWidth + charWidth; } }
void CMuleListCtrl::SortList() { if (!IsSorting() && (m_sort_func && GetColumnCount())) { m_isSorting = true; MuleSortData sortdata(m_sort_orders, m_sort_func); // In many cases control already has correct order, and sorting causes nasty flickering. // Make one pass through it to check if sorting is necessary at all. int nrItems = GetItemCount(); bool clean = true; long lastItemdata = 0; if (nrItems > 1) { lastItemdata = GetItemData(0); } for (int i = 1; i < nrItems; i++) { long nextItemdata = GetItemData(i); if (SortProc(lastItemdata, nextItemdata, (long int)&sortdata) > 0) { // ok - we need to sort clean = false; break; } lastItemdata = nextItemdata; } if (clean) { // no need to sort m_isSorting = false; return; } // Positions are likely to be invalid after sorting. ResetTTS(); // Store the current selected items ItemDataList selectedItems = GetSelectedItems(); // Store the focused item long pos = GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED ); wxUIntPtr focused = (pos == -1) ? 0 : GetItemData(pos); SortItems(SortProc, (long int)&sortdata); // Re-select the selected items. for (unsigned i = 0; i < selectedItems.size(); ++i) { long it_pos = FindItem(-1, selectedItems[i]); if (it_pos != -1) { SetItemState(it_pos, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } } // Set focus on item if any was focused if (focused) { long it_pos = FindItem(-1, focused); if (it_pos != -1) { SetItemState(it_pos, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); } } m_isSorting = false; } }
BOOL CReportCtrl::DeleteAllColumns() { while (GetColumnCount() > 0) DeleteColumn(0); return TRUE; }
void wxListCtrlEx::LoadColumnSettings(int widthsOptionId, int visibilityOptionId, int sortOptionId) { wxASSERT(!GetColumnCount()); if (widthsOptionId != -1) ReadColumnWidths(widthsOptionId); delete [] m_pVisibleColumnMapping; m_pVisibleColumnMapping = new unsigned int[m_columnInfo.size()]; if (visibilityOptionId != -1) { wxString visibleColumns = COptions::Get()->GetOption(visibilityOptionId); if (visibleColumns.Len() >= m_columnInfo.size()) { for (unsigned int i = 0; i < m_columnInfo.size(); i++) { if (!m_columnInfo[i].fixed) m_columnInfo[i].shown = visibleColumns[i] == '1'; } } } if (sortOptionId != -1) { wxString strorder = COptions::Get()->GetOption(sortOptionId); wxStringTokenizer tokens(strorder, _T(",")); unsigned int count = tokens.CountTokens(); if (count == m_columnInfo.size()) { unsigned long *order = new unsigned long[count]; bool *order_set = new bool[count]; memset(order_set, 0, sizeof(bool) * count); unsigned int i = 0; while (tokens.HasMoreTokens()) { if (!tokens.GetNextToken().ToULong(&order[i])) break; if (order[i] >= count || order_set[order[i]]) break; order_set[order[i]] = true; i++; } if (i == count) { bool valid = true; for (unsigned int j = 0; j < m_columnInfo.size(); j++) { if (!m_columnInfo[j].fixed) continue; if (j != order[j]) { valid = false; break; } } if (valid) for (unsigned int i = 0; i < m_columnInfo.size(); i++) m_columnInfo[i].order = order[i]; } delete [] order; delete [] order_set; } } CreateVisibleColumnMapping(); }
bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], int majorDim, long style, const wxValidator& validator, const wxString &name ) { if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxRadioBox creation failed") ); return false; } m_widget = gtk_frame_new(NULL); SetLabel(title); if ( HasFlag(wxNO_BORDER) ) { // If we don't do this here, the wxNO_BORDER style is ignored in Show() gtk_frame_set_shadow_type(GTK_FRAME(m_widget), GTK_SHADOW_NONE); } // majorDim may be 0 if all trailing parameters were omitted, so don't // assert here but just use the correct value for it SetMajorDim(majorDim == 0 ? n : majorDim, style); unsigned int num_of_cols = GetColumnCount(); unsigned int num_of_rows = GetRowCount(); GtkRadioButton *m_radio = (GtkRadioButton*) NULL; GtkWidget *table = gtk_table_new( num_of_rows, num_of_cols, FALSE ); gtk_table_set_col_spacings( GTK_TABLE(table), 1 ); gtk_table_set_row_spacings( GTK_TABLE(table), 1 ); gtk_widget_show( table ); gtk_container_add( GTK_CONTAINER(m_widget), table ); wxString label; GSList *radio_button_group = (GSList *) NULL; for (int i = 0; i < n; i++) { if ( i != 0 ) radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); label.Empty(); for ( const wxChar *pc = choices[i]; *pc; pc++ ) { if ( *pc != wxT('&') ) label += *pc; } m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) ); gtk_widget_show( GTK_WIDGET(m_radio) ); gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event", GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this ); m_boxes.Append( (wxObject*) m_radio ); if (HasFlag(wxRA_SPECIFY_COLS)) { int left = i%num_of_cols; int right = (i%num_of_cols) + 1; int top = i/num_of_cols; int bottom = (i/num_of_cols)+1; gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom, GTK_FILL, GTK_FILL, 1, 1 ); } else { int left = i/num_of_rows; int right = (i/num_of_rows) + 1; int top = i%num_of_rows; int bottom = (i%num_of_rows)+1; gtk_table_attach( GTK_TABLE(table), GTK_WIDGET(m_radio), left, right, top, bottom, GTK_FILL, GTK_FILL, 1, 1 ); } ConnectWidget( GTK_WIDGET(m_radio) ); if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); gtk_signal_connect( GTK_OBJECT(m_radio), "focus_in_event", GTK_SIGNAL_FUNC(gtk_radiobutton_focus_in), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_radio), "focus_out_event", GTK_SIGNAL_FUNC(gtk_radiobutton_focus_out), (gpointer)this ); } m_parent->DoAddChild( this ); PostCreation(size); return true; }
void ColumnManager::OnContextMenuHeader(CWnd* pWnd, CPoint point, bool isGroundEnable /* = false*/) { CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)pWnd; if ((point.x == -1) && (point.y == -1)) { CRect rect; pHeaderCtrl->GetItemRect(0, &rect); pHeaderCtrl->ClientToScreen(&rect); point = rect.CenterPoint(); } CMenu popup; if (popup.CreatePopupMenu()) { int columnCount = GetColumnCount(); CString temp; UINT uCheckedFlags = MF_STRING | MF_ENABLED | MF_CHECKED; UINT uUnCheckedFlags = MF_STRING | MF_ENABLED; // build control menu //temp.LoadString(IDS_STATUSLIST_SHOWGROUPS); //popup.AppendMenu(isGroundEnable? uCheckedFlags : uUnCheckedFlags, columnCount, temp); temp.LoadString(IDS_STATUSLIST_RESETCOLUMNORDER); popup.AppendMenu(uUnCheckedFlags, columnCount + 2, temp); popup.AppendMenu(MF_SEPARATOR); // standard columns AddMenuItem(&popup); // user-prop columns: // find relevant ones and sort 'em std::map<CString, int> sortedProps; for (int i = (int)itemName.size(); i < columnCount; ++i) if (IsRelevant(i)) sortedProps[GetName(i)] = i; if (!sortedProps.empty()) { // add 'em to the menu popup.AppendMenu(MF_SEPARATOR); for (auto iter = sortedProps.cbegin(), end = sortedProps.cend(); iter != end; ++iter) { popup.AppendMenu(IsVisible(iter->second) ? uCheckedFlags : uUnCheckedFlags , iter->second , iter->first); } } // show menu & let user pick an entry int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, pWnd); if ((cmd >= 1) && (cmd < columnCount)) SetVisible(cmd, !IsVisible(cmd)); else if (cmd == columnCount) { pWnd->GetParent()->SendMessage(LVM_ENABLEGROUPVIEW, !isGroundEnable, NULL); //EnableGroupView(!isGroundEnable); } else if (cmd == columnCount + 1) RemoveUnusedProps(); else if (cmd == columnCount + 2) { temp.LoadString(IDS_CONFIRMRESETCOLUMNORDER); if (MessageBox(pWnd->m_hWnd, temp, L"TortoiseGit", MB_YESNO | MB_ICONQUESTION) == IDYES) ResetColumns(m_dwDefaultColumns); } } }
bool CCellListCtrl::IsValidColumn(int index) const { return (0 <= index && index < GetColumnCount()); }
GDALDefaultRasterAttributeTable *KEARasterAttributeTable::Clone() const { if( ( GetRowCount() * GetColumnCount() ) > RAT_MAX_ELEM_FOR_CLONE ) return NULL; GDALDefaultRasterAttributeTable *poRAT = new GDALDefaultRasterAttributeTable(); for( int iCol = 0; iCol < (int)m_aoFields.size(); iCol++) { CPLString sName = m_aoFields[iCol].name; CPLString sUsage = m_aoFields[iCol].usage; GDALRATFieldUsage eGDALUsage; if( sUsage == "PixelCount" ) eGDALUsage = GFU_PixelCount; else if( sUsage == "Name" ) eGDALUsage = GFU_Name; else if( sUsage == "Red" ) eGDALUsage = GFU_Red; else if( sUsage == "Green" ) eGDALUsage = GFU_Green; else if( sUsage == "Blue" ) eGDALUsage = GFU_Blue; else if( sUsage == "Alpha" ) eGDALUsage = GFU_Alpha; else { // don't recognise any other special names - generic column eGDALUsage = GFU_Generic; } GDALRATFieldType eGDALType; switch( m_aoFields[iCol].dataType ) { case kealib::kea_att_bool: case kealib::kea_att_int: eGDALType = GFT_Integer; break; case kealib::kea_att_float: eGDALType = GFT_Real; break; case kealib::kea_att_string: eGDALType = GFT_String; break; default: eGDALType = GFT_Integer; break; } poRAT->CreateColumn(sName, eGDALType, eGDALUsage); poRAT->SetRowCount(m_poKEATable->getSize()); if( m_poKEATable->getSize() == 0 ) continue; if( eGDALType == GFT_Integer ) { int *panColData = (int*)VSIMalloc2(sizeof(int), m_poKEATable->getSize()); if( panColData == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Memory Allocation failed in KEARasterAttributeTable::Clone"); delete poRAT; return NULL; } if( (const_cast<KEARasterAttributeTable*>(this))-> ValuesIO(GF_Read, iCol, 0, m_poKEATable->getSize(), panColData ) != CE_None ) { CPLFree(panColData); delete poRAT; return NULL; } for( int iRow = 0; iRow < (int)m_poKEATable->getSize(); iRow++ ) { poRAT->SetValue(iRow, iCol, panColData[iRow]); } CPLFree(panColData); } if( eGDALType == GFT_Real ) { double *padfColData = (double*)VSIMalloc2(sizeof(double), m_poKEATable->getSize()); if( padfColData == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Memory Allocation failed in KEARasterAttributeTable::Clone"); delete poRAT; return NULL; } if( (const_cast<KEARasterAttributeTable*>(this))-> ValuesIO(GF_Read, iCol, 0, m_poKEATable->getSize(), padfColData ) != CE_None ) { CPLFree(padfColData); delete poRAT; return NULL; } for( int iRow = 0; iRow < (int)m_poKEATable->getSize(); iRow++ ) { poRAT->SetValue(iRow, iCol, padfColData[iRow]); } CPLFree(padfColData); } if( eGDALType == GFT_String ) { char **papszColData = (char**)VSIMalloc2(sizeof(char*), m_poKEATable->getSize()); if( papszColData == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Memory Allocation failed in KEARasterAttributeTable::Clone"); delete poRAT; return NULL; } if( (const_cast<KEARasterAttributeTable*>(this))-> ValuesIO(GF_Read, iCol, 0, m_poKEATable->getSize(), papszColData ) != CE_None ) { CPLFree(papszColData); delete poRAT; return NULL; } for( int iRow = 0; iRow < (int)m_poKEATable->getSize(); iRow++ ) { poRAT->SetValue(iRow, iCol, papszColData[iRow]); CPLFree(papszColData[iRow]); } CPLFree(papszColData); } } return poRAT; }
unsigned int wxHeaderCtrlBase::GetColumnAt(unsigned int pos) const { wxCHECK_MSG( pos < GetColumnCount(), wxNO_COLUMN, "invalid position" ); return GetColumnsOrder()[pos]; }
bool wxDataViewCtrl::AppendColumn(wxDataViewColumn* columnPtr) { return wxDataViewCtrl::InsertColumn( GetColumnCount(), columnPtr ); }
int Sql::GetColumns() const { return GetColumnCount(); }
wxSize wxRadioBox::DoGetBestSize() const { int charWidth, charHeight; int maxWidth, maxHeight; int eachWidth, eachHeight; int totWidth, totHeight; wxFont font = GetFont(); // GetParent()->GetFont() GetTextExtent( wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font ); charWidth /= 52; maxWidth = -1; maxHeight = -1; wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth, &eachHeight, NULL, NULL, &font ); eachWidth = (eachWidth + RADIO_SIZE); eachHeight = wxMax(eachHeight, bestSizeRadio.y ); if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxHeight < eachHeight) maxHeight = eachHeight; } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ); totWidth = sz.x; totHeight = sz.y; // optimum size is an additional 5 pt border to all sides totWidth += 10; totHeight += 10; // handle radio box title as well GetTextExtent( GetLabel(), &eachWidth, NULL ); eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth; if (totWidth < eachWidth) totWidth = eachWidth; return wxSize( totWidth, totHeight ); }
void ColumnManager::ReadSettings(DWORD defaultColumns, DWORD hideColumns, const CString& containerName, int maxsize, int* widthlist) { // defaults DWORD selectedStandardColumns = defaultColumns & ~hideColumns; m_dwDefaultColumns = defaultColumns & ~hideColumns; columns.resize(maxsize); int power = 1; for (int i = 0; i < maxsize; ++i) { columns[i].index = static_cast<int>(i); if (!widthlist) columns[i].width = 0; else columns[i].width = widthlist[i]; columns[i].visible = true; columns[i].relevant = !(hideColumns & power); columns[i].adjusted = false; power *= 2; } // userProps.clear(); // where the settings are stored within the registry registryPrefix = L"Software\\TortoiseGit\\StatusColumns\\" + containerName; // we accept settings of current version only bool valid = (DWORD)CRegDWORD(registryPrefix + L"Version", 0xff) == GITSLC_COL_VERSION; if (valid) { // read (possibly different) column selection selectedStandardColumns = CRegDWORD(registryPrefix, selectedStandardColumns) & ~hideColumns; // read column widths CString colWidths = CRegString(registryPrefix + L"_Width"); ParseWidths(colWidths); } // process old-style visibility setting SetStandardColumnVisibility(selectedStandardColumns); // clear all previously set header columns int c = control->GetHeaderCtrl()->GetItemCount() - 1; while (c >= 0) control->DeleteColumn(c--); // create columns for (int i = 0, count = GetColumnCount(); i < count; ++i) control->InsertColumn(i, GetName(i), LVCFMT_LEFT, IsVisible(i) && IsRelevant(i) ? -1 : GetVisibleWidth(i, false)); // restore column ordering if (valid) ParseColumnOrder(CRegString(registryPrefix + L"_Order")); else ParseColumnOrder(CString()); ApplyColumnOrder(); // auto-size the columns so we can see them while fetching status // (seems the same values will not take affect in InsertColumn) for (int i = 0, count = GetColumnCount(); i < count; ++i) { if (IsVisible(i)) control->SetColumnWidth(i, GetVisibleWidth(i, true)); } }
BOOL CReportCtrl::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == WM_KEYDOWN) { if (!_IsEditVisible()) { // disable user from check/uncheck the checkboxes using space key // things get nasty if the user is HOLDING the space bar down if (pMsg->wParam == VK_SPACE) return TRUE; } else { POINT pt = m_ptEditting; switch (pMsg->wParam) { case VK_ESCAPE: // Cancel edit EndEdit(FALSE); return TRUE; case VK_RETURN: // Commit edit EndEdit(TRUE); return TRUE; case VK_TAB: // switch edit sub items if (pt.y == GetColumnCount() - 1) pt.y = 0; else pt.y++; EndEdit(TRUE); StartEdit(pt.x, pt.y); return TRUE; case VK_UP: // edit upper item if (pt.x > 0) { pt.x--; EndEdit(TRUE); StartEdit(pt.x, pt.y); EnsureVisible(pt.x, FALSE); return TRUE; } break; case VK_DOWN: // edit lower item if (pt.x < CListCtrl::GetItemCount() - 1) { pt.x++; EndEdit(TRUE); StartEdit(pt.x, pt.y); EnsureVisible(pt.x, FALSE); return TRUE; } break; default: break; } } } return CListCtrl::PreTranslateMessage(pMsg); }
bool CBOINCListCtrl::OnSaveState(wxConfigBase* pConfig) { wxString strBaseConfigLocation = wxEmptyString; wxInt32 iIndex = 0; wxInt32 iStdColumnCount = 0; wxInt32 iActualColumnCount = GetColumnCount(); int i, j; wxASSERT(pConfig); // Retrieve the base location to store configuration information // Should be in the following form: "/Projects/" strBaseConfigLocation = pConfig->GetPath() + wxT("/"); iStdColumnCount = m_pParentView->m_iStdColWidthOrder.size(); // Cycle through the columns recording their widths for (iIndex = 0; iIndex < iActualColumnCount; iIndex++) { m_pParentView->m_iStdColWidthOrder[m_pParentView->m_iColumnIndexToColumnID[iIndex]] = GetColumnWidth(iIndex); } for (iIndex = 0; iIndex < iStdColumnCount; iIndex++) { pConfig->SetPath(strBaseConfigLocation + m_pParentView->m_aStdColNameOrder->Item(iIndex)); pConfig->Write(wxT("Width"), m_pParentView->m_iStdColWidthOrder[iIndex]); } // Save sorting column and direction pConfig->SetPath(strBaseConfigLocation); pConfig->Write(wxT("SortColumn"), m_pParentView->m_iSortColumnID); pConfig->Write(wxT("ReverseSortOrder"), m_pParentView->m_bReverseSort); // Save Column Order wxString strColumnOrder; wxString strBuffer; wxString strHiddenColumns; wxArrayInt aOrder(iActualColumnCount); CBOINCBaseView* pView = (CBOINCBaseView*)GetParent(); wxASSERT(wxDynamicCast(pView, CBOINCBaseView)); #ifdef wxHAS_LISTCTRL_COLUMN_ORDER aOrder = GetColumnsOrder(); #else for (i = 0; i < iActualColumnCount; ++i) { aOrder[i] = i; } #endif strColumnOrder.Printf(wxT("%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[0]])); for (i = 1; i < iActualColumnCount; ++i) { strBuffer.Printf(wxT(";%s"), pView->m_aStdColNameOrder->Item(pView->m_iColumnIndexToColumnID[aOrder[i]])); strColumnOrder += strBuffer; } pConfig->Write(wxT("ColumnOrder"), strColumnOrder); strHiddenColumns = wxEmptyString; for (i = 0; i < iStdColumnCount; ++i) { bool found = false; for (j = 0; j < iActualColumnCount; ++j) { if (pView->m_iColumnIndexToColumnID[aOrder[j]] == i) { found = true; break; } } if (found) continue; if (!strHiddenColumns.IsEmpty()) { strHiddenColumns += wxT(";"); } strHiddenColumns += pView->m_aStdColNameOrder->Item(i); } pConfig->Write(wxT("HiddenColumns"), strHiddenColumns); return true; }
BOOL CReportCtrl::_IsEditVisible() const { return m_bAllowEdit && m_ptEditting.x >= 0 && m_ptEditting.x < CListCtrl::GetItemCount() && m_ptEditting.y >= 0 && m_ptEditting.y < GetColumnCount(); }
// SetListColumnOrder() is called mostly from OnRestoreState(), so we don't // call OnSaveState() from here. CDlgHiddenColumns calls OnSaveState() // when we really need to do that. // // Unfortunately, we have no way of immediately calling OnSaveState() when // the user manually reorders columns because that does not generate a // notification from MS Windows so wxWidgets can't generate an event. void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) { int i, stdCount, columnPosition; int colCount = GetColumnCount(); int shownColCount = orderArray.GetCount(); int columnIndex = 0; // Column number among shown columns before re-ordering int columnID = 0; // ID of column, e.g. COLUMN_PROJECT, COLUMN_STATUS, etc. int sortColumnIndex = -1; wxArrayInt aOrder(shownColCount); CBOINCBaseView* pView = (CBOINCBaseView*)GetParent(); wxASSERT(wxDynamicCast(pView, CBOINCBaseView)); pView->m_iColumnIndexToColumnID.Clear(); for (i=colCount-1; i>=0; --i) { DeleteColumn(i); } stdCount = pView->m_aStdColNameOrder->GetCount(); pView->m_iColumnIDToColumnIndex.Clear(); for (columnID=0; columnID<stdCount; ++columnID) { pView->m_iColumnIDToColumnIndex.Add(-1); } for (columnID=0; columnID<stdCount; ++columnID) { for (columnPosition=0; columnPosition<shownColCount; ++columnPosition) { if (orderArray[columnPosition].IsSameAs(pView->m_aStdColNameOrder->Item(columnID))) { aOrder[columnPosition] = columnIndex; pView->AppendColumn(columnID); pView->m_iColumnIndexToColumnID.Add(columnID); pView->m_iColumnIDToColumnIndex[columnID] = columnIndex; ++columnIndex; break; } } } // Prevent a crash bug if we just changed to a new locale. // // If a column has the same name in both the old and new locale, we guard against // changing the sort column to that column. // // CBOINCListCtrl::OnRestoreState() may have incorrectly added the column names in // the new locale as "new" columns, so check against both shownColCount and stdCount. int limit = wxMin(shownColCount, stdCount); if (columnIndex < limit) { SetStandardColumnOrder(); for (columnID=0; columnID<limit; ++columnID) { aOrder[columnID] = columnID; pView->AppendColumn(columnID); pView->m_iColumnIndexToColumnID.Add(columnID); pView->m_iColumnIDToColumnIndex[columnID] = columnID; } } // If sort column is now hidden, set the new first column as sort column if (pView->m_iSortColumnID >= 0) { sortColumnIndex = pView->m_iColumnIDToColumnIndex[pView->m_iSortColumnID]; if (sortColumnIndex < 0) { pView->m_iSortColumnID = pView->m_iColumnIndexToColumnID[0]; pView->m_bReverseSort = false; pView->SetSortColumn(0); } else { // Redraw the sort arrow, etc. pView->SetSortColumn(sortColumnIndex); } } #ifdef wxHAS_LISTCTRL_COLUMN_ORDER colCount = GetColumnCount(); if ((shownColCount > 0) && (shownColCount <= stdCount) && (colCount == shownColCount)) { SetColumnsOrder(aOrder); } #endif }
void CTradeGridBase::FillGrid(IDataList* pDataList) { if (m_pTradeTable) { m_pDataList = pDataList; int iRowCount = m_pDataList->GetCount() + 1; int iColCount = GetColumnCount(); DWORD nBegin = GetTickCount(); DWORD nEnd = 0; CString sTmp = ""; sTmp.Format(_T("FillGrid GridCount:%d, Begin:%d\n"), iRowCount - 1, nBegin); TRACE(sTmp); BeginUpdateData(); SetRowCount(iRowCount); for (int i = 1; i < iRowCount; i++) { IDataItem* pRowItem = m_pDataList->GetItems(i - 1); SetItemData(i, 0, (LPARAM)pRowItem); for (int j = 0; j < iColCount; j++) { ITradeColumn* pColItem = (ITradeColumn*)GetItemData(0, j); CString sColName = pColItem->GetColumnName(); CString sText = pRowItem->GetStrByName(sColName); sText = pColItem->GetDictValue(sText); switch (pColItem->GetAlign()) { case alLeft: { SetItemFormat(i, j, DT_LEFT|DT_VCENTER|DT_SINGLELINE); break; } case alCenter: { SetItemFormat(i, j, DT_CENTER|DT_VCENTER|DT_SINGLELINE); break; } case alRight: { SetItemFormat(i, j, DT_RIGHT|DT_VCENTER|DT_SINGLELINE); break; } } SetItemText(i, j, sText); } } int nRow = GetCurrRow(); CCellID CellID; if (-1 == nRow) { CellID.row = 1; CellID.col = 1; SetFocusCell(CellID); SelectRows(CellID); } else if (nRow >= iRowCount) { CellID.row = iRowCount - 1; CellID.col = 1; SetFocusCell(CellID); SelectRows(CellID); } EndUpdateData(); nEnd = GetTickCount(); sTmp.Format(_T("ThreadId:%d,FillGrid End:%d, UseTime:%d\n"), GetCurrentThreadId(), nEnd, nEnd - nBegin); TRACE(sTmp); } }
BOOL CBCGPODBCGridCtrl::OpenSQL (LPCTSTR lpszSQL) { ASSERT (lpszSQL != NULL); m_strSQL.Empty (); RemoveAll (); if (!m_bIsSorting) { DeleteAllColumns (); } if (m_pDataBase == NULL) { ASSERT (FALSE); return FALSE; } try { ASSERT_VALID (m_pDataBase); if (!m_pDataBase->IsOpen ()) { ASSERT (FALSE); return FALSE; } if (m_pRecordSet != NULL) { ASSERT_VALID (m_pRecordSet); if (m_pRecordSet->IsOpen ()) { m_pRecordSet->Close (); } delete m_pRecordSet; m_pRecordSet = NULL; } //--------------------------------------------------------- // Create a new record set and open it using SQL statement: //--------------------------------------------------------- m_pRecordSet = new CRecordset (m_pDataBase); if (!m_pRecordSet->Open (CRecordset::dynaset, lpszSQL)) { return FALSE; } int nColumns = 0; if (!m_bIsSorting) { //------------- // Add columns: //------------- CStringList lstField; if (!GetFieldList (lstField)) { return FALSE; } int nColumn = 0; for (POSITION pos = lstField.GetHeadPosition (); pos != NULL; nColumn++) { InsertColumn (nColumn, lstField.GetNext (pos), 50); } nColumns = (int) lstField.GetCount (); } else { nColumns = GetColumnCount (); } if (nColumns == 0) { // No columns AdjustLayout (); return TRUE; } //------------- // Add records: //------------- if (m_pRecordSet->IsEOF () && m_pRecordSet->IsBOF ()) { // The table is empty AdjustLayout (); return TRUE; } if (m_bVirtualMode) { while (!m_pRecordSet->IsEOF ()) { m_pRecordSet->MoveNext (); } SetVirtualRows (max (0, m_pRecordSet->GetRecordCount ())); } else { for (int nRow = 0; !m_pRecordSet->IsEOF (); m_pRecordSet->MoveNext (), nRow++) { CBCGPGridRow* pRow = CreateRow (nColumns); ASSERT_VALID (pRow); for (int nColumn = 0; nColumn < nColumns; nColumn++) { OnAddData (pRow, nColumn, nRow); } if (OnBeforeAddRow (pRow, nRow)) { AddRow (pRow, FALSE); } else { delete pRow; } } } m_strSQL = lpszSQL; AdjustLayout (); if (!m_pRecordSet->CanUpdate ()) { SetReadOnly (); } } catch (CDBException* pEx) { OnODBCException (pEx); pEx->Delete (); return FALSE; } return TRUE; }
int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const { const int itemStart = item; int count = GetCount(), numCols = GetColumnCount(), numRows = GetRowCount(); bool horz = (style & wxRA_SPECIFY_COLS) != 0; do { switch ( dir ) { case wxUP: if ( horz ) { item -= numCols; } else // vertical layout { if ( !item-- ) item = count - 1; } break; case wxLEFT: if ( horz ) { if ( !item-- ) item = count - 1; } else // vertical layout { item -= numRows; } break; case wxDOWN: if ( horz ) { item += numCols; } else // vertical layout { if ( ++item == count ) item = 0; } break; case wxRIGHT: if ( horz ) { if ( ++item == count ) item = 0; } else // vertical layout { item += numRows; } break; default: wxFAIL_MSG( wxT("unexpected wxDirection value") ); return wxNOT_FOUND; } // ensure that the item is in range [0..count) if ( item < 0 ) { // first map the item to the one in the same column but in the last // row item += count; // now there are 2 cases: either it is the first item of the last // row in which case we need to wrap again and get to the last item // or we can just go to the previous item if ( item % (horz ? numCols : numRows) ) item--; else item = count - 1; } else if ( item >= count ) { // same logic as above item -= count; // ... except that we need to check if this is not the last item, // not the first one if ( (item + 1) % (horz ? numCols : numRows) ) item++; else item = 0; } wxASSERT_MSG( item < count && item >= 0, wxT("logic error in wxRadioBox::GetNextItem()") ); } // we shouldn't select the non-active items, continue looking for a // visible and shown one unless we came back to the item we started from in // which case bail out to avoid infinite loop while ( !(IsItemShown(item) && IsItemEnabled(item)) && item != itemStart ); return item; }
int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const { int count = GetCount(), numCols = GetColumnCount(), numRows = GetRowCount(); bool horz = (style & wxRA_SPECIFY_COLS) != 0; switch ( dir ) { case wxUP: if ( horz ) { item -= numCols; } else // vertical layout { if ( !item-- ) item = count - 1; } break; case wxLEFT: if ( horz ) { if ( !item-- ) item = count - 1; } else // vertical layout { item -= numRows; } break; case wxDOWN: if ( horz ) { item += numCols; } else // vertical layout { if ( ++item == count ) item = 0; } break; case wxRIGHT: if ( horz ) { if ( ++item == count ) item = 0; } else // vertical layout { item += numRows; } break; default: wxFAIL_MSG( _T("unexpected wxDirection value") ); return wxNOT_FOUND; } // ensure that the item is in range [0..count) if ( item < 0 ) { // first map the item to the one in the same column but in the last row item += count; // now there are 2 cases: either it is the first item of the last row // in which case we need to wrap again and get to the last item or we // can just go to the previous item if ( item % (horz ? numCols : numRows) ) item--; else item = count - 1; } else if ( item >= count ) { // same logic as above item -= count; // ... except that we need to check if this is not the last item, not // the first one if ( (item + 1) % (horz ? numCols : numRows) ) item++; else item = 0; } wxASSERT_MSG( item < count && item >= 0, _T("logic error in wxRadioBox::GetNextItem()") ); return item; }
// This shows a little tooltip with the current Game's emulation state void CGameListCtrl::OnMouseMotion(wxMouseEvent& event) { int flags; long subitem = 0; const long item = HitTest(event.GetPosition(), flags, &subitem); static int lastItem = -1; if (GetColumnCount() <= 1) return; if (item != wxNOT_FOUND) { wxRect Rect; #ifdef __WXMSW__ if (subitem == COLUMN_EMULATION_STATE) #else // The subitem parameter of HitTest is only implemented for wxMSW. On // all other platforms it will always be -1. Check the x position // instead. GetItemRect(item, Rect); if (Rect.GetX() + Rect.GetWidth() - GetColumnWidth(COLUMN_EMULATION_STATE) < event.GetX()) #endif { if (toolTip || lastItem == item || this != FindFocus()) { if (lastItem != item) lastItem = -1; event.Skip(); return; } // Emulation status static const char* const emuState[] = { "Broken", "Intro", "In-Game", "Playable", "Perfect" }; const GameListItem& rISO = *m_ISOFiles[GetItemData(item)]; const int emu_state = rISO.GetEmuState(); const std::string& issues = rISO.GetIssues(); // Show a tooltip containing the EmuState and the state description if (emu_state > 0 && emu_state < 6) { char temp[2048]; sprintf(temp, "^ %s%s%s", emuState[emu_state - 1], issues.size() > 0 ? " :\n" : "", issues.c_str()); toolTip = new wxEmuStateTip(this, StrToWxStr(temp), &toolTip); } else { toolTip = new wxEmuStateTip(this, _("Not Set"), &toolTip); } // Get item Coords GetItemRect(item, Rect); int mx = Rect.GetWidth(); int my = Rect.GetY(); #ifndef __WXMSW__ // For some reason the y position does not account for the header // row, so subtract the y position of the first visible item. GetItemRect(GetTopItem(), Rect); my -= Rect.GetY(); #endif // Convert to screen coordinates ClientToScreen(&mx, &my); toolTip->SetBoundingRect(wxRect(mx - GetColumnWidth(COLUMN_EMULATION_STATE), my, GetColumnWidth(COLUMN_EMULATION_STATE), Rect.GetHeight())); toolTip->SetPosition(wxPoint(mx - GetColumnWidth(COLUMN_EMULATION_STATE), my - 5 + Rect.GetHeight())); lastItem = item; } } if (!toolTip) lastItem = -1; event.Skip(); }
nsresult nsARIAGridAccessible::GetSelectedColumnsArray(PRUint32 *acolumnCount, PRInt32 **aColumns) { NS_ENSURE_ARG_POINTER(acolumnCount); *acolumnCount = 0; if (aColumns) *aColumns = nsnull; if (IsDefunct()) return NS_ERROR_FAILURE; AccIterator rowIter(this, filters::GetRow); nsAccessible *row = rowIter.GetNext(); if (!row) return NS_OK; PRInt32 colCount = 0; GetColumnCount(&colCount); if (!colCount) return NS_OK; PRInt32 selColCount = colCount; nsTArray<PRBool> isColSelArray(selColCount); isColSelArray.AppendElements(selColCount); for (PRInt32 i = 0; i < selColCount; i++) isColSelArray[i] = PR_TRUE; do { if (nsAccUtils::IsARIASelected(row)) continue; PRInt32 colIdx = 0; AccIterator cellIter(row, filters::GetCell); nsAccessible *cell = nsnull; for (colIdx = 0; (cell = cellIter.GetNext()); colIdx++) { if (isColSelArray.SafeElementAt(colIdx, PR_FALSE) && !nsAccUtils::IsARIASelected(cell)) { isColSelArray[colIdx] = PR_FALSE; selColCount--; } } } while ((row = rowIter.GetNext())); if (!selColCount) return NS_OK; if (!aColumns) { *acolumnCount = selColCount; return NS_OK; } *aColumns = static_cast<PRInt32*>( nsMemory::Alloc(selColCount * sizeof(PRInt32))); NS_ENSURE_TRUE(*aColumns, NS_ERROR_OUT_OF_MEMORY); *acolumnCount = selColCount; for (PRInt32 colIdx = 0, idx = 0; colIdx < colCount; colIdx++) { if (isColSelArray[colIdx]) (*aColumns)[idx++] = colIdx; } return NS_OK; }
void SimpleCheckpoint::Scan(storage::DataTable *target_table, oid_t database_oid) { auto schema = target_table->GetSchema(); PL_ASSERT(schema); std::vector<oid_t> column_ids; column_ids.resize(schema->GetColumnCount()); std::iota(column_ids.begin(), column_ids.end(), 0); oid_t current_tile_group_offset = START_OID; auto table_tile_group_count = target_table->GetTileGroupCount(); CheckpointTileScanner scanner; // TODO scan assigned tile in multi-thread checkpoint while (current_tile_group_offset < table_tile_group_count) { // Retrieve a tile group auto tile_group = target_table->GetTileGroup(current_tile_group_offset); // Retrieve a logical tile std::unique_ptr<executor::LogicalTile> logical_tile( scanner.Scan(tile_group, column_ids, start_commit_id_)); // Empty result if (!logical_tile) { current_tile_group_offset++; continue; } auto tile_group_id = logical_tile->GetColumnInfo(0) .base_tile->GetTileGroup() ->GetTileGroupId(); // Go over the logical tile for (oid_t tuple_id : *logical_tile) { expression::ContainerTuple<executor::LogicalTile> cur_tuple( logical_tile.get(), tuple_id); // Logging { // construct a physical tuple from the logical tuple std::unique_ptr<storage::Tuple> tuple(new storage::Tuple(schema, true)); for (auto column_id : column_ids) { tuple->SetValue(column_id, cur_tuple.GetValue(column_id), this->pool.get()); } ItemPointer location(tile_group_id, tuple_id); // TODO is it possible to avoid `new` for checkpoint? std::shared_ptr<LogRecord> record(logger_->GetTupleRecord( LOGRECORD_TYPE_TUPLE_INSERT, INITIAL_TXN_ID, target_table->GetOid(), database_oid, location, INVALID_ITEMPOINTER, tuple.get())); PL_ASSERT(record); CopySerializeOutput output_buffer; record->Serialize(output_buffer); LOG_TRACE("Insert a new record for checkpoint (%u, %u)", tile_group_id, tuple_id); records_.push_back(record); } } // persist to file once per tile Persist(); current_tile_group_offset++; } }
// Makes a row exchange places void wxAdvancedListCtrl::FlipRow(long Row, long NextRow) { if(Row == NextRow) return; // Retrieve data for the next item wxListItem Item1, Item2; wxListItem Item1Flipped, Item2Flipped; Item1.SetId(Row); Item1.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE); Item2.SetId(NextRow); Item2.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE); Item1Flipped.SetId(NextRow); Item1Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE); Item2Flipped.SetId(Row); Item2Flipped.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_DATA | wxLIST_MASK_IMAGE); // Due to bugs/limitations with wxWidgets, certain stuff needs to be // physically taken from the list control as GetItem is finicky wxColour Item1Colour = GetItemTextColour(Row); wxColour Item2Colour = GetItemTextColour(NextRow); wxInt32 Item1State = GetItemState(Row, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED); wxInt32 Item2State = GetItemState(NextRow, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED); // Flip the data for columns. for (wxInt32 ColumnCounter = 0; ColumnCounter < GetColumnCount(); ++ColumnCounter) { Item1.SetColumn(ColumnCounter); GetItem(Item1); Item2.SetColumn(ColumnCounter); GetItem(Item2); // Do the flip // Set data for the first item Item2Flipped.SetImage(Item2.GetImage()); Item2Flipped.SetData(Item2.GetData()); Item2Flipped.SetText(Item2.GetText()); // Now the second Item1Flipped.SetImage(Item1.GetImage()); Item1Flipped.SetData(Item1.GetData()); Item1Flipped.SetText(Item1.GetText()); // Set them Item1Flipped.SetColumn(ColumnCounter); SetItem(Item1Flipped); Item2Flipped.SetColumn(ColumnCounter); SetItem(Item2Flipped); } // Due to bugs/limitations with wxWidgets, certain stuff needs to be // physically taken from the list control as GetItem is finicky SetItemState(NextRow, Item1State, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED); SetItemState(Row, Item2State, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED); SetItemTextColour(NextRow, Item1Colour); SetItemTextColour(Row, Item2Colour); }