static void SetBackColor(FXWindow*w) { FXColor c=w->getApp()->getBackColor(); BackColor(FXComboBox); BackColor(FXListBox); BackColor(FXList); BackColor(FXTextField); c=w->getApp()->getBaseColor(); BackColor(FXWindow); }
static WORD AttrVideo(int b, int f) { WORD result; if (rvcolor) { result = ((WORD) ((ForeColor(f) << 4) | BackColor(b))); TRACE2(("rev AttrVideo(%d,%d) = %04x\n", f, b, result)); } else { result = ((WORD) ((BackColor(b) << 4) | ForeColor(f))); TRACE2(("AttrVideo(%d,%d) = %04x\n", f, b, result)); } return result; }
void wxMacToolTip::Clear() { m_mark++ ; if ( m_timer ) { delete m_timer ; m_timer = NULL ; } if ( !m_shown ) return ; #if TARGET_CARBON HMHideTag() ; m_helpTextRef.Release() ; #else if ( m_window == s_ToolTipWindowRef && m_backpict ) { wxMacPortStateHelper help( (GrafPtr) GetWindowPort(m_window) ) ; m_shown = false ; BackColor( whiteColor ) ; ForeColor(blackColor ) ; DrawPicture(m_backpict, &m_rect); KillPicture(m_backpict); m_backpict = NULL ; } #endif }
void ShowTxt(void) { switch (gCurrWin) { case kLicenseID: if(gControls->lw->licTxt) { RGBColor backColorOld; Rect textRect; // get back color GetBackColor(&backColorOld); // set to white BackColor(whiteColor); // erase rect and update textRect = (**(gControls->lw->licTxt)).viewRect; EraseRect(&textRect); TEUpdate(&textRect, gControls->lw->licTxt); // restore back color RGBBackColor(&backColorOld); } break; default: break; } }
void iA3DColoredPolyObjectVis::renderSelection(std::vector<size_t> const & sortedSelInds, int classID, QColor const & constClassColor, QStandardItem* activeClassItem) { QColor BackColor(128, 128, 128, 0); int currentObjectIndexInSelection = 0; size_t curSelObjID = NoPointIdx; QColor classColor(constClassColor); if (sortedSelInds.size() > 0) { curSelObjID = sortedSelInds[currentObjectIndexInSelection]; classColor.setAlpha(TransparentAlpha); } else { classColor.setAlpha(255); } for (size_t objID = 0; objID < m_objectTable->GetNumberOfRows(); ++objID) { int curClassID = m_objectTable->GetValue(objID, m_objectTable->GetNumberOfColumns() - 1).ToInt(); QColor curColor = (objID == curSelObjID) ? SelectedColor : ((curClassID == classID) ? classColor : BackColor); setPolyPointColor(objID, curColor); if (objID == curSelObjID) { ++currentObjectIndexInSelection; if (currentObjectIndexInSelection < sortedSelInds.size()) curSelObjID = sortedSelInds[currentObjectIndexInSelection]; } } updatePolyMapper(); }
void cPict::draw(){ RGBColor store_color; Rect rect = frame; GrafPtr cur_port; GetPort(&cur_port); SetPortWindowPort(parent->win); if(!visible){ // Erase it InsetRect(&rect, -3, -3); tileImage(rect,bg_gworld,bg[parent->bg]); return; } if(picNum < 0) { // Just fill with black GetForeColor(&store_color); ForeColor(blackColor); PaintRect(&rect); RGBForeColor(&store_color); return; } GetBackColor(&store_color); BackColor(whiteColor); drawPict()[picType](picNum,rect); if(drawFramed) drawFrame(2,0); SetPort(cur_port); }
bool MCRegionCalculateMask(MCRegionRef self, int32_t w, int32_t h, MCBitmap*& r_mask) { // Create a pixmap Pixmap t_image; t_image = MCscreen -> createpixmap(w, h, 1, False); // Draw into the pixmap's port CGrafPtr t_old_port; GDHandle t_old_device; GetGWorld(&t_old_port, &t_old_device); SetGWorld((CGrafPtr)t_image -> handle . pixmap, NULL); BackColor(whiteColor); ForeColor(blackColor); Rect t_rect; SetRect(&t_rect, 0, 0, w, h); EraseRect(&t_rect); PaintRgn((RgnHandle)self); SetGWorld(t_old_port, t_old_device); // Fetch the pixmap as a bitmap MCBitmap *t_bitmap; t_bitmap = MCscreen -> getimage(t_image, 0, 0, w, h, False); // Discard the pixmap MCscreen -> freepixmap(t_image); r_mask = t_bitmap; return true; }
// by 한나 void drop() { int i, j, A; srand(time(0)); int Q; while (1) { Q = 0; for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { if (board[i][j] == 0) { if (j - 1 >= 0) { board[i][j] = board[i][j - 1]; DrawBoard(i, j); if (TEST == T) Sleep(75); // 시험중 board[i][j - 1] = 0; DrawBoard(i, j - 1); Sleep(75); } } } } for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { if (board[i][0] == 0) { board[i][j] = rand() % RANDOM + 1; DrawBoard(i, j); Sleep(100); } } } for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { if (board[i][j] != 0) { Q++; } } } if (Q == 64)break; } BackColor(' '); color(15); SetCursors(50, 10); printf("score:%5d", score); if (score > s_limit && timer <= t_limit) { level++; if (level % 2 == 0) t_limit -= 3; if (level % 2 == 1) RANDOM++; score = 0; } else if ((end - start)>500); start = clock(); }
void UpdateAdditionsWin(void) { Rect r; Cell c; int i; GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad + 1); HLock(gControls->cfg->selAddMsg); DrawString( CToPascal(*gControls->cfg->selAddMsg)); HUnlock(gControls->cfg->selAddMsg); #if 0 RGBColor backColorOld; Rect adjustedRect, *clRect = &gControls->aw->compListBox; SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1); GetBackColor(&backColorOld); BackColor(whiteColor); EraseRect(&adjustedRect); RGBBackColor(&backColorOld); #endif LUpdate( (*gControls->aw->compList)->port->visRgn, gControls->aw->compList); SetRect(&r, gControls->aw->compListBox.left, gControls->aw->compListBox.top, gControls->aw->compListBox.right + 1, gControls->aw->compListBox.bottom); FrameRect(&r); SetPt(&c, 0, 0); if (LGetSelect(true, &c, gControls->aw->compList)) { HLock((Handle)gControls->aw->compDescTxt); SetRect(&r, (*gControls->aw->compDescTxt)->viewRect.left, (*gControls->aw->compDescTxt)->viewRect.top, (*gControls->aw->compDescTxt)->viewRect.right, (*gControls->aw->compDescTxt)->viewRect.bottom); HUnlock((Handle)gControls->aw->compDescTxt); TEUpdate(&r, gControls->aw->compDescTxt); } DrawDiskSpaceMsgs( gControls->opt->vRefNum ); for (i = 0; i < numRows; i++) { if (gControls->cfg->comp[rowToComp[i]].highlighted) { AddInitRowHighlight(i); break; } } SetPort(oldPort); }
void fever(int count) { if (count == 0) fev_lev = 1; else if (count > 3) { fev_lev += (count - 3); fevt = clock(); } BackColor(' '); color(15); SetCursors(58, 11); printf("%2d", fev_lev); }
VOID CColorPage::OnBackColor() { CColorDialog dlgColor (m_lBackColor, CC_RGBINIT, this); if (IDOK == dlgColor.DoModal()) { m_lBackColor = dlgColor.GetColor(); BackColor().InvalidateRect(NULL, TRUE); SetModified(); RedrawWindow(); } }
static void textbox(char **textlines) { int items = 0, i; int height, width; rect R; rect tR; int cx, cy; char *msg1 = "Click or press any key to continue"; for (items = width = 0; textlines[items]; items++) width = max(width, StringWidth(textlines[items]) + 16); width = max(width, StringWidth(msg1) + 16); Centers(&sR, &cx, &cy); height = FontHeight * (items + 1) + 16; R.Xmin = cx - width / 2; R.Xmax = R.Xmin + width - 1; R.Ymin = cy - height / 2; R.Ymax = R.Ymin + height - 1; framelines(&R); BasicCenteredBox(&tR, width, height, DARKGRAY, textlines[0], WHITE); TextAlign(alignLeft, alignTop); for (i = 1; i < items; i++) { MoveTo(tR.Xmin + 4, tR.Ymin + 8 + FontHeight * i); PenColor(WHITE); BackColor(DARKGRAY); DrawString(textlines[i]); } MoveTo(cx, tR.Ymin + 8 + FontHeight * i + 4); TextAlign(alignCenter, alignTop); DrawString(msg1); while (1) { event e; KeyEvent(true, &e); if (e.ASCII || e.ScanCode || (e.State & 0x700)) break; } WaitForNothing(); PopRect(&i); framelines(&R); }
VOID CColorPage::OnPaint() { CRect rcBack, rcGrid; CPaintDC dc(this); CPaintDC dcBack(&BackColor()); CPaintDC dcGrid(&GridColor()); rcBack.CopyRect(&(dcBack.m_ps.rcPaint)); rcGrid.CopyRect(&(dcGrid.m_ps.rcPaint)); dcBack.FillSolidRect(&rcBack, m_lBackColor); dcGrid.FillSolidRect(&rcGrid, m_lGridColor); CPropertyPage::OnPaint(); }
int disk_error_handler(int errval, int ax, int bp, int si) { rect R, R2; char tbuf[128]; int err; int centerx = sR.Xmax / 2; int centery = sR.Ymax / 2; int height = 2 * FontHeight + 10; int width = sR.Xmax / 2; R.Xmin = sR.Xmax / 4; R.Xmax = R.Xmin + width; R.Ymin = centery - height / 2; R.Ymax = R.Ymin + height; PushRect(&R, &err); if (ax < 0) sprintf(tbuf, "Device error %x: %x %p", errval, ax, MK_FP(bp, si)); else sprintf(tbuf, "Disk error on drive %c", 'A' + (ax & 0xff)); PenColor(MENUBACK); PaintRect(&R); PenColor(MENUTEXT); BackColor(MENUBACK); R2 = R; InsetRect(&R2, 2, 2); FrameRect(&R2); TextAlign(alignCenter, alignTop); MoveTo(centerx, R.Ymin + 4); DrawString(tbuf); MoveTo(centerx, R.Ymin + FontHeight + 4); DrawString("Hit any key to continue"); getch(); PopRect(&err); hardretn(-1); #pragma warn -rvl }
// 터트리기 int Bomb(int x, int y, int O) { int bomb[BOARD_WIDTH][BOARD_HEIGHT] = { 0, }; int a, b, count = 0; Bomb_Width(x, y, bomb); Bomb_Height(x, y, bomb); //bomb를 확인하기위해 bomb출력 나중에 삭제 if (TEST == T) { SetCursors(0, 23); for (a = 0; a < 8; a++) { for (b = 0; b < 8; b++) { printf("%d ", bomb[b][a]); } printf("\n"); } } for (b = 0; b < BOARD_HEIGHT; b++) { for (a = 0; a < BOARD_WIDTH; a++) { if (bomb[a][b] == 1) { if (O == 1) board[a][b] = 0; count++; } } } if (TEST == T) { SetCursors(20, 25); printf("%d", count); } if (count >= 3) { if (O == 1) { printf("\a"); BackColor(' '); //DrawBoard(x, y); score += (count)* 10 * fev_lev; if (work == 1) fever(count); } return count; } return 0; }
void drawSourceImage() { Rect rect; Rect outlineRect; Rect tempRect1; GetPortBounds(gGWorld, &tempRect1); SetRect( &rect, 20, 37, 20 + tempRect1.right, 37 + tempRect1.bottom); outlineRect = rect; InsetRect( &outlineRect, -5, -5 ); drawDeepBox( &outlineRect ); ForeColor( blackColor ); BackColor( whiteColor ); CopyBits( (BitMap *)(*(GetPortPixMap(gGWorld))), GetPortBitMapForCopyBits(GetWindowPort(gWindow)), &((**(GetPortPixMap(gGWorld))).bounds), &rect, srcCopy, nil ); }
void PaintQuitButton(int inout) { rect R = QuitButtonR; int cx, cy; HideCursor(); RasterOp(zREPz); Centers(&R, &cx, &cy); PaintRadioButton(&R, inout, inout, ""); TextAlign(alignCenter, alignTop); PenColor(WHITE); BackColor(inout ? RED : DARKGRAY); MoveTo(cx, R.Ymin + 4); DrawString("Alt-X"); MoveTo(cx, R.Ymin + FontHeight + 4); DrawString("to Exit"); PushButton(&R, inout); ExtraHilite(&R, inout); if (inout) DoublePress(&R, true, RED); ShowCursor(); }
void main(int argc, char *argv[]) { double r, g, b; uint rows, cols; char fname[256]; double colormag; time_t tstart, tend; int nrgbr = 63, nrgbg = 63, nrgbb = 63; OctreeType *octree; RGBType color; FILE *f; char title[40]; char description[128]; ulong i; uint j; int n; RGBType palette[256]; ulong image_start; union REGS regs; int resx, resy; int px, py; int ii; int cols2, rows2; int k; int cli; int maxr=0, maxg=0, maxb=0; #if defined METAWINDO rect screen; #endif printf("Image file : "); scanf("%s",fname); if ((f = fopen(fname,"rb")) == NULL) { printf("%s not found.\n",fname); exit(1); } /* ** Read the image file header */ fgets(title,40,f); fgets(description,128,f); fscanf(f,"%d %d",&cols,&rows); fscanf(f,"%lf",&colormag); image_start = ftell(f); cols2 = cols/2; rows2 = rows/2; time(&tstart); /* ** Initialize the color octree */ octree = CreateOctNode(0); /* ** Loop through the image and store each unique color. */ for (i = 0L; i < (ulong)rows*(ulong)cols; i++) { /* ** Show progress... */ if ((i % (ulong)cols) == 0L) printf("%ld\r",i/cols); fscanf(f,"%lf %lf %lf",&r,&g,&b); /* ** Convert input floating point values to bytes. NOTE: We assume that ** all input values are between 0..1.0 */ color.r = (unsigned char)(r * nrgbr); color.g = (unsigned char)(g * nrgbg); color.b = (unsigned char)(b * nrgbb); if (color.r > nrgbr) color.r = nrgbr; if (color.g > nrgbg) color.g = nrgbg; if (color.b > nrgbb) color.b = nrgbb; /* ** Insert this color into the octree */ InsertTree(&octree, &color, 0); /* ** If there are too many colors in the tree as a result of this ** insert, reduce the octree */ while (TotalLeafNodes() > npal) { ReduceTree(); } } /* ** Make a pass through the completed octree to average down the ** rgb components. When done, 'n' contains the actual number of ** colors in the palette table. */ n = 0; MakePaletteTable(octree, palette, &n); /* ** How long did it take? */ time(&tend); printf("Processed %ld pixels per second\ninto %d quantized colors\n", ((long)rows*(long)cols)/(tend-tstart), n); j = 0; while (j != 3) { printf("Output to (1)monitor or (2).PCX file or (3) quit: "); scanf("%s",title); j = atoi(title); if (j == 2) { fseek(f,image_start,0); SaveAsPCX(f, octree, cols, rows, nrgbr, nrgbg, nrgbb, npal, palette); } else if (j == 1) { #if defined METAWINDO /* ** NOTE: This section requires MetaWINDOW graphics lib ** ** Let the user choose his graphics device and resolution */ MetQuery(argc,argv); if (InitGraphics(GrafixCard) != 0) { printf("\n---Error initializing graphics device---\n"); exit(1); } SetDisplay(GrafPg0); BackColor(0); /* ** Set the VGA palette */ for (j = 0; j < n; j++) { regs.h.al = 0x10; regs.h.ah = 0x10; regs.h.bl = j; regs.h.bh = 0; regs.h.ch = (int)(palette[j].g); regs.h.cl = (int)(palette[j].b); regs.h.dh = (int)(palette[j].r); int86(0x10,®s,®s); } /* ** Center the image on the screen */ ScreenRect(&screen); resx = screen.Xmax; resy = screen.Ymax; px = resx/2 - npal; /* ** Display a color bar at the top of the screen */ for (ii = 0; ii < npal; ii++){ PenColor(ii); SetPixel(ii*2+px,1); SetPixel(ii*2+px+1,1); SetPixel(ii*2+px,2); SetPixel(ii*2+px+1,2); SetPixel(ii*2+px,3); SetPixel(ii*2+px+1,3); SetPixel(ii*2+px,4); SetPixel(ii*2+px+1,4); } fseek(f,image_start,0); py = resy/2 - rows2 - 1; for (ii = 0; ii < rows ; ii++) { px = resx/2 - cols2; for (k = 0; k < cols; k++) { if (fscanf(f,"%f %f %f",&r,&g,&b) == EOF) { goto pdone; } color.r = (byte)(nrgbr * r); color.g = (byte)(nrgbg * g); color.b = (byte)(nrgbb * b); cli = QuantizeColor(octree, &color); PenColor(cli); SetPixel(px,py); px++; } py++; } pdone: getch(); SetDisplay(TextPg0); StopGraphics(); #endif } } }
/* ---------------------------------------------------------------------------- _ApplyTransparentColor Set destination port background color to transparent color. Returns nothing. ---------------------------------------------------------------------------- */ static void _ApplyTransparentColor (RGBColorPtr pBackColor) { RGBColor rgbColor; short qdColor; GetBackColor(pBackColor); if (fHasColorQuickdraw) //fColorQuickdrawAvailable(true)) { switch (_TransparentColor) { case TBIT_White: rgbColor.red = 0xFFFF; rgbColor.green = 0xFFFF; rgbColor.blue = 0xFFFF; break; case TBIT_Black: rgbColor.red = 0x0000; rgbColor.green = 0x0000; rgbColor.blue = 0x0000; break; case TBIT_Red: rgbColor.red = 0xDD6B; rgbColor.green = 0x08C2; rgbColor.blue = 0x06A2; break; case TBIT_Green: rgbColor.red = 0x0000; rgbColor.green = 0x8000; rgbColor.blue = 0x11B0; break; case TBIT_Blue: rgbColor.red = 0x0000; rgbColor.green = 0x0000; rgbColor.blue = 0xD400; break; default: rgbColor.red = 0x0000; rgbColor.green = 0x0000; rgbColor.blue = 0x0000; break; } RGBBackColor(&rgbColor); } else { switch (_TransparentColor) { case TBIT_White: qdColor = whiteColor; break; case TBIT_Black: qdColor = blackColor; break; case TBIT_Red: qdColor = redColor; break; case TBIT_Green: qdColor = greenColor; break; case TBIT_Blue: qdColor = blueColor; break; default: qdColor = blackColor; break; } BackColor(qdColor); } }
void iA3DLabelledVolumeVis::renderSelection( std::vector<size_t> const & sortedSelInds, int classID, QColor const & classColor, QStandardItem* activeClassItem ) { QColor BackColor(128, 128, 128, 0); double backRGB[3]; backRGB[0] = BackColor.redF(); backRGB[1] = BackColor.greenF(); backRGB[2] = BackColor.blueF(); // background color double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.5, backAlpha = 0.00, classRGB[3], selRGB[3]; selRGB[0] = SelectedColor.redF(); selRGB[1] = SelectedColor.greenF(); selRGB[2] = SelectedColor.blueF(); classRGB[0] = classColor.redF(); classRGB[1] = classColor.greenF(); classRGB[2] = classColor.blueF(); // clear existing points oTF->RemoveAllPoints(); cTF->RemoveAllPoints(); oTF->ClampingOff(); cTF->ClampingOff(); oTF->AddPoint( 0, backAlpha, 0.5, 1.0 ); cTF->AddRGBPoint( 0, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); int hid = 0, next_hid = 1, prev_hid = -1, selectionIndex = 0, previous_selectionIndex = 0; bool starting = false, hid_isASelection = false, previous_hid_isASelection = false; int countClass = activeClassItem->rowCount(); int countSelection = sortedSelInds.size(); for ( size_t j = 0; j < countClass; ++j ) { hid = activeClassItem->child( j )->text().toInt(); if ( countSelection > 0 ) { if (hid-1 == sortedSelInds[selectionIndex] ) { hid_isASelection = true; red = SelectedColor.redF(), green = SelectedColor.greenF(), blue = SelectedColor.blueF(); if ( selectionIndex + 1 < sortedSelInds.size() ) selectionIndex++; } else { hid_isASelection = false; red = classRGB[0]; green = classRGB[1]; blue = classRGB[2]; } if ( prev_hid > 0 ) { if (prev_hid-1 == sortedSelInds[previous_selectionIndex]) { previous_hid_isASelection = true; if ( previous_selectionIndex + 1 < sortedSelInds.size()) previous_selectionIndex++; } else previous_hid_isASelection = false; } } else { red = classRGB[0]; green = classRGB[1]; blue = classRGB[2]; } // If we are not yet at the last object (of the class) get the next hid if ( ( j + 1 ) < countClass ) { next_hid = activeClassItem->child( j + 1 )->text().toInt(); } else // If hid = the last object (of the class) we have to set the last object points { if ( starting ) // If we are in a sequence we have to set the ending (\) { oTF->AddPoint( hid - 1 + 0.3, alpha, 0.5, 1.0 ); oTF->AddPoint( hid - 0.5, alpha, 0.5, 1.0 ); oTF->AddPoint( hid, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, backAlpha, 0.5, 1.0 ); if ( hid_isASelection ) { cTF->AddRGBPoint( hid - 0.5, 1.0, 0.0, 0.0, 0.5, 1.0 ); cTF->AddRGBPoint( hid, 1.0, 0.0, 0.0, 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); } else { cTF->AddRGBPoint( hid - 0.5, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); } if ( previous_hid_isASelection ) cTF->AddRGBPoint( hid - 1 + 0.3, 1.0, 0.0, 0.0, 0.5, 1.0 ); else cTF->AddRGBPoint( hid - 1 + 0.3, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); break; } else // if we are not in a sequence we have to create the last tooth (/\) { oTF->AddPoint( hid - 0.5, backAlpha, 0.5, 1.0 ); oTF->AddPoint( hid, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, backAlpha, 0.5, 1.0 ); cTF->AddRGBPoint( hid - 0.5, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid, red, green, blue, 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); break; } } if ( next_hid > hid + 1 && !starting ) //Create one single tooth { oTF->AddPoint( hid - 0.5, backAlpha, 0.5, 1.0 ); oTF->AddPoint( hid, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, backAlpha, 0.5, 1.0 ); cTF->AddRGBPoint( hid - 0.5, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid, red, green, blue, 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); } else if ( next_hid == hid + 1 && !starting ) //Creates the beginning of a sequence (/) { starting = true; oTF->AddPoint( hid - 0.5, backAlpha, 0.5, 1.0 ); oTF->AddPoint( hid, alpha, 0.5, 1.0 ); cTF->AddRGBPoint( hid - 0.5, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid, red, green, blue, 0.5, 1.0 ); } else if ( next_hid == hid + 1 && starting ) //Continues the started sequence (-) { if ( !hid_isASelection && previous_hid_isASelection ) { cTF->AddRGBPoint( hid - 1 + 0.3, selRGB[0], selRGB[1], selRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid - 0.5, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); oTF->AddPoint( hid - 1 + 0.3, alpha, 0.5, 1.0 ); oTF->AddPoint( hid - 0.5, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, alpha, 0.5, 1.0 ); } else if ( hid_isASelection && !previous_hid_isASelection ) { cTF->AddRGBPoint( hid - 0.5, selRGB[0], selRGB[1], selRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, selRGB[0], selRGB[1], selRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid - 1 + 0.3, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); oTF->AddPoint( hid - 0.5, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, alpha, 0.5, 1.0 ); oTF->AddPoint( hid - 1 + 0.3, alpha, 0.5, 1.0 ); } } else if ( next_hid > hid + 1 && starting ) // (\) { starting = false; oTF->AddPoint( hid - 1 + 0.3, alpha, 0.5, 1.0 ); oTF->AddPoint( hid - 0.5, alpha, 0.5, 1.0 ); oTF->AddPoint( hid, alpha, 0.5, 1.0 ); oTF->AddPoint( hid + 0.3, backAlpha, 0.5, 1.0 ); if ( previous_hid_isASelection ) cTF->AddRGBPoint( hid - 1 + 0.3, selRGB[0], selRGB[1], selRGB[2], 0.5, 1.0 ); else cTF->AddRGBPoint( hid - 1 + 0.3, classRGB[0], classRGB[1], classRGB[2], 0.5, 1.0 ); cTF->AddRGBPoint( hid - 0.5, red, green, blue, 0.5, 1.0 ); cTF->AddRGBPoint( hid, red, green, blue, 0.5, 1.0 ); cTF->AddRGBPoint( hid + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); } prev_hid = hid; } if ( hid < m_objectTable->GetNumberOfRows() ) // Creates the very last points (for all objects) if it's not created yet { oTF->AddPoint( m_objectTable->GetNumberOfRows() + 0.3, backAlpha, 0.5, 1.0 ); cTF->AddRGBPoint( m_objectTable->GetNumberOfRows() + 0.3, backRGB[0], backRGB[1], backRGB[2], 0.5, 1.0 ); } updateRenderer(); }
void CWindowOSXQT::OnPaint() { int iBytesNeeded = (mSize.iCX + 1) * (mSize.iCY + 1) * 4; if (iBytesNeeded > miDrawBufferSize) { if (mpcDrawBuffer) { delete[] mpcDrawBuffer; } miDrawBufferSize = iBytesNeeded; mpcDrawBuffer = new tuchar[miDrawBufferSize]; } if (mpInvalidater->IsRectInvalidated() == false) { // No updating neccasary return; } SRect RectUpdate; mpInvalidater->GetInvalidatedRect(RectUpdate); mpInvalidater->Reset(); // Limit update rect to our actual size SRect RectThis(SPos(0, 0), mSize); RectUpdate.FitInside(RectThis); GetPane()->OnDraw(RectUpdate); if (mpControlOnTop) { mpControlOnTop->OnDraw(RectUpdate); } PixMap srcbm; GrafPtr saved; Rect portBounds; GrafPtr grafPtrThis; BitMapPtr dstbitmap; PixMapHandle dstpixmap; memset(&srcbm,0,sizeof(PixMap)); // setup begin srcbm.baseAddr = nil; srcbm.rowBytes = 0x8000; srcbm.bounds.left = 0; srcbm.bounds.top = 0; srcbm.bounds.right = mSize.iCX - 1; srcbm.bounds.bottom = mSize.iCY - 1; // ??? int bytesPerRow = mSize.iCX * 4; srcbm.pmVersion = 4; srcbm.packType = 0; srcbm.packSize = 0; srcbm.hRes = 0x00480000; srcbm.vRes = 0x00480000; srcbm.pixelType = 0; srcbm.pixelSize = 0; srcbm.cmpCount = 0; srcbm.cmpSize = 0; srcbm.pmTable = nil; srcbm.pixelType = RGBDirect; srcbm.pixelSize = 32; srcbm.cmpCount = 3; srcbm.cmpSize = 5; srcbm.rowBytes = 0x8000 | (unsigned short) bytesPerRow; srcbm.baseAddr = (Ptr)mpcDrawBuffer; unsigned long ulOffsetX, ulOffsetY; ulOffsetX = 0; ulOffsetY = 0; Rect SrcRect; SrcRect.left = RectUpdate.iX; SrcRect.right = RectUpdate.iX + RectUpdate.iCX - 1; SrcRect.top = RectUpdate.iY; SrcRect.bottom = RectUpdate.iY + RectUpdate.iCY - 1; Rect DstRect; DstRect = SrcRect; GetPort(&saved); grafPtrThis = (GrafPtr)::GetWindowPort(GetWindowRef()); if (saved != grafPtrThis) { SetPort(grafPtrThis); } GetPortBounds(grafPtrThis, &portBounds); int port_offsetX = portBounds.left; int port_offsetY = portBounds.top; SetOrigin( port_offsetX, port_offsetY ); /* Rect rctClip; rctClip.left = 0; rctClip.right = rctClip.left + mSize.iCX; rctClip.top = 0; rctClip.bottom = rctClip.top + mSize.iCY; ClipRect(&rctClip);*/ dstpixmap = ::GetPortPixMap(grafPtrThis); dstbitmap = (BitMapPtr)(*dstpixmap); ForeColor(blackColor); BackColor(whiteColor); ::CopyBits((BitMapPtr)&srcbm, dstbitmap, &SrcRect, &DstRect, srcCopy, nil); // SetOrigin(0, 0); if (saved != grafPtrThis) { SetPort(saved); } }
void create_slider_base_width(slider * s, rect * mR, int x, int y, int floater, int tinies, int frame, int numbers, int width) { rect R; int row; double range, foffset; int offset; point p; int zwidth; int zepps; int i; R.Xmin = mR->Xmin + x; R.Xmax = mR->Xmax - x; R.Ymin = mR->Ymin + y; R.Ymax = R.Ymin + slider_height(s); s->tR = R; s->bubblewidth = width; #ifndef NOFRAME /* Box the whole thing */ if (frame) { PenColor(BUTTONFRAME); FrameRect(&R); } #endif row = R.Ymin + 2; #ifndef NOTITLE if (s->title) { int cx; cx = R.Xmin + (R.Xmax - R.Xmin) / 2; PenColor(BLACK); BackColor(MENUBACK); TextAlign(alignCenter, alignTop); MoveTo(cx, row); DrawString(s->title); row += FontHeight + 4; } #else row += FontHeight + 4; #endif #ifndef NONUMBERS if (numbers) { int w = 8 * 10; R.Xmin = s->tR.Xmin + 4; R.Xmax = R.Xmin + w - 1; R.Ymin = row - FontHeight / 4; R.Ymax = R.Ymin + FontHeight + 4; s->TB.nR = R; PaintNumberBoxEntry(&s->TB, s->value, (floater) ? GS_FLOAT : GS_UNSIGNED); s->sR.Xmin = R.Xmax + 8; } else { s->sR.Xmin = s->tR.Xmin + 2; } #else s->sR.Xmin = s->tR.Xmin + 2; #endif s->sR.Xmax = s->tR.Xmax - 2; s->sR.Ymin = row; s->sR.Ymax = row + (4 * FontHeight) / 5; PenColor(BUTTONBACK); PaintRect(&s->sR); PushButton(&s->sR, true); /* * Now figure out where we want the slider piece to be. We XOR the * thing into place, to make it easier to move it. And we just paint * it by drawing a 10-wide vertical line. */ range = s->max - s->min; foffset = s->value - s->min; offset = foffset / range * (s->sR.Xmax - s->sR.Xmin); p.X = s->sR.Xmin + offset; p.X = max(s->sR.Xmin + 5, p.X); p.X = min(s->sR.Xmax - 5, p.X); R.Xmin = p.X - width / 2; R.Xmax = p.X + width / 2 - 1; R.Ymin = s->sR.Ymin + 2; R.Ymax = s->sR.Ymax - 2; while (R.Xmin < s->sR.Xmin + 2) OffsetRect(&R, 1, 0); while (R.Xmax > s->sR.Xmax - 2) OffsetRect(&R, -1, 0); s->bR = R; PenColor(LIGHTGRAY); PaintRect(&s->bR); PushButton(&s->bR, false); /* Now position and paint the value box. */ s->old_value = s->value; /* create the zed box */ #ifdef NOTINIES if (tinies) { int cx, cy; Centers(&s->sR, &cx, &cy); zwidth = (s->sR.Xmax - s->sR.Xmin - 10) / 6; row = s->tR.Ymax - FontHeight / 2 - 4; for (i = 0; i < 3; i++) { rect R1, R2; R1.Xmin = cx + i * zwidth + 2 * (i + 1); R1.Xmax = R1.Xmin + zwidth - 1; R1.Ymin = row; R1.Ymax = row + FontHeight / 2; R2.Xmax = cx - i * zwidth - 2 * (i + 1); R2.Xmin = R2.Xmax - zwidth + 1; R2.Ymin = row; R2.Ymax = row + FontHeight / 2; s->zR[3 + i] = R1; s->zR[2 - i] = R2; } zepps = -3; for (i = 0; i < 6; i++) { rect R; int cy; int zwidth3 = zwidth / 3; int zstart; int dashwidth = zwidth3 - 4; R = s->zR[i]; dashwidth = min(dashwidth, s->zR[i].Ymax - s->zR[i].Ymin - 4); Centers(&R, &cx, &cy); PenColor(8); PaintRect(&R); PushButton(&R, false); PenColor(7); switch (zepps) { case -3: case 3: zstart = cx - (3 * dashwidth / 2 + 4); dash_or_plus(zstart, cy + 1, dashwidth, zepps == 3); zstart = cx - dashwidth / 2; dash_or_plus(zstart, cy + 1, dashwidth, zepps == 3); zstart = cx + dashwidth / 2 + 4; dash_or_plus(zstart, cy + 1, dashwidth, zepps == 3); break; case -2: case 2: zstart = R.Xmin + zwidth / 2 - dashwidth - 2; dash_or_plus(zstart, cy + 1, dashwidth, zepps == 2); zstart = R.Xmin + zwidth / 2 + 2; dash_or_plus(zstart, cy + 1, dashwidth, zepps == 2); break; case -1: case 1: zstart = R.Xmin + zwidth / 2 - dashwidth / 2; dash_or_plus(zstart, cy + 1, dashwidth, zepps == 1); break; } zepps++; if (zepps == 0) zepps++; } } #endif }
void reposition_slider_v_base(slider * s, int selected, int floater, int numbers) { /* reposition the slider based on value v */ double range; double foffset; int offset; double barwidth = s->sR.Xmax - s->sR.Xmin; point p; rect R; s->value = max(s->value, s->min); s->value = min(s->value, s->max); #ifndef NOFLOATS if (floater) { long t; if (s->value > 0) t = (long) ((s->value + .00005) * 1000); else t = (long) ((s->value - .00005) * 1000); s->value = t / 1000.0; } #endif if (s->value == s->old_value) return; range = s->max - s->min; foffset = s->value - s->min; offset = foffset / range * barwidth; /* Screw this XOR shit, just slide the whole box. */ BackColor(selected == 2 ? ~BUTTONBACK : BUTTONBACK); p.X = s->sR.Xmin + offset; p.X = max(s->sR.Xmin + 5, p.X); p.X = min(s->sR.Xmax - 5, p.X); R.Xmin = p.X - s->bubblewidth / 2; R.Xmax = p.X + s->bubblewidth / 2 - 1; R.Ymin = s->sR.Ymin + 2; R.Ymax = s->sR.Ymax - 2; while (R.Xmin < s->sR.Xmin + 2) OffsetRect(&R, 1, 0); while (R.Xmax > s->sR.Xmax - 2) OffsetRect(&R, -1, 0); if (R.Xmin != s->bR.Xmin) { rect R1 = s->sR; ProtectRect(&R1); InsetRect(&R1, 1, 1); ClipRect(&R1); ScrollRect(&R1, -(s->bR.Xmin - R.Xmin), 0); ClipRect(&sR); ProtectOff(); } s->bR = R; /* Now paint the new number in */ #ifndef NONUMBERS if (numbers) { PaintNumberBoxEntry(&s->TB, s->value, (floater) ? GS_FLOAT : GS_UNSIGNED); } #endif s->old_value = s->value; }
void CWsRootWindow::ClearDisplay() { MWsScreenDevice *sd=static_cast<MWsScreenDevice*>(iScreen->ResolveObjectInterface(KMWsScreenDevice)); WS_ASSERT_ALWAYS(sd, EWsPanicScreenDeviceMissing); sd->ClearDisplay(BackColor()); }
bool MCImageBitmapToPICT(MCImageBitmap *p_bitmap, MCMacSysPictHandle &r_pict) { #ifdef LIBGRAPHICS_BROKEN bool t_success = true; Pixmap drawdata = nil, drawmask = nil; MCBitmap *maskimagealpha = nil; t_success = MCImageSplitPixmaps(p_bitmap, drawdata, drawmask, maskimagealpha); if (!t_success) return false; Rect t_rect; SetRect(&t_rect, 0, 0, p_bitmap->width, p_bitmap->height); GWorldPtr t_old_gworld; GDHandle t_old_gdevice; GetGWorld(&t_old_gworld, &t_old_gdevice); PixMapHandle t_draw_pixmap; t_draw_pixmap = GetGWorldPixMap((CGrafPtr)drawdata -> handle . pixmap); GWorldPtr t_img_gworld; t_img_gworld = NULL; if (t_success) { QDErr t_err; t_err = NewGWorld(&t_img_gworld, 32, &t_rect, NULL, NULL, 0); if (t_err != noErr) t_success = false; } if (t_success) { SetGWorld(t_img_gworld, GetGDevice()); PenMode(srcCopy); ForeColor(blackColor); BackColor(whiteColor); if (maskimagealpha != NULL) { GWorldPtr t_alpha_gworld; if (NewGWorldFromPtr(&t_alpha_gworld, 8, &t_rect, GetCTable(40), NULL, 0, maskimagealpha -> data, maskimagealpha -> bytes_per_line) == noErr) { const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; t_src_bits = GetPortBitMapForCopyBits((CGrafPtr)drawdata -> handle . pixmap); const BitMap *t_mask_bits; t_mask_bits = GetPortBitMapForCopyBits(t_alpha_gworld); EraseRect(&t_rect); CopyDeepMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect, srcCopy, NULL); } } else if (drawmask != NULL) { PixMapHandle t_mask_pixmap; t_mask_pixmap = GetGWorldPixMap((CGrafPtr)drawmask -> handle . pixmap); EraseRect(&t_rect); const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; LockPixels(t_draw_pixmap); t_src_bits = (BitMap *)*t_draw_pixmap; const BitMap *t_mask_bits; LockPixels(t_mask_pixmap); t_mask_bits = (BitMap *)*t_mask_pixmap; CopyMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect); UnlockPixels(t_mask_pixmap); UnlockPixels(t_draw_pixmap); } else { const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld); const BitMap *t_src_bits; LockPixels(t_draw_pixmap); t_src_bits = (BitMap *)*t_draw_pixmap; CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL); UnlockPixels(t_draw_pixmap); } } PicHandle t_handle; t_handle = NULL; if (t_success) { OpenCPicParams t_params; t_params . srcRect = t_rect; t_params . hRes = 72 << 16; t_params . vRes = 72 << 16; t_params . version = -2; t_params . reserved1 = 0; t_params . reserved2 = 0; t_handle = OpenCPicture(&t_params); if (t_handle == NULL) t_success = false; } if (t_success) { GWorldPtr t_pict_gworld; GDHandle t_pict_gdevice; GetGWorld(&t_pict_gworld, &t_pict_gdevice); PenMode(srcCopy); ForeColor(blackColor); BackColor(whiteColor); const BitMap *t_dst_bits; t_dst_bits = GetPortBitMapForCopyBits(t_pict_gworld); const BitMap *t_src_bits; t_src_bits = GetPortBitMapForCopyBits(t_img_gworld); CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL); ClosePicture(); } if (t_img_gworld != NULL) DisposeGWorld(t_img_gworld); SetGWorld(t_old_gworld, t_old_gdevice); MCscreen->freepixmap(drawdata); MCscreen->freepixmap(drawmask); if (maskimagealpha != nil) MCscreen->destroyimage(maskimagealpha); if (t_success) r_pict = (MCMacSysPictHandle)t_handle; return t_success; #else return false; #endif }
void ShowAdditionsWin(void) { Str255 next, back; Str255 compDescTitle; StringPtr selCompMsg; Handle listBoxRect; Rect dataBounds, listBoxFrame, viewRect; short reserr; int totalRows = 0, i, instChoice; Point cSize; Boolean bCellSelected; GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); gCurrWin = kAdditionsID; /* gControls->aw = (CompWin *) NewPtrClear(sizeof(CompWin)); */ GetResourcedString(next, rInstList, sNextBtn); GetResourcedString(back, rInstList, sBackBtn); // get controls listBoxRect = Get1Resource('RECT', rCompListBox); reserr = ResError(); if (reserr == noErr && listBoxRect != NULL) { HLock((Handle)listBoxRect); SetRect(&gControls->aw->compListBox, ((Rect*)*listBoxRect)->left, ((Rect*)*listBoxRect)->top, ((Rect*)*listBoxRect)->right, ((Rect*)*listBoxRect)->bottom); HUnlock((Handle)listBoxRect); } else { ErrorHandler(reserr, nil); return; } gControls->aw->compDescBox = NULL; gControls->aw->compDescBox = GetNewControl(rCompDescBox, gWPtr); if (!gControls->aw->compDescBox) { ErrorHandler(eMem, nil); return; } gControls->aw->compListBox.right -= kScrollBarWidth; instChoice = gControls->opt->instChoice-1; for (i=0; i<kMaxComponents; i++) { if (totalRows >= gControls->cfg->numComps) break; if (!gControls->cfg->comp[i].invisible && gControls->cfg->comp[i].additional && (gControls->cfg->st[instChoice].comp[i] == kInSetupType)) totalRows++; } SetRect(&dataBounds, 0, 0, 1, totalRows); SetPt( &cSize, 0, 0); gControls->aw->compList = LNew((const Rect*)&gControls->aw->compListBox, (const Rect*)&dataBounds, cSize, rCheckboxLDEF, gWPtr, true, false, false, true); (*gControls->aw->compList)->selFlags = lExtendDrag + lUseSense + lDoVAutoscroll; HLock((Handle)gControls->aw->compDescBox); SetRect(&viewRect, (*gControls->aw->compDescBox)->contrlRect.left, (*gControls->aw->compDescBox)->contrlRect.top, (*gControls->aw->compDescBox)->contrlRect.right, (*gControls->aw->compDescBox)->contrlRect.bottom); HUnlock((Handle)gControls->aw->compDescBox); viewRect.top += kInterWidgetPad; SetRect(&viewRect, viewRect.left + kTxtRectPad, viewRect.top + kTxtRectPad, viewRect.right - kTxtRectPad, viewRect.bottom - kTxtRectPad); TextFont(applFont); TextSize(9); gControls->aw->compDescTxt = TENew(&viewRect, &viewRect); TextFont(systemFont); TextSize(12); // populate controls bCellSelected = AddPopulateCompInfo(); // show controls GetResourcedString(compDescTitle, rInstList, sCompDescTitle); SetControlTitle(gControls->aw->compDescBox, compDescTitle); MoveTo( gControls->aw->compListBox.left, gControls->aw->compListBox.top - kInterWidgetPad); HLock(gControls->cfg->selCompMsg); selCompMsg = CToPascal(*gControls->cfg->selAddMsg); if (selCompMsg) DrawString( selCompMsg ); HUnlock(gControls->cfg->selCompMsg); SetRect(&listBoxFrame, gControls->aw->compListBox.left, --gControls->aw->compListBox.top, gControls->aw->compListBox.right + kScrollBarWidth, ++gControls->aw->compListBox.bottom); FrameRect(&listBoxFrame); ShowNavButtons( back, next ); if (bCellSelected) AddSetOptInfo(true); else DrawDiskSpaceMsgs( gControls->opt->vRefNum ); // default highlight first row AddInitRowHighlight(0); #if 0 RGBColor backColorOld; Rect adjustedRect, *clRect = &gControls->aw->compListBox; SetRect(&adjustedRect, clRect->left, clRect->top+1, clRect->right, clRect->bottom-1); GetBackColor(&backColorOld); BackColor(whiteColor); EraseRect(&adjustedRect); RGBBackColor(&backColorOld); #endif SetPort(oldPort); }
// by 한나 void swap(int *a, int*b, int x, int y, int x2, int y2) { int tmp, X, Y; int i, j, A, B = 0; tmp = *a; *a = *b; *b = tmp; DrawBoard(x, y); DrawBoard(x2, y2); X = Bomb(x, y, 1); Y = Bomb(x2, y2, 1); if (X + Y == 0) { BackColor('I'); DrawBoard(x, y); DrawBoard(x2, y2); Sleep(300); tmp = *a; *a = *b; *b = tmp; BackColor(' '); DrawBoard(x, y); DrawBoard(x2, y2); } else { /* end = clock(); timer = -((start - end) / CLOCKS_PER_SEC); BackColor(' '); color(15); SetCursors(50, 9); printf(" "); SetCursors(50, 9); printf("Time: %02d", timer); SetCursors(56, 9); printf("%02d", timer); */ //Sleep(800); drop(); while (1) { B = 0; for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { Sleep(10); A = Bomb(i, j, 1); drop(); B += A; } } if (B == 0) break; } } }
void CWsBackedUpWindow::ActivateGc() { iBitGc->Activate(iBitmapDevice); iBitGc->Reset(); iBitGc->SetBrushColor(BackColor()); }
// 게임 시작. // 커서가 가리키는 위치의 유니코드 배경 색 바꾸기. // 0,0일때 8 + 2*x, +2* y +3 위치에 배경색 설정 후 printf("유니"); 스위치문 갖다 넣기 int StartGame() { int i, j, A, B; ConfirmBoard(); BackColor(' '); color(15); SetCursors(50, 8); printf("Level:%d", level); SetCursors(50, 9); printf("Time: %d", timer); SetCursors(50, 10); printf("score:%d", score); SetCursors(50, 11); printf("fever: %2d", fev_lev); while (1) { B = 0; for (i = 0; i < BOARD_WIDTH; i++) { for (j = 0; j < BOARD_HEIGHT; j++) { Sleep(50); A = Bomb(i, j, 1); drop(); B += A; } } if (B == 0)break; } int x = 0, y = 0, x1 = 0, y1 = 0, x2 = -1, y2 = -1, sel = F, count = 0; char ip = '\0'; BackColor('G'); DrawBoard(x, y); work = 1; while (1) { if (start > end) fevt = fevt + (start - end) / 2; if (TEST == T) { SetCursors(50, 14); printf("%03d", (end - fevt) / CLOCKS_PER_SEC); } if ((end - fevt) / CLOCKS_PER_SEC == 10) { fever(0); } end = clock(); timer = -((start - end) / CLOCKS_PER_SEC); BackColor(' '); color(15); SetCursors(56, 9); printf("%02d", timer); if (timer > t_limit) { BackColor(' '); color(15); SetCursors(50, 7); printf("Game Over"); Sleep(2000); system("cls"); record_W(); exit(1); } if (_kbhit()) { if (sel != T) { if (x1 == x2 && y1 == y2) BackColor('W'); else BackColor(' '); DrawBoard(x1, y1); } BackColor('G'); ip = _getch(); switch (ip) { case LEFT: sel = F; if (x > 0) x -= 1; DrawBoard(x, y); break; case RIGHT: sel = F; if (x < BOARD_WIDTH - 1) x += 1; DrawBoard(x, y); break; case UP: ; sel = F; if (y > 0) y -= 1; DrawBoard(x, y); break; case DOWN: sel = F; if (y < BOARD_HEIGHT - 1) y += 1; DrawBoard(x, y); break; case SPACE: sel = T; if ((x1 == x2 + 1 && y1 == y2) || (x1 == x2&&y1 == y2 + 1) || (x1 == x2 - 1 && y1 == y2) || (x1 == x2&&y1 == y2 - 1) || count == 0)BackColor('W'); DrawBoard(x, y); count++; if (count == 1) { x2 = x; y2 = y; } if (count >= 2) { BackColor(' '); color(15); SetCursors(50, 8); printf("Level:%d", level); BackColor(' '); if ((x1 == x2 + 1 && y1 == y2) || (x1 == x2&&y1 == y2 + 1) || (x1 == x2 - 1 && y1 == y2) || (x1 == x2&&y1 == y2 - 1)) { swap(&board[x][y], &board[x2][y2], x, y, x2, y2); ConfirmBoard(); } BackColor(' '); DrawBoard(x, y); //DrawBoard(x2, y2); count = 0; x2 = -1; y2 = -1; } break; case ESC: sel = F; system("cls"); exit(1); break; } x1 = x; y1 = y; sel = F; SetCursors(0, 0); if (TEST == T) printf("%d %d\n%d %d %d \n %d", x1, y1, x2, y2, count, sel); } } }
void wxMacToolTip::Draw() { if ( m_label.Length() == 0 ) return ; if ( m_window == s_ToolTipWindowRef ) { m_shown = true ; #if TARGET_CARBON HMHelpContentRec tag ; tag.version = kMacHelpVersion; SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ; QDLocalToGlobalRect( GetWindowPort( m_window ) , &tag.absHotRect ) ; m_helpTextRef.Assign( m_label , wxFONTENCODING_DEFAULT ) ; tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ; tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ; tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ; tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ; tag.tagSide = kHMDefaultSide; HMDisplayTag( &tag ); #else wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) ); FontFamilyID fontId ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; GetFNum( fontName, &fontId ); TextFont( fontId ) ; TextSize( fontSize ) ; TextFace( fontStyle ) ; FontInfo fontInfo; ::GetFontInfo(&fontInfo); short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; short height = 0 ; int i = 0 ; int length = m_label.Length() ; int width = 0 ; int thiswidth = 0 ; int laststop = 0 ; wxCharBuffer text = m_label.mb_str( wxConvLocal) ; while( i < length ) { if( text[i] == 13 || text[i] == 10) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; height += lineh ; laststop = i+1 ; } i++ ; } if ( i - laststop > 0 ) { thiswidth = ::TextWidth( text , laststop , i - laststop ) ; if ( thiswidth > width ) width = thiswidth ; height += lineh ; } m_rect.left = m_position.x + kTipOffset; m_rect.top = m_position.y + kTipOffset; m_rect.right = m_rect.left + width + 2 * kTipBorder; m_rect.bottom = m_rect.top + height + 2 * kTipBorder; Rect r ; GetPortBounds( GetWindowPort( m_window ) , &r ) ; if ( m_rect.top < 0 ) { m_rect.bottom += -m_rect.top ; m_rect.top = 0 ; } if ( m_rect.left < 0 ) { m_rect.right += -m_rect.left ; m_rect.left = 0 ; } if ( m_rect.right > r.right ) { m_rect.left -= (m_rect.right - r.right ) ; m_rect.right = r.right ; } if ( m_rect.bottom > r.bottom ) { m_rect.top -= (m_rect.bottom - r.bottom) ; m_rect.bottom = r.bottom ; } ClipRect( &m_rect ) ; BackColor( whiteColor ) ; ForeColor(blackColor ) ; GWorldPtr port ; NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ; CGrafPtr origPort ; GDHandle origDevice ; GetGWorld( &origPort , &origDevice ) ; SetGWorld( port , NULL ) ; m_backpict = OpenPicture(&m_rect); CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), GetPortBitMapForCopyBits(port), &m_rect, &m_rect, srcCopy, NULL); ClosePicture(); SetGWorld( origPort , origDevice ) ; DisposeGWorld( port ) ; PenNormal() ; RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ; BackColor( whiteColor ) ; RGBForeColor( &tooltipbackground ) ; PaintRect( &m_rect ) ; ForeColor(blackColor ) ; FrameRect( &m_rect ) ; SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ; ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder); i = 0 ; laststop = 0 ; height = 0 ; while( i < length ) { if( text[i] == 13 || text[i] == 10) { ::DrawText( text , laststop , i - laststop ) ; height += lineh ; ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height ); laststop = i+1 ; } i++ ; } ::DrawText( text , laststop , i - laststop ) ; ::TextMode( srcOr ) ; #endif } }