void LogMessagesViewer::appendMessages() { wxCriticalSectionLocker lock( _messagesCS ); if ( _messages.empty() ) { return; } BeginBatch(); int row = GetNumberRows(); AppendRows( _messages.size() ); do { appendMessage( _messages.front(), row ); _messages.pop(); ++row; } while ( !_messages.empty() ); AutoSizeColumns(); EndBatch(); MakeCellVisible( GetNumberRows()-1, 0 ); }
void DataGrid::updateBalanceAndTotal() { char buf[MONEY_LEN]; BeginBatch(); long balance = m_data->getInitial(); long income = 0; long outlay = 0; int row = 1; for (DataFileRW::ItemIterator i = m_data->ItemBegin(); i != m_data->ItemEnd(); ++i, row++) { if (is_dummy_item(&*i)) continue; balance = cal_item_balance(&*i, balance); money_to_str_trail(buf, balance); SetCellValue(row, BalanceIndex, buf); if (i->money < 0) { income -= i->money; } else { outlay += i->money; } } money_to_str_trail(buf, income); SetCellValue(row, IncomeIndex, buf); money_to_str_trail(buf, outlay); SetCellValue(row, OutlayIndex, buf); EndBatch(); }
void GLIDebugVariableGrid::RefreshGrid() { //Flag that we are updating the cells internally (so update callbacks do not get called) SetInternalEditMode(true); //Begin batch to not redraw during changes BeginBatch(); //Clear any existing data ClearGrid(); rowTypeDataArray.clear(); //Delete all rows if(GetNumberRows() > 0) { DeleteRows(0, GetNumberRows()); } //Refresh the watch values RefreshWatchValues(); //Refresh the uniform data RefreshUniformValues(); //End Batch to update the changes to the grid EndBatch(); //Reset the cell update counter SetInternalEditMode(false); }
//--------------------------------------------------------- bool CVIEW_Table_Control::Update_Table(void) { if( GetBatchCount() > 0 ) { return( false ); } BeginBatch(); //----------------------------------------------------- int Difference = (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols(); if( Difference > 0 ) { AppendCols(Difference); } else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 ) { // here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class DeleteCols(0, Difference); } //----------------------------------------------------- for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++) { SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField)); switch( m_pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: case SG_DATATYPE_Binary: SetColFormatCustom(iCol, wxGRID_VALUE_STRING); break; case SG_DATATYPE_Bit: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: SetColFormatNumber(iCol); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: SetColFormatFloat(iCol); break; } } //----------------------------------------------------- EndBatch(); return( _Set_Records() ); }
void CDX9Renderer::Box(const rect& r, cr_float angle, point hotspot, const color& c) { // No support for textured lines SetTexture(NULL); quad q((r - hotspot).rotate_to_quad(angle, r.topleft())); BeginBatch(batch_linestrip); CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back()); D3DCOLOR color = c.getD3DCOLOR(); // 4 vertices and use 5th index to repeat first vertex closing the strip as a box AddVertex(color, q.tl, 0.0f, 0.0f); AddVertex(color, q.tr, 0.0f, 0.0f); AddVertex(color, q.br, 0.0f, 0.0f); AddVertex(color, q.bl, 0.0f, 0.0f); unsigned short index = draw_op->vertex_count; AddIndex(index); AddIndex(index + 1); AddIndex(index + 2); AddIndex(index + 3); AddIndex(index); draw_op->vertex_count += 4; draw_op->index_count += 5; }
void CDX9Renderer::Box(const rect& r, const color& c) { // No support for textured lines SetTexture(NULL); BeginBatch(batch_linestrip); CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back()); D3DCOLOR color = c.getD3DCOLOR(); // 4 vertices and use 5th index to repeat first vertex closing the strip as a box AddVertex(color, r.topleft(), 0.0f, 0.0f); AddVertex(color, r.topright(), 0.0f, 0.0f); AddVertex(color, r.bottomright(), 0.0f, 0.0f); AddVertex(color, r.bottomleft(), 0.0f, 0.0f); unsigned short index = draw_op->vertex_count; AddIndex(index); AddIndex(index + 1); AddIndex(index + 2); AddIndex(index + 3); AddIndex(index); draw_op->vertex_count += 4; draw_op->index_count += 5; }
void CDX9Renderer::Point(point p, const color& c) { BeginBatch(batch_points); CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back()); AddVertex(c.getD3DCOLOR(), p, origin); draw_op->vertex_count++; }
void ctlResultGrid::fillGrid( PGresult * result ) { int rowCount = PQntuples( result ); int colCount = PQnfields( result ); // If this PGresult represents a non-query command // (like an INSERT), there won't be any columns in // the result set - just return if( colCount == 0 ) return; // Disable repaints to we don't flicker too much BeginBatch(); // Clear out the old results (if any) and resize // grid to match the result set if( GetNumberRows()) DeleteRows( 0, GetNumberRows()); if( GetNumberCols()) DeleteCols( 0, GetNumberCols()); AppendRows( rowCount ); AppendCols( colCount ); EnableEditing( false ); // Copy the column names from the result set into the column headers for( int col = 0; col < colCount; ++col ) SetColLabelValue( col, wxString( PQfname( result, col ), wxConvUTF8 )); // Now copy each value from the result set into the grid for( int row = 0; row < rowCount; ++row ) { for( int col = 0; col < colCount; ++col ) { if( PQgetisnull( result, row, col )) SetCellValue( row, col, wxT( "" )); else SetCellValue( row, col, wxString( PQgetvalue( result, row, col ), wxConvUTF8 )); } } // Resize each column to fit its content AutoSizeColumns( false ); // Enable repaints EndBatch(); }
//--------------------------------------------------------- void CVIEW_Table_Control::_Update_Views(void) { if( GetBatchCount() == 0 ) { BeginBatch(); g_pData->Update_Views(m_pTable); EndBatch(); } }
void CDX9Renderer::Line(point p1, point p2, const color& c1, const color& c2) { // No support for textured lines SetTexture(NULL); BeginBatch(batch_lines); CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back()); AddVertex(c1.getD3DCOLOR(), p1, 0.0f, 0.0f); AddVertex(c2.getD3DCOLOR(), p2, 1.0f, 1.0f); draw_op->vertex_count += 2; }
/* select all rows, that were formerly selected this raises selection events without user interaction */ void CBOINCGridCtrl::RestoreSelection() { BeginBatch(); // To prevent flicker ClearSelection(); for(unsigned int i=0;i < m_arrSelectedKeys1.size();i++) { int index = GetTable()->FindRowIndexByColValue( m_pkColumnIndex1,m_arrSelectedKeys1[i],m_pkColumnIndex2,m_arrSelectedKeys2[i] ); if(index >=0) { SelectRow(index,true); } } EndBatch(); }
void DX11SpriteBatch::DrawConsoleCommand(DX11FontSheet& fs, char (&text)[COMMAND_MAX_LENGTH], const POINT& pos) { BeginBatch(fs.GetFontSheetSRV()); int posX = pos.x; int posY = pos.y; XMCOLOR color = 0xffffffff; for(u32 i = 0; i < COMMAND_MAX_LENGTH; ++i) { WCHAR character = text[i]; if(character == ' ') posX += fs.GetSpaceWidth(); else if(character == '\t') posX += (4*fs.GetMaxCharWidth() - posX%(4*fs.GetMaxCharWidth())); else if(character == '\n') { posX = pos.x; posY += fs.GetCharHeight(); } else if(character == nullchar) break; else { if ( character < DX11FontSheet::StartChar || character > DX11FontSheet::EndChar ) character = '?'; const CD3D11_RECT& charRect = fs.GetCharBoundingRect(character); int width = charRect.right - charRect.left; int height = charRect.bottom - charRect.top; Draw(CD3D11_RECT(posX, posY, posX + width, posY + height), charRect, color); // Move to the next character position. posX += width + 1; } } // We Draw the cursor const CD3D11_RECT& charRect = fs.GetCharBoundingRect('_'); int width = charRect.right - charRect.left; int height = charRect.bottom - charRect.top; Draw(CD3D11_RECT(posX, posY, posX + width, posY + height), charRect, color); EndBatch(mContext); }
void DxSprite::DrawString(int X, int Y, const std::wstring & text, int R, int G, int B, int A, DxFont & F) { float blendFactor[4] = { 1.0f }; GetDX11Context()->OMSetBlendState(TransparentBS, blendFactor, 0xFFFFFFFF); BeginBatch(F.GetFontSheetSRV()); UINT length = text.length(); int posX = X; int posY = Y; XMCOLOR color; XMVECTOR Vec = XMVectorSet( R ? (float)( R / 255.0f ) : 0.0f, G ? (float)( G / 255.0f ) : 0.0f, B ? (float)( B / 255.0f ) : 0.0f, A ? (float)( A / 255.0f ) : 0.0f ); XMStoreColor(&color, Vec); for(UINT i = 0; i < length; ++i) { WCHAR character = text[i]; if(character == ' ') posX += F.GetSpaceWidth(); else if(character == '\n') { posX = X; posY += F.GetCharHeight(); } else { const CD3D11_RECT & charRect = F.GetCharRect(character); int width = charRect.right - charRect.left; int height = charRect.bottom - charRect.top; Draw(CD3D11_RECT(posX, posY, posX + width, posY + height), charRect, color); posX += width + 1; } } EndBatch(); GetDX11Context()->OMSetBlendState(0, blendFactor, 0xFFFFFFFF); }
void BaseGrid::OnSubtitlesOpen() { BeginBatch(); ClearMaps(); UpdateMaps(); if (GetRows()) { int row = context->ass->GetScriptInfoAsInt("Active Line"); if (row < 0 || row >= GetRows()) row = 0; SetActiveLine(GetDialogue(row)); SelectRow(row); } ScrollTo(context->ass->GetScriptInfoAsInt("Scroll Position")); EndBatch(); SetColumnWidths(); }
// Draw quad void CDX9Renderer::Quad(const quad& q, const color& filter, const rect* _uv) { if (current_texture != NULL && current_texture == current_rendertarget) throw error(_T("Illegal rendering operation attempted"), E_FAIL); // Not allowed to draw with texture being the render target BeginBatch(batch_quads); CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back()); rect uv; // No texture: UV coords don't matter if (current_texture == NULL) uv = zero_rect; else { // Texture supplied but no UV given: draw entire texture if (_uv == NULL) uv = point(current_texture->xf, current_texture->yf).make_rect(); else uv = (*_uv) * point(current_texture->xf, current_texture->yf); } D3DCOLOR c = filter.getD3DCOLOR(); AddVertex(c, q.tl + point(state.x_skew, 0.0), uv.topleft()); AddVertex(c, q.tr + point(state.x_skew, state.y_skew), uv.topright()); AddVertex(c, q.bl, uv.bottomleft()); AddVertex(c, q.br + point(0.0, state.y_skew), uv.bottomright()); unsigned short index = draw_op->vertex_count; AddIndex(index); AddIndex(index + 1); AddIndex(index + 2); AddIndex(index + 2); AddIndex(index + 1); AddIndex(index + 3); draw_op->vertex_count += 4; draw_op->index_count += 6; }
void DataGrid::showMainData() { char buf[MONEY_LEN]; BeginBatch(); int diff = GetNumberRows()-(m_data->getItemsNum()+1+1); // +initial and total if (diff < 0) { if (!AppendRows(-diff)) return; setRows(m_data->getItemsNum()+1+diff, -diff); } else if (diff > 0) { if (!DeleteRows(m_data->getItemsNum()+1, diff)) return; } SetRowLabelValue(0, HaStrings::strInitial); money_to_str_trail(buf, m_data->getInitial()); SetCellValue(0, BalanceIndex, buf); int row = 1; for (DataFileRW::ItemIterator i = m_data->ItemBegin(); i != m_data->ItemEnd(); ++i, row++) { if (ulist_is_first(&i->owner->items, &i->ulist)) { SetRowLabelValue(row, i->owner->title.str); } else { SetRowLabelValue(row, wxT("")); } clearRow(row); if (is_dummy_item(&*i)) continue; if (i->money < 0) { money_to_str_trail(buf, -i->money); SetCellValue(row, IncomeIndex, buf); } else { money_to_str_trail(buf, i->money); SetCellValue(row, OutlayIndex, buf); } SetCellValue(row, DescIndex, i->desc.str); SetCellValue(row, CommentIndex, i->comment.str); } SetRowLabelValue(row, HaStrings::strTotal); for (int i = 0; i < ColumnNum; i++) SetReadOnly(row, i); wxFont font = GetCellFont(row, 0); font.MakeBold(); SetCellFont(row, IncomeIndex, font); SetCellFont(row, OutlayIndex, font); EndBatch(); }
//--------------------------------------------------------- void CVIEW_Table_Control::On_Select(wxGridRangeSelectEvent &event) { if( GetBatchCount() == 0 ) { BeginBatch(); for(int iRow=event.GetTopRow(); iRow<=event.GetBottomRow(); iRow++) { if( m_pRecords[iRow]->is_Selected() != event.Selecting() ) { m_pTable->Select(m_pRecords[iRow], true); } } EndBatch(); _Update_Views(); } event.Skip(); }
void THDContentGrid::Refresh() { // Update the table to account for current index state. BeginBatch(); // Give wxGrid ownership over the pointer, so it's destroyed at the proper time. table = new THDContentTable(model); ClearColumns(); SetTable(table, true); SetRowLabelSize(0); SetColLabelSize(0); EnableEditing(false); EnableDragRowSize(false); EnableDragColSize(false); if (GetNumberRows() > 0) { // Scroll by entire rows int rowSize = GetRowSize(0); if (rowSize > 0) SetScrollLineY(rowSize); // Size all columns for (int col = 0; col < table->columns.size(); col++) { THDContentColumn &colObj = table->columns[col]; wxClientDC dc(GetParent()); int width = colObj.visualizer->GetWidth(dc); SetColMinimalWidth(col, width); SetColSize(col, width); } } EndBatch(); }
//--------------------------------------------------------- bool CVIEW_Table_Control::Update_Selection(void) { if( GetBatchCount() == 0 ) { BeginBatch(); if( m_pTable->Get_Selection_Count() >= m_pTable->Get_Count() ) { SelectAll(); } else { ClearSelection(); if( m_pTable->Get_Selection_Count() > 0 ) { #pragma omp parallel for for(int iRecord=0; iRecord<GetNumberRows(); iRecord++) { if( m_pRecords[iRecord]->is_Selected() ) { SelectRow(iRecord, true); } } } } EndBatch(); _Update_Views(); return( true ); } return( false ); }
//--------------------------------------------------------- bool CVIEW_Table_Control::_Set_Records(bool bSelection_To_Top) { BeginBatch(); //----------------------------------------------------- if( m_bSelOnly && m_pTable->Get_Selection_Count() <= 0 ) { m_bSelOnly = false; } int Difference, nRecords = m_bSelOnly ? m_pTable->Get_Selection_Count() : m_pTable->Get_Count(); if( (Difference = nRecords - GetNumberRows()) > 0 ) { AppendRows(Difference); } else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 ) { DeleteRows(0, Difference); } m_pRecords = (CSG_Table_Record **)SG_Realloc(m_pRecords, nRecords * sizeof(CSG_Table_Record *)); ClearSelection(); //----------------------------------------------------- if( m_bSelOnly ) { // #pragma omp parallel for for(int iRecord=0; iRecord<nRecords; iRecord++) { _Set_Record(iRecord, m_pTable->Get_Selection(iRecord)); } } else if( !bSelection_To_Top ) { // #pragma omp parallel for for(int iRecord=0; iRecord<nRecords; iRecord++) { _Set_Record(iRecord, m_pTable->Get_Record_byIndex(iRecord)); } } else // if( bSelection_To_Top && m_pTable->Get_Selection_Count() > 0 ) { for(int iRecord=0, iSel=0, iNoSel=m_pTable->Get_Selection_Count(); iRecord<nRecords && PROGRESSBAR_Set_Position(iRecord, nRecords); iRecord++) { CSG_Table_Record *pRecord = m_pTable->Get_Record_byIndex(iRecord); if( pRecord->is_Selected() ) { _Set_Record(iSel ++, pRecord); } else { _Set_Record(iNoSel++, pRecord); } } PROCESS_Set_Okay(); } //----------------------------------------------------- EndBatch(); _Update_Views(); return( true ); }
void BaseGrid::SetSelectionAndActive(Selection const& new_selection, AssDialogue *new_line) { BeginBatch(); SetSelectedSet(new_selection); SetActiveLine(new_line); EndBatch(); }
void BaseGrid::UpdateMaps(bool preserve_selected_rows) { BeginBatch(); int active_row = line_index_map[active_line]; std::vector<int> sel_rows; if (preserve_selected_rows) { sel_rows.reserve(selection.size()); transform(selection.begin(), selection.end(), back_inserter(sel_rows), [this](AssDialogue *diag) { return GetDialogueIndex(diag); }); } index_line_map.clear(); line_index_map.clear(); for (auto curdiag : context->ass->Line | agi::of_type<AssDialogue>()) { line_index_map[curdiag] = (int)index_line_map.size(); index_line_map.push_back(curdiag); } if (preserve_selected_rows) { Selection sel; // If the file shrank enough that no selected rows are left, select the // last row if (sel_rows.empty()) sel_rows.push_back(index_line_map.size() - 1); else if (sel_rows[0] >= (int)index_line_map.size()) sel_rows[0] = index_line_map.size() - 1; for (int row : sel_rows) { if (row >= (int)index_line_map.size()) break; sel.insert(index_line_map[row]); } SetSelectedSet(sel); } else { Selection lines; copy(index_line_map.begin(), index_line_map.end(), inserter(lines, lines.begin())); Selection new_sel; // Remove lines which no longer exist from the selection set_intersection(selection.begin(), selection.end(), lines.begin(), lines.end(), inserter(new_sel, new_sel.begin())); SetSelectedSet(new_sel); } // Force a reannounce of the active line if it hasn't changed, as it isn't // safe to touch the active line while processing a commit event which would // cause this function to be called AssDialogue *line = active_line; active_line = 0; // The active line may have ceased to exist; pick a new one if so if (line_index_map.size() && line_index_map.find(line) == line_index_map.end()) { if (active_row < (int)index_line_map.size()) { SetActiveLine(index_line_map[active_row]); } else if (preserve_selected_rows && !selection.empty()) { SetActiveLine(index_line_map[sel_rows[0]]); } else { SetActiveLine(index_line_map.back()); } } else { SetActiveLine(line); } if (selection.empty() && active_line) { Selection sel; sel.insert(active_line); SetSelectedSet(sel); } EndBatch(); SetColumnWidths(); Refresh(false); }
//--------------------------------------------------------- bool CActive_Attributes_Control::Update_Table(void) { if( GetBatchCount() > 0 ) { return( false ); } BeginBatch(); //----------------------------------------------------- int Difference = (m_pTable->Get_Field_Count() - m_Field_Offset) - GetNumberCols(); if( Difference > 0 ) { AppendCols(Difference); } else if( (Difference = -Difference < GetNumberCols() ? -Difference : GetNumberCols()) > 0 ) { // here is (or was!?) a memory leak - solution: use own wxGridTableBase derived grid table class DeleteCols(0, Difference); } //----------------------------------------------------- for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++) { SetColLabelValue(iCol, m_pTable->Get_Field_Name(iField)); switch( m_pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: case SG_DATATYPE_Binary: SetColFormatCustom(iCol, wxGRID_VALUE_STRING); break; case SG_DATATYPE_Bit: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: SetColFormatNumber(iCol); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: SetColFormatFloat(iCol); break; } } //----------------------------------------------------- if( (Difference = m_pTable->Get_Count() - GetNumberRows()) > 0 ) { AppendRows(Difference); } else if( Difference < 0 && (Difference = -Difference < GetNumberRows() ? -Difference : GetNumberRows()) > 0 ) { DeleteRows(0, Difference); } //------------------------------------------------- for(int iRecord=0; iRecord<m_pTable->Get_Count(); iRecord++) { _Set_Record(iRecord); } //----------------------------------------------------- if( GetNumberCols() > 0 && GetNumberRows() > 0 ) { SetRowLabelSize(wxGRID_AUTOSIZE); if( m_Field_Offset ) // feature attributes { if( GetClientSize().x > GetRowLabelSize() ) { SetColSize(0, GetClientSize().x - GetRowLabelSize()); } } else // grid cell values { AutoSizeColumns(); } } Enable(GetNumberRows() > 0); m_pTable->Set_Modified(false); //----------------------------------------------------- EndBatch(); return( true ); }
void DX11SpriteBatch::DrawTexture2D(ID3D11ShaderResourceView* texSRV, ID3D11DeviceContext* dc, CD3D11_RECT rect, XMCOLOR color) { BeginBatch(texSRV); Draw(rect, color); EndBatch(dc); }
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event) { int maxHeight, maxWidth; GetClientSize(&maxWidth, &maxHeight); int row = event.GetRow(); int col = event.GetCol(); int extent, extentWant = 0; if (row >= 0) { for (col = 0 ; col < GetNumberCols() ; col++) { extent = GetBestSize(row, col).GetHeight(); if (extent > extentWant) extentWant = extent; } extentWant += EXTRAEXTENT_HEIGHT; extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight()); extentWant = wxMin(extentWant, maxHeight * 3 / 4); int currentHeight = GetRowHeight(row); if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant) extentWant = GetRowMinimalAcceptableHeight(); else if (currentHeight < maxHeight / 4) extentWant = wxMin(maxHeight / 4, extentWant); else if (currentHeight < maxHeight / 2) extentWant = wxMin(maxHeight / 2, extentWant); else if (currentHeight < maxHeight * 3 / 4) extentWant = wxMin(maxHeight * 3 / 4, extentWant); if (extentWant != currentHeight) { BeginBatch(); if(IsCellEditControlShown()) { HideCellEditControl(); SaveEditControlValue(); } SetRowHeight(row, extentWant); EndBatch(); } } else if (col >= 0) { // Holding Ctrl or Meta switches back to automatic column's sizing if (event.ControlDown() || event.CmdDown()) { colSizes.erase(GetColKeyValue(col)); BeginBatch(); if(IsCellEditControlShown()) { HideCellEditControl(); SaveEditControlValue(); } AutoSizeColumn(col, false); EndBatch(); } else // toggle between some predefined sizes { if (col < (int)colMaxSizes.GetCount() && colMaxSizes[col] >= 0) extentWant = colMaxSizes[col]; else { for (row = 0 ; row < GetNumberRows() ; row++) { if (CheckRowPresent(row)) { extent = GetBestSize(row, col).GetWidth(); if (extent > extentWant) extentWant = extent; } } } extentWant += EXTRAEXTENT_WIDTH; extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth()); extentWant = wxMin(extentWant, maxWidth * 3 / 4); int currentWidth = GetColumnWidth(col); if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant) extentWant = GetColMinimalAcceptableWidth(); else if (currentWidth < maxWidth / 4) extentWant = wxMin(maxWidth / 4, extentWant); else if (currentWidth < maxWidth / 2) extentWant = wxMin(maxWidth / 2, extentWant); else if (currentWidth < maxWidth * 3 / 4) extentWant = wxMin(maxWidth * 3 / 4, extentWant); if (extentWant != currentWidth) { BeginBatch(); if(IsCellEditControlShown()) { HideCellEditControl(); SaveEditControlValue(); } SetColumnWidth(col, extentWant); EndBatch(); colSizes[GetColKeyValue(col)] = extentWant; } } } }
void DX11SpriteBatch::DrawString(DX11FontSheet& fs, const char text[], const POINT& pos, XMCOLOR color, TextAlignment alignment) { BeginBatch(fs.GetFontSheetSRV()); u32 length = (u32)strlen(text); int posX = 0; int posY = pos.y; int totalWidth = 0; int tabIdx = 0; int maxCharWidth = fs.GetMaxCharWidth(); if (alignment == LeftAligned) { posX = pos.x; } else { // Calculate text total width to adjust with the alignment for(u32 i = 0; i < length; ++i) { WCHAR character = text[i]; if(character == ' ') { totalWidth += maxCharWidth; } else { if ( character < DX11FontSheet::StartChar || character > DX11FontSheet::EndChar ) character = '?'; // Get the bounding rect of the character on the fontsheet. const CD3D11_RECT& charRect = fs.GetCharBoundingRect(character); int width = charRect.right - charRect.left; totalWidth += width; } } if (alignment == RightAligned) posX = pos.x - totalWidth; else posX = pos.x - totalWidth/ 2; } for(u32 i = 0; i < length; ++i) { WCHAR character = text[i]; if(character == ' ') { posX += maxCharWidth; tabIdx += maxCharWidth; } else if(character == '\t') { posX += (4*maxCharWidth - posX%(4*maxCharWidth)); tabIdx = 0; } else if(character == '\n') { posX = pos.x; posY += fs.GetCharHeight();; tabIdx = 0; } else { if ( character < DX11FontSheet::StartChar || character > DX11FontSheet::EndChar ) character = '?'; // Get the bounding rect of the character on the fontsheet. const CD3D11_RECT& charRect = fs.GetCharBoundingRect(character); int width = charRect.right - charRect.left; int height = charRect.bottom - charRect.top; int delta = maxCharWidth - width; // Draw the character sprite. Draw(CD3D11_RECT(posX, posY, posX + width, posY + height), charRect, color); // Move to the next character position. posX += width + delta; tabIdx += width + delta; } } EndBatch(mContext); }
void DX11SpriteBatch::DrawInfoText(DX11FontSheet& fs, const char* text, const POINT& pos) { BeginBatch(fs.GetFontSheetSRV()); int posX = pos.x; int posY = pos.y; int tabIdx = 0; int maxCharWidth = fs.GetMaxCharWidth(); XMCOLOR color = Color::Black; u32 i = 0; while( true ) { WCHAR character = text[i]; if(character == ' ') { posX += maxCharWidth; tabIdx += maxCharWidth; } else if(character == '\t') { posX += (4*maxCharWidth - tabIdx%(4*maxCharWidth)); tabIdx = 0; } else if(character == '\n') { posX = pos.x; posY += fs.GetCharHeight(); tabIdx = 0; } else if(character == SCREEN_WHITE) color = Color::White; else if(character == SCREEN_RED) color = Color::Red; else if(character == SCREEN_GREEN) color = Color::Lime; else if(character == SCREEN_BLUE) color = Color::Blue; else if(character == SCREEN_YELLOW) color = Color::Yellow; else if(character == SCREEN_ORANGE) color = Color::Orange; else if(character == SCREEN_ROSE) color = Color::Fuchsia; else if(character == SCREEN_GRAY) color = Color::Gray; else if(character == SCREEN_BLACK) color = Color::Black; else if(character == nullchar) break; else { if ( character < DX11FontSheet::StartChar || character > DX11FontSheet::EndChar ) character = '?'; // Get the bounding rect of the character on the fontsheet. const CD3D11_RECT& charRect = fs.GetCharBoundingRect(character); int width = charRect.right - charRect.left; int height = charRect.bottom - charRect.top; int delta = maxCharWidth - width; // Draw the character sprite. Draw(CD3D11_RECT(posX, posY, posX + width, posY + height), charRect, color); // Move to the next character position. posX += width + delta; tabIdx += width + delta; } ++i; } EndBatch(mContext); }
void ctlSQLGrid::OnLabelDoubleClick(wxGridEvent &event) { int maxHeight, maxWidth; GetClientSize(&maxWidth, &maxHeight); int row = event.GetRow(); int col = event.GetCol(); int extent, extentWant = 0; if (row >= 0) { for (col = 0 ; col < GetNumberCols() ; col++) { extent = GetBestSize(row, col).GetHeight(); if (extent > extentWant) extentWant = extent; } extentWant += EXTRAEXTENT_HEIGHT; extentWant = wxMax(extentWant, GetRowMinimalAcceptableHeight()); extentWant = wxMin(extentWant, maxHeight * 3 / 4); int currentHeight = GetRowHeight(row); if (currentHeight >= maxHeight * 3 / 4 || currentHeight == extentWant) extentWant = GetRowMinimalAcceptableHeight(); else if (currentHeight < maxHeight / 4) extentWant = wxMin(maxHeight / 4, extentWant); else if (currentHeight < maxHeight / 2) extentWant = wxMin(maxHeight / 2, extentWant); else if (currentHeight < maxHeight * 3 / 4) extentWant = wxMin(maxHeight * 3 / 4, extentWant); if (extentWant != currentHeight) { BeginBatch(); if(IsCellEditControlShown()) { HideCellEditControl(); SaveEditControlValue(); } SetRowHeight(row, extentWant); EndBatch(); } } else if (col >= 0) { for (row = 0 ; row < GetNumberRows() ; row++) { if (CheckRowPresent(row)) { extent = GetBestSize(row, col).GetWidth(); if (extent > extentWant) extentWant = extent; } } extentWant += EXTRAEXTENT_WIDTH; extentWant = wxMax(extentWant, GetColMinimalAcceptableWidth()); extentWant = wxMin(extentWant, maxWidth * 3 / 4); int currentWidth = GetColumnWidth(col); if (currentWidth >= maxWidth * 3 / 4 || currentWidth == extentWant) extentWant = GetColMinimalAcceptableWidth(); else if (currentWidth < maxWidth / 4) extentWant = wxMin(maxWidth / 4, extentWant); else if (currentWidth < maxWidth / 2) extentWant = wxMin(maxWidth / 2, extentWant); else if (currentWidth < maxWidth * 3 / 4) extentWant = wxMin(maxWidth * 3 / 4, extentWant); if (extentWant != currentWidth) { BeginBatch(); if(IsCellEditControlShown()) { HideCellEditControl(); SaveEditControlValue(); } SetColumnWidth(col, extentWant); EndBatch(); } } }