glade-fixed.h 3.27 KB
Newer Older
1 2 3 4 5 6 7
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_FIXED_H__
#define __GLADE_FIXED_H__

#include <glib-object.h>
#include <gdk/gdk.h>

8 9
#include <gladeui/glade-widget.h>
#include <gladeui/glade-cursor.h>
10 11 12 13 14 15 16 17 18 19

G_BEGIN_DECLS

#define GLADE_TYPE_FIXED            (glade_fixed_get_type())
#define GLADE_FIXED(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_FIXED, GladeFixed))
#define GLADE_FIXED_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_FIXED, GladeFixedClass))
#define GLADE_IS_FIXED(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_FIXED))
#define GLADE_IS_FIXED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_FIXED))
#define GLADE_FIXED_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GLADE_FIXED, GladeFixedClass))

Tristan Van Berkom's avatar
Tristan Van Berkom committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
/* Convenience macros used in pointer events.
 */
#define GLADE_FIXED_CURSOR_TOP(type)                      \
	((type) == GLADE_CURSOR_RESIZE_TOP_RIGHT ||       \
	 (type) == GLADE_CURSOR_RESIZE_TOP_LEFT  ||       \
	 (type) == GLADE_CURSOR_RESIZE_TOP)

#define GLADE_FIXED_CURSOR_BOTTOM(type)                   \
	((type) == GLADE_CURSOR_RESIZE_BOTTOM_RIGHT ||    \
	 (type) == GLADE_CURSOR_RESIZE_BOTTOM_LEFT  ||    \
	 (type) == GLADE_CURSOR_RESIZE_BOTTOM)

#define GLADE_FIXED_CURSOR_RIGHT(type)                    \
	((type) == GLADE_CURSOR_RESIZE_TOP_RIGHT    ||    \
	 (type) == GLADE_CURSOR_RESIZE_BOTTOM_RIGHT ||    \
	 (type) == GLADE_CURSOR_RESIZE_RIGHT)

#define GLADE_FIXED_CURSOR_LEFT(type)                    \
	((type) == GLADE_CURSOR_RESIZE_TOP_LEFT    ||    \
	 (type) == GLADE_CURSOR_RESIZE_BOTTOM_LEFT ||    \
	 (type) == GLADE_CURSOR_RESIZE_LEFT)
41 42 43 44 45 46 47 48 49 50 51

typedef struct _GladeFixed        GladeFixed;
typedef struct _GladeFixedClass   GladeFixedClass;

struct _GladeFixed {
	GladeWidget       parent_instance;

	gchar            *x_prop;      /* packing property names (on child widgets) used */
	gchar            *y_prop;      /* to obtain & configure widget coordinates */
	gchar            *width_prop;  /* property names (on child widgets) used to obtain */
	gchar            *height_prop; /* & configure widget dimentions. */
52 53 54 55

        gboolean          can_resize; /* whether the container supports child resizes or only
				       * drags.
				       */
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

	/* State machine used to commit properties at the end
	 * of a drag or a resize (i.e. a "configure").
	 */
	gint              pointer_x_origin;
	gint              pointer_y_origin;
	gint              pointer_x_child_origin;
	gint              pointer_y_child_origin;
	gint              child_x_origin;
	gint              child_y_origin;
	gint              child_width_origin;
	gint              child_height_origin;

	GladeWidget      *configuring;
	GladeCursorType   operation;
	gboolean          creating;
	gint              mouse_x;
	gint              mouse_y;
};

struct _GladeFixedClass {
77
	GladeWidgetClass   parent_class;
78 79

	gboolean     (* configure_child) (GladeFixed *, GladeWidget *, GdkRectangle *);
Tristan Van Berkom's avatar
Tristan Van Berkom committed
80 81
	gboolean     (* configure_begin) (GladeFixed *, GladeWidget *);
	gboolean     (* configure_end)   (GladeFixed *, GladeWidget *);
82 83 84

	/* Signal handler for child widgets
	 */
85
	gint         (* child_event)     (GladeWidget *, GdkEvent *, GladeFixed *);
86 87 88 89 90 91 92 93

};

GType              glade_fixed_get_type     (void);

G_END_DECLS

#endif   /* __GLADE_FIXED_H__ */