Example #1
0
void DKCube::SetPosition(DKPoint pos)
{
	point = pos;
	CalculateDraw();

	front.SetPosition(point);
	back.SetPosition(DKPoint(point.x,point.y,point.z+size.z));
	right.SetPosition(point);
	left.SetPosition(DKPoint(point.x+size.x,point.y,point.z));
	top.SetPosition(point);
	bottom.SetPosition(DKPoint(point.x,point.y+size.y,point.z));
}
Example #2
0
static PyObject* DCPointAbsolute(PyObject* obj)
{
	return DCPointUnaryOperand(obj, [](const DKPoint& pt, DKPoint& r)
	{
		r = DKPoint((pt.x < 0 ? -pt.x : pt.x), (pt.y < 0 ? -pt.y : pt.y));
		return true;
	});
}
Example #3
0
static PyObject* DCPointNegative(PyObject* obj)
{
	return DCPointUnaryOperand(obj, [](const DKPoint& pt, DKPoint& r)
	{
		r = DKPoint(-pt.x, -pt.y);
		return true;
	});
}
Example #4
0
void DKCube::SetSize(DKSize siz)
{
	size = siz;

	//front.SetPosition(x,y,z);
	back.SetPosition(DKPoint(point.x,point.y,point.z+size.z));
	//right.SetPosition(x,y,z);
	left.SetPosition(DKPoint(point.x+size.x,point.y,point.z));
	//top.SetPosition(x,y,z);
	bottom.SetPosition(DKPoint(point.x,point.y+size.y,point.z));

	front.SetSize(DKSize(size.x,size.y,0));
	back.SetSize(DKSize(size.x,size.y,0));
	right.SetSize(DKSize(size.x,size.y,0));
	left.SetSize(DKSize(size.x,size.y,0));
	top.SetSize(DKSize(size.x,size.y,0));
	bottom.SetSize(DKSize(size.x,size.y,0));
};
Example #5
0
NewPanel::NewPanel(DKObject *parent, int x, int y, int w, int h)
	: DKPanel(parent,DKPoint(x,y),DKSize(w,h))
{
	DKDebug("NewPanel initiated\n");

	SetColor(DKColor(0.1f,0.1f,0.1f,1));
	text1.Create(this,DKPoint(0,0),DKFont::fonts[0],"New Window");
	button1.Create(this,DKPoint(20,20),DKFile::DataPath("newwindow.png"));
	button1.LinkButtonEvent(&ButtonEvent, this, 1);
	text2.Create(this,DKPoint(30,145),DKFont::fonts[0],"New Window");

	button2.Create(this,DKPoint(150,20),DKFile::DataPath("newpanel.png"));
	button2.LinkButtonEvent(&ButtonEvent, this, 2);
	text3.Create(this,DKPoint(160,145),DKFont::fonts[0],"New Panel");

	button3.Create(this,DKPoint(size.x-18,0.0f),DKFile::DataPath("close.png"));
	button3.LinkButtonEvent(&ButtonEvent, this, 3);

	button4.Create(this,DKPoint(20,200),DKFont::fonts[0],"Move left 10");
	button4.LinkTextButtonEvent(&TextButtonEvent, this, 1);
}
Example #6
0
static int DCFontInit(DCFont *self, PyObject *args, PyObject *kwds)
{
	if (self->font)
		return 0;
	
	PyObject* obj = NULL;
	int point = 12;
	float embolden = 0.0f;
	float outline = 0.0f;
	DKPoint dpi = DKPoint(72, 72);
	int enableKerning = 1;
	int forceBitmap = 0;

	char* kwlist[] = { "font", "point", "embolden", "outline", "dpi", "enableKerning", "forceBitmap", NULL };
	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|iffO&pp", kwlist,
		&obj, &point, &embolden, &outline, &DCPointConverter, &dpi, &enableKerning, &forceBitmap))
		return -1;

	// data 또는 file 로 폰트 로딩함.
	if (PyUnicode_Check(obj))
	{
		const char* s = PyUnicode_AsUTF8(obj);
		if (s && s[0])
		{
			Py_BEGIN_ALLOW_THREADS

			DKString url(s);
			if (url.Find(L"://") < 0)		// 실제 파일
			{
				self->font = DKFont::Create(url);
			}
			else
			{
				DKObject<DKBuffer> data = DKBuffer::Create(url);
				if (data)
					self->font = DKFont::Create(data);
			}

			Py_END_ALLOW_THREADS
		}
		PyErr_Clear();
	}
Example #7
0
static int DCPointInit(DCPoint *self, PyObject *args, PyObject *kwds)
{
	Py_ssize_t numArgs = PyTuple_GET_SIZE(args);
	if (numArgs > 1 && DCPointConverter(args, &self->point))
	{
		return 0;
	}
	else if (numArgs == 1 && PyArg_ParseTuple(args, "O&", &DCPointConverter, &self->point))
	{
		return 0;
	}
	else if (numArgs == 0)
	{
		self->point = DKPoint(0, 0);
		return 0;
	}

	PyErr_Clear();
	PyErr_SetString(PyExc_TypeError, "argument must be two floating point (x,y) or empty");
	return -1;
}
Example #8
0
void NewPanel::OnTextButton(DKEvent* event)
{
	if(event->id == 1){
		SetPosition(DKPoint(point.x-10,point.y,point.z));
	}
}