X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fecore_x%2Frb_window.c;h=e3f1bcfb018cd050df517407a05686ae88206d1c;hb=HEAD;hp=b5c0f6549ebe7880d1e2ecfdf6d2ff1ac72a0721;hpb=f581ab591b3fd398dda2eb58cff4a4a30c37d045;p=ruby-ecore.git diff --git a/src/ecore_x/rb_window.c b/src/ecore_x/rb_window.c index b5c0f65..e3f1bcf 100644 --- a/src/ecore_x/rb_window.c +++ b/src/ecore_x/rb_window.c @@ -1,6 +1,4 @@ /* - * $Id: rb_window.c 99 2004-08-26 18:08:05Z tilman $ - * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * * This library is free software; you can redistribute it and/or @@ -29,7 +27,7 @@ #include "rb_window.h" #include "rb_cursor.h" -VALUE cWindow; +static VALUE cWindow; static void c_mark (RbWindow *w) { @@ -60,14 +58,21 @@ VALUE TO_ECORE_X_WINDOW (VALUE parent, Ecore_X_Window w) return self; } -static VALUE c_new (int argc, VALUE *argv, VALUE klass) +static VALUE c_alloc (VALUE klass) +{ + RbWindow *window = NULL; + + return Data_Make_Struct (cWindow, RbWindow, c_mark, c_free, window); +} + +static VALUE c_init (int argc, VALUE *argv, VALUE self) { - VALUE self, parent, geom[4]; - RbWindow *window = NULL, *p = NULL; + VALUE parent, geom[4]; + RbWindow *p = NULL; int i, igeom[4] = {0, 0, 0, 0}; Ecore_X_Window pwin = 0; - self = Data_Make_Struct (cWindow, RbWindow, c_mark, c_free, window); + GET_OBJ (self, RbWindow, win); rb_scan_args (argc, argv, "05", &parent, &geom[0], &geom[1], &geom[2], &geom[3]); @@ -84,17 +89,10 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) igeom[i] = FIX2INT (geom[i]); } - window->real = ecore_x_window_new (pwin, igeom[0], igeom[1], - igeom[2], igeom[3]); - window->parent = parent; - - rb_obj_call_init (self, 0, NULL); - - return self; -} + win->real = ecore_x_window_new (pwin, igeom[0], igeom[1], + igeom[2], igeom[3]); + win->parent = parent; -static VALUE c_init (int argc, VALUE *argv, VALUE self) -{ rb_iv_set (self, "@cursor", Qnil); return self; @@ -123,6 +121,47 @@ static VALUE c_equal_value (VALUE self, VALUE other) return w1->real == w2->real ? Qtrue : Qfalse; } +static VALUE c_configure (int argc, VALUE *argv, VALUE self) +{ + VALUE mask, geom[4], border, sibling, stackm; + RbWindow *sibwin = NULL; + int i; + + GET_OBJ (self, RbWindow, win); + + rb_scan_args (argc, argv, "17", &mask, + &geom[0], &geom[1], &geom[2], &geom[3], + &border, &sibling, &stackm); + + Check_Type (mask, T_FIXNUM); + + for (i = 0; i < 4; i++) + if (!NIL_P (geom[i])) + Check_Type (geom[i], T_FIXNUM); + + if (!NIL_P (border)) + Check_Type (border, T_FIXNUM); + + if (!NIL_P (sibling)) { + CHECK_CLASS (sibling, cWindow); + Data_Get_Struct (sibling, RbWindow, sibwin); + } + + if (!NIL_P (stackm)) + Check_Type (stackm, T_FIXNUM); + + ecore_x_window_configure (win->real, FIX2INT (mask), + NIL_P (geom[0]) ? 0 : FIX2INT (geom[0]), + NIL_P (geom[1]) ? 0 : FIX2INT (geom[1]), + NIL_P (geom[2]) ? 0 : FIX2INT (geom[2]), + NIL_P (geom[3]) ? 0 : FIX2INT (geom[3]), + NIL_P (border) ? 0 : FIX2INT (border), + sibwin ? sibwin->real : 0, + NIL_P (stackm) ? 0 : FIX2INT (stackm)); + + return Qnil; +} + static VALUE c_show (VALUE self) { GET_OBJ (self, RbWindow, win); @@ -228,7 +267,7 @@ static VALUE c_resize (VALUE self, VALUE w, VALUE h) Check_Type (w, T_FIXNUM); Check_Type (h, T_FIXNUM); - ecore_x_window_move (win->real, FIX2INT (w), FIX2INT (h)); + ecore_x_window_resize (win->real, FIX2INT (w), FIX2INT (h)); return Qnil; } @@ -289,6 +328,7 @@ static VALUE c_parent_get (VALUE self) ecore_x_window_parent_get (win->real)); } +#if 0 static VALUE c_title_get (VALUE self) { char *s; @@ -310,6 +350,7 @@ static VALUE c_title_set (VALUE self, VALUE val) return Qnil; } +#endif static VALUE c_set_event_mask (VALUE self, VALUE val) { @@ -333,6 +374,7 @@ static VALUE c_unset_event_mask (VALUE self, VALUE val) return Qnil; } +#if 0 static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on) { GET_OBJ (self, RbWindow, win); @@ -345,6 +387,7 @@ static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on) return Qnil; } +#endif static VALUE c_get_protocol (VALUE self, VALUE proto) { @@ -357,6 +400,7 @@ static VALUE c_get_protocol (VALUE self, VALUE proto) return s ? Qtrue : Qfalse; } +#if 0 static VALUE c_sticky_get (VALUE self) { int s; @@ -380,6 +424,29 @@ static VALUE c_sticky_set (VALUE self, VALUE val) return Qnil; } +static VALUE c_borderless_get (VALUE self) +{ + int s; + + GET_OBJ (self, RbWindow, win); + + s = ecore_x_window_prop_borderless_get (win->real); + + return s ? Qtrue : Qfalse; +} + +static VALUE c_borderless_set (VALUE self, VALUE val) +{ + GET_OBJ (self, RbWindow, win); + + CHECK_BOOL (val); + + ecore_x_window_prop_borderless_set (win->real, val == Qtrue); + + return Qnil; +} +#endif + static VALUE c_cursor_set (VALUE self, VALUE val) { GET_OBJ (self, RbWindow, win); @@ -442,10 +509,13 @@ void Init_Window (void) { cWindow = rb_define_class_under (mX, "Window", rb_cObject); - rb_define_singleton_method (cWindow, "new", c_new, -1); + rb_define_alloc_func (cWindow, c_alloc); rb_define_method (cWindow, "initialize", c_init, -1); rb_define_method (cWindow, "inspect", c_inspect, 0); + rb_define_method (cWindow, "eql?", c_equal_value, 1); rb_define_method (cWindow, "==", c_equal_value, 1); + rb_define_method (cWindow, "===", c_equal_value, 1); + rb_define_method (cWindow, "configure", c_configure, -1); rb_define_method (cWindow, "show", c_show, 0); rb_define_method (cWindow, "hide", c_hide, 0); rb_define_method (cWindow, "visible?", c_visible_get, 0); @@ -464,15 +534,23 @@ void Init_Window (void) rb_define_method (cWindow, "border_width=", c_border_width_set, 1); rb_define_method (cWindow, "depth", c_depth_get, 0); rb_define_method (cWindow, "parent", c_parent_get, 0); +#if 0 rb_define_method (cWindow, "title", c_title_get, 0); rb_define_method (cWindow, "title=", c_title_set, 1); +#endif rb_define_method (cWindow, "set_event_mask", c_set_event_mask, 1); rb_define_method (cWindow, "unset_event_mask", c_unset_event_mask, 1); +#if 0 rb_define_method (cWindow, "set_protocol", c_set_protocol, 2); +#endif rb_define_method (cWindow, "get_protocol", c_get_protocol, 1); +#if 0 rb_define_method (cWindow, "sticky?", c_sticky_get, 0); rb_define_method (cWindow, "sticky=", c_sticky_set, 1); + rb_define_method (cWindow, "borderless?", c_borderless_get, 0); + rb_define_method (cWindow, "borderless=", c_borderless_set, 1); +#endif rb_define_method (cWindow, "cursor=", c_cursor_set, 1); rb_define_method (cWindow, "manage", c_manage, 0); rb_define_method (cWindow, "manage_container", c_manage_container, 0);