void Zoom(double zoomFactor) { if (zoomFactor < 0.05) { zoomFactor = 0.05; } if (zoomFactor > 5) { zoomFactor = 5; } m_zoomFactor = zoomFactor; wxRect currentImageRect = GetImageRect(); wxSize clientSize = GetClientSize(); int scrollX = currentImageRect.width + 10 > clientSize.x ? (currentImageRect.width - clientSize.x) : 0; int scrollY = currentImageRect.height + 10 > clientSize.y ? (currentImageRect.height - clientSize.y) : 0; SetVirtualSize(currentImageRect.width + 10, currentImageRect.height + 10); Scroll(scrollX / 2, scrollY / 2); Refresh(); }
void UppPackageViewWindow::UpdateBitmap(const wxSize& sz) { // initialize the bitmap if (!m_bmp.Create(sz)) { wxLogError(_("Can't create the package bitmap!")); return; } wxMemoryDC dc(m_bmp); if (!dc.IsOk()) { wxLogError(_("Can't draw the PIC package!")); return; } // clear the bitmap dc.SetBackground(*wxWHITE); dc.SetBrush(*wxWHITE); dc.Clear(); // draw the package on the bitmap m_pkg.Draw(dc, sz, m_name); dc.SelectObject(wxNullBitmap); { // NOTE: on wxMSW setting the virtual size triggers a size event // and thus our OnSize() would be called with an outdated // m_fitting variable; to avoid this we temporarily block // event generation wxEventBlocker nul(this); SetVirtualSize(sz); } AdjustScrollbars(); Refresh(); }
void VisualEditor::UpdateVirtualSize() { int w, h, panelW, panelH; GetVirtualSize(&w, &h); m_back->GetSize(&panelW, &panelH); panelW += 20; panelH += 20; if (panelW != w || panelH != h) SetVirtualSize(panelW, panelH); }
void TileMapPanel::Update() { if (!m_tilemap || !m_tileset) return; SetScrollRate(1, 1); SetVirtualSize(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y); Refresh(); }
void CalcSize() { if (m_sizeInitialized) return; m_sizeInitialized = true; wxSize size = GetClientSize(); if (!m_icons.empty()) { int icons_per_line = wxMax(1, (size.GetWidth() - BORDER) / (m_iconSize.GetWidth() + BORDER)); // Number of lines and line height int lines = (m_icons.size() - 1) / icons_per_line + 1; int vheight = lines * (m_iconSize.GetHeight() + BORDER) + BORDER; if (vheight > size.GetHeight()) { // Scroll bar would appear, need to adjust width size.SetHeight(vheight); SetVirtualSize(size); SetVirtualSizeHints(size, size); SetScrollRate(0, m_iconSize.GetHeight() + BORDER); wxSize size2 = GetClientSize(); size.SetWidth(size2.GetWidth()); icons_per_line = wxMax(1, (size.GetWidth() - BORDER) / (m_iconSize.GetWidth() + BORDER)); lines = (m_icons.size() - 1) / icons_per_line + 1; vheight = lines * (m_iconSize.GetHeight() + BORDER) + BORDER; if (vheight > size.GetHeight()) size.SetHeight(vheight); } // Calculate extra padding if (icons_per_line > 1) { int extra = size.GetWidth() - BORDER - icons_per_line * (m_iconSize.GetWidth() + BORDER); m_extra_padding = extra / (icons_per_line - 1); } } SetVirtualSize(size); SetVirtualSizeHints(size, size); SetScrollRate(0, m_iconSize.GetHeight() + BORDER); }
FancyTextPanel::FancyTextPanel(wxWindow* parent) : wxScrolled<wxWindow>(parent, wxID_ANY) , m_landscape(false) { static const double kSizeX = 576, kSizeY = 734 - 606; SetVirtualSize(wxSize(kSizeX, kSizeY)); SetScrollRate(10, 10); SetBackgroundColour(*wxWHITE); Connect(wxEVT_PAINT, wxPaintEventHandler(FancyTextPanel::OnPaint)); }
void Canvas::set_zoom(int zoom, wxPoint center) { { /* Overpaint old image */ wxClientDC dc(this); wxPen pen( *wxLIGHT_GREY ); wxBrush brush( *wxLIGHT_GREY ); dc.SetPen( pen ); dc.SetBrush( brush ); dc.DrawRectangle( canvas_coords( wxRect(0, 0, contents->GetWidth(), contents->GetHeight())) ); } if ( center == wxDefaultPosition ) { int xl, yl, xs, ys, xr, yr; GetViewStart( &xl, &yl ); GetScrollPixelsPerUnit( &xr, &yr ); GetClientSize( &xs, &ys ); center.x = xl*xr + xs / 2; center.y = yl*yr + ys / 2; center = image_coords( wxRect( center, wxSize(1,1) ) ).GetTopLeft(); } if ( zoom < 0 ) { zoom_out_level = -zoom+1; zoom_in_level = 1; } else { zoom_out_level = 1; zoom_in_level = zoom+1; } if ( zcl ) zcl->zoom_changed( zoom ); wxSize new_size( contents->GetWidth(), contents->GetHeight() ); SetVirtualSize( canvas_coords( new_size ).GetSize() ); int xr, yr; GetScrollPixelsPerUnit( &xr, &yr ); wxRect viewport = get_visible_region(); /* Transform center to new scroll coordinates. */ wxPoint top_left = viewport.CenterIn( canvas_coords( wxRect( center, wxSize(1,1) ) ) ).GetTopLeft(); Scroll( top_left.x / xr, top_left.y / yr ); wxClientDC dc(this); DoPrepareDC( dc ); wxRect canvas_region = get_visible_region(); wxBitmap bitmap = zoomed_bitmap_for_canvas_region( canvas_region ); dc.DrawBitmap( bitmap, canvas_region.GetTopLeft() ); }
wxsToolSpace::wxsToolSpace(wxWindow* Parent,wxsItemResData* Data): wxScrolledWindow(Parent), m_First(0), m_Count(0), m_Data(Data), m_Unstable(false) { SetScrollbars(5,0,1,1); SetClientSize(wxSize(2*ExtraBorderSize+IconSize,2*ExtraBorderSize+IconSize)); SetVirtualSize(1,1); }
BOOL CDiagramEntityContainer::FromString( const CString& str ) /* ============================================================ Function : CDiagramEntityContainer::FromString Description : Sets the virtual paper size from a string. Return : BOOL - TRUE if the string represented a paper. Parameters : const CString& str - The string representation. Usage : Call to set the paper size of the container from a string. The format is "paper:[x],[y];" where [x] and [y] are the horisontal and vertical sizes. ============================================================*/ { BOOL result = FALSE; CTokenizer main( str, _T( ":" ) ); CString header; CString data; if( main.GetSize() == 2 ) { main.GetAt( 0, header ); main.GetAt( 1, data ); header.TrimLeft(); header.TrimRight(); data.TrimLeft(); data.TrimRight(); if( header == _T( "paper" ) ) { CTokenizer tok( data.Left( data.GetLength() - 1 ) ); int size = tok.GetSize(); if( size == 2 ) { int right; int bottom; tok.GetAt(0, right ); tok.GetAt(1, bottom ); SetVirtualSize( CSize( right, bottom ) ); result = TRUE; } } } return result; }
TTYScroll::TTYScroll(wxWindow *parent, int n_lines) : wxScrolledWindow(parent), m_nLines( n_lines ) { bpause = false; wxClientDC dc(this); dc.GetTextExtent(_T("Line Height"), NULL, &m_hLine); SetScrollRate( 0, m_hLine ); SetVirtualSize( -1, ( m_nLines + 1 ) * m_hLine ); m_plineArray = new wxArrayString; for(unsigned int i=0 ; i < m_nLines ; i++) m_plineArray->Add(_T("")); }
/***************************************************** ** ** SheetWidget --- initViewPort ** ******************************************************/ void SheetWidget::initViewPort() { wxSize oldViewport = GetVirtualSize(); xviewport = writer->xSizeContents + 2 * SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_X; yviewport = writer->ycursor + 2 * SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_Y; if ( xviewport != oldViewport.x || yviewport != oldViewport.y ) { //printf( "SET VIEWPORT %d ---- %d\n", xviewport, yviewport ); SetVirtualSize( xviewport, yviewport ); } }
void OOPLyric::UpdateVirtualHeight() { wxASSERT(m_parser); int rowHeight = GetRowHeight(); int topBlankLinesHeight = m_blankLinesTop * rowHeight; int bottomBlankLinesHeight = m_Rect.height - topBlankLinesHeight; int actualHeight = m_parser->GetLinesCount() * rowHeight; int ySize = topBlankLinesHeight + actualHeight + bottomBlankLinesHeight; // -1 是为了得到一个总是不超出有效作用域的大小 SetVirtualSize(0, ySize - 1); }
GraphCanvas::GraphCanvas(wxWindow* parent, int border) : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxALWAYS_SHOW_SB | wxHSCROLL | wxVSCROLL), m_BorderSize(border), m_HandCursor(wxCURSOR_SIZING), m_Zoom(1.0f), m_OldZoom(0.0f), m_Width(0), m_Height(0), m_Zooming(false) { SetVirtualSize(0, 0); SetScrollRate(1, 1); SetBackgroundStyle(wxBG_STYLE_CUSTOM); }
void glictList::AddObject(glictContainer* object) { object->SetPos(0, totalheight); if(forcedheight) object->SetHeight(forcedheight); totalheight += object->GetHeight()+object->GetTopSize()+object->GetBottomSize(); glictContainer::AddObject(object); listlist.push_back(object); if (defocusabilize_element) object->SetFocusable(false); SetVirtualSize(width, totalheight); SetWidth(width); }
// Default OnSize resets scrollbars, if any void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) { if ( m_targetWindow->GetAutoLayout() ) { wxSize size = m_targetWindow->GetBestVirtualSize(); // This will call ::Layout() and ::AdjustScrollbars() SetVirtualSize( size ); } else { AdjustScrollbars(); } }
void PictureCanvas::imageChanged () { if (myBitmap) delete myBitmap; // Don't leak memory. if (!myImage) return; // Maybe there isn't a new image. myBitmap = new wxBitmap (*myImage); SetVirtualSize (myImage->GetWidth (), myImage->GetHeight ()); SetScrollRate (1, 1); if (wxFrame *frame = dynamic_cast<wxFrame *> (GetParent ())) { frame->SetSizeHints (-1, -1, myImage->GetWidth (), myImage->GetHeight ()); frame->Refresh (); } }
void StateEvaluationTreePanel::clear() { CurrentAccess.reset(); CurrentProcess = nullptr; CurrentThread = nullptr; Statement.clear(); Nodes.clear(); HoverNodeIt = Nodes.end(); ReplayHoverNodeIt = Nodes.end(); HoverTimer.Stop(); SetVirtualSize(1, 1); redraw(); }
// Define a constructor for my canvas MyCanvas::MyCanvas(wxView *view, wxWindow *parent) : wxScrolledWindow(parent ? parent : view->GetFrame()) { m_view = view; m_currentSegment = NULL; m_lastMousePos = wxDefaultPosition; SetCursor(wxCursor(wxCURSOR_PENCIL)); // this is completely arbitrary and is done just for illustration purposes SetVirtualSize(1000, 1000); SetScrollRate(20, 20); SetBackgroundColour(*wxWHITE); }
MaterialWindow::MaterialWindow(wxWindow* parent, MaterialsWindow* matTool) : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE), mMaterialsWindow(matTool), mMaterialAsset(NULL), mRightMouseDown(false), mRightMouseDrag(false), mWindowX(0.0f), mWindowY(0.0f) { mActiveConnection = NULL; mSelectedNode = NULL; mHoverNode = NULL; Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MaterialWindow::OnMenuEvent), NULL, this); SetVirtualSize(1000, 1000); }
void glictList::RebuildList(){ float currentheight=0; for (std::list<glictContainer*>::iterator it = listlist.begin() ; it != listlist.end() ; it++) { if (!(*it)->GetVisible()) continue; (*it)->SetPos(0, currentheight); if (forcedheight) (*it)->SetHeight(forcedheight); (*it)->SetWidth(width - GetCurrentVScrollbarWidth() - (*it)->GetLeftSize() - (*it)->GetRightSize()); currentheight += (*it)->GetHeight()+(*it)->GetTopSize()+(*it)->GetBottomSize(); } totalheight = currentheight; SetVirtualSize(width, totalheight); }
ModPanel::ModPanel(wxWindow *parent, int itemsize, double scale ) :BasePanel( parent, wxSUNKEN_BORDER | wxWANTS_CHARS ) { m_Parent = parent; m_Scale = scale; m_ItemSize = itemsize; m_ModList = ListOp.inst(); SetBackgroundColour( *wxWHITE ); // TODO: resize virtual size after every module add iONode ini = wGui.getmodpanel( wxGetApp().getIni() ); TraceOp.trc( "modpanel", TRCLEVEL_INFO, __LINE__, 9999, "modpanel cx=%d cy=%d", wModPanel.getcx(ini), wModPanel.getcy(ini) ); SetVirtualSize( (int)(m_ItemSize*m_Scale * wModPanel.getcx(ini)), (int)(m_ItemSize*m_Scale * wModPanel.getcy(ini)) ); SetScrollRate( (int)(m_ItemSize*m_Scale), (int)(m_ItemSize*m_Scale) ); }
void wxPaintBox::OnPaint(wxPaintEvent& WXUNUSED(event)) { SetVirtualSize(m_imageWidth, m_imageHeight); wxPaintDC dc(this); PrepareDC(dc); dc.BeginDrawing(); dc.DrawBitmap(*m_buffer, m_bufferX, m_bufferY); //background dc.SetPen(wxPen(*wxBLACK,0,wxTRANSPARENT)); dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); int w = wxMax(GetClientSize().GetWidth(), m_imageWidth); int h = wxMax(GetClientSize().GetHeight(), m_imageHeight); dc.DrawRectangle(m_imageWidth, 0, w-m_imageWidth, h+50); dc.DrawRectangle(0, m_imageHeight, w, h-m_imageHeight+50); dc.EndDrawing(); }
void StateEvaluationTreePanel::recalculateNodePositions() { wxClientDC dc(this); // Calculate the new size of the display. dc.SetFont(CodeFont); auto const StatementExtent = dc.GetTextExtent(Statement); auto const CharWidth = dc.GetCharWidth(); auto const CharHeight = dc.GetCharHeight(); wxCoord const PageBorderH = CharWidth * Settings.PageBorderHorizontal; wxCoord const PageBorderV = CharHeight * Settings.PageBorderVertical; wxCoord const NodeBorderV = CharHeight * Settings.NodeBorderVertical; auto const TotalWidth = StatementExtent.GetWidth() + (2 * PageBorderH); // Depth is zero-based, so there are (MaxDepth+1) lines for sub-nodes, plus // one line for the pretty-printed top-level node. auto const TotalHeight = ((MaxDepth + 2) * CharHeight) + ((MaxDepth + 1) * NodeBorderV) + (2 * PageBorderV); CurrentSize.Set(TotalWidth, TotalHeight); SetVirtualSize(TotalWidth, TotalHeight); // Calculate the position of each node in the display. for (auto &Node : Nodes) { auto const WidthPrior = dc.GetTextExtent(Statement.substr(0, Node.RangeStart)) .GetWidth(); auto const Width = dc.GetTextExtent(Statement.substr(Node.RangeStart, Node.RangeLength)) .GetWidth(); auto const XStart = PageBorderH + WidthPrior; auto const XEnd = XStart + Width; auto const YStart = TotalHeight - PageBorderV - CharHeight - (Node.Depth * (CharHeight + NodeBorderV)); Node.XStart = XStart; Node.XEnd = XEnd; Node.YStart = YStart; Node.YEnd = YStart + CharHeight; } }
CTreeCanvas::CTreeCanvas(wxWindow* parent) : wxScrolledWindow(parent),m_frozen(false), m_refresh_wanted_on_thaw(false), width(0), height(0), textureWidth(0), textureHeight(0), m_dragging(false), m_waiting_until_left_up(false), m_xpos(0), m_ypos(0), m_max_xpos(0) { wxGetApp().RegisterObserver(this); bmp_branch_plus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_plus.png"))); bmp_branch_minus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_minus.png"))); bmp_branch_end_plus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_end_plus.png"))); bmp_branch_end_minus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_end_minus.png"))); bmp_branch_split = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_split.png"))); bmp_branch_end = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_end.png"))); bmp_plus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/plus.png"))); bmp_minus = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/minus.png"))); bmp_branch_trunk = new wxBitmap(wxImage(wxGetApp().GetResFolder() + _T("/icons/branch_trunk.png"))); SetScrollRate( 10, 10 ); SetVirtualSize( 92, 97 ); }
void SetViewSize(int viewWidth, int viewHeight) { wxRect oldImageRect = GetImageRect(); m_viewSize = wxSize(viewWidth, viewHeight); wxSize zoomedSize((int)(viewWidth * m_zoomFactor), (int)(viewHeight * m_zoomFactor)); wxSize virtualSize = GetVirtualSize(); if (virtualSize.x != zoomedSize.GetWidth() + 10 || virtualSize.y != zoomedSize.GetHeight() + 10) { SetVirtualSize(zoomedSize.GetWidth() + 10, zoomedSize.GetHeight() + 10); } wxRect imageRect = GetImageRect(); imageRect = imageRect.Union(oldImageRect); Refresh(false, &imageRect); }
CDiagramEntityContainer::CDiagramEntityContainer( CDiagramClipboardHandler* clip ) /* ============================================================ Function : CDiagramEntityContainer::CDiagramEntityContainer Description : constructor Return : void Parameters : none Usage : ============================================================*/ { m_lastSelObj=NULL; m_clip = clip; SetUndoStackSize( 0 ); Clear(); SetVirtualSize( CSize( 0, 0 ) ); }
void CDiagramEntityContainer::Undo() /* ============================================================ Function : CDiagramEntityContainer::Undo Description : Sets the container data to the last entry in the undo stack. Return : void Parameters : none Usage : Call to undo the last operation ============================================================*/ { if( m_undo.GetSize() ) { // We remove all current data RemoveAll(); // We get the last entry from the undo-stack // and clone it into the container data CUndoItem* undo = static_cast< CUndoItem* >( m_undo.GetAt( m_undo.GetUpperBound() ) ); int count = ( undo->arr )->GetSize(); for( int t = 0 ; t < count ; t++ ) { CDiagramEntity* obj = static_cast< CDiagramEntity* >( ( undo->arr )->GetAt( t ) ); Add( obj->Clone() ); } // Set the saved virtual size as well SetVirtualSize( *( undo->pt ) ); // We remove the entry from the undo-stack delete undo; m_undo.RemoveAt( m_undo.GetUpperBound() ); } }
void nkToolBar::evtRepintar(wxPaintEvent& WXUNUSED(evt)){ wxPaintDC dc(this); int alto = 0, ancho = 0; int ancho_real, alto_real; int xx = 0, yy = 0; CalcScrolledPosition(xx, yy, &xx, &yy); for (nkListaMenu::Node *node = prv_listaMenus.GetFirst(); node; node = node->GetNext() ){ nkMenuTool *contador = node->GetData(); contador->Move(xx, alto + yy); alto = alto + contador->obtenerTamanio().GetHeight(); if (ancho<contador->obtenerTamanio().GetWidth()){ ancho = contador->obtenerTamanio().GetWidth(); } contador->Refresh(); } ancho_real = GetClientSize().GetWidth(); alto_real = GetClientSize().GetHeight(); SetVirtualSize(ancho, alto); SetMaxSize(wxSize(ancho+ALINEACION, alto+ALINEACION)); }
/* BEGIN_EVENT_TABLE(DatabaseCanvas, wxSFShapeCanvas) EVT_MENU(wxID_TABLEDROPTABLE, DatabaseCanvas::OnDropTable) END_EVENT_TABLE() */ DatabaseCanvas::DatabaseCanvas(wxView *view, const wxPoint &pt, wxWindow *parent) : wxSFShapeCanvas() { m_view = view; m_showDataTypes = m_showLabels = m_showToolBox = m_showComments = m_showIndexKeys = m_showIntegrity = true; m_oldSelectedSign = NULL; startPoint.x = 10; startPoint.y = 10; m_showComments = m_showIndexKeys = m_showIntegrity = true; m_pManager.SetRootItem( new xsSerializable() ); SetDiagramManager( &m_pManager ); Create( view->GetFrame(), wxID_ANY, pt, wxDefaultSize, wxHSCROLL | wxVSCROLL | wxALWAYS_SHOW_SB ); SetVirtualSize( 1000, 1000 ); SetScrollRate( 20, 20 ); m_mode = modeDESIGN; SetCanvasColour( *wxWHITE ); // Bind( wxID_TABLEDROPTABLE, &DatabaseCanvas::OnDropTable, this ); Bind( wxEVT_MENU, &DatabaseCanvas::OnDropTable, this, wxID_DROPOBJECT ); Bind( wxEVT_MENU, &DatabaseCanvas::OnDropTable, this, wxID_TABLECLOSE ); Bind( wxEVT_MENU, &DatabaseCanvas::OnShowSQLBox, this, wxID_SHOWSQLTOOLBOX ); Bind( wxEVT_MENU, &DatabaseCanvas::OnShowComments, this, wxID_VIEWSHOWCOMMENTS ); }
void ModPanel::reScale( double scale ) { int itemsize = wxGetApp().getItemSize(); m_Scale = scale; m_ItemSize = itemsize; SetVirtualSize( (int)(m_ItemSize*m_Scale*128), (int)(m_ItemSize*m_Scale*96) ); SetScrollRate( (int)(m_ItemSize*m_Scale), (int)(m_ItemSize*m_Scale) ); BasePanel* p = (BasePanel*)ListOp.first(m_ModList); while( p != NULL ) { p->reScale(scale); int xpos = (int)(itemsize * m_Scale * wZLevel.getmodviewx(p->getZLevel())); int ypos = (int)(itemsize * m_Scale * wZLevel.getmodviewy(p->getZLevel())); p->SetPosition( wxPoint( xpos, ypos) ); p = (BasePanel*)ListOp.next(m_ModList); } Refresh(); }