这篇教程C++ DrawString函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DrawString函数的典型用法代码示例。如果您正苦于以下问题:C++ DrawString函数的具体用法?C++ DrawString怎么用?C++ DrawString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DrawString函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: SetWindowvoid ImportSampleDialog::DrawView() { SetWindow(LIST_WIDTH,LIST_SIZE+3) ; GUITextProperties props ;// Draw title// char title[40] ; SetColor(CD_NORMAL) ;// sprintf(title,"Sample Import from %s",currentPath_.GetName()) ;// w_.DrawString(title,pos,props) ;// Draw samples int x=1 ; int y=1 ; if (currentSample_<topIndex_) { topIndex_=currentSample_ ; } ; if (currentSample_>=topIndex_+LIST_SIZE) { topIndex_=currentSample_ ; } ; IteratorPtr<Path> it(sampleList_.GetIterator()) ; int count=0 ; char buffer[256] ; for(it->Begin(); !it->IsDone(); it->Next()) { if ((count>=topIndex_)&&(count<topIndex_+LIST_SIZE)) { Path ¤t=it->CurrentItem() ; const std::string p=current.GetName() ; if (count==currentSample_) { SetColor(CD_HILITE2) ; props.invert_=true ; } else { SetColor(CD_NORMAL) ; props.invert_=false ; } if (!current.IsDirectory()) { strcpy(buffer,p.c_str()) ; } else { buffer[0]='[' ; strcpy(buffer+1,p.c_str()) ; strcat(buffer,"]") ; } buffer[LIST_WIDTH-1]=0 ; DrawString(x,y,buffer,props) ; y+=1 ; } count++ ; } ; y=LIST_SIZE+2 ; int offset=LIST_WIDTH/4 ; SetColor(CD_NORMAL) ; for (int i=0; i<3; i++) { const char *text=buttonText[i] ; x=offset*(i+1)-strlen(text)/2 ; props.invert_=(i==selected_)?true:false ; DrawString(x,y,text,props) ; }} ;
开发者ID:EQ4,项目名称:LittleGPTracker,代码行数:68,
示例2: hsStringToWStringvoid plDynamicTextMsg::DrawString( int16_t x, int16_t y, const char *text ){ wchar_t *wString = hsStringToWString(text); DrawString(x,y,wString); delete [] wString;}
开发者ID:JECervini,项目名称:Plasma,代码行数:6,
示例3: IsEnabled//.........这里部分代码省略......... if (active) flags |= BControlLook::B_FOCUSED; be_control_look->DrawTextControlBorder(this, rect, updateRect, base, flags); rect = Bounds(); rect.right = fDivider - kLabelInputSpacing;// rect.right = fText->Frame().left - 2;// rect.right -= 3;//be_control_look->DefaultLabelSpacing(); be_control_look->DrawLabel(this, Label(), rect, updateRect, base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE)); return; } // outer bevel rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT); rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT); rgb_color lightenMax = tint_color(noTint, B_LIGHTEN_MAX_TINT); rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT); rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT); rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT); rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR); if (enabled) SetHighColor(darken1); else SetHighColor(noTint); StrokeLine(rect.LeftBottom(), rect.LeftTop()); StrokeLine(rect.RightTop()); if (enabled) SetHighColor(lighten2); else SetHighColor(lighten1); StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom()); // inner bevel rect.InsetBy(1.0f, 1.0f); if (active) { SetHighColor(navigationColor); StrokeRect(rect); } else { if (enabled) SetHighColor(darken4); else SetHighColor(darken2); StrokeLine(rect.LeftTop(), rect.LeftBottom()); StrokeLine(rect.LeftTop(), rect.RightTop()); SetHighColor(noTint); StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom()); StrokeLine(BPoint(rect.right, rect.top + 1.0f)); } // label if (Label()) { _ValidateLayoutData(); font_height& fontHeight = fLayoutData->font_info; float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent - fontHeight.descent) / 2 + fontHeight.ascent; float x; float labelWidth = StringWidth(Label()); switch (fLabelAlign) { case B_ALIGN_RIGHT: x = fDivider - labelWidth - kLabelInputSpacing; break; case B_ALIGN_CENTER: x = fDivider - labelWidth / 2.0; break; default: x = 0.0; break; } BRect labelArea(x, Bounds().top, x + labelWidth, Bounds().bottom); if (x < fDivider && updateRect.Intersects(labelArea)) { labelArea.right = fText->Frame().left - kLabelInputSpacing; BRegion clipRegion(labelArea); ConstrainClippingRegion(&clipRegion); SetHighColor(IsEnabled() ? ui_color(B_CONTROL_TEXT_COLOR) : tint_color(noTint, B_DISABLED_LABEL_TINT)); DrawString(Label(), BPoint(x, y)); } }}
开发者ID:mmanley,项目名称:Antares,代码行数:101,
示例4: FillRectvoid TextInput::Draw( Rect area ){ FillRect( Bounds(), 0x888888 ); DrawRect( Bounds(), 0x999999 ); DrawString( 2,2, m_text, 0 );}
开发者ID:AdamRLukaitis,项目名称:spoon,代码行数:6,
示例5: DrawTrainDetails/** * Draw the details for the given vehicle at the given position * * @param v current vehicle * @param left The left most coordinate to draw * @param right The right most coordinate to draw * @param y The y coordinate * @param vscroll_pos Position of scrollbar * @param vscroll_cap Number of lines currently displayed * @param det_tab Selected details tab */void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab){ /* get rid of awkward offset */ y -= WD_MATRIX_TOP; int sprite_height = ScaleGUITrad(GetVehicleHeight(VEH_TRAIN)); int line_height = max(sprite_height, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM); int sprite_y_offset = line_height / 2; int text_y_offset = (line_height - FONT_HEIGHT_NORMAL) / 2; /* draw the first 3 details tabs */ if (det_tab != TDW_TAB_TOTALS) { bool rtl = _current_text_dir == TD_RTL; Direction dir = rtl ? DIR_E : DIR_W; int x = rtl ? right : left; for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) { GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary); /* Draw sprites */ uint dx = 0; int px = x; const Train *u = v; do { Point offset; int width = u->GetDisplayImageWidth(&offset); if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) { int pitch = 0; const Engine *e = Engine::Get(v->engine_type); if (e->GetGRF() != NULL) { pitch = ScaleGUITrad(e->GetGRF()->traininfo_vehicle_pitch); } PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); VehicleSpriteSeq seq; u->GetImage(dir, EIT_IN_DETAILS, &seq); seq.Draw(px + (rtl ? -offset.x : offset.x), y - line_height * vscroll_pos + sprite_y_offset + pitch, pal, v->vehstatus & VS_CRASHED); } px += rtl ? -width : width; dx += width; u = u->Next(); } while (u != NULL && u->IsArticulatedPart()); bool separate_sprite_row = (dx > (uint)ScaleGUITrad(TRAIN_DETAILS_MAX_INDENT)); if (separate_sprite_row) { vscroll_pos--; dx = 0; } uint num_lines = max(1u, _cargo_summary.Length()); for (uint i = 0; i < num_lines; i++) { int sprite_width = max<int>(dx, ScaleGUITrad(TRAIN_DETAILS_MIN_INDENT)) + 3; int data_left = left + (rtl ? 0 : sprite_width); int data_right = right - (rtl ? sprite_width : 0); if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) { int py = y - line_height * vscroll_pos + text_y_offset; if (i > 0 || separate_sprite_row) { if (vscroll_pos != 0) GfxFillRect(left, py - WD_MATRIX_TOP - 1, right, py - WD_MATRIX_TOP, _colour_gradient[COLOUR_GREY][5]); } switch (det_tab) { case TDW_TAB_CARGO: if (i < _cargo_summary.Length()) { TrainDetailsCargoTab(&_cargo_summary[i], data_left, data_right, py); } else { DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE); } break; case TDW_TAB_INFO: if (i == 0) TrainDetailsInfoTab(v, data_left, data_right, py); break; case TDW_TAB_CAPACITY: if (i < _cargo_summary.Length()) { TrainDetailsCapacityTab(&_cargo_summary[i], data_left, data_right, py); } else { SetDParam(0, STR_EMPTY); DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY); } break; default: NOT_REACHED(); } } vscroll_pos--; } } } else { CargoArray act_cargo; CargoArray max_cargo; Money feeder_share = 0;//.........这里部分代码省略.........
开发者ID:tony,项目名称:openttd,代码行数:101,
示例6: _jGetStringint _jGetString(char *dest, char *start, int maxlen, GS_TYPE type){ /* * Returns 1 if OK; 0 if rejected or quit. */ int y; event e; int i; int startx; int key; curpos = 0; HideCursor(); startx = QueryX(); y = QueryY(); lrects = malloc(maxlen * sizeof(rect)); for (i = 0; i < maxlen; i++) { rect R; R.Xmin = startx + i * StringWidthX; R.Xmax = R.Xmin + StringWidthX - 1; R.Ymax = y; R.Ymin = R.Ymax - FontHeight + 1; lrects[i] = R; } tbuf = malloc(maxlen + 1); memset(tbuf, ' ', maxlen); tbuf[maxlen] = 0; i = 0; if (start) { for (i = 0; i < maxlen && start[i]; i++) tbuf[i] = start[i]; } curpos = min(i, maxlen - 1); TextAlign(alignLeft, alignBottom); DrawString(tbuf); /* Now highlight somebody */ InvertRect(&lrects[curpos]); while (1) { key = 0; KeyEvent(true, &e); if (e.ASCII && e.ASCII != 0xe0) key = e.ASCII; else if (e.ScanCode != 0xff) key = e.ScanCode << 8; if (key) { if (key == 0x0d || key == 0x1b) break; if (key == 0x08) /* backspace */ backspace(maxlen); else if (key == 0x15) /* control U */ { while(curpos) backspace(maxlen); } else { int acceptable = 0; if (type == GS_ANYTHING) acceptable = isprint(key); else if (type == GS_INTEGER) acceptable = isdigit(key) || key == '-'; else if (type == GS_UNSIGNED) acceptable = isdigit(key); else if (type == GS_FLOAT) acceptable = isdigit(key) || key == '.' || key == '-' || key == 'E' || key == 'e'; if (acceptable) { InvertRect(&lrects[curpos]); MoveTo(lrects[curpos].Xmin, lrects[curpos].Ymax); DrawChar(key); tbuf[curpos] = key; if (curpos < maxlen - 1) curpos++;//.........这里部分代码省略.........
开发者ID:mrchurrisky,项目名称:chaos,代码行数:101,
|