void VPAbstractNode::setupSlots() { int slotSize = VPAbstractNode::SlotSize; inputSlots.clear(); inputSlots.resize(myInCount); for (int i(0); i<myInCount; i++) { QPointF tRectCenter = slotOffset(i, IN); QRectF tRect(tRectCenter.x()-slotSize/2, tRectCenter.y()-slotSize/2, slotSize, slotSize); inputSlots[i] = new ConnectorType(tRect, tRectCenter, true, i, this); } outputSlots.clear(); outputSlots.resize(myOutCount); for (int i(0); i<myOutCount; i++) { QPointF tRectCenter = slotOffset(i, OUT); QRectF tRect(tRectCenter.x()-slotSize/2, tRectCenter.y()-slotSize/2, slotSize, slotSize); outputSlots[i] = new ConnectorType(tRect, tRectCenter, false, i, this); } }
void NotificationWidget::paintEvent(QPaintEvent *event) { QPainter painter(this); tm* dt = localtime(&timer); this->setWindowOpacity(0.75); painter.drawRect(this->geometry()); if(TopText != NULL){ QFont font("Helvetica",10); painter.setFont(font); int length = sizeof(TopText); QRect tRect(QPoint(35,20),QSize(length*40,20)); painter.drawText(tRect,(QString)TopText); } if(BottomText != NULL){ int length = sizeof(BottomText); QFont font("Times",8); painter.setFont(font); QRect tRect(QPoint(35,45),QSize(length*20,40)); painter.drawText(tRect,(QString)BottomText); } QString noteTime = QString::number(dt->tm_hour) + ":" + QString::number(dt->tm_min); QFont font("Times", 15); painter.setFont(font); QRect tRect(QPoint(110,55), QSize(noteTime.length()*20,20)); painter.drawText(tRect,noteTime); }
void CustomGrid::DrawColLabel( wxDC& dc, int col ) { //init dc font and colours dc.SetFont(m_labelFont); if(col == m_gParent->m_pIndex){ dc.SetBrush(wxBrush(m_greenColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_greenColour, 1)); }else { dc.SetBrush(wxBrush(m_labelBackgroundColour, wxBRUSHSTYLE_SOLID)); dc.SetPen(wxPen(m_labelBackgroundColour, 1)); } //draw retangle wxRect tRect( GetColLeft(col), 1, GetColWidth(col)-2, m_colLabelHeight -2); dc.DrawRectangle(tRect); //draw lines aroud label dc.SetPen(GetDefaultGridLinePen()); dc.DrawLine( GetColLeft(col) -1, 0, GetColRight(col), 0 ); if( col > -1 && (col == 0 || GetColLabelValue( col ).BeforeFirst('-') != GetColLabelValue( col - 1 ).BeforeFirst('-')) ) dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColLeft(col) -1, 0, GetColLeft(col) - 1, m_colLabelHeight); if( col == m_numCols - 1 ){ dc.SetPen(wxPen(*wxBLACK, 4)); dc.DrawLine( GetColRight(col), 0, GetColRight(col), m_colLabelHeight); } //then draw label dc.DrawLabel(GetColLabelValue(col), tRect, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL); }
void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) { Window::mousePressed(mouseEvent); const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); Item *item = 0; // Checks if any of the presses were in the equip boxes. for (int i = 0; i < mBoxesNumber; ++i) { item = mEquipment->getEquipment(i); gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y) && item) { setSelected(i); break; } } if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) { if (item) { /* Convert relative to the window coordinates to absolute screen * coordinates. */ const int mx = x + getX(); const int my = y + getY(); viewport->showPopup(this, mx, my, item, true, false); } } }
BOOL CObjDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; string pathStr = lpszPathName; m_Object = new CWavefrontObj(pathStr); CRect tRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT); CDC tDC; CBitmap *oldBitmap; // CRgn ClipRgn; CDC scrDC; scrDC.Attach(GetDC(GetDesktopWindow())); // ClipRgn.CreateRectRgn(tRect.left, tRect.top, tRect.right, tRect.bottom); tDC.CreateCompatibleDC(&scrDC); tDC.SetMapMode(scrDC.GetMapMode()); tDC.DPtoLP(&tRect); tDC.SetWindowExt(tRect.Size()); tDC.SetWindowOrg(tRect.left, tRect.top); tDC.LPtoDP(&tRect); tDC.SetViewportExt(tRect.Size()); tDC.SetViewportOrg(tRect.left, tRect.top); m_ThumbNail.CreateCompatibleBitmap(&scrDC, tRect.Width(), tRect.Height()); oldBitmap = tDC.SelectObject(&m_ThumbNail); tDC.FillSolidRect(tRect, RGB(0xff, 0xff, 0xff)); // create a thumbnail CObjView::RenderImage(&tDC, this, tRect); tDC.SelectObject(oldBitmap); m_FileName = lpszPathName; GetFileTitle(m_FileName, m_DisplayName.GetBuffer(_MAX_FNAME), _MAX_FNAME); m_DisplayName.ReleaseBuffer(); // made it this far so add to program list of objects gObjLoader->m_WavfObjects.push_back(m_Object); OBJECTSTRUCT os; os.name = &m_DisplayName; os.fileName = &m_FileName; os.thumbNail = &m_ThumbNail; os.pageIndex = &gObjLoader->m_PageIndex; os.rsrcIndex = &m_ObjectIndex; os.object = m_Object; gObjLoader->m_ProgramInfo->BroadcastMessage( AddObjectMessage, &os); return TRUE; }
// gives the intersection-point between two lines, returns true, if any // computes the crossing point between the (infinite) lines // defined by the endpoints of the DLines, then checks if it // lies within the two rectangles defined by the DLines endpoints bool DLine::intersection( const DLine &line, DPoint &inter, bool endpoints) const { double ix, iy; //do not return true if parallel edges are encountered if (slope() == line.slope()) return false; //two possible checks: // only check for overlap on endpoints if option parameter set, // compute crossing otherwise // or skip computation if endpoints overlap (can't have "real" crossing) // (currently implemented) //if (endpoints) { if (m_start == line.m_start || m_start == line.m_end) { inter = m_start; if (endpoints) return true; else return false; } if (m_end == line.m_start || m_end == line.m_end) { inter = m_end; if (endpoints) return true; else return false; } //}//if endpoints //if the edge is vertical, we cannot compute the slope if (isVertical()) ix = m_start.m_x; else if (line.isVertical()) ix = line.m_start.m_x; else ix = (line.yAbs() - yAbs())/(slope() - line.slope()); //set iy to the value of the infinite line at xvalue ix //use a non-vertical line (can't be both, otherwise they're parallel) if (isVertical()) iy = line.slope() * ix + line.yAbs(); else iy = slope() * ix + yAbs(); inter = DPoint(ix, iy); //the (infinite) lines cross point DRect tRect(line); DRect mRect(*this); return (tRect.contains(inter) && mRect.contains(inter)); }
const std::string EquipmentWindow::getSlotName(int x, int y) const { for (int i = 0; i < mBoxesNumber; ++i) { gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y)) return mEquipment->getSlotName(i); } return std::string(); }
Item *EquipmentWindow::getItem(int x, int y) const { for (int i = 0; i < mBoxesNumber; ++i) { gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); } return 0; }
void FreeSpaceWidget::paintEvent(QPaintEvent*) { QPainter p(this); p.setPen(palette().mid().color()); p.drawRect(0, 0, width() - 1, height() - 1); p.drawPixmap(2, height() / 2 - d->iconPix.height() / 2, d->iconPix, 0, 0, d->iconPix.width(), d->iconPix.height()); if (isValid()) { // We will compute the estimated % of space size used to download and process. unsigned long eUsedKb = d->dSizeKb + d->kBUsed; int peUsed = (int)(100.0 * ((double)eUsedKb / (double)d->kBSize)); int pClamp = (peUsed > 100) ? 100 : peUsed; QColor barcol = QColor(62, 255, 62); // Smooth Green. if (peUsed > 80) { barcol = QColor(240, 255, 62); // Smooth Yellow. } if (peUsed > 95) { barcol = QColor(255, 62, 62); // Smooth Red. } p.setBrush(barcol); p.setPen(palette().light().color()); QRect gRect(d->iconPix.height() + 3, 2, (int)(((double)width() - 3.0 - d->iconPix.width() - 2.0) * (pClamp / 100.0)), height() - 5); p.drawRect(gRect); QRect tRect(d->iconPix.height() + 3, 2, width() - 3 - d->iconPix.width() - 2, height() - 5); QString text = QString::fromUtf8("%1%").arg(peUsed); QFontMetrics fontMt = p.fontMetrics(); // QRect fontRect = fontMt.boundingRect(tRect.x(), tRect.y(), // tRect.width(), tRect.height(), 0, text); p.setPen(Qt::black); p.drawText(tRect, Qt::AlignCenter, text); } }
void FlatCheckbox::paintEvent(QPaintEvent *e) { QPainter p(this); p.setOpacity(_opacity); if (_st.bgColor != st::transparent) { p.fillRect(rect(), _st.bgColor->b); } if (!_text.isEmpty()) { p.setFont(_st.font->f); p.setRenderHint(QPainter::TextAntialiasing); p.setPen((_state & StateDisabled ? _st.disColor : _st.textColor)->p); QRect tRect(rect()); tRect.setTop(_st.textTop); tRect.setLeft(_st.textLeft); // p.drawText(_st.textLeft, _st.textTop + _st.font->ascent, _text); p.drawText(tRect, _text, QTextOption(style::al_topleft)); } if (_state & StateDisabled) { QRect sRect(_checked ? _st.chkDisImageRect : _st.disImageRect); p.drawPixmap(_st.imagePos, App::sprite(), sRect); } else if ((_checked && _st.chkImageRect == _st.chkOverImageRect) || (!_checked && _st.imageRect == _st.overImageRect)) { p.setOpacity(_opacity); QRect sRect(_checked ? _st.chkImageRect : _st.imageRect); p.drawPixmap(_st.imagePos, App::sprite(), sRect); } else { if (a_over.current() < 1) { QRect sRect(_checked ? _st.chkImageRect : _st.imageRect); p.drawPixmap(_st.imagePos, App::sprite(), sRect); } if (a_over.current() > 0) { p.setOpacity(_opacity * a_over.current()); QRect sRect(_checked ? _st.chkOverImageRect : _st.overImageRect); p.drawPixmap(_st.imagePos, App::sprite(), sRect); } } }
ossimRefPtr<ossimImageData> ossimImageSourceSequencer::getTile( ossim_int32 id, ossim_uint32 resLevel) { static const char* MODULE= "ossimImageSourceSequencer::getTile(id, resLevel)"; if(traceDebug()) { CLOG << "entering.."<<endl; } if(!theInputConnection) { if(traceDebug()) { CLOG << "No input connection so returing NULL" << endl; } return NULL; } // if we have no tiles try to initialize. if(getNumberOfTiles() == 0) { initialize(); } ossimIpt origin; if(getTileOrigin(id, origin)) { if(traceDebug()) { CLOG << "returning tile" << endl; } ossimIrect tRect(origin.x, origin.y, origin.x + theTileSize.x - 1, origin.y + theTileSize.y - 1); ossimRefPtr<ossimImageData> temp = theInputConnection->getTile(tRect, resLevel); theBlankTile->setImageRectangle(tRect); if(temp.valid()) { if(!temp->getBuf()) { return theBlankTile; } } else { return theBlankTile; } return temp; } else { if(traceDebug()) { CLOG << "was not able to get an origin for id = " << id << endl; } } if(traceDebug()) { CLOG << "leaving.."<<endl; } return 0; }
BOOL CTextureDoc::TargetOpenDocument(LPCTSTR lpszPathName, bool isOnlyForThumbnail) { CString message; if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; bool loadedTexture = false; CHashString hashName(lpszPathName); static DWORD msgHash_SetLoadParameters = CHashString(_T("SetLoadParameters")).GetUniqueID(); LOADPARAMETERS lp1; if (!isOnlyForThumbnail) { m_pTextureObject = CRenderObject<>::LoadTexture(lpszPathName); } else { TEXTUREOBJECTPARAMS top; top.Name = &hashName; static DWORD msgHash_GetTexture = CHashString(_T("GetTexture")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetTexture, sizeof(TEXTUREOBJECTPARAMS), &top); if (top.TextureObjectInterface == NULL) { static DWORD msgHash_GetLoadParameters = CHashString(_T("GetLoadParameters")).GetUniqueID(); m_ToolBox->SendMessage(msgHash_GetLoadParameters, sizeof(LOADPARAMETERS), &lp1); LOADPARAMETERS lp2(TEX_MEM_SYSMEM); m_ToolBox->SendMessage(msgHash_SetLoadParameters, sizeof(LOADPARAMETERS), &lp2); m_pTextureObject = CRenderObject<>::LoadTexture(lpszPathName); loadedTexture = true; } else { m_pTextureObject = top.TextureObjectInterface; } } if (loadedTexture) m_ToolBox->SendMessage(msgHash_SetLoadParameters, sizeof(LOADPARAMETERS), &lp1); CRect tRect(0, 0, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT); CDC tDC; CBitmap *oldBitmap; CRgn ClipRgn; CDC scrDC; scrDC.Attach(GetDC(GetDesktopWindow())); ClipRgn.CreateRectRgn(tRect.left, tRect.top, tRect.right, tRect.bottom); tDC.CreateCompatibleDC(&scrDC); tDC.SetMapMode(scrDC.GetMapMode()); tDC.DPtoLP(&tRect); tDC.SetWindowExt(tRect.Size()); tDC.SetWindowOrg(tRect.left, tRect.top); tDC.LPtoDP(&tRect); tDC.SetViewportExt(tRect.Size()); tDC.SetViewportOrg(tRect.left, tRect.top); m_ThumbNail.CreateCompatibleBitmap(&scrDC, tRect.Width(), tRect.Height()); oldBitmap = tDC.SelectObject(&m_ThumbNail); tDC.FillSolidRect(tRect, RGB(0xff, 0x00, 0x00)); // create a thumbnail CTextureView::RenderImage(&tDC, this, tRect); tDC.SelectObject(oldBitmap); if (m_pTextureObject != NULL) GetFileTitle(m_pTextureObject->GetTextureName()->GetString(), m_DisplayName.GetBuffer(_MAX_FNAME), _MAX_FNAME); if (loadedTexture) { static DWORD msgHash_RemoveTexture = CHashString(_T("RemoveTexture")).GetUniqueID(); TEXTUREOBJECTPARAMS top; top.Name = &hashName; top.TextureObjectInterface = m_pTextureObject; m_ToolBox->SendMessage(msgHash_RemoveTexture, sizeof(TEXTUREOBJECTPARAMS), &top); } m_DisplayName.ReleaseBuffer(); // made it this far so add to program list of objects //SINGLETONINSTANCE(CTextureEditor)->GetTextureDataList()->push_back(m_TextureObject); //OBJECTPAGEINFO objPageInfo; //objPageInfo.name = &m_DisplayName; //objPageInfo.thumbNail = &m_ThumbNail; //objPageInfo.pageIndex = SINGLETONINSTANCE(CTextureEditor)->m_PageIndex; //objPageInfo.rsrcIndex = m_ObjectIndex; //objPageInfo.object = m_TextureObject; //static DWORD msgHash_AddObjectMessage = CHashString(_T("AddObjectMessage")).GetUniqueID(); //m_ToolBox->SendMessage(msgHash_AddObjectMessage, sizeof(OBJECTPAGEINFO), &objPageInfo); return TRUE; }