static inline void drawtri_horse(Image *img, Rect *r, short *a, short *b, short *c, uchar *color) { v4int abp_y, bcp_y, cap_y, abp, bcp, cap; v4int abp_dx, bcp_dx, cap_dx; v4int abp_dy, bcp_dy, cap_dy; v4int mask; short u0, v0; enum { ustep = 2, vstep = 2 }; abp_dx = vec4ir(ori2i_dx(a, b)); bcp_dx = vec4ir(ori2i_dx(b, c)); cap_dx = vec4ir(ori2i_dx(c, a)); abp_dy = vec4ir(ori2i_dy(a, b)); bcp_dy = vec4ir(ori2i_dy(b, c)); cap_dy = vec4ir(ori2i_dy(c, a)); short p[2] = { r->u0, r->v0 }; abp_y = vec4ir(ori2i(a, b, p)) + vec4i(0, abp_dx[0], abp_dy[0], abp_dx[0]+abp_dy[0]); bcp_y = vec4ir(ori2i(b, c, p)) + vec4i(0, bcp_dx[0], bcp_dy[0], bcp_dx[0]+bcp_dy[0]); cap_y = vec4ir(ori2i(c, a, p)) + vec4i(0, cap_dx[0], cap_dy[0], cap_dx[0]+cap_dy[0]); abp_y += topleft(a, b); bcp_y += topleft(b, c); cap_y += topleft(c, a); abp_dx = abp_dx * ustep; bcp_dx = bcp_dx * ustep; cap_dx = cap_dx * ustep; abp_dy = abp_dy * vstep; bcp_dy = bcp_dy * vstep; cap_dy = cap_dy * vstep; for(v0 = r->v0; v0 < r->vend; v0 += vstep){ abp = abp_y; bcp = bcp_y; cap = cap_y; for(u0 = r->u0; u0 < r->uend; u0 += ustep){ mask = (abp | bcp | cap) >> 31; if((mask[0]&mask[1]&mask[2]&mask[3]) == 0){ mask |= vec4i(0, -(u0 == r->uend-1), 0, -(u0 == r->uend-1)); mask |= vec4i(0, 0, -(v0 == r->vend-1), -(v0 == r->vend-1)); fragment(img, u0, v0, *(u32int*)color, mask); } abp += abp_dx; bcp += bcp_dx; cap += cap_dx; } abp_y += abp_dy; bcp_y += bcp_dy; cap_y += cap_dy; } }
static void draw_image_button(button obj, rect r) { image img; bitmap store = NULL; rect ir; rgb up, down; rgb old = currentcolour(); img = obj->img; if (has_transparent_pixels(img)) { store = newbitmap(r.width, r.height, 0); drawto(store); setcolour(getbackground(obj)); fillrect(r); } if (img) { ir = insetr(r,2); if (ishighlighted(obj)) /* button is pressed */ ir.x += 1, ir.y += 1; /* Draw the button image. */ if (ischecked(obj)) drawdarker(img, ir, getrect(img)); else if (isenabled(obj)) drawimage(img, ir, getrect(img)); else drawgreyscale(img, ir, getrect(img)); if (ishighlighted(obj)) { /* fill the gap */ ir.x -= 1, ir.y -= 1; setcolour(getbackground(obj)); drawline(topleft(ir),topright(ir)); drawline(topleft(ir),bottomleft(ir)); } } /* Draw button border. */ setcolour(getforeground(obj)); setlinewidth(1); drawrect(r); /* Draw button shadow. */ up = White, down = Grey; if (ishighlighted(obj)) up = Grey, down = LightGrey; draw_shadow(insetr(r,1), up, down, 1); if (store != NULL) { drawto(obj); copyrect(store, pt(0,0), getrect(store)); del(store); } setcolour(old); }
bool GenericObjectDetector::ShiftWindow(const Point& seedPt, Size winSz, Point& newPt) { // define window Point topleft(seedPt.x-winSz.width/2, seedPt.y-winSz.height/2); topleft.x = MAX(0, topleft.x); topleft.y = MAX(0, topleft.y); Point bottomright(seedPt.x+winSz.width/2, seedPt.y+winSz.height/2); bottomright.x = MIN(bottomright.x, imgSize.width-1); bottomright.y = MIN(bottomright.y, imgSize.height-1); Rect win(topleft, bottomright); // start iteration for(int i=0; i<shiftCrit.maxCount; i++) { // compute edge orientation difference sum double sumgx = integralGx.at<double>(win.br().y, win.br().x); sumgx += integralGx.at<double>(win.tl().y, win.tl().x); sumgx -= integralGx.at<double>(win.tl().y, win.br().x); sumgx -= integralGx.at<double>(win.br().y, win.tl().x); double sumgy = integralGy.at<double>(win.br().y, win.br().x); sumgy += integralGy.at<double>(win.tl().y, win.tl().x); sumgy -= integralGy.at<double>(win.tl().y, win.br().x); sumgy -= integralGy.at<double>(win.br().y, win.tl().x); } return true; }
Room* RoomLoader::LoadRoom( const std::string& aRoomName ) { Tmx::Map map; map.ParseFile(aRoomName); if (map.HasError()) { printf("error code: %d\n", map.GetErrorCode()); printf("error text: %s\n", map.GetErrorText().c_str()); return NULL; } Room* room = new Room(GetLayer(map, "background"), GetLayer(map, "middle"), GetLayer(map, "foreground")); std::vector<Entity*> entities = GetEntities(map, "entities"); float2 topleft(0,0); float2 bottomright((map.GetWidth()) * map.GetTileWidth(), (map.GetHeight()) * map.GetTileHeight()); std::vector<std::pair<float2, float2>> rects = GetCameraRects(map, "camera"); room->setCameraRect(topleft, bottomright); room->setCamera(new Camera(rects)); for (unsigned int i = 0; i < entities.size(); i++) { room->addEntity(entities[i]); } return room; }
std::vector<std::pair<float2, float2>> GetCameraRects( const Tmx::Map& aMap, std::string aObjectGroupName) { std::vector<std::pair<float2, float2>> result; const std::vector< Tmx::ObjectGroup* >& objectGroups = aMap.GetObjectGroups(); for (unsigned int i = 0; i < objectGroups .size(); i++) { if (objectGroups[i]->GetName() != aObjectGroupName) continue; const std::vector< Tmx::Object* >& objects = objectGroups[i]->GetObjects(); for (unsigned int j = 0; j < objects.size(); j++) { const Tmx::Object* object = objects[j]; float2 topleft(object->GetX(), object->GetY()); float2 botright = topleft + float2(object->GetWidth(), object->GetHeight()); std::pair<float2, float2> rect(topleft, botright); result.push_back(rect); } } return result; }
void FuncTest::inout_rectTest() { std::vector<cv::KeyPoint> keypoints; keypoints.push_back(cv::KeyPoint(10, 10, 1)); keypoints.push_back(cv::KeyPoint(21.5, 10, 1)); keypoints.push_back(cv::KeyPoint(50, 10, 1)); keypoints.push_back(cv::KeyPoint(10, 29.3, 1)); keypoints.push_back(cv::KeyPoint(31.1, 55.7, 1)); keypoints.push_back(cv::KeyPoint(50, 38.2, 1)); keypoints.push_back(cv::KeyPoint(10, 70, 1)); keypoints.push_back(cv::KeyPoint(41.12, 70, 1)); keypoints.push_back(cv::KeyPoint(50, 70, 1)); keypoints.push_back(cv::KeyPoint(100.1, 75.58, 1)); cv::Point2f topleft(10.0,10.0); cv::Point2f bottomright(50.0,70.0); std::vector<cv::KeyPoint> in; std::vector<cv::KeyPoint> out; inout_rect(keypoints, topleft, bottomright, in, out); std::vector<cv::KeyPoint> in_test; std::vector<cv::KeyPoint> out_test; out_test.push_back(cv::KeyPoint(10, 10, 1)); out_test.push_back(cv::KeyPoint(21.5, 10, 1)); out_test.push_back(cv::KeyPoint(50, 10, 1)); out_test.push_back(cv::KeyPoint(10, 29.3, 1)); in_test.push_back(cv::KeyPoint(31.1, 55.7, 1)); out_test.push_back(cv::KeyPoint(50, 38.2, 1)); out_test.push_back(cv::KeyPoint(10, 70, 1)); out_test.push_back(cv::KeyPoint(41.12, 70, 1)); out_test.push_back(cv::KeyPoint(50, 70, 1)); out_test.push_back(cv::KeyPoint(100.1, 75.58, 1)); QCOMPARE(in.size(), in_test.size()); QCOMPARE(out.size(), out_test.size()); }
RectangleD MenuBar::getLabelFrame(const RectD&bounds) const { RectangleD frame = getFrame(); Vector2d topleft(bounds.left*frame.width, bounds.top*frame.height); Vector2d bottomright(bounds.right*frame.width, bounds.bottom*frame.height); return RectangleD(frame.x+topleft.x, frame.y+topleft.y, bottomright.x-topleft.x, bottomright.y-topleft.y); }
void MovableSquare::clear(ProjectionWindow &pw) { // no idea why small single pixel border left when clearing a box size+=4; int hsize = size / 2; COORD topleft((center.x-hsize), (center.y-hsize)); pw.draw_box(topleft, size, size, background, true); size-=4; };
void MovableSquare::paint(ProjectionWindow &pw) { // since we are a square with equal height and width, our proportion will be to height+width/2 of the // projection window size = (int) (double(prop.convert_width(pw.dimensions.width) + prop.convert_height(pw.dimensions.height)) / 2.0); int hsize = size / 2; COORD topleft((center.x-hsize), (center.y-hsize)); pw.draw_box(topleft, size, size, color, true); };
QRect Waveform::scopeRect() { // Distance from top/left/right int offset = 6; QPoint topleft(offset, ui->verticalSpacer->geometry().y()+offset); return QRect(topleft, this->size() - QSize(offset+topleft.x(), offset+topleft.y())); }
void CTransform::RAllTransform(GraphTypes::RectF &p) const { /* RDpiTransform(p); RTranslateTransform(p); RScaleTransform(p); RRotateTransform(p); RSpacingTransform(p); */ GraphTypes::PointF topleft(p.x, p.y); p.x=im11 * topleft.x + im12 * topleft.y + im13; p.y=im21 * topleft.x + im22 * topleft.y + im23; p.Width*=ism11; p.Height*=ism22; }
void UserDesktopWidget::paintEvent(QPaintEvent *p) { UserImageWidget::paintEvent(p); if(!m_cursorpos.isNull()) { QPainter painter(this); QPoint topleft(m_cursorpos.x() - m_img_offset.x() + m_paint_offset.x() - 3, m_cursorpos.y() - m_img_offset.y() + m_paint_offset.y() - 3); QRect r(topleft, QSize(5, 5)); painter.drawRect(r); topleft.setX(topleft.x() + 1); topleft.setY(topleft.y() + 1); r = QRect(topleft, QSize(4, 4)); painter.fillRect(r, QBrush(QColor(128,255,86))); } }
QStringList ImageInstance::getAnnotations() { QString topleft("Im: %1 Se: %3\n%4%5Scalor: 100mm"); QString topright("%1\n%2 %3/%4\n%5"); QString bottomleft("%1\n%2"); QString bottomright("%1 mAs %2 kV\n%3\n%4"); topleft = topleft.arg(instanceNumber, seriesNumber, studyDes.isEmpty()?studyDes:QString("\n").prepend(studyDes), seriesDes.isEmpty()?seriesDes:QString("\n").prepend(seriesDes)); topright = topright.arg(patientName, patientID, patientSex, patientAge, patientBirth.toString("yyyy/M/d")); bottomleft = bottomleft.arg(procId.isEmpty()?bodyPart:procId, manufacturer); bottomright = bottomright.arg(QString::number(mAs), QString::number(kvp), acquisitionTime.toString("yyyy/M/d hh:mm:ss"), institution); return QStringList() << topleft << topright << bottomleft << bottomright; }
void KoUniColorChooser::updateSelectorsB() { //kDebug(30004)() <<"B selected"; quint8 data[4]; data[2] = 0; data[1] = 255; data[0] = m_BIn->value(); data[3] = 255; KoColor topleft(data, rgbColorSpace()); data[2] = 255; data[1] = 255; KoColor topright(data, rgbColorSpace()); data[2] = 0; data[1] = 0; KoColor bottomleft(data, rgbColorSpace()); data[2] = 255; data[1] = 0; KoColor bottomright(data, rgbColorSpace()); m_xycolorselector->setColors(topleft,topright,bottomleft,bottomright); data[2] = m_RIn->value(); data[1] = m_GIn->value(); data[0] = 0; KoColor mincolor(data, rgbColorSpace()); data[0] = 255; KoColor maxcolor(data, rgbColorSpace()); m_colorSlider->setColors(mincolor, maxcolor); m_xycolorselector->blockSignals(true); m_colorSlider->blockSignals(true); m_xycolorselector->setValues(m_RIn->value(), m_GIn->value()); m_colorSlider->setValue(m_BIn->value()); m_xycolorselector->blockSignals(false); m_colorSlider->blockSignals(false); }
void openTableImageGroup::draw() { float current_rotation = m_rotation - 45.0; float rotation_inc = 90.0 / m_images.size(); ofPath path; ofPoint axis( 0, 0, 1.0); for ( int i = 0; i < m_images.size(); i++ ) { if ( m_images[ i ].isLoaded() ) { ofPushMatrix(); ofPoint dim(m_images[ i ].m_image->getWidth(),m_images[ i ].m_image->getHeight()); float scale = MIN(160./dim.x, 120./dim.y); dim *= scale; ofTranslate( m_position ); ofRotate( current_rotation ); m_images[ i ].m_image->draw( 0, 0, dim.x, dim.y ); ofPopMatrix(); // // update outline path // dim /= 2.; ofPoint topleft( -dim.x, -dim.y ); ofPoint topright( dim.x, -dim.y ); ofPoint bottomright( dim.x, dim.y ); ofPoint bottomleft( -dim.x, dim.y ); topleft.rotate(current_rotation, axis); topleft += m_position; topright.rotate(current_rotation, axis); topright += m_position; bottomright.rotate(current_rotation, axis); bottomright += m_position; bottomleft.rotate(current_rotation, axis); bottomleft += m_position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); // // // current_rotation += rotation_inc; } } if ( m_annotation.length() > 0 ) { ofApp* app = ( ofApp* ) ofGetAppPtr(); //ofRectangle bounds = app->m_default_font.getStringBoundingBox(m_annotation, 0, 0, 24.); ofRectangle bounds = app->m_default_font.getBBox(m_annotation, 24., 0, 0); ofPoint dim( bounds.width, bounds.height ); ofPushStyle(); ofPushMatrix(); ofTranslate( m_position ); ofRotate( m_rotation ); ofTranslate( -( dim.x/2. ), 120.0 ); ofSetColor(255, 255, 255, 127); ofRect( -8, -( dim.y / 2 + 16 ), dim.x + 16, dim.y + 16 ); ofSetColor(ofColor::black); //app->m_default_font.drawString(m_annotation, 0, 0, 24.); app->m_default_font.draw(m_annotation, 24., 0, 0); ofPopMatrix(); ofPopStyle(); // // add to outline // ofPoint position = m_position; dim.x += 16; dim.y += 16; dim /= 2.; ofPoint topleft( -dim.x, -dim.y + 112. ); ofPoint topright( dim.x, -dim.y + 112. ); ofPoint bottomright( dim.x, dim.y + 112. ); ofPoint bottomleft( -dim.x, dim.y + 112. ); topleft.rotate(m_rotation, axis); topleft += position; topright.rotate(m_rotation, axis); topright += position; bottomright.rotate(m_rotation, axis); bottomright += position; bottomleft.rotate(m_rotation, axis); bottomleft += position; path.newSubPath(); path.moveTo( topleft ); path.lineTo( topright ); path.lineTo( bottomright ); path.lineTo( bottomleft ); path.close(); } // // convert path to polyline for hit test // m_hit_lock.lock(); m_outline = path.getOutline(); m_hit_lock.unlock(); /* ofPushStyle(); path.setStrokeWidth( 1 ); path.setStrokeColor( ofColor::red ); path.setFillColor( ofColor( 255, 0, 0, 128 ) ); path.draw(); ofSetColor( ofColor::green ); ofNoFill(); for ( auto& poly : m_outline ) { poly.draw(); } ofPopStyle(); */ }
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { removeChildren(); v2s32 size(620, 430); core::rect < s32 > rect(screensize.X / 2 - size.X / 2, screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, screensize.Y / 2 + size.Y / 2); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 topleft(0, 0); { core::rect < s32 > rect(0, 0, 600, 40); rect += topleft + v2s32(25, 3); //gui::IGUIStaticText *t = const wchar_t *text = wgettext("Keybindings. (If this menu screws up, remove stuff from minetest.conf)"); Environment->addStaticText(text, rect, false, true, this, -1); delete[] text; //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } // Build buttons v2s32 offset(25, 60); for(size_t i = 0; i < key_settings.size(); i++) { key_setting *k = key_settings.at(i); { core::rect < s32 > rect(0, 0, 110, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(k->button_name, rect, false, true, this, -1); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 115, offset.Y - 5); const wchar_t *text = wgettext(k->key.name()); k->button = Environment->addButton(rect, this, k->id, text); delete[] text; } if(i + 1 == KMaxButtonPerColumns) offset = v2s32(260, 60); else offset += v2s32(0, 25); } { s32 option_x = offset.X; s32 option_y = offset.Y + 5; u32 option_w = 180; { core::rect<s32> rect(0, 0, option_w, 30); rect += topleft + v2s32(option_x, option_y); const wchar_t *text = wgettext("\"Use\" = climb down"); Environment->addCheckBox(g_settings->getBool("aux1_descends"), rect, this, GUI_ID_CB_AUX1_DESCENDS, text); delete[] text; } offset += v2s32(0, 25); } { s32 option_x = offset.X; s32 option_y = offset.Y + 5; u32 option_w = 280; { core::rect<s32> rect(0, 0, option_w, 30); rect += topleft + v2s32(option_x, option_y); const wchar_t *text = wgettext("Double tap \"jump\" to toggle fly"); Environment->addCheckBox(g_settings->getBool("doubletap_jump"), rect, this, GUI_ID_CB_DOUBLETAP_JUMP, text); delete[] text; } offset += v2s32(0, 25); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); const wchar_t *text = wgettext("Save"); Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, text); delete[] text; } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); const wchar_t *text = wgettext("Cancel"); Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, text); delete[] text; } }
void Viewport::adjustBoundaries() { QPointF empty(0.f, 0.f); empty = modelview.map(empty); QPointF leftbound = empty; leftbound.setX(0.f); QPointF lb = modelview.map(leftbound); QPointF rightbound = empty; SharedDataLock ctxlock(ctx->mutex); rightbound.setX((*ctx)->dimensionality - 1); QPointF rb = modelview.map(rightbound); QPointF bottombound = empty; bottombound.setY(0.f); QPointF bb = modelview.map(bottombound); QPointF topbound = empty; topbound.setY((float)((*ctx)->nbins)); QPointF tb = modelview.map(topbound); qreal lbpos = yaxisWidth + 25; qreal rbpos = width - 15; qreal bbpos = height - boundaries.vp - boundaries.vtp; qreal tbpos = boundaries.vp; // qDebug() << "LEFT BOUND " << lb // << "RIGHT BOUND " << rb // << "BOTTOM BOUND " << bb // << "TOP BOUND " << tb; qreal xp = 0; qreal yp = 0; if (lb.x() > lbpos) { //qDebug() << "LEFT BOUND IS VISIBLE!"; QPointF topleft(lbpos, 0.f); topleft = modelviewI.map(topleft); xp = topleft.x(); } else if (rb.x() < rbpos) { //qDebug() << "RIGHT BOUND IS VISIBLE!"; QPointF right(rbpos, 0.f); right = modelviewI.map(right); rb = modelviewI.map(rb); xp = right.x()-rb.x(); } if (bb.y() < bbpos) { //qDebug() << "BOTTOM BOUND IS VISIBLE!"; QPointF bottom(0.f, bbpos); bottom = modelviewI.map(bottom); bb = modelviewI.map(bb); yp = bottom.y()-bb.y(); } else if (tb.y() > tbpos) { //qDebug() << "TOP BOUND IS VISIBLE!"; QPointF top(0, tbpos); top = modelviewI.map(top); tb = modelviewI.map(tb); yp = top.y()-tb.y(); } modelview.translate(xp, yp); modelviewI = modelview.inverted(); }
void CPredView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default CScrollView::OnMouseMove(nFlags, point); int i; CClientDC dc(this); OnPrepareDC(&dc); POINT m_point; CFCCDoc* pDoc=(CFCCDoc*)GetDocument(); m_point.x=point.x; m_point.y=point.y; dc.DPtoLP(&m_point); CRgn rgn; bHitCaption=false; for(i=0;i<nCol;i++) { if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1) { CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30); CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { //pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); } } if(bHitCaption) { if(bOldMouseInCaption==false && pDoc->list_CompoundTest.GetCount()>0) { if(SortAscend) ::SetCursor(cursorAscend); else ::SetCursor(cursorDescend); bOldMouseInCaption=true; //TRACE("hit caption change cursor\n"); } } else { //if(bOldMouseInCaption==true) { ::SetCursor(::LoadCursor(NULL,IDC_ARROW)); bOldMouseInCaption=false; //TRACE("not hit caption change cursor\n"); } } // TODO: Add your message handler code here }
void CPredView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default /*HCURSOR hCursor=AfxGetApp()->LoadCursorA(IDC_DESCEND); if(hCursor==NULL) TRACE("Invaidate cursor\n"); SetCursor(hCursor);*/ TRACE("%d\n",nFlags); CClientDC dc(this); OnPrepareDC(&dc); POINT m_point; CFCCDoc* pDoc=(CFCCDoc*)GetDocument(); m_point.x=point.x; m_point.y=point.y; dc.DPtoLP(&m_point); CRgn rgn; int i,j; int selCol=-1; int selRow=-1; for(i=0;i<nCol;i++) { bool bHitCaption=false; if(wnd_navi.nCurPage<wnd_navi.nTotalPage || (wnd_navi.nCurPage-1)*nCol+i+1 <= (pDoc->list_CompoundTest.GetCount()-1)/nItemPage+1) { CPoint topleft(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),30); CPoint bottomright(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_ID,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+10,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+10,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_NAME,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); topleft.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+20,30); bottomright.SetPoint(60+i*(80+widthCompoundName+widthYhat+widthClassName+widthID)+widthID+widthCompoundName+widthClassName+widthYhat+30,50); rgn.CreateRectRgn(topleft.x,topleft.y,bottomright.x,bottomright.y); if(rgn.PtInRegion(m_point)) { pDoc->MergeSort(SORT_BY_VALUE,SortAscend,pDoc->list_CompoundTest); bHitCaption=true; } rgn.DeleteObject(); } if(bHitCaption) { TRACE("LButton down caption\n"); Invalidate(); UpdateWindow(); SortAscend=1-SortAscend; if(SortAscend) ::SetCursor(cursorAscend); else ::SetCursor(cursorDescend); bOldMouseInCaption=true; } for(j=0;j<nItemPage;j++) { rgn.CreateRectRgn(50+i*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*j, 20+(i+1)*(80+widthCompoundName+widthYhat+widthClassName+widthID),50+20*(j+1)); if(rgn.PtInRegion(m_point)) { selCol=i; selRow=j; } rgn.DeleteObject(); } } if(selCol>=0 && selRow>=0) { dlg.nIndex=(wnd_navi.nCurPage-1)*(nCol*nItemPage)+selCol*nItemPage+selRow+1; if(nFlags&MK_CONTROL) SendMessage(WM_FINDCOMPOUND,GOTOLINE,2); else SendMessage(WM_FINDCOMPOUND,GOTOLINE,1); } else { if(nFlags!=MK_CONTROL) { POSITION pos; pos=pDoc->list_CompoundTest.GetHeadPosition(); while(pos) { pCompound=(CCompound*)pDoc->list_CompoundTest.GetNext(pos); ((CCompound*)pCompound)->bSelect=false; } } Invalidate(0); } CScrollView::OnLButtonDown(nFlags, point); }
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ v2s32 size(620, 430); core::rect < s32 > rect(screensize.X / 2 - size.X / 2, screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, screensize.Y / 2 + size.Y / 2); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 topleft(0, 0); changeCtype(""); { core::rect < s32 > rect(0, 0, 500, 20); rect += topleft + v2s32(25, 3); //gui::IGUIStaticText *t = Environment->addStaticText(wgettext("KEYBINDINGS (If this menu screws up, see minetest.conf)"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } v2s32 offset(25, 40); // buttons { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Forward"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->forward = Environment->addButton(rect, this, GUI_ID_KEY_FORWARD_BUTTON, wgettext(key_forward.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Backward"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->backward = Environment->addButton(rect, this, GUI_ID_KEY_BACKWARD_BUTTON, wgettext(key_backward.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Left"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, wgettext(key_left.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Right"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->right = Environment->addButton(rect, this, GUI_ID_KEY_RIGHT_BUTTON, wgettext(key_right.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Use"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, wgettext(key_use.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Sneak"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->sneak = Environment->addButton(rect, this, GUI_ID_KEY_SNEAK_BUTTON, wgettext(key_sneak.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Jump"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, wgettext(key_jump.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Drop"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->dropbtn = Environment->addButton(rect, this, GUI_ID_KEY_DROP_BUTTON, wgettext(key_drop.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Inventory"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->inventory = Environment->addButton(rect, this, GUI_ID_KEY_INVENTORY_BUTTON, wgettext(key_inventory.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Chat"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, wgettext(key_chat.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Command"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->cmd = Environment->addButton(rect, this, GUI_ID_KEY_CMD_BUTTON, wgettext(key_cmd.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Console"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->console = Environment->addButton(rect, this, GUI_ID_KEY_CONSOLE_BUTTON, wgettext(key_console.name())); } //next col offset = v2s32(250, 40); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Toggle fly"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, wgettext(key_fly.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Toggle fast"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, wgettext(key_fast.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Range select"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->range = Environment->addButton(rect, this, GUI_ID_KEY_RANGE_BUTTON, wgettext(key_range.name())); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); Environment->addStaticText(wgettext("Print stacks"), rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, wgettext(key_dump.name())); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, wgettext("Save")); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, wgettext("Cancel")); } changeCtype("C"); }
QRect Histogram::scopeRect() { //qDebug() << "According to the spacer, the top left point is " << ui->verticalSpacer->geometry().x() << "/" << ui->verticalSpacer->geometry().y(); QPoint topleft(offset, offset+ ui->verticalSpacer->geometry().y()); return QRect(topleft, this->rect().size() - QSize(topleft.x() + offset, topleft.y() + offset)); }
void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) { /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ v2s32 size(620, 430); core::rect < s32 > rect(screensize.X / 2 - size.X / 2, screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, screensize.Y / 2 + size.Y / 2); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 topleft(0, 0); { core::rect < s32 > rect(0, 0, 125, 20); rect += topleft + v2s32(25, 3); const wchar_t *text = L"KEYBINDINGS"; //gui::IGUIStaticText *t = Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } v2s32 offset(25, 40); // buttons { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Forward"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->forward = Environment->addButton(rect, this, GUI_ID_KEY_FORWARD_BUTTON, narrow_to_wide(KeyNames[key_forward]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Backward"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->backward = Environment->addButton(rect, this, GUI_ID_KEY_BACKWARD_BUTTON, narrow_to_wide(KeyNames[key_backward]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Left"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, narrow_to_wide(KeyNames[key_left]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Right"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->right = Environment->addButton(rect, this, GUI_ID_KEY_RIGHT_BUTTON, narrow_to_wide(KeyNames[key_right]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Use"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, narrow_to_wide(KeyNames[key_use]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Sneak"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->sneak = Environment->addButton(rect, this, GUI_ID_KEY_SNEAK_BUTTON, narrow_to_wide(KeyNames[key_sneak]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Jump"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, narrow_to_wide(KeyNames[key_jump]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Inventory"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->inventory = Environment->addButton(rect, this, GUI_ID_KEY_INVENTORY_BUTTON, narrow_to_wide(KeyNames[key_inventory]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Chat"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, narrow_to_wide(KeyNames[key_chat]).c_str()); } //next col offset = v2s32(250, 40); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Toggle fly"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, narrow_to_wide(KeyNames[key_fly]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Toggle fast"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, narrow_to_wide(KeyNames[key_fast]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Range select"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->range = Environment->addButton(rect, this, GUI_ID_KEY_RANGE_BUTTON, narrow_to_wide(KeyNames[key_range]).c_str()); } offset += v2s32(0, 25); { core::rect < s32 > rect(0, 0, 100, 20); rect += topleft + v2s32(offset.X, offset.Y); const wchar_t *text = L"Print stacks"; Environment->addStaticText(text, rect, false, true, this, -1); //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(offset.X + 105, offset.Y - 5); this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, narrow_to_wide(KeyNames[key_dump]).c_str()); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, L"Save"); } { core::rect < s32 > rect(0, 0, 100, 30); rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, L"Cancel"); } }
void CGetBlackOutDlg::OnMouseDown( UINT nflags, CPoint point) { if (mWon) return; int x,y,cx,cy,i,piece; x=y=cx=cy=piece=0; for(i = 0 ; i < mBoard.numpieces(); i++) { x = mBoard.pborder() + (mBoard.piece(i)->xpos() * (mBoard.pper() + mBoard.pborder())); y = mBoard.pborder() + (mBoard.piece(i)->ypos() * (mBoard.pper() + mBoard.pborder())); cx = (mBoard.piece(i)->width() * mBoard.pper()); if (mBoard.piece(i)->width() == 2) cx += mBoard.pborder(); cy = (mBoard.piece(i)->height() * mBoard.pper()); if (mBoard.piece(i)->height() == 2) cy += mBoard.pborder(); CRect piecerect(x,y,x+cx,y+cy); if (piecerect.PtInRect(point)) { piece=i; i=mBoard.numpieces(); mMoving = TRUE; mMouseStartPoint = point; mPieceMoving = piece; break; } } int moves = 0; if (mMoving) { int x,y,sx,sy,sx2,sy2; x=y=sx=sy=sx2=sy2=0; x = -mBoard.pper(); y = 0; if (mBoard.canmove(mPieceMoving,x,y)) { moves++; sx=x;sy=y; } x = mBoard.pper(); y = 0; if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } x = 0; y = mBoard.pper(); if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } x = 0; y = -mBoard.pper(); if (mBoard.canmove(mPieceMoving,x,y)) { moves++; if (moves < 2) { sx=x;sy=y; } else { sx2=x;sy2=y; } } if (moves == 1) { CPoint delta(point); delta += CPoint(sx,sy); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if (moves == 2) { CRect piecerect(mBoard.piece(mPieceMoving)->mPieceRect); int deltax, deltay;deltax=deltay=0; if (abs(sx) == mBoard.pper() && abs(sx2) == mBoard.pper()) { CRect lhalf(piecerect); CRect rhalf(piecerect); lhalf.BottomRight().x -= lhalf.Width() / 2; rhalf.TopLeft().x = lhalf.BottomRight().x; if (lhalf.PtInRect(point)) { deltax = sx2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if (abs(sy) == mBoard.pper() && abs(sy2) == mBoard.pper()) { CRect thalf(piecerect); CRect bhalf(piecerect); thalf.BottomRight().y -= thalf.Height() / 2; bhalf.TopLeft().y = thalf.BottomRight().y; if (thalf.PtInRect(point)) { deltay = sy; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == mBoard.pper() && sy2 == mBoard.pper() || sx2 == mBoard.pper() && sy == mBoard.pper() ) { if (distance(topright(piecerect),point) < distance(point, bottomleft(piecerect))) { deltay = sy2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == -mBoard.pper() && sy2 == mBoard.pper() || sx2 == -mBoard.pper() && sy == mBoard.pper() ) { if (distance(topleft(piecerect),point) < distance(point, bottomright(piecerect))) { deltay = sy2; } else { deltax = sx; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == mBoard.pper() && sy2 == -mBoard.pper() || sx2 == mBoard.pper() && sy == -mBoard.pper() ) { if (distance(topleft(piecerect),point) < distance(point, bottomright(piecerect))) { deltax = sx; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } else if ( sx == -mBoard.pper() && sy2 == -mBoard.pper() || sx2 == -mBoard.pper() && sy == -mBoard.pper() ) { if (distance(topright(piecerect),point) < distance(point, bottomleft(piecerect))) { deltax = sx; } else { deltay = sy2; } CPoint delta(point); delta += CPoint(deltax,deltay); OnMouseMove(0, delta); OnMouseUp(0,CPoint()); } } } }