Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gtk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1,126
Issues
1,126
List
Boards
Labels
Service Desk
Milestones
Merge Requests
150
Merge Requests
150
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GNOME
gtk
Commits
61124945
Commit
61124945
authored
Dec 19, 1997
by
Elliot Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more gtkhandlebox work..
parent
e9f322e2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
152 additions
and
27 deletions
+152
-27
configure.in
configure.in
+1
-1
glib/glibconfig.h.in
glib/glibconfig.h.in
+1
-0
gtk/Makefile.am
gtk/Makefile.am
+1
-1
gtk/gtkhandlebox.c
gtk/gtkhandlebox.c
+55
-22
gtk/gtkhandlebox.h
gtk/gtkhandlebox.h
+2
-1
gtk/testgtk.c
gtk/testgtk.c
+46
-1
tests/testgtk.c
tests/testgtk.c
+46
-1
No files found.
configure.in
View file @
61124945
...
...
@@ -14,7 +14,7 @@ VERSION=$GTK_VERSION
PACKAGE=gtk+
# Configure glib
AC_CONFIG_SUBDIRS(glib)
#
AC_CONFIG_SUBDIRS(glib)
# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS+set}
...
...
glib/glibconfig.h.in
View file @
61124945
...
...
@@ -31,6 +31,7 @@
#undef NO_SYS_SIGLIST
#undef HAVE_WCHAR_H
#undef HAVE_WCSTR_H
#undef HAVE_WCTYPE_H
/* #undef PACKAGE */
...
...
gtk/Makefile.am
View file @
61124945
...
...
@@ -29,7 +29,7 @@ libgtk_la_SOURCES = \
gtkframe.c
\
gtkgamma.c
\
gtkgc.c
\
#
gtkhandlebox.c
\
gtkhandlebox.c
\
gtkhbbox.c
\
gtkhbox.c
\
gtkhpaned.c
\
...
...
gtk/gtkhandlebox.c
View file @
61124945
...
...
@@ -17,7 +17,9 @@
*/
#include "gtksignal.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_init
(
GtkHandleBox
*
handle_box
);
...
...
@@ -26,6 +28,8 @@ static void gtk_handle_box_size_request (GtkWidget *widget,
GtkRequisition
*
requisition
);
static
void
gtk_handle_box_size_allocate
(
GtkWidget
*
widget
,
GtkAllocation
*
allocation
);
static
void
gtk_handle_box_paint
(
GtkWidget
*
widget
,
GdkRectangle
*
area
);
static
void
gtk_handle_box_draw
(
GtkWidget
*
widget
,
GdkRectangle
*
area
);
static
gint
gtk_handle_box_expose
(
GtkWidget
*
widget
,
...
...
@@ -41,7 +45,7 @@ gtk_handle_box_get_type ()
{
static
guint
handle_box_type
=
0
;
if
(
!
event
_box_type
)
if
(
!
handle
_box_type
)
{
GtkTypeInfo
handle_box_info
=
{
...
...
@@ -65,14 +69,13 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
GtkWidgetClass
*
widget_class
;
widget_class
=
(
GtkWidgetClass
*
)
class
;
widget_class
->
realize
=
gtk_handle_box_realize
;
widget_class
->
size_request
=
gtk_handle_box_size_request
;
widget_class
->
size_allocate
=
gtk_handle_box_size_allocate
;
widget_class
->
draw
=
gtk_handle_box_draw
;
widget_class
->
expose_event
=
gtk_handle_box_expose
;
widget_class
->
button_press_event
=
gtk_handle_box_button_change
;
widget_class
->
button_release_event
=
gtk_handle_box_button_change
;
widget_class
->
button_press_event
=
gtk_handle_box_button_change
d
;
widget_class
->
button_release_event
=
gtk_handle_box_button_change
d
;
widget_class
->
motion_notify_event
=
gtk_handle_box_motion
;
}
...
...
@@ -129,7 +132,7 @@ gtk_handle_box_realize (GtkWidget *widget)
static
void
gtk_handle_box_size_request
(
GtkWidget
*
widget
,
GtkRequisition
*
requisition
)
GtkRequisition
*
requisition
)
{
GtkBin
*
bin
;
...
...
@@ -139,15 +142,16 @@ gtk_handle_box_size_request (GtkWidget *widget,
bin
=
GTK_BIN
(
widget
);
requisition
->
width
=
GTK_CONTAINER
(
widget
)
->
border_width
*
2
;
requisition
->
height
=
GTK_CONTAINER
(
widget
)
->
border_width
*
2
;
requisition
->
width
=
DRAG_HANDLE_SIZE
;
requisition
->
height
=
DRAG_HANDLE_SIZE
;
if
(
bin
->
child
&&
GTK_WIDGET_VISIBLE
(
bin
->
child
))
{
gtk_widget_size_request
(
bin
->
child
,
&
bin
->
child
->
requisition
);
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
.
y
=
0
;
child_allocation
.
width
=
allocation
->
width
-
GTK_CONTAINER
(
widget
)
->
border_width
*
2
;
child_allocation
.
height
=
allocation
->
height
-
GTK_CONTAINER
(
widget
)
->
border_width
*
2
;
child_allocation
.
width
=
allocation
->
width
-
DRAG_HANDLE_SIZE
;
child_allocation
.
height
=
allocation
->
height
;
if
(
GTK_WIDGET_REALIZED
(
widget
))
{
gdk_window_move_resize
(
widget
->
window
,
allocation
->
x
+
GTK_CONTAINER
(
widget
)
->
border_width
,
allocation
->
y
+
GTK_CONTAINER
(
widget
)
->
border_width
,
allocation
->
x
+
DRAG_HANDLE_SIZE
,
allocation
->
y
,
child_allocation
.
width
,
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
gtk_handle_box_draw
(
GtkWidget
*
widget
,
GdkRectangle
*
area
)
...
...
@@ -199,7 +216,8 @@ gtk_handle_box_draw (GtkWidget *widget,
if
(
GTK_WIDGET_DRAWABLE
(
widget
))
{
bin
=
GTK_BIN
(
widget
);
gtk_handle_box_paint
(
widget
,
area
);
if
(
bin
->
child
)
{
if
(
gtk_widget_intersect
(
bin
->
child
,
area
,
&
child_area
))
...
...
@@ -210,7 +228,7 @@ gtk_handle_box_draw (GtkWidget *widget,
static
gint
gtk_handle_box_expose
(
GtkWidget
*
widget
,
GdkEventExpose
*
event
)
GdkEventExpose
*
event
)
{
GtkBin
*
bin
;
GdkEventExpose
child_event
;
...
...
@@ -222,6 +240,7 @@ gtk_handle_box_expose (GtkWidget *widget,
if
(
GTK_WIDGET_DRAWABLE
(
widget
))
{
bin
=
GTK_BIN
(
widget
);
gtk_handle_box_paint
(
widget
,
&
event
->
area
);
child_event
=
*
event
;
if
(
bin
->
child
&&
...
...
@@ -242,35 +261,49 @@ static gint gtk_handle_box_button_changed(GtkWidget *widget,
g_return_val_if_fail
(
event
!=
NULL
,
FALSE
);
hb
=
GTK_HANDLE_BOX
(
widget
);
if
(
event
->
button
==
0
)
if
(
event
->
button
==
1
)
{
if
(
event
->
type
==
GDK_BUTTON_PRESS
)
{
hb
->
is_being_dragged
=
TRUE
;
real_parent
=
widget
->
parent
;
gdk_window_set_override_redirect
(
hb
->
window
,
TRUE
);
gdk_window_reparent
(
hb
->
window
,
GDK_ROOT_PARENT
(),
event
->
x
,
event
->
y
);
if
(
!
hb
->
real_parent
)
{
hb
->
real_parent
=
widget
->
parent
;
gdk_window_set_override_redirect
(
widget
->
window
,
TRUE
);
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
)
{
hb
->
is_being_dragged
=
FALSE
;
}
}
return
TRUE
;
}
static
gint
gtk_handle_box_motion
(
GtkWidget
*
widget
,
GdkEventMotion
*
event
)
{
GtkHandleBox
*
hb
;
gint
newx
,
newy
;
g_return_val_if_fail
(
widget
!=
NULL
,
FALSE
);
g_return_val_if_fail
(
GTK_IS_HANDLE_BOX
(
widget
),
FALSE
);
g_return_val_if_fail
(
event
!=
NULL
,
FALSE
);
hb
=
GTK_HANDLE_BOX
(
widget
);
if
(
hb
->
is_being_dragged
)
{
gdk_window_move
(
widget
->
window
,
event
->
x_root
-
event
->
x
,
event
->
y_root
-
event
->
y
);
newx
=
event
->
x_root
-
DRAG_HANDLE_SIZE
;
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
;
}
gtk/gtkhandlebox.h
View file @
61124945
...
...
@@ -15,7 +15,8 @@
* License along with this library; if not, write to the Free
* 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__
#define __GTK_HANDLE_BOX_H__
...
...
gtk/testgtk.c
View file @
61124945
...
...
@@ -20,7 +20,7 @@
#include "gtk.h"
#include "../gdk/gdk.h"
#include "../gdk/gdkx.h"
#include "gtkhandlebox.h"
void
destroy_window
(
GtkWidget
*
widget
,
...
...
@@ -548,6 +548,50 @@ create_button_box ()
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
reparent_label
(
GtkWidget
*
widget
,
...
...
@@ -3234,6 +3278,7 @@ create_main_window ()
{
"check buttons"
,
create_check_buttons
},
{
"radio buttons"
,
create_radio_buttons
},
{
"button box"
,
create_button_box
},
{
"handle box"
,
create_handle_box
},
{
"reparent"
,
create_reparent
},
{
"pixmap"
,
create_pixmap
},
{
"tooltips"
,
create_tooltips
},
...
...
tests/testgtk.c
View file @
61124945
...
...
@@ -20,7 +20,7 @@
#include "gtk.h"
#include "../gdk/gdk.h"
#include "../gdk/gdkx.h"
#include "gtkhandlebox.h"
void
destroy_window
(
GtkWidget
*
widget
,
...
...
@@ -548,6 +548,50 @@ create_button_box ()
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
reparent_label
(
GtkWidget
*
widget
,
...
...
@@ -3234,6 +3278,7 @@ create_main_window ()
{
"check buttons"
,
create_check_buttons
},
{
"radio buttons"
,
create_radio_buttons
},
{
"button box"
,
create_button_box
},
{
"handle box"
,
create_handle_box
},
{
"reparent"
,
create_reparent
},
{
"pixmap"
,
create_pixmap
},
{
"tooltips"
,
create_tooltips
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment