1a05542005-07-28Martin Nilsson /* -*- C -*- */ class GDK2.Rectangle; //! Rectangle class. void create(int x, int y, int width, int height) //! Create a new rectangle //! //! NOIMG { GdkRectangle *r; INT_TYPE x,y,w,h;
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_setup(); pgtk2_verify_not_inited();
0cda022005-12-28Martin Nilsson  THIS->obj=(void *)(r=(GdkRectangle *)g_malloc(sizeof(GdkRectangle)));
2fa8a62008-04-11Per Hedbor  THIS->owned = 1;
1a05542005-07-28Martin Nilsson  if (r==NULL)
32353e2005-12-30Martin Nilsson  SIMPLE_OUT_OF_MEMORY_ERROR("create",sizeof(GdkRectangle));
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args,"%i%i%i%i",&x,&y,&w,&h);
1a05542005-07-28Martin Nilsson  r->x=x; r->y=y; r->width=w; r->height=h;
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
1a05542005-07-28Martin Nilsson } void set(int x, int y, int width, int height ) //! Set the upper left corner and the size of the rectangle. { GdkRectangle *r=(GdkRectangle *)THIS->obj; INT_TYPE x,y,w,h;
96f5f42018-08-05Martin Nilsson  get_all_args(NULL,args, "%i%i%i%i",&x,&y,&w,&h);
1a05542005-07-28Martin Nilsson  r->x=x; r->y=y; r->width=w; r->height=h; RETURN_THIS(); } mixed cast(string type) //! Normally used like (mapping)rectangle or (array)rectangle. {
8ae5a42006-01-07Martin Nilsson  struct pike_string *type;
1a05542005-07-28Martin Nilsson  GdkRectangle *r=(GdkRectangle *)THIS->obj;
68ec3f2014-08-18Martin Nilsson  if (args!=1)
06bd612016-01-26Martin Nilsson  SIMPLE_WRONG_NUM_ARGS_ERROR("cast",1);
68ec3f2014-08-18Martin Nilsson  type = Pike_sp[-args].u.string; pgtk2_pop_n_elems(args); if (type == literal_mapping_string) {
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("x"));
1a05542005-07-28Martin Nilsson  push_int(r->x);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("y"));
1a05542005-07-28Martin Nilsson  push_int(r->y);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("width"));
1a05542005-07-28Martin Nilsson  push_int(r->width);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("height"));
1a05542005-07-28Martin Nilsson  push_int(r->height); f_aggregate_mapping(8);
68ec3f2014-08-18Martin Nilsson  } else if(type == literal_array_string) {
1a05542005-07-28Martin Nilsson  push_int(r->x); push_int(r->y); push_int(r->width); push_int(r->height); f_aggregate(4); } else {
68ec3f2014-08-18Martin Nilsson  push_undefined();
1a05542005-07-28Martin Nilsson  } }
15ab0b2017-11-05Henrik Grubbström (Grubba) void _destruct()
1a05542005-07-28Martin Nilsson {
2edd4f2008-01-30Per Hedbor  if( THIS->obj && THIS->owned ) g_free(THIS->obj);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
3d76632005-11-03Lance Dillon  push_int(0);
1a05542005-07-28Martin Nilsson }