Global void ConvertImage(XImage *image, unsigned int width, unsigned int height, ColormapPtr src_cmap, ColormapPtr dst_cmap) { int x, y; card32 pixel; if (image->depth == 1) return; if (src_cmap == NULL && dst_cmap == NULL) return; if (src_cmap == NULL) { MoveImage(image, image, width, height, dst_cmap, Request); return; } if (dst_cmap == NULL) { MoveImage(image, image, width, height, src_cmap, Reply); return; } for (x = 0; x < width; x++) for (y = 0; y < height; y++) { pixel = XGetPixel(image, x, y); pixel = MapColorCell(pixel, src_cmap, Reply); pixel = MapColorCell(pixel, dst_cmap, Request); XPutPixel(image, x, y, pixel); } }
Move BookReader::pickRandom(const Board &b, const vector< pair<Move,int> > &moves) { int total_weight = 0; const int n = (int)moves.size(); for (int i = 0; i < n; i++) total_weight += moves[i].second; // If total_weight is 0, no moves have non-zero weights. if (total_weight == 0) return NullMove; unsigned nRand = rand() % total_weight; unsigned weight = 0; // Randomly pick from the available moves. Prefer moves // with high weights. for (int i=0; i < n; i++) { int w = moves[i].second; weight += w; if (nRand <= weight) { #ifdef _TRACE cout << "selecting "; MoveImage(moves[i].first,cout); cout << endl; #endif return moves[i].first; } } // should never get here assert(0); return NullMove; }
MenuCodeEnum MI_IPField::SendInput(CPlayerInput * playerInput) { for (int iPlayer = 0; iPlayer < 4; iPlayer++) { if (playerInput->outputControls[iPlayer].menu_right.fPressed) { if (++iSelectedDigit > 11) iSelectedDigit = 0; MoveImage(); } if (playerInput->outputControls[iPlayer].menu_left.fPressed) { if (--iSelectedDigit < 0) iSelectedDigit = 11; MoveImage(); } if (playerInput->outputControls[iPlayer].menu_up.fPressed) { values[iSelectedDigit]++; AssignHostAddress(); } if (playerInput->outputControls[iPlayer].menu_down.fPressed) { values[iSelectedDigit]--; AssignHostAddress(); } if (playerInput->outputControls[iPlayer].menu_select.fPressed || playerInput->outputControls[iPlayer].menu_cancel.fPressed) { miModifyImage->Show(false); fModifying = false; return MENU_CODE_UNSELECT_ITEM; } } return MENU_CODE_NONE; }
int see( const Board &board, Move move ) { ASSERT(!IsNull(move)); #ifdef ATTACK_TRACE cout << "see "; MoveImage(move,cout); cout << endl; #endif ColorType my_side = PieceColor(board[StartSquare(move)]); ColorType side = my_side; ColorType oside = OppositeColor(side); Square square = DestSquare(move); Square attack_square = StartSquare(move); Piece attacker = board[attack_square]; Piece on_square = (TypeOfMove(move) == EnPassant) ? MakePiece(Pawn,oside) : board[square]; Bitboard opp_attacks(board.calcAttacks(square,oside)); if (opp_attacks.isClear()) { // piece is undefended #ifdef ATTACK_TRACE cout << "undefended, returning " << Gain(move) << endl; #endif return Gain(move); } int score_list[20]; int swap_score = 0; int gain; Bitboard attacks[2]; Square last_attack_sq[2] = {InvalidSquare, InvalidSquare}; attacks[side] = board.calcAttacks(square,side); attacks[oside] = opp_attacks; int count = 0; for (;;) { last_attack_sq[side] = attack_square; attacker = board[attack_square]; #ifdef ATTACK_TRACE cout << " " << PieceImage(TypeOfPiece(attacker)) << " on " << FileImage(attack_square) << RankImage(attack_square) << " takes " << PieceImage(TypeOfPiece(on_square)) << endl; #endif gain = PieceValue(on_square); if (TypeOfPiece(attacker) == Pawn && Rank(square,side) == 8) { if (count == 0) { // initial capture is a promotion (could be under-promotion) gain += (PieceValues[PromoteTo(move)] - PAWN_VALUE); on_square = MakePiece(PromoteTo(move),side); } else { // assume Queen promotion gain += QUEEN_VALUE-PAWN_VALUE; on_square = MakePiece(Queen,side); } } else { on_square = attacker; } if (side == my_side) swap_score += gain; else swap_score -= gain; ASSERT(count < 20); score_list[count++] = swap_score; // remove piece we used from attacks attacks[side].clear(attack_square); // switch sides side = OppositeColor(side); const Square atk = last_attack_sq[side]; if (atk != InvalidSquare && TypeOfPiece(board[atk]) != Knight) { // add in x-ray attacks if any Square xray = board.getDirectionalAttack(atk, -Attacks::directions[atk][square], side); if (xray != InvalidSquare) { attacks[side].set(xray); } } if (attacks[side]) { // get next opponent attacker attack_square = minAttacker(board,attacks[side],side); } else { // no more attackers (including x-rays) break; } } ASSERT(count >= 1); // minimax over the score list for (int i = count-1; i > 0; --i) { if (i % 2 == 0) { score_list[i-1] = max(score_list[i],score_list[i-1]); } else { score_list[i-1] = min(score_list[i],score_list[i-1]); } } #ifdef ATTACK_TRACE cout << "returning " << score_list[0] << endl; #endif return score_list[0]; }
int seeSign( const Board &board, Move move, int threshold ) { ASSERT(!IsNull(move)); #ifdef ATTACK_TRACE cout << "see "; MoveImage(move,cout); cout << endl; #endif ColorType my_side = PieceColor(board[StartSquare(move)]); ColorType side = my_side; ColorType oside = OppositeColor(side); Square square = DestSquare(move); Square attack_square = StartSquare(move); Piece attacker = board[attack_square]; Piece on_square = (TypeOfMove(move) == EnPassant) ? MakePiece(Pawn,oside) : board[square]; Bitboard opp_attacks(board.calcAttacks(square,oside)); if (opp_attacks.isClear()) { // piece is undefended #ifdef ATTACK_TRACE cout << "undefended, returning " << (Gain(move) >= threshold) << endl; #endif return Gain(move) >= threshold; } int score_list[20]; int swap_score = 0; int gain; Bitboard attacks[2]; Square last_attack_sq[2] = {InvalidSquare, InvalidSquare}; attacks[side] = board.calcAttacks(square,side); attacks[oside] = opp_attacks; int count = 0; for (;;) { last_attack_sq[side] = attack_square; attacker = board[attack_square]; #ifdef ATTACK_TRACE cout << " " << PieceImage(TypeOfPiece(attacker)) << " on " << FileImage(attack_square) << RankImage(attack_square) << " takes " << PieceImage(TypeOfPiece(on_square)) << endl; #endif gain = PieceValue(on_square); if (TypeOfPiece(attacker) == Pawn && Rank(square,side) == 8) { if (count == 0) { // initial capture is a promotion (could be under-promotion) gain += (PieceValues[PromoteTo(move)] - PAWN_VALUE); on_square = MakePiece(PromoteTo(move),side); } else { // assume Queen promotion gain += QUEEN_VALUE-PAWN_VALUE; on_square = MakePiece(Queen,side); } } else { on_square = attacker; } if (side == my_side) swap_score += gain; else swap_score -= gain; ASSERT(count < 20); score_list[count++] = swap_score; // remove piece we used from attacks attacks[side].clear(attack_square); // switch sides side = OppositeColor(side); if (count % 2 == 0) { // If it is our turn to move and we are above the threshold // then we can exit - if we capture it only improves the score. if (swap_score >= threshold) { ASSERT(see(board,move) >= threshold); return 1; } // Futility: If capturing the opponent piece for free does // not bring us up to the threshold, exit. (Do not cut off // if we have a potential promotion). if ((Rank(square,side) != 8 || !(attacks[side] & board.pawn_bits[side])) && swap_score + PieceValue(on_square) < threshold) { ASSERT(see(board,move) < threshold); return 0; } } else { // See if opponent already has captured enough that SEE is // below threshold if (swap_score < threshold) { ASSERT(see(board,move) < threshold); return 0; } // Futility: opponent capture cannot get us below threshold if ((Rank(square,side) != 8 || !(attacks[side] & board.pawn_bits[side])) && swap_score - PieceValue(on_square) >= threshold) { ASSERT(see(board,move) >= threshold); return 1; } } const Square atk = last_attack_sq[side]; if (atk != InvalidSquare && TypeOfPiece(board[atk]) != Knight) { // add in x-ray attacks if any Square xray = board.getDirectionalAttack(atk, -Attacks::directions[atk][square], side); if (xray != InvalidSquare) { attacks[side].set(xray); } } if (attacks[side]) { // get next opponent attacker attack_square = minAttacker(board,attacks[side],side); } else { // no more attackers (including x-rays) break; } } ASSERT(count >= 1); // minimax over the score list for (int i = count-1; i > 0; --i) { if (i % 2 == 0) { score_list[i-1] = max(score_list[i],score_list[i-1]); } else { score_list[i-1] = min(score_list[i],score_list[i-1]); } } #ifdef ATTACK_TRACE cout << "returning " << (score_list[0]>=threshold) << endl; #endif ASSERT((score_list[0] >= threshold) == (see(board,move) >= threshold)); return score_list[0] >= threshold; }
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK ) { // trying to move an item when there is a block at the same time is not acceptable return; } if( item == NULL ) { // If we didn't get here by a hot key, then something has gone wrong. if( aEvent.GetInt() == 0 ) return; EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject(); wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) ); item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems, aEvent.GetInt() ); // Exit if no item found at the current location or the item is already being edited. if( (item == NULL) || (item->GetFlags() != 0) ) return; } INSTALL_UNBUFFERED_DC( dc, m_canvas ); switch( item->Type() ) { case SCH_LINE_T: break; case SCH_JUNCTION_T: case SCH_NO_CONNECT_T: case SCH_BUS_BUS_ENTRY_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_TEXT_T: case SCH_COMPONENT_T: case SCH_SHEET_PIN_T: case SCH_FIELD_T: MoveItem( item, &dc ); break; case SCH_BITMAP_T: MoveImage( (SCH_BITMAP*) item, &dc ); break; case SCH_SHEET_T: StartMoveSheet( (SCH_SHEET*) item, &dc ); break; case SCH_MARKER_T: default: wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), GetChars( item->GetClass() ) ) ); break; } if( GetToolId() == ID_NO_TOOL_SELECTED ) SetRepeatItem( NULL ); }
LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { RECT rc; HANDLE hPalMem; flightstruct *fs = &flights; int x, R,G,B; struct elem *pelem; switch (message) { case WM_CREATE: vLoadStrings(); GetIniSettings(); wTimer = SetTimer(hWnd, ID_TIMER, wElapse, NULL); // create timer for image refresh GetClientRect(hWnd, &rc); fs->centerx = rc.right / 2; fs->centery = rc.bottom / 2; fs->smallscrn = (rc.right < 320); fs->num = iRotorCnt; if (fs->elements == NULL) { // allocate memory if ((fs->elements = (struct elem *) malloc(sizeof(struct elem) * fs->num)) == 0) { exit(1); } if ((fs->savex = (LPINT)malloc(sizeof(INT) * iSegLen)) == 0) exit(1); if ((fs->savey = (LPINT)malloc(sizeof(INT) * iSegLen)) == 0) exit(1); } (void) memset(fs->savex,0, sizeof(fs->savex)); pelem = fs->elements; for (x = fs->num; --x >= 0; pelem++) { // define drift for segments pelem->radius_drift_max = (FLOAT)1.0; pelem->radius_drift_now = (FLOAT)1.0; pelem->end_radius = (FLOAT)100.0; // define end radius pelem->ratio_drift_max = (FLOAT)1.0; // define ratio drift pelem->ratio_drift_now = (FLOAT)1.0; pelem->end_ratio = (FLOAT)10.0; } srand((unsigned)time(NULL)); // seed random # generator fs->rotor = 0; fs->prev = 1; fs->lastx = fs->centerx; fs->lasty = fs->centery; fs->angle = (float)(rand() % (long)MAXANGLE) / 3; // define initial angle fs->r = iClrStart; // set start color value fs->firsttime = TRUE; // first time through hPalMem = LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + PALSIZE * sizeof(PALETTEENTRY)); if (!hPalMem) { return -1; } pLogPal = (NPLOGPALETTE) LocalLock(hPalMem); pLogPal->palVersion = 0x300; pLogPal->palNumEntries = PALSIZE; for (x=0, R=255, G=0, B=0; x < PALSIZE; x++) { cycle_colors(&R, &G, &B, 255, 0, 6); pLogPal->palPalEntry[x].peRed = LOBYTE(R); pLogPal->palPalEntry[x].peGreen = LOBYTE(G); pLogPal->palPalEntry[x].peBlue = LOBYTE(B); pLogPal->palPalEntry[x].peFlags = PC_RESERVED; } hPal = CreatePalette((LPLOGPALETTE)pLogPal); if (!hPal) { return -1; } break; case WM_ERASEBKGND: GetClientRect(hWnd,&rc); FillRect((HDC)wParam,&rc,(HBRUSH)GetStockObject(BLACK_BRUSH)); return 0L; break; case WM_TIMER: MoveImage(hWnd); break; case WM_DESTROY: if( wTimer ) // if timer was defined KillTimer(hWnd, ID_TIMER); // then kill it free( flights.savey ); // free any allocated memory free( flights.savex ); free( flights.elements ); if (hPal) { // free palette memory DeleteObject(hPal); } break; } return DefScreenSaverProc(hWnd, message, wParam, lParam); }
//================================================================================================================ void HUDEditorSystem::OnMouseMove(WPARAM btnState, int x, int y) { if (gridMode == GM_Snap) { XMFLOAT2 selToolPoint = SnapToGrid(x, y); m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); // Move a image display cover if in image mode UpdateDisplaySprite(selToolPoint.x, selToolPoint.y); // If a image or text is being moved then continue to move it MoveImage(selToolPoint.x, selToolPoint.y); MoveText(selToolPoint.x, selToolPoint.y); HighlightImage(selToolPoint.x, selToolPoint.y); HighlightText(selToolPoint.x, selToolPoint.y); } else { // Move a image display cover if in image mode UpdateDisplaySprite(x, y); // If a image or text is being moved then continue to move it MoveImage(x, y); MoveText(x, y); HighlightImage(x, y); HighlightText(x, y); } // Start a left button drag of an item if ((btnState & MK_LBUTTON) != 0) { CalculateSelectedMousePosition(x, y); stampPressed = true; // If applicable, Add a image AddImage(); // If applicable, Add a text AddText(); // Selects a image on the map and deletes it if in image delete mode DeleteImage(); // Selects a text on the map and deletes it if in text delete mode DeleteText(); } // Move a button or text display cover /*if (editMode == ET_Button && (action == A_Place || action == A_Move)) { XMFLOAT2 selToolPoint = SnapToGrid(x, y); m_StampNormal->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); m_StampHighlight->TopLeftPosition() = XMFLOAT3(selToolPoint.x, selToolPoint.y, 0); }*/ }
LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { RECT rc; HANDLE hPalMem; switch (msg) { case WM_CREATE: { gravstruct *gp = &gravs; int i, R,G,B; unsigned char ball; vLoadStrings(); // load strings from table GetIniSettings(); // get settings from ini file (control.ini) wTimer = SetTimer(hWnd, ID_TIMER, wElapse, NULL); // create timer to move image GetClientRect(hWnd, &rc); // find size of screen gp->width = rc.right; gp->height = rc.bottom; gp->sr = STARRADIUS; gp->nplanets = iPlanets; srand((unsigned)time(NULL)); // seed random w/ timer if (!gp->planets) { gp->planets = (planetstruct*)malloc((gp->nplanets+1)*sizeof(planetstruct)); memset(gp->planets, 0, (gp->nplanets+1)*sizeof(planetstruct)); gp->starcolor = rand() % (PALSIZE-21); } for (ball = 0; ball <= gp->nplanets; ball++) init_planet(&(gp->planets[ball])); // Create a logical palette to play with hPalMem = LocalAlloc(LMEM_FIXED, sizeof(LOGPALETTE) + PALSIZE * sizeof(PALETTEENTRY)); if (!hPalMem) { // error("No memory for palette"); return -1; } pLogPal = (NPLOGPALETTE) LocalLock(hPalMem); pLogPal->palVersion = 0x300; pLogPal->palNumEntries = PALSIZE; for (i=0, R=255,G=0,B=0; i<PALSIZE; i++) { cycle_colors(&R,&G,&B,255,0,6); pLogPal->palPalEntry[i].peRed = LOBYTE(R); pLogPal->palPalEntry[i].peGreen = LOBYTE(G); pLogPal->palPalEntry[i].peBlue = LOBYTE(B); pLogPal->palPalEntry[i].peFlags = PC_RESERVED; } hPal = CreatePalette((LPLOGPALETTE)pLogPal); if (!hPal) { //Error("CreatePalette() failed"); return -1; } break; } case WM_TIMER: // BOUNCER-specific MoveImage(hWnd); // move image around break; case WM_DESTROY: // BOUNCER-specific if( wTimer ) KillTimer(hWnd, ID_TIMER); if (hPal) DeleteObject(hPal); free(gravs.planets); break; case WM_ERASEBKGND: GetClientRect(hWnd,&rc); FillRect((HDC)wParam,&rc,(HBRUSH)GetStockObject(BLACK_BRUSH)); return 0L; default: break; } return DefScreenSaverProc(hWnd, msg, wParam, lParam); }
int main() { GsDispEnv my_dispenv; GsDrawEnv my_drawenv; GsLine my_line; GsSprite my_sprite; GsRectangle colorbox; GsDot my_dot; unsigned short pad1; unsigned int WasL2=0, WasR2=0, WasL1=0, WasR1=0, WasSelect = 0; int x, y; PSX_InitEx(PSX_INIT_NOBIOS); GsInit(); GsClearMem(); SetVBlankHandler(my_vblank_handler); // This has to be interlaced GsSetVideoModeEx(640, 480, EXAMPLES_VMODE, 0, 1, 0); my_dispenv.x = 0; my_dispenv.y = 0; GsSetDispEnv(&my_dispenv); my_drawenv.dither = 0; my_drawenv.draw_on_display = 1; my_drawenv.x = 0; my_drawenv.y = 0; my_drawenv.w = 640; my_drawenv.h = 512; my_drawenv.ignore_mask = 0; my_drawenv.set_mask = 0; GsSetDrawEnv(&my_drawenv); GsSetList(primitive_list); load_ui_graphics(); while(GsIsDrawing()); colorbox.x = 0; colorbox.y = 0; colorbox.w = 640; colorbox.h = 511; colorbox.r = 255; colorbox.g = 255; colorbox.b = 255; colorbox.attribute = 0; GsSortRectangle(&colorbox); sort_color_boxes(); my_sprite.x = 0; my_sprite.y = 0; my_sprite.tpage = 10; my_sprite.u = 0; my_sprite.v = 0; my_sprite.attribute = 0; my_sprite.cx = 640; my_sprite.cy = 480; my_sprite.r = my_sprite.g = my_sprite.b = NORMAL_LUMINOSITY; my_sprite.scalex = my_sprite.scaley = 0; my_sprite.w = 16; my_sprite.h = 24; GsDrawList(); while(GsIsDrawing()); // Backup 32x32 area MoveImage(cursor_x, cursor_y, 992, 0, 32, 32); my_dot.attribute = 0; while(1) { while(speed_counter) { old_cursor_x = cursor_x; old_cursor_y = cursor_y; // Restore 32x32 area MoveImage(992, 0, old_cursor_x, old_cursor_y, 32, 32); while(GsIsDrawing()); PSX_ReadPad(&pad1, NULL); if(pad1 & PAD_LEFT) cursor_x-=cursor_speed; if(pad1 & PAD_RIGHT) cursor_x+=cursor_speed; if(pad1 & PAD_UP) cursor_y-=cursor_speed; if(pad1 & PAD_DOWN) cursor_y+=cursor_speed; if(cursor_x <= 0) cursor_x = 0; if(pad1 & PAD_CROSS) { if(cursor_y >= 384) { y = (cursor_y - 384) >> 4; x = cursor_x >> 6; current_color[0] = paint_colors[(y * 10)+x][0]; current_color[1] = paint_colors[(y * 10)+x][1]; current_color[2] = paint_colors[(y * 10)+x][2]; } else { switch(brush_type) { case 0: if(cursor_y >= 384) { break; } my_dot.r = current_color[0]; my_dot.g = current_color[1]; my_dot.b = current_color[2]; my_dot.x = cursor_x; my_dot.y = cursor_y; GsSortDot(&my_dot); break; case 1: if(cursor_y >= 380) { break; } my_dot.r = current_color[0]; my_dot.g = current_color[1]; my_dot.b = current_color[2]; my_dot.x = cursor_x + 1; my_dot.y = cursor_y; GsSortDot(&my_dot); my_dot.x++; GsSortDot(&my_dot); my_dot.y++; my_dot.x-=2; GsSortDot(&my_dot); my_dot.x++; GsSortDot(&my_dot); my_dot.x++; GsSortDot(&my_dot); my_dot.x++; GsSortDot(&my_dot); my_dot.y++; my_dot.x-=2; GsSortDot(&my_dot); my_dot.x++; GsSortDot(&my_dot); break; } } GsDrawList(); while(GsIsDrawing()); } if((pad1 & PAD_R2) && !WasR2) { cursor_speed++; WasR2 = 1; } if((pad1 & PAD_L2) && !WasL2) { cursor_speed--; WasL2 = 1; } if(!(pad1 & PAD_R2)) WasR2 = 0; if(!(pad1 & PAD_L2)) WasL2 = 0; if((pad1 & PAD_R1) && !WasR1) { brush_type++; WasR1 = 1; } if((pad1 & PAD_L1) && !WasL1) { brush_type--; WasL1 = 1; } if((pad1 & PAD_SELECT) && !WasSelect) { my_sprite.attribute ^= (ENABLE_TRANS | TRANS_MODE(0)); my_dot.attribute ^= (ENABLE_TRANS | TRANS_MODE(0)); WasSelect = 1; } if(!(pad1 & PAD_SELECT)) WasSelect = 0; if(!(pad1 & PAD_R1)) WasR1 = 0; if(!(pad1 & PAD_L1)) WasL1 = 0; if(cursor_speed <= 0) cursor_speed = 1; if(cursor_speed >= 8) cursor_speed = 7; if(brush_type <= 0) brush_type = 0; if(brush_type > 1) brush_type = 1; // Backup 32x32 area MoveImage(cursor_x, cursor_y, 992, 0, 32, 32); while(GsIsDrawing()); // if(cursor_x != old_cursor_x || cursor_y != old_cursor_y) // { // printf("cx = %d, cy = %d, cursor_speed = %d, brush_type = %d\n", // cursor_x, cursor_y, cursor_speed, brush_type); my_sprite.x = cursor_x; my_sprite.y = cursor_y; GsSortSimpleSprite(&my_sprite); GsDrawList(); while(GsIsDrawing()); // } speed_counter--; }
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent ) { SCH_SCREEN* screen = GetScreen(); SCH_ITEM* item = screen->GetCurItem(); if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK ) { // trying to move an item when there is a block at the same time is not acceptable return; } if( item == NULL ) { // If we didn't get here by a hot key, then something has gone wrong. if( aEvent.GetInt() == 0 ) return; EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject(); wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) ); item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems, aEvent.GetInt() ); // Exit if no item found at the current location or the item is already being edited. if( (item == NULL) || (item->GetFlags() != 0) ) return; } INSTALL_UNBUFFERED_DC( dc, m_canvas ); switch( item->Type() ) { case SCH_LINE_T: break; case SCH_JUNCTION_T: case SCH_NO_CONNECT_T: case SCH_BUS_BUS_ENTRY_T: case SCH_BUS_WIRE_ENTRY_T: case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_TEXT_T: case SCH_COMPONENT_T: case SCH_SHEET_PIN_T: case SCH_FIELD_T: case SCH_SHEET_T: PrepareMoveItem( item, &dc ); break; case SCH_BITMAP_T: // move an image is a special case: // we cannot undraw/redraw a bitmap just using our xor mode // the MoveImage function handle this undraw/redraw difficulty // By redrawing the full bounding box MoveImage( (SCH_BITMAP*) item, &dc ); break; case SCH_MARKER_T: // Moving a marker has no sense break; default: // Unknown items cannot be moved wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %d" ), item->Type() ) ); break; } if( GetToolId() == ID_NO_TOOL_SELECTED ) SetRepeatItem( NULL ); }
void MoveSelectImage::OnMouseLButtonUp(LPINPUT_DATA lpd) { MoveImage(lpd, &beforPt); cvReleaseImage(&move_mask); }
void MoveSelectImage::OnMouseLDrag(LPINPUT_DATA lpd) { MoveImage(lpd, &beforPt); beforPt.x = lpd->x; beforPt.y = lpd->y; }