示例#1
0
void Graphics::DrawRectangle(Pen* pen, const Rect& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	PenPrivate* pp = reinterpret_cast<PenPrivate*>(pen->_private);
	cairo_pattern_t* cp = pp->pattern;
	cairo_set_source(cg, cp);
	cairo_set_line_width(cg, pp->width);
	cairo_translate(cg, rc.GetLeft(), rc.GetTop());
	cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
	cairo_stroke(cg);
	cairo_restore(cg);
}
示例#2
0
void Graphics::FillRectangle(Brush* brush, const Rect& rc) {
	cairo_t* cg = reinterpret_cast<cairo_t*>(_private);
	cairo_save(cg);
	if(cg!=0) {
		cairo_pattern_t* cp = reinterpret_cast<cairo_pattern_t*>(brush->_private);
		if(cp!=0) {
			cairo_set_source(cg, cp);
			cairo_translate(cg, rc.GetLeft(), rc.GetTop());
			cairo_rectangle(cg, 0, 0, rc.GetWidth(), rc.GetHeight());
			cairo_fill(cg);
		}
	}
	cairo_restore(cg);
}
示例#3
0
int Navigator::LineDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style, int x) const
{
	w.DrawRect(r, paper);
	const NavLine& l = q.To<NavLine>();
	x += r.left;
	String p = GetSourceFilePath(l.file);
	int y = r.top + (r.GetHeight() - StdFont().GetCy()) / 2;
	PaintTeXt(w, x, y, GetFileName(GetFileFolder(p)) + "/", StdFont(), ink);
	PaintTeXt(w, x, y, GetFileName(p), StdFont().Bold(), ink);
	PaintTeXt(w, x, y, " (", StdFont(), ink);
	PaintTeXt(w, x, y, AsString(l.line), StdFont().Bold(), ink);
	PaintTeXt(w, x, y, ")", StdFont(), ink);
	return x - r.left;
}
示例#4
0
int Navigator::NavigatorDisplay::DoPaint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
	int ii = q;
	if(ii < 0 || ii >= item.GetCount())
		return 0;
	const NavItem& m = *item[ii];
	bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT);

	int x = r.left;
	int ry = r.top + r.GetHeight() / 2;
	int y = ry - Draw::GetStdFontCy() / 2;

	if(findarg(m.kind, KIND_FILE, KIND_NEST) >= 0) {
		w.DrawRect(r, focuscursor ? paper : m.kind == KIND_NEST ? Blend(SColorMark, SColorPaper, 220)
		                                    : SColorFace);
		if(m.kind == KIND_FILE)
			return PaintFileName(w, r, m.type, ink);
		String h = FormatNest(m.type);
		w.DrawText(x, y, h, StdFont().Bold(), ink);
		return GetTextSize(h, StdFont().Bold()).cx;
	}
	
	w.DrawRect(r, paper);
	if(m.kind == KIND_LINE) {
		w.DrawText(x, y, m.type, StdFont().Bold(), ink);
		return GetTextSize(m.type, StdFont().Bold()).cx;
	}

	PaintCppItemImage(w, x, ry, m.access, m.kind, focuscursor);

	x += Zx(15);
	Vector<ItemTextPart> n = ParseItemNatural(m.name, m.natural, m.ptype, m.pname, m.type,
	                                          m.tname, m.ctname, ~m.natural + m.at);
	int starti = 0;
	for(int i = 0; i < n.GetCount(); i++)
		if(n[i].type == ITEM_NAME) {
			starti = i;
			break;
		}
	PaintText(w, x, y, m.natural, n, starti, n.GetCount(), focuscursor, ink, false);
	if(starti) {
		const char *h = " : ";
		w.DrawText(x, y, h, BrowserFont(), SColorText);
		x += GetTextSize(h, BrowserFont()).cx;
	}
	PaintText(w, x, y, m.natural, n, 0, starti, focuscursor, ink, false);
	return x;
}
示例#5
0
void StdDisplayClass::Paint0(Draw& w, const Rect& r, const Value& q,
                             Color ink, Color paper, dword s) const {
	LLOG("StdDisplay::Paint0: " << q << " ink:" << ink << " paper:" << paper);
	WString txt;
	Font font = StdFont();
	int a = align;
	int x = r.left;
	int width = r.GetWidth();
	if(IsType<AttrText>(q)) {
		const AttrText& t = ValueTo<AttrText>(q);
		txt = t.text;
		font = t.font;
		if(!IsNull(t.paper))
			paper = t.paper;
		if(!IsNull(t.ink))
			ink = t.ink;
		if(!IsNull(t.normalink) && !(s & (CURSOR|SELECT|READONLY)))
			ink = t.normalink;
		if(!IsNull(t.normalpaper) && !(s & (CURSOR|SELECT|READONLY)))
			paper = t.normalpaper;
		if(!IsNull(t.align))
			a = t.align;
		if(!IsNull(t.img)) {
			Size isz = t.img.GetSize();
			w.DrawImage(x, r.top + max((r.Height() - isz.cy) / 2, 0), t.img);
			x += isz.cx + t.imgspc;
		}
	}
	else
		txt = IsString(q) ? q : StdConvert().Format(q);
	Size tsz = GetTLTextSize(txt, font);
	if(a == ALIGN_RIGHT)
		x = r.right - tsz.cx;
	if(a == ALIGN_CENTER)
		x += (width - tsz.cx) / 2;
	int tcy = GetTLTextHeight(txt, font);
	int tt = r.top + max((r.Height() - tcy) / 2, 0);
	if(tsz.cx > width) {
		Size isz = DrawImg::threedots().GetSize();
		int wd = width - isz.cx;
		w.Clip(r.left, r.top, wd, r.GetHeight());
		DrawTLText(w, x, tt, width, txt, font, ink);
		w.End();
		w.DrawImage(r.left + wd, tt + font.Info().GetAscent() - isz.cy, DrawImg::threedots(), ink);
	}
	else
		DrawTLText(w, x, tt, width, txt, font, ink);
}
示例#6
0
文件: Bar.cpp 项目: ultimatepp/mirror
	virtual void Paint(Draw& w, const Rect& r, const Value& q,
	                   Color ink, Color paper, dword style) const
	{
		w.DrawRect(r, paper);
		Image m = q;
		if(IsNull(m))
			return;
		Size isz = m.GetSize();
		if(isz.cx > 200 || isz.cy > 200)
			m = IconDesImg::LargeImage();
		else
		if(isz.cx > r.GetWidth() || isz.cy > r.GetHeight())
			m = CachedRescale(m, GetFitSize(m.GetSize(), r.GetSize()));
		Point p = r.CenterPos(m.GetSize());
		w.DrawImage(p.x, p.y, m);
	}
示例#7
0
	void Window::FullScreen()
	{
		::GetClientRect(hWnd_, &restoreFullRect_);
		Point point;
		::ClientToScreen(hWnd_, &point);
		restoreFullRect_.left = point.x;
		restoreFullRect_.top = point.y;
		restoreFullRect_.right += point.x;
		restoreFullRect_.bottom += point.y;
		MONITORINFO oMonitor = {};
		oMonitor.cbSize = sizeof(oMonitor);
		::GetMonitorInfo(::MonitorFromWindow(*this, MONITOR_DEFAULTTONEAREST), &oMonitor);
		Rect rcWork = oMonitor.rcWork;

		::SetWindowPos(hWnd_, nullptr, rcWork.left, rcWork.top, rcWork.GetWidth(), rcWork.GetHeight(), SWP_SHOWWINDOW | SWP_NOZORDER);
	}
示例#8
0
void DockCont::Handle::Paint(Draw& w)
{
	if (IsShown() && dc) {
		const DockableCtrl::Style &s = dc->GetStyle();
		Rect r = GetSize();
		const Rect &m = s.handle_margins;
		Point p;

		if (s.handle_vert)
			p = Point(r.left-1 + m.left, r.bottom - m.bottom);
		else
			p = Point(r.left + m.left, r.top + m.top);
		ChPaint(w, r, s.handle[focus]);

		Image img = dc->GetIcon();
		if (!img.IsEmpty()) {
			if (s.handle_vert) {
				int isz = r.GetWidth();
				p.y -= isz;
				isz -= (m.left + m.right);
				ChPaint(w, max(p.x+m.left, r.left), p.y, isz, isz, img);
				p.y -= 2;
			}
			else {
				int isz = r.GetHeight();
				isz -= (m.top + m.bottom);
				ChPaint(w, p.x, max(p.y, r.top), isz, isz, img);
				p.x += isz + 2;
			}
		}
		if (!s.title_font.IsNull()) {
			Ctrl *c = GetLastChild();
			while (c && !c->IsShown() && c->GetParent())
				c = c->GetNext();
			if (s.handle_vert)
				r.top = c ? c->GetRect().bottom + m.top : m.top;
			else
				r.right = c ? c->GetRect().left + m.right : m.right;
			w.Clip(r);
			WString text = IsNull(dc->GetGroup()) ? dc->GetTitle() : (WString)Format("%s (%s)", dc->GetTitle(), dc->GetGroup());
			w.DrawText(p.x, p.y, s.handle_vert ? 900 : 0, text, s.title_font, s.title_ink[focus]);
			w.End();
		}
	}
}
示例#9
0
void Ctrl::WndSetPos(const Rect& rect)
{
	LLOG("WndSetPos0 " << rect);
	GuiLock __;
	if(!IsOpen())
		return;
	Ptr<Ctrl> this_ = this;
	SweepConfigure(false); // Remove any previous GDK_CONFIGURE for this window
	if(!this_ || !IsOpen())
		return;
//	gtk_window_move(gtk(), rect.left, rect.top);
//	gtk_window_resize(gtk(), rect.GetWidth(), rect.GetHeight());
	gdk_window_move_resize(gdk(), rect.left, rect.top, rect.GetWidth(), rect.GetHeight());
	int t0 = msecs();
	do { // Wait up to 500ms for corresponding GDK_CONFIGURE to arrive
		if(SweepConfigure(true))
			break;
	}
	while(msecs() - t0 < 500);
	LLOG("-- WndSetPos0 " << rect << " " << msecs() - t0);
}
示例#10
0
void SetSurface(SystemDraw& w, const Rect& dest, const RGBA *pixels, Size srcsz, Point srcoff)
{
	GuiLock __;
	XImage ximg;
	sInitXImage(ximg, srcsz);
	ximg.bitmap_pad = 32;
	ximg.bytes_per_line = sizeof(RGBA) * srcsz.cx;
	ximg.bits_per_pixel = 32;
	ximg.blue_mask = 0x00ff0000;
	ximg.green_mask = 0x0000ff00;
	ximg.red_mask = 0x000000ff;
	ximg.bitmap_unit = 32;
	ximg.depth = 24;
	ximg.data = (char *)pixels;
	XInitImage(&ximg);
	Drawable dw = w.GetDrawable();
	GC gc = XCreateGC(Xdisplay, dw, 0, 0);
	Point p = dest.TopLeft() + w.GetOffset();
	XPutImage(Xdisplay, dw, gc, &ximg, srcoff.x, srcoff.y,
	          p.x, p.y, dest.GetWidth(), dest.GetHeight());
	XFreeGC(Xdisplay, gc);
}
示例#11
0
void ViewContext::SetupViewport(const Rect &size, SCREEN_ORIENTATION_ANGLE screenOrientation)
{
	Rect viewport;
	
	if (m_viewportIsFixedSize)
	{
		viewport = m_viewport;
		m_screenOrientation = SCREEN_ANGLE_0;
	}
	else
	{
		// based on the orientation, we may need to swap the width/height
		// of the passed viewport dimensions
		// (we don't do viewport rotation if the viewport is fixed)
		if (!IgnoringScreenRotation() && (screenOrientation == SCREEN_ANGLE_90 || screenOrientation == SCREEN_ANGLE_270))
		{
			// swap width and height
			viewport.left = size.top;
			viewport.top = size.left;
			viewport.right = size.bottom;
			viewport.bottom = size.right;
		}
		else
			viewport = size;
		
		// we **don't** want this to be rotated
		m_viewport = size;
		
		m_screenOrientation = screenOrientation;
	}
	
	// we **do** obviously want this to be rotated (if there is a rotation)
	GL_CALL(glViewport(viewport.left, viewport.top, viewport.GetWidth(), viewport.GetHeight()));
		
	// we also **don't** want the camera to work with a rotated viewport
	if (m_camera != NULL)
		m_camera->OnResize(m_viewport);
}
示例#12
0
void SDLExample::Layout() {
	SDLCtrl::Layout();
	if (!IsReady())
		return;
	
	Rect r = GetRect();
	for(int i = 0; i < r.GetWidth(); i++)
		sintab[i] = sin(i * M_PI / 180.0);

	for(int i = 0; i < MAXPOINT; i++) {
		points[i].x   = rand() % (r.GetWidth() - 1);
		points[i].y   = rand() % (r.GetHeight() - 1);
		points[i].sx  = (rand() & 1) + 1;
		points[i].sy  = (rand() & 1) + 1;
		points[i].col = (rand() % 255);
	}
	
	if (!demoInitialized)
		return;
	
	int width = GetWidth();
	int height = GetHeight();
	
	surf.Resize(width, height);
	
	SetupPalette(surf.GetSurface());
	SetupPalette(GetSurface());
	
	j = 0;
	k = 0;
	len0 = LengthStr(scroll[j]);
	len1 = len0;
	xmax = (width - len1) / 2;
	x0 = width;
	x1 = -len0;	
}
示例#13
0
void MultiButton::Lay(Rect& r)
{
	int border, lx, rx;
	bool frm = Metrics(border, lx, rx);
	bool left = false;
	bool right = false;
	for(int i = 0; i < button.GetCount(); i++) {
		SubButton& b = button[i];
		int cx = 0; int x = 0;
		GetPos(b, lx, rx, x, cx);
		(b.left ? left : right) = true;
	}
	if(ComplexFrame()) {
		r.right = r.left + rx;
		r.left += lx;
	}
	else
	if(frm) {
		Rect m = GetMargin();
		r = Rect(r.left + max(lx, m.left), r.top + m.top, min(rx, r.right - m.right), r.bottom - m.bottom);
	}
	else {
		Rect m = style->margin;
		r = Rect(r.left + max(lx, m.left), r.top + m.top, min(rx, r.right - m.right), r.bottom - m.bottom);
		if(!IsTrivial() || style->trivialsep) {
			if(left)
				r.left++;
			if(right)
				r.right--;
		}
	}
	if(!IsNull(valuecy)) {
		r.top += (r.GetHeight() - valuecy) / 2;
		r.bottom = r.top + valuecy;
	}
}
示例#14
0
void SystemDraw::RectPath(const Rect& r)
{
	cairo_rectangle(cr, r.left, r.top, r.GetWidth(), r.GetHeight());
}
示例#15
0
文件: Draw.cpp 项目: pedia/raidget
void Draw::DrawRect(const Rect& rect, Color color)
{
	DrawRect(rect.left, rect.top, rect.GetWidth(), rect.GetHeight(), color);
}
示例#16
0
			bool Mesh::InitSprite(HandleOrRid matId, HandleOrRid texId, const Rect &rect)
			{
				CoreManagers *res = CoreManagers::Get();

				if(matId.isHandle && matId.handle != HANDLE_NONE) {
					MaterialManager::AddRef(matId.handle);
					material = matId.handle;
				} else if(matId.rid != RID_NONE) {
					material = res->materialManager->Load(matId.rid);
				}

				Texture *tex = nullptr;
				if((texId.isHandle && texId.handle != HANDLE_NONE) || (!texId.isHandle && texId.rid != RID_NONE)) {
					
					// Get exclusive access to material
					material = MaterialManager::DuplicateIfShared(material);
					Material *mat = MaterialManager::Get(material);

					// Create a new texture set for this material
					TextureSetManager::Free(mat->textureSet);
					if(texId.isHandle) {
						tex = TextureManager::Get(texId.handle);
						TextureManager::AddRef(texId.handle);
						TextureSet ts;
						ts.textures[ts.textureCount] = texId.handle;
						ts.textures[ts.textureCount++] = tex->rid;
						mat->textureSet = res->textureSetManager->Add(Move(ts));
					} else {
						mat->SetTextures(1, &texId.rid);
						tex = TextureManager::Get(TextureSetManager::Get(mat->textureSet)->textures[0]);
					}
				} else {
					Material *mat = MaterialManager::Get(material);
					if(mat->textureSet != HANDLE_NONE) {
						TextureSet *ts = TextureSetManager::Get(mat->textureSet);
						if(ts->textureCount > 0) {
							tex = TextureManager::Get(ts->textures[0]);
						}
					}
				}

				if(tex == nullptr) {
					Console::Error("Sprite cannot be initialized without a texture (it has to know texture dimensions)");
					return false;
				}

				struct V
				{
					Vector3 pos;
					uint32 color;
					Vector2 uv;
				} verts[4];

				Core::Mesh m;
				m.SetIndexAttributes(3, 2);
				m.SetVertexAttributes(VertexFormat::AttributeFlag_Color|VertexFormat::AttributeFlag_TexCoord);
				m.SetMeshFlag(Core::Mesh::MeshFlag_HasTranslucency);

				// Draw a quad that is 1 pixel smaller than the sprite area would suggest.
				// Shrink the uv's by a half a texel on each side.
				// These two adjustments will let us put sprites next to eachother without
				// having visible seams between them (as long as you don't use mipmaps).
				float pw = rect.GetWidth();
				float w = (pw-1) / MAKI_PPU;
				float ph = rect.GetHeight();
				float h = (ph-1) / MAKI_PPU;

				float du = 0.5f / tex->width;
				float dv = 0.5f / tex->height;

				verts[0].pos = Vector3(0.0f, 0.0f, 0.0f);
				verts[0].color = 0xffffffff;
				verts[0].uv.x = rect.left / tex->width + du;
				verts[0].uv.y = rect.top / tex->height + dv;

				verts[1].pos = Vector3(0.0f, -h, 0.0f);
				verts[1].color = 0xffffffff;
				verts[1].uv.x = rect.left / tex->width + du;
				verts[1].uv.y = (rect.top + ph) / tex->height - dv;

				verts[2].pos = Vector3(w, -h, 0.0f);
				verts[2].color = 0xffffffff;
				verts[2].uv.x = (rect.left + pw) / tex->width - du;
				verts[2].uv.y = (rect.top + ph) / tex->height - dv;

				verts[3].pos = Vector3(w, 0.0f, 0.0f);
				verts[3].color = 0xffffffff;
				verts[3].uv.x = (rect.left + pw) / tex->width - du;
				verts[3].uv.y = rect.top / tex->height + dv;

				m.PushVertexData(sizeof(verts), (char *)verts);

				uint16 indices[6] = { 0, 1, 2, 0, 2, 3 };
				m.PushIndexData(sizeof(indices), (char *)indices);

				m.Upload();
				bounds.Merge(m.bounds);
		
				mesh = res->meshManager->Add(Move(m));

				// Allocate and initialize draw commands
				drawCommands.SetSize(1);
				DrawCommand *dc = &drawCommands[0];
				new(dc) DrawCommand();
				dc->SetMesh(mesh);
				dc->SetMaterial(material);
				
				return true;
			}
示例#17
0
void Ctrl::DrawLine(const Vector<Rect>& clip, int x, int y, int cx, int cy, bool horz, const byte *pattern, int animation)
{
	if(cx <= 0 || cy <= 0)
		return;
	Vector<Rect> rr = Intersection(clip, RectC(x, y, cx, cy));
	for(int i = 0; i < rr.GetCount(); i++) {
		Rect r = rr[i];
		AddUpdate(r);
		if(horz)
			for(int y = r.top; y < r.bottom; y++)
				DDRect(framebuffer[y] + r.left, 1, pattern, r.left + animation, r.GetWidth());
		else
			for(int x = r.left; x < r.right; x++)
				DDRect(framebuffer[r.top] + x, framebuffer.GetWidth(), pattern, r.top + animation, r.GetHeight());
	}
}
示例#18
0
文件: Draw.cpp 项目: pedia/raidget
void Draw::DrawData(const Rect& r, const String& data, const char *type)
{
	DrawDataOp(r.left, r.top, r.GetWidth(), r.GetHeight(), data, type);
}
示例#19
0
void Painter::RectPath(const Rect& r)
{
	RectPath(r.left, r.top, r.GetWidth(), r.GetHeight());
}
void GreenKoopa::MoveGreenKoopas(const char* id) {
		CommitDestructions(id); // to destroy the lost koopas
		for (std::list<MovingAnimator*>::iterator it=running[id].begin(); it != running[id].end(); ++it) {
				MovingAnimator* g = *it;
				Dim currPosX = g->GetSprite()->GetX();
				Dim currPosY = g->GetSprite()->GetY();

				Dim TileX = g->GetSprite()->GetTileX();
				Dim TileY = g->GetSprite()->GetTileY();
				
				if(Enemies::IsMarioAbove(TileX, TileY + 1)){
					char toCreate[20];
					const std::string id = g->GetSprite()->GetCurrFilm()->GetID();
					if(!strcmp(id.c_str(), "greenkoopaleft"))
						strcpy(toCreate, "greenkoopahit");
					else
						strcpy(toCreate, "redkoopahit");

						MovingAnimator* d; Dim x, y;
						if(suspendingdead[toCreate].size() == 0) 
								Dead(toCreate);
						d = suspendingdead[toCreate].back();
						d->GetMovingAnimation()->SetDx(0);
						d->GetMovingAnimation()->SetDelay(10000);
						d->GetMovingAnimation()->SetContinuous(false);
						d->SetLastTime(currTime);
						suspendingdead[toCreate].pop_back();
						assert(d);
						d->GetSprite()->SetX(x = g->GetSprite()->GetX());
						d->GetSprite()->SetY(y = g->GetSprite()->GetY() + 16);
						d->SetLastTime(CurrTime());
						AnimatorHolder::MarkAsRunning(d);
						walkingdead[toCreate].push_back(d);
						suspending[id].push_back(*it);
						AnimatorHolder::MarkAsSuspended(*it);
						running[id].erase(it);
						Sounds::Play("stomp");

						//jump mario:
						Dim mx = Mario::GetMarioCurrentSprite()->GetX();
						Dim my = Mario::GetMarioCurrentSprite()->GetY();
						Mario::SetDimensions(mx, my);

						AnimatorHolder::MarkAsSuspended( Mario::GetAnimator());
						Mario::SetDimensions(mx, my);
						Mario::ChangeState(Jumping);
						MovingPathAnimator* g = Mario::GetStandJump();
						g->SetCurrIndex(0);
						g->SetLastTime(currTime);
						AnimatorHolder::MarkAsRunning(g);

						return ;
				}

				if(Enemies::CanGoLeft(TileX, TileY) && g->GetMovingAnimation()->GetDx() < 0)
						g->GetMovingAnimation()->SetDx(-2);
				else if(!Enemies::CanGoLeft(TileX, TileY) && g->GetMovingAnimation()->GetDx() < 0)
						g->GetMovingAnimation()->SetDx(2);
				else if( Enemies::CanGoRight(TileX, TileY) && g->GetMovingAnimation()->GetDx() > 0)
						g->GetMovingAnimation()->SetDx(2);
				else if( !Enemies::CanGoRight(TileX, TileY) && g->GetMovingAnimation()->GetDx() > 0)
						g->GetMovingAnimation()->SetDx(-2);
				else
						g->GetMovingAnimation()->SetDx(0);
				Rect r = g->GetSprite()->GetCurrFilm()->GetFrameBox(g->GetSprite()->GetFrame());
				Dim f = r.GetHeight();
				if( Enemies::IsOnAir(TileX, TileY, f-1) && !Enemies::IsOnBrick(currPosX, currPosY))  
						g->GetMovingAnimation()->SetDy(3);
				else
						g->GetMovingAnimation()->SetDy(0);
		}
}
示例#21
0
文件: font.cpp 项目: Dingf/Paper-TD
void Font::PrintText(const char * text, const Point2D& pos, const Rect& bounds, uint8 format) const
{
	Point2D offset;

	glPushMatrix();
	glLoadIdentity();
	glColor(Black);
	glTranslated(pos.GetX(), pos.GetY(), 0);

	uint8 justify = format & 0x03;

	Float lineOffset = (int32)(CalculateLineLength(text, bounds.GetWidth(), 0)/2.0 * justify);
	offset.SetValues(offset.GetX() + lineOffset, offset.GetY());
	glTranslated(lineOffset, 0.0, 0);

	uint32 textPos = 0;
	while (textPos < strlen(text))
	{
		bool wordBegin = true;
		uint32 wordLength = GetWordLength(text, textPos);
		uint32 wordSpace = GetWordSpace(text, textPos);

		for (uint32 i = textPos; i < textPos + wordLength; i++)
		{
			if (text[i] == '&')
			{
				ParseSpecial(text, i, true);
				continue;
			}
			else if (((text[i] == '\n') || ((text[i] == '\\') && (text[i+1] == 'n')) || (offset.GetX() > bounds.GetWidth())) || ((wordSpace + offset.GetX() >= bounds.GetWidth()) && (wordSpace < bounds.GetWidth()) && (wordBegin == true)))
			{
				glTranslated(-offset.GetX(), baseSize, 0);
				offset.SetValues(0, offset.GetY() + baseSize);
				if (offset.GetY() > bounds.GetHeight())
				{
					glPopMatrix();
					return;
				}
				lineOffset = (int32)(CalculateLineLength(text, bounds.GetWidth(), i + 1)/2.0 * justify);
				offset.SetValues(offset.GetX() + lineOffset, offset.GetY());
				glTranslated(lineOffset, 0.0, 0);

				if (text[i] == '\n')
				{
					continue;
				}
				else if ((text[i] == '\\') && (text[i+1] == 'n'))
				{
					i++;
					continue;
				}
			}
			glCallList(text[i] + displayLists);
			offset.SetValues(offset.GetX() + width[text[i]], offset.GetY());
			wordBegin = false;
		}

		offset.SetValues(offset.GetX() + baseSize, offset.GetY());
		glTranslated(baseSize, 0, 0);

		textPos += wordLength + 1;
	}

	glPopMatrix();
}
示例#22
0
int CppItemInfoDisplay::DoPaint(Draw& w, const Rect& r, const Value& q,
	                            Color _ink, Color paper, dword style) const
{
	const CppItemInfo& m = ValueTo<CppItemInfo>(q);
	w.DrawRect(r, paper);
	bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT);
	if(IsNull(q)) return 0;
	int x = r.left;
	int ry = r.top + r.GetHeight() / 2;
	Image img;
	if(m.access == PROTECTED)
		img = BrowserImg::mprotected();
	else
	if(m.access == PRIVATE)
		img = BrowserImg::mprivate();
	else
	if(m.access == WITHBODY)
		img = BrowserImg::impl();
	if(!IsNull(img))
		w.DrawImage(x, ry - img.GetHeight() / 2, img);
	x += 4;
	img = BrowserImg::unknown();
	Image bk;
	switch(m.kind) {
	case FUNCTIONTEMPLATE:
		bk = BrowserImg::template_function();
	case FUNCTION:
		img = BrowserImg::function();
		break;
	case INSTANCEFUNCTIONTEMPLATE:
		bk = BrowserImg::template_function();
	case INSTANCEFUNCTION:
		img = BrowserImg::instance_function();
		break;
	case CLASSFUNCTIONTEMPLATE:
		bk = BrowserImg::template_function();
	case CLASSFUNCTION:
		img = BrowserImg::class_function();
		break;
	case STRUCTTEMPLATE:
		bk = BrowserImg::template_struct();
	case STRUCT:
		img = BrowserImg::type_struct();
		break;
	case INSTANCEVARIABLE:
		img = BrowserImg::instance_data();
		break;
	case CLASSVARIABLE:
		img = BrowserImg::class_data();
		break;
	case VARIABLE:
		img = BrowserImg::data();
		break;
	case ENUM:
		img = BrowserImg::type_enum();
		break;
	case INLINEFRIEND:
		img = BrowserImg::inline_friend();
		break;
	case TYPEDEF:
		img = BrowserImg::type_def();
		break;
	case CONSTRUCTOR:
		img = BrowserImg::constructor();
		break;
	case DESTRUCTOR:
		img = BrowserImg::destructor();
		break;
	case MACRO:
		img = BrowserImg::macro();
		break;
	case FRIENDCLASS:
		img = BrowserImg::friend_class();
		break;
	case KIND_INCLUDEFILE:
		img = IdeCommonImg::Header();
		break;
	case KIND_INCLUDEFILE_ANY:
		img = CtrlImg::File();
		break;
	case KIND_INCLUDEFOLDER:
		img = CtrlImg::Dir();
		break;
	}

	int by = ry - bk.GetSize().cy / 2;
	int iy = ry - img.GetSize().cy / 2;

	if(focuscursor) {
		DrawHighlightImage(w, x, by, bk);
		w.DrawImage(x, iy, img);
	}
	else {
		w.DrawImage(x, by, bk);
		w.DrawImage(x, iy, img);
	}
	if(m.inherited) {
		w.DrawImage(x + 10, r.top, BrowserImg::inherited());
		for(int i = 1; i < min(m.inherited, 5); i++)
			w.DrawRect(x + 10, r.top + 7 + 2 * i, 7, 1, SColorText);
	}
	x += 20;
	int y = ry - Draw::GetStdFontCy() / 2;
	int x0 = x;
	Vector<ItemTextPart> n = ParseItemNatural(m);
	int starti = 0;
	if(namestart)
		for(int i = 0; i < n.GetCount(); i++)
			if(n[i].type == ITEM_NAME) {
				starti = i;
				break;
			}
	PaintText(w, x, y, m, n, starti, n.GetCount(), focuscursor, _ink);
	if(starti) {
		const char *h = " : ";
		w.DrawText(x, y, h, BrowserFont(), SColorText);
		x += GetTextSize(h, BrowserFont()).cx;
	}
	PaintText(w, x, y, m, n, 0, starti, focuscursor, _ink);
	if(m.virt || m.over)
		w.DrawRect(x0, r.bottom - 2, x - x0, 1, m.over ? m.virt ? LtRed : LtBlue : SColorText);
	if(m.inherited && m.IsType())
		w.DrawRect(r.left, r.top, r.Width(), 1, SColorDisabled);

	if(showtopic) {
		String k = MakeCodeRef(m.scope, m.qitem);
		int cnt = GetRefLinks(k).GetCount();
		if(cnt) {
			Size sz = BrowserImg::Ref().GetSize();
			int xx = r.right - sz.cx - 1;
			int yy = r.top + (r.Height() - sz.cy) / 2;
			DrawHighlightImage(w, xx, yy, BrowserImg::Ref());
			if(cnt > 1) {
				String txt = AsString(cnt);
				Font fnt = Arial(Ctrl::VertLayoutZoom(10)).Bold();
				Size tsz = GetTextSize(txt, fnt);
				Point p(xx + (sz.cx - tsz.cx) / 2, yy + (sz.cy - tsz.cy) / 2);
				for(int ax = -1; ax <= 1; ax++)
					for(int ay = -1; ay <= 1; ay++)
						w.DrawText(p.x + ax, p.y + ay, txt, fnt, White);
				w.DrawText(p.x, p.y, txt, fnt, Blue);
			}
			x += sz.cx + 3;
		}
	}

	return x;
}
示例#23
0
void Graphics::DrawImage(Image* image, const Rect& rc, const ImageAttributes* attr) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Image* gdiImage = reinterpret_cast<Gdiplus::Image*>(image->_private);

    if(attr!=0) {
        Gdiplus::ImageAttributes* ia = reinterpret_cast<Gdiplus::ImageAttributes*>(attr->_private);
        g->DrawImage(gdiImage, Gdiplus::Rect(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight()), 0, 0, gdiImage->GetWidth(), gdiImage->GetHeight(), Gdiplus::UnitPixel, ia);
    }
    else {
        g->DrawImage(gdiImage, ToGDIRect<Rect, Gdiplus::Rect>(rc));
    }
}
示例#24
0
void SDLExample::Demo() {
	if(!fntbmp.LoadBMP(GetDataFile("font.bmp"))) {
		Exclamation(Format("Error loading font.bmp : %s\n", SDL_GetError()));
		return;
	}
	Rect r = GetRect();
	int width = r.GetWidth();
	int height = r.GetHeight();

	if (!surf.CreateRGB(width, height, GetBpp()))
		return;

	SetupPalette(surf.GetSurface());
	SetupPalette(GetSurface());

	demoInitialized = true;
	done = false;
	
	j = 0;
	k = 0;
	len0 = LengthStr(scroll[j]);
	len1 = len0;
	xmax = (width - len1) / 2;
	x0 = width;
	x1 = -len0;

	SDL_Event event;

	while(!done) {
		Ctrl::ProcessEvents();
		if(SDL_PollEvent(&event))
			switch (event.type) {
				case SDL_MOUSEMOTION:
					r = GetScreenView();
					GetParent()->MouseMove(Point(r.left+event.motion.x, r.top+event.motion.y), 0);				
					break;
				case SDL_QUIT:
					done = true;
					break;
				default:
					break;
			} else {
				r = GetRect();
				width = GetWidth();
				height = GetHeight();
			
				surf.Lock();
				
				DrawPoints(points);
				Blur(width, height);
				MovePoints(points, width, height);

				if(x0 > -len0)
					WriteStr(x0 + 5, height - 185, scroll[k], 254, 50);

				if(x1 <= xmax)
					WriteStr(x1, height - 250, scroll[j], 255, 50);

				x0 -= 2;
				x1 += 2;

				if(x0 < -len0) {
					if(++k > MAXSCROLL - 1) 
						k = 0;
					len0 = LengthStr(scroll[k]);
					x0 = width;
				}
				if(x1 > xmax) {
					if(++j > MAXSCROLL - 1) 
						j = 0;
					len1 =LengthStr(scroll[j]);
					xmax = (width - len1) / 2;
					x1 = -len1;
				}
				surf.Unlock();
				
				Blit(surf);
			}
	}
}
示例#25
0
void ToSDL_Rect(SDL_Rect &sdlrect, Rect &rect) {
    sdlrect.x = rect.left;
    sdlrect.y = rect.top;
    sdlrect.w = rect.GetWidth();
    sdlrect.h = rect.GetHeight();
}
示例#26
0
inline int Area(const Rect& r)
{
	return r.GetHeight() * r.GetWidth();
}
示例#27
0
bool Bitmap::LockBits(const Rect& rc, bool write, BitmapData* data) {
    Gdiplus::BitmapData* bd = reinterpret_cast<Gdiplus::BitmapData*>(data->_private);
    Gdiplus::Bitmap* gdiBitmap = dynamic_cast<Gdiplus::Bitmap*>(reinterpret_cast<Gdiplus::Image*>(_private));
    Gdiplus::Rect gdiRect(rc.GetLeft(), rc.GetTop(), rc.GetWidth(), rc.GetHeight());
    return gdiBitmap->LockBits(&gdiRect, write ? Gdiplus::ImageLockModeWrite : Gdiplus::ImageLockModeRead, PixelFormat32bppARGB, bd) == Gdiplus::Ok;
}