void DISPLAY_FOOTPRINTS_FRAME::InitDisplay() { wxString msg; CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent(); wxString footprintName = parentframe->m_footprintListBox->GetSelectedFootprint(); if( !footprintName.IsEmpty() ) { msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) ); SetTitle( msg ); const FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName ); const wxChar* libname; if( module_info ) libname = GetChars( module_info->GetNickname() ); else libname = GetChars( wxT( "???" ) ); msg.Printf( _( "Lib: %s" ), libname ); SetStatusText( msg, 0 ); if( GetBoard()->m_Modules.GetCount() ) { // there is only one module in the list GetBoard()->m_Modules.DeleteAll(); } MODULE* module = Get_Module( footprintName ); if( module ) GetBoard()->m_Modules.PushBack( module ); Zoom_Automatique( false ); } else // No footprint to display. Erase old footprint, if any { if( GetBoard()->m_Modules.GetCount() ) { GetBoard()->m_Modules.DeleteAll(); Zoom_Automatique( false ); SetStatusText( wxEmptyString, 0 ); } } // Display new cursor coordinates and zoom value: UpdateStatusBar(); GetCanvas()->Refresh(); if( m_Draw3DFrame ) m_Draw3DFrame->NewDisplay(); }
void PCB_EDIT_FRAME::Swap_Layers( wxCommandEvent& event ) { PCB_LAYER_ID new_layer[PCB_LAYER_ID_COUNT]; DIALOG_SWAP_LAYERS dlg( this, new_layer ); if( dlg.ShowModal() != wxID_OK ) return; BOARD_COMMIT commit( this ); bool hasChanges = false; // Change tracks. for( TRACK* segm = GetBoard()->m_Track; segm; segm = segm->Next() ) { if( segm->Type() == PCB_VIA_T ) { VIA* via = (VIA*) segm; PCB_LAYER_ID top_layer, bottom_layer; if( via->GetViaType() == VIA_THROUGH ) continue; via->LayerPair( &top_layer, &bottom_layer ); if( new_layer[bottom_layer] != bottom_layer || new_layer[top_layer] != top_layer ) { commit.Modify( via ); via->SetLayerPair( new_layer[top_layer], new_layer[bottom_layer] ); GetGalCanvas()->GetView()->Update( via, KIGFX::GEOMETRY ); hasChanges = true; } } else { hasChanges |= processBoardItem( this, commit, segm, new_layer ); } } for( BOARD_ITEM* zone : GetBoard()->Zones() ) { hasChanges |= processBoardItem( this, commit, zone, new_layer ); } for( BOARD_ITEM* drawing : GetBoard()->Drawings() ) { hasChanges |= processBoardItem( this, commit, drawing, new_layer ); } if( hasChanges ) { OnModify(); commit.Push( "Layers moved" ); GetCanvas()->Refresh(); } }
void wxCompositeShape::OnDragLeft(bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { double xx = x; double yy = y; m_canvas->Snap(&xx, &yy); double offsetX = xx - objectStartX; double offsetY = yy - objectStartY; wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(OGLRBLF); wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); GetEventHandler()->OnDrawOutline(dc, GetX() + offsetX, GetY() + offsetY, GetWidth(), GetHeight()); // wxShape::OnDragLeft(draw, x, y, keys, attachment); }
void TGUIStimulusView::Paint() { if( bitmap == NULL ) return; // Draw the bitmap. if( visible ) GetCanvas()->Draw( bitmapTRect.Left, bitmapTRect.Top, bitmap ); }
void StagePanel::OnPreview() { int width, height; QueryWindowViewSizeSJ::Instance()->Query(width, height); std::vector<ee::SprPtr> sprs; TraverseSprites(ee::FetchAllRefVisitor<ee::Sprite>(sprs)); EnableObserve(false); GetCanvas()->EnableObserve(false); GetStageImpl()->EnableObserve(false); PreviewDialog dlg(const_cast<StagePanel*>(this), GetCanvas()->GetGLContext(), width, height, sprs); dlg.ShowModal(); EnableObserve(true); GetCanvas()->EnableObserve(true); GetStageImpl()->EnableObserve(true); }
void wxDiagram::ReadLines(wxExprDatabase& database) { database.BeginFind(); wxExpr *clause = database.FindClauseByFunctor(_T("line")); while (clause) { wxString type; long parentId = -1; clause->GetAttributeValue(_T("type"), type); clause->GetAttributeValue(_T("parent"), parentId); wxClassInfo *classInfo = wxClassInfo::FindClass(type); if (classInfo) { wxLineShape *shape = (wxLineShape *)classInfo->CreateObject(); shape->Show(true); OnShapeLoad(database, *shape, *clause); shape->SetCanvas(GetCanvas()); long image_to = -1; long image_from = -1; clause->GetAttributeValue(_T("to"), image_to); clause->GetAttributeValue(_T("from"), image_from); wxExpr *image_to_expr = database.HashFind(_T("shape"), image_to); if (!image_to_expr) { // Error } wxExpr *image_from_expr = database.HashFind(_T("shape"), image_from); if (!image_from_expr) { // Error } if (image_to_expr && image_from_expr) { wxShape *image_to_object = (wxShape *)image_to_expr->GetClientData(); wxShape *image_from_object = (wxShape *)image_from_expr->GetClientData(); if (image_to_object && image_from_object) { image_from_object->AddLine(shape, image_to_object, shape->GetAttachmentFrom(), shape->GetAttachmentTo()); } } clause->SetClientData(shape); m_shapeList->Append(shape); } clause = database.FindClauseByFunctor(_T("line")); } }
bool wxDivisionShape::AdjustBottom(double bottom, bool test) { double y1 = (double)(GetY() - (GetHeight() / 2.0)); if (bottom <= y1) return FALSE; if (test) return TRUE; double newH = bottom - y1; double newY = (double)(y1 + newH / 2.0); SetSize(GetWidth(), newH); Move(GetX(), newY); if (GetCanvas()) GetCanvas()->Refresh(); return TRUE; }
// Adjust a side, returning false if it's not physically possible. bool wxDivisionShape::AdjustLeft(double left, bool test) { double x2 = (double)(GetX() + (GetWidth()/2.0)); if (left >= x2) return false; if (test) return true; double newW = x2 - left; double newX = (double)(left + newW/2.0); SetSize(newW, GetHeight()); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); Move(dc, newX, GetY()); return true; }
bool wxDivisionShape::AdjustTop(double top, bool test) { double y2 = (double)(GetY() + (GetHeight()/2.0)); if (top >= y2) return false; if (test) return true; double newH = y2 - top; double newY = (double)(top + newH/2.0); SetSize(GetWidth(), newH); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); Move(dc, GetX(), newY); return true; }
bool wxDivisionShape::AdjustRight(double right, bool test) { double x1 = (double)(GetX() - (GetWidth()/2.0)); if (right <= x1) return false; if (test) return true; double newW = right - x1; double newX = (double)(x1 + newW/2.0); SetSize(newW, GetHeight()); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); Move(dc, newX, GetY()); return true; }
bool wxDivisionShape::AdjustBottom(double bottom, bool test) { double y1 = (double)(GetY() - (GetHeight()/2.0)); if (bottom <= y1) return false; if (test) return true; double newH = bottom - y1; double newY = (double)(y1 + newH/2.0); SetSize(GetWidth(), newH); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); Move(dc, GetX(), newY); return true; }
bool wxDivisionShape::AdjustRight(double right, bool test) { double x1 = (double)(GetX() - (GetWidth() / 2.0)); if (right <= x1) return FALSE; if (test) return TRUE; double newW = right - x1; double newX = (double)(x1 + newW / 2.0); SetSize(newW, GetHeight()); Move(newX, GetY()); if (GetCanvas()) GetCanvas()->Refresh(); return TRUE; }
bool wxDivisionShape::AdjustTop(double top, bool test) { double y2 = (double)(GetY() + (GetHeight() / 2.0)); if (top >= y2) return FALSE; if (test) return TRUE; double newH = y2 - top; double newY = (double)(top + newH / 2.0); SetSize(GetWidth(), newH); Move(GetX(), newY); if (GetCanvas()) GetCanvas()->Refresh(); return TRUE; }
// Adjust a side, returning FALSE if it's not physically possible. bool wxDivisionShape::AdjustLeft(double left, bool test) { double x2 = (double)(GetX() + (GetWidth() / 2.0)); if (left >= x2) return FALSE; if (test) return TRUE; double newW = x2 - left; double newX = (double)(left + newW / 2.0); SetSize(newW, GetHeight()); Move(newX, GetY()); if (GetCanvas()) GetCanvas()->Refresh(); return TRUE; }
void PCB_BASE_FRAME::SetPrevGrid() { EDA_DRAW_FRAME::SetPrevGrid(); if( m_gridSelectBox ) { wxCommandEvent cmd( wxEVT_CHOICE ); cmd.SetEventObject( this ); OnSelectGrid( cmd ); } else GetCanvas()->Refresh(); }
void CGUIContext::Clear() { Console = 0; TitleLabels = 0; VolumeControl = 0; TerrainControl = 0; GlyphControl = 0; SceneControl = 0; ControlPanel = 0; Manager->RemoveAllWidgets(); GetCanvas()->RemoveAllChildren(); }
void GTKWindow::PanelStateChanged(void) { Rect oRect; GdkBitmap *mask; GetCanvas()->SetNoScreenUpdate(true); Window::PanelStateChanged(); GetCanvas()->GetBackgroundRect(oRect); mask = ((GTKCanvas *)m_pCanvas)->GetMask(); gdk_threads_enter(); if (mask) gdk_window_shape_combine_mask(mainWindow->window, mask, 0, 0); gtk_widget_set_usize(mainWindow, oRect.Width(), oRect.Height()); gdk_threads_leave(); GetCanvas()->SetNoScreenUpdate(false); ((GTKCanvas *)GetCanvas())->Paint(oRect); }
void BLWorld::DrawDebugPath(const IBPath& oPath) const { if (oPath.GetLength() > 0) { int x1 = oPath.GetList()[0].x * GetGridSize() + GetGridSize()/2; int y1 = oPath.GetList()[0].y * GetGridSize() + GetGridSize()/2; //int x2 = m_pBot->GetPos().x * GetGridSize() + GetGridSize()/2; //int y2 = m_pBot->GetPos().y * GetGridSize() + GetGridSize()/2; //GetCanvas().CanvasBase::DrawLine(x1, y1, x2, y2, Color(0, 255, 0)); GetCanvas().CanvasBase::DrawRect(x1-5, y1-5, 10, 10, Color(0, 255, 0)); } for (uint i=1 ; i<oPath.GetLength() ; ++i) { int x1 = oPath.GetList()[i-1].x * GetGridSize() + GetGridSize()/2; int y1 = oPath.GetList()[i-1].y * GetGridSize() + GetGridSize()/2; int x2 = oPath.GetList()[i].x * GetGridSize() + GetGridSize()/2; int y2 = oPath.GetList()[i].y * GetGridSize() + GetGridSize()/2; GetCanvas().CanvasBase::DrawLine(x1, y1, x2, y2, Color(0, 255, 0)); } }
void wxCompositeShape::SetSize(double w, double h, bool recursive) { SetAttachmentSize(w, h); double xScale = (double)(w / (wxMax(1.0, GetWidth()))); double yScale = (double)(h / (wxMax(1.0, GetHeight()))); m_width = w; m_height = h; if (!recursive) return; wxNode *node = m_children.GetFirst(); wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); double xBound, yBound; while (node) { wxShape *object = (wxShape *)node->GetData(); // Scale the position first double newX = (double)(((object->GetX() - GetX()) * xScale) + GetX()); double newY = (double)(((object->GetY() - GetY()) * yScale) + GetY()); object->Show(FALSE); object->Move(newX, newY); object->Show(TRUE); // Now set the scaled size object->GetBoundingBoxMin(&xBound, &yBound); object->SetSize(object->GetFixedWidth() ? xBound : xScale * xBound, object->GetFixedHeight() ? yBound : yScale * yBound); node = node->GetNext(); } SetDefaultRegionSize(); }
void ComboBox::Open() { if (!_menu) { return; } _menu->SetParent(GetCanvas()); _menu->SetHidden(false); _menu->BringToFront(); Gwen::Point point = LocalPositionToCanvas(Gwen::Point(0, 0)); _menu->SetBounds(Gwen::Rectangle(point._x, point._y + Height(), Width(), _menu->Height())); }
void TGUIReinforcementView::Paint() { if( animationCounter != lastAnimationCounter ) { if( animationCounter < numAnimationFrames ) animationBitmap = animFrames[ animationCounter ]; else animationBitmap = NULL; lastAnimationCounter = animationCounter; } if( animationBitmap != NULL ) GetCanvas()->Draw( animTRect.Left, animTRect.Top, animationBitmap ); }
void MyFrame::OnSetFaceName(wxCommandEvent& WXUNUSED(event)) { wxString facename = GetCanvas()->GetTextFont().GetFaceName(); wxString newFaceName = wxGetTextFromUser( wxT("Here you can edit current font face name."), wxT("Input font facename"), facename, this); if (newFaceName.IsEmpty()) return; // user clicked "Cancel" - do nothing wxFont font(GetCanvas()->GetTextFont()); if (font.SetFaceName(newFaceName)) // change facename only { wxASSERT_MSG(font.IsOk(), wxT("The font should now be valid")); DoChangeFont(font); } else { wxASSERT_MSG(!font.IsOk(), wxT("The font should now be invalid")); wxMessageBox(wxT("There is no font with such face name..."), wxT("Invalid face name"), wxOK|wxICON_ERROR, this); } }
// Control points ('handles') redirect control to the actual shape, to make it easier // to override sizing behaviour. void wxPolygonShape::OnSizingDragLeft(wxControlPoint *pt, bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { wxPolygonControlPoint *ppt = (wxPolygonControlPoint *) pt; wxClientDC dc(GetCanvas()); GetCanvas()->PrepareDC(dc); dc.SetLogicalFunction(OGLRBLF); wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); dc.SetPen(dottedPen); dc.SetBrush((* wxTRANSPARENT_BRUSH)); #if 0 // keys & KEY_CTRL) { // TODO: mend this code. Currently we rely on altering the // actual points, but we should assume we're not, as per // the normal sizing case. m_canvas->Snap(&x, &y); // Move point ppt->m_polygonVertex->x = x - this->GetX(); ppt->m_polygonVertex->y = y - this->GetY(); ppt->SetX(x); ppt->SetY(y); ((wxPolygonShape *)this)->CalculateBoundingBox(); ((wxPolygonShape *)this)->CalculatePolygonCentre(); } #else { ppt->CalculateNewSize(x, y); } #endif this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(), ppt->GetNewSize().x, ppt->GetNewSize().y); }
Error GTKWindow::GetWindowPosition(Rect &oWindowRect) { if (!mainWindow->window) return kError_NoErr; gdk_threads_enter(); gdk_window_get_position(mainWindow->window, &oWindowRect.x1, &oWindowRect.y1); gdk_threads_leave(); Rect oRect; if (GetCanvas()) { GetCanvas()->GetBackgroundRect(oRect); oWindowRect.x2 = oWindowRect.x1 + oRect.Width(); oWindowRect.y2 = oWindowRect.y1 + oRect.Height(); } else { oWindowRect.x2 = oWindowRect.x1; oWindowRect.y2 = oWindowRect.y1; } return kError_NoErr; }
void Menu::Layout(Skin::Base* skin) { // Call the base class. ScrollControl::Layout(skin); int children_height = 0; for (auto i = _inner_panel->GetChildren().begin(); i != _inner_panel->GetChildren().end(); ++i) { Base* child = (*i); assert(child != nullptr); if (child != nullptr) { children_height += child->Height(); } } if (Y() + children_height > GetCanvas()->Height()) { children_height = GetCanvas()->Height() - Y(); } SetSize(Width(), children_height); }
void SCH_EDIT_FRAME::DeleteAnnotation( bool aCurrentSheetOnly ) { if( aCurrentSheetOnly ) { m_CurrentSheet->Last()->ClearAnnotation(); } else { m_CurrentSheet->Last()->GetRootSheet()->ClearAnnotation( true ); } // Update the references for the sheet that is currently being displayed. m_CurrentSheet->Last()->UpdateAllScreenReferences(); GetCanvas()->Refresh(); OnModify(); }
void CGUIContext::SetupMainState() { GetCanvas()->SetDrawBackground(false); // Widgets Console = new CGUIConsoleWidget(& Manager->Get()); TitleLabels = new CGUITitleLabelsWidget(CProgramContext::Get().CurrentSite); VolumeControl = new CGUIVolumeControlWidget(); TerrainControl = new CGUITerrainControlWidget(); GlyphControl = new CGUIGlyphControlWidget(); SceneControl = new CGUISceneControlWidget(); ControlPanel = new CGUIControlPanelWidget(); Console->AddMessage("GUI Initialized."); Console->AddMessage("Starting program...", Colors::Red); }
void LIB_VIEW_FRAME::OnCloseWindow( wxCloseEvent& Event ) { GetCanvas()->StopDrawing(); if( !IsModal() ) { Destroy(); } else if( !IsDismissed() ) { // only dismiss modal frame if not already dismissed. DismissModal( false ); // Modal frame will be destroyed by the calling function. } }
void PCB_BASE_FRAME::SetFastGrid2() { if( m_FastGrid2 >= (int)GetScreen()->GetGridCount() ) return; int cmdId = GetScreen()->GetGrids()[m_FastGrid2].m_CmdId; SetPresetGrid( cmdId - ID_POPUP_GRID_LEVEL_1000 ); if( m_gridSelectBox ) { wxCommandEvent cmd( wxEVT_CHOICE ); cmd.SetEventObject( this ); OnSelectGrid( cmd ); } else GetCanvas()->Refresh(); }
void FieldStringEditor::do_xselection_paste(const Event& e) { XDisplay* disp = GetWorld()->display()->rep()->display_; unsigned int win = GetCanvas()->rep()->window_->rep()->xwindow_; Atom target_property = XInternAtom(disp, "PASTESTRING", false); Atom actual_atom; int actual_format; unsigned long ret_length, ret_remaining; unsigned char* data; int ret=XGetWindowProperty(disp, win, target_property, 0L, BUFSIZ, false, XA_STRING, &actual_atom, &actual_format, &ret_length, &ret_remaining, &data); if (ret == Success && data) { InsertText((char*) data, strlen((char*)data)); XFree(data); } }