/// Creation bool InstanceCtrl::Create(wxWindow* parent, InstanceModel *instList, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) { m_instList = instList; if (!wxScrolledCanvas::Create(parent, id, pos, size, style | wxFULL_REPAINT_ON_RESIZE | wxWANTS_CHARS)) return false; SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); CalculateOverallItemSize(); m_itemsPerRow = CalculateItemsPerRow(); m_intended_column = 0; SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); SetBackgroundStyle(wxBG_STYLE_CUSTOM); DisableKeyboardScrolling(); ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_ALWAYS); // Tell the sizers to use the given or best size SetInitialSize(size); // Create a buffer RecreateBuffer(size); return true; }
/// Sizing void InstanceCtrl::OnSize(wxSizeEvent& event) { int old_rows = GetItemsPerRow(); int new_rows = CalculateItemsPerRow(); if (old_rows != new_rows) { SetItemsPerRow(new_rows); ReflowAll(); } SetupScrollbars(); RecreateBuffer(); event.Skip(); }
void wxShapeCanvas::OnPaint(wxPaintEvent &WXUNUSED(event)) { #if OGL_USE_BUFFERED_PAINT RecreateBuffer(); wxBufferedPaintDC dc(this, m_bufferBitmap); #else wxPaintDC dc(this); #endif PrepareDC(dc); DrawBackground(dc, true); if (GetDiagram()) GetDiagram()->Redraw(dc); // Necessary or it unscales again if there's a zoom level dc.SetUserScale(1.0, 1.0); }
// Object canvas wxShapeCanvas::wxShapeCanvas(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name): wxScrolledWindow(parent, id, pos, size, style | wxVSCROLL | wxHSCROLL, name) { m_shapeDiagram = NULL; m_dragState = NoDragging; m_draggedShape = NULL; m_oldDragX = 0; m_oldDragY = 0; m_firstDragX = 0; m_firstDragY = 0; m_checkTolerance = TRUE; #if OGL_USE_BUFFERED_PAINT RecreateBuffer(size); #endif }