void Table::Attach( Widget::Ptr widget, const sf::Rect<sf::Uint32>& rect, int x_options, int y_options, const sf::Vector2f& padding ) { assert( rect.Width > 0 ); assert( rect.Height > 0 ); // Store widget in a table cell object. priv::TableCell cell( widget, rect, x_options, y_options, padding ); m_cells.push_back( cell ); // Check if we need to enlarge rows/columns. if( rect.Left + rect.Width >= m_columns.size() ) { std::size_t old_size( m_columns.size() ); m_columns.resize( rect.Left + rect.Width ); // Set default spacings. for( std::size_t col_index = old_size; col_index < m_columns.size(); ++col_index ) { m_columns[col_index].spacing = m_general_spacings.x; } } if( rect.Top + rect.Height >= m_rows.size() ) { std::size_t old_size( m_rows.size() ); m_rows.resize( rect.Top + rect.Height ); // Set default spacings. for( std::size_t row_index = old_size; row_index < m_rows.size(); ++row_index ) { m_rows[row_index].spacing = m_general_spacings.y; } } // Add widget to container. Add( widget ); // Request new size. RequestSize(); }
void Widget::Show( bool show ) { if( show == m_visible ) { return; } m_visible = show; RequestSize(); }
void Table::SetRowSpacing( std::size_t index, float spacing ) { if( index >= m_rows.size() ) { return; } m_rows[index].spacing = spacing; RequestSize(); }
void Table::SetColumnSpacing( std::size_t index, float spacing ) { if( index >= m_columns.size() ) { return; } m_columns[index].spacing = spacing; RequestSize(); }
void Table::SetRowSpacings( float spacing ) { for( std::size_t row_index = 0; row_index < m_rows.size(); ++row_index ) { m_rows[row_index].spacing = spacing; } m_general_spacings.y = spacing; RequestSize(); }
void Window::HandleAdd( Widget::Ptr child ) { Bin::HandleAdd( child ); if( GetChild() ) { // Reset allocation so the window will be as large as required. AllocateSize( sf::FloatRect( GetAllocation().Left, GetAllocation().Top, 1.f, 1.f ) ); RequestSize(); } }
void Table::SetColumnSpacings( float spacing ) { for( std::size_t column_index = 0; column_index < m_columns.size(); ++column_index ) { m_columns[column_index].spacing = spacing; } m_general_spacings.x = spacing; RequestSize(); }
/* Validate a node. Check to see that the node is "clean" in the sense that nothing has over/underwritten it etc. */ int wxMemStruct::ValidateNode () { char * startPointer = (char *) this; if (!AssertIt ()) { if (IsDeleted ()) ErrorMsg ("Object already deleted"); else { // Can't use the error routines as we have no recognisable object. #ifndef __WXGTK__ wxLogMessage(wxT("Can't verify memory struct - all bets are off!")); #endif } return 0; } /* int i; for (i = 0; i < wxDebugContext::TotSize (requestSize ()); i++) cout << startPointer [i]; cout << endl; */ if (Marker () != MemStartCheck) ErrorMsg (); if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck) ErrorMsg (); if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, RequestSize ()) != MemEndCheck) ErrorMsg (); // Back to before the extra buffer and check that // we can still read what we originally wrote. if (Marker () != MemStartCheck || * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck || * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, RequestSize ()) != MemEndCheck) { ErrorMsg (); return 0; } return 1; }
void Widget::SetRequisition( const sf::Vector2f& requisition ) const { if( requisition.x > 0.f || requisition.y >= 0.f ) { m_custom_requisition.reset( new sf::Vector2f( requisition ) ); } else { m_custom_requisition.reset(); } // Set flag to recalculate requisition and request new size. m_recalc_requisition = true; RequestSize(); }
/* Print out a single node. There are many far better ways of doing this but this will suffice for now. */ void wxMemStruct::PrintNode () { if (m_isObject) { wxObject *obj = (wxObject *)m_actualData; wxClassInfo *info = obj->GetClassInfo(); // Let's put this in standard form so IDEs can load the file at the appropriate // line wxString msg; if (m_fileName) msg.Printf(wxT("%s(%d): "), m_fileName, (int)m_lineNum); if (info && info->GetClassName()) msg += info->GetClassName(); else msg += wxT("object"); wxString msg2; msg2.Printf(wxT(" at 0x%lX, size %d"), (long)GetActualData(), (int)RequestSize()); msg += msg2; wxLogMessage(msg); } else { wxString msg; if (m_fileName) msg.Printf(wxT("%s(%d): "), m_fileName, (int)m_lineNum); msg += wxT("non-object data"); wxString msg2; msg2.Printf(wxT(" at 0x%lX, size %d\n"), (long)GetActualData(), (int)RequestSize()); msg += msg2; wxLogMessage(msg); } }
void Window::SetStyle( int style ) { m_style = style; // Make sure dragging and resizing operations are cancelled. m_dragging = false; m_resizing = false; RequestSize(); Invalidate(); if( GetChild() ) { GetChild()->AllocateSize( GetClientRect() ); } }
void Widget::Refresh() const { sf::FloatRect old_allocation( GetAllocation() ); RequestSize(); if( old_allocation.Left == GetAllocation().Left && old_allocation.Top == GetAllocation().Top && old_allocation.Width == GetAllocation().Width && old_allocation.Height == GetAllocation().Height ) { HandleAbsolutePositionChange(); HandleSizeAllocate( old_allocation ); } Invalidate(); }
void wxMemStruct::Dump () { if (!ValidateNode()) return; if (m_isObject) { wxObject *obj = (wxObject *)m_actualData; wxString msg; if (m_fileName) msg.Printf(wxT("%s(%d): "), m_fileName, (int)m_lineNum); /* TODO: We no longer have a stream (using wxLogDebug) so we can't dump it. * Instead, do what wxObject::Dump does. * What should we do long-term, eliminate Dumping? Or specify * that MyClass::Dump should use wxLogDebug? Ugh. obj->Dump(wxDebugContext::GetStream()); */ if (obj->GetClassInfo() && obj->GetClassInfo()->GetClassName()) msg += obj->GetClassInfo()->GetClassName(); else msg += wxT("unknown object class"); wxString msg2; msg2.Printf(wxT(" at 0x%lX, size %d"), (long)GetActualData(), (int)RequestSize()); msg += msg2; wxDebugContext::OutputDumpLine(msg.c_str()); } else { wxString msg; if (m_fileName) msg.Printf(wxT("%s(%d): "), m_fileName, (int)m_lineNum); wxString msg2; msg2.Printf(wxT("non-object data at 0x%lX, size %d"), (long)GetActualData(), (int)RequestSize() ); msg += msg2; wxDebugContext::OutputDumpLine(msg.c_str()); } }
/* Checks a node and block of memory to see that the markers are still intact. */ int wxMemStruct::CheckBlock () { int nFailures = 0; if (m_firstMarker != MemStartCheck) { nFailures++; ErrorMsg (); } char * pointer = wxDebugContext::MidMarkerPos ((char *) this); if (* (wxMarkerType *) pointer != MemMidCheck) { nFailures++; ErrorMsg (); } pointer = wxDebugContext::EndMarkerPos ((char *) this, RequestSize ()); if (* (wxMarkerType *) pointer != MemEndCheck) { nFailures++; ErrorMsg (); } return nFailures; }
int CTabStack::AppendInt(CTabID* pTab, BOOL abMoveFirst, MSectionLockSimple* pSC) { // Сразу накрутить счетчик таба pTab->AddRef(); #ifdef TAB_REF_PLACE pTab->AddPlace(m_rp.filename, m_rp.fileline); #endif // Если требуется модификация списка #ifdef _DEBUG if (!mpp_Stack || (mn_Used == mn_MaxCount) || abMoveFirst) { #if 1 _ASSERTE(pSC->isLocked()); #else pSC->RelockExclusive(); #endif } #endif if (!mpp_Stack || (mn_Used == mn_MaxCount)) { RequestSize(mn_Used+1, pSC); } if (abMoveFirst && mn_Used > 0) { memmove(mpp_Stack+1, mpp_Stack, mn_Used*sizeof(CTabID**)); mpp_Stack[0] = NULL; } int i = abMoveFirst ? 0 : mn_Used; mpp_Stack[i] = pTab; mn_Used++; return i; }
void CTabStack::UpdateAppend(HANDLE hUpdate, CTabID* pTab, BOOL abMoveFirst) { MSectionLockSimple* pUpdateLock = (MSectionLockSimple*)hUpdate; // Функция должна вызваться ТОЛЬКО между UpdateBegin & UpdateEnd if (mn_UpdatePos < 0 || !pUpdateLock) { _ASSERTE(mn_UpdatePos>=0); _ASSERTE(pUpdateLock!=NULL); return; } // Если таб в списке уже есть - то НИЧЕГО не делать (только переместить его в начало, если abActive) // Если таб новый - добавить в список и вызвать AddRef для таба if (!pTab) { _ASSERTE(pTab != NULL); return; } int nIndex = -1; for (int i = 0; i < mn_Used; i++) { if (mpp_Stack[i] == pTab) { nIndex = i; break; } } if (!abMoveFirst) { // "Обычное" население #ifdef _DEBUG if (nIndex == -1 || nIndex != mn_UpdatePos) { #if 1 _ASSERTE(pUpdateLock->isLocked()); #else pUpdateLock->RelockExclusive(); #endif } #endif RequestSize(mn_UpdatePos+1, pUpdateLock); if (nIndex != -1 && nIndex != mn_UpdatePos) { //_ASSERTE(nIndex > mn_UpdatePos); -- may happens when creating new split from active "far /e ..." tab // Do NOT release tab here! Behavior can differs by arguments of UpdateEnd! CTabID* p = mpp_Stack[mn_UpdatePos]; mpp_Stack[mn_UpdatePos] = mpp_Stack[nIndex]; mpp_Stack[nIndex] = p; // At the moment vector must be realigned! _ASSERTE(mpp_Stack[mn_UpdatePos] == pTab); } if (mpp_Stack[mn_UpdatePos] != pTab) { pTab->AddRef(); #ifdef TAB_REF_PLACE pTab->AddPlace(m_rp.filename, m_rp.fileline); #endif } mpp_Stack[mn_UpdatePos] = pTab; mn_UpdatePos++; if (mn_UpdatePos > mn_Used) { mn_Used = mn_UpdatePos; } } else { if (nIndex == -1) { // Таба в списке еще нет, добавляем AppendInt(pTab, abMoveFirst, pUpdateLock); } else if (abMoveFirst && nIndex > 0) { // Таб нужно переместить в начало списка #if 1 _ASSERTE(pUpdateLock->isLocked()); #else pUpdateLock->RelockExclusive(); #endif memmove(mpp_Stack+1, mpp_Stack, sizeof(CTabID**) * (nIndex-1)); mpp_Stack[0] = pTab; // AddRef не нужен, таб уже у нас в списке! } mn_UpdatePos++; } }