void ButtonManage::ParseStrToBtn(std::wstring& buttoninformation) { std::wstring s; std::wstring classificationname; int pos; std::wstring bmpstr; int align1 = 0, align2 = 0; CRect rect1,rect2(0,0,0,0); BOOL bnotbutton,bhide; int id; int width = 0; std::wstring pbuttonname = L""; CSUIButton* pbutton = 0; BOOL baddalign = FALSE; while ((pos = buttoninformation.find_first_of(L",")) != std::wstring::npos) { classificationname = buttoninformation.substr(0, pos); buttoninformation = buttoninformation.substr(pos + 1); pos = buttoninformation.find_first_of(L";"); s = buttoninformation.substr(0, pos); switch (m_property_map[classificationname]) { case BMP: bmpstr = s; break; case FIXALIGN: align1 = m_property_map[s]; break; case FIXCRECT: rect1 = GetCRect(s); break; case NOTBUTTON: if (buttoninformation[0] == 'T') bnotbutton = TRUE; if (buttoninformation[0] == 'F') bnotbutton = FALSE; break; case ID: id = _wtoi(s.c_str()); break; case HIDE: if (buttoninformation[0] == 'T') bhide = TRUE; if (buttoninformation[0] == 'F') bhide = FALSE; break; case HIDEWIDTH: if (s == L"MAXINT") width = MAXINT; else width = _wtoi(s.c_str()); break; case RELATIVEALIGN: align2 = m_property_map[s]; break; case BUTTON: pbuttonname = s; pbutton = GetButton(pbuttonname); break; case RELATIVECRECT: rect2 = GetCRect(s); break; case ADDALIGN: baddalign = TRUE; break; } if (baddalign) break; buttoninformation = buttoninformation.substr(pos + 1); } CSUIButton* newbtn = 0; buttonattribute btnstructtmp = {align1, rect1, bhide, width}; if (align2 != 0 && pbutton != 0 && rect2 != CRect(0,0,0,0)) { relativebuttonattribute rtbtnstructtmp = {align2, pbutton, rect2}; btnstructtmp.relativevec.push_back(rtbtnstructtmp); } if (!m_bnotinitialize) newbtn = new CSUIButton(bmpstr.c_str(), align1, rect1, bnotbutton, id, bhide,align2, pbutton, rect2,width,m_buttonname.c_str()); else m_btnstruct = btnstructtmp; if (baddalign) ParseStrToBtnAddalign(buttoninformation, newbtn); if (!m_bnotinitialize) m_pbtnlist->AddTail(newbtn); m_attribute_map[m_buttonname] = m_btnstruct; }
int Events::handleOneShot(Event *event) { Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: { TextListEntry entry = *((TextListEntry *)event->data); _vm->_scene->_textList.remove(entry); } break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface = _vm->_render->getBackGroundSurface(); BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayInfo().width || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; #ifdef ENABLE_IHNM if (_vm->getGameId() == GID_IHNM) { PalEntry portraitBgColor = _vm->_interface->_portraitBgColor; byte portraitColor = (_vm->getLanguage() == Common::ES_ESP) ? 253 : 254; // Set the portrait bg color, in case a saved state is restored from the // launcher. In this case, sfSetPortraitBgColor is not called, thus the // portrait color will always be 0 (black). if (portraitBgColor.red == 0 && portraitBgColor.green == 0 && portraitBgColor.blue == 0) portraitBgColor.green = 255; if (_vm->_spiritualBarometer > 255) _vm->_gfx->setPaletteColor(portraitColor, 0xff, 0xff, 0xff); else _vm->_gfx->setPaletteColor(portraitColor, _vm->_spiritualBarometer * portraitBgColor.red / 256, _vm->_spiritualBarometer * portraitBgColor.green / 256, _vm->_spiritualBarometer * portraitBgColor.blue / 256); } #endif _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } _vm->_render->clearFlag(RF_DISABLE_ACTORS); } break; case kPsychicProfileBgEvent: { ResourceContext *context = _vm->_resource->getContext(GAME_RESOURCEFILE); ByteArray resourceData; _vm->_resource->loadResource(context, _vm->getResourceDescription()->psychicProfileResourceId, resourceData); ByteArray image; int width; int height; _vm->decodeBGImage(resourceData, image, &width, &height); const PalEntry *palette = (const PalEntry *)_vm->getImagePal(resourceData); const Rect profileRect(width, height); _vm->_render->getBackGroundSurface()->blit(profileRect, image.getBuffer()); _vm->_render->addDirtyRect(profileRect); _vm->_frameCount++; _vm->_gfx->setPalette(palette); // Draw the scene. It won't be drawn by Render::drawScene(), as a placard is up _vm->_scene->draw(); } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; case kEventResumeAll: _vm->_anim->resumeAll(); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventDraw: { BGInfo bgInfo; _vm->_scene->getBGInfo(bgInfo); _vm->_render->getBackGroundSurface()->blit(bgInfo.bounds, bgInfo.buffer); _vm->_render->addDirtyRect(bgInfo.bounds); _vm->_scene->draw(); } break; case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; case kEventRestoreMode: _vm->_interface->restoreMode(); break; case kEventSetMode: _vm->_interface->setMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: { debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); ScriptThread &sthread = _vm->_script->createThread(event->param, event->param2); sthread._threadVars[kThreadVarAction] = event->param3; sthread._threadVars[kThreadVarObject] = event->param4; sthread._threadVars[kThreadVarWithObject] = event->param5; sthread._threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; } case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; case kEventSetNormalCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorNormal); break; case kEventSetBusyCursor: // in ITE and IHNM demo there is just one cursor // ITE never makes this call if (!_vm->isIHNMDemo()) _vm->_gfx->setCursor(kCursorBusy); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; _vm->_gfx->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } #ifdef ENABLE_IHNM case kCutawayEvent: switch (event->op) { case kEventClear: _vm->_anim->clearCutaway(); break; case kEventShowCutawayBg: _vm->_anim->showCutawayBg(event->param); break; default: break; } #endif case kActorEvent: switch (event->op) { case kEventMove: // TODO (check Actor::direct) break; default: break; } default: break; } return kEvStDelete; }
void BoardDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { // Проверки if (!index.isValid()) return; int row = index.row(); if (row <= 0 || row >= model_->rowCount() - 1) return; int col = index.column(); if (col <= 0 || col >= model_->columnCount() - 1) return; painter->save(); QRectF rect(option.rect); // Отрисовка фона if (skin == 0) { QBrush fill_brush(QColor(220, 179, 92, 255), Qt::SolidPattern); painter->fillRect(rect, fill_brush); } else { QPixmap *pixmap = pixmaps->getBoardPixmap(col - 1, row - 1, rect.width(), rect.height()); painter->drawPixmap(rect, *pixmap, pixmap->rect()); } QBrush brush1(Qt::SolidPattern); int row_min = 2; int row_max = model_->rowCount() - 3; int col_min = 2; int col_max = model_->columnCount() - 3; if (row >= row_min && row <= row_max && col >= col_min && col <= col_max) { // Отрисовка центральных линий qreal x = rect.left() + rect.width() / 2.0; qreal y = rect.top() + rect.height() / 2.0; painter->setPen(Qt::darkGray); painter->drawLine(rect.left(), y - 1, rect.right(), y - 1); painter->drawLine(x - 1, rect.top(), x - 1, rect.bottom()); painter->setPen(Qt::lightGray); painter->drawLine(rect.left(), y, rect.right(), y); painter->drawLine(x, rect.top(), x, rect.bottom()); // Отрисовка разделителя if (row == row_min || col == col_min || row == row_max || col == col_max) { painter->setPen(Qt::black); if (row == row_min) { painter->drawLine(rect.topLeft(), rect.topRight()); } else if (row == row_max) { QPointF p1 = rect.bottomLeft(); p1.setY(p1.y() - 1.0); QPointF p2 = rect.bottomRight(); p2.setY(p2.y() - 1.0); painter->drawLine(p1, p2); } if (col == col_min) { painter->drawLine(rect.topLeft(), rect.bottomLeft()); } else if (col == col_max) { QPointF p1 = rect.topRight(); p1.setX(p1.x() - 1); QPointF p2 = rect.bottomRight(); p2.setX(p2.x() - 1); painter->drawLine(p1, p2); } } if (model_->selectX == col && model_->selectY == row) { brush1.setColor(QColor(0, 255, 0, 64)); painter->fillRect(rect, brush1); } // Отрисовка если курсор мыши над клеткой if (option.state & QStyle::State_MouseOver) { brush1.setColor(QColor(0, 0, 0, 32)); painter->fillRect(rect, brush1); } rect.setWidth(rect.width() - 1); rect.setHeight(rect.height() - 1); // Отрисовка если клетка выбрана if (option.state & QStyle::State_Selected) { QRectF rect2(rect); rect2.setLeft(rect2.left() + 1); rect2.setTop(rect2.top() + 1); rect2.setWidth(rect2.width() - 1); rect2.setHeight(rect2.height() - 1); painter->setPen(Qt::gray); painter->drawRect(rect2); } // Отрисовка элемента const GameElement *el = model_->getGameElement(col, row); if (el) { el->paint(painter, rect); } } else { // Рисуем координаты if ((row == 1 || row == model_->columnCount() - 2) && col >= 2 && col <= model_->columnCount() - 3) { // Буквы QString text = horHeaderString.at(col - 2); painter->drawText(rect, Qt::AlignCenter,text, 0); } else if ((col == 1 || model_->rowCount() - 2) && row >= 2 && row <= model_->rowCount() - 3) { // Цифры QString text = QString::number(row - 1); painter->drawText(rect, Qt::AlignCenter,text, 0); } } painter->restore(); }
void CSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct != NULL); CDC *pDC, dcmem, dcSkin; CBitmap bmpMem, *pOldbmpMem, *pOldbmpSkin; CString str, str2, strSkinPath, strFile; CRect rect, rect2(0,0,1,1); UINT nState, nXStart, nSpriteYStart, nDownDecal; register int i; if (bIni) { bIni = FALSE; // Donne caption GetWindowText(m_strCaption.GetBuffer(20), 20); // Charge le skin / options if (m_strCaption == "ICQ Clan") str = "ButtonICQClanImages"; else if (m_strCaption == "Add clan") str = "ButtonAdduserImages"; else if (m_strCaption == "System") str = "ButtonSysmessageImages"; else if (m_strCaption == "x") str = "ButtonCloseImages"; strSkinPath = AfxGetApp()->GetProfileString("Options", "Skin", ""); strFile.ReleaseBuffer( ::GetPrivateProfileString("Buttons", str, "", strFile.GetBuffer(255), 255, strSkinPath+"Skin.ini") ); pBmpSkin = NULL; if (strFile != "") { HBITMAP hBitmap = NULL; hBitmap = (HBITMAP)LoadImage(NULL, strSkinPath+strFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); pBmpSkin = new CBitmap; if (hBitmap == NULL || pBmpSkin->Attach(hBitmap) == 0) { delete pBmpSkin; pBmpSkin = NULL; } } // Add if (m_strCaption == "Add clan") str = "Adduser"; // Sys else if (m_strCaption == "System") str = "Sysmessage"; if (m_strCaption == "Add clan" || m_strCaption == "System") { nButtonWidth1 = ::GetPrivateProfileInt("Buttons", "Button"+str+"LeftFixWidth", 4, strSkinPath+"skin.ini"); nButtonWidth2 = ::GetPrivateProfileInt("Buttons", "Button"+str+"MidleWidth", 45, strSkinPath+"skin.ini"); str2.ReleaseBuffer( ::GetPrivateProfileString("Buttons", "Button"+str+"MidleMode", "Stretch", str2.GetBuffer(20), 20, strSkinPath+"skin.ini") ); str2.MakeUpper(); nButtonWidth2Mode = str2 == "STRETCH" ? 0 : 1; nButtonWidth3 = ::GetPrivateProfileInt("Buttons", "Button"+str+"RightFixWidth", 4, strSkinPath+"skin.ini"); nButtonSpriteWidth = ::GetPrivateProfileInt("Buttons", "Button"+str+"SpriteWidth", 99, strSkinPath+"skin.ini"); } } if (pBmpSkin == NULL) { SetButtonStyle( GetButtonStyle() & ~BS_OWNERDRAW, TRUE); return; } GetWindowRect(rect); nState = lpDrawItemStruct->itemState; pDC = CDC::FromHandle(lpDrawItemStruct->hDC); // Créé un dc mem dcmem.CreateCompatibleDC(pDC); bmpMem.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()); pOldbmpMem = dcmem.SelectObject(&bmpMem); // Créé un dc mem avec le skin dcSkin.CreateCompatibleDC(pDC); pOldbmpSkin = dcSkin.SelectObject(pBmpSkin); // Place le skin ds le dcmem (1/2) // ICQ Clan if (m_strCaption == "ICQ Clan") { // Selon l'état if (nState & ODS_SELECTED) // Down nXStart = BTC_ICQ_X + 2*BTC_ICQ_WIDTH; else if (nState & ODS_FOCUS) // Focus nXStart = BTC_ICQ_X + BTC_ICQ_WIDTH; else // Normal nXStart = BTC_ICQ_X; dcmem.BitBlt(0,0, BTC_ICQ_WIDTH, BTC_ICQ_HEIGHT, &dcSkin, nXStart+BTC_ICQ_X, BTC_ICQ_Y, SRCCOPY); } // Add / Sys else if (m_strCaption == "Add clan" || m_strCaption == "System") { // Selon l'état if (nState & ODS_SELECTED) // Down { nXStart = BTC_X + 2*BTC_WIDTH; nSpriteYStart = BTC_SPRITE_Y + 2*BTC_SPRITE_HEIGHT; } else if (nState & ODS_FOCUS) // Focus { nXStart = BTC_X + BTC_WIDTH; nSpriteYStart = BTC_SPRITE_Y + BTC_SPRITE_HEIGHT; } else if (nState & ODS_DISABLED) // Disabled { nXStart = BTC_X + 3*BTC_WIDTH; nSpriteYStart = BTC_SPRITE_Y + 3*BTC_SPRITE_HEIGHT; } else // Normal { nXStart = BTC_X; nSpriteYStart = BTC_SPRITE_Y; } // En mode répété ou étiré if (nButtonWidth2Mode == 0) dcmem.StretchBlt(BTC_WIDTH1,0, rect.Width()-BTC_WIDTH1-BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1, BTC_Y, BTC_WIDTH2, BTC_HEIGHT, SRCCOPY); else for (i=BTC_WIDTH1; i<rect.Width()-BTC_WIDTH1-BTC_WIDTH3; i+=BTC_WIDTH2) dcmem.BitBlt(i,0, rect.Width()-BTC_WIDTH1-BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1, BTC_Y, SRCCOPY); } // Close else if (m_strCaption == "x") { // Selon l'état if (nState & ODS_SELECTED) // Down nXStart = 2*BTC_X_WIDTH; else if (nState & ODS_FOCUS) // Focus nXStart = BTC_X_WIDTH; else // Normal nXStart = 0; dcmem.BitBlt(0, 0, BTC_X_WIDTH, BTC_X_HEIGHT, &dcSkin, nXStart, 0, SRCCOPY); } // Place le sprite if (m_strCaption == "Add clan" || m_strCaption == "System") { // Down ? if (nState & ODS_SELECTED) nDownDecal=1; else nDownDecal=0; GetWindowText(str); // Txt à afficher // Prépare l'affichage rect2 = CRect(BTC_WIDTH1, 0, rect.Width()-BTC_WIDTH3, rect.Height()); // Zone de texte // Applique l'image en tenant compte de la couche alpha dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCPAINT); dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCINVERT); dcSkin.BitBlt(BTC_SPRITE_X, nSpriteYStart, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_A_X, nSpriteYStart, SRCAND); dcmem.BitBlt(rect.Width()/2-BTC_SPRITE_WIDTH/2+nDownDecal, nDownDecal, BTC_SPRITE_WIDTH, BTC_SPRITE_HEIGHT, &dcSkin, BTC_SPRITE_X, nSpriteYStart, SRCPAINT); } // Place le skin ds le dcmem (2/2) // Add / Sys if (m_strCaption == "Add clan" || m_strCaption == "System") { dcmem.BitBlt(0,0, BTC_WIDTH1, BTC_HEIGHT, &dcSkin, nXStart+BTC_X, BTC_Y, SRCCOPY); dcmem.BitBlt(rect.Width()-BTC_WIDTH3,0, BTC_WIDTH3, BTC_HEIGHT, &dcSkin, nXStart+BTC_X+BTC_WIDTH1+BTC_WIDTH2, 0, SRCCOPY); } // Affiche à l'écran pDC->BitBlt(0,0, rect.Width(), rect.Height(), &dcmem, 0,0, SRCCOPY); // Clear la memoire dcmem.SelectObject(pOldbmpMem); dcmem.DeleteDC(); dcSkin.SelectObject(pOldbmpSkin); dcSkin.DeleteDC(); }
void CDigitalStatusPrinter::PrintSinglTable(QPainter*p) { int textWidth = p->window().width(); int textHeight = p->window().height(); QFontMetrics metics(m_font); QString strXuhao = QString("序号"); QString strDesc = QString("描述");// : 实际值"); QString strMaohao = QString(":"); QString strActual = QString("实际值"); int nDescWidth = metics.width(strDesc); int nDescHeight = metics.height(); printf("nDescHeight=%d\n",nDescHeight); DigitalStatusList SettingLst = m_pComTrade->GetDigitalStatusList(); /*m_nCurrentY*/ int nActualWidth = textWidth-m_nLeftMargin-m_nRightMargin; int nActualHeight = textHeight-m_nCurrentY-m_nBottomMargin; int nTableCoumn = nActualHeight/(nDescHeight+minStep)-1; m_nTableColum = nTableCoumn; nActualHeight = (nTableCoumn+1)*(nDescHeight+minStep); p->drawLine(m_nLeftMargin,m_nCurrentY,textWidth-m_nRightMargin,m_nCurrentY); p->drawLine(m_nLeftMargin,m_nCurrentY,m_nLeftMargin,nActualHeight+m_nCurrentY); p->drawLine(nActualWidth/2+m_nLeftMargin,m_nCurrentY,nActualWidth/2+m_nLeftMargin, nActualHeight+m_nCurrentY); //下限不要了 p->drawLine(m_nLeftMargin,nActualHeight+m_nCurrentY,m_nLeftMargin+nActualWidth,nActualHeight+m_nCurrentY); int nTitleWidth = metics.width(strXuhao); int nTitleHeight = metics.height(); int nMaohaoWidth = metics.width(strMaohao); p->drawLine(nTitleWidth+minStep+m_nLeftMargin,m_nCurrentY,nTitleWidth+minStep+m_nLeftMargin,nActualHeight+m_nCurrentY/*textHeight*/); p->drawLine(nActualWidth+m_nLeftMargin,m_nCurrentY,nActualWidth+m_nLeftMargin,nActualHeight+m_nCurrentY/*textHeight*/); QRectF rect(m_nLeftMargin+minStep,m_nCurrentY+minStep,minStep+nTitleWidth,minStep+nTitleHeight); p->drawText(rect,strXuhao); QRectF rect2(minStep+nActualWidth/2+m_nLeftMargin,m_nCurrentY+minStep,minStep+nTitleWidth, minStep+nTitleHeight); p->drawText(rect2,strXuhao); p->drawLine(3*minStep+nActualWidth/2+m_nLeftMargin+nTitleWidth,m_nCurrentY, 3*minStep+nActualWidth/2+m_nLeftMargin+nTitleWidth,nActualHeight+m_nCurrentY/*textHeight*/); QRectF rect3(2*minStep+nTitleWidth+m_nLeftMargin,m_nCurrentY+minStep,nDescWidth,nTitleHeight); p->drawText(rect3,strDesc); QRectF rect4(4*minStep+nActualWidth/2+nTitleWidth+m_nLeftMargin,m_nCurrentY+minStep, nDescWidth,nTitleHeight); p->drawText(rect4,strDesc); QRectF rectMao1(3*nActualWidth/8+m_nLeftMargin,m_nCurrentY+minStep, nMaohaoWidth+minStep,nTitleHeight); p->drawText(rectMao1,strMaohao); QRectF rectMao2(7*nActualWidth/8+m_nLeftMargin,m_nCurrentY+minStep, nMaohaoWidth+minStep,nTitleHeight); p->drawText(rectMao2,strMaohao); int nActualWid = metics.width(strActual); QRectF rectActual1(m_nLeftMargin+nActualWidth/2-minStep-nActualWid,m_nCurrentY+minStep, nActualWid,nTitleHeight); p->drawText(rectActual1,strActual); QRectF rectActual2(m_nLeftMargin+nActualWidth-minStep-nActualWid,m_nCurrentY+minStep, nActualWid,nTitleHeight); p->drawText(rectActual2,strActual); m_nCurrentY = m_nCurrentY+2*minStep+nTitleHeight; for(int nIndex=0;nIndex<m_nTableColum*2;nIndex++) { //int SettingNum = nIndex+nPageIndex*m_nTableColum*2; if(m_nCurrentIndex>=SettingLst.count()) { return; } CDigitalStatus settingValue = SettingLst.at(m_nCurrentIndex); QString strNumber = QString::number(m_nCurrentIndex+1/*nIndex+1*/); //int nY =m_nCurrentY+nIndex*(minStep+nDescHeight); QString strDesc = settingValue.m_strName; QString strValue = QString::number(settingValue.m_nValue)+QString(" "); //左边 if(nIndex<m_nTableColum) { QRectF rectNum(m_nLeftMargin+minStep,m_nCurrentY+nIndex*(minStep+nDescHeight), minStep+nTitleWidth,nTitleHeight); p->drawText(rectNum,strNumber); int nDescWid = metics.width(strDesc); QRectF rectDesc(2*minStep+nTitleWidth+m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), nDescWid, nDescHeight); p->drawText(rectDesc,strDesc); QRectF rectMao(3*nActualWidth/8+m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), nMaohaoWidth,nDescHeight); //p->drawText(rectMao,strMaohao); //计算冒号的位置 int nValueWidth = metics.width(strValue); int nStartPoint = nActualWidth/2-nValueWidth+m_nLeftMargin-minStep; QRectF rectValue(nStartPoint,m_nCurrentY+nIndex*(minStep+nDescHeight), nValueWidth,nDescHeight); p->drawText(rectValue,strValue); //如果值太长了,那就不要冒号了 if(!rectValue.contains(rectMao)) { p->drawText(rectMao,strMaohao); } p->drawLine(m_nLeftMargin,m_nCurrentY+nIndex*(minStep+nDescHeight), m_nLeftMargin+nActualWidth,m_nCurrentY+nIndex*(minStep+nDescHeight)); } //右边 else if(nIndex<m_nTableColum*2&&nIndex>=m_nTableColum) { QRectF rectNum(minStep*2+nActualWidth/2+m_nLeftMargin,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nTitleWidth,nTitleHeight); p->drawText(rectNum,strNumber); int nDescWid = metics.width(strDesc); QRectF rectDesc(4*minStep+nTitleWidth+nActualWidth/2+m_nLeftMargin, m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nDescWid, nDescHeight); //QRectF rectDesc(4*minStep+nTitleWidth+textWidth/2,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), // 2*minStep+nTitleWidth+5*textWidth/8,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight)+nDescHeight); p->drawText(rectDesc,strDesc); QRectF rectMao(7*nActualWidth/8+m_nLeftMargin,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nMaohaoWidth,nDescHeight); //p->drawText(rectMao,strMaohao); int nValueWidth = metics.width(strValue); int nStartPoint = m_nLeftMargin+nActualWidth-nValueWidth-minStep; QRectF rectValue(nStartPoint,m_nCurrentY+(nIndex-m_nTableColum)*(minStep+nDescHeight), nValueWidth,nDescHeight); p->drawText(rectValue,strValue); //如果值太长了,那就不要冒号了 if(!rectValue.contains(rectMao)) { p->drawText(rectMao,strMaohao); } } m_nCurrentIndex++; } //continue print on new page if(m_nCurrentIndex<SettingLst.count()) { m_nCurrentY = m_nTopMargin; m_pPrinter->newPage(); PrintSinglTable(p); } }
BOOL CTestOutlineTextDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // Initialize the scroll view CRect rect; GetClientRect(&rect); CClientDC dc(this); int PosY = 190*dc.GetDeviceCaps(LOGPIXELSY)/96; int nMargin = 7*dc.GetDeviceCaps(LOGPIXELSY)/96; CRect rect2(nMargin,PosY,rect.Width()-nMargin*2,rect.Height()-nMargin-PosY); CRuntimeClass *pClass = RUNTIME_CLASS(CMyScrollView); m_pScrollView = (CMyScrollView*)pClass->CreateObject(); m_pScrollView->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect2, this, 10001); m_pScrollView->ModifyStyleEx(0, WS_EX_CLIENTEDGE); m_pScrollView->OnInitialUpdate(); m_pScrollView->SetWindowPos( &m_staticShadowColor, nMargin,PosY, rect.Width()-nMargin*2, rect.Height()-nMargin-PosY, SWP_SHOWWINDOW); m_pScrollView->Render(false); // Initialize buttons COLORREF color= RGB(64,0,64); m_btnOutlineColor1.SetColor(color); m_pScrollView->SetOutlineColor1(Gdiplus::Color(GetRValue(color),GetGValue(color),GetBValue(color))); COLORREF color2= RGB(255,128,255); m_btnOutlineColor2.SetColor(color2); m_pScrollView->SetOutlineColor2(Gdiplus::Color(GetRValue(color2),GetGValue(color2),GetBValue(color2))); COLORREF colorText= RGB(255, 128, 64); m_btnTextColor.SetColor(colorText); m_pScrollView->SetTextColor1(Gdiplus::Color(GetRValue(colorText),GetGValue(colorText),GetBValue(colorText))); COLORREF colorText2= RGB(255,0,0); m_btnTextColor2.SetColor(colorText2); m_pScrollView->SetTextColor2(Gdiplus::Color(GetRValue(colorText2),GetGValue(colorText2),GetBValue(colorText2))); m_chkGradientText.SetCheck(1); m_pScrollView->EnableTextGradient(true); // initialize combo. m_cboTextEffect.AddString(_T("Single Outline")); m_cboTextEffect.AddString(_T("Double Outline")); m_cboTextEffect.AddString(_T("Text Glow")); m_cboTextEffect.AddString(_T("Gradient Outline")); m_cboTextEffect.AddString(_T("Just Outline")); m_cboTextEffect.AddString(_T("No Outline")); m_cboTextEffect.AddString(_T("Double Text Glow")); m_cboTextEffect.SetCurSel(3); m_pScrollView->SetTextEffect(GradOutline); EnableOutline2UI(TRUE, TRUE); m_cboTextPath.AddString(_T("GDI+")); m_cboTextPath.AddString(_T("GDI")); m_cboTextPath.SetCurSel(0); m_pScrollView->SetTextPath(GdiPlus); m_edtAngle.EnableWindow(FALSE); m_staticAngle.EnableWindow(FALSE); // Set the font //LOGFONT lf; memset(&m_lf, 0, sizeof(m_lf)); m_lf.lfHeight = -48; //-MulDiv(48, dc.GetDeviceCaps(LOGPIXELSY), 72); m_lf.lfWeight = FW_NORMAL; //m_lf.lfItalic = TRUE; //m_lf.lfOrientation = 100; //m_lf.lfEscapement = 100; //m_lf.lfOutPrecision = OUT_TT_ONLY_PRECIS; m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS; m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; m_lf.lfQuality = PROOF_QUALITY; wcscpy_s(m_lf.lfFaceName, _T("Arial Black")); m_edtFont.SetWindowText(_T("Arial Black, 36 Regular")); m_pScrollView->SetLogFont(&m_lf); m_pScrollView->SetFontSize(48); // Set the Text CString str = _T("TEXT DESIGNER"); m_edtText.SetWindowText(str); m_pScrollView->SetText(str); // Set the Alphas m_edtOutlineAlpha1.SetWindowText(_T("255")); m_pScrollView->SetOutlineAlpha1(255); m_edtOutlineAlpha2.SetWindowText(_T("255")); m_pScrollView->SetOutlineAlpha2(255); // Set the Thickness m_edtThickness1.SetWindowText(_T("5")); m_pScrollView->SetOutlineThickness1(5); m_edtThickness2.SetWindowText(_T("5")); m_pScrollView->SetOutlineThickness2(5); // Set Text Position m_edtPosX.SetWindowText(_T("10")); m_pScrollView->SetTextPosX(10); m_edtPosY.SetWindowText(_T("10")); m_pScrollView->SetTextPosY(10); m_edtAngle.SetWindowText(_T("0")); m_pScrollView->SetTextAngle(0); // Set Shadow Properties m_chkEnableShadow.SetCheck(1); //m_pScrollView->SetEnableShadow(true); OnBnClickedChkEnableShadow(); m_edtShadowAlpha.SetWindowText(_T("128")); m_pScrollView->SetShadowAlpha(128); m_edtShadowOffsetX.SetWindowText(_T("4")); m_pScrollView->SetShadowOffsetX(4); m_edtShadowOffsetY.SetWindowText(_T("4")); m_pScrollView->SetShadowOffsetY(4); m_btnShadowColor.SetColor(RGB(0,0,0)); m_pScrollView->SetShadowColor(Gdiplus::Color(0,0,0)); m_edtShadowThickness.SetWindowText(_T("8")); m_pScrollView->SetShadowThickness(8); m_chkDiffusedShadow.SetCheck(0); OnBnClickedChkDiffusedShadow(); // PNG rendering m_chkPngRendering.SetCheck(0); OnBnClickedChkEnablePngRendering(); m_chkExtrudedText.SetCheck(0); OnBnClickedChkExtrudedText(); m_chkEnableReflection.SetCheck(0); m_chkEnableReflection.EnableWindow(FALSE); m_pScrollView->EnableReflection(false); m_btnReflectSettings.EnableWindow(FALSE); m_btnSavePng.EnableWindow(FALSE); m_btnSaveRefPng.EnableWindow(FALSE); //m_btnFont.EnableWindow(FALSE); m_pScrollView->Render(true); return TRUE; // return TRUE unless you set the focus to a control }
void update_world_area(World_Area* area) { game_set_scale(2.0); real movespeed = 800; Vec2 move_impulse = v2(0, 0); if(_check(LEFT, A, State_Pressed)) { move_impulse.x -= movespeed; } if(_check(RIGHT, D, State_Pressed)) { move_impulse.x += movespeed; } if(_check(UP, W, State_Pressed)) { move_impulse.y -= movespeed; } if(_check(DOWN, S, State_Pressed)) { move_impulse.y += movespeed; } if(fabsf(move_impulse.x * move_impulse.y) > 0.01f) { move_impulse *= Math_InvSqrt2; } play_state->current_time = SDL_GetTicks(); real dt = (play_state->current_time - play_state->prev_time) / 1000.0; dt = clamp(dt, 0, 1.2f); play_state->accumulator += dt; play_state->prev_time = play_state->current_time; sim_sort_bodies_on_id(&area->sim); Entity* player_entity = world_area_find_entity(area, 0); Sim_Body* player = player_entity->body; Tile_Info* player_tile = area->map.info + tilemap_get_at(&area->map, player->shape.center); move_impulse *= player_tile->movement_modifier; while(play_state->accumulator >= Time_Step) { play_state->accumulator -= Time_Step; player->velocity += move_impulse; sim_update(&area->sim, &area->map, Time_Step); } Direction old_direction = player_entity->direction; if(move_impulse.y < 0) { player_entity->direction = Direction_North; } else if(move_impulse.y > 0) { player_entity->direction = Direction_South; } if(move_impulse.x < 0) { player_entity->facing = -1; player_entity->direction = Direction_West; } else if(move_impulse.x > 0) { player_entity->facing = 1; player_entity->direction = Direction_East; } if(input->scancodes[SDL_SCANCODE_SPACE] == State_Pressed) { player_entity->direction = old_direction; } Sprite* plr_spr = &player_entity->sprite; int32 player_frame = 0; if(v2_dot(move_impulse, move_impulse) > 0){ player_entity->counter++; player_frame = 1; if(player_entity->counter > 15) { player_frame = 0; if(player_entity->counter > 30) { player_entity->counter = 0; } } } else { player_entity->counter = 0; player_frame = 0; } if(player_entity->facing == -1) { plr_spr->texture = Get_Texture_Coordinates(32 + player_frame * 32, 0, -32, 32); } else if(player_entity->facing == 1) { plr_spr->texture = Get_Texture_Coordinates(0 + player_frame * 32, 0, 32, 32); } Vec2 target = player->shape.center; if(target.x < 0) { world_switch_current_area(play_state->world, area->west); play_state->world_xy.x--; } else if(target.x > area->map.w * Tile_Size) { world_switch_current_area(play_state->world, area->east); play_state->world_xy.x++; } else if(target.y < 0) { world_switch_current_area(play_state->world, area->north); play_state->world_xy.y--; } else if(target.y > area->map.h * Tile_Size) { world_switch_current_area(play_state->world, area->south); play_state->world_xy.y++; } area->offset += (target - area->offset) * 0.1f; area->offset -= game->size * 0.5f; if(area->offset.x < 0) area->offset.x = 0; else if((area->offset.x + game->size.x) > area->map.w * Tile_Size) area->offset.x = area->map.w * Tile_Size - game->size.x; if(area->offset.y < 0) area->offset.y = 0; else if((area->offset.y + game->size.y) > area->map.h * Tile_Size) area->offset.y = area->map.h * Tile_Size - game->size.y; //TODO(will) refactor into own function? /* * Player input code * */ if(input->mouse[SDL_BUTTON_LEFT] == State_Just_Pressed) { Entity* ball_entity = world_area_get_next_entity(area); Sim_Body* ball = ball_entity->body; Vec2 dmouse = v2(input->mouse_x / game->scale, input->mouse_y / game->scale) + area->offset; dmouse -= player->shape.center; real angle = atan2f(dmouse.y, dmouse.x); Vec2 normal = v2(cosf(angle), sinf(angle)); entity_add_event_on_activate(ball_entity, delete_on_activate); ball->damping = 0.9999f; ball->shape.hext = v2(8, 16); ball->shape.center = normal * ball->shape.hw * 4 + player->shape.center; ball->velocity += normal * 2000; ball->shape.hext = v2(8, 6); //ball->flags = Body_Flag_No_Friction; ball_entity->sprite.size = v2(16, 32); ball_entity->sprite.center = v2(0, 10); ball_entity->sprite.texture = Get_Texture_Coordinates(0, 96, 32, 64); } if(input->mouse[SDL_BUTTON_RIGHT] == State_Just_Pressed) { Vec2 dmouse = v2( input->mouse_x / game->scale, input->mouse_y / game->scale) + area->offset; AABB mbb = aabb(dmouse, 0, 0); world_area_synchronize_entities_and_bodies(area); for(isize i = 0; i < area->entities_count; ++i) { Entity* e = area->entities + i; if(aabb_intersect(e->body->shape, mbb)) { if(e->id != 0) { for(isize j = 0; j < e->event_on_activate_count; ++j) { e->event_on_activate[j](e, area); } break; } } } } if(input->scancodes[SDL_SCANCODE_F] == State_Just_Pressed) { //tilemap_set_at(&area->map, player->shape.center, Tile_Dug_Earth); Tile_State* state = tilemap_get_state_at(&area->map, player->shape.center); if(state != NULL) { state->damage++; update_tile_state_at(&area->map, player->shape.center); } } Sprite s; if(input->scancodes[SDL_SCANCODE_SPACE] >= State_Pressed) { init_sprite(&s); s.position = player->shape.center; s.size = v2(16, 16); s.texture = Get_Texture_Coordinates(0, renderer->texture_height - 16, 16, 16); s.color = v4(1, 1, 1, 1); switch(player_entity->direction) { case Direction_North: s.position.y -= s.size.y + player->shape.hh; break; case Direction_South: s.position.y += s.size.y + player->shape.hh; break; case Direction_East: s.position.x += s.size.x + player->shape.hw; break; case Direction_West: s.position.x -= s.size.x + player->shape.hh; break; } if(input->scancodes[SDL_SCANCODE_SPACE] == State_Just_Pressed) { //TODO(will) implement good space queries Sim_Body* touching = sim_query_aabb(&area->sim, aabb(s.position, s.size.x / 2, s.size.y / 2)); if(touching != NULL) { if(!Has_Flag(touching->flags, Body_Flag_Static)) player_entity->held_entity_id = touching->entity_id; } } } else { player_entity->held_entity_id = -1; } char debug_str[256]; if(player_entity->held_entity_id > 0) { Entity* e = world_area_find_entity(area, player_entity->held_entity_id); if(e != NULL) { Sim_Body* b = e->body; Vec2 target = player->shape.center; Vec2 diff = b->shape.hext + player->shape.hext + v2(8, 8); switch(player_entity->direction) { case Direction_North: target.y -= diff.y; break; case Direction_South: target.y += diff.y; break; case Direction_East: target.x += diff.x; break; case Direction_West: target.x -= diff.x; break; } Vec2 impulse = (target - b->shape.center); if(v2_dot(impulse, impulse) > (4 * Tile_Size * Tile_Size)) { player_entity->held_entity_id = -1; } impulse *= 60; { snprintf(debug_str, 256, "T(%.2f %.2f) j(%.2f %.2f)", target.x, target.y, impulse.x, impulse.y); } if(v2_dot(impulse, impulse) < (1000 * 1000)) b->velocity += impulse;// * b->inv_mass; } } renderer->offset = area->offset; area->offset += game->size * 0.5f; // throw a ball renderer_start(); Rect2 screen = rect2( area->offset.x - game->size.x / 2, area->offset.y - game->size.y / 2, game->size.x, game->size.y); isize sprite_count_offset = render_tilemap(&area->map, v2(0,0), screen); for(isize i = 0; i < area->entities_count; ++i) { Entity* e = area->entities + i; Sim_Body* b = sim_find_body(&area->sim, e->body_id); if (b == NULL) continue; e->sprite.position = b->shape.center; //e->sprite.size = v2(b->shape.hw * 2, b->shape.hh * 2); //TODO(will) align entity sprites by their bottom center renderer_push_sprite(&e->sprite); } renderer_push_sprite(&s); renderer_sort(sprite_count_offset); renderer_draw(); renderer->offset = v2(0, 0); game_set_scale(1.0); renderer_start(); char str[256]; isize len = snprintf(str, 256, "X:%d Y:%d Tile: %s", play_state->world_xy.x, play_state->world_xy.y, player_tile->name); render_body_text(str, v2(16, game->size.y - (body_font->glyph_height) - 8), true); render_body_text(debug_str, v2(16, 16), true); renderer_draw(); }
static bool TestIntersection() { RectType rect1(10, 10, 50, 50); RectType rect2(rect1); RectType dest; // Test against a rect that's the same as rect1 EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(rect1))) << "[1] Test against a rect that's the same as rect1"; // Test against a rect that's enclosed by rect1 rect2.Inflate(-1, -1); EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(rect2))) << "[2] Test against a rect that's enclosed by rect1"; rect2.Inflate(1, 1); // Test against a rect that overlaps the left edge of rect1 rect2.x--; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y, rect1.width - 1, rect1.height)))) << "[3] Test against a rect that overlaps the left edge of rect1"; rect2.x++; // Test against a rect that's outside of rect1 on the left rect2.x -= rect2.width; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[4] Test against a rect that's outside of rect1 on the left"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[4] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[4b] Should be finite"; rect2.x += rect2.width; // Test against a rect that overlaps the top edge of rect1 rect2.y--; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y, rect1.width, rect1.height - 1)))) << "[5] Test against a rect that overlaps the top edge of rect1"; EXPECT_TRUE(dest.IsFinite()) << "[5b] Should be finite"; rect2.y++; // Test against a rect that's outside of rect1 on the top rect2.y -= rect2.height; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[6] Test against a rect that's outside of rect1 on the top"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[6] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[6b] Should be finite"; rect2.y += rect2.height; // Test against a rect that overlaps the right edge of rect1 rect2.x++; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x + 1, rect1.y, rect1.width - 1, rect1.height)))) << "[7] Test against a rect that overlaps the right edge of rect1"; rect2.x--; // Test against a rect that's outside of rect1 on the right rect2.x += rect2.width; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[8] Test against a rect that's outside of rect1 on the right"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[8] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[8b] Should be finite"; rect2.x -= rect2.width; // Test against a rect that overlaps the bottom edge of rect1 rect2.y++; EXPECT_FALSE(!dest.IntersectRect(rect1, rect2) || !(dest.IsEqualInterior(RectType(rect1.x, rect1.y + 1, rect1.width, rect1.height - 1)))) << "[9] Test against a rect that overlaps the bottom edge of rect1"; EXPECT_TRUE(dest.IsFinite()) << "[9b] Should be finite"; rect2.y--; // Test against a rect that's outside of rect1 on the bottom rect2.y += rect2.height; EXPECT_FALSE(dest.IntersectRect(rect1, rect2)) << "[10] Test against a rect that's outside of rect1 on the bottom"; // Make sure an empty rect is returned EXPECT_FALSE(!dest.IsEmpty()) << "[10] Make sure an empty rect is returned"; EXPECT_TRUE(dest.IsFinite()) << "[10b] Should be finite"; rect2.y -= rect2.height; // Test against a rect with zero width or height rect1.SetRect(100, 100, 100, 100); rect2.SetRect(150, 100, 0, 100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[11] Intersection of rects with zero width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[11b] Should be finite"; // Tests against a rect with negative width or height // // Test against a rect with negative width rect1.SetRect(100, 100, 100, 100); rect2.SetRect(100, 100, -100, 100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[12] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[12b] Should be finite"; // Those two rects exactly overlap in some way... // but we still want to return an empty rect rect1.SetRect(100, 100, 100, 100); rect2.SetRect(200, 200, -100, -100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[13] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[13b] Should be finite"; // Test against two identical rects with negative height rect1.SetRect(100, 100, 100, -100); rect2.SetRect(100, 100, 100, -100); EXPECT_FALSE(dest.IntersectRect(rect1, rect2) || !dest.IsEmpty()) << "[14] Intersection of rects with negative width or height should be empty"; EXPECT_TRUE(dest.IsFinite()) << "[14b] Should be finite"; return true; }
static void test_CRect() { CRect empty; ok(empty.left == 0, "Expected left to be 0, was %ld\n", empty.left); ok(empty.top == 0, "Expected top to be 0, was %ld\n", empty.top); ok(empty.Width() == 0, "Expected Width to be 0, was %i\n", empty.Width()); ok(empty.Height() == 0, "Expected Height to be 0, was %i\n", empty.Height()); CRect rect(0, 0, 100, 50); ok(rect.Width() == 100, "Expected Width to be 100, was %i\n", rect.Width()); ok(rect.Height() == 50, "Expected Height to be 50, was %i\n", rect.Height()); RECT sdkRect; sdkRect.left = 0; sdkRect.top = 0; sdkRect.right = 100; sdkRect.bottom = 50; CRect rect2(sdkRect); CRect rect3(&sdkRect); ok_rect(rect2, rect); ok_rect(rect3, rect); CPoint pt(0, 0); CSize sz(100, 50); CRect rect4(pt, sz); ok_rect(rect4, rect2); CPoint ptBottomRight(100, 50); CRect rect5(pt, ptBottomRight); ok_rect(rect5, rect4); rect = CRect(210, 150, 350, 900); CPoint ptDown; ptDown = rect.BottomRight(); pt = CPoint(350, 900); ok_point(ptDown, pt); rect2 = CRect(10, 10, 350, 350); CPoint ptLow(180, 180); rect2.BottomRight() = ptLow; rect = CRect(10, 10, 180, 180); ok_rect(rect2, rect); pt = CPoint(95, 95); CPoint pt2 = rect2.CenterPoint(); ok_point(pt2, pt); pt2 = rect2.BottomRight(); pt = CPoint(180, 180); ok_point(pt2, pt); pt2 = rect2.TopLeft(); pt = CPoint(10, 10); ok_point(pt2, pt); rect2.TopLeft().Offset(3, 3); rect3 = CRect(13, 13, 180, 180); ok_rect(rect3, rect2); CRect rectSource(35, 10, 125, 10); CRect rectDest; rectDest.CopyRect(&rectSource); RECT rectSource2; rectSource2.left = 0; rectSource2.top = 0; rectSource2.bottom = 480; rectSource2.right = 640; rectDest.CopyRect(&rectSource2); rect = CRect(10, 10, 50, 50); rect.DeflateRect(1, 2); rect2 = CRect(11, 12, 49, 48); ok_rect(rect2, rect); rect2 = CRect(10, 10, 50, 50); CRect rectDeflate(1, 2, 3, 4); rect2.DeflateRect(&rectDeflate); rect = CRect(11, 12, 47, 46); ok_rect(rect2, rect); rect2.DeflateRect(sz); rect = CRect(111, 62, -53, -4); ok_rect(rect2, rect); rect2.OffsetRect(sz); rect = CRect(211, 112, 47, 46); ok_rect(rect2, rect); CRect rect1(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok(rect1.EqualRect(rect2), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect2)); ok(!rect1.EqualRect(rect3), "Expected EqualRect to return FALSE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&rect3)); RECT test; test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok(rect1.EqualRect(&test), "Expected EqualRect to return TRUE for %s, %s\n", wine_dbgstr_rect(&rect1), wine_dbgstr_rect(&test)); rect = test; rect2 = CRect(35, 150, 10, 25); ok_rect(rect, rect2); rect = CRect(0, 0, 300, 300); rect.InflateRect(50, 200); rect2 = CRect(-50, -200, 350, 500); ok_rect(rect, rect2); rect.InflateRect(sz); rect2 = CRect(-150, -250, 450, 550); ok_rect(rect, rect2); rect = CRect(20, 30, 80, 70); int nHt = rect.Height(); ok(nHt == 40, "Expected nHt to be 40, was %i\n", nHt); CRect rectOne(125, 0, 150, 200); CRect rectTwo(0, 75, 350, 95); CRect rectInter; rectInter.IntersectRect(rectOne, rectTwo); rect = CRect(125, 75, 150, 95); ok_rect(rectInter, rect); CRect rectInter2 = rectOne; rectInter2 &= rectTwo; rect = CRect(125, 75, 150, 95); ok_rect(rectInter2, rect); CRect rectNone(0, 0, 0, 0); CRect rectSome(35, 50, 135, 150); ok(rectNone.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectEmpty(), "Expected IsRectEmpty to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectEmpty(35, 35, 35, 35); ok(rectEmpty.IsRectEmpty(), "Expected IsRectEmpty to return TRUE for %s\n", wine_dbgstr_rect(&rectEmpty)); ok(rectNone.IsRectNull(), "Expected IsRectNull to return TRUE for %s\n", wine_dbgstr_rect(&rectNone)); ok(!rectSome.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectSome)); CRect rectNotNull(0, 0, 35, 50); ok(!rectNotNull.IsRectNull(), "Expected IsRectNull to return FALSE for %s\n", wine_dbgstr_rect(&rectNotNull)); rect1 = CRect(35, 150, 10, 25); rect2 = CRect(35, 150, 10, 25); rect3 = CRect(98, 999, 6, 3); ok_rect(rect1, rect2); test.left = 35; test.top = 150; test.right = 10; test.bottom = 25; ok_rect(rect1, test); nok_rect(rect1, rect3); nok_rect(rect3, test); rect1 = CRect(100, 235, 200, 335); pt = CPoint(35, 65); rect2 = CRect(135, 300, 235, 400); rect1 += pt; ok_rect(rect1, rect2); rect1 = CRect(100, 235, 200, 335); rect2 = rect1 + pt; CRect rectResult(135, 300, 235, 400); ok_rect(rectResult, rect2); rect2 = rect1 + &test; rectResult = CRect(65, 85, 210, 360); ok_rect(rectResult, rect2); rect2 = rect1 - (LPCRECT)&test; rectResult = CRect(135, 385, 190, 310); ok_rect(rectResult, rect2); rect2 = rect1 - pt; rectResult = CRect(65, 170, 165, 270); ok_rect(rect2, rectResult); rect1 -= pt; ok_rect(rect1, rectResult); rect1 = CRect(100, 0, 200, 300); rect2 = CRect(0, 100, 300, 200); rect3 = rect1 & rect2; rectResult = CRect(100, 100, 200, 200); ok_rect(rectResult, rect3); rect3 = rect1 | rect2; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect3); rect1 |= rect2; ok_rect(rectResult, rect1); rect1 += sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect1); rect1 += &test; rectResult = CRect(65, -100, 410, 375); ok_rect(rectResult, rect1); rect1 -= sz; rectResult = CRect(-35, -150, 310, 325); ok_rect(rectResult, rect1); rect1 -= &test; rectResult = CRect(0, 0, 300, 300); ok_rect(rectResult, rect1); rect2 = rect1 + sz; rectResult = CRect(100, 50, 400, 350); ok_rect(rectResult, rect2); rect2 = rect1 - sz; rectResult = CRect(-100, -50, 200, 250); ok_rect(rectResult, rect2); }
void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { // Determine wxDC to use based on need to double-buffer or // use system-generated transparent background portions wxDC* dcPtr; if ( HasTransparentBackground() ) dcPtr = new wxPaintDC(this); else dcPtr = new wxAutoBufferedPaintDC(this); wxDC& dc = *dcPtr; wxSize sz = GetClientSize(); const wxRect& butRect = m_btnArea; wxRect tcRect = m_tcArea; wxRect fullRect(0, 0, sz.x, sz.y); // artificial simple border if ( m_widthCustomBorder ) { int customBorder = m_widthCustomBorder; // Set border colour #ifdef __WXMAC__ wxPen pen1( wxColour(133,133,133), customBorder, wxPENSTYLE_SOLID ); #else wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), customBorder, wxPENSTYLE_SOLID); #endif dc.SetPen( pen1 ); // area around both controls wxRect rect2(fullRect); if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) { rect2 = tcRect; if ( customBorder == 1 ) { rect2.Inflate(1); } else { #ifdef __WXGTK__ rect2.x -= 1; rect2.y -= 1; #else rect2.x -= customBorder; rect2.y -= customBorder; #endif rect2.width += 1 + customBorder; rect2.height += 1 + customBorder; } } dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawRectangle(rect2); } // Clear the main background if the system doesn't do it by itself if ( !HasTransparentBackground() && (tcRect.x > 0 || tcRect.y > 0) ) { wxColour winCol = GetParent()->GetBackgroundColour(); dc.SetBrush(winCol); dc.SetPen(winCol); dc.DrawRectangle(fullRect); } if ( !m_btn ) { // Standard button rendering DrawButton(dc, butRect); } // paint required portion on the control if ( !m_text || m_widthCustomPaint ) { wxASSERT( m_widthCustomPaint >= 0 ); // Clear the text-control area background wxColour tcCol = GetBackgroundColour(); dc.SetBrush(tcCol); dc.SetPen(tcCol); dc.DrawRectangle(tcRect); // this is intentionally here to allow drawed rectangle's // right edge to be hidden if ( m_text ) tcRect.width = m_widthCustomPaint; dc.SetFont( GetFont() ); dc.SetClippingRegion(tcRect); if ( m_popupInterface ) m_popupInterface->PaintComboControl(dc, tcRect); else wxComboPopup::DefaultPaintComboControl(this, dc, tcRect); } delete dcPtr; }
static bool TestIntersects() { RectType rect1(10, 10, 50, 50); RectType rect2(rect1); // Test against a rect that's the same as rect1 EXPECT_FALSE(!rect1.Intersects(rect2)) << "[1] Test against a rect that's the same as rect1"; // Test against a rect that's enclosed by rect1 rect2.Inflate(-1, -1); EXPECT_FALSE(!rect1.Contains(rect2) || !rect1.Intersects(rect2)) << "[2] Test against a rect that's enclosed by rect1"; rect2.Inflate(1, 1); // Make sure inflate and deflate worked correctly EXPECT_TRUE(rect1.IsEqualInterior(rect2)) << "[3] Make sure inflate and deflate worked correctly"; // Test against a rect that overlaps the left edge of rect1 rect2.x--; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[4] Test against a rect that overlaps the left edge of rect1"; rect2.x++; // Test against a rect that's outside of rect1 on the left rect2.x -= rect2.width; EXPECT_FALSE(rect1.Intersects(rect2)) << "[5] Test against a rect that's outside of rect1 on the left"; rect2.x += rect2.width; // Test against a rect that overlaps the top edge of rect1 rect2.y--; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[6] Test against a rect that overlaps the top edge of rect1"; rect2.y++; // Test against a rect that's outside of rect1 on the top rect2.y -= rect2.height; EXPECT_FALSE(rect1.Intersects(rect2)) << "[7] Test against a rect that's outside of rect1 on the top"; rect2.y += rect2.height; // Test against a rect that overlaps the right edge of rect1 rect2.x++; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[8] Test against a rect that overlaps the right edge of rect1"; rect2.x--; // Test against a rect that's outside of rect1 on the right rect2.x += rect2.width; EXPECT_FALSE(rect1.Intersects(rect2)) << "[9] Test against a rect that's outside of rect1 on the right"; rect2.x -= rect2.width; // Test against a rect that overlaps the bottom edge of rect1 rect2.y++; EXPECT_FALSE(!rect1.Intersects(rect2)) << "[10] Test against a rect that overlaps the bottom edge of rect1"; rect2.y--; // Test against a rect that's outside of rect1 on the bottom rect2.y += rect2.height; EXPECT_FALSE(rect1.Intersects(rect2)) << "[11] Test against a rect that's outside of rect1 on the bottom"; rect2.y -= rect2.height; return true; }
void Menu::init(Game *game) { //////////////////FONTS//////////////////////////////// if(!_font.loadFromFile("data/fonts/caveman.ttf")) std::cout << "Can't load data/fonts/caveman.ttf" <<std::endl; //////////////////TEXTES//////////////////////////////// _titre.setFont(_font); _titre.setString("PUCE"); _titre.setCharacterSize(80); _titre.setPosition((600 - _titre.getGlobalBounds().width) / 2 ,-10); _titre.setColor(sf::Color(195,135,100)); _sousTitre.setFont(_font); _sousTitre.setString(sf::String("& THE LEG STEALER")); _sousTitre.setCharacterSize(20); _sousTitre.setPosition((600 - _titre.getGlobalBounds().width) / 2 , _titre.getGlobalBounds().height ); _sousTitre.setColor(sf::Color(150,90,100)); //////////////////MUSIQUE//////////////////////////////// if(!_music.openFromFile("data/music/8bit.ogg")) std::cout << "Can't load data/music/8bit.ogg" <<std::endl; _music.play(); _music.setLoop(true); _music.setVolume(3); //////////////////NUAGE 1//////////////////////////////// if(!_text.loadFromFile("data/menu/tileset_nuage1.png")) _text.setSmooth(false); _nuage.setTexture(_text); _nuage.setPosition(10,150); sf::IntRect rect(0,0,300,_nuage.getGlobalBounds().height); _nuage.setTextureRect(rect); //////////////////NUAGE 2//////////////////////////////// if(!_text2.loadFromFile("data/menu/tileset_nuage2.png")) _text2.setSmooth(false); _nuage2.setTexture(_text2); _nuage2.setPosition(530,60); sf::IntRect rect2(0,0,262,_nuage2.getGlobalBounds().height); _nuage2.setTextureRect(rect2); //////////////////MONTAGNES//////////////////////////////// if(!_textM.loadFromFile("data/menu/mountains1.png")) _textM.setSmooth(false); _mountain.setTexture(_textM); //////////////////PUCE//////////////////////////////// if(!_textP.loadFromFile("data/menu/puce_volante_tileset.png")) _textP.setSmooth(false); _puce.setTexture(_textP); _puce.setPosition(200,250); sf::IntRect rect3(0,0,300,_puce.getGlobalBounds().height); _puce.setTextureRect(rect3); //////////////////FORET//////////////////////////////// if(!_textF.loadFromFile("data/menu/foret_defilante.png")) _textF.setSmooth(false); _foret1.setTexture(_textF); _foret2.setTexture(_textF); _foret3.setTexture(_textF); _foret1.setTextureRect(sf::IntRect(0,0,400,_foret1.getGlobalBounds().height)); _foret2.setTextureRect(sf::IntRect(400,0,400,_foret2.getGlobalBounds().height)); _foret3.setTextureRect(sf::IntRect(800,0,403,_foret3.getGlobalBounds().height)); _foret1.setPosition(0,0); _foret2.setPosition(400,0); _foret3.setPosition(800,0); //////////////////MENU//////////////////////////////// if(!_textMenu.loadFromFile("data/menu/menu.png")) _textMenu.setSmooth(false); _menu.setTexture(_textMenu); _menu.setPosition(600,200); int _boucle = 0; _montre.restart(); _montre2.restart(); }
void wxSheetCellBitmapRendererRefData::AlignBmpTextRects(const wxRect& rect, int bmp_align, int WXUNUSED(txt_align), int margin, wxRect& bmpRect, wxRect& txtRect) { bool txt1st = ((bmp_align & wxSHEET_BMPREN_BMPRIGHT) != 0) || ((bmp_align & wxSHEET_BMPREN_BMPBELOW) != 0); bool expand1st = (!txt1st && ((bmp_align & wxSHEET_BMPREN_BMPEXPAND) != 0)) || ( txt1st && ((bmp_align & wxSHEET_BMPREN_BMPEXPAND) == 0)); wxSize size1(txt1st ? txtRect.GetSize() : bmpRect.GetSize()); wxSize size2(txt1st ? bmpRect.GetSize() : txtRect.GetSize()); wxRect rect1(rect); wxRect rect2(rect); if (((bmp_align & wxSHEET_BMPREN_BMPABOVE) != 0) || ((bmp_align & wxSHEET_BMPREN_BMPBELOW) != 0)) { // too tall if (size1.y + size2.y + margin > rect.height) { rect1.height = size1.y + 1; // only push second to bottom if it doesn't fall off if (size2.y < rect.height) { rect2.y = rect.GetBottom() - size2.y - 1; rect2.height = size2.y; } } else // fits within rect { // 1st will take any extra area, else pin to edge if (expand1st) { rect1.height -= size2.y + margin; rect2.y = rect1.GetBottom() + margin + 1; rect2.height = size2.y + 1; } else { rect1.height = size1.y + 1; rect2.y = rect1.GetBottom() + margin + 1; rect2.height = rect.GetBottom() - rect2.y + 1; } } } else // RIGHT or LEFT { // too wide if (size1.x + size2.x + margin > rect.width) { rect1.width = size1.x + 1; // only push second to right if it doesn't fall off if (size2.x < rect.width) { rect2.x = rect.GetRight() - size2.x - 1; rect2.width = size2.x; } } else // fits within rect { // 1st will take any extra area, else pin to edge if (expand1st) { rect1.width -= size2.x + margin; rect2.x = rect1.GetRight() + margin + 1; rect2.width = size2.x + 1; } else { rect1.width = size1.x + 1; rect2.x = rect1.GetRight() + margin + 1; rect2.width = rect.GetRight() - rect2.x + 1; } } } txtRect = txt1st ? rect1 : rect2; bmpRect = txt1st ? rect2 : rect1; }
static void drawEpipolarLines(const std::string& title, const cv::Matx<T1,3,3> F, const cv::Mat& img1, const cv::Mat& img2, const std::vector<cv::Point_<T2>> points1, const std::vector<cv::Point_<T2>> points2, const float inlierDistance = -1) { CV_Assert(img1.size() == img2.size() && img1.type() == img2.type()); cv::Mat outImg(img1.rows, img1.cols*2, CV_8UC3); cv::Rect rect1(0,0, img1.cols, img1.rows); cv::Rect rect2(img1.cols, 0, img1.cols, img1.rows); /* * Allow color drawing */ if (img1.type() == CV_8U) { cv::cvtColor(img1, outImg(rect1), CV_GRAY2BGR); cv::cvtColor(img2, outImg(rect2), CV_GRAY2BGR); } else { img1.copyTo(outImg(rect1)); img2.copyTo(outImg(rect2)); } std::vector<cv::Vec<T2,3>> epilines1, epilines2; cv::computeCorrespondEpilines(points1, 1, F, epilines1); //Index starts with 1 cv::computeCorrespondEpilines(points2, 2, F, epilines2); CV_Assert(points1.size() == points2.size() && points2.size() == epilines1.size() && epilines1.size() == epilines2.size()); cv::RNG rng(0); for(size_t i=0; i<points1.size(); i++) { if(inlierDistance > 0) { if(distancePointLine(points1[i], epilines2[i]) > inlierDistance || distancePointLine(points2[i], epilines1[i]) > inlierDistance) { //The point match is no inlier continue; } } /* * Epipolar lines of the 1st point set are drawn in the 2nd image and vice-versa */ cv::Scalar color(rng(256),rng(256),rng(256)); cv::line(outImg(rect2), cv::Point(0,-epilines1[i][2]/epilines1[i][1]), cv::Point(img1.cols,-(epilines1[i][2]+epilines1[i][0]*img1.cols)/epilines1[i][1]), color); cv::circle(outImg(rect1), points1[i], 3, color, -1, CV_AA); cv::line(outImg(rect1), cv::Point(0,-epilines2[i][2]/epilines2[i][1]), cv::Point(img2.cols,-(epilines2[i][2]+epilines2[i][0]*img2.cols)/epilines2[i][1]), color); cv::circle(outImg(rect2), points2[i], 3, color, -1, CV_AA); } cv::imshow(title, outImg); cv::waitKey(1); }
void CalendarControl::Draw(BRect r) { #ifdef __UNIVERSAL_INTERFACE if(interface==CC_ZETA_INTERFACE) { #endif #ifdef __ZETA_INTERFACE BRect rect1(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-2; BRect rect2(rect1); BPoint p1, p2; rgb_color color; if(IsEnabled()) { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is enabled) { SetHighColor(170,50,184,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); SetHighColor(218,218,218,0); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); StrokeLine(rect1.LeftTop(),rect1.RightTop()); SetHighColor(114,114,114,0); StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=170+(uint8)((229-170)*(view_color.red-170)/(255-170)); color.green=50+(uint8)((194-50)*(view_color.green-50)/(255-50)); color.blue=184+(uint8)((233-184)*(view_color.blue-184)/(255-184)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is enabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(0,0,0,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); SetHighColor(180,180,180,0); p1.Set(rect2.left+2,rect2.top+1); p2.Set(rect2.right-2,rect2.top+1); StrokeLine(p1,p2); p1.Set(rect2.left+1,rect2.top+2); p2.Set(rect2.left+1,rect2.bottom-2); StrokeLine(p1,p2); p1.Set(rect2.left+2,rect2.top+2); StrokeLine(p1,p1); SetHighColor(218,218,218,0); p1.Set(rect2.left+2,rect2.top+3); p2.Set(rect2.left+2,rect2.bottom-1); StrokeLine(p1,p2); p1.Set(rect2.left+3,rect2.top+2); p2.Set(rect2.right-1,rect2.top+2); StrokeLine(p1,p2); // outward borders color.red=(uint8)(218*view_color.red/255); color.green=(uint8)(218*view_color.green/255); color.blue=(uint8)(218*view_color.blue/255); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } else // control is disabled { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is disabled) { SetHighColor(255,255,255,0); rect1.left+=2; rect1.top+=2; rect1.right-=2; rect1.bottom-=2; StrokeRect(rect1); rect1=rect2; SetHighColor(231,198,235,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=231+(uint8)((251-231)*(view_color.red-231)/(255-231)); color.green=198+(uint8)((246-198)*(view_color.green-198)/(255-198)); color.blue=235+(uint8)((251-235)*(view_color.blue-235)/(255-235)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is disabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(185,185,185,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=185+(uint8)((245-185)*(view_color.red-185)/(255-185)); color.green=185+(uint8)((245-185)*(view_color.green-185)/(255-185)); color.blue=185+(uint8)((245-185)*(view_color.blue-185)/(255-185)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } #endif #ifdef __UNIVERSAL_INTERFACE } else // interface==CC_BEOS_INTERFACE { #endif #ifdef __BEOS_INTERFACE BRect rect1(Bounds()),rect2(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-1; rect2.top++; rect2.left++; rect2.bottom-=2; rect2.right=rect1.right-1; if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); if(IsEnabled()) SetHighColor(184,184,184,0); else SetHighColor(216,216,216,0); StrokeLine(rect1.LeftTop(),rect1.RightTop()); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); if(dtvc->IsFocus() && wc) { SetHighColor(0,0,229,0); StrokeRect(rect2); } else { SetHighColor(216,216,216,0); StrokeLine(rect2.LeftBottom(),rect2.RightBottom()); StrokeLine(rect2.RightTop(),rect2.RightBottom()); if(IsEnabled()) SetHighColor(96,96,96,0); else SetHighColor(152,152,152,0); StrokeLine(rect2.LeftTop(),rect2.RightTop()); StrokeLine(rect2.LeftTop(),rect2.LeftBottom()); } if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); rect2.top++; rect2.left++; rect2.right--; rect2.bottom--; StrokeRect(rect2); #endif #ifdef __UNIVERSAL_INTERFACE } #endif }
void snake_or_rat_tra(int sr) { if(no_of_pl==1 && lan==0) { write("score:",20,700);write(str,140,700); write("best score:",250,700);write(bstr,420,700); } if(no_of_pl==2 || lan==1) { write("score1:",20,700);write(si,140,700); write("score2:",210,700);write(si2,320,700); } if(sr==0) { glLoadIdentity(); switch(state_rat) { case UP: y=(y+10)%760; break; case RIGHT: x=(x+10)%1020; break; case DOWN: y=(y-10); if(y<0) y=y+760; break; case LEFT : x=(x-10); if(x<0) x=x+1020; } } else if(sr==2) { for(i=1;i<=size;i++) { glLoadIdentity(); // glColor3f(0.8+i*0.05,0.3+i*0.05,0.3); switch(state[i]) { case UP : t[i][1]=(t[i][1]+20)%760; glTranslated(t[i][0],t[i][1],0); rectangle(); break; case RIGHT : t[i][0]=(t[i][0]+20)%1020; glTranslated(t[i][0],t[i][1],0); rectangle(); break; case DOWN : t[i][1]=(t[i][1]-20); if(t[i][1]<=0)t[i][1]=(t[i][1]+760); glTranslated(t[i][0],t[i][1],0); rectangle(); break; case LEFT : t[i][0]=(t[i][0]-20); if(t[i][0]<=0)t[i][0]=(t[i][0]+1020); glTranslated(t[i][0],t[i][1],0); rectangle(); break; } } if(no_of_pl==2) { for(i=1;i<=size2;i++) { // glColor3f(0.9+i*0.05,0.9+i*0.05,0.1); glLoadIdentity(); switch(state2[i]) { case UP : t2[i][1]=(t2[i][1]+20)%760; glTranslated(t2[i][0],t2[i][1],0); rect2(); break; case RIGHT : t2[i][0]=(t2[i][0]+20)%1020; glTranslated(t2[i][0],t2[i][1],0); rect2(); break; case DOWN : t2[i][1]=(t2[i][1]-20); if(t2[i][1]<=0)t2[i][1]=(t2[i][1]+760); glTranslated(t2[i][0],t2[i][1],0); rect2(); break; case LEFT : t2[i][0]=(t2[i][0]-20); if(t2[i][0]<=0)t2[i][0]=(t2[i][0]+1020); glTranslated(t2[i][0],t2[i][1],0); rect2(); break; } } } } }
void Entity::Update(sf::Time const diff) { if (!map) return; ParticleEmitter.setParticlePosition(GetCenter()); ParticleSystem.update(diff); // Now we do collision detection and determine if we can actually move there std::list<CollisionInfo> collisions; bool collides = map->HasCollisionAt(NewPosition, this, collisions); bool floor = false; for (std::list<CollisionInfo>::const_iterator itr = collisions.begin(); itr != collisions.end(); ++itr) { CollisionInfo const& collision = *itr; if (collision.Block == this) // Don't collide with yourself continue; if (game->DebugEnabled()) { sf::RectangleShape rect2(sf::Vector2f(collision.Block->GetWidth(), collision.Block->GetHeight())); rect2.setPosition(collision.Block->GetPositionX(), collision.Block->GetPositionY()); rect2.setOutlineColor(sf::Color::Blue); rect2.setFillColor(sf::Color::Transparent); rect2.setOutlineThickness(3.f); game->GetWindow().draw(rect2); sf::RectangleShape rect(sf::Vector2f(collision.Intersection.width, collision.Intersection.height)); rect.setPosition(collision.Intersection.left, collision.Intersection.top); game->GetWindow().draw(rect); } // Detect vertical collisions if (collision.Block->IntersectTop(this, collision.Intersection)) { collision.Block->HandleFloor(this, floor); // Check that we're actually heading towards the tile if (Velocity.y > 0.f) { collision.Block->OnTopCollision(this, collision.Intersection); if (Type == TYPEID_PLAYER) std::cout << "Top collision" << std::endl; } } // Detect horizontal collisions else if (collision.Block->IntersectSide(this, collision.Intersection)) { if (Utils::CompareFloats(Velocity.x, 0.f) == Utils::COMPARE_GREATER_THAN && Utils::CompareFloats(collision.Intersection.left + collision.Intersection.width, collision.Block->GetPositionX(), 10.f) == Utils::COMPARE_EQUAL) // If we already trespassed the tile, don't bother with collision handling, for example if the player jumped from below { // We are colliding horizontally with the left side of a tile StopHorizontalMovement(); NewPosition.x = collision.Block->GetPositionX() - sprite.getGlobalBounds().width; // Move back a bit if (Type == TYPEID_PLAYER) std::cout << "Left collision" << std::endl; } else if (Utils::CompareFloats(Velocity.x, 0.f) == Utils::COMPARE_LESS_THAN && Utils::CompareFloats(collision.Intersection.left, collision.Block->GetPositionX() + collision.Block->GetWidth(), 10.f) == Utils::COMPARE_EQUAL) { // We are colliding horizontally with the right side of a tile StopHorizontalMovement(); NewPosition.x = collision.Block->GetPositionX() + collision.Block->GetWidth(); // Move back a bit if (Type == TYPEID_PLAYER) std::cout << "Right collision" << std::endl; } } } // Now we perform Entity-Entity collision detection, these collisions don't stop movement, they are used for events like eating coins, bullet hit detection, etc. for (auto& entity : game->Entities) if (entity->Intersects(this)) entity->HandleCollision(this); Position.x = NewPosition.x; Position.y = NewPosition.y; inAir = !floor; sprite.setPosition(Position); Draw(); }
void CodeView::paintEvent ( QPaintEvent * event ) { int rowHeight = getRowHeight(); QColor darkRed(100,0,0); QPainter painter(this); // Draw background painter.fillRect(event->rect(), Qt::black); // Border QRect rect = event->rect(); rect.setRight(BORDER_WIDTH); QColor borderColor; borderColor = QColor(60,60,60); painter.fillRect(rect, borderColor); // Show breakpoints for(int j = 0;j < m_breakpointList.size();j++) { int lineNo = m_breakpointList[j]; int rowIdx = lineNo-1; int y = rowHeight*rowIdx; QRect rect2(5,y,BORDER_WIDTH-10,rowHeight); painter.fillRect(rect2, Qt::blue); } // Draw content painter.setFont(m_font); for(size_t rowIdx = 0;rowIdx < m_highlighter.getRowCount();rowIdx++) { //int x = BORDER_WIDTH+10; int y = rowHeight*rowIdx; QString nrText; if((int)rowIdx == m_cursorY-1) { QRect rect2(BORDER_WIDTH,y,event->rect().width()-1,rowHeight); painter.fillRect(rect2, darkRed); } int fontY = y+(rowHeight-(m_fontInfo->ascent()+m_fontInfo->descent()))/2+m_fontInfo->ascent(); painter.setPen(Qt::white); nrText = QString("%1").arg(rowIdx+1); painter.drawText(4, fontY, nrText); QVector<TextField*> cols = m_highlighter.getRow(rowIdx); int x = BORDER_WIDTH+10; for(int j = 0;j < cols.size();j++) { TextField *field = cols[j]; painter.setPen(field->m_color); painter.drawText(x, fontY, field->m_text); x += m_fontInfo->width(field->m_text); } } }
void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) ) { wxSize sz = GetClientSize(); wxAutoBufferedPaintDC dc(this); const wxRect& rectb = m_btnArea; wxRect rect = m_tcArea; // artificial simple border if ( m_widthCustomBorder ) { int customBorder = m_widthCustomBorder; // Set border colour wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT), customBorder, wxPENSTYLE_SOLID); dc.SetPen( pen1 ); // area around both controls wxRect rect2(0,0,sz.x,sz.y); if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE ) { rect2 = m_tcArea; if ( customBorder == 1 ) { rect2.Inflate(1); } else { #ifdef __WXGTK__ rect2.x -= 1; rect2.y -= 1; #else rect2.x -= customBorder; rect2.y -= customBorder; #endif rect2.width += 1 + customBorder; rect2.height += 1 + customBorder; } } dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawRectangle(rect2); } #ifndef __WXMAC__ // see note in OnThemeChange wxColour winCol = GetBackgroundColour(); #else wxColour winCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); #endif dc.SetBrush(winCol); dc.SetPen(winCol); //wxLogDebug(wxT("hei: %i tcy: %i tchei: %i"),GetClientSize().y,m_tcArea.y,m_tcArea.height); //wxLogDebug(wxT("btnx: %i tcx: %i tcwid: %i"),m_btnArea.x,m_tcArea.x,m_tcArea.width); // clear main background dc.DrawRectangle(rect); if ( !m_btn ) { // Standard button rendering DrawButton(dc,rectb); } // paint required portion on the control if ( (!m_text || m_widthCustomPaint) ) { wxASSERT( m_widthCustomPaint >= 0 ); // this is intentionally here to allow drawed rectangle's // right edge to be hidden if ( m_text ) rect.width = m_widthCustomPaint; dc.SetFont( GetFont() ); dc.SetClippingRegion(rect); if ( m_popupInterface ) m_popupInterface->PaintComboControl(dc,rect); else wxComboPopup::DefaultPaintComboControl(this,dc,rect); } }
FlattenTestImage() : refRect(0,0,512,512) , p(refRect) { image = p.image; layer1 = p.layer; layer5 = new KisPaintLayer(p.image, "paint5", 0.4 * OPACITY_OPAQUE_U8); layer5->disableAlphaChannel(true); layer2 = new KisPaintLayer(p.image, "paint2", OPACITY_OPAQUE_U8); tmask = new KisTransparencyMask(); // check channel flags // make addition composite op group1 = new KisGroupLayer(p.image, "group1", OPACITY_OPAQUE_U8); layer3 = new KisPaintLayer(p.image, "paint3", OPACITY_OPAQUE_U8); layer4 = new KisPaintLayer(p.image, "paint4", OPACITY_OPAQUE_U8); layer6 = new KisPaintLayer(p.image, "paint6", OPACITY_OPAQUE_U8); layer7 = new KisPaintLayer(p.image, "paint7", OPACITY_OPAQUE_U8); layer8 = new KisPaintLayer(p.image, "paint8", OPACITY_OPAQUE_U8); layer7->setCompositeOp(COMPOSITE_ADD); layer8->setCompositeOp(COMPOSITE_ADD); QRect rect1(100, 100, 100, 100); QRect rect2(150, 150, 150, 150); QRect tmaskRect(200,200,100,100); QRect rect3(400, 100, 100, 100); QRect rect4(500, 100, 100, 100); QRect rect5(50, 50, 100, 100); QRect rect6(50, 250, 100, 100); QRect rect7(50, 350, 50, 50); QRect rect8(50, 400, 50, 50); layer1->paintDevice()->fill(rect1, KoColor(Qt::red, p.image->colorSpace())); layer2->paintDevice()->fill(rect2, KoColor(Qt::green, p.image->colorSpace())); tmask->testingInitSelection(tmaskRect); layer3->paintDevice()->fill(rect3, KoColor(Qt::blue, p.image->colorSpace())); layer4->paintDevice()->fill(rect4, KoColor(Qt::yellow, p.image->colorSpace())); layer5->paintDevice()->fill(rect5, KoColor(Qt::green, p.image->colorSpace())); layer6->paintDevice()->fill(rect6, KoColor(Qt::cyan, p.image->colorSpace())); layer7->paintDevice()->fill(rect7, KoColor(Qt::red, p.image->colorSpace())); layer8->paintDevice()->fill(rect8, KoColor(Qt::green, p.image->colorSpace())); KisPSDLayerStyleSP style(new KisPSDLayerStyle()); style->dropShadow()->setEffectEnabled(true); style->dropShadow()->setDistance(10.0); style->dropShadow()->setSpread(80.0); style->dropShadow()->setSize(10); style->dropShadow()->setNoise(0); style->dropShadow()->setKnocksOut(false); style->dropShadow()->setOpacity(80.0); layer2->setLayerStyle(style); layer2->setCompositeOp(COMPOSITE_ADD); group1->setCompositeOp(COMPOSITE_ADD); p.image->addNode(layer5); p.image->addNode(layer2); p.image->addNode(tmask, layer2); p.image->addNode(group1); p.image->addNode(layer3, group1); p.image->addNode(layer4, group1); p.image->addNode(layer6); p.image->addNode(layer7); p.image->addNode(layer8); p.image->initialRefreshGraph(); // dbgKrita << ppVar(layer1->exactBounds()); // dbgKrita << ppVar(layer5->exactBounds()); // dbgKrita << ppVar(layer2->exactBounds()); // dbgKrita << ppVar(group1->exactBounds()); // dbgKrita << ppVar(layer3->exactBounds()); // dbgKrita << ppVar(layer4->exactBounds()); TestUtil::ExternalImageChecker chk("flatten", "imagetest"); QVERIFY(chk.checkDevice(p.image->projection(), p.image, "00_initial")); }
static void draw_graph( QPainter &painter, int w, /* width */ int h, /* height */ int margin, double *X, /* x-values */ double *Y, /* y-values */ unsigned int N /* number of X[], Y[] */ ) { if ((w <= 3*margin) || (h <= 2*margin)) return; /* Qt coordinate system */ int x0 = 2*margin; int x1 = w - margin; int y0 = margin; int y1 = h - margin; if (x0 >= x1) return; if (y0 >= y1) return; /* draw boundary rectangle */ QRectF rectangle(x0, y0, x1-x0, y1-y0); painter.drawRect(rectangle); if (!X || !Y || !N) return; double Ymin = 0.0; double Ymax = 1.0; double Xmin = X[0]; double Xmax = X[0]; for(uint32_t i=1; i < N; i++) { double x = X[i]; if (x < Xmin) Xmin = x; if (x > Xmax) Xmax = x; } if ((Xmax > Xmin) && (Ymax > Ymin)) { /* allocate */ QPoint **points = (QPoint **) malloc(N*sizeof(QPoint *)); /* convert to qt coordinate system */ for(uint32_t i=0; i < N; i++) { int x = (int) (x0 + (x1 - x0) * (X[i] - Xmin) / (Xmax - Xmin)); int y = (int) (y1 - (y1 - y0) * (Y[i] - Ymin) / (Ymax - Ymin)); points[i] = new QPoint(x, y); } /* order along horizontal axis */ qsort((void *)points, N, sizeof(QPoint *), qpoint_cmp); /* draw line */ for(uint32_t i=0; i+1 < N; i++) painter.drawLine(*points[i], *points[i+1]); int labelwidth = 3*margin/2; int labelheight = margin; const char *labelfmtX = "%.0f"; const char *labelfmtY = "%.2f"; char label[32]; uint32_t labelsz = sizeof(label) - 1; /* draw horizontal labels */ snprintf(label, labelsz, labelfmtX, Xmin); QString XminStr = label; QRectF rect0(x0-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect0, Qt::AlignCenter, XminStr); snprintf(label, labelsz, labelfmtX, Xmax); QString XmaxStr = label; QRectF rect1(x1-labelwidth/2, y1, labelwidth, labelheight); painter.drawText(rect1, Qt::AlignCenter, XmaxStr); /* draw vertical labels */ snprintf(label, labelsz, labelfmtY, Ymin); QString YminStr = label; QRectF rect2(x0-labelwidth, y1-labelheight/2, labelwidth, labelheight); painter.drawText(rect2, Qt::AlignCenter, YminStr); snprintf(label, labelsz, labelfmtY, Ymax); QString YmaxStr = label; QRectF rect3(x0-labelwidth, y0-labelheight/2, labelwidth, labelheight); painter.drawText(rect3, Qt::AlignCenter, YmaxStr); /* clean up */ for(uint32_t i=0; i < N; i++) delete points[i]; free(points); } else if ((Xmin == Xmax) && (Ymin == Ymax)) { /* draw point */ } else if (Xmin == Xmax) { /* draw vertical line */ } else if (Ymin == Ymax) { /* draw horizontal line */ } }
// CSplitWnd message handlers void CSplitWnd::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CStatic::OnPaint() CRect rectClient; GetClientRect(&rectClient); dc.FillSolidRect(&rectClient, RGB(200, 200, 200)); CRect rect2(rectClient); rect2.InflateRect(-2, -2, -2, -2); dc.FillSolidRect(&rect2, RGB(200, 220, 220)); dc.Draw3dRect(&rectClient, RGB(255, 255, 255), RGB(128, 128, 128)); if(m_bCapture) { CPoint point; GetCursorPos(&point); ::ScreenToClient(GetSafeHwnd(), &point); CPen pen(PS_SOLID, 1, RGB(55, 55, 55)); CPen* pOldPen = dc.SelectObject(&pen); int nOldRop = dc.SetROP2(R2_XORPEN); if(m_nLastPos != INVALID_POS) { dc.MoveTo(m_nLastPos-1, 0); dc.LineTo(m_nLastPos-1, rectClient.Height()); dc.MoveTo(m_nLastPos+1, 0); dc.LineTo(m_nLastPos+1, rectClient.Height()); } dc.MoveTo(point.x-1, 0); dc.LineTo(point.x-1, rectClient.Height()); dc.MoveTo(point.x+1, 0); dc.LineTo(point.x+1, rectClient.Height()); m_nLastPos = point.x; dc.SetROP2(nOldRop); dc.SelectObject(pOldPen); } else { if(INVALID_POS != m_nLastPos) { //CPen pen(PS_SOLID, 1, RGB(55, 55, 55)); //CPen* pOldPen = dc.SelectObject(&pen); //int nOldRop = dc.SetROP2(R2_XORPEN); //dc.MoveTo(m_nLastPos-1, 0); //dc.LineTo(m_nLastPos-1, rectClient.Height()); //dc.MoveTo(m_nLastPos+1, 0); //dc.LineTo(m_nLastPos+1, rectClient.Height()); //dc.SetROP2(nOldRop); //dc.SelectObject(pOldPen); m_nLastPos = INVALID_POS; } } }
int Events::handleOneShot(Event *event) { Surface *backBuffer; ScriptThread *sthread; Rect rect; if (event->time > 0) { return kEvStContinue; } // Event has been signaled switch (event->code & EVENT_MASK) { case kTextEvent: switch (event->op) { case kEventDisplay: ((TextListEntry *)event->data)->display = true; break; case kEventRemove: _vm->_scene->_textList.remove((TextListEntry *)event->data); break; default: break; } break; case kSoundEvent: _vm->_sound->stopSound(); if (event->op == kEventPlay) _vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0); break; case kVoiceEvent: _vm->_sndRes->playVoice(event->param); break; case kMusicEvent: _vm->_music->stop(); if (event->op == kEventPlay) _vm->_music->play(event->param, (MusicFlags)event->param2); break; case kBgEvent: { Surface *backGroundSurface; BGInfo bgInfo; if (!(_vm->_scene->getFlags() & kSceneFlagISO)) { backBuffer = _vm->_gfx->getBackBuffer(); backGroundSurface = _vm->_render->getBackGroundSurface(); _vm->_scene->getBGInfo(bgInfo); backGroundSurface->blit(bgInfo.bounds, bgInfo.buffer); // If it is inset scene then draw black border if (bgInfo.bounds.width() < _vm->getDisplayWidth() || bgInfo.bounds.height() < _vm->_scene->getHeight()) { Common::Rect rect1(2, bgInfo.bounds.height() + 4); Common::Rect rect2(bgInfo.bounds.width() + 4, 2); Common::Rect rect3(2, bgInfo.bounds.height() + 4); Common::Rect rect4(bgInfo.bounds.width() + 4, 2); rect1.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect2.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.top - 2); rect3.moveTo(bgInfo.bounds.right, bgInfo.bounds.top - 2); rect4.moveTo(bgInfo.bounds.left - 2, bgInfo.bounds.bottom); backGroundSurface->drawRect(rect1, kITEColorBlack); backGroundSurface->drawRect(rect2, kITEColorBlack); backGroundSurface->drawRect(rect3, kITEColorBlack); backGroundSurface->drawRect(rect4, kITEColorBlack); } if (event->param == kEvPSetPalette) { PalEntry *palPointer; _vm->_scene->getBGPal(palPointer); _vm->_gfx->setPalette(palPointer); } } } break; case kAnimEvent: switch (event->op) { case kEventPlay: _vm->_anim->play(event->param, event->time, true); break; case kEventStop: _vm->_anim->stop(event->param); break; case kEventFrame: _vm->_anim->play(event->param, event->time, false); break; case kEventSetFlag: _vm->_anim->setFlag(event->param, event->param2); break; case kEventClearFlag: _vm->_anim->clearFlag(event->param, event->param2); break; default: break; } break; case kSceneEvent: switch (event->op) { case kEventEnd: _vm->_scene->nextScene(); return kEvStBreak; default: break; } break; case kPalAnimEvent: switch (event->op) { case kEventCycleStart: _vm->_palanim->cycleStart(); break; case kEventCycleStep: _vm->_palanim->cycleStep(event->time); break; default: break; } break; case kInterfaceEvent: switch (event->op) { case kEventActivate: _vm->_interface->activate(); break; case kEventDeactivate: _vm->_interface->deactivate(); break; case kEventSetStatus: _vm->_interface->setStatusText((const char*)event->data); _vm->_interface->drawStatusBar(); break; case kEventClearStatus: _vm->_interface->setStatusText(""); _vm->_interface->drawStatusBar(); break; case kEventSetFadeMode: _vm->_interface->setFadeMode(event->param); break; default: break; } break; case kScriptEvent: switch (event->op) { case kEventExecBlocking: case kEventExecNonBlocking: debug(6, "Exec module number %ld script entry number %ld", event->param, event->param2); sthread = _vm->_script->createThread(event->param, event->param2); if (sthread == NULL) { _vm->_console->DebugPrintf("Thread creation failed.\n"); break; } sthread->_threadVars[kThreadVarAction] = event->param3; sthread->_threadVars[kThreadVarObject] = event->param4; sthread->_threadVars[kThreadVarWithObject] = event->param5; sthread->_threadVars[kThreadVarActor] = event->param6; if (event->op == kEventExecBlocking) _vm->_script->completeThread(); break; case kEventThreadWake: _vm->_script->wakeUpThreads(event->param); break; } break; case kCursorEvent: switch (event->op) { case kEventShow: _vm->_gfx->showCursor(true); break; case kEventHide: _vm->_gfx->showCursor(false); break; default: break; } break; case kGraphicsEvent: switch (event->op) { case kEventFillRect: rect.top = event->param2; rect.bottom = event->param3; rect.left = event->param4; rect.right = event->param5; ((Surface *)event->data)->drawRect(rect, event->param); break; case kEventSetFlag: _vm->_render->setFlag(event->param); break; case kEventClearFlag: _vm->_render->clearFlag(event->param); break; default: break; } default: break; } return kEvStDelete; }
void CLineNode::InsertMMLFormulaNode_MTABLE_readAttr( AST_TXML_Tag *node, CFormulaNode *new_node ) { struct HMathMLAttr mml_attr( _T(""), _T("") ); // not one of the predefined tokens mml_attr.set( ::getCurrentFormulatorStyle().getUnit2PX(), node, _T("") /*has no body*/ ); mml_attr.accountAttr( FBL_ATTR_align ); mml_attr.accountAttr( FBL_ATTR_columnalign ); mml_attr.accountAttr( FBL_ATTR_rowalign ); new_node->CNodeInfo_Property::setUnfilteredAttr( mml_attr ); AST_TXML_Attribute *tblAttr = 0; long i, j, idx; tblAttr = node->getAttribute( FBL_ATTR_align ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { idx = -1; i = 0; QString tmp = _T(""), body = tblAttr->getStringValue(); do { while( i < body.length() && body.at(i).isSpace() ) i++; while( i < body.length() && body.at(i).isLetter() ) { tmp.append( body.at(i) ); i++; } if( tmp.length() == 0 ) break; while( i < body.length() && body.at(i).isSpace() ) i++; if( i >= body.length() ) break; if( !(body.at(i).isDigit() || body.at(i) == QChar('-')) ) break; LSDigit ldigit; long result = ldigit.Analisys( body.midRef(i) ); if( result != LSDigit::Integer ) break; if( ldigit.mnt_int >= 1 && ((long) ldigit.mnt_int) <= new_node->GetNumLine() ) { if( ldigit.asign < 0 ) idx = (new_node->GetNumLine() - ldigit.mnt_int) * new_node->GetNumColumn(); else idx = (ldigit.mnt_int - 1) * new_node->GetNumColumn(); } } while( 0 ); if( tmp == FBL_VAL_top ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableTop2Baseline, idx + 1 ); else if( tmp == FBL_VAL_bottom ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableBottom2Baseline, idx + 1 ); else if( tmp == FBL_VAL_center || tmp == FBL_VAL_baseline ) new_node->setSpecialVerticalCenter( FBtnChildPos::TableCenter2Baseline, idx + 1 ); else new_node->setSpecialVerticalCenter( FBtnChildPos::TableAxis, idx + 1 ); } std::vector<long> vAlign, hAlign; long v = TO_BASELINE, h = HORISONTAL_CENTER; ::bb_read_attr_align_horizontal( node, FBL_ATTR_columnalign, hAlign, h ); ::bb_read_attr_align_vertical( node, FBL_ATTR_rowalign, vAlign, v ); if( hAlign.size() > 0 ) h = hAlign[ hAlign.size() - 1 ]; if( vAlign.size() > 0 ) v = vAlign[ vAlign.size() - 1 ]; vAlign.resize( new_node->GetNumLine(), v ); hAlign.resize( new_node->GetNumColumn(), h ); long effV, cellEffV, cellEffH; AST_TXML_Tag *mtr = 0, *mtd = 0; idx = 0; for( i = 0; i < new_node->GetNumLine() && i < (long) vAlign.size(); i++ ) { mtr = ::mml_get_table_tag_mtr( node, i ); std::vector<long> hRowAlign; long rowH = LONG_MAX; ::bb_read_attr_align_horizontal( mtr, FBL_ATTR_columnalign, hRowAlign, LONG_MAX ); if( hRowAlign.size() > 0 ) rowH = hRowAlign[ hRowAlign.size() - 1 ]; hRowAlign.resize( hAlign.size(), rowH ); for( j = 0; j < (long) hRowAlign.size() && j < (long) hAlign.size(); j++ ) if( hRowAlign[ j ] == LONG_MAX ) hRowAlign[ j ] = hAlign[ j ]; effV = LONG_MAX; ::bb_read_attr_align_vertical( mtr, FBL_ATTR_rowalign, effV ); if( effV == LONG_MAX ) effV = vAlign[ i ]; for( j = 0; j < new_node->GetNumColumn() && j < (long) hAlign.size(); j++ ) { mtd = ::mml_get_table_tag_mtd( node, i, j ); cellEffH = LONG_MAX; ::bb_read_attr_align_horizontal( mtd, FBL_ATTR_columnalign, cellEffH ); if( cellEffH == LONG_MAX ) cellEffH = hRowAlign[ j ]; cellEffV = LONG_MAX; ::bb_read_attr_align_vertical( mtd, FBL_ATTR_rowalign, cellEffV ); if( cellEffV == LONG_MAX ) cellEffV = effV; Q_ASSERT( cellEffV != LONG_MAX && cellEffH != LONG_MAX ); new_node->SetChildFrameAlignType( idx, cellEffV | cellEffH ); idx++; } } std::vector<FBtnGraphics> frameLine; RealFde x0 = 0.0; RealFde y0 = 0.0; RealFde x100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; RealFde y100 = -1;//HF_BINBUTTON_VERTICAL_SCALE; tblAttr = node->getAttribute( FBL_ATTR_frame ); if( tblAttr && tblAttr->getStringValue().length() > 0 ) { int penStyle = -1; if( tblAttr->getStringValue() == FBL_VAL_solid ) penStyle = Qt::SolidLine; else if ( tblAttr->getStringValue() == FBL_VAL_dashed ) penStyle = Qt::DashLine; if( penStyle != -1 ) { FBtnGraphics oneLine; RectFde rect1( PointFde(x0, y0), PointFde(x100, y0) ); RectFde rect2( PointFde(x100, y0), PointFde(x100, y100) ); RectFde rect3( PointFde(x100, y100), PointFde(x0, y100) ); RectFde rect4( PointFde(x0, y100), PointFde(x0, y0) ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect1 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect2 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect3 ); frameLine.push_back( oneLine ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyle, rect4 ); frameLine.push_back( oneLine ); } } RealFde pos; std::vector<long> penStyleList; if( new_node->GetNumLine() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_rowlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumLine() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( x0, 0.0, x100, 0.0 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i * new_node->GetNumColumn() ).GetPecentPosition().bottom(); pos += new_node->GetSlot( (i + 1) * new_node->GetNumColumn() ).GetPecentPosition().top(); rc.setTop( pos / 2.0 ); rc.setBottom( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( new_node->GetNumColumn() > 1 ) { ::bb_read_attr_table_lines( node, FBL_ATTR_columnlines, penStyleList ); if( penStyleList.size() > 0 ) { penStyleList.resize( new_node->GetNumColumn() - 1, penStyleList[ penStyleList.size() - 1 ] ); FBtnGraphics oneLine; for( i = 0; i < (long) penStyleList.size(); i++ ) { RectFde rc( 0.0, y0, 0.0, y100 ); if( penStyleList[ i ] == -1 ) continue; pos = new_node->GetSlot( i ).GetPecentPosition().left(); pos += new_node->GetSlot( i + 1 ).GetPecentPosition().right(); rc.setLeft( pos / 2.0 ); rc.setRight( pos / 2.0 ); oneLine.createLine( FBtnGraphics::GRAPH_PRIM_LINE, penStyleList[ i ], rc ); frameLine.push_back( oneLine ); } } } if( frameLine.size() > 0 ) { CGraphPrimFormula *primList = new CGraphPrimFormula[ frameLine.size() ]; new_node->FlushAltGroup(); for( i = 0; i < (long) frameLine.size(); i++ ) { primList[ i ].Create( frameLine[ i ] ); new_node->AddAltGroup( frameLine[ i ].altGroup ); } new_node->CreateGraphPrimIndirect( (int) frameLine.size(), primList ); delete[] primList; } }
void drawItemStack(video::IVideoDriver *driver, gui::IGUIFont *font, const ItemStack &item, const core::rect<s32> &rect, const core::rect<s32> *clip, IGameDef *gamedef) { if(item.empty()) return; const ItemDefinition &def = item.getDefinition(gamedef->idef()); video::ITexture *texture = gamedef->idef()->getInventoryTexture(def.name, gamedef); // Draw the inventory texture if(texture != NULL) { const video::SColor color(255,255,255,255); const video::SColor colors[] = {color,color,color,color}; driver->draw2DImage(texture, rect, core::rect<s32>(core::position2d<s32>(0,0), core::dimension2di(texture->getOriginalSize())), clip, colors, true); } if(def.type == ITEM_TOOL && item.wear != 0) { // Draw a progressbar float barheight = rect.getHeight()/16; float barpad_x = rect.getWidth()/16; float barpad_y = rect.getHeight()/16; core::rect<s32> progressrect( rect.UpperLeftCorner.X + barpad_x, rect.LowerRightCorner.Y - barpad_y - barheight, rect.LowerRightCorner.X - barpad_x, rect.LowerRightCorner.Y - barpad_y); // Shrink progressrect by amount of tool damage float wear = item.wear / 65535.0; int progressmid = wear * progressrect.UpperLeftCorner.X + (1-wear) * progressrect.LowerRightCorner.X; // Compute progressbar color // wear = 0.0: green // wear = 0.5: yellow // wear = 1.0: red video::SColor color(255,255,255,255); int wear_i = MYMIN(floor(wear * 600), 511); wear_i = MYMIN(wear_i + 10, 511); if(wear_i <= 255) color.set(255, wear_i, 255, 0); else color.set(255, 255, 511-wear_i, 0); core::rect<s32> progressrect2 = progressrect; progressrect2.LowerRightCorner.X = progressmid; driver->draw2DRectangle(color, progressrect2, clip); color = video::SColor(255,0,0,0); progressrect2 = progressrect; progressrect2.UpperLeftCorner.X = progressmid; driver->draw2DRectangle(color, progressrect2, clip); } if(font != NULL && item.count >= 2) { // Get the item count as a string std::string text = itos(item.count); v2u32 dim = font->getDimension(narrow_to_wide(text).c_str()); v2s32 sdim(dim.X,dim.Y); core::rect<s32> rect2( /*rect.UpperLeftCorner, core::dimension2d<u32>(rect.getWidth(), 15)*/ rect.LowerRightCorner - sdim, sdim ); video::SColor bgcolor(128,0,0,0); driver->draw2DRectangle(bgcolor, rect2, clip); video::SColor color(255,255,255,255); font->draw(text.c_str(), rect2, color, false, false, clip); } }
//----------------------------------------------------------------------------- // // void CFightGroundLayer::upData( ccTime dt ) { if( m_bIsFightOver ) { g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE, 0 ); return; } if( m_iFightTurnId == m_pPetLeft->getSitId() ) { m_iFightTurnId = 0; m_pPetLeft->Attack(); } else if( m_iFightTurnId == m_pPetRight->getSitId() ) { m_iFightTurnId = 0; m_pPetRight->Attack(); } //if( m_pPetLeft->getHp() <= 0 ) //{ // m_pPetLeft->setHp(10); //} if( m_pPetLeft->getHp() <= 0 ) { m_pPlayer1Hp->setIsVisible(false); m_bIsFightOver = true; CCSize size = CCDirector::sharedDirector()->getWinSize(); string path = GetGameImagesPath(); path = path + "lose.png"; CCSprite *pSprite = CCSprite::spriteWithFile( path.c_str() ); addChild( pSprite, 100 ); pSprite->setPosition( ccp( size.width/2, size.height/2 ) ); g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE_LOSE, 0 ); g_pPetDataBlock->recordsave.loseBattleCount++; // string utf81; // CChineseCode::GB2312ToUTF_8( utf81, (char*)fightmessage_lost[g_iCurLanguageIndex], 256 ); // // char buffer[256]; // sprintf( buffer, utf81.c_str(), m_pPetRight->GetPetData()->playername.c_str(), m_pPetLeft->getName().c_str() ); // g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer ); //CFightFinish *pFightFinish = new CFightFinish( false ); //pFightFinish->init(); //pFightFinish->autorelease(); //addChild( pFightFinish, 100 ); schedule( schedule_selector(CFightGroundLayer::ScheudleExit),3.0f ); s_iWincount = 0; return; } if( m_pPetRight->getHp() <= 0 ) { m_pPlayer2Hp->setIsVisible(false); m_bIsFightOver = true; m_bIsWin = true; CCSize size = CCDirector::sharedDirector()->getWinSize(); string path = GetGameImagesPath(); path = path + "win.png"; CCSprite *pSprite = CCSprite::spriteWithFile( path.c_str() ); addChild( pSprite, 100 ); pSprite->setPosition( ccp( size.width/2, size.height/2 ) ); g_pPlayerEventCtrl->AddCounterNum( 1, SPECIAL_COUNTER_BATTLE_WIN, 0 ); g_pPetDataBlock->recordsave.winBattleCount++; string utf81; CChineseCode::GB2312ToUTF_8( utf81, (char*)fightmessage_win[g_iCurLanguageIndex], 256 ); char buffer[256]; sprintf( buffer, utf81.c_str(), m_pPetRight->GetPetData()->playername.c_str(), m_pPetRight->getName().c_str() ); g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer ); schedule( schedule_selector( CFightGroundLayer::SheduleWin ),3.0f ); //CChineseCode::GB2312ToUTF_8( utf81, (char*)fightplayermessage_lost[g_iCurLanguageIndex], 256 ); //sprintf( buffer, utf81.c_str(), m_pPetLeft->GetPetData()->playername.c_str() ); s_iWincount++; if( s_iWincount >= 2 ) { string utf8; CChineseCode::GB2312ToUTF_8( utf8, (char*)message_kill[g_iCurLanguageIndex], 256 ); sprintf( buffer, utf8.c_str(), m_pPetLeft->getName().c_str(), s_iWincount ); g_pPetDataBlock->addGameMessage( GetGameDayAndTime().c_str(), buffer ); } if( CCUserDefault::sharedUserDefault()->getBoolForKey( "sound" ) ) { if( s_iWincount >= 5 ) { CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/rampage.mp3", false); } else if( s_iWincount >= 4 ) { CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/ultrakill.mp3", false); } else if( s_iWincount >= 3 ) { CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/triple_kill.mp3", false); } else if( s_iWincount >= 2 ) { CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/Double_Kill.mp3", false); } } return; } CCRect rect( 0,0, (float)(m_iMaxHpBar) / (float)(m_pPetLeft->getMaxHp()) * m_pPetLeft->getHp(), m_iMaxHpHeight ); m_pPlayer1Hp->setTextureRect( rect ); m_pPlayer1Hp->setPosition( ccp( m_iHpInitPos + ( m_iMaxHpBar - (float)(m_iMaxHpBar) / (float)(m_pPetLeft->getMaxHp()) * m_pPetLeft->getHp() ), m_pPlayer1Hp->getPosition().y ) ); CCRect rect2( 0,0, (float)(m_iMaxHpBar) / (float)(m_pPetRight->getMaxHp()) * m_pPetRight->getHp(), m_iMaxHpHeight ); m_pPlayer2Hp->setTextureRect( rect2 ); CCRect rectMp( 0, 0, (float)(m_iMaxMpBar) / (float)(m_pPetLeft->getMaxMp()) * m_pPetLeft->getMp(), m_iMaxMpHeight ); m_pPlayer1Mp->setTextureRect( rectMp ); m_pPlayer1Mp->setPosition( ccp( m_iMpInitPos + ( m_iMaxMpBar - (float)(m_iMaxMpBar) / (float)(m_pPetLeft->getMaxMp()) * m_pPetLeft->getMp() ), m_pPlayer1Mp->getPosition().y ) ); CCRect rect2Mp( 0,0, (float)(m_iMaxMpBar) / (float)(m_pPetRight->getMaxMp()) * m_pPetRight->getMp(), m_iMaxMpHeight ); m_pPlayer2Mp->setTextureRect( rect2Mp ); }
void CBC_OnedUPCAWriter::ShowChars(const CFX_WideStringC& contents, CFX_DIBitmap* pOutBitmap, CFX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t multiple, int32_t& e) { if (!device && !pOutBitmap) { e = BCExceptionIllegalArgument; return; } int32_t leftPadding = 7 * multiple; int32_t leftPosition = 10 * multiple + leftPadding; CFX_ByteString str = FX_UTF8Encode(contents); int32_t iLen = str.GetLength(); FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); FXSYS_memset(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); CFX_ByteString tempStr = str.Mid(1, 5); FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; FX_FLOAT blank = 0.0; CFX_FxgeDevice geBitmap; if (pOutBitmap) geBitmap.Attach(pOutBitmap, false, nullptr, false); iLen = tempStr.GetLength(); int32_t iFontSize = (int32_t)fabs(m_fFontSize); int32_t iTextHeight = iFontSize + 1; if (!pOutBitmap) { CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect( (FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); matr.Concat(*matrix); matr.TransformRect(rect); FX_RECT re = rect.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect1( (FX_FLOAT)(leftPosition + 40 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), (FX_FLOAT)m_Height); matr1.Concat(*matrix); matr1.TransformRect(rect1); re = rect1.GetOutterRect(); device->FillRect(&re, m_backgroundColor); FX_FLOAT strWidth1 = (FX_FLOAT)multiple * 7; CFX_Matrix matr2(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect2(0.0, (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)strWidth1 - 1, (FX_FLOAT)m_Height); matr2.Concat(*matrix); matr2.TransformRect(rect2); re = rect2.GetOutterRect(); device->FillRect(&re, m_backgroundColor); CFX_Matrix matr3(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); CFX_FloatRect rect3( (FX_FLOAT)(leftPosition + 85 * multiple), (FX_FLOAT)(m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 85 * multiple) + strWidth1 - 0.5), (FX_FLOAT)m_Height); matr3.Concat(*matrix); matr3.TransformRect(rect3); re = rect3.GetOutterRect(); device->FillRect(&re, m_backgroundColor); } if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos + 1, m_pFont, strWidth, iFontSize, blank); CFX_Matrix affine_matrix(1.0, 0.0, 0.0, -1.0, 0.0, (FX_FLOAT)iFontSize); CFX_FxgeDevice ge; if (pOutBitmap) { ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, (FX_FLOAT)leftPosition * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 1, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(6, 5); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 6, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { FX_RECT rect2(0, 0, (int)strWidth, iTextHeight); ge.FillRect(&rect2, m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 40 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 40 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 6, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(0, 1); iLen = tempStr.GetLength(); strWidth = (FX_FLOAT)multiple * 7; if (!pOutBitmap) strWidth = strWidth * m_outputHScale; CalcTextInfo(tempStr, pCharPos, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), 0, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1(1.0, 0.0, 0.0, -1.0, 0, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } tempStr = str.Mid(11, 1); iLen = tempStr.GetLength(); CalcTextInfo(tempStr, pCharPos + 11, m_pFont, strWidth, iFontSize, blank); if (pOutBitmap) { delete ge.GetBitmap(); ge.Create((int)strWidth, iTextHeight, FXDIB_Argb, nullptr); ge.GetBitmap()->Clear(m_backgroundColor); ge.DrawNormalText(iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix, m_fontColor, FXTEXT_CLEARTYPE); geBitmap.SetDIBits(ge.GetBitmap(), leftPosition + 85 * multiple, m_Height - iTextHeight); } else { CFX_Matrix affine_matrix1( 1.0, 0.0, 0.0, -1.0, (FX_FLOAT)(leftPosition + 85 * multiple) * m_outputHScale, (FX_FLOAT)(m_Height - iTextHeight + iFontSize)); if (matrix) { affine_matrix1.Concat(*matrix); } device->DrawNormalText( iLen, pCharPos + 11, m_pFont, CFX_GEModule::Get()->GetFontCache(), (FX_FLOAT)iFontSize, &affine_matrix1, m_fontColor, FXTEXT_CLEARTYPE); } FX_Free(pCharPos); }
void GUIConfirmRegistration::regenerateGui(v2u32 screensize) { acceptInput(); removeChildren(); /* Calculate new sizes and positions */ const float s = m_gui_scale; DesiredRect = core::rect<s32>( screensize.X / 2 - 600 * s / 2, screensize.Y / 2 - 360 * s / 2, screensize.X / 2 + 600 * s / 2, screensize.Y / 2 + 360 * s / 2 ); recalculateAbsolutePosition(false); v2s32 size = DesiredRect.getSize(); v2s32 topleft_client(0, 0); const wchar_t *text; /* Add stuff */ s32 ypos = 30 * s; { std::string address = m_address; if (address.empty()) address = "localhost"; core::rect<s32> rect2(0, 0, 540 * s, 180 * s); rect2 += topleft_client + v2s32(30 * s, ypos); static const std::string info_text_template = strgettext( "You are about to join the server at %1$s with the " "name \"%2$s\" for the first time. If you proceed, a " "new account using your credentials will be created " "on this server.\n" "Please retype your password and click Register and " "Join to confirm account creation or click Cancel to " "abort."); char info_text_buf[1024]; porting::mt_snprintf(info_text_buf, sizeof(info_text_buf), info_text_template.c_str(), address.c_str(), m_playername.c_str()); wchar_t *info_text_buf_wide = utf8_to_wide_c(info_text_buf); gui::IGUIEditBox *e = new gui::intlGUIEditBox(info_text_buf_wide, true, Environment, this, ID_message, rect2, false, true); delete[] info_text_buf_wide; e->drop(); e->setMultiLine(true); e->setWordWrap(true); e->setTextAlignment(gui::EGUIA_UPPERLEFT, gui::EGUIA_CENTER); } ypos += 210 * s; { core::rect<s32> rect2(0, 0, 540 * s, 30 * s); rect2 += topleft_client + v2s32(30 * s, ypos); gui::IGUIEditBox *e = Environment->addEditBox(m_pass_confirm.c_str(), rect2, true, this, ID_confirmPassword); e->setPasswordBox(true); } ypos += 60 * s; { core::rect<s32> rect2(0, 0, 230 * s, 35 * s); rect2 = rect2 + v2s32(size.X / 2 - 220 * s, ypos); text = wgettext("Register and Join"); Environment->addButton(rect2, this, ID_confirm, text); delete[] text; } { core::rect<s32> rect2(0, 0, 120 * s, 35 * s); rect2 = rect2 + v2s32(size.X / 2 + 70 * s, ypos); text = wgettext("Cancel"); Environment->addButton(rect2, this, ID_cancel, text); delete[] text; } { core::rect<s32> rect2(0, 0, 200 * s, 20 * s); rect2 += topleft_client + v2s32(30 * s, ypos - 40 * s); text = wgettext("Passwords do not match!"); IGUIElement *e = Environment->addStaticText( text, rect2, false, true, this, ID_message); e->setVisible(false); delete[] text; } }
void CAlfPerfAppAvkonTestCaseBasic::NextAnimFrameL() { // Begin drawing RWindow& window = static_cast< RWindow& >( *iAvkonControl->DrawableWindow() ); CWindowGc& gc = iAvkonControl->SystemGc(); TRect updateRect(iAvkonControl->Rect()); window.Invalidate( updateRect ); window.BeginRedraw( updateRect ); gc.Activate(window); // Draw background TRgb color (KRgbWhite); gc.SetBrushColor(color); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenSize(TSize(10,10)); gc.SetPenColor(color); gc.DrawRect(updateRect); // Calc timeline TTime now; now.UniversalTime(); TUint millisecondFromCycleStart = now.MicroSecondsFrom(iCycleStartTime).Int64() / 1000; double timelinePercentage = (double)millisecondFromCycleStart / KCycleDurationMs; timelinePercentage *= 0.5; // scale it a bit... // Calc rect TRect fullRect(updateRect); TSize size(fullRect.Width()*(1.0 - timelinePercentage), fullRect.Height()*(1.0 - timelinePercentage)); TPoint windowCenter = fullRect.Center(); TPoint tl(windowCenter.iX - size.iWidth/2, windowCenter.iY - size.iHeight/2); TRect rect(tl, size); // Draw gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); const TPoint Point1(rect.iTl); const TPoint Point2(rect.iBr.iX, rect.iTl.iY); const TPoint Point3(rect.iBr); const TPoint Point4(rect.iTl.iX, rect.iBr.iY); const TPoint center(rect.Center()); switch (iCycleCounter) { case 1: // DrawEllipse { gc.DrawEllipse(rect); break; } case 2: // DrawRect { gc.DrawRect(rect); break; } case 3: // DrawRoundRect { TSize corner(rect.Width()/5, rect.Height()/5); gc.DrawRoundRect(rect, corner); break; } case 4: // Draw lines { gc.SetPenColor(TRgb(255,0,0)); gc.DrawLine(Point1, Point2); gc.SetPenColor(TRgb(200,50,0)); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(150,100,0)); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(100,150,0)); gc.DrawLineBy(TPoint(0, -rect.Height())); gc.SetPenColor(TRgb(50,200,0)); gc.MoveTo(Point2); gc.DrawLineTo(Point4); gc.SetPenColor(TRgb(0,255,0)); gc.MoveBy(TPoint(0, -rect.Height())); gc.DrawLineTo(Point3); gc.SetPenColor(TRgb(255,0,0)); gc.Plot(center); break; } case 5: // Draw { gc.SetPenColor(TRgb(255,0,0)); gc.DrawArc(rect, Point2, Point1); gc.DrawPie(rect, Point4, Point3); break; } case 6: // Draw polygons { const TInt KNumPoints = 9; TPoint pointList[KNumPoints]; pointList[0] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); pointList[1] = TPoint(Point1.iX+rect.Width()*0.75, Point1.iY); pointList[2] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.25); pointList[3] = TPoint(Point2.iX, Point2.iY+rect.Height()*0.75); pointList[4] = TPoint(Point3.iX-rect.Width()*0.25, Point3.iY); pointList[5] = TPoint(Point3.iX-rect.Width()*0.75, Point3.iY); pointList[6] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.25); pointList[7] = TPoint(Point4.iX, Point4.iY-rect.Height()*0.75); pointList[8] = TPoint(Point1.iX+rect.Width()*0.25, Point1.iY); CArrayFix<TPoint>* mypoints = new CArrayFixFlat<TPoint>(KNumPoints); CleanupStack::PushL(mypoints); for(TInt i=0; i<KNumPoints; i++) { mypoints->AppendL(pointList[i]); } gc.SetPenColor(TRgb(255,0,0)); gc.SetPenSize(TSize(20,20)); gc.DrawPolyLine(mypoints); gc.SetPenColor(TRgb(0,255,0)); gc.SetPenSize(TSize(15,15)); gc.DrawPolyLine(pointList, KNumPoints); gc.SetPenColor(TRgb(255,255,0)); gc.SetPenSize(TSize(10,10)); gc.DrawPolygon(mypoints); gc.SetPenColor(TRgb(0,0,255)); gc.SetPenSize(TSize(5,5)); gc.DrawPolygon(pointList, KNumPoints); CleanupStack::PopAndDestroy(); // mypoints break; } case 7: // Draw texts { gc.UseFont(iFont); gc.SetDrawMode(CGraphicsContext::EDrawModePEN); gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); TInt h = rect.Height() / 3; TInt y = rect.iTl.iY; TRect tinyBox(rect); tinyBox.SetHeight(h); TInt fontDescent=iFont->DescentInPixels(); gc.SetBrushColor(TRgb(0, 0, 255)); // blue gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawText(_L("Ilves"), tinyBox.iTl+TPoint(0, fontDescent)); tinyBox.Move(0,h); TInt posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawText(_L("Tappara"), tinyBox, posY); gc.SetPenColor(TRgb(0,255,0)); // green gc.DrawTextVertical(_L("Ilves"), tinyBox.iTl+TPoint(fontDescent, 0 ), ETrue); tinyBox.Move(0,h); posY = tinyBox.Height()-fontDescent; gc.SetPenColor(TRgb(255,0,0)); gc.DrawTextVertical(_L("Tappara"), tinyBox, posY, ETrue); break; } case 8: // Draw bitmaps { TPoint pos(rect.iTl); gc.BitBlt(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY); gc.BitBlt(pos, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()*2/3, rect.iTl.iY); gc.BitBltMasked(pos, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()/3); TRect dstRect(pos, TSize(rect.Width()/3, rect.Height()/3)); gc.DrawBitmap(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels())); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmap(dstRect, iPictureBm); pos = TPoint(rect.iTl.iX, rect.iTl.iY+ rect.Height()*2/3); gc.DrawBitmap(pos, iPictureBm); pos = TPoint(rect.iTl.iX + rect.Width()/3, rect.iTl.iY+ rect.Height()*2/3); dstRect = TRect(pos, dstRect.Size()); gc.DrawBitmapMasked(dstRect, iPictureBm, TRect(iPictureBm->SizeInPixels()), iMaskBm, EFalse); break; } case 9: // Miscellanious { TRect rect1(rect); rect1.SetWidth(rect.Width()/2); rect1.SetHeight(rect.Height()/2); TRect rect2(rect1); rect2.Move(rect1.Width(),0); TRect rect3(rect1); rect3.Move(0, rect1.Height()); TRect rect4(rect1); rect4.Move(rect1.Width(), rect1.Height()); // Clear gc.Clear(); // Brush pattern gc.UseBrushPattern(iPictureBm); gc.SetBrushStyle(CGraphicsContext::EPatternedBrush); gc.DrawRect(rect1); gc.DiscardBrushPattern(); // Fading & copy rect gc.SetFaded(ETrue); gc.CopyRect(rect2.iTl, rect1); gc.SetFadingParameters(255,0); gc.CopyRect(rect3.iTl, rect1); // Map colors gc.SetPenColor(KRgbBlue); gc.SetBrushColor(KRgbRed); gc.DrawRect(rect4); TRgb colors[2] = {KRgbRed, KRgbGreen}; // change brush color gc.MapColors(rect4,colors,1,ETrue); break; } default: gc.DrawRect(rect); } // End drawing gc.Deactivate(); window.EndRedraw(); iTestCaseFrameCount++; }
bool contientPlus(sf::FloatRect rect, sf::Vector2f point) { sf::FloatRect rect2 (rect.left - epsilon, rect.top - epsilon, rect.width + 2 * epsilon, rect.height + 2 * epsilon); return rect2.contains(point); }