void ChessBoard::mousePressEvent(QMouseEvent *e) { //QMessageBox::information(this, tr("JJJJ"), tr("OKKKK")); if(mRunning) { int x = e->x(); int y = e->y(); int r, c; c = (x-5)/38; r = (y-5)/38; // QMessageBox::information(this, tr("JJJ"), tr("%1...%2").arg(r).arg(c)); if(chess[r][c] == 2) { chess[r][c] = mTurn; if(Place(r, c)) { update(); mTurn = 1-mTurn; //change role emit ChangeNum(GetNum(0), GetNum(1)); ChangeCursor(); } else { chess[r][c] = 2; } } } }
void CMiscToolbar::OnClickedFiles() { if (RDialog::m_pView->m_currentpage != 0) //RJS 29Oct00 return; //RJS 29Oct00 typedef HideEdgeControl EDGE; CString wildcard="*.bs"; CFiling::selectedfile=Save_Data.lastsavegame; if (Todays_Packages.localplayer==NAT_RAF) wildcard+="R"; else wildcard+="L"; // CFiling::selectedfile="test.sav"; if (!LoggedChild(FILES)) { LogChild(FILES, RDialog::MakeTopDialog(Place(POSN_CENTRE,POSN_CENTRE), DialList(DialBox(FIL_NULL/*IDB_BBC3*/,new CFiling,Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE)), //rdh HTabBox(FIL_NULL,IdList(IDS_SAVE,IDS_LOAD),Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX,EDGE::ALIGN_MAX), DialBox(FIL_D_BLANK/*IDB_BBC3*/,new CLoad(IDDX_SAVE,LSD_SAVE, FIL_SAVEGAMEDIR,wildcard,CFiling::selectedfile)), DialBox(FIL_D_BLANK/*IDB_BBC3*/,new CLoad(IDDX_LOAD,LSD_LOAD_DESELECT,FIL_SAVEGAMEDIR,wildcard,CFiling::selectedfile)) ) ) ) ); } else CloseLoggedChild(FILES); }
/* virtual */ nsresult nsMathMLmpaddedFrame::MeasureForWidth(DrawTarget* aDrawTarget, ReflowOutput& aDesiredSize) { ProcessAttributes(); return Place(aDrawTarget, false, aDesiredSize); }
void JXStringCompletionMenu::CompletionRequested ( const JSize prefixLength ) { itsRequestCount++; if (itsRequestCount > 1 && !IsEmpty()) { itsPrefixLength = prefixLength; // prepend "insert tab character" option JString s; if (itsAllowTabChar && (!GetItemShortcuts(1, &s) || s != kInsertTabShortcut)) { PrependItem(kInsertTabStr, kPlainType, kInsertTabShortcut); } // place it next to the caret (use the character in front of the caret) const JIndex charIndex = itsTE->GetInsertionIndex() - 1; const JCoordinate x = itsTE->GetCharRight(charIndex) + 2; const JIndex lineIndex = itsTE->GetLineForChar(charIndex); const JCoordinate y = itsTE->GetLineTop(lineIndex) - GetFrameHeight(); Place(x,y); // open it HandleShortcut('\t', JXKeyModifiers(GetDisplay())); } }
void MAS::Window::Maximize() { if (extraFlags & W_MINIMIZED) { return; } if (!(extraFlags & W_MAXIMIZED)) { restoreRect = (*this); extraFlags |= W_MAXIMIZED; iconMax.SetBitmap(Skin::ICONRESTORE); Place(GetParent()->topLeft()); Resize(GetParent()->size()); iconMax.SetSample(Skin::SAMPLE_CLOSE, Skin::SAMPLE_ACTIVATE); iconMin.SetSample(Skin::SAMPLE_ACTIVATE, Skin::SAMPLE_ACTIVATE); } else { extraFlags &= ~W_MAXIMIZED; iconMax.SetBitmap(Skin::ICONMAX); Shape(restoreRect); iconMax.SetSample(Skin::SAMPLE_OPEN, Skin::SAMPLE_ACTIVATE); iconMin.SetSample(Skin::SAMPLE_ACTIVATE, Skin::SAMPLE_ACTIVATE); } MsgShape(); }
/* virtual */ nsresult nsMathMLmpaddedFrame::MeasureForWidth(nsRenderingContext& aRenderingContext, nsHTMLReflowMetrics& aDesiredSize) { ProcessAttributes(); return Place(aRenderingContext, false, aDesiredSize); }
//=================================================================================================== // Интересует только попадание в центральное окно //=================================================================================================== bool BKBTurtle::IsItYours(POINT *_pnt) { // Попала ли точка в границы окна? POINT pnt=*_pnt; RECT crect; GetClientRect(hwndCenter,&crect); ScreenToClient(hwndCenter,&pnt); if((pnt.x>=0)&&(pnt.x<crect.right)&&(pnt.y>=0)&&(pnt.y<crect.bottom)) { if(swap_step<2) // Добавть точку на экран { swap_step++; } else // Можно менять расположение { swap_step=0; if(flag_right_bottom) flag_right_bottom=0; else flag_right_bottom=1; Place(); } InvalidateRect(hwndCenter,NULL,FALSE); return true; } return false; }
void BackTrack() { int k; x[1] = 0; //初始化为0 k = 1; while (k >= 1) //循环 { x[k] += 1; //先放在第一个位置 while ((x[k] <= n) && !(Place(k))) //如果不能放 x[k] += 1; //放在下一个位置 if (x[k] <= n) //放置完成 { if (k == n) //如果已经放完了n个皇后 { sum++; //处理次数,输出 OutPut(); } else //没有处理完,让k自加,处理下一个皇后 { k++; x[k] = 0; } } //x[k] > n,说明没有合适的位置了 else k--; //回溯回去,回到第k-1步 } }
/** * Prepare a picture for display */ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture) { vout_display_sys_t *sys = vd->sys; if (!sys->dither) { /* Create the libcaca dither object */ sys->dither = cucul_create_dither(32, vd->source.i_visible_width, vd->source.i_visible_height, picture->p[0].i_pitch, vd->fmt.i_rmask, vd->fmt.i_gmask, vd->fmt.i_bmask, 0x00000000); if (!sys->dither) { msg_Err(vd, "could not create libcaca dither object"); return; } } vout_display_place_t place; Place(vd, &place); cucul_set_color_ansi(sys->cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_BLACK); cucul_clear_canvas(sys->cv); const int crop_offset = vd->source.i_y_offset * picture->p->i_pitch + vd->source.i_x_offset * picture->p->i_pixel_pitch; cucul_dither_bitmap(sys->cv, place.x, place.y, place.width, place.height, sys->dither, &picture->p->p_pixels[crop_offset]); VLC_UNUSED(subpicture); }
int main(int argc, char* argv[]) { int i, j, Square; for (i = 0; i < 9; i++) for (j = 0; j < 9; j++) { Square = 9 * i + j; InRow[Square] = i; InCol[Square] = j; InBlock[Square] = (i / 3) * 3 + ( j / 3); } for (Square = 0; Square < 81; Square++) { Sequence[Square] = Square; Entry[Square] = BLANK; LevelCount[Square] = 0; } for (i = 0; i < 9; i++) Block[i] = Row[i] = Col[i] = ONES; ConsoleInput(); Place(SeqPtr); printf("\n\nTotal Count = %d\n", Count); return 0; }
void MonoScene::Resize() { if (output != nil && GetCanvasType() != CanvasInputOnly) { canvas->SetBackground(output->GetBgColor()); } if (interior_ != nil) { Place(interior_, 0, 0, xmax, ymax); } }
void InsertionSort (int data [], int Size, int sorted) // Special Massive: {1, 3, 6, 14, 23, 43, 46, 13, 32, 10, 17, 8, 5} { while (sorted < Size - 1) { int start = sorted + 1; ROR (data, Place (data, Size, sorted), start); sorted ++; } printf (" %d ", data); }
bool TechTreeLayout::Column::Move(int to, TechTreeLayout::Node* node) { if (Fit(to, node)) { for ( int i = node->m_row + node->GetWeight(); i-->node->m_row; ) m_column[i] = 0; Place(to, node); return true; } return false; }
void TrollingModel::initialize() { m_DBLayer = new DBLayer(m_filePath+"/database"); connect(m_DBLayer, SIGNAL(storeSignal(int, QString)), &m_journal, SLOT(addJournal(int, QString))); connect(&m_synchronizer, SIGNAL(uploadDone()), this, SLOT(resetJournal())); qDebug() << "start loading"; m_DBLayer->loadObjects(Lure().getType(), &m_factory); m_DBLayer->loadObjects(Trip().getType(), &m_factory); m_DBLayer->loadObjects(Place().getType(), &m_factory); qDebug() << "finished loading"; }
void BtKt(int r, int n){ if( r>n ){ /*for(int i=1; i<=n; i++) printf("%d ", x[i]); printf("\n");*/ return; } for(int c=1; c<=n; c++){ if( Place(r, c) ){ x[r] = c; BtKt(r+1, n); } } }
void CMiscToolbar::OpenSaveOnly(bool quitafter) { typedef HideEdgeControl EDGE; CString wildcard="*.sav"; CFiling::selectedfile=Save_Data.lastsavegame; if (!LoggedChild(FILES)) LogChild(FILES, RDialog::MakeTopDialog(Place(POSN_CENTRE,POSN_CENTRE), DialList(DialBox(FIL_NULL/*IDB_BBC3*/,new CFiling(true),Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE)), //rdh HTabBox(FIL_NULL,IdList(IDS_QUITSAVE),Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX,EDGE::ALIGN_MAX), DialBox(FIL_MAP_PLAYER_LOG/*IDB_BBC3*/,new CLoad(IDD_SAVE,LSD_SAVE, FIL_SAVEGAMEDIR,wildcard,CFiling::selectedfile)) ) ) ) ); else ;//bring to front... }
void VBox::PlaceElement (Interactor* i, Coord y, int length, int size, int w) { Coord x1, y1, x2, y2; if (align == Right) { x1 = size - w; } else if (align == Center) { x1 = (size - w) / 2; } else /* Left */ { x1 = 0; } x2 = x1 + w - 1; y2 = ymax - y; y1 = y2 - length + 1; Place(i, x1, y1, x2, y2); }
/** * 算法6.16,八皇后问题求解 * 进入本函数时,在n*n棋盘前i-1行已放置了互不攻击的i-1个棋子 * 现从第i行起继续为后续棋子选择合适位置 * 当i>n时,求得一个合法布局,输出之 */ void Queen(int i, int n) //i从1开始 { if (i > n) show_chess(n); //输出棋盘当前布局 else { for (int j = 1; j <= n; j++) { Place(i, j); //在第i行第j列放置一个棋子 if (illigal(i)) //若当前布局合法 Queen(i + 1, n); Remove(i, j); //移走第i行第j列的棋子 } } }
void HBox::PlaceElement (Interactor* i, Coord x, int length, int size, int h) { Coord x1, y1, x2, y2; x1 = x; if (align == Top) { y1 = size - h; } else if (align == Center) { y1 = (size - h) / 2; } else /* Bottom */ { y1 = 0; } x2 = x1 + length - 1; y2 = y1 + h - 1; Place(i, x1, y1, x2, y2); }
void CMiscToolbar::OnClickedThumbnail() { typedef HideEdgeControl EDGE; if (!LoggedChild(THUMBNAIL)) { CMIGView::m_thumbnail=new CThumbnail; LogChild(THUMBNAIL, RDialog::MakeTopDialog( //CRect(140,140,0,0), Place(POSN_MIN,POSN_MIN), DialBox(FIL_NULL,CMIGView::m_thumbnail,Edges(EDGE::ALIGN_MIN + EDGE::ACTIONS_SPLITTER,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE)) ) ); } else CloseLoggedChild(THUMBNAIL); }
bool Place(const typename Content<_T>::Vector &contentVector, typename Content<_T>::Vector &remainder) { bool placedAll = true; for( typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++ ) { const Content<_T> & content = *itor; if( Place( content ) == false ) { placedAll = false; remainder.push_back( content ); } } return placedAll; }
MonoScene::MonoScene (Sensor* in, Painter* out) : (in, out) { component = nil; } MonoScene::~MonoScene () { if (component != nil) { delete component; } } void MonoScene::DoInsert (Interactor* i, boolean, Coord&, Coord&) { if (component != nil) { delete component; } component = i; } void MonoScene::DoChange (Interactor*) { Reconfig(); } void MonoScene::DoRemove (Interactor*) { component = nil; } void MonoScene::Reconfig () { if (component != nil) { *shape = *component->GetShape(); } } void MonoScene::Resize () { if (output != nil) { canvas->SetBackground(output->GetBgColor()); } if (component != nil) { Place(component, 0, 0, xmax, ymax); } } void MonoScene::Draw () { Scene::Draw(); if (component != nil) { component->Draw(); } }
void BackTrack1(int t) { //如果t>n说明已经完成一次放置 if (t > n) { sum++; OutPut(); } else { for (int i = 1; i <= n; ++i) { x[t] = i; if (Place(t)) //可以放在i位置处,则继续搜索 BackTrack1(t + 1); } } }
void Camera::Place(D3DCUBEMAP_FACES face) { D3DXVECTOR3 center = STATE_GET(Render)->GetModelCenter(); float radius = 2.5f*STATE_GET(Render)->GetModelRadius(); D3DXVECTOR3 eye; switch( face ) { case D3DCUBEMAP_FACE_NEGATIVE_X: { eye = D3DXVECTOR3(-radius, 0.0f, 0.0f); } break; case D3DCUBEMAP_FACE_POSITIVE_X: { eye = D3DXVECTOR3(radius, 0.0f, 0.0f); } break; case D3DCUBEMAP_FACE_NEGATIVE_Y: { eye = D3DXVECTOR3(0.0f, -radius, 0.0f); } break; case D3DCUBEMAP_FACE_POSITIVE_Y: { eye = D3DXVECTOR3(0.0f, radius, 0.0f); } break; case D3DCUBEMAP_FACE_NEGATIVE_Z: { eye = D3DXVECTOR3(0.0f, 0.0f, -radius); } break; case D3DCUBEMAP_FACE_POSITIVE_Z: default: { eye = D3DXVECTOR3(0.0f, 0.0f, radius); } break; }; eye = center + eye; Place(eye); }
void CMiscToolbar::OnClickedFiles() { typedef HideEdgeControl EDGE; CString wildcard="*.sav"; CFiling::selectedfile=Save_Data.lastsavegame; // CFiling::selectedfile="test.sav"; if (!LoggedChild(FILES)) { LogChild(FILES, RDialog::MakeTopDialog(Place(POSN_CENTRE,POSN_CENTRE), DialList(DialBox(FIL_NULL/*IDB_BBC3*/,new CFiling,Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE,EDGE::ALIGN_MAX + EDGE::OCCLUDE_INSIDE)), //rdh HTabBox(FIL_NULL,IdList(IDS_SAVE,IDS_LOAD),Edges(EDGE::ALIGN_MIN,EDGE::ALIGN_MIN,EDGE::ALIGN_MAX,EDGE::ALIGN_MAX), DialBox(FIL_MAP_PLAYER_LOG/*IDB_BBC3*/,new CLoad(IDD_SAVE,LSD_SAVE, FIL_SAVEGAMEDIR,wildcard,CFiling::selectedfile)), DialBox(FIL_MAP_PLAYER_LOG/*IDB_BBC3*/,new CLoad(IDD_LOAD,LSD_LOAD_DESELECT,FIL_SAVEGAMEDIR,wildcard,CFiling::selectedfile)) ) ) ) ); } else CloseLoggedChild(FILES); }
void JXScrolltab::PlaceHoriz ( const JCoordinate xmin, const JCoordinate xmax, const JFloat scale ) { JCoordinate x = xmin + JRound(scale * (itsValue - JXScrollbar::kMinValue)); if (x > xmax) { x = xmax; } if (x < xmin) { x = xmin; } Place(x, itsScrollbar->GetBoundsHeight() - kAcrossSize); SetSize(kAlongSize, kAcrossSize); }
void JXScrolltab::PlaceVert ( const JCoordinate ymin, const JCoordinate ymax, const JFloat scale ) { JCoordinate y = ymin + JRound(scale * (itsValue - JXScrollbar::kMinValue)); if (y > ymax) { y = ymax; } if (y < ymin) { y = ymin; } Place(itsScrollbar->GetBoundsWidth() - kAcrossSize, y); SetSize(kAcrossSize, kAlongSize); }
void mc::Terrain::OnEnter( ) { SetHumanPlayer( mc::Allocator::New< mc::Core::Player >( "Gracz 1", CL_Orange ) ); mc::Core::Object* obj = Factory.CreateObject( "Vehicle" );//Factory.RandomObject( ); for(int i = 0 ; i < 1000; ) { if( Place( obj, GetHex( ds::Math::RandomInt( 0, Count ) ) ) ) { obj->SetPlayer( Human ); obj = Factory.RandomObject( ); i++; } } Err << Hex[Count-1].GetCenter().X << ", " << Hex[Count-1].GetCenter().Y << Br; }
void Place(int S) { LevelCount[S]++; Count++; if (S >= 81) { Succeed(); return; } int S2 = NextSeq(S); SwapSeqEntries(S, S2); int Square = Sequence[S]; int BlockIndex = InBlock[Square], RowIndex = InRow[Square], ColIndex = InCol[Square]; int Possibles = Block[BlockIndex] & Row[RowIndex] & Col[ColIndex]; while (Possibles) { int valbit = Possibles & (-Possibles); // Lowest 1 bit in Possibles Possibles &= ~valbit; Entry[Square] = valbit; Block[BlockIndex] &= ~valbit; Row[RowIndex] &= ~valbit; Col[ColIndex] &= ~valbit; Place(S + 1); Entry[Square] = BLANK; // Could be moved out of the loop Block[BlockIndex] |= valbit; Row[RowIndex] |= valbit; Col[ColIndex] |= valbit; } SwapSeqEntries(S, S2); }
//bool Camera::OnKeyboardMsg( UINT nChar, bool bKeyDown, bool bAltDown ) LRESULT Camera::HandleMessages( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch( uMsg ) { case WM_KEYDOWN: { UINT nChar = (UINT)wParam; switch( nChar ) { case VK_HOME: Home(); return true; case L'X': case L'Y': case L'Z': bool key_shiftl = (0x8000 & GetKeyState(VK_LSHIFT)) != 0; bool key_shiftr = (0x8000 & GetKeyState(VK_RSHIFT)) != 0; bool key_shift = key_shiftl || key_shiftr || ((0x8000 & GetKeyState(VK_SHIFT)) != 0); D3DCUBEMAP_FACES face = D3DCUBEMAP_FACE_FORCE_DWORD; if(nChar == L'X') face = key_shift ? D3DCUBEMAP_FACE_NEGATIVE_X : D3DCUBEMAP_FACE_POSITIVE_X; else if(nChar == L'Y') face = key_shift ? D3DCUBEMAP_FACE_NEGATIVE_Y : D3DCUBEMAP_FACE_POSITIVE_Y; else if(nChar == L'Z') face = key_shift ? D3DCUBEMAP_FACE_NEGATIVE_Z : D3DCUBEMAP_FACE_POSITIVE_Z; Place( face ); return true; } } break; }; return __super::HandleMessages( hWnd, uMsg, wParam, lParam ); }