forked from AuroraMiddleware/gtk
more gtkhandlebox work..
This commit is contained in:
parent
e9f322e2f0
commit
61124945c0
@ -14,7 +14,7 @@ VERSION=$GTK_VERSION
|
|||||||
PACKAGE=gtk+
|
PACKAGE=gtk+
|
||||||
|
|
||||||
# Configure glib
|
# Configure glib
|
||||||
AC_CONFIG_SUBDIRS(glib)
|
#AC_CONFIG_SUBDIRS(glib)
|
||||||
|
|
||||||
# Save this value here, since automake will set cflags later
|
# Save this value here, since automake will set cflags later
|
||||||
cflags_set=${CFLAGS+set}
|
cflags_set=${CFLAGS+set}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#undef NO_SYS_SIGLIST
|
#undef NO_SYS_SIGLIST
|
||||||
|
|
||||||
#undef HAVE_WCHAR_H
|
#undef HAVE_WCHAR_H
|
||||||
|
#undef HAVE_WCSTR_H
|
||||||
#undef HAVE_WCTYPE_H
|
#undef HAVE_WCTYPE_H
|
||||||
|
|
||||||
/* #undef PACKAGE */
|
/* #undef PACKAGE */
|
||||||
|
@ -29,7 +29,7 @@ libgtk_la_SOURCES = \
|
|||||||
gtkframe.c \
|
gtkframe.c \
|
||||||
gtkgamma.c \
|
gtkgamma.c \
|
||||||
gtkgc.c \
|
gtkgc.c \
|
||||||
# gtkhandlebox.c \
|
gtkhandlebox.c \
|
||||||
gtkhbbox.c \
|
gtkhbbox.c \
|
||||||
gtkhbox.c \
|
gtkhbox.c \
|
||||||
gtkhpaned.c \
|
gtkhpaned.c \
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "gtksignal.h"
|
#include "gtksignal.h"
|
||||||
#include "gtkhandlebox.h"
|
#include "gtkhandlebox.h"
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
|
#define DRAG_HANDLE_SIZE 10
|
||||||
|
|
||||||
static void gtk_handle_box_class_init (GtkHandleBoxClass *klass);
|
static void gtk_handle_box_class_init (GtkHandleBoxClass *klass);
|
||||||
static void gtk_handle_box_init (GtkHandleBox *handle_box);
|
static void gtk_handle_box_init (GtkHandleBox *handle_box);
|
||||||
@ -26,6 +28,8 @@ static void gtk_handle_box_size_request (GtkWidget *widget,
|
|||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
static void gtk_handle_box_size_allocate (GtkWidget *widget,
|
static void gtk_handle_box_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *allocation);
|
GtkAllocation *allocation);
|
||||||
|
static void gtk_handle_box_paint (GtkWidget *widget,
|
||||||
|
GdkRectangle *area);
|
||||||
static void gtk_handle_box_draw (GtkWidget *widget,
|
static void gtk_handle_box_draw (GtkWidget *widget,
|
||||||
GdkRectangle *area);
|
GdkRectangle *area);
|
||||||
static gint gtk_handle_box_expose (GtkWidget *widget,
|
static gint gtk_handle_box_expose (GtkWidget *widget,
|
||||||
@ -41,7 +45,7 @@ gtk_handle_box_get_type ()
|
|||||||
{
|
{
|
||||||
static guint handle_box_type = 0;
|
static guint handle_box_type = 0;
|
||||||
|
|
||||||
if (!event_box_type)
|
if (!handle_box_type)
|
||||||
{
|
{
|
||||||
GtkTypeInfo handle_box_info =
|
GtkTypeInfo handle_box_info =
|
||||||
{
|
{
|
||||||
@ -65,14 +69,13 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
|
|||||||
GtkWidgetClass *widget_class;
|
GtkWidgetClass *widget_class;
|
||||||
|
|
||||||
widget_class = (GtkWidgetClass*) class;
|
widget_class = (GtkWidgetClass*) class;
|
||||||
|
|
||||||
widget_class->realize = gtk_handle_box_realize;
|
widget_class->realize = gtk_handle_box_realize;
|
||||||
widget_class->size_request = gtk_handle_box_size_request;
|
widget_class->size_request = gtk_handle_box_size_request;
|
||||||
widget_class->size_allocate = gtk_handle_box_size_allocate;
|
widget_class->size_allocate = gtk_handle_box_size_allocate;
|
||||||
widget_class->draw = gtk_handle_box_draw;
|
widget_class->draw = gtk_handle_box_draw;
|
||||||
widget_class->expose_event = gtk_handle_box_expose;
|
widget_class->expose_event = gtk_handle_box_expose;
|
||||||
widget_class->button_press_event = gtk_handle_box_button_change;
|
widget_class->button_press_event = gtk_handle_box_button_changed;
|
||||||
widget_class->button_release_event = gtk_handle_box_button_change;
|
widget_class->button_release_event = gtk_handle_box_button_changed;
|
||||||
widget_class->motion_notify_event = gtk_handle_box_motion;
|
widget_class->motion_notify_event = gtk_handle_box_motion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,15 +142,16 @@ gtk_handle_box_size_request (GtkWidget *widget,
|
|||||||
|
|
||||||
bin = GTK_BIN (widget);
|
bin = GTK_BIN (widget);
|
||||||
|
|
||||||
requisition->width = GTK_CONTAINER (widget)->border_width * 2;
|
requisition->width = DRAG_HANDLE_SIZE;
|
||||||
requisition->height = GTK_CONTAINER (widget)->border_width * 2;
|
requisition->height = DRAG_HANDLE_SIZE;
|
||||||
|
|
||||||
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
||||||
{
|
{
|
||||||
gtk_widget_size_request (bin->child, &bin->child->requisition);
|
gtk_widget_size_request (bin->child, &bin->child->requisition);
|
||||||
|
|
||||||
requisition->width += bin->child->requisition.width;
|
requisition->width += bin->child->requisition.width;
|
||||||
requisition->height += bin->child->requisition.height;
|
if(bin->child->requisition.height > requisition->height)
|
||||||
|
requisition->height = bin->child->requisition.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,14 +171,14 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
child_allocation.x = 0;
|
child_allocation.x = 0;
|
||||||
child_allocation.y = 0;
|
child_allocation.y = 0;
|
||||||
child_allocation.width = allocation->width - GTK_CONTAINER (widget)->border_width * 2;
|
child_allocation.width = allocation->width - DRAG_HANDLE_SIZE;
|
||||||
child_allocation.height = allocation->height - GTK_CONTAINER (widget)->border_width * 2;
|
child_allocation.height = allocation->height;
|
||||||
|
|
||||||
if (GTK_WIDGET_REALIZED (widget))
|
if (GTK_WIDGET_REALIZED (widget))
|
||||||
{
|
{
|
||||||
gdk_window_move_resize (widget->window,
|
gdk_window_move_resize (widget->window,
|
||||||
allocation->x + GTK_CONTAINER (widget)->border_width,
|
allocation->x + DRAG_HANDLE_SIZE,
|
||||||
allocation->y + GTK_CONTAINER (widget)->border_width,
|
allocation->y,
|
||||||
child_allocation.width,
|
child_allocation.width,
|
||||||
child_allocation.height);
|
child_allocation.height);
|
||||||
}
|
}
|
||||||
@ -185,6 +189,19 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gtk_handle_box_paint(GtkWidget *widget,
|
||||||
|
GdkRectangle *area)
|
||||||
|
{
|
||||||
|
g_print("painting %dx%d+%d+%d\n",
|
||||||
|
area->x, area->y, area->width, area->height);
|
||||||
|
gtk_draw_diamond(widget->style, widget->window,
|
||||||
|
GTK_STATE_NORMAL,
|
||||||
|
GTK_SHADOW_ETCHED_IN,
|
||||||
|
1, 1,
|
||||||
|
DRAG_HANDLE_SIZE,
|
||||||
|
DRAG_HANDLE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_handle_box_draw (GtkWidget *widget,
|
gtk_handle_box_draw (GtkWidget *widget,
|
||||||
GdkRectangle *area)
|
GdkRectangle *area)
|
||||||
@ -200,6 +217,7 @@ gtk_handle_box_draw (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
bin = GTK_BIN (widget);
|
bin = GTK_BIN (widget);
|
||||||
|
|
||||||
|
gtk_handle_box_paint(widget, area);
|
||||||
if (bin->child)
|
if (bin->child)
|
||||||
{
|
{
|
||||||
if (gtk_widget_intersect (bin->child, area, &child_area))
|
if (gtk_widget_intersect (bin->child, area, &child_area))
|
||||||
@ -222,6 +240,7 @@ gtk_handle_box_expose (GtkWidget *widget,
|
|||||||
if (GTK_WIDGET_DRAWABLE (widget))
|
if (GTK_WIDGET_DRAWABLE (widget))
|
||||||
{
|
{
|
||||||
bin = GTK_BIN (widget);
|
bin = GTK_BIN (widget);
|
||||||
|
gtk_handle_box_paint(widget, &event->area);
|
||||||
|
|
||||||
child_event = *event;
|
child_event = *event;
|
||||||
if (bin->child &&
|
if (bin->child &&
|
||||||
@ -242,35 +261,49 @@ static gint gtk_handle_box_button_changed(GtkWidget *widget,
|
|||||||
g_return_val_if_fail(event != NULL, FALSE);
|
g_return_val_if_fail(event != NULL, FALSE);
|
||||||
|
|
||||||
hb = GTK_HANDLE_BOX(widget);
|
hb = GTK_HANDLE_BOX(widget);
|
||||||
|
if(event->button == 1)
|
||||||
if(event->button == 0)
|
|
||||||
{
|
{
|
||||||
if(event->type == GDK_BUTTON_PRESS)
|
if(event->type == GDK_BUTTON_PRESS)
|
||||||
{
|
{
|
||||||
hb->is_being_dragged = TRUE;
|
hb->is_being_dragged = TRUE;
|
||||||
real_parent = widget->parent;
|
if(!hb->real_parent) {
|
||||||
gdk_window_set_override_redirect(hb->window, TRUE);
|
hb->real_parent = widget->parent;
|
||||||
gdk_window_reparent(hb->window, GDK_ROOT_PARENT(),
|
gdk_window_set_override_redirect(widget->window, TRUE);
|
||||||
event->x, event->y);
|
gdk_window_reparent(widget->window, GDK_ROOT_PARENT(),
|
||||||
|
event->x_root - event->x,
|
||||||
|
event->y_root - event->y);
|
||||||
|
g_print("Reparenting with event %f (%f) x %f (%f)\n",
|
||||||
|
event->x_root, event->x,
|
||||||
|
event->y_root, event->y);
|
||||||
|
} else
|
||||||
|
gdk_window_raise(widget->window);
|
||||||
}
|
}
|
||||||
else if(event->type == GDK_BUTTON_RELEASE)
|
else if(event->type == GDK_BUTTON_RELEASE)
|
||||||
{
|
{
|
||||||
hb->is_being_dragged = FALSE;
|
hb->is_being_dragged = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint gtk_handle_box_motion (GtkWidget *widget,
|
static gint gtk_handle_box_motion (GtkWidget *widget,
|
||||||
GdkEventMotion *event)
|
GdkEventMotion *event)
|
||||||
{
|
{
|
||||||
GtkHandleBox *hb;
|
GtkHandleBox *hb;
|
||||||
|
gint newx, newy;
|
||||||
|
|
||||||
g_return_val_if_fail(widget != NULL, FALSE);
|
g_return_val_if_fail(widget != NULL, FALSE);
|
||||||
g_return_val_if_fail(GTK_IS_HANDLE_BOX(widget), FALSE);
|
g_return_val_if_fail(GTK_IS_HANDLE_BOX(widget), FALSE);
|
||||||
g_return_val_if_fail(event != NULL, FALSE);
|
g_return_val_if_fail(event != NULL, FALSE);
|
||||||
|
|
||||||
hb = GTK_HANDLE_BOX(widget);
|
hb = GTK_HANDLE_BOX(widget);
|
||||||
if(hb->is_being_dragged) {
|
if(hb->is_being_dragged) {
|
||||||
gdk_window_move(widget->window, event->x_root - event->x,
|
newx = event->x_root - DRAG_HANDLE_SIZE;
|
||||||
event->y_root - event->y);
|
newy = event->y_root - DRAG_HANDLE_SIZE;
|
||||||
|
if(newx < 0) newx = 0;
|
||||||
|
if(newy < 0) newy = 0;
|
||||||
|
gdk_window_move(widget->window, newx,
|
||||||
|
newy);
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@
|
|||||||
* License along with this library; if not, write to the Free
|
* License along with this library; if not, write to the Free
|
||||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* The GtkHandleBox is to allow
|
/* The GtkHandleBox is to allow widgets to be dragged in and out of
|
||||||
|
their parents */
|
||||||
#ifndef __GTK_HANDLE_BOX_H__
|
#ifndef __GTK_HANDLE_BOX_H__
|
||||||
#define __GTK_HANDLE_BOX_H__
|
#define __GTK_HANDLE_BOX_H__
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "gtk.h"
|
#include "gtk.h"
|
||||||
#include "../gdk/gdk.h"
|
#include "../gdk/gdk.h"
|
||||||
#include "../gdk/gdkx.h"
|
#include "../gdk/gdkx.h"
|
||||||
|
#include "gtkhandlebox.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
destroy_window (GtkWidget *widget,
|
destroy_window (GtkWidget *widget,
|
||||||
@ -548,6 +548,50 @@ create_button_box ()
|
|||||||
gtk_widget_destroy (window);
|
gtk_widget_destroy (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
create_handle_box ()
|
||||||
|
{
|
||||||
|
static GtkWidget* window = NULL;
|
||||||
|
GtkWidget* hbox;
|
||||||
|
GtkWidget* button;
|
||||||
|
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
|
gtk_window_set_title (GTK_WINDOW (window),
|
||||||
|
"Handle Box Test");
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC(destroy_window), &window);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||||
|
GTK_SIGNAL_FUNC(destroy_window), &window);
|
||||||
|
|
||||||
|
gtk_container_border_width (GTK_CONTAINER (window), 20);
|
||||||
|
|
||||||
|
/*
|
||||||
|
*these 15 lines are a nice and easy example for GtkHButtonBox
|
||||||
|
*/
|
||||||
|
hbox = gtk_handle_box_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||||
|
gtk_widget_set_usize(hbox, 300, 40);
|
||||||
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
button = gtk_toggle_button_new_with_label ("Let's try this");
|
||||||
|
#else
|
||||||
|
button = gtk_label_new ("Let's try this");
|
||||||
|
#endif
|
||||||
|
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||||
|
gtk_widget_set_usize(button, 250, 40);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GTK_WIDGET_VISIBLE (window))
|
||||||
|
gtk_widget_show (window);
|
||||||
|
else
|
||||||
|
gtk_widget_destroy (window);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reparent_label (GtkWidget *widget,
|
reparent_label (GtkWidget *widget,
|
||||||
@ -3234,6 +3278,7 @@ create_main_window ()
|
|||||||
{ "check buttons", create_check_buttons },
|
{ "check buttons", create_check_buttons },
|
||||||
{ "radio buttons", create_radio_buttons },
|
{ "radio buttons", create_radio_buttons },
|
||||||
{ "button box", create_button_box },
|
{ "button box", create_button_box },
|
||||||
|
{ "handle box", create_handle_box },
|
||||||
{ "reparent", create_reparent },
|
{ "reparent", create_reparent },
|
||||||
{ "pixmap", create_pixmap },
|
{ "pixmap", create_pixmap },
|
||||||
{ "tooltips", create_tooltips },
|
{ "tooltips", create_tooltips },
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "gtk.h"
|
#include "gtk.h"
|
||||||
#include "../gdk/gdk.h"
|
#include "../gdk/gdk.h"
|
||||||
#include "../gdk/gdkx.h"
|
#include "../gdk/gdkx.h"
|
||||||
|
#include "gtkhandlebox.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
destroy_window (GtkWidget *widget,
|
destroy_window (GtkWidget *widget,
|
||||||
@ -548,6 +548,50 @@ create_button_box ()
|
|||||||
gtk_widget_destroy (window);
|
gtk_widget_destroy (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
create_handle_box ()
|
||||||
|
{
|
||||||
|
static GtkWidget* window = NULL;
|
||||||
|
GtkWidget* hbox;
|
||||||
|
GtkWidget* button;
|
||||||
|
|
||||||
|
if (!window)
|
||||||
|
{
|
||||||
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
|
gtk_window_set_title (GTK_WINDOW (window),
|
||||||
|
"Handle Box Test");
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC(destroy_window), &window);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||||
|
GTK_SIGNAL_FUNC(destroy_window), &window);
|
||||||
|
|
||||||
|
gtk_container_border_width (GTK_CONTAINER (window), 20);
|
||||||
|
|
||||||
|
/*
|
||||||
|
*these 15 lines are a nice and easy example for GtkHButtonBox
|
||||||
|
*/
|
||||||
|
hbox = gtk_handle_box_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (window), hbox);
|
||||||
|
gtk_widget_set_usize(hbox, 300, 40);
|
||||||
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
button = gtk_toggle_button_new_with_label ("Let's try this");
|
||||||
|
#else
|
||||||
|
button = gtk_label_new ("Let's try this");
|
||||||
|
#endif
|
||||||
|
gtk_container_add (GTK_CONTAINER (hbox), button);
|
||||||
|
gtk_widget_set_usize(button, 250, 40);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GTK_WIDGET_VISIBLE (window))
|
||||||
|
gtk_widget_show (window);
|
||||||
|
else
|
||||||
|
gtk_widget_destroy (window);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reparent_label (GtkWidget *widget,
|
reparent_label (GtkWidget *widget,
|
||||||
@ -3234,6 +3278,7 @@ create_main_window ()
|
|||||||
{ "check buttons", create_check_buttons },
|
{ "check buttons", create_check_buttons },
|
||||||
{ "radio buttons", create_radio_buttons },
|
{ "radio buttons", create_radio_buttons },
|
||||||
{ "button box", create_button_box },
|
{ "button box", create_button_box },
|
||||||
|
{ "handle box", create_handle_box },
|
||||||
{ "reparent", create_reparent },
|
{ "reparent", create_reparent },
|
||||||
{ "pixmap", create_pixmap },
|
{ "pixmap", create_pixmap },
|
||||||
{ "tooltips", create_tooltips },
|
{ "tooltips", create_tooltips },
|
||||||
|
Loading…
Reference in New Issue
Block a user