int egg_tips()//打印egg库版本的初始化提示信息 { HEGG first_egg;//打印初始信息的egg char infor1[]="欢迎来到黄金梅里号~~"; char infor2[]="为了使您“旅途愉快”,请先进行一下电梯参数的参数配置:"; int situ,i/*counter*/; int mouseX,mouseY; int dealwith_click(int num); first_egg=LayEgg(); DrawBitmap("bitmap//开始.bmp"); MovePen(200,670); SetPenColor(BLUE); act_string(infor1,70); MovePen(200,650); SetPenColor(DARK_MAGENTA); act_string(infor2,60); //initialization MovePen(200,590); DrawBitmap("bitmap//scale.bmp"); if(delay==DEFAULT_DELAY && ratio==DEFAULT_RATIO && strategy==DEFAULT_STRATEGY) { MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_R); } switch(delay) { case 500: MovePen(click[3].leftup_x,click[3].leftup_y); DrawBitmap(click[3].bitmap_R); break; case 1000: MovePen(click[4].leftup_x,click[4].leftup_y); DrawBitmap(click[4].bitmap_R); break; case 1500: MovePen(click[5].leftup_x,click[5].leftup_y); DrawBitmap(click[5].bitmap_R); break; case 2000: MovePen(click[6].leftup_x,click[6].leftup_y); DrawBitmap(click[6].bitmap_R); break; case 3000: MovePen(click[7].leftup_x,click[7].leftup_y); DrawBitmap(click[7].bitmap_R); break; } MovePen(click[7+ratio].leftup_x,click[7+ratio].leftup_y); DrawBitmap(click[7+ratio].bitmap_R); MovePen(click[12+strategy].leftup_x,click[12+strategy].leftup_y); DrawBitmap(click[12+strategy].bitmap_R); while((situ=WaitForEvent())!=0) { mouseX=(int)GetMouseX(); mouseY=(int)GetMouseY(); if(situ==KEYDOWN) { for(i=0;i<19;i++) { if(click[i].leftup_x<=mouseX && click[i].leftup_y>=mouseY && click[i].rightdown_x>=mouseX && click[i].rightdown_y<=mouseY) { int r; if((r=dealwith_click(i))==1) { EatEgg(); return 1; } else if(r==-1) { EatEgg(); return -1; } break; } } } } EatEgg(); return 0; }
int dealwith_click(int num) { void clean(int order); switch(num) { case 0: delay=1000; ratio=5; strategy=1; clean(0);clean(1);clean(2); //unvalue all clicks MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_R); MovePen(click[4].leftup_x,click[4].leftup_y); DrawBitmap(click[4].bitmap_R); MovePen(click[12].leftup_x,click[12].leftup_y); DrawBitmap(click[12].bitmap_R); MovePen(click[13].leftup_x,click[13].leftup_y); DrawBitmap(click[13].bitmap_R); break; case 1: case 2: break; //change delay case 3: case 4: case 5: case 6: case 7: switch(num) { case 3: delay=500; break; case 4: delay=1000; break; case 5: delay=1500; break; case 6: delay=2000; break; case 7: delay=3000; break; } clean(0); MovePen(click[num].leftup_x,click[num].leftup_y); DrawBitmap(click[num].bitmap_R); //unvalue default MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_B); break; //change ratio case 8: case 9: case 10: case 11: case 12: ratio=num-7; clean(1); MovePen(click[num].leftup_x,click[num].leftup_y); DrawBitmap(click[num].bitmap_R); //unvalue default MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_B); break; //change strategy case 13: case 14: case 15: case 16: strategy=num-12; clean(2); MovePen(click[num].leftup_x,click[num].leftup_y); DrawBitmap(click[num].bitmap_R); //unvalue default MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_B); break; case 17: return -1; case 18: return 1; } return 0; }
void ColorStepView::Draw(BRect updateRect) { BView *view = NULL; if(fOffScreenView){ view = fOffScreenView; } else{ view = this; } if (!fOffScreenBitmap || !fOffScreenBitmap->Lock()) return; view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillRect(updateRect); BRect colorBarRect = fSlider->BarFrame(); colorBarRect.top = 0; colorBarRect.bottom = kColorBarHeight; colorBarRect.OffsetTo(colorBarRect.left, fSlider->Frame().bottom); float pos = 0.0; for (int i = fPerformanceList->CountItems() - 1; i >= 0 ; i--) { performance_step* perfState = fPerformanceList->ItemAt(i); float nextPos = perfState->cpu_usage; float width = colorBarRect.Width(); BRect subRect(colorBarRect); subRect.left += pos * width; subRect.right = colorBarRect.left + nextPos * width; view->SetHighColor(perfState->color); view->FillRect(subRect); pos = nextPos; } // draw label if (IsEnabled()) { view->SetHighColor(0, 0, 0); } else { view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT)); } font_height fontHeight; GetFontHeight(&fontHeight); float totalFontHeight = fontHeight.descent + fontHeight.ascent; view->DrawString(fMinFrequencyLabel.String(), BPoint(0.0, colorBarRect.bottom + totalFontHeight + 5)); view->DrawString(fMaxFrequencyLabel.String(), BPoint(Bounds().right - StringWidth(fMaxFrequencyLabel.String()), colorBarRect.bottom + totalFontHeight + 5)); // blit bitmap view->Sync(); fOffScreenBitmap->Unlock(); DrawBitmap(fOffScreenBitmap, B_ORIGIN); BView::Draw(updateRect); }
void egg_outer_condition(int floor,int dir)//打印egg库版本电梯外部的运行状态提示(floor为楼层 dir为方向 1上 -1下 0停 -2空闲) { //static int step=0; while (bitmap==1); ng=1; SetActiveEgg(main_egg); if (dir==1) { MovePen(843,348); DrawBitmap("bitmap//外部上2.bmp"); MovePen(843,282); DrawBitmap("bitmap//外部下1.bmp"); } else if (dir==-1) { MovePen(843,348); DrawBitmap("bitmap//外部上1.bmp"); MovePen(843,282); DrawBitmap("bitmap//外部下2.bmp"); } else { MovePen(843,348); DrawBitmap("bitmap//外部上1.bmp"); MovePen(843,282); DrawBitmap("bitmap//外部下1.bmp"); } ng=0; while (bitmap==1); ng=1; MovePen(843,216); switch (floor) { case 1: DrawBitmap("bitmap//外部1.bmp"); break; case 2: DrawBitmap("bitmap//外部2.bmp"); break; case 3: DrawBitmap("bitmap//外部3.bmp"); break; case 4: DrawBitmap("bitmap//外部4.bmp"); break; case 5: DrawBitmap("bitmap//外部5.bmp"); break; case 6: DrawBitmap("bitmap//外部6.bmp"); break; case 7: DrawBitmap("bitmap//外部7.bmp"); break; case 8: DrawBitmap("bitmap//外部8.bmp"); break; case 9: DrawBitmap("bitmap//外部9.bmp"); break; default: break; } ng=0; return; }
void ActivityView::_DrawHistory(bool drawBackground) { _UpdateOffscreenBitmap(); BView* view = this; if (fOffscreen != NULL) { fOffscreen->Lock(); view = _OffscreenView(); } BRect frame = _HistoryFrame(); BRect outerFrame = frame.InsetByCopy(-2, -2); // draw the outer frame uint32 flags = 0; if (!drawBackground) flags |= BControlLook::B_BLEND_FRAME; be_control_look->DrawTextControlBorder(this, outerFrame, outerFrame, fLegendBackgroundColor, flags); // convert to offscreen view if necessary if (view != this) frame.OffsetTo(B_ORIGIN); view->SetLowColor(fHistoryBackgroundColor); view->FillRect(frame, B_SOLID_LOW); uint32 step = 2; uint32 resolution = fDrawResolution; if (fDrawResolution > 1) { step = 1; resolution--; } uint32 width = frame.IntegerWidth() - 10; uint32 steps = width / step; bigtime_t timeStep = RefreshInterval() * resolution; bigtime_t now = system_time(); // Draw scale // TODO: add second markers? view->SetPenSize(1); rgb_color scaleColor = view->LowColor(); uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3; if (average < 96) scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT); else scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT); view->SetHighColor(scaleColor); view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2), BPoint(frame.right, frame.top + frame.Height() / 2)); // Draw values view->SetPenSize(1.5); BAutolock _(fSourcesLock); for (uint32 i = fSources.CountItems(); i-- > 0;) { ViewHistory* viewValues = fViewValues.ItemAt(i); DataSource* source = fSources.ItemAt(i); DataHistory* values = fValues.ItemAt(i); viewValues->Update(values, steps, fDrawResolution, now, timeStep, RefreshInterval()); uint32 x = viewValues->Start() * step; BShape shape; bool first = true; for (uint32 i = viewValues->Start(); i < steps; x += step, i++) { float y = _PositionForValue(source, values, viewValues->ValueAt(i)); if (first) { shape.MoveTo(BPoint(x, y)); first = false; } else shape.LineTo(BPoint(x, y)); } view->SetHighColor(source->Color()); view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN); view->MovePenTo(B_ORIGIN); view->StrokeShape(&shape); } // TODO: add marks when an app started or quit view->Sync(); if (fOffscreen != NULL) { fOffscreen->Unlock(); DrawBitmap(fOffscreen, outerFrame.LeftTop()); } }
void BStatusView::Draw(BRect updateRect) { if (fBitmap) { BPoint location; location.x = (fStatusBar->Frame().left - fBitmap->Bounds().Width()) / 2; location.y = (Bounds().Height()- fBitmap->Bounds().Height()) / 2; DrawBitmap(fBitmap, location); } BRect bounds(Bounds()); be_control_look->DrawRaisedBorder(this, bounds, updateRect, ViewColor()); SetHighColor(0, 0, 0); BPoint tp = fStatusBar->Frame().LeftBottom(); font_height fh; GetFontHeight(&fh); tp.y += ceilf(fh.leading) + ceilf(fh.ascent); if (IsPaused()) { DrawString(B_TRANSLATE("Paused: click to resume or stop"), tp); return; } BFont font; GetFont(&font); float normalFontSize = font.Size(); float smallFontSize = max_c(normalFontSize * 0.8f, 8.0f); float availableSpace = fStatusBar->Frame().Width(); availableSpace -= be_control_look->DefaultLabelSpacing(); // subtract to provide some room between our two strings float destinationStringWidth = 0.f; BString destinationString(_DestinationString(&destinationStringWidth)); availableSpace -= destinationStringWidth; float statusStringWidth = 0.f; BString statusString(_StatusString(availableSpace, smallFontSize, &statusStringWidth)); if (statusStringWidth > availableSpace) { TruncateString(&destinationString, B_TRUNCATE_MIDDLE, availableSpace + destinationStringWidth - statusStringWidth); } BPoint textPoint = fStatusBar->Frame().LeftBottom(); textPoint.y += ceilf(fh.leading) + ceilf(fh.ascent); if (destinationStringWidth > 0) { DrawString(destinationString.String(), textPoint); } SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT)); font.SetSize(smallFontSize); SetFont(&font, B_FONT_SIZE); textPoint.x = fStatusBar->Frame().right - statusStringWidth; DrawString(statusString.String(), textPoint); font.SetSize(normalFontSize); SetFont(&font, B_FONT_SIZE); }
void TouchpadView::DrawSliders() { BView* view = fOffScreenView != NULL ? fOffScreenView : this; if (!LockLooper()) return; if (fOffScreenBitmap->Lock()) { view->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->FillRect(Bounds()); view->SetHighColor(100, 100, 100); view->FillRoundRect(fPadRect, 4, 4); int32 dragSize = 3; // half drag size // scroll areas view->SetHighColor(145, 100, 100); BRect rightRect(fPadRect.left + fXScrollRange, fPadRect.top, fPadRect.right, fPadRect.bottom); view->FillRoundRect(rightRect, 4, 4); BRect bottomRect(fPadRect.left, fPadRect.top + fYScrollRange, fPadRect.right, fPadRect.bottom); view->FillRoundRect(bottomRect, 4, 4); // Stroke Rect view->SetHighColor(100, 100, 100); view->SetPenSize(2); view->StrokeRoundRect(fPadRect, 4, 4); // x scroll range line view->SetHighColor(200, 0, 0); view->StrokeLine(BPoint(fPadRect.left + fXScrollRange, fPadRect.top), BPoint(fPadRect.left + fXScrollRange, fPadRect.bottom)); fXScrollDragZone = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); fXScrollDragZone1 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.top - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.top + dragSize); view->FillRect(fXScrollDragZone1); fXScrollDragZone2 = BRect(fPadRect.left + fXScrollRange - dragSize, fPadRect.bottom - dragSize, fPadRect.left + fXScrollRange + dragSize, fPadRect.bottom + dragSize); view->FillRect(fXScrollDragZone2); // y scroll range line view->StrokeLine(BPoint(fPadRect.left, fPadRect.top + fYScrollRange), BPoint(fPadRect.right, fPadRect.top + fYScrollRange)); fYScrollDragZone = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); fYScrollDragZone1 = BRect(fPadRect.left - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.left + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone1); fYScrollDragZone2 = BRect(fPadRect.right - dragSize, fPadRect.top + fYScrollRange - dragSize, fPadRect.right + dragSize, fPadRect.top + fYScrollRange + dragSize); view->FillRect(fYScrollDragZone2); view->Sync(); fOffScreenBitmap->Unlock(); DrawBitmap(fOffScreenBitmap, B_ORIGIN); } UnlockLooper(); }
// CFepLayoutChoiceList::DrawItem // Draw a choice list item. // (other items were commented in a header). // --------------------------------------------------------------------------- // void CFepLayoutChoiceList::DrawItem(const TRect& aRect, const CFepLayoutChoiceList::SItem& aItem, TBool aErase, TBool aFocus) { if(iWndControl) return; CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); if( aErase ) { SetBorderColor( BkColor() ); //DrawChoiceListBackground( aRect );//, EFalse); } if( aFocus ) { //draw focus bitmap TRect rtFocusRect(iItemFocusRect); TRect rtFocusInBmp(TPoint(0,0), iItemFocusRect.Size()); rtFocusRect.Move(aRect.iTl); TRect rtInnerRect( rtFocusRect ); rtInnerRect.Shrink( 5, 5 ); if( iSubItemSkinID.iMajor != EAknsMajorNone && iSubItemSkinID.iMinor != EAknsMinorNone) { gc->Activate( BitmapDevice() ); AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *gc, rtFocusRect, rtInnerRect, iSubItemSkinID, KAknsIIDDefault ); } else { //mask bitmaps------- gc->Activate( MaskBitmapDevice() ); if( iItemFocusBmpMask ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmpMask, iItemFocusBmpMask->SizeInPixels() == rtFocusInBmp.Size()); } //front bitmaps------- gc->Activate( BitmapDevice() ); if( iItemFocusBmp ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmp, iItemFocusBmp->SizeInPixels() == rtFocusInBmp.Size()); } } } //draw text if (iFont) { gc->UseFont(iFont); gc->SetBrushStyle( CGraphicsContext::ENullBrush ); gc->SetPenColor(iFontColor); gc->SetPenStyle(CGraphicsContext::ESolidPen); gc->DrawText(aItem.iText, aRect, iBaseline, CGraphicsContext::ELeft, iMargin); gc->DiscardFont(); } }
void BitmapView::Draw(BRect updateRect) { SetDrawingMode(B_OP_ALPHA); DrawBitmap(m_bitmap); }