//Gives the pivot position over the screen iPoint GuiItem::GetPivotPosition() { iPoint ret = pivot; ret += GetScreenPosition(); return ret; }
void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event ) { int localkey; wxPoint pos; localkey = event.GetKeyCode(); switch( localkey ) { default: break; case WXK_ESCAPE: m_abortRequest = true; if( IsMouseCaptured() ) EndMouseCapture(); else EndMouseCapture( ID_NO_TOOL_SELECTED, m_defaultCursor, wxEmptyString ); break; } /* Normalize keys code to easily handle keys from Ctrl+A to Ctrl+Z * They have an ascii code from 1 to 27 remapped * to GR_KB_CTRL + 'A' to GR_KB_CTRL + 'Z' */ if( event.ControlDown() && localkey >= WXK_CONTROL_A && localkey <= WXK_CONTROL_Z ) localkey += 'A' - 1; /* Disallow shift for keys that have two keycodes on them (e.g. number and * punctuation keys) leaving only the "letter keys" of A-Z. * Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout) * and Ctrl-( and Ctrl-5 (FR layout). * Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout */ bool keyIsLetter = ( localkey >= 'A' && localkey <= 'Z' ) || ( localkey >= 'a' && localkey <= 'z' ); if( event.ShiftDown() && ( keyIsLetter || localkey > 256 ) ) localkey |= GR_KB_SHIFT; if( event.ControlDown() ) localkey |= GR_KB_CTRL; if( event.AltDown() ) localkey |= GR_KB_ALT; INSTALL_UNBUFFERED_DC( DC, this ); // Some key commands use the current mouse position: refresh it. pos = wxGetMousePosition() - GetScreenPosition(); // Compute the cursor position in drawing units. Also known as logical units to wxDC. pos = wxPoint( DC.DeviceToLogicalX( pos.x ), DC.DeviceToLogicalY( pos.y ) ); GetParent()->SetMousePosition( pos ); if( !GetParent()->GeneralControl( &DC, pos, localkey ) ) event.Skip(); }
void QvisText2DInterface::GetCurrentValues(int which_widget) { bool doAll = (which_widget == -1); if(which_widget == 0 || doAll) { // Get the new position GetScreenPosition(positionEdit, tr("Lower left")); } if(which_widget == 1 || doAll) { stringVector sv; sv.push_back(textLineEdit->text().toStdString()); annot->SetText(sv); } if(which_widget == 2 || doAll) { // Get its new current value and store it in the atts. ForceSpinBoxUpdate(heightSpinBox); int w = heightSpinBox->value(); double pos2[3]; pos2[0] = double(w) * 0.01; pos2[1] = annot->GetPosition2()[1]; pos2[2] = annot->GetPosition2()[2]; annot->SetPosition2(pos2); } }
/** OnInit * * Called when the machine needs to be initialized */ void ComplxFrame::OnInit(void) { static bool first = true; lc3_init(state, true); if (console != NULL) delete console; console = new LC3Console(this); state.input = &console->inputStream; state.reader = complx_reader; state.peek = complx_peek; state.writer = complx_writer; // For keyboard interrupts state.interrupt_test.push_back(complx_step); console->Show(); int x, y; GetScreenPosition(&x, &y); if (first) { Move(x + console->GetSize().GetX() / 2, y); console->Move(x - console->GetSize().GetX() / 2, y); first = false; } else { console->Move(x - console->GetSize().GetX(), y); } lc3_set_true_traps(state, menuStateTrueTraps->IsChecked()); state.interrupt_enabled = menuStateInterrupts->IsChecked(); state.max_stack_size = stack_size; state.max_call_stack_size = call_stack_size; }
void TWidget::_handle_mouseMove(const TEvent_MouseMoved& event, bool& consume) { consume = false; if (IsVisible() == false) { return; } const auto& mousePosition = event; const auto position = GetScreenPosition(); const auto bounds = position + GetOwnSize(); const bool isOver = IsVisible() && isPointInRect(mousePosition.x, mousePosition.y, position.x, position.y, bounds.x, bounds.y); if ((isOver == true) && (mouseOver == false)) { _OnHover(); GetSignal(DefaultSignalID::MouseEntered).Send(); } else if ((isOver == false) && (mouseOver == true)) { _OnMouseLeave(); GetSignal(DefaultSignalID::MouseLeave).Send(); } else { /*none*/ } mouseOver = isOver; }
/** * Returns the position within the parent window. */ gcc_pure const PixelRect GetPosition() const { #ifndef USE_GDI return { GetLeft(), GetTop(), GetRight(), GetBottom() }; #else PixelRect rc = GetScreenPosition(); HWND parent = ::GetParent(hWnd); if (parent != NULL) { POINT pt; pt.x = rc.left; pt.y = rc.top; ::ScreenToClient(parent, &pt); rc.left = pt.x; rc.top = pt.y; pt.x = rc.right; pt.y = rc.bottom; ::ScreenToClient(parent, &pt); rc.right = pt.x; rc.bottom = pt.y; } return rc; #endif }
void IDraggable::OnMessageReceived(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (!IsVisible()) { if (IsDragged() && !_notifyDragEndEvent(nullptr)) ClearDrag(); return; } Utils::Vector2 position(lParam); IComponent::OnMessageReceived(uMsg, wParam, lParam); switch(uMsg) { case WM_LBUTTONDOWN: if (!sWndProc.LastMessageHandled) { if (!IsDragged() && PtInBoundingRect(position) && !_notifyDragBeginEvent(&position)) StartDrag(position - GetScreenPosition()); sWndProc.LastMessageHandled |= IsDragged(); } break; case WM_LBUTTONUP: if (IsDragged()) { if (!_notifyDragEndEvent(&position)) ClearDrag(); sWndProc.LastMessageHandled = true; } break; case WM_MOUSEMOVE: if (IsDragged() && GetGlobalInterface()->ClipStack.PtInClipArea(position) && !_notifyDragMoveEvent(&position)) { position -= s_dragVector; auto pParent = GetUIParent(); if (pParent != nullptr) position -= pParent->GetScreenPosition(); SetPosition(position); } sWndProc.LastMessageHandled |= IsDragged(); break; }; }
void mmTransDialog::OnCustomFields(wxCommandEvent& /*event*/) { const wxString& RefType = Model_Attachment::reftype_desc(Model_Attachment::TRANSACTION); int TransID = m_trx_data.TRANSID; if (m_duplicate) TransID = -1; CustomFieldDialog_ = new mmCustomFieldDialog(this, GetScreenPosition(), GetSize(), RefType, TransID); CustomFieldDialog_->Show(); }
RECT IRectComponent::GetFullRect() const { RECT fullRect = {0}; Utils::Vector2 position = GetScreenPosition(); fullRect.left = static_cast<LONG>(position.x); fullRect.right = static_cast<LONG>(position.x + GetWidth()); fullRect.top = static_cast<LONG>(position.y); fullRect.bottom = static_cast<LONG>(position.y + GetHeight()); return fullRect; }
NS_IMETHODIMP BoxObject::GetScreenY(int32_t *_retval) { nsIntPoint position; nsresult rv = GetScreenPosition(position); if (NS_FAILED(rv)) return rv; *_retval = position.y; return NS_OK; }
bool TAbstractWindow::_isMouseOverHeader() const { if (HasHeader() == false) { return false; } const TCoordinate position = GetScreenPosition(); return IO::IsCursorInRect(position.x, position.y, position.x + size.x, position.y + headerHeight); }
TCoordinate TWidget::GetScreenPosition() const { const auto currentParent = parent.lock(); if (currentParent != nullptr) { TPadding innerBorder = currentParent->GetInnerBorder(); return position + currentParent->GetScreenPosition() + TCoordinate(innerBorder.left, innerBorder.top); } else { return position; } }
bool wxRibbonPanel::ShowExpanded() { if(!IsMinimised()) { return false; } if(m_expanded_dummy != NULL || m_expanded_panel != NULL) { return false; } wxSize size = GetBestSize(); wxPoint pos = GetExpandedPosition(wxRect(GetScreenPosition(), GetSize()), size, m_preferred_expand_direction).GetTopLeft(); // Need a top-level frame to contain the expanded panel wxFrame *container = new wxFrame(NULL, wxID_ANY, GetLabel(), pos, size, wxFRAME_NO_TASKBAR | wxBORDER_NONE); m_expanded_panel = new wxRibbonPanel(container, wxID_ANY, GetLabel(), m_minimised_icon, wxPoint(0, 0), size, m_flags); m_expanded_panel->SetArtProvider(m_art); m_expanded_panel->m_expanded_dummy = this; // Move all children to the new panel. // Conceptually it might be simpler to reparent this entire panel to the // container and create a new panel to sit in its place while expanded. // This approach has a problem though - when the panel is reinserted into // its original parent, it'll be at a different position in the child list // and thus assume a new position. // NB: Children iterators not used as behaviour is not well defined // when iterating over a container which is being emptied while(!GetChildren().IsEmpty()) { wxWindow *child = GetChildren().GetFirst()->GetData(); child->Reparent(m_expanded_panel); child->Show(); } // Move sizer to new panel if(GetSizer()) { wxSizer* sizer = GetSizer(); SetSizer(NULL, false); m_expanded_panel->SetSizer(sizer); } m_expanded_panel->Realize(); Refresh(); container->Show(); m_expanded_panel->SetFocus(); return true; }
void GuiInputBox::Draw() { image.Draw(); text.Draw(); if (inputOn) { iPoint pos = GetScreenPosition(); App->render->DrawQuad({ pos.x + cursor.x - App->render->camera.x, pos.y - App->render->camera.y, CURSOR_WIDTH, cursor.y }, 255, 255, 255); } }
void dxfv_wxWidgetsFrame::OnOpen(wxCommandEvent& event) { wxFileDialog openFileDialog(this, _("Open DXF file"), "", "", "DXF files (*.dxf)|*.dxf", wxFD_OPEN|wxFD_FILE_MUST_EXIST); if (openFileDialog.ShowModal() == wxID_CANCEL) return; // the user changed idea... dxf->LoadFile( std::string(openFileDialog.GetPath().utf8_str())); // check for control point splines for( dxfv::CSpline& spline : dxf->m_Spline ) { if( ! spline.m_FitPointCount) { wxMessageBox( "File contains control point splines\n" "These will not be displayed", "WARNING"); break; } } #ifdef DEMO if( dxf->myLoadStatus == dxfv::CDxf::demo ) { wxMessageBox( "Demo limit exceeded!", "Sorry"); exit(1); } #endif // DEMO SetTitle( openFileDialog.GetPath() ); dxf->myBoundingRectangle.Fit(); // restart the pan feature // this stores the current mouse position // if this is not done here, then a false pan operation // sometime occurrs on the first display of a newly opened file old_pos.x = wxGetMousePosition().x - GetScreenPosition().x; old_pos.y = wxGetMousePosition().y - GetScreenPosition().y - 55; Refresh(); }
/* restores former dialog size and (on Mac) position */ bool CDlgItemProperties::RestoreState() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); int iWidth, iHeight; wxASSERT(pConfig); if (!pConfig) return false; pConfig->SetPath(m_strBaseConfigLocation); pConfig->Read(wxT("Width"), &iWidth, wxDefaultCoord); pConfig->Read(wxT("Height"), &iHeight, wxDefaultCoord); #ifndef __WXMAC__ // Set size to saved values or defaults if no saved values SetSize(iWidth, iHeight); #else int iTop, iLeft; pConfig->Read(wxT("YPos"), &iTop, wxDefaultCoord); pConfig->Read(wxT("XPos"), &iLeft, wxDefaultCoord); // If either co-ordinate is less then 0 then set it equal to 0 to ensure // it displays on the screen. if ((iLeft < 0) && (iLeft != wxDefaultCoord)) iLeft = 30; if ((iTop < 0) && (iTop != wxDefaultCoord)) iTop = 30; // Set size and position to saved values or defaults if no saved values SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); // Now make sure window is on screen GetScreenPosition(&iLeft, &iTop); GetSize(&iWidth, &iHeight); Rect titleRect = {iTop, iLeft, iTop+22, iLeft+iWidth }; InsetRect(&titleRect, 5, 5); // Make sure at least a 5X5 piece visible RgnHandle displayRgn = NewRgn(); CopyRgn(GetGrayRgn(), displayRgn); // Region encompassing all displays Rect menuRect = ((**GetMainDevice())).gdRect; menuRect.bottom = GetMBarHeight() + menuRect.top; RgnHandle menuRgn = NewRgn(); RectRgn(menuRgn, &menuRect); // Region hidden by menu bar DiffRgn(displayRgn, menuRgn, displayRgn); // Subtract menu bar region if (!RectInRgn(&titleRect, displayRgn)) { iTop = iLeft = 30; SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); } DisposeRgn(menuRgn); DisposeRgn(displayRgn); #endif return true; }
void GameManager::Render() { rect r = GetScreenPosition(); Image* scr = Screen::Instance(); if (IsMapLoading() && mLoader) { //render some sort of color overlay surface over mMap? mLoader->Render(); } Frame::Render(); }
void Widget::Render() { Image* scr = Screen::Instance(); if (mBorderColor.a != 0) //default will have a zero alpha scr->DrawRound(GetScreenPosition(), 0, mBorderColor); for (int i = 0; i < mChildren.size(); i++) { if (mChildren.at(i)->mVisible) mChildren.at(i)->Render(); } }
void wxWebcamProps::OnClose(wxCloseEvent& WXUNUSED(event)) { int fx(0),fy(0); GetScreenPosition(&fx,&fy); if(fx > -1 && fy > -1) { long pos_x(fx),pos_y(fy); wxFactory::singleton()->config()->Write(_T("PropsPos_x"),pos_x); wxFactory::singleton()->config()->Write(_T("PropsPos_y"),pos_y); } // self-destruct the object when dialog is closed Destroy(); }
WXLRESULT MainMenuButton::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { if (WM_MENUSELECT == message) { if (HIWORD(wParam) == 0xFFFF && lParam == 0) { wxPoint pos = wxGetMousePosition()-GetScreenPosition(); wxRect rect = GetRect(); m_bIgnoreNextClick = rect.Contains(pos); } } return gcImageButton::MSWWindowProc(message, wParam, lParam); }
void ToolTip::Update(float timeStep) { // Track the element we are parented to for hovering. When we display, we move ourself to the root element // to ensure displaying on top UIElement* root = GetRoot(); if (!root) return; if (parent_ != root) target_ = parent_; // If target is removed while we are displaying, we have no choice but to destroy ourself if (target_.Expired()) { Remove(); return; } if (target_->IsHovering() && target_->IsVisibleEffective()) { float effectiveDelay = delay_ > 0.0f ? delay_ : GetSubsystem<UI>()->GetDefaultToolTipDelay(); if (!parentHovered_) { parentHovered_ = true; displayAt_.Reset(); } else if (displayAt_.GetMSec(false) >= (unsigned)(effectiveDelay * 1000.0f) && parent_ == target_) { originalPosition_ = GetPosition(); IntVector2 screenPosition = GetScreenPosition(); SetParent(root); SetPosition(screenPosition); SetVisible(true); // BringToFront() is unreliable in this case as it takes into account only input-enabled elements. // Rather just force priority to max SetPriority(M_MAX_INT); } } else { if (IsVisible() && parent_ == root) { SetParent(target_); SetPosition(originalPosition_); SetVisible(false); } parentHovered_ = false; displayAt_.Reset(); } }
void LoginForm::onMouseDown(wxMouseEvent& event) { #ifdef WIN32 wxPoint pos = wxGetMousePosition()-GetScreenPosition(); m_bMouseDrag = true; m_StartDrag = pos; m_StartPos = wxGetMousePosition(); if (!HasCapture()) CaptureMouse(); #else event.Skip(); #endif }
bool Control::PointIn(const Point& point) const { if(!GetVisible()) return false; Point position = GetScreenPosition(); if(point.x < position.x || point.x > position.x + mSize.cx) return false; if(point.y < position.y || point.y > position.y + mSize.cy) return false; return true; }
void ListBox::Draw( SpriteBatch& spriteBatch, SpriteBatch& spriteBatchFont ) { if (!mVisible) return; int2 screenPos = GetScreenPosition(); float zOrder = GetDepthLayer(); // Draw background first Rectanglef backRC((float)screenPos.X(), (float)screenPos.Y(), (float)mSize.X(), (float)mSize.Y()); mLisBoxStyle->DrawNinePatch(spriteBatch, UI_State_Normal, backRC, zOrder); if (mItems.size()) { int mimItem, maxItem; mVertScrollBar->GetScrollRange(&mimItem, &maxItem); Rectanglef rc((float)mTextRegion.X, (float)mTextRegion.Y, (float)mTextRegion.Width, (float)mTextRegion.Height); rc.SetBottom( rc.Y + mTextRowHeight); for (int i = mVertScrollBar->GetScrollValue(); i < maxItem + mNumVisibleItems; ++i) { if (rc.Bottom() > (float)mTextRegion.Bottom()) break; if( i == mSelectedIndex ) { // Draw selected highlight Rectanglef rcSel; rcSel.SetLeft(mSelectionRegion.Left()+1); rcSel.SetRight(mSelectionRegion.Right()); rcSel.SetTop((float)rc.Top()); rcSel.SetBottom((float)rc.Bottom()); spriteBatch.Draw(mLisBoxStyle->StyleTex, rcSel, &mLisBoxStyle->StyleStates[UI_State_Hover].TexRegion, mLisBoxStyle->StyleStates[UI_State_Hover].TexColor, zOrder); } // draw text //Rectanglef region((float)rc.X, (float)rc.Y, (float)rc.Width, (float)rc.Height); mLisBoxStyle->Font->DrawString(spriteBatchFont, mItems[i], mLisBoxStyle->FontSize, AlignVCenter, rc, mLisBoxStyle->ForeColor, zOrder); rc.Offset(0, mTextRowHeight); } } }
void AvatarCreator::Render() { //redraw (if necessary) and render mCompositePreview and the background image. if (mRedraw) _redraw(); Image* scr = Screen::Instance(); rect r = GetScreenPosition(); Frame::Render(); if (mCompositePreview) { mCompositePreview->Render(scr, r.x + 10, r.y + 50); } }
void TAbstractWindow::_draw(TRenderTarget& target) { if (needsRedraw == true) { TRenderTarget& localTarget = renderImage.getRenderTarget(); localTarget.clear(_currentColor()); if (image.drawingObject != nullptr) { if (image.image != nullptr) { sf::Sprite* sprite = image.drawingObject.get(); if (sprite != nullptr) { sprite->setColor(_currentColor()); } } localTarget.draw(*image.drawingObject); } if (HasHeader() == true) { sf::RectangleShape headerRect( sf::Vector2f(size.x, headerHeight) ); headerRect.setFillColor(_currentHeaderColor()); localTarget.draw(headerRect); } if (headerText->GetText().empty() == false) { headerText->Draw(localTarget); } renderImage.createDrawingObject(); needsRedraw = false; } const TCoordinate position = GetScreenPosition(); renderImage.getDrawingObject().setPosition(position.x, position.y); target.draw(renderImage.getDrawingObject()); #if defined(_DEBUG) if (Debug::show_frames() == true) { sf::RectangleShape boundingRect( sf::Vector2f(size.x, size.y) ); boundingRect.setFillColor(sf::Color(0, 0, 0, 0)); boundingRect.setOutlineColor(sf::Color(0, 255 - 55 * mouseOver, 0, 128)); boundingRect.setOutlineThickness(2.f); boundingRect.setPosition(position.x, position.y); target.draw(boundingRect); sf::Text rectText = TFont().CreateText(String::toWide(name)); rectText.setPosition(position.x, position.y); target.draw(rectText); } #endif // _DEBUG }
void MainEmuFrame::InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf ) { conf.DisplaySize.Set( std::min( std::max( conf.DisplaySize.GetWidth(), 160 ), wxGetDisplayArea().GetWidth() ), std::min( std::max( conf.DisplaySize.GetHeight(), 160 ), wxGetDisplayArea().GetHeight() ) ); if( conf.AutoDock ) { conf.DisplayPosition = GetScreenPosition() + wxSize( GetSize().x, 0 ); } else if( conf.DisplayPosition != wxDefaultPosition ) { if( !wxGetDisplayArea().Contains( wxRect( conf.DisplayPosition, conf.DisplaySize ) ) ) conf.DisplayPosition = wxDefaultPosition; } }
/* restores former dialog size and (on Mac) position */ bool CDlgItemProperties::RestoreState() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); int iWidth, iHeight; wxASSERT(pConfig); if (!pConfig) return false; pConfig->SetPath(m_strBaseConfigLocation); pConfig->Read(wxT("Width"), &iWidth, wxDefaultCoord); pConfig->Read(wxT("Height"), &iHeight, wxDefaultCoord); // Guard against a rare situation where registry values are zero if ((iWidth < 50) && (iWidth != wxDefaultCoord)) iWidth = wxDefaultCoord; if ((iHeight < 50) && (iHeight != wxDefaultCoord)) iHeight = wxDefaultCoord; #ifndef __WXMAC__ // Set size to saved values or defaults if no saved values SetSize(iWidth, iHeight); #else int iTop, iLeft; pConfig->Read(wxT("YPos"), &iTop, wxDefaultCoord); pConfig->Read(wxT("XPos"), &iLeft, wxDefaultCoord); // If either co-ordinate is less then 0 then set it equal to 0 to ensure // it displays on the screen. if ((iLeft < 0) && (iLeft != wxDefaultCoord)) iLeft = 30; if ((iTop < 0) && (iTop != wxDefaultCoord)) iTop = 30; // Set size and position to saved values or defaults if no saved values SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); // Now make sure window is on screen GetScreenPosition(&iLeft, &iTop); GetSize(&iWidth, &iHeight); if (!IsWindowOnScreen(iLeft, iTop, iWidth, iHeight)) { iTop = iLeft = 30; SetSize(iLeft, iTop, iWidth, iHeight, wxSIZE_USE_EXISTING); } #endif return true; }
void GSFrame::OnMove( wxMoveEvent& evt ) { if( IsBeingDeleted() ) return; evt.Skip(); g_Conf->GSWindow.IsMaximized = IsMaximized(); // evt.GetPosition() returns the client area position, not the window frame position. if( !g_Conf->GSWindow.IsMaximized && !IsFullScreen() && !IsIconized() && IsVisible() ) g_Conf->GSWindow.WindowPos = GetScreenPosition(); // wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions // like selecting or deselecting a window, which muck up docking logic. We filter them // out using 'lastpos' here. :) //static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord ); //if( lastpos == evt.GetPosition() ) return; //lastpos = evt.GetPosition(); }
//Draw functions void GuiImage::Draw() { iPoint p = GetScreenPosition(); //For now without mask, it gives some problems /*if (parent && parent->mask) { SDL_Rect r = parent->GetScreenRect(); App->render->SetViewPort({ r.x , r.y , r.w, r.h }); p = GetLocalPosition(); }*/ //Change the camera application to the GetScreenPositionFunction App->render->Blit(App->gui->GetAtlas(), p.x - App->render->camera.x, p.y - App->render->camera.y, &tex_rect); /*if (parent && parent->mask) App->render->ResetViewPort();*/ }