void wxQtDCImpl::Clear() { int width, height; DoGetSize(&width, &height); m_qtPainter->eraseRect(QRect(0, 0, width, height)); }
void wxQtDCImpl::DoCrossHair(wxCoord x, wxCoord y) { int w, h; DoGetSize( &w, &h ); // Map width and height back (inverted transform) QTransform inv = m_qtPainter->transform().inverted(); int left, top, right, bottom; inv.map( w, h, &right, &bottom ); inv.map( 0, 0, &left, &top ); m_qtPainter->drawLine( left, y, right, y ); m_qtPainter->drawLine( x, top, x, bottom ); }
void wxQtDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { // Special case: Empty region -> DestroyClippingRegion() if ( width == 0 && height == 0 ) { DestroyClippingRegion(); } else { if ( width < 0 ) { width = -width; x -= width - 1; } if ( height < 0 ) { height = -height; y -= height - 1; } if (m_qtPainter->isActive()) { // Set QPainter clipping (intersection if not the first one) m_qtPainter->setClipRect( x, y, width, height, m_clipping ? Qt::IntersectClip : Qt::ReplaceClip ); } // Set internal state for getters /* Note: Qt states that QPainter::clipRegion() may be slow, so we * keep the region manually, which should be faster */ if ( !m_clipping || m_clippingRegion.IsEmpty() ) { int dcwidth, dcheight; DoGetSize(&dcwidth, &dcheight); m_clippingRegion = wxRegion(0, 0, dcwidth, dcheight); } m_clippingRegion.Intersect( wxRect(x, y, width, height) ); wxRect clipRect = m_clippingRegion.GetBox(); m_clipX1 = clipRect.GetLeft(); m_clipX2 = clipRect.GetRight() + 1; m_clipY1 = clipRect.GetTop(); m_clipY2 = clipRect.GetBottom() + 1; m_clipping = true; } }
bool Stream::Seek(Signal &sig, long offset, SeekMode seekMode) { size_t offsetPrev = _offsetCur; if (seekMode == SeekSet) { _offsetCur = static_cast<size_t>(offset); } else if (seekMode == SeekCur) { _offsetCur = _offsetCur + offset; } else if (seekMode == SeekEnd) { _offsetCur = DoGetSize(); if (offset < 0 && _offsetCur < static_cast<size_t>(-offset)) { sig.SetError(ERR_IOError, "seek error"); return false; } } else { // this must not happen because illegal value has to be rejected before. return false; } if (_peek.buff == nullptr) return DoSeek(sig, offset, offsetPrev, seekMode); if (_offsetCur < offsetPrev) { size_t bytesPeeked = _peek.bytes; if (_peek.offsetRead >= offsetPrev - _offsetCur) { _peek.offsetRead -= (offsetPrev - _offsetCur); return true; } delete[] _peek.buff; _peek.buff = nullptr; _peek.bytes = 0; _peek.offsetRead = 0; if (seekMode == SeekSet) return DoSeek(sig, offset, offsetPrev, SeekSet); offset -= static_cast<long>(bytesPeeked); return DoSeek(sig, offset, offsetPrev, SeekCur); } else { if (_peek.offsetRead + _offsetCur - offsetPrev <= _peek.bytes) { _peek.offsetRead += _offsetCur - offsetPrev; return true; } size_t bytesTrail = _peek.bytes - _peek.offsetRead; delete[] _peek.buff; _peek.buff = nullptr; _peek.bytes = 0; _peek.offsetRead = 0; if (seekMode == SeekSet) return DoSeek(sig, offset, offsetPrev, SeekSet); offset -= static_cast<long>(bytesTrail); return DoSeek(sig, offset, offsetPrev, SeekCur); } }
bool wxScreenDC::StartDrawingOnTop( wxRect *rectIn ) { // VZ: should we do the same thing that wxMotif wxScreenDC does here? #if 0 wxRect rect; if ( rectIn ) { rect = *rectIn; } else { rect.x = rect.y = 0; DoGetSize(&rect.width, &rect.height); } #endif // 0 return TRUE; }
void HexEditorCtrl::OnMouseRight( wxMouseEvent& event ){ if(event.GetEventObject() == hex_ctrl) LastRightClickAt = hex_ctrl->PixelCoordToInternalPosition( event.GetPosition() )/2; else if(event.GetEventObject() == text_ctrl) LastRightClickAt = text_ctrl->PixelCoordToInternalPosition( event.GetPosition() ); else if( event.GetEventObject() == offset_ctrl) { //m_static_offset->SetLabel( offset_ctrl->hex_offset==true ? _("Offset: DEC") : _("Offset: HEX")); //event.Skip(true); offset_ctrl->OnMouseRight( event ); int x,y; DoGetSize(&x,&y); wxSizeEvent mevent(wxSize(x,y)); OnResize(mevent); return;//to avoid ShowContextMenu } else std::cout << "Right click captured without ctrl!\n"; ShowContextMenu( event ); }
void wxGTKDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { wxASSERT_MSG( width >= 0 && height >= 0, "Clipping box size values cannot be negative" ); wxRect newRegion(x, y, width, height); wxRect clipRegion; if ( m_clipping ) { // New clipping box is an intersection // of required clipping box and the current one. wxRect curRegion(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1); clipRegion = curRegion.Intersect(newRegion); } else { // Effective clipping box is an intersection // of required clipping box and DC surface. int dcWidth, dcHeight; DoGetSize(&dcWidth, &dcHeight); wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0), DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight)); clipRegion = dcRect.Intersect(newRegion); m_clipping = true; } if ( clipRegion.IsEmpty() ) { m_clipX1 = m_clipY1 = m_clipX2 = m_clipY2 = 0; } else { m_clipX1 = clipRegion.GetLeftTop().x; m_clipY1 = clipRegion.GetLeftTop().y; m_clipX2 = clipRegion.GetBottomRight().x + 1; m_clipY2 = clipRegion.GetBottomRight().y + 1; } }
void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion ®ion ) { // region is in device coordinates wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") ); // Convert device coordinates to logical coordinates // for all region components. wxRegion logRegion; if ( region.IsEmpty() ) { // Empty region is skipped by iterator // so we have to copy it directly. logRegion = region; } else { wxRegionIterator ri(region); while (ri) { logRegion.Union(DeviceToLogicalX(ri.GetX()), DeviceToLogicalY(ri.GetY()), DeviceToLogicalXRel(ri.GetWidth()), DeviceToLogicalYRel(ri.GetHeight())); ++ri; } } m_graphicContext->Clip(logRegion); wxRect newRegion = logRegion.GetBox(); wxRect clipRegion; if ( m_clipping ) { // New clipping box is an intersection // of required clipping box and the current one. wxRect curRegion(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1); clipRegion = curRegion.Intersect(newRegion); } else { // Effective clipping box is an intersection // of required clipping box and DC surface. int dcWidth, dcHeight; DoGetSize(&dcWidth, &dcHeight); wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0), DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight)); clipRegion = dcRect.Intersect(newRegion); m_clipping = true; } if ( clipRegion.IsEmpty() ) { m_clipX1 = m_clipY1 = m_clipX2 = m_clipY2 = 0; } else { m_clipX1 = clipRegion.GetLeft(); m_clipY1 = clipRegion.GetTop(); m_clipX2 = clipRegion.GetRight() + 1; m_clipY2 = clipRegion.GetBottom() + 1; } }
// Get size *available for subwindows* i.e. excluding menu bar etc. void wxWindowDFB::DoGetClientSize(int *x, int *y) const { DoGetSize(x, y); }
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int heightOrig = height; // the height which we must pass to Windows should be the total height of // the control including the drop down list while the height given to us // is, of course, just the height of the permanently visible part of it if ( height != wxDefaultCoord ) { // don't make the drop down list too tall, arbitrarily limit it to 40 // items max and also don't leave it empty size_t nItems = GetCount(); if ( !nItems ) nItems = 9; else if ( nItems > 24 ) nItems = 24; // add space for the drop down list const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); height += hItem*(nItems + 1); } else { // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses // wxGetWindowRect() to determine the current height of the combobox, // and then again sets the combobox's height to that value. Unfortunately, // wxGetWindowRect doesn't include the dropdown list's height (at least // on Win2K), so this would result in a combobox with dropdown height of // 1 pixel. We have to determine the default height ourselves and call // wxControl with that value instead. int w, h; RECT r; DoGetSize(&w, &h); if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0) { height = h + r.bottom - r.top; } } wxControl::DoSetSize(x, y, width, height, sizeFlags); // If we're storing a pending size, make sure we store // the original size for reporting back to the app. if (m_pendingSize != wxDefaultSize) m_pendingSize = wxSize(width, heightOrig); // This solution works on XP, but causes choice/combobox lists to be // too short on W2K and earlier. #if 0 int widthCurrent, heightCurrent; DoGetSize(&widthCurrent, &heightCurrent); // the height which we must pass to Windows should be the total height of // the control including the drop down list while the height given to us // is, of course, just the height of the permanently visible part of it if ( height != wxDefaultCoord && height != heightCurrent ) { // don't make the drop down list too tall, arbitrarily limit it to 40 // items max and also don't leave it empty unsigned int nItems = GetCount(); if ( !nItems ) nItems = 9; else if ( nItems > 24 ) nItems = 24; // add space for the drop down list const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); height += hItem*(nItems + 1); } else // keep the same height as now { // normally wxWindow::DoSetSize() checks if we set the same size as the // window already has and does nothing in this case, but for us the // check fails as the size we pass to it includes the dropdown while // the size returned by our GetSize() does not, so test if the size // didn't really change ourselves here if ( width == wxDefaultCoord || width == widthCurrent ) { // size doesn't change, what about position? int xCurrent, yCurrent; DoGetPosition(&xCurrent, &yCurrent); const bool defMeansUnchanged = !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE); if ( ((x == wxDefaultCoord && defMeansUnchanged) || x == xCurrent) && ((y == wxDefaultCoord && defMeansUnchanged) || y == yCurrent) ) { // nothing changes, nothing to do return; } } // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses // wxGetWindowRect() to determine the current height of the combobox, // and then again sets the combobox's height to that value. Unfortunately, // wxGetWindowRect doesn't include the dropdown list's height (at least // on Win2K), so this would result in a combobox with dropdown height of // 1 pixel. We have to determine the default height ourselves and call // wxControl with that value instead. // // Also notice that sometimes CB_GETDROPPEDCONTROLRECT seems to return // wildly incorrect values (~32000) which looks like a bug in it, just // ignore them in this case RECT r; if ( ::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) && r.bottom < 30000 ) { height = heightCurrent + r.bottom - r.top; } } wxControl::DoSetSize(x, y, width, height, sizeFlags); #endif }
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { int heightOrig = height; // the height which we must pass to Windows should be the total height of // the control including the drop down list while the height given to us // is, of course, just the height of the permanently visible part of it if ( height != wxDefaultCoord ) { // don't make the drop down list too tall, arbitrarily limit it to 40 // items max and also don't leave it empty size_t nItems = GetCount(); if ( !nItems ) nItems = 9; else if ( nItems > 24 ) nItems = 24; // add space for the drop down list const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); height += hItem*(nItems + 1); } else { // We cannot pass wxDefaultCoord as height to wxControl. wxControl uses // wxGetWindowRect() to determine the current height of the combobox, // and then again sets the combobox's height to that value. Unfortunately, // wxGetWindowRect doesn't include the dropdown list's height (at least // on Win2K), so this would result in a combobox with dropdown height of // 1 pixel. We have to determine the default height ourselves and call // wxControl with that value instead. int w, h; RECT r; DoGetSize(&w, &h); if (::SendMessage(GetHwnd(), CB_GETDROPPEDCONTROLRECT, 0, (LPARAM) &r) != 0) { height = h + r.bottom - r.top; } } wxControl::DoSetSize(x, y, width, height, sizeFlags); // I'm commenting this out since the code appears to make choices // and comboxes too high when they have associated sizers. I'm sure this // is not the end of the story, which is why I'm leaving it #if'ed out for // now. JACS. #if 0 // if the height specified for the visible part of the control is // different from the current one, we need to change it separately // as it is not affected by normal WM_SETSIZE if ( height != wxDefaultCoord ) { const int delta = heightOrig - GetSize().y; if ( delta ) { int h = ::SendMessage(GetHwnd(), CB_GETITEMHEIGHT, (WPARAM)-1, 0); SendMessage(GetHwnd(), CB_SETITEMHEIGHT, (WPARAM)-1, h + delta); } } #else wxUnusedVar(heightOrig); #endif }
void wxMenuBar::DoGetClientSize(int *width, int *height) const { DoGetSize(width, height); }
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags) { const int heightBest = GetBestSize().y; // we need the real height below so get the current one if it's not given if ( height == wxDefaultCoord ) { // height not specified, use the same as before DoGetSize(NULL, &height); } else if ( height == heightBest ) { // we don't need to manually manage our height, let the system use the // default one m_heightOwn = wxDefaultCoord; } else // non-default height specified { // set our new own height but be careful not to make it too big: the // native control apparently stores it as a single byte and so setting // own height to 256 pixels results in default height being used (255 // is still ok) m_heightOwn = height; if ( m_heightOwn > UCHAR_MAX ) m_heightOwn = UCHAR_MAX; // nor too small: see MSWUpdateVisibleHeight() else if ( m_heightOwn < COMBO_HEIGHT_ADJ ) m_heightOwn = COMBO_HEIGHT_ADJ; } // the height which we must pass to Windows should be the total height of // the control including the drop down list while the height given to us // is, of course, just the height of the permanently visible part of it so // add the drop down height to it // don't make the drop down list too tall, arbitrarily limit it to 30 // items max and also don't make it too small if it's currently empty size_t nItems = GetCount(); if (!HasFlag(wxCB_SIMPLE)) { if ( !nItems ) nItems = 9; else if ( nItems > 30 ) nItems = 30; } const int hItem = SendMessage(GetHwnd(), CB_GETITEMHEIGHT, 0, 0); int heightWithItems = 0; if (!HasFlag(wxCB_SIMPLE)) heightWithItems = height + hItem*nItems; else heightWithItems = SetHeightSimpleComboBox(nItems); // do resize the native control wxControl::DoSetSize(x, y, width, heightWithItems, sizeFlags); // make the control itself of the requested height: notice that this // must be done after changing its size or it has no effect (apparently // the height is reset to default during the control layout) and that it's // useless to to do it when using the deferred sizing -- in this case it // will be done from MSWEndDeferWindowPos() #if wxUSE_DEFERRED_SIZING if ( m_pendingSize == wxDefaultSize ) { // not using deferred sizing, update it immediately MSWUpdateVisibleHeight(); } else // in the middle of deferred sizing { // we need to report the size of the visible part of the control back // in GetSize() and not height stored by DoSetSize() in m_pendingSize m_pendingSize = wxSize(width, height); } #else // !wxUSE_DEFERRED_SIZING // always update the visible height immediately MSWUpdateVisibleHeight(); #endif // wxUSE_DEFERRED_SIZING }