⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flmodule.c

📁 python s60 1.4.5版本的源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
{
	return call_forms_INf (fl_set_slider_step, g-> ob_generic, args);
}


static PyMethodDef slider_methods[] = {
	{"set_slider_value",	(PyCFunction)set_slider_value},
	{"get_slider_value",	(PyCFunction)get_slider_value},
	{"set_slider_bounds",	(PyCFunction)set_slider_bounds},
	{"get_slider_bounds",	(PyCFunction)get_slider_bounds},
	{"set_slider_return",	(PyCFunction)set_slider_return},
	{"set_slider_size",	(PyCFunction)set_slider_size},
	{"set_slider_precision",(PyCFunction)set_slider_precision},
	{"set_slider_step",	(PyCFunction)set_slider_step},
	{NULL,			NULL}		/* sentinel */
};

static PyObject *
set_positioner_xvalue (genericobject *g, PyObject *args)
{
	return call_forms_INf (fl_set_positioner_xvalue, g-> ob_generic, args);
}

static PyObject *
set_positioner_xbounds (genericobject *g, PyObject *args)
{
	return call_forms_INfINf (fl_set_positioner_xbounds,
				  g-> ob_generic, args);
}

static PyObject *
set_positioner_yvalue (genericobject *g, PyObject *args)
{
	return call_forms_INf (fl_set_positioner_yvalue, g-> ob_generic, args);
}

static PyObject *
set_positioner_ybounds (genericobject *g, PyObject *args)
{
	return call_forms_INfINf (fl_set_positioner_ybounds,
				  g-> ob_generic, args);
}

static PyObject *
get_positioner_xvalue (genericobject *g, PyObject *args)
{
	return call_forms_Rf (fl_get_positioner_xvalue, g-> ob_generic, args);
}

static PyObject *
get_positioner_xbounds (genericobject *g, PyObject *args)
{
	return call_forms_OUTfOUTf (fl_get_positioner_xbounds,
				    g-> ob_generic, args);
}

static PyObject *
get_positioner_yvalue (genericobject *g, PyObject *args)
{
	return call_forms_Rf (fl_get_positioner_yvalue, g-> ob_generic, args);
}

static PyObject *
get_positioner_ybounds (genericobject *g, PyObject *args)
{
	return call_forms_OUTfOUTf (fl_get_positioner_ybounds,
				    g-> ob_generic, args);
}

static PyMethodDef positioner_methods[] = {
	{"set_positioner_xvalue",	(PyCFunction)set_positioner_xvalue},
	{"set_positioner_yvalue",	(PyCFunction)set_positioner_yvalue},
	{"set_positioner_xbounds",	(PyCFunction)set_positioner_xbounds},
	{"set_positioner_ybounds",	(PyCFunction)set_positioner_ybounds},
	{"get_positioner_xvalue",	(PyCFunction)get_positioner_xvalue},
	{"get_positioner_yvalue",	(PyCFunction)get_positioner_yvalue},
	{"get_positioner_xbounds",	(PyCFunction)get_positioner_xbounds},
	{"get_positioner_ybounds",	(PyCFunction)get_positioner_ybounds},
	{NULL,			NULL}		/* sentinel */
};

/* Class timer */

static PyObject *
set_timer (genericobject *g, PyObject *args)
{
	return call_forms_INf (fl_set_timer, g-> ob_generic, args);
}

static PyObject *
get_timer (genericobject *g, PyObject *args)
{
	return call_forms_Rf (fl_get_timer, g-> ob_generic, args);
}

static PyMethodDef timer_methods[] = {
	{"set_timer",		(PyCFunction)set_timer},
	{"get_timer",		(PyCFunction)get_timer},
	{NULL,			NULL}		/* sentinel */
};

/* Form objects */

typedef struct {
	PyObject_HEAD
	FL_FORM *ob_form;
} formobject;

staticforward PyTypeObject Formtype;

#define is_formobject(v) ((v)->ob_type == &Formtype)

static PyObject *
form_show_form(formobject *f, PyObject *args)
{
	int place, border;
	char *name;
	if (!PyArg_Parse(args, "(iis)", &place, &border, &name))
		return NULL;
	fl_show_form(f->ob_form, place, border, name);
	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
form_call(void (*func)(FL_FORM *), FL_FORM *f, PyObject *args)
{
	if (!PyArg_NoArgs(args)) return NULL;

	(*func)(f);

	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
form_call_INiINi(void (*func)(FL_FORM *, int, int), FL_FORM *f, PyObject *args)
{
	int a, b;

	if (!PyArg_Parse(args, "(ii)", &a, &b)) return NULL;

	(*func)(f, a, b);

	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
form_call_INfINf(void (*func)(FL_FORM *, float, float), FL_FORM *f, PyObject *args)
{
	float a, b;

	if (!PyArg_Parse(args, "(ff)", &a, &b)) return NULL;

	(*func)(f, a, b);

	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
form_hide_form(formobject *f, PyObject *args)
{
	return form_call(fl_hide_form, f-> ob_form, args);
}

static PyObject *
form_redraw_form(formobject *f, PyObject *args)
{
	return form_call(fl_redraw_form, f-> ob_form, args);
}

static PyObject *
form_set_form_position(formobject *f, PyObject *args)
{
	return form_call_INiINi(fl_set_form_position, f-> ob_form, args);
}

static PyObject *
form_set_form_size(formobject *f, PyObject *args)
{
	return form_call_INiINi(fl_set_form_size, f-> ob_form, args);
}

static PyObject *
form_scale_form(formobject *f, PyObject *args)
{
	return form_call_INfINf(fl_scale_form, f-> ob_form, args);
}

static PyObject *
generic_add_object(formobject *f, PyObject *args, FL_OBJECT *(*func)(int, float, float, float, float, char*), PyMethodDef *internal_methods)
{
	int type;
	float x, y, w, h;
	char *name;
	FL_OBJECT *obj;

	if (!PyArg_Parse(args,"(iffffs)", &type,&x,&y,&w,&h,&name))
		return NULL;

	fl_addto_form (f-> ob_form);

	obj = (*func) (type, x, y, w, h, name);

	fl_end_form();

	if (obj == NULL) {
		PyErr_NoMemory();
		return NULL;
	}

	return newgenericobject (obj, internal_methods);
}

static PyObject *
form_add_button(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_button, button_methods);
}

static PyObject *
form_add_lightbutton(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_lightbutton, button_methods);
}

static PyObject *
form_add_roundbutton(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_roundbutton, button_methods);
}

static PyObject *
form_add_menu (formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_menu, menu_methods);
}

static PyObject *
form_add_slider(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_slider, slider_methods);
}

static PyObject *
form_add_valslider(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_valslider, slider_methods);
}

static PyObject *
form_add_dial(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_dial, dial_methods);
}

static PyObject *
form_add_counter(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_counter, counter_methods);
}

static PyObject *
form_add_clock(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_clock, clock_methods);
}

static PyObject *
form_add_box(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_box,
				  (PyMethodDef *)NULL);
}

static PyObject *
form_add_choice(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_choice, choice_methods);
}

static PyObject *
form_add_browser(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_browser, browser_methods);
}

static PyObject *
form_add_positioner(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_positioner,
				  positioner_methods);
}

static PyObject *
form_add_input(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_input, input_methods);
}

static PyObject *
form_add_text(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_text,
				  (PyMethodDef *)NULL);
}

static PyObject *
form_add_timer(formobject *f, PyObject *args)
{
	return generic_add_object(f, args, fl_add_timer, timer_methods);
}

static PyObject *
form_freeze_form(formobject *f, PyObject *args)
{
	return form_call(fl_freeze_form, f-> ob_form, args);
}

static PyObject *
form_unfreeze_form(formobject *f, PyObject *args)
{
	return form_call(fl_unfreeze_form, f-> ob_form, args);
}

static PyObject *
form_activate_form(formobject *f, PyObject *args)
{
	return form_call(fl_activate_form, f-> ob_form, args);
}

static PyObject *
form_deactivate_form(formobject *f, PyObject *args)
{
	return form_call(fl_deactivate_form, f-> ob_form, args);
}

static PyObject *
form_bgn_group(formobject *f, PyObject *args)
{
	FL_OBJECT *obj;

	fl_addto_form(f-> ob_form);
	obj = fl_bgn_group();
	fl_end_form();

	if (obj == NULL) {
		PyErr_NoMemory();
		return NULL;
	}

	return newgenericobject (obj, (PyMethodDef *) NULL);
}

static PyObject *
form_end_group(formobject *f, PyObject *args)
{
	fl_addto_form(f-> ob_form);
	fl_end_group();
	fl_end_form();
	Py_INCREF(Py_None);
	return Py_None;
}

static PyObject *
forms_find_first_or_last(FL_OBJECT *(*func)(FL_FORM *, int, float, float), formobject *f, PyObject *args)
{
	int type;
	float mx, my;
	FL_OBJECT *generic;
	genericobject *g;
	
	if (!PyArg_Parse(args, "(iff)", &type, &mx, &my)) return NULL;

	generic = (*func) (f-> ob_form, type, mx, my);

	if (generic == NULL)
	{
		Py_INCREF(Py_None);
		return Py_None;
	}

	g = findgeneric(generic);
	if (g == NULL) {
		PyErr_SetString(PyExc_RuntimeError,
			   "forms_find_{first|last} returns unknown object");
		return NULL;
	}
	Py_INCREF(g);
	return (PyObject *) g;
}

static PyObject *
form_find_first(formobject *f, PyObject *args)
{
	return forms_find_first_or_last(fl_find_first, f, args);
}

static PyObject *
form_find_last(formobject *f, PyObject *args)
{
	return forms_find_first_or_last(fl_find_last, f, args);
}

static PyObject *
form_set_object_focus(formobject *f, PyObject *args)
{
	genericobject *g;
	if (args == NULL || !is_genericobject(args)) {
		PyErr_BadArgument();
		return NULL;
	}
	g = (genericobject *)args;
	fl_set_object_focus(f->ob_form, g->ob_generic);
	Py_INCREF(Py_None);
	return Py_None;
}

static PyMethodDef form_methods[] = {
/* adm */
	{"show_form",		(PyCFunction)form_show_form},
	{"hide_form",		(PyCFunction)form_hide_form},
	{"redraw_form",		(PyCFunction)form_redraw_form},
	{"set_form_position",	(PyCFunction)form_set_form_position},
	{"set_form_size",	(PyCFunction)form_set_form_size},
	{"scale_form",		(PyCFunction)form_scale_form},
	{"freeze_form",		(PyCFunction)form_freeze_form},
	{"unfreeze_form",	(PyCFunction)form_unfreeze_form},
	{"activate_form",	(PyCFunction)form_activate_form},
	{"deactivate_form",	(PyCFunction)form_deactivate_form},
	{"bgn_group",		(PyCFunction)form_bgn_group},
	{"end_group",		(PyCFunction)form_end_group},
	{"find_first",		(PyCFunction)form_find_first},
	{"find_last",		(PyCFunction)form_find_last},
	{"set_object_focus",	(PyCFunction)form_set_object_focus},

/* basic objects */
	{"add_button",		(PyCFunction)form_add_button},
/*	{"add_bitmap",		(method)form_add_bitmap}, */
	{"add_lightbutton",	(PyCFunction)form_add_lightbutton},
	{"add_roundbutton",	(PyCFunction)form_add_roundbutton},
	{"add_menu",		(PyCFunction)form_add_menu},
	{"add_slider",		(PyCFunction)form_add_slider},
	{"add_positioner",	(PyCFunction)form_add_positioner},
	{"add_valslider",	(PyCFunction)form_add_valslider},
	{"add_dial",		(PyCFunction)form_add_dial},
	{"add_counter",		(PyCFunction)form_add_counter},
	{"add_box",		(PyCFunction)form_add_box},
	{"add_clock",		(PyCFunction)form_add_clock},
	{"add_choice",		(PyCFunction)form_add_choice},
	{"add_browser",		(PyCFunction)form_add_browser},
	{"add_input",		(PyCFunction)form_add_input},
	{"add_timer",		(PyCFunction)form_add_timer},
	{"add_text",		(PyCFunction)form_add_text},
	{NULL,			NULL}		/* sentinel */
};

static void
form_dealloc(formobject *f)
{
	releaseobjects(f->ob_form);
	if (f->ob_form->visible)
		fl_hide_form(f->ob_form);
	fl_free_form(f->ob_form);
	PyObject_Del(f);
}

#define OFF(x) offsetof(FL_FORM, x)

static struct memberlist form_memberlist[] = {
	{"window",	T_LONG,		OFF(window),	RO},
	{"w",		T_FLOAT,	OFF(w)},
	{"h",		T_FLOAT,	OFF(h)},
	{"x",		T_FLOAT,	OFF(x),		RO},
	{"y",		T_FLOAT,	OFF(y),		RO},
	{"deactivated",	T_INT,		OFF(deactivated)},
	{"visible",	T_INT,		OFF(visible),	RO},
	{"frozen",	T_INT,		OFF(frozen),	RO},
	{"doublebuf",	T_INT,		OFF(doublebuf)},
	{NULL}	/* Sentinel */
};

#undef OFF

static PyObject *
form_getattr(formobject *f, char *name)
{
	PyObject *meth;

	meth = Py_FindMethod(form_methods, (PyObject *)f, name);
	if (meth != NULL)
		return meth;
	PyErr_Clear();
	return PyMember_Get((char *)f->ob_form, form_memberlist, name);
}

static int
form_setattr(formobject *f, char *name, PyObject *v)
{
	if (v == NULL) {
		PyErr_SetString(PyExc_TypeError,
				"can't delete form attributes");
		return -1;
	}

	return PyMember_Set((char *)f->ob_form, form_memberlist, name, v);
}

static PyObject *
form_repr(formobject *f)
{
	char buf[100];
	PyOS_snprintf(buf, sizeof(buf), "<FORMS_form at %p, window=%ld>",
		      f, f->ob_form->window);
	return PyString_FromString(buf);
}

static PyTypeObject Formtype = {
	PyObject_HEAD_INIT(&PyType_Type)
	0,				/*ob_size*/
	"fl.FORMS_form",		/*tp_name*/
	sizeof(formobject),		/*tp_size*/
	0,				/*tp_itemsize*/
	/* methods */
	(destructor)form_dealloc,	/*tp_dealloc*/
	0,				/*tp_print*/
	(getattrfunc)form_getattr,	/*tp_getattr*/
	(setattrfunc)form_setattr,	/*tp_setattr*/
	0,				/*tp_compare*/
	(reprfunc)form_repr,		/*tp_repr*/
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -