diff options
author | Owen Taylor <otaylor@src.gnome.org> | 1998-11-06 22:05:02 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-11-06 22:05:02 +0000 |
commit | e2a521922085c8010028e227f61bba59ea6b8242 (patch) | |
tree | 2500d6aa6f63aab4b58c17546532ecce8fdcca37 /gtk | |
parent | 3c0df19a588bd96f328bda975db8eb9fa7f79e81 (diff) | |
download | gtk+-e2a521922085c8010028e227f61bba59ea6b8242.tar.gz |
Merge from themes-2. See the ChangeLog for a somewhat detailed
history of the evolution of the changes involved. Most of this
is actually minor painting tweaks.
Diffstat (limited to 'gtk')
74 files changed, 6792 insertions, 3911 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 7ce7310c55..d2802d55ec 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -5,7 +5,7 @@ DEFS += -DG_LOG_DOMAIN=\"Gtk\" lib_LTLIBRARIES = libgtk.la -libgtk_la_SOURCES = \ +static_sources = \ gtkaccelgroup.c \ gtkaccellabel.c \ gtkadjustment.c \ @@ -31,6 +31,7 @@ libgtk_la_SOURCES = \ gtkdialog.c \ gtkdnd.c \ gtkdrawingarea.c \ + gtkdrawwindow.c \ gtkeditable.c \ gtkentry.c \ gtkeventbox.c \ @@ -57,7 +58,6 @@ libgtk_la_SOURCES = \ gtklist.c \ gtklistitem.c \ gtkmain.c \ - gtkmarshal.c \ gtkmenu.c \ gtkmenubar.c \ gtkmenufactory.c \ @@ -90,6 +90,7 @@ libgtk_la_SOURCES = \ gtktable.c \ gtktearoffmenuitem.c \ gtktext.c \ + gtkthemes.c \ gtktipsquery.c \ gtktogglebutton.c \ gtktoolbar.c \ @@ -110,6 +111,10 @@ libgtk_la_SOURCES = \ fnmatch.c \ fnmatch.h +libgtk_la_SOURCES = \ + $(static_sources) \ + gtkmarshal.c + # Source headers are are non-autogenerated headers source_headers = \ gtk.h \ @@ -139,6 +144,7 @@ source_headers = \ gtkdialog.h \ gtkdnd.h \ gtkdrawingarea.h \ + gtkdrawwindow.h \ gtkeditable.h \ gtkentry.h \ gtkenums.h \ @@ -199,6 +205,7 @@ source_headers = \ gtktable.h \ gtktearoffmenuitem.h \ gtktext.h \ + gtkthemes.h \ gtktipsquery.h \ gtktogglebutton.h \ gtktoolbar.h \ @@ -232,7 +239,7 @@ BUILT_SOURCES = \ gtkmarshal.h # cause the built sources to be rebuild when possible, even with --include-deps -$(libgtk_la_SOURCES): $(BUILT_SOURCES) +$(static_sources): $(BUILT_SOURCES) # More headers to use when autogenerating. gdk_headers = \ @@ -307,12 +314,13 @@ EXTRA_DIST = \ tree_minus.xbm \ circles.xbm -INCLUDES = -I$(top_srcdir) @GLIB_CFLAGS@ @x_cflags@ +INCLUDES = \ + -DGTK_EXE_PREFIX=\"$(exec_prefix)\" \ + -DGTK_DATA_PREFIX=\"$(prefix)\" \ + -I$(top_srcdir) @GLIB_CFLAGS@ @x_cflags@ noinst_PROGRAMS = testgtk testinput testselection testthreads testrgb testdnd simple -# FIXME, we currently rely on linking against libglib-1.1 - DEPS = \ libgtk.la \ $(top_builddir)/gdk/libgdk.la diff --git a/gtk/Makefile.in b/gtk/Makefile.in deleted file mode 100644 index 48cc410cb3..0000000000 --- a/gtk/Makefile.in +++ /dev/null @@ -1,712 +0,0 @@ -# Makefile.in generated automatically by automake 1.3 from Makefile.am - -# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - -SHELL = /bin/sh - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -bindir = @bindir@ -sbindir = @sbindir@ -libexecdir = @libexecdir@ -datadir = @datadir@ -sysconfdir = @sysconfdir@ -sharedstatedir = @sharedstatedir@ -localstatedir = @localstatedir@ -libdir = @libdir@ -infodir = @infodir@ -mandir = @mandir@ -includedir = @includedir@ -oldincludedir = /usr/include - -DISTDIR = - -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ - -top_builddir = .. - -ACLOCAL = @ACLOCAL@ -AUTOCONF = @AUTOCONF@ -AUTOMAKE = @AUTOMAKE@ -AUTOHEADER = @AUTOHEADER@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -transform = @program_transform_name@ - -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -host_alias = @host_alias@ -host_triplet = @host@ -CC = @CC@ -GTK_MAJOR_VERSION = @GTK_MAJOR_VERSION@ -GTK_MICRO_VERSION = @GTK_MICRO_VERSION@ -GTK_MINOR_VERSION = @GTK_MINOR_VERSION@ -GTK_VERSION = @GTK_VERSION@ -LD = @LD@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LT_AGE = @LT_AGE@ -LT_CURRENT = @LT_CURRENT@ -LT_RELEASE = @LT_RELEASE@ -LT_REVISION = @LT_REVISION@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -NM = @NM@ -PACKAGE = @PACKAGE@ -RANLIB = @RANLIB@ -VERSION = @VERSION@ -x_cflags = @x_cflags@ -x_includes = @x_includes@ -x_ldflags = @x_ldflags@ -x_libs = @x_libs@ -xinput_progs = @xinput_progs@ - -gtkincludedir = $(includedir)/gtk - -lib_LTLIBRARIES = libgtk-1.1.la - -libgtk_1_1_la_SOURCES = \ - gtkaccelerator.c \ - gtkadjustment.c \ - gtkaspectframe.c \ - gtkalignment.c \ - gtkarrow.c \ - gtkbin.c \ - gtkbbox.c \ - gtkbox.c \ - gtkbutton.c \ - gtkcheckbutton.c \ - gtkcheckmenuitem.c \ - gtkclist.c \ - gtkcolorsel.c \ - gtkcombo.c \ - gtkcontainer.c \ - gtkctree.c \ - gtkcurve.c \ - gtkdata.c \ - gtkdialog.c \ - gtkdrawingarea.c \ - gtkeditable.c \ - gtkentry.c \ - gtkeventbox.c \ - gtkfilesel.c \ - gtkfixed.c \ - gtkframe.c \ - gtkgamma.c \ - gtkgc.c \ - gtkhandlebox.c \ - gtkhbbox.c \ - gtkhbox.c \ - gtkhpaned.c \ - gtkhruler.c \ - gtkhscale.c \ - gtkhscrollbar.c \ - gtkhseparator.c \ - gtkimage.c \ - gtkinputdialog.c \ - gtkitem.c \ - gtklabel.c \ - gtklist.c \ - gtklistitem.c \ - gtkmain.c \ - gtkmenu.c \ - gtkmenubar.c \ - gtkmenufactory.c \ - gtkmenuitem.c \ - gtkmenushell.c \ - gtkmisc.c \ - gtknotebook.c \ - gtkobject.c \ - gtkoptionmenu.c \ - gtkpaned.c \ - gtkpixmap.c \ - gtkpreview.c \ - gtkprogressbar.c \ - gtkradiobutton.c \ - gtkradiomenuitem.c \ - gtkrange.c \ - gtkrc.c \ - gtkruler.c \ - gtkscale.c \ - gtkscrollbar.c \ - gtkscrolledwindow.c \ - gtkselection.c \ - gtkseparator.c \ - gtksignal.c \ - gtkspinbutton.c \ - gtkstyle.c \ - gtkstatusbar.c \ - gtktable.c \ - gtktext.c \ - gtktipsquery.c \ - gtktogglebutton.c \ - gtktoolbar.c \ - gtktooltips.c \ - gtktree.c \ - gtktreeitem.c \ - gtktypeutils.c \ - gtkvbbox.c \ - gtkvbox.c \ - gtkviewport.c \ - gtkvpaned.c \ - gtkvruler.c \ - gtkvscale.c \ - gtkvscrollbar.c \ - gtkvseparator.c \ - gtkwidget.c \ - gtkwindow.c \ - fnmatch.c \ - fnmatch.h - -gtkinclude_HEADERS = \ - gtk.h \ - gtkaccelerator.h \ - gtkadjustment.h \ - gtkaspectframe.h \ - gtkalignment.h \ - gtkarrow.h \ - gtkbin.h \ - gtkbbox.h \ - gtkbox.h \ - gtkbutton.h \ - gtkcheckbutton.h \ - gtkcheckmenuitem.h \ - gtkclist.h \ - gtkcolorsel.h \ - gtkcombo.h \ - gtkcontainer.h \ - gtkctree.h \ - gtkcurve.h \ - gtkdata.h \ - gtkdebug.h \ - gtkdialog.h \ - gtkdrawingarea.h \ - gtkeditable.h \ - gtkentry.h \ - gtkenums.h \ - gtkeventbox.h \ - gtkfeatures.h \ - gtkfilesel.h \ - gtkfixed.h \ - gtkframe.h \ - gtkgamma.h \ - gtkgc.h \ - gtkhandlebox.h \ - gtkhbbox.h \ - gtkhbox.h \ - gtkhpaned.h \ - gtkhruler.h \ - gtkhscale.h \ - gtkhscrollbar.h \ - gtkhseparator.h \ - gtkimage.h \ - gtkinputdialog.h \ - gtkitem.h \ - gtklabel.h \ - gtklist.h \ - gtklistitem.h \ - gtkmain.h \ - gtkmenu.h \ - gtkmenubar.h \ - gtkmenufactory.h \ - gtkmenuitem.h \ - gtkmenushell.h \ - gtkmisc.h \ - gtknotebook.h \ - gtkobject.h \ - gtkoptionmenu.h \ - gtkpaned.h \ - gtkpixmap.h \ - gtkpreview.h \ - gtkprivate.h \ - gtkprogressbar.h \ - gtkradiobutton.h \ - gtkradiomenuitem.h \ - gtkrange.h \ - gtkrc.h \ - gtkruler.h \ - gtkscale.h \ - gtkscrollbar.h \ - gtkscrolledwindow.h \ - gtkselection.h \ - gtkseparator.h \ - gtksignal.h \ - gtkspinbutton.h \ - gtkstyle.h \ - gtkstatusbar.h \ - gtktable.h \ - gtktext.h \ - gtktipsquery.h \ - gtktogglebutton.h \ - gtktoolbar.h \ - gtktooltips.h \ - gtktree.h \ - gtktreeitem.h \ - gtktypeutils.h \ - gtkvbbox.h \ - gtkvbox.h \ - gtkviewport.h \ - gtkvpaned.h \ - gtkvruler.h \ - gtkvscale.h \ - gtkvscrollbar.h \ - gtkvseparator.h \ - gtkwidget.h \ - gtkwindow.h \ - gtktypebuiltins.h - -libgtk_1_1_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) - -EXTRA_DIST = \ - line-arrow.xbm \ - line-wrap.xbm \ - testgtkrc \ - testgtkrc2 \ - gtk.defs \ - gtkfeatures.h.in \ - runelisp \ - gentypeinfo.el \ - gtktypebuiltins.c \ - test.xpm \ - marble.xpm \ - 3DRings.xpm \ - FilesQueue.xpm \ - Modeller.xpm \ - tree_plus.xpm \ - tree_minus.xpm \ - tree_plus.xbm \ - tree_minus.xbm \ - circles.xbm - -INCLUDES = -I$(top_srcdir) -I../glib -I$(top_srcdir)/glib @x_cflags@ - -noinst_PROGRAMS = testgtk testinput testselection testthreads simple - -# FIXME, we currently rely on linking against libglib-1.1 - -DEPS = \ - libgtk-@LT_RELEASE@.la \ - $(top_builddir)/gdk/libgdk-@LT_RELEASE@.la \ - $(top_builddir)/glib/libglib-1.1.la -LDADDS = \ - libgtk-@LT_RELEASE@.la \ - $(top_builddir)/gdk/libgdk-@LT_RELEASE@.la \ - @x_ldflags@ \ - @x_libs@ \ - $(top_builddir)/glib/libglib-1.1.la \ - -lm - -testgtk_DEPENDENCIES = $(DEPS) -testinput_DEPENDENCIES = $(DEPS) -testthreads_DEPENDENCIES = $(DEPS) -testselection_DEPENDENCIES = $(DEPS) -simple_DEPENDENCIES = $(DEPS) - -testgtk_LDADD = $(LDADDS) -testinput_LDADD = $(LDADDS) -testthreads_LDADD = $(LDADDS) -testselection_LDADD = $(LDADDS) -simple_LDADD = $(LDADDS) -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = gtkfeatures.h -LTLIBRARIES = $(lib_LTLIBRARIES) - - -DEFS = @DEFS@ -I. -I$(srcdir) -I.. -CPPFLAGS = @CPPFLAGS@ -LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ -X_CFLAGS = @X_CFLAGS@ -X_LIBS = @X_LIBS@ -X_EXTRA_LIBS = @X_EXTRA_LIBS@ -X_PRE_LIBS = @X_PRE_LIBS@ -libgtk_1_1_la_LIBADD = -libgtk_1_1_la_OBJECTS = gtkaccelerator.lo gtkadjustment.lo \ -gtkaspectframe.lo gtkalignment.lo gtkarrow.lo gtkbin.lo gtkbbox.lo \ -gtkbox.lo gtkbutton.lo gtkcheckbutton.lo gtkcheckmenuitem.lo \ -gtkclist.lo gtkcolorsel.lo gtkcombo.lo gtkcontainer.lo gtkctree.lo \ -gtkcurve.lo gtkdata.lo gtkdialog.lo gtkdrawingarea.lo gtkeditable.lo \ -gtkentry.lo gtkeventbox.lo gtkfilesel.lo gtkfixed.lo gtkframe.lo \ -gtkgamma.lo gtkgc.lo gtkhandlebox.lo gtkhbbox.lo gtkhbox.lo \ -gtkhpaned.lo gtkhruler.lo gtkhscale.lo gtkhscrollbar.lo \ -gtkhseparator.lo gtkimage.lo gtkinputdialog.lo gtkitem.lo gtklabel.lo \ -gtklist.lo gtklistitem.lo gtkmain.lo gtkmenu.lo gtkmenubar.lo \ -gtkmenufactory.lo gtkmenuitem.lo gtkmenushell.lo gtkmisc.lo \ -gtknotebook.lo gtkobject.lo gtkoptionmenu.lo gtkpaned.lo gtkpixmap.lo \ -gtkpreview.lo gtkprogressbar.lo gtkradiobutton.lo gtkradiomenuitem.lo \ -gtkrange.lo gtkrc.lo gtkruler.lo gtkscale.lo gtkscrollbar.lo \ -gtkscrolledwindow.lo gtkselection.lo gtkseparator.lo gtksignal.lo \ -gtkspinbutton.lo gtkstyle.lo gtkstatusbar.lo gtktable.lo gtktext.lo \ -gtktipsquery.lo gtktogglebutton.lo gtktoolbar.lo gtktooltips.lo \ -gtktree.lo gtktreeitem.lo gtktypeutils.lo gtkvbbox.lo gtkvbox.lo \ -gtkviewport.lo gtkvpaned.lo gtkvruler.lo gtkvscale.lo gtkvscrollbar.lo \ -gtkvseparator.lo gtkwidget.lo gtkwindow.lo fnmatch.lo -PROGRAMS = $(noinst_PROGRAMS) - -testgtk_SOURCES = testgtk.c -testgtk_OBJECTS = testgtk.o -testgtk_LDFLAGS = -testinput_SOURCES = testinput.c -testinput_OBJECTS = testinput.o -testinput_LDFLAGS = -testselection_SOURCES = testselection.c -testselection_OBJECTS = testselection.o -testselection_LDFLAGS = -testthreads_SOURCES = testthreads.c -testthreads_OBJECTS = testthreads.o -testthreads_LDFLAGS = -simple_SOURCES = simple.c -simple_OBJECTS = simple.o -simple_LDFLAGS = -CFLAGS = @CFLAGS@ -COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@ -HEADERS = $(gtkinclude_HEADERS) - -DIST_COMMON = Makefile.am Makefile.in gtkfeatures.h.in - - -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP = --best -DEP_FILES = .deps/fnmatch.P .deps/gtkaccelerator.P \ -.deps/gtkadjustment.P .deps/gtkalignment.P .deps/gtkarrow.P \ -.deps/gtkaspectframe.P .deps/gtkbbox.P .deps/gtkbin.P .deps/gtkbox.P \ -.deps/gtkbutton.P .deps/gtkcheckbutton.P .deps/gtkcheckmenuitem.P \ -.deps/gtkclist.P .deps/gtkcolorsel.P .deps/gtkcombo.P \ -.deps/gtkcontainer.P .deps/gtkctree.P .deps/gtkcurve.P .deps/gtkdata.P \ -.deps/gtkdialog.P .deps/gtkdrawingarea.P .deps/gtkeditable.P \ -.deps/gtkentry.P .deps/gtkeventbox.P .deps/gtkfilesel.P \ -.deps/gtkfixed.P .deps/gtkframe.P .deps/gtkgamma.P .deps/gtkgc.P \ -.deps/gtkhandlebox.P .deps/gtkhbbox.P .deps/gtkhbox.P .deps/gtkhpaned.P \ -.deps/gtkhruler.P .deps/gtkhscale.P .deps/gtkhscrollbar.P \ -.deps/gtkhseparator.P .deps/gtkimage.P .deps/gtkinputdialog.P \ -.deps/gtkitem.P .deps/gtklabel.P .deps/gtklist.P .deps/gtklistitem.P \ -.deps/gtkmain.P .deps/gtkmenu.P .deps/gtkmenubar.P \ -.deps/gtkmenufactory.P .deps/gtkmenuitem.P .deps/gtkmenushell.P \ -.deps/gtkmisc.P .deps/gtknotebook.P .deps/gtkobject.P \ -.deps/gtkoptionmenu.P .deps/gtkpaned.P .deps/gtkpixmap.P \ -.deps/gtkpreview.P .deps/gtkprogressbar.P .deps/gtkradiobutton.P \ -.deps/gtkradiomenuitem.P .deps/gtkrange.P .deps/gtkrc.P \ -.deps/gtkruler.P .deps/gtkscale.P .deps/gtkscrollbar.P \ -.deps/gtkscrolledwindow.P .deps/gtkselection.P .deps/gtkseparator.P \ -.deps/gtksignal.P .deps/gtkspinbutton.P .deps/gtkstatusbar.P \ -.deps/gtkstyle.P .deps/gtktable.P .deps/gtktext.P .deps/gtktipsquery.P \ -.deps/gtktogglebutton.P .deps/gtktoolbar.P .deps/gtktooltips.P \ -.deps/gtktree.P .deps/gtktreeitem.P .deps/gtktypeutils.P \ -.deps/gtkvbbox.P .deps/gtkvbox.P .deps/gtkviewport.P .deps/gtkvpaned.P \ -.deps/gtkvruler.P .deps/gtkvscale.P .deps/gtkvscrollbar.P \ -.deps/gtkvseparator.P .deps/gtkwidget.P .deps/gtkwindow.P \ -.deps/simple.P .deps/testgtk.P .deps/testinput.P .deps/testselection.P \ -.deps/testthreads.P -SOURCES = $(libgtk_1_1_la_SOURCES) testgtk.c testinput.c testselection.c testthreads.c simple.c -OBJECTS = $(libgtk_1_1_la_OBJECTS) testgtk.o testinput.o testselection.o testthreads.o simple.o - -all: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) - -.SUFFIXES: -.SUFFIXES: .S .c .lo .o .s -$(srcdir)/Makefile.in: @MAINT@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu gtk/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - -gtkfeatures.h: $(top_builddir)/config.status gtkfeatures.h.in - cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status - -mostlyclean-libLTLIBRARIES: - -clean-libLTLIBRARIES: - -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - -distclean-libLTLIBRARIES: - -maintainer-clean-libLTLIBRARIES: - -install-libLTLIBRARIES: $(lib_LTLIBRARIES) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(libdir) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - if test -f $$p; then \ - echo "$(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \ - $(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \ - else :; fi; \ - done - -uninstall-libLTLIBRARIES: - @$(NORMAL_UNINSTALL) - list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ - done - -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - -mostlyclean-compile: - -rm -f *.o core *.core - -clean-compile: - -distclean-compile: - -rm -f *.tab.c - -maintainer-clean-compile: - -.s.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -.S.lo: - $(LIBTOOL) --mode=compile $(COMPILE) -c $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -maintainer-clean-libtool: - -libgtk-1.1.la: $(libgtk_1_1_la_OBJECTS) $(libgtk_1_1_la_DEPENDENCIES) - $(LINK) -rpath $(libdir) $(libgtk_1_1_la_LDFLAGS) $(libgtk_1_1_la_OBJECTS) $(libgtk_1_1_la_LIBADD) $(LIBS) - -mostlyclean-noinstPROGRAMS: - -clean-noinstPROGRAMS: - -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) - -distclean-noinstPROGRAMS: - -maintainer-clean-noinstPROGRAMS: - -testgtk: $(testgtk_OBJECTS) $(testgtk_DEPENDENCIES) - @rm -f testgtk - $(LINK) $(testgtk_LDFLAGS) $(testgtk_OBJECTS) $(testgtk_LDADD) $(LIBS) - -testinput: $(testinput_OBJECTS) $(testinput_DEPENDENCIES) - @rm -f testinput - $(LINK) $(testinput_LDFLAGS) $(testinput_OBJECTS) $(testinput_LDADD) $(LIBS) - -testselection: $(testselection_OBJECTS) $(testselection_DEPENDENCIES) - @rm -f testselection - $(LINK) $(testselection_LDFLAGS) $(testselection_OBJECTS) $(testselection_LDADD) $(LIBS) - -testthreads: $(testthreads_OBJECTS) $(testthreads_DEPENDENCIES) - @rm -f testthreads - $(LINK) $(testthreads_LDFLAGS) $(testthreads_OBJECTS) $(testthreads_LDADD) $(LIBS) - -simple: $(simple_OBJECTS) $(simple_DEPENDENCIES) - @rm -f simple - $(LINK) $(simple_LDFLAGS) $(simple_OBJECTS) $(simple_LDADD) $(LIBS) - -install-gtkincludeHEADERS: $(gtkinclude_HEADERS) - @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(gtkincludedir) - @list='$(gtkinclude_HEADERS)'; for p in $$list; do \ - if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ - echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(gtkincludedir)/$$p"; \ - $(INSTALL_DATA) $$d$$p $(DESTDIR)$(gtkincludedir)/$$p; \ - done - -uninstall-gtkincludeHEADERS: - @$(NORMAL_UNINSTALL) - list='$(gtkinclude_HEADERS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(gtkincludedir)/$$p; \ - done - -tags: TAGS - -ID: $(HEADERS) $(SOURCES) $(LISP) - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) - -mostlyclean-tags: - -clean-tags: - -distclean-tags: - -rm -f TAGS ID - -maintainer-clean-tags: - -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) - -subdir = gtk - -distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu gtk/Makefile - @for file in $(DISTFILES); do \ - d=$(srcdir); \ - test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file; \ - done - -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) - -mostlyclean-depend: - -clean-depend: - -distclean-depend: - -maintainer-clean-depend: - -rm -rf .deps - -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).P -c $< - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $< - @-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \ - < .deps/$(*F).p > .deps/$(*F).P - @-rm -f .deps/$(*F).p -info: -dvi: -check: all - $(MAKE) -installcheck: -install-exec: install-libLTLIBRARIES - @$(NORMAL_INSTALL) - -install-data: install-gtkincludeHEADERS - @$(NORMAL_INSTALL) - -install: install-exec install-data all - @: - -uninstall: uninstall-libLTLIBRARIES uninstall-gtkincludeHEADERS - -install-strip: - $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install -installdirs: - $(mkinstalldirs) $(DATADIR)$(libdir) $(DATADIR)$(gtkincludedir) - - -mostlyclean-generic: - -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) - -clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) - -distclean-generic: - -rm -f Makefile $(DISTCLEANFILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) - -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -mostlyclean: mostlyclean-libLTLIBRARIES mostlyclean-compile \ - mostlyclean-libtool mostlyclean-noinstPROGRAMS \ - mostlyclean-tags mostlyclean-depend mostlyclean-generic - -clean: clean-libLTLIBRARIES clean-compile clean-libtool \ - clean-noinstPROGRAMS clean-tags clean-depend \ - clean-generic mostlyclean - -distclean: distclean-libLTLIBRARIES distclean-compile distclean-libtool \ - distclean-noinstPROGRAMS distclean-tags \ - distclean-depend distclean-generic clean - -rm -f config.status - -rm -f libtool - -maintainer-clean: maintainer-clean-libLTLIBRARIES \ - maintainer-clean-compile maintainer-clean-libtool \ - maintainer-clean-noinstPROGRAMS maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." - -.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ -clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ -uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -mostlyclean-libtool distclean-libtool clean-libtool \ -maintainer-clean-libtool mostlyclean-noinstPROGRAMS \ -distclean-noinstPROGRAMS clean-noinstPROGRAMS \ -maintainer-clean-noinstPROGRAMS uninstall-gtkincludeHEADERS \ -install-gtkincludeHEADERS tags mostlyclean-tags distclean-tags \ -clean-tags maintainer-clean-tags distdir mostlyclean-depend \ -distclean-depend clean-depend maintainer-clean-depend info dvi \ -installcheck install-exec install-data install uninstall all \ -installdirs mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean - - -$(srcdir)/gtktypebuiltins.h: @MAINT@ $(srcdir)/gtk.defs $(srcdir)/gentypeinfo.el - $(SHELL) $(srcdir)/runelisp $(srcdir)/gentypeinfo.el idmac $< $@ - -$(srcdir)/gtktypebuiltins.c: @MAINT@ $(srcdir)/gtk.defs $(srcdir)/gentypeinfo.el - $(SHELL) $(srcdir)/runelisp $(srcdir)/gentypeinfo.el id $< $@ - -.PHONY: files test test-debug - -files: - @files=`ls $(DISTFILES) 2> /dev/null `; for p in $$files; do \ - echo $$p; \ - done - -test: testgtk - builddir=`pwd`; cd $(top_builddir); top_builddir=`pwd`; \ - cd $$builddir; cd $(srcdir); \ - $(SHELL) $$top_builddir/libtool --mode=execute $$builddir/testgtk - -test-debug: testgtk - builddir=`pwd`; cd $(top_builddir); top_builddir=`pwd`; \ - cd $$builddir; cd $(srcdir); \ - $(SHELL) $$top_builddir/libtool --mode=execute gdb $$builddir/testgtk - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/gtk/genmarshal.pl b/gtk/genmarshal.pl index 475e4b456b..ec1bea23a3 100755 --- a/gtk/genmarshal.pl +++ b/gtk/genmarshal.pl @@ -45,7 +45,6 @@ print OH <<EOT; #ifdef __cplusplus extern "C" { -#pragma } #endif /* __cplusplus */ #define gtk_signal_default_marshaller gtk_marshal_NONE__NONE @@ -46,6 +46,7 @@ #include <gtk/gtkdialog.h> #include <gtk/gtkdnd.h> #include <gtk/gtkdrawingarea.h> +#include <gtk/gtkdrawwindow.h> #include <gtk/gtkeditable.h> #include <gtk/gtkentry.h> #include <gtk/gtkenums.h> @@ -105,6 +106,7 @@ #include <gtk/gtktable.h> #include <gtk/gtktearoffmenuitem.h> #include <gtk/gtktext.h> +#include <gtk/gtkthemes.h> #include <gtk/gtktipsquery.h> #include <gtk/gtktogglebutton.h> #include <gtk/gtktoolbar.h> diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c index 566b5ecc09..e70f649368 100644 --- a/gtk/gtkarrow.c +++ b/gtk/gtkarrow.c @@ -172,14 +172,7 @@ gtk_arrow_set (GtkArrow *arrow, arrow->shadow_type = shadow_type; if (GTK_WIDGET_DRAWABLE (arrow)) - { - gdk_window_clear_area (GTK_WIDGET (arrow)->window, - GTK_WIDGET (arrow)->allocation.x, - GTK_WIDGET (arrow)->allocation.y, - GTK_WIDGET (arrow)->allocation.width, - GTK_WIDGET (arrow)->allocation.height); - gtk_widget_queue_draw (GTK_WIDGET (arrow)); - } + gtk_widget_queue_clear (GTK_WIDGET (arrow)); } } @@ -227,9 +220,11 @@ gtk_arrow_expose (GtkWidget *widget, shadow_type = GTK_SHADOW_ETCHED_IN; } - gtk_draw_arrow (widget->style, widget->window, - widget->state, shadow_type, arrow->arrow_type, TRUE, - x, y, extent, extent); + gtk_paint_arrow (widget->style, widget->window, + widget->state, shadow_type, + &event->area, widget, "arrow", + arrow->arrow_type, TRUE, + x, y, extent, extent); } return TRUE; diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c index fe6c76a0f8..2472e8b2aa 100644 --- a/gtk/gtkaspectframe.c +++ b/gtk/gtkaspectframe.c @@ -135,11 +135,7 @@ gtk_aspect_frame_set (GtkAspectFrame *aspect_frame, aspect_frame->obey_child = obey_child; if (GTK_WIDGET_DRAWABLE(widget)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); gtk_widget_queue_resize (widget); } @@ -152,7 +148,7 @@ gtk_aspect_frame_paint (GtkWidget *widget, GtkFrame *frame; gint height_extra; gint label_area_width; - gint x, y; + gint x, y, x2, y2; GtkAllocation *allocation; g_return_if_fail (widget != NULL); @@ -170,32 +166,40 @@ gtk_aspect_frame_paint (GtkWidget *widget, x = GTK_CONTAINER (frame)->border_width; y = GTK_CONTAINER (frame)->border_width; - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, frame->shadow_type, - allocation->x + x, - allocation->y + y + height_extra / 2, - allocation->width - x * 2, - allocation->height - y * 2 - height_extra / 2); - if (frame->label) { label_area_width = (allocation->width + GTK_CONTAINER (frame)->border_width * 2 - widget->style->klass->xthickness * 2); - x = ((label_area_width - frame->label_width) * frame->label_xalign + - GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); - y = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); - - gdk_window_clear_area (widget->window, - allocation->x + x + 2, - allocation->y + GTK_CONTAINER (frame)->border_width, - frame->label_width - 4, frame->label_height); - gtk_draw_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), - allocation->x + x + 3, - allocation->y + y, - frame->label); + x2 = ((label_area_width - frame->label_width) * frame->label_xalign + + GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); + y2 = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); + + gtk_paint_shadow_gap (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + allocation->x + x, + allocation->y + y + height_extra / 2, + allocation->width - x * 2, + allocation->height - y * 2 - height_extra / 2, + GTK_POS_TOP, + x2 + 2 - x, frame->label_width - 4); + + gtk_paint_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), + area, widget, "frame", + allocation->x + x2 + 3, + allocation->y + y2, + frame->label); } + else + gtk_paint_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + allocation->x + x, + allocation->y + y + height_extra / 2, + allocation->width - x * 2, + allocation->height - y * 2 - height_extra / 2); } } diff --git a/gtk/gtkbin.c b/gtk/gtkbin.c index 6362eb53de..e3bdab1fcc 100644 --- a/gtk/gtkbin.c +++ b/gtk/gtkbin.c @@ -142,11 +142,7 @@ gtk_bin_unmap (GtkWidget *widget) bin = GTK_BIN (widget); if (GTK_WIDGET_NO_WINDOW (widget)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); else gdk_window_hide (widget->window); diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 652c735aa7..c092c0bb00 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -638,20 +638,20 @@ gtk_box_draw (GtkWidget *widget, GtkBoxChild *child; GdkRectangle child_area; GList *children; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_BOX (widget)); - + if (GTK_WIDGET_DRAWABLE (widget)) { box = GTK_BOX (widget); - + children = box->children; while (children) { child = children->data; children = children->next; - + if (gtk_widget_intersect (child->widget, area, &child_area)) gtk_widget_draw (child->widget, &child_area); } diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 1ebc69b27f..7ea658af2c 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -507,146 +507,32 @@ static void gtk_button_paint (GtkWidget *widget, GdkRectangle *area) { - GdkRectangle restrict_area; - GdkRectangle outer_area; - GdkRectangle tmp_area; - GdkRectangle new_area; - gint xthickness; - gint ythickness; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_BUTTON (widget)); - - xthickness = widget->style->klass->xthickness; - ythickness = widget->style->klass->ythickness; - - if (GTK_WIDGET_DRAWABLE (widget)) - { - restrict_area.x = xthickness; - restrict_area.y = ythickness; - restrict_area.width = GTK_WIDGET (widget)->allocation.width - - restrict_area.x * 2 - GTK_CONTAINER (widget)->border_width * 2; - restrict_area.height = GTK_WIDGET (widget)->allocation.height - - restrict_area.y * 2 - GTK_CONTAINER (widget)->border_width * 2; - - outer_area = restrict_area; - - if (GTK_WIDGET_CAN_DEFAULT (widget)) - { - restrict_area.x += DEFAULT_LEFT_POS; - restrict_area.y += DEFAULT_TOP_POS; - restrict_area.width -= DEFAULT_SPACING; - restrict_area.height -= DEFAULT_SPACING; - } - - if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) - { - if ((GTK_WIDGET_STATE (widget) == GTK_STATE_PRELIGHT) && - (GTK_BUTTON (widget)->relief != GTK_RELIEF_NORMAL)) - gtk_style_set_background (widget->style, widget->window, - GTK_BUTTON (widget)->relief == GTK_RELIEF_NONE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget)); - else - gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (widget)); - gdk_window_clear_area (widget->window, - new_area.x, new_area.y, - new_area.width, new_area.height); - } - - if (GTK_WIDGET_CAN_DEFAULT (widget)) - { - /* Now fill spacing area between the default border and the button */ - - /* 1 */ tmp_area = outer_area; - tmp_area.width = restrict_area.x - outer_area.x; - if (gdk_rectangle_intersect (area, &tmp_area, &new_area)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - new_area.x, new_area.y, - new_area.width, new_area.height); - - /* 2 */ tmp_area.x = restrict_area.x + restrict_area.width; - - if (gdk_rectangle_intersect (area, &tmp_area, &new_area)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - new_area.x, new_area.y, - new_area.width, new_area.height); - - /* 3 */ tmp_area.width = restrict_area.width; - tmp_area.height = restrict_area.y - outer_area.y; - tmp_area.x = restrict_area.x; - - if (gdk_rectangle_intersect (area, &tmp_area, &new_area)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - new_area.x, new_area.y, - new_area.width, new_area.height); - - /* 4 */ tmp_area.y = restrict_area.y + restrict_area.height; - - if (gdk_rectangle_intersect (area, &tmp_area, &new_area)) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - new_area.x, new_area.y, - new_area.width, new_area.height); - } - } -} - -static void -gtk_button_draw (GtkWidget *widget, - GdkRectangle *area) -{ - GtkButton *button; - GdkRectangle child_area; - GdkRectangle tmp_area; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_BUTTON (widget)); - g_return_if_fail (area != NULL); - - if (GTK_WIDGET_DRAWABLE (widget)) - { - button = GTK_BUTTON (widget); - - tmp_area = *area; - tmp_area.x -= GTK_CONTAINER (button)->border_width; - tmp_area.y -= GTK_CONTAINER (button)->border_width; - - gtk_button_paint (widget, &tmp_area); - - if (GTK_BIN (button)->child && gtk_widget_intersect (GTK_BIN (button)->child, &tmp_area, &child_area)) - gtk_widget_draw (GTK_BIN (button)->child, &child_area); - - gtk_widget_draw_default (widget); - gtk_widget_draw_focus (widget); - } -} - -static void -gtk_button_draw_focus (GtkWidget *widget) -{ GtkButton *button; GtkShadowType shadow_type; gint width, height; gint x, y; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_BUTTON (widget)); - + if (GTK_WIDGET_DRAWABLE (widget)) { button = GTK_BUTTON (widget); - + x = 0; y = 0; width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + if (GTK_WIDGET_HAS_DEFAULT (widget) && + GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) + { + gtk_paint_box (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + area, widget, "buttondefault", + x, y, width, height); + } + if (GTK_WIDGET_CAN_DEFAULT (widget)) { x += widget->style->klass->xthickness; @@ -656,7 +542,7 @@ gtk_button_draw_focus (GtkWidget *widget) x += DEFAULT_LEFT_POS; y += DEFAULT_TOP_POS; } - + if (GTK_WIDGET_HAS_FOCUS (widget)) { x += 1; @@ -664,84 +550,73 @@ gtk_button_draw_focus (GtkWidget *widget) width -= 2; height -= 2; } - else - { - if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE, - x + 1, y + 1, width - 4, height - 4); - else if (button->relief == GTK_RELIEF_NORMAL) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE, - x + 2, y + 2, width - 5, height - 5); - else - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE, - x, y, width - 1, height - 1); - } - + if (GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - if ((button->relief == GTK_RELIEF_NORMAL) || - ((GTK_WIDGET_STATE (widget) != GTK_STATE_NORMAL) && - (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE))) - { - gtk_draw_shadow (widget->style, widget->window, - button->relief == GTK_RELIEF_NONE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget), - shadow_type, - x, y, width, height); - } - + if ((button->relief != GTK_RELIEF_NONE) || + ((GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL) && + (GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))) + gtk_paint_box (widget->style, widget->window, + GTK_WIDGET_STATE (widget), + shadow_type, area, widget, "button", + x, y, width, height); + if (GTK_WIDGET_HAS_FOCUS (widget)) { x -= 1; y -= 1; width += 2; height += 2; - - gdk_draw_rectangle (widget->window, - widget->style->black_gc, FALSE, - x, y, width - 1, height - 1); + + gtk_paint_focus (widget->style, widget->window, + area, widget, "button", + x, y, width - 1, height - 1); } } } static void -gtk_button_draw_default (GtkWidget *widget) +gtk_button_draw (GtkWidget *widget, + GdkRectangle *area) { - gint width, height; - gint x, y; + GtkButton *button; + GdkRectangle child_area; + GdkRectangle tmp_area; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_BUTTON (widget)); + g_return_if_fail (area != NULL); if (GTK_WIDGET_DRAWABLE (widget)) { - x = 0; - y = 0; - width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2; - height = widget->allocation.height - GTK_CONTAINER (widget)->border_width * 2; + button = GTK_BUTTON (widget); - if (GTK_WIDGET_HAS_DEFAULT (widget) && - GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL) - { - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - x, y, width, height); - } - else - { - gdk_draw_rectangle (widget->window, widget->style->bg_gc[GTK_STATE_NORMAL], - FALSE, x, y, width - 1, height - 1); - gdk_draw_rectangle (widget->window, widget->style->bg_gc[GTK_STATE_NORMAL], - FALSE, x + 1, y + 1, width - 3, height - 3); - } + tmp_area = *area; + tmp_area.x -= GTK_CONTAINER (button)->border_width; + tmp_area.y -= GTK_CONTAINER (button)->border_width; + + gtk_button_paint (widget, &tmp_area); + + if (GTK_BIN (button)->child && gtk_widget_intersect (GTK_BIN (button)->child, &tmp_area, &child_area)) + gtk_widget_draw (GTK_BIN (button)->child, &child_area); } } +static void +gtk_button_draw_focus (GtkWidget *widget) +{ + gtk_widget_draw (widget, NULL); +} + +static void +gtk_button_draw_default (GtkWidget *widget) +{ + gtk_widget_draw (widget, NULL); +} + static gint gtk_button_expose (GtkWidget *widget, GdkEventExpose *event) @@ -756,16 +631,13 @@ gtk_button_expose (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { button = GTK_BUTTON (widget); - + gtk_button_paint (widget, &event->area); child_event = *event; if (GTK_BIN (button)->child && GTK_WIDGET_NO_WINDOW (GTK_BIN (button)->child) && gtk_widget_intersect (GTK_BIN (button)->child, &event->area, &child_event.area)) gtk_widget_event (GTK_BIN (button)->child, (GdkEvent*) &child_event); - - gtk_widget_draw_default (widget); - gtk_widget_draw_focus (widget); } return FALSE; diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 8b863a8b80..3560b422d5 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -42,7 +42,6 @@ static void gtk_check_button_draw_indicator (GtkCheckButton *check_but static void gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle *area); - static GtkToggleButtonClass *parent_class = NULL; @@ -84,7 +83,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) widget_class->size_request = gtk_check_button_size_request; widget_class->size_allocate = gtk_check_button_size_allocate; widget_class->expose_event = gtk_check_button_expose; - + class->indicator_size = INDICATOR_SIZE; class->indicator_spacing = INDICATOR_SPACING; class->draw_indicator = gtk_real_check_button_draw_indicator; @@ -93,6 +92,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class) static void gtk_check_button_init (GtkCheckButton *check_button) { + GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW); check_button->toggle_button.draw_indicator = TRUE; } @@ -137,15 +137,23 @@ gtk_check_button_draw (GtkWidget *widget, if (check_button->toggle_button.draw_indicator) { - button = GTK_BUTTON (widget); + gint border_width; + button = GTK_BUTTON (widget); gtk_check_button_draw_indicator (check_button, area); - + + border_width = GTK_CONTAINER (widget)->border_width; + if (GTK_WIDGET_HAS_FOCUS (widget)) + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "checkbutton", + border_width + widget->allocation.x, + border_width + widget->allocation.y, + widget->allocation.width - 2 * border_width - 1, + widget->allocation.height - 2 * border_width - 1); + if (GTK_BIN (button)->child && GTK_WIDGET_NO_WINDOW (GTK_BIN (button)->child) && gtk_widget_intersect (GTK_BIN (button)->child, area, &child_area)) gtk_widget_draw (GTK_BIN (button)->child, &child_area); - - gtk_widget_draw_focus (widget); } else { @@ -158,38 +166,17 @@ gtk_check_button_draw (GtkWidget *widget, static void gtk_check_button_draw_focus (GtkWidget *widget) { - GtkCheckButton *check_button; + gint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); - - if (GTK_WIDGET_DRAWABLE (widget)) - { - check_button = GTK_CHECK_BUTTON (widget); - if (check_button->toggle_button.draw_indicator) - { - gint border_width; - - border_width = GTK_CONTAINER (widget)->border_width; - if (GTK_WIDGET_HAS_FOCUS (widget)) - gdk_draw_rectangle (widget->window, - widget->style->black_gc, FALSE, - border_width, border_width, - widget->allocation.width - 2 * border_width - 1, - widget->allocation.height - 2 * border_width - 1); - else - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_STATE_NORMAL], FALSE, - border_width, border_width, - widget->allocation.width - 2 * border_width - 1, - widget->allocation.height - 2 * border_width - 1); - } - else - { - if (GTK_WIDGET_CLASS (parent_class)->draw_focus) - (* GTK_WIDGET_CLASS (parent_class)->draw_focus) (widget); - } - } + + border_width = GTK_CONTAINER (widget)->border_width; + gtk_widget_queue_clear_area(widget->parent, + border_width + widget->allocation.x, + border_width + widget->allocation.y, + widget->allocation.width - 2 * border_width, + widget->allocation.height - 2 * border_width); } static void @@ -227,19 +214,21 @@ gtk_check_button_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkCheckButton *check_button; + GtkToggleButton *toggle_button; GtkButton *button; GtkAllocation child_allocation; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (widget)); g_return_if_fail (allocation != NULL); check_button = GTK_CHECK_BUTTON (widget); + toggle_button = GTK_TOGGLE_BUTTON (widget); if (check_button->toggle_button.draw_indicator) { widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) - gdk_window_move_resize (widget->window, + gdk_window_move_resize (toggle_button->event_window, allocation->x, allocation->y, allocation->width, allocation->height); @@ -249,11 +238,16 @@ gtk_check_button_size_allocate (GtkWidget *widget, { child_allocation.x = (GTK_CONTAINER (widget)->border_width + CHECK_BUTTON_CLASS (widget)->indicator_size + - CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1); - child_allocation.y = GTK_CONTAINER (widget)->border_width + 1; - child_allocation.width = MAX (1, allocation->width - child_allocation.x - + CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1 + + widget->allocation.x); + child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 + + widget->allocation.y; + child_allocation.width = MAX (1, allocation->width - + (GTK_CONTAINER (widget)->border_width + + CHECK_BUTTON_CLASS (widget)->indicator_size + + CHECK_BUTTON_CLASS (widget)->indicator_spacing * 3 + 1) - GTK_CONTAINER (widget)->border_width - 1); - child_allocation.height = MAX (1, allocation->height - child_allocation.y * 2); + child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2); gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation); } @@ -333,34 +327,43 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle new_area; gint width, height; gint x, y; - + GdkWindow *window; + g_return_if_fail (check_button != NULL); g_return_if_fail (GTK_IS_CHECK_BUTTON (check_button)); + if (GTK_WIDGET_DRAWABLE (check_button)) { widget = GTK_WIDGET (check_button); toggle_button = GTK_TOGGLE_BUTTON (check_button); - state_type = GTK_WIDGET_STATE (widget); + window = widget->window; + if (!window) + return; + + state_type = GTK_WIDGET_STATE (widget); if ((state_type != GTK_STATE_NORMAL) && (state_type != GTK_STATE_PRELIGHT)) state_type = GTK_STATE_NORMAL; - restrict_area.x = GTK_CONTAINER (widget)->border_width; - restrict_area.y = restrict_area.x; - restrict_area.width = widget->allocation.width - restrict_area.x * 2; - restrict_area.height = widget->allocation.height - restrict_area.x * 2; + restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; + restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; + restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width); + restrict_area.height = widget->allocation.height - ( 2 * GTK_CONTAINER (widget)->border_width); if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) { - gtk_style_set_background (widget->style, widget->window, state_type); - gdk_window_clear_area (widget->window, new_area.x, new_area.y, - new_area.width, new_area.height); + if (state_type != GTK_STATE_NORMAL) + gtk_paint_flat_box(widget->style, window, state_type, + GTK_SHADOW_ETCHED_OUT, + area, widget, "checkbutton", + new_area.x, new_area.y, + new_area.width, new_area.height); } - x = CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; - y = (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; + x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; + y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; width = CHECK_BUTTON_CLASS (widget)->indicator_size; height = CHECK_BUTTON_CLASS (widget)->indicator_size; @@ -369,11 +372,10 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, else shadow_type = GTK_SHADOW_OUT; - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, x + 1, y + 1, width, height); - gtk_draw_shadow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - x + 1, y + 1, width, height); + gtk_paint_check (widget->style, window, + GTK_WIDGET_STATE (widget), shadow_type, + area, widget, "checkbutton", + x + 1, y + 1, width, height); } } + diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c index c21050c269..6db3c8040f 100644 --- a/gtk/gtkcheckmenuitem.c +++ b/gtk/gtkcheckmenuitem.c @@ -244,8 +244,6 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, widget->style->klass->xthickness + 2); y = (widget->allocation.height - height) / 2; - gdk_window_clear_area (widget->window, x, y, width, height); - if (check_menu_item->active || check_menu_item->always_show_toggle || (GTK_WIDGET_STATE (check_menu_item) == GTK_STATE_PRELIGHT)) @@ -266,11 +264,9 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, shadow_type = GTK_SHADOW_OUT; } - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[state_type], - TRUE, x, y, width, height); - gtk_draw_shadow (widget->style, widget->window, + gtk_paint_check (widget->style, widget->window, state_type, shadow_type, + area, widget, "check", x, y, width, height); } } diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index c8822743a9..89b253267c 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -21,6 +21,7 @@ #include <math.h> #include <gdk/gdk.h> #include "gtkcolorsel.h" +#include "gtkdrawwindow.h" #include "gtkhbbox.h" #include "gtkdnd.h" #include "gtkselection.h" @@ -861,7 +862,7 @@ gtk_color_selection_drag_begin (GtkWidget *widget, gdouble colors[4]; GdkColor bg; - window = gtk_window_new(GTK_WINDOW_POPUP); + window = gtk_draw_window_new(GTK_WINDOW_POPUP); gtk_widget_set_usize (window, 48, 32); gtk_widget_realize (window); @@ -1041,14 +1042,15 @@ gtk_color_selection_value_events (GtkWidget *area, colorsel = (GtkColorSelection*) gtk_object_get_data (GTK_OBJECT (area), "_GtkColorSelection"); + if (colorsel->value_gc == NULL) + colorsel->value_gc = gdk_gc_new (colorsel->value_area->window); + switch (event->type) { case GDK_MAP: gtk_color_selection_draw_value_marker (colorsel); break; case GDK_EXPOSE: - if (colorsel->value_gc == NULL) - colorsel->value_gc = gdk_gc_new (colorsel->value_area->window); gtk_color_selection_draw_value_marker (colorsel); break; case GDK_BUTTON_PRESS: @@ -1128,7 +1130,14 @@ gtk_color_selection_wheel_events (GtkWidget *area, gint x, y; colorsel = (GtkColorSelection*) gtk_object_get_data (GTK_OBJECT (area), "_GtkColorSelection"); - + + if (colorsel->wheel_gc == NULL) + colorsel->wheel_gc = gdk_gc_new (colorsel->wheel_area->window); + if (colorsel->sample_gc == NULL) + colorsel->sample_gc = gdk_gc_new (colorsel->sample_area->window); + if (colorsel->value_gc == NULL) + colorsel->value_gc = gdk_gc_new (colorsel->value_area->window); + switch (event->type) { case GDK_MAP: @@ -1137,12 +1146,6 @@ gtk_color_selection_wheel_events (GtkWidget *area, gtk_color_selection_draw_sample (colorsel, TRUE); break; case GDK_EXPOSE: - if (colorsel->wheel_gc == NULL) - colorsel->wheel_gc = gdk_gc_new (colorsel->wheel_area->window); - if (colorsel->sample_gc == NULL) - colorsel->sample_gc = gdk_gc_new (colorsel->sample_area->window); - if (colorsel->value_gc == NULL) - colorsel->value_gc = gdk_gc_new (colorsel->value_area->window); gtk_color_selection_draw_wheel_marker (colorsel); gtk_color_selection_draw_wheel_frame (colorsel); break; @@ -1247,7 +1250,7 @@ gtk_color_selection_draw_value_bar (GtkColorSelection *colorsel, v -= sv; } - gtk_widget_draw (colorsel->value_area, NULL); + gtk_widget_queue_draw (colorsel->value_area); } static void @@ -1320,7 +1323,39 @@ gtk_color_selection_draw_wheel (GtkColorSelection *colorsel, gtk_preview_draw_row (GTK_PREVIEW (colorsel->wheel_area), colorsel->wheel_buf, 0, y, wid); } - gtk_widget_draw (colorsel->wheel_area, NULL); + if (colorsel->wheel_area->window) + { + GdkPixmap *pm = NULL; + GdkGC *pmgc = NULL; + GdkColor col; + gint w, h; + + pm = gdk_pixmap_new (colorsel->wheel_area->window, wid, heig, 1); + pmgc = gdk_gc_new (pm); + + col.pixel = 0; + gdk_gc_set_foreground(pmgc, &col); + gdk_draw_rectangle(pm, pmgc, TRUE, 0, 0, wid, heig); + col.pixel = 1; + + gdk_gc_set_foreground(pmgc, &col); + gdk_draw_arc (pm, pmgc, TRUE, 0, 0, wid, heig, 0, 360*64); + + w = colorsel->wheel_area->allocation.width; + h = colorsel->wheel_area->allocation.height; + + gdk_draw_arc (pm, pmgc, + FALSE, 1, 1, w - 1, h - 1, 30 * 64, 180 * 64); + gdk_draw_arc (pm, pmgc, + FALSE, 0, 0, w, h, 30 * 64, 180 * 64); + gdk_draw_arc (pm, pmgc, + FALSE, 1, 1, w - 1, h - 1, 210 * 64, 180 * 64); + gdk_draw_arc (pm, pmgc, + FALSE, 0, 0, w, h, 210 * 64, 180 * 64); + gdk_window_shape_combine_mask(colorsel->wheel_area->window, pm, 0, 0); + gdk_pixmap_unref(pm); + gdk_gc_destroy(pmgc); + } } static void @@ -1385,7 +1420,7 @@ gtk_color_selection_draw_sample (GtkColorSelection *colorsel, gtk_preview_draw_row (GTK_PREVIEW (colorsel->sample_area), colorsel->sample_buf, 0, y, wid); } - gtk_widget_draw (colorsel->sample_area, NULL); + gtk_widget_queue_draw (colorsel->sample_area); } static gint diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c index 80e770115f..e430da3b74 100644 --- a/gtk/gtkcontainer.c +++ b/gtk/gtkcontainer.c @@ -50,6 +50,9 @@ struct _GtkChildArgInfo guint seq_id; }; +/* The global list of toplevel windows */ +static GList *toplevel_list = NULL; + static void gtk_container_base_class_init (GtkContainerClass *klass); static void gtk_container_class_init (GtkContainerClass *klass); static void gtk_container_init (GtkContainer *container); @@ -1235,6 +1238,10 @@ gtk_container_children (GtkContainer *container) void gtk_container_register_toplevel (GtkContainer *container) { + g_return_if_fail (container != NULL); + + toplevel_list = g_list_prepend (toplevel_list, container); + gtk_widget_ref (GTK_WIDGET (container)); gtk_object_sink (GTK_OBJECT (container)); } @@ -1242,9 +1249,28 @@ gtk_container_register_toplevel (GtkContainer *container) void gtk_container_unregister_toplevel (GtkContainer *container) { + GList *node; + + g_return_if_fail (container != NULL); + + node = g_list_find (toplevel_list, container); + g_return_if_fail (node != NULL); + + toplevel_list = g_list_remove_link (toplevel_list, node); + g_list_free_1 (node); + gtk_widget_unref (GTK_WIDGET (container)); } +GList * +gtk_container_get_toplevels (void) +{ + /* XXX: fixme we should ref all these widgets and duplicate + * the list. + */ + return toplevel_list; +} + void gtk_container_real_set_focus_child (GtkContainer *container, GtkWidget *child) diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h index 3e80b4a832..d14955c07b 100644 --- a/gtk/gtkcontainer.h +++ b/gtk/gtkcontainer.h @@ -130,6 +130,8 @@ void gtk_container_set_focus_hadjustment (GtkContainer *container, GtkAdjustment *adjustment); void gtk_container_register_toplevel (GtkContainer *container); void gtk_container_unregister_toplevel (GtkContainer *container); +GList * gtk_container_get_toplevels (void); + void gtk_container_resize_children (GtkContainer *container); GtkType gtk_container_child_type (GtkContainer *container); diff --git a/gtk/gtkcurve.c b/gtk/gtkcurve.c index b867e6b7a1..36442e1303 100644 --- a/gtk/gtkcurve.c +++ b/gtk/gtkcurve.c @@ -239,9 +239,9 @@ gtk_curve_draw (GtkCurve *c, gint width, gint height) style = GTK_WIDGET (c)->style; /* clear the pixmap: */ - gdk_draw_rectangle (c->pixmap, style->bg_gc[state], TRUE, + gtk_paint_flat_box (style, c->pixmap, GTK_STATE_NORMAL, GTK_SHADOW_NONE, + NULL, GTK_WIDGET(c), "curve_bg", 0, 0, width + RADIUS * 2, height + RADIUS * 2); - /* draw the grid lines: (XXX make more meaningful) */ for (i = 0; i < 5; i++) { diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 20063c99b7..151a5c0eb8 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -23,7 +23,7 @@ #include "gtkinvisible.h" #include "gtkmain.h" #include "gtksignal.h" -#include "gtkwindow.h" +#include "gtkdrawwindow.h" static GSList *drag_widgets = NULL; @@ -83,6 +83,7 @@ struct _GtkDragDestSite { GdkDragAction actions; GdkWindow *proxy_window; GdkDragProtocol proxy_protocol; + gboolean do_proxy : 1; gboolean proxy_coords : 1; gboolean have_drag : 1; }; @@ -128,7 +129,7 @@ struct _GtkDragFindData { /* Enumeration for some targets we handle internally */ enum { - TARGET_MOTIF_SUCCESS = 0x80000000, + TARGET_MOTIF_SUCCESS = 0x40000000, TARGET_MOTIF_FAILURE, TARGET_DELETE }; @@ -694,7 +695,7 @@ gtk_drag_dest_set (GtkWidget *widget, site->target_list = NULL; site->actions = actions; - site->proxy_window = NULL; + site->do_proxy = FALSE; gtk_object_set_data_full (GTK_OBJECT (widget), "gtk-drag-dest", site, gtk_drag_dest_site_destroy); @@ -741,7 +742,9 @@ gtk_drag_dest_set_proxy (GtkWidget *widget, site->target_list = NULL; site->actions = 0; site->proxy_window = proxy_window; - gdk_window_ref (proxy_window); + if (proxy_window) + gdk_window_ref (proxy_window); + site->do_proxy = TRUE; site->proxy_protocol = protocol; site->proxy_coords = use_coordinates; @@ -1172,7 +1175,7 @@ gtk_drag_dest_leave (GtkWidget *widget, site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest"); g_return_if_fail (site != NULL); - if (site->proxy_window) + if (site->do_proxy) { GtkDragDestInfo *info = g_dataset_get_data (context, "gtk-info"); @@ -1183,14 +1186,14 @@ gtk_drag_dest_leave (GtkWidget *widget, } else { + if (site->flags & GTK_DEST_DEFAULT_HIGHLIGHT) + gtk_drag_unhighlight (widget); + if (!(site->flags & GTK_DEST_DEFAULT_MOTION) || site->have_drag) gtk_signal_emit_by_name (GTK_OBJECT (widget), "drag_leave", context, time); site->have_drag = FALSE; - - if (site->flags & GTK_DEST_DEFAULT_HIGHLIGHT) - gtk_drag_unhighlight (widget); } } @@ -1208,10 +1211,13 @@ gtk_drag_dest_motion (GtkWidget *widget, site = gtk_object_get_data (GTK_OBJECT (widget), "gtk-drag-dest"); g_return_val_if_fail (site != NULL, FALSE); - if (site->proxy_window) + if (site->do_proxy) { GdkAtom selection; GdkEvent *current_event; + GdkWindow *dest_window; + GdkDragProtocol proto; + GtkDragDestInfo *info = g_dataset_get_data (context, "gtk-info"); if (!info->proxy_source) @@ -1219,9 +1225,22 @@ gtk_drag_dest_motion (GtkWidget *widget, current_event = gtk_get_current_event (); + if (site->proxy_window) + { + dest_window = site->proxy_window; + proto = site->proxy_protocol; + } + else + { + gdk_drag_find_window (info->proxy_source->context, + NULL, + current_event->dnd.x_root, + current_event->dnd.y_root, + &dest_window, &proto); + } + gdk_drag_motion (info->proxy_source->context, - site->proxy_window, - site->proxy_protocol, + dest_window, proto, current_event->dnd.x_root, current_event->dnd.y_root, context->suggested_action, time); @@ -1298,7 +1317,7 @@ gtk_drag_dest_drop (GtkWidget *widget, info->drop_x = x; info->drop_y = y; - if (site->proxy_window) + if (site->do_proxy) { if (info->proxy_source || (info->context->protocol == GDK_DRAG_PROTO_ROOTWIN)) @@ -1313,6 +1332,8 @@ gtk_drag_dest_drop (GtkWidget *widget, GdkEvent *current_event; GdkAtom selection; + GdkWindow *dest_window; + GdkDragProtocol proto; gtk_drag_proxy_begin (widget, info); info->proxy_drop_wait = TRUE; @@ -1320,9 +1341,22 @@ gtk_drag_dest_drop (GtkWidget *widget, current_event = gtk_get_current_event (); + if (site->proxy_window) + { + dest_window = site->proxy_window; + proto = site->proxy_protocol; + } + else + { + gdk_drag_find_window (info->proxy_source->context, + NULL, + current_event->dnd.x_root, + current_event->dnd.y_root, + &dest_window, &proto); + } + gdk_drag_motion (info->proxy_source->context, - site->proxy_window, - site->proxy_protocol, + dest_window, proto, current_event->dnd.x_root, current_event->dnd.y_root, context->suggested_action, time); @@ -1430,7 +1464,7 @@ gtk_drag_begin (GtkWidget *widget, gtk_drag_get_event_action (event, info->button, actions)); gtk_signal_emit_by_name (GTK_OBJECT (widget), "drag_begin", - info->context, NULL); + info->context); /* We use a GTK grab here to override any grabs that the widget * we are dragging from might have held @@ -1499,7 +1533,8 @@ gtk_drag_source_set (GtkWidget *widget, gtk_widget_add_events (widget, gtk_widget_get_events (widget) | - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_MOTION_MASK); + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_MOTION_MASK); if (site) { @@ -1647,7 +1682,7 @@ gtk_drag_set_icon_pixmap (GdkDragContext *context, gtk_widget_push_visual (gdk_colormap_get_visual(colormap)); gtk_widget_push_colormap (colormap); - window = gtk_window_new (GTK_WINDOW_POPUP); + window = gtk_draw_window_new (GTK_WINDOW_POPUP); gtk_widget_pop_visual (); gtk_widget_pop_colormap (); @@ -2007,12 +2042,21 @@ gtk_drag_source_event_cb (GtkWidget *widget, case GDK_BUTTON_PRESS: if ((GDK_BUTTON1_MASK << (event->button.button - 1)) & site->start_button_mask) { + site->state |= (GDK_BUTTON1_MASK << (event->button.button - 1)); site->x = event->button.x; site->y = event->button.y; } + break; + + case GDK_BUTTON_RELEASE: + if ((GDK_BUTTON1_MASK << (event->button.button - 1)) & site->start_button_mask) + { + site->state &= ~(GDK_BUTTON1_MASK << (event->button.button - 1)); + } + break; case GDK_MOTION_NOTIFY: - if (event->motion.state & site->start_button_mask) + if (site->state & event->motion.state & site->start_button_mask) { /* FIXME: This is really broken and can leave us * with a stuck grab @@ -2020,7 +2064,8 @@ gtk_drag_source_event_cb (GtkWidget *widget, int i; for (i=1; i<6; i++) { - if (event->motion.state & GDK_BUTTON1_MASK << (i - 1)) + if (site->state & event->motion.state & + GDK_BUTTON1_MASK << (i - 1)) break; } @@ -2030,6 +2075,7 @@ gtk_drag_source_event_cb (GtkWidget *widget, GtkDragSourceInfo *info; GdkDragContext *context; + site->state = 0; context = gtk_drag_begin (widget, site->target_list, site->actions, i, event); @@ -2054,6 +2100,7 @@ gtk_drag_source_event_cb (GtkWidget *widget, break; default: /* hit for 2/3BUTTON_PRESS */ + break; } return FALSE; } @@ -2183,6 +2230,10 @@ gtk_drag_source_info_destroy (gpointer data) gtk_drag_remove_icon (data); + if (!info->proxy_dest) + gtk_signal_emit_by_name (GTK_OBJECT (info->widget), "drag_end", + info->context); + if (info->widget) gtk_widget_unref (info->widget); diff --git a/gtk/gtkdnd.h b/gtk/gtkdnd.h index 399a0390de..98ca190a35 100644 --- a/gtk/gtkdnd.h +++ b/gtk/gtkdnd.h @@ -26,7 +26,6 @@ #ifdef __cplusplus extern "C" { -#pragma } #endif /* __cplusplus */ typedef enum { diff --git a/gtk/gtkdrawwindow.c b/gtk/gtkdrawwindow.c new file mode 100644 index 0000000000..b8df2a4d56 --- /dev/null +++ b/gtk/gtkdrawwindow.c @@ -0,0 +1,125 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include "gtkdrawwindow.h" + +static void gtk_draw_window_class_init (GtkDrawWindowClass *klass); +static void gtk_draw_window_init (GtkDrawWindow *draw_window); +static void gtk_draw_window_draw (GtkWidget *widget, + GdkRectangle *area); +static gint gtk_draw_window_expose (GtkWidget *widget, + GdkEventExpose *event); + + +GtkType +gtk_draw_window_get_type (void) +{ + static GtkType draw_window_type = 0; + + if (!draw_window_type) + { + GtkTypeInfo draw_window_info = + { + "GtkDrawWindow", + sizeof (GtkDrawWindow), + sizeof (GtkDrawWindowClass), + (GtkClassInitFunc) gtk_draw_window_class_init, + (GtkObjectInitFunc) gtk_draw_window_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + draw_window_type = gtk_type_unique (GTK_TYPE_WINDOW, &draw_window_info); + } + + return draw_window_type; +} + +static void +gtk_draw_window_class_init (GtkDrawWindowClass *class) +{ + GtkWidgetClass *widget_class; + + widget_class = (GtkWidgetClass*) class; + + widget_class->draw = gtk_draw_window_draw; + widget_class->expose_event = gtk_draw_window_expose; +} + +static void +gtk_draw_window_init (GtkDrawWindow *draw_window) +{ +} + +static gint +gtk_draw_window_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + GtkBin *bin; + GdkEventExpose child_event; + + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (GTK_IS_BIN (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + if (GTK_WIDGET_DRAWABLE (widget)) + { + bin = GTK_BIN (widget); + + child_event = *event; + if (bin->child && + GTK_WIDGET_NO_WINDOW (bin->child) && + gtk_widget_intersect (bin->child, &event->area, &child_event.area)) + gtk_widget_event (bin->child, (GdkEvent*) &child_event); + } + + return FALSE; +} + +static void +gtk_draw_window_draw (GtkWidget *widget, + GdkRectangle *area) +{ + GtkBin *bin; + GdkRectangle child_area; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_BIN (widget)); + + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) + { + bin = GTK_BIN (widget); + + if (bin->child && + gtk_widget_intersect (bin->child, area, &child_area)) + gtk_widget_draw (bin->child, &child_area); + } +} + +GtkWidget* +gtk_draw_window_new (GtkWindowType type) +{ + GtkWindow *window; + + window = gtk_type_new (GTK_TYPE_DRAW_WINDOW); + + window->type = type; + + return GTK_WIDGET (window); +} diff --git a/gtk/gtkdrawwindow.h b/gtk/gtkdrawwindow.h new file mode 100644 index 0000000000..20f9f7fe08 --- /dev/null +++ b/gtk/gtkdrawwindow.h @@ -0,0 +1,63 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#ifndef __GTK_DRAW_WINDOW_H__ +#define __GTK_DRAW_WINDOW_H__ + + +#include <gdk/gdk.h> +#include <gtk/gtkwindow.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define GTK_TYPE_DRAW_WINDOW (gtk_draw_window_get_type ()) +#define GTK_DRAW_WINDOW(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_DRAW_WINDOW, GtkDrawWindow)) +#define GTK_DRAW_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_DRAW_WINDOW, GtkDrawWindowClass)) +#define GTK_IS_DRAW_WINDOW(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_DRAW_WINDOW)) +#define GTK_IS_DRAW_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DRAW_WINDOW)) + + +typedef struct _GtkDrawWindow GtkDrawWindow; +typedef struct _GtkDrawWindowClass GtkDrawWindowClass; +typedef struct _GtkDrawWindowButton GtkDrawWindowButton; + + +struct _GtkDrawWindow +{ + GtkWindow window; +}; + +struct _GtkDrawWindowClass +{ + GtkWindowClass parent_class; +}; + + +GtkType gtk_draw_window_get_type (void); +GtkWidget* gtk_draw_window_new (GtkWindowType type); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_DRAW_WINDOW_H__ */ diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 1e9922486a..663485be55 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -27,6 +27,7 @@ #include "gtkmain.h" #include "gtkselection.h" #include "gtksignal.h" +#include "gtkstyle.h" #include "gtkprivate.h" #define MIN_ENTRY_WIDTH 150 @@ -564,8 +565,8 @@ gtk_entry_realize (GtkWidget *widget) widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, entry); - attributes.x = widget->style->klass->xthickness + INNER_BORDER; - attributes.y = widget->style->klass->ythickness + INNER_BORDER; + attributes.x = widget->style->klass->xthickness; + attributes.y = widget->style->klass->ythickness; attributes.width = widget->allocation.width - attributes.x * 2; attributes.height = widget->requisition.height - attributes.y * 2; attributes.cursor = entry->cursor = gdk_cursor_new (GDK_XTERM); @@ -700,22 +701,18 @@ gtk_entry_draw_focus (GtkWidget *widget) width -= 2; height -= 2; } - else - { - gdk_draw_rectangle (widget->window, - widget->style->base_gc[GTK_WIDGET_STATE (widget)], - FALSE, x + 2, y + 2, width - 5, height - 5); - } - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - x, y, width, height); + gtk_paint_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + NULL, widget, "entry", + x, y, width, height); if (GTK_WIDGET_HAS_FOCUS (widget)) { - gdk_window_get_size (widget->window, &width, &height); - gdk_draw_rectangle (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], - FALSE, 0, 0, width - 1, height - 1); + gdk_window_get_size (widget->window, &width, &height); + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "entry", + 0, 0, width - 1, height - 1); } if (GTK_EDITABLE (widget)->editable) @@ -759,10 +756,10 @@ gtk_entry_size_allocate (GtkWidget *widget, allocation->y + (allocation->height - widget->requisition.height) / 2, allocation->width, widget->requisition.height); gdk_window_move_resize (entry->text_area, - widget->style->klass->xthickness + INNER_BORDER, - widget->style->klass->ythickness + INNER_BORDER, - allocation->width - (widget->style->klass->xthickness + INNER_BORDER) * 2, - widget->requisition.height - (widget->style->klass->ythickness + INNER_BORDER) * 2); + widget->style->klass->xthickness, + widget->style->klass->ythickness, + allocation->width - widget->style->klass->xthickness * 2, + widget->requisition.height - widget->style->klass->ythickness * 2); /* And make sure the cursor is on screen */ gtk_entry_adjust_scroll (entry); @@ -1273,7 +1270,11 @@ gtk_entry_draw_text (GtkEntry *entry) if (!entry->text) { - gdk_window_clear (entry->text_area); + gtk_paint_flat_box (widget->style, entry->text_area, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + 0, 0, -1, -1); + if (editable->editable) gtk_entry_draw_cursor (entry); return; @@ -1289,21 +1290,18 @@ gtk_entry_draw_text (GtkEntry *entry) use_backing_pixmap = GTK_WIDGET_HAS_FOCUS (widget) && (entry->text != NULL); if (use_backing_pixmap) { - gtk_entry_make_backing_pixmap (entry, width, height); - drawable = entry->backing_pixmap; - gdk_draw_rectangle (drawable, - widget->style->base_gc[GTK_WIDGET_STATE(widget)], - TRUE, - 0, 0, - width, - height); + gtk_entry_make_backing_pixmap (entry, width, height); + drawable = entry->backing_pixmap; } - else - { - drawable = entry->text_area; - gdk_window_clear (entry->text_area); - } - + else + { + drawable = entry->text_area; + } + gtk_paint_flat_box (widget->style, drawable, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + 0, 0, width, height); + y = (height - (widget->style->font->ascent + widget->style->font->descent)) / 2; y += widget->style->font->ascent; @@ -1358,37 +1356,35 @@ gtk_entry_draw_text (GtkEntry *entry) if (selection_start_pos > start_pos) gdk_draw_text (drawable, widget->style->font, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - start_xoffset, y, + INNER_BORDER + start_xoffset, y, toprint, selection_start_pos - start_pos); if ((selection_end_pos >= start_pos) && (selection_start_pos < end_pos) && (selection_start_pos != selection_end_pos)) - { - gdk_draw_rectangle (drawable, - widget->style->bg_gc[selected_state], - TRUE, - selection_start_xoffset, - 0, - selection_end_xoffset - selection_start_xoffset, - -1); - - gdk_draw_text (drawable, widget->style->font, - widget->style->fg_gc[selected_state], - selection_start_xoffset, y, - toprint + selection_start_pos - start_pos, - selection_end_pos - selection_start_pos); - } - - if (selection_end_pos < end_pos) - gdk_draw_text (drawable, widget->style->font, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - selection_end_xoffset, y, - toprint + selection_end_pos - start_pos, - end_pos - selection_end_pos); - - /* free the space allocated for the stars if it's neccessary. */ + { + gtk_paint_flat_box (widget->style, drawable, + selected_state, GTK_SHADOW_NONE, + NULL, widget, "text", + INNER_BORDER + selection_start_xoffset, + INNER_BORDER, + selection_end_xoffset - selection_start_xoffset, + height - 2*INNER_BORDER); + gdk_draw_text (drawable, widget->style->font, + widget->style->fg_gc[selected_state], + INNER_BORDER + selection_start_xoffset, y, + toprint + selection_start_pos - start_pos, + selection_end_pos - selection_start_pos); + } + + if (selection_end_pos < end_pos) + gdk_draw_text (drawable, widget->style->font, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + INNER_BORDER + selection_end_xoffset, y, + toprint + selection_end_pos - start_pos, + end_pos - selection_end_pos); + /* free the space allocated for the stars if it's neccessary. */ if (!entry->visible) g_free (toprint); @@ -1417,7 +1413,6 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable) { GtkWidget *widget; GtkEditable *editable; - GdkGC *gc; gint xoffset; gint text_area_height; @@ -1429,17 +1424,25 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable) widget = GTK_WIDGET (entry); editable = GTK_EDITABLE (entry); - xoffset = entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)]; + xoffset = INNER_BORDER + entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)]; xoffset -= entry->scroll_offset; + gdk_window_get_size (entry->text_area, NULL, &text_area_height); + if (GTK_WIDGET_HAS_FOCUS (widget) && (editable->selection_start_pos == editable->selection_end_pos)) - gc = widget->style->fg_gc[GTK_STATE_NORMAL]; + { + gdk_draw_line (drawable, widget->style->fg_gc[GTK_STATE_NORMAL], + xoffset, 0, xoffset, text_area_height); + } else - gc = widget->style->base_gc[GTK_WIDGET_STATE(widget)]; + { + gtk_paint_flat_box (widget->style, drawable, + GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, + NULL, widget, "entry_bg", + xoffset, 0, 1, text_area_height); + } - gdk_window_get_size (entry->text_area, NULL, &text_area_height); - gdk_draw_line (drawable, gc, xoffset, 0, xoffset, text_area_height); #ifdef USE_XIM if (gdk_im_ready() && editable->ic && gdk_ic_get_style (editable->ic) & GDK_IM_PREEDIT_POSITION) @@ -2321,7 +2324,7 @@ gtk_entry_style_set (GtkWidget *widget, } if (GTK_WIDGET_DRAWABLE (widget)) - gdk_window_clear (widget->window); + gtk_widget_queue_clear(widget); } static void @@ -2338,5 +2341,5 @@ gtk_entry_state_changed (GtkWidget *widget, } if (GTK_WIDGET_DRAWABLE (widget)) - gdk_window_clear (widget->window); + gtk_widget_queue_clear(widget); } diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 9b88198de1..726a94b2ee 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -346,7 +346,7 @@ gtk_fixed_paint (GtkWidget *widget, g_return_if_fail (area != NULL); if (GTK_WIDGET_DRAWABLE (widget)) - gdk_window_clear_area (widget->window, + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); } diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c index d11a578597..93414fa113 100644 --- a/gtk/gtkframe.c +++ b/gtk/gtkframe.c @@ -242,11 +242,11 @@ gtk_frame_set_label (GtkFrame *frame, /* clear the old label area */ widget = GTK_WIDGET (frame); - gdk_window_clear_area (widget->window, - widget->allocation.x + GTK_CONTAINER (frame)->border_width, - widget->allocation.y + GTK_CONTAINER (frame)->border_width, - widget->allocation.width - GTK_CONTAINER (frame)->border_width, - widget->allocation.y + frame->label_height); + gtk_widget_queue_clear_area (widget, + widget->allocation.x + GTK_CONTAINER (frame)->border_width, + widget->allocation.y + GTK_CONTAINER (frame)->border_width, + widget->allocation.width - GTK_CONTAINER (frame)->border_width, + widget->allocation.y + frame->label_height); } @@ -276,11 +276,11 @@ gtk_frame_set_label_align (GtkFrame *frame, /* clear the old label area */ widget = GTK_WIDGET (frame); - gdk_window_clear_area (widget->window, - widget->allocation.x + GTK_CONTAINER (frame)->border_width, - widget->allocation.y + GTK_CONTAINER (frame)->border_width, - widget->allocation.width - GTK_CONTAINER (frame)->border_width, - widget->allocation.y + frame->label_height); + gtk_widget_queue_clear_area (widget, + widget->allocation.x + GTK_CONTAINER (frame)->border_width, + widget->allocation.y + GTK_CONTAINER (frame)->border_width, + widget->allocation.width - GTK_CONTAINER (frame)->border_width, + widget->allocation.y + frame->label_height); } gtk_widget_queue_resize (GTK_WIDGET (frame)); @@ -300,11 +300,7 @@ gtk_frame_set_shadow_type (GtkFrame *frame, if (GTK_WIDGET_DRAWABLE (frame)) { - gdk_window_clear_area (GTK_WIDGET (frame)->window, - GTK_WIDGET (frame)->allocation.x, - GTK_WIDGET (frame)->allocation.y, - GTK_WIDGET (frame)->allocation.width, - GTK_WIDGET (frame)->allocation.height); + gtk_widget_queue_clear (GTK_WIDGET (frame)); } gtk_widget_queue_resize (GTK_WIDGET (frame)); } @@ -334,7 +330,7 @@ gtk_frame_paint (GtkWidget *widget, GtkFrame *frame; gint height_extra; gint label_area_width; - gint x, y; + gint x, y, x2, y2; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_FRAME (widget)); @@ -350,33 +346,40 @@ gtk_frame_paint (GtkWidget *widget, x = GTK_CONTAINER (frame)->border_width; y = GTK_CONTAINER (frame)->border_width; - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, frame->shadow_type, - widget->allocation.x + x, - widget->allocation.y + y + height_extra / 2, - widget->allocation.width - x * 2, - widget->allocation.height - y * 2 - height_extra / 2); - if (frame->label) { - label_area_width = (widget->allocation.width - - GTK_CONTAINER (frame)->border_width * 2 - - widget->style->klass->xthickness * 2); - - x = ((label_area_width - frame->label_width) * frame->label_xalign + - GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); - y = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); - - gdk_window_clear_area (widget->window, - widget->allocation.x + x + 2, - widget->allocation.y + GTK_CONTAINER (frame)->border_width, - frame->label_width - 4, - frame->label_height); - gtk_draw_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), - widget->allocation.x + x + 3, - widget->allocation.y + y, - frame->label); + label_area_width = (widget->allocation.width - + GTK_CONTAINER (frame)->border_width * 2 - + widget->style->klass->xthickness * 2); + + x2 = ((label_area_width - frame->label_width) * frame->label_xalign + + GTK_CONTAINER (frame)->border_width + widget->style->klass->xthickness); + y2 = (GTK_CONTAINER (frame)->border_width + widget->style->font->ascent); + + gtk_paint_shadow_gap (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + widget->allocation.x + x, + widget->allocation.y + y + height_extra / 2, + widget->allocation.width - x * 2, + widget->allocation.height - y * 2 - height_extra / 2, + GTK_POS_TOP, + x2 + 2 - x, frame->label_width - 4); + + gtk_paint_string (widget->style, widget->window, GTK_WIDGET_STATE (widget), + area, widget, "frame", + widget->allocation.x + x2 + 3, + widget->allocation.y + y2, + frame->label); } + else + gtk_paint_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, frame->shadow_type, + area, widget, "frame", + widget->allocation.x + x, + widget->allocation.y + y + height_extra / 2, + widget->allocation.width - x * 2, + widget->allocation.height - y * 2 - height_extra / 2); } } @@ -488,11 +491,7 @@ gtk_frame_size_allocate (GtkWidget *widget, (widget->allocation.height != allocation->height)) && (widget->allocation.width != 0) && (widget->allocation.height != 0)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); widget->allocation = *allocation; diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index 18f0e32f3d..a4d8bac299 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -308,6 +308,7 @@ gtk_handle_box_realize (GtkWidget *widget) gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (hb)); gtk_style_set_background (widget->style, hb->bin_window, GTK_WIDGET_STATE (hb)); gtk_style_set_background (widget->style, hb->float_window, GTK_WIDGET_STATE (hb)); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static void @@ -567,77 +568,42 @@ gtk_handle_box_draw_ghost (GtkHandleBox *hb) width = widget->allocation.width; height = DRAG_HANDLE_SIZE; } - gtk_draw_shadow (widget->style, - widget->window, - GTK_WIDGET_STATE (widget), - GTK_SHADOW_ETCHED_IN, - x, - y, - width, - height); - /* - if (hb->handle_position == GTK_POS_LEFT || - hb->handle_position == GTK_POS_RIGHT) - gtk_draw_hline (widget->style, - widget->window, - GTK_WIDGET_STATE (widget), - hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : widget->allocation.width - DRAG_HANDLE_SIZE, - widget->allocation.width - DRAG_HANDLE_SIZE, - widget->allocation.height / 2); - else - gtk_draw_vline (widget->style, + gtk_paint_shadow (widget->style, widget->window, GTK_WIDGET_STATE (widget), - hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : widget->allocation.height - DRAG_HANDLE_SIZE, - widget->allocation.height - DRAG_HANDLE_SIZE, - widget->allocation.width / 2); - */ + GTK_SHADOW_ETCHED_IN, + NULL, widget, "handle", + x, + y, + width, + height); + if (hb->handle_position == GTK_POS_LEFT || + hb->handle_position == GTK_POS_RIGHT) + gtk_paint_hline (widget->style, + widget->window, + GTK_WIDGET_STATE (widget), + NULL, widget, "handlebox", + hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : widget->allocation.width - DRAG_HANDLE_SIZE, + widget->allocation.width - DRAG_HANDLE_SIZE, + widget->allocation.height / 2); + else + gtk_paint_vline (widget->style, + widget->window, + GTK_WIDGET_STATE (widget), + NULL, widget, "handlebox", + hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : widget->allocation.height - DRAG_HANDLE_SIZE, + widget->allocation.height - DRAG_HANDLE_SIZE, + widget->allocation.width / 2); } static void draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow, GdkRectangle *clip) { - int x, y; - int xthick, ythick; - GdkGC *light_gc, *dark_gc; - GdkRectangle dest; - - if (gdk_rectangle_intersect (rect, clip, &dest)) - { - gdk_draw_rectangle (window, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, - dest.x, dest.y, - dest.width, dest.height); - - light_gc = widget->style->light_gc[GTK_STATE_NORMAL]; - dark_gc = widget->style->dark_gc[GTK_STATE_NORMAL]; - - xthick = widget->style->klass->xthickness; - ythick = widget->style->klass->ythickness; - - gdk_gc_set_clip_rectangle (light_gc, &dest); - gdk_gc_set_clip_rectangle (dark_gc, &dest); - - for (y = rect->y + ythick; y < (rect->y + rect->height - ythick); y += 3) - for (x = rect->x + xthick; x < (rect->x + rect->width - xthick); x += 6) - { - gdk_draw_point (window, light_gc, x, y); - gdk_draw_point (window, dark_gc, x + 1, y + 1); - - gdk_draw_point (window, light_gc, x + 3, y + 1); - gdk_draw_point (window, dark_gc, x + 4, y + 2); - } - - gdk_gc_set_clip_rectangle (light_gc, NULL); - gdk_gc_set_clip_rectangle (dark_gc, NULL); - - gtk_draw_shadow (widget->style, window, - GTK_STATE_NORMAL, shadow, - rect->x, rect->y, - rect->width, rect->height); - } + gtk_paint_handle(widget->style, window, GTK_STATE_NORMAL, shadow, + NULL, widget, "handlebox", + rect->x, rect->y, rect->width, rect->height, + GTK_ORIENTATION_VERTICAL); } static void @@ -673,22 +639,29 @@ gtk_handle_box_paint (GtkWidget *widget, width = widget->allocation.width; height = widget->allocation.height - DRAG_HANDLE_SIZE; } - + if (!event) - gdk_window_clear_area (hb->bin_window, - area->x, - area->y, - area->width, - area->height); - - gtk_draw_shadow (widget->style, - hb->bin_window, - GTK_WIDGET_STATE (widget), - GTK_SHADOW_OUT, - hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0, - hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0, - width, - height); + gtk_paint_box(widget->style, + hb->bin_window, + GTK_WIDGET_STATE (widget), + GTK_SHADOW_OUT, + area, widget, "handlebox_bin", + 0, 0, -1, -1); + else + gtk_paint_box(widget->style, + hb->bin_window, + GTK_WIDGET_STATE (widget), + GTK_SHADOW_OUT, + &event->area, widget, "handlebox_bin", + 0, 0, -1, -1); + +/* We currently draw the handle _above_ the relief of the handlebox. + * it could also be drawn on the same level... + + hb->handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0, + hb->handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0, + width, + height);*/ rect.x = 0; rect.y = 0; diff --git a/gtk/gtkhpaned.c b/gtk/gtkhpaned.c index e828de2b3a..4312575f82 100644 --- a/gtk/gtkhpaned.c +++ b/gtk/gtkhpaned.c @@ -229,6 +229,8 @@ gtk_hpaned_draw (GtkWidget *widget, paned = GTK_PANED (widget); border_width = GTK_CONTAINER (paned)->border_width; + gdk_window_clear_area (widget->window, + area->x, area->y, area->width, area->height); if (paned->child1 && gtk_widget_intersect (paned->child1, area, &child_area)) gtk_widget_draw (paned->child1, &child_area); @@ -236,18 +238,10 @@ gtk_hpaned_draw (GtkWidget *widget, gtk_widget_intersect (paned->child2, area, &child_area)) gtk_widget_draw (paned->child2, &child_area); - gdk_draw_line (widget->window, - widget->style->dark_gc[widget->state], - border_width + paned->child1_size + paned->gutter_size / 2 - 1, - 0, - border_width + paned->child1_size + paned->gutter_size / 2 - 1, - widget->allocation.height - 1); - gdk_draw_line (widget->window, - widget->style->light_gc[widget->state], - border_width + paned->child1_size + paned->gutter_size / 2, - 0, - border_width + paned->child1_size + paned->gutter_size / 2, - widget->allocation.height - 1); + gtk_paint_vline(widget->style, widget->window, GTK_STATE_NORMAL, + area, widget, "hpaned", + 0, widget->allocation.height - 1, + border_width + paned->child1_size + paned->gutter_size / 2 - 1); } } diff --git a/gtk/gtkhruler.c b/gtk/gtkhruler.c index 0a8b6307c5..40af247119 100644 --- a/gtk/gtkhruler.c +++ b/gtk/gtkhruler.c @@ -162,7 +162,15 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) width = widget->allocation.width; height = widget->allocation.height - ythickness * 2; - gdk_draw_line (ruler->backing_store, gc, + + gtk_paint_box (widget->style, ruler->backing_store, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "hruler", + 0, 0, + widget->allocation.width, widget->allocation.height); + + + gdk_draw_line (ruler->backing_store, gc, xthickness, height + ythickness, widget->allocation.width - xthickness, @@ -231,11 +239,6 @@ gtk_hruler_draw_ticks (GtkRuler *ruler) if (i == 0) { sprintf (unit_str, "%d", (int) cur); - gdk_draw_rectangle (ruler->backing_store, - bg_gc, TRUE, - pos + 1, ythickness, - gdk_string_width(font, unit_str) + 1, - digit_height); gdk_draw_string (ruler->backing_store, font, gc, pos + 2, ythickness + font->ascent - 1, unit_str); diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 96ec889415..e4559fb12c 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -38,12 +38,20 @@ static void gtk_hscale_pos_trough (GtkHScale *hscale, gint *y, gint *w, gint *h); +static void gtk_hscale_pos_background (GtkHScale *hscale, + gint *x, + gint *y, + gint *w, + gint *h); static void gtk_hscale_draw_slider (GtkRange *range); static void gtk_hscale_draw_value (GtkScale *scale); +static void gtk_hscale_draw (GtkWidget *widget, + GdkRectangle *area); static gint gtk_hscale_trough_keys (GtkRange *range, GdkEventKey *key, GtkScrollType *scroll, GtkTroughType *pos); +static void gtk_hscale_clear_background (GtkRange *range); guint gtk_hscale_get_type (void) @@ -84,12 +92,14 @@ gtk_hscale_class_init (GtkHScaleClass *class) widget_class->realize = gtk_hscale_realize; widget_class->size_request = gtk_hscale_size_request; widget_class->size_allocate = gtk_hscale_size_allocate; + widget_class->draw = gtk_hscale_draw; range_class->slider_update = gtk_range_default_hslider_update; range_class->trough_click = gtk_range_default_htrough_click; range_class->motion = gtk_range_default_hmotion; range_class->draw_slider = gtk_hscale_draw_slider; range_class->trough_keys = gtk_hscale_trough_keys; + range_class->clear_background = gtk_hscale_clear_background; scale_class->draw_value = gtk_hscale_draw_value; } @@ -97,6 +107,7 @@ gtk_hscale_class_init (GtkHScaleClass *class) static void gtk_hscale_init (GtkHScale *hscale) { + GTK_WIDGET_SET_FLAGS (hscale, GTK_NO_WINDOW); } GtkWidget* @@ -129,28 +140,27 @@ gtk_hscale_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); range = GTK_RANGE (widget); - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; + widget->window = gtk_widget_get_parent_window (widget); + gdk_window_ref (widget->window); + + gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &w, &h); + attributes.x = x + widget->allocation.x; + attributes.y = y + widget->allocation.y; + attributes.width = w; + attributes.height = h; attributes.wclass = GDK_INPUT_OUTPUT; attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; + + attributes.event_mask = gtk_widget_get_events (widget) | + (GDK_EXPOSURE_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_ENTER_NOTIFY_MASK | + GDK_LEAVE_NOTIFY_MASK); attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); - - gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &w, &h); - attributes.x = x; - attributes.y = y; - attributes.width = w; - attributes.height = h; - attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK); range->trough = gdk_window_new (widget->window, &attributes, attributes_mask); @@ -163,18 +173,75 @@ gtk_hscale_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); - gdk_window_set_user_data (widget->window, widget); gdk_window_set_user_data (range->trough, widget); gdk_window_set_user_data (range->slider, widget); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE); gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL); gtk_range_slider_update (GTK_RANGE (widget)); gdk_window_show (range->slider); - gdk_window_show (range->trough); +} + +static void +gtk_hscale_draw (GtkWidget *widget, + GdkRectangle *area) +{ + GtkRange *range; + GdkRectangle tmp_area; + GdkRectangle child_area; + gint x, y, width, height; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_RANGE (widget)); + g_return_if_fail (area != NULL); + + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) + { + range = GTK_RANGE (widget); + + gtk_hscale_pos_background (GTK_HSCALE (widget), &x, &y, &width, &height); + + tmp_area.x = x; + tmp_area.y = y; + tmp_area.width = width; + tmp_area.height = height; + + if (gdk_rectangle_intersect (area, &tmp_area, &child_area)) + gtk_range_draw_background (range); + + gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &width, &height); + + tmp_area.x = x; + tmp_area.y = y; + tmp_area.width = width; + tmp_area.height = height; + + if (gdk_rectangle_intersect (area, &tmp_area, &child_area)) + { + gtk_range_draw_trough (range); + gtk_range_draw_slider (range); + gtk_range_draw_step_forw (range); + gtk_range_draw_step_back (range); + } + } +} + +static void +gtk_hscale_clear_background (GtkRange *range) +{ + GtkWidget *widget; + gint x, y, width, height; + + g_return_if_fail (range != NULL); + + widget = GTK_WIDGET (range); + + gtk_hscale_pos_background (GTK_HSCALE (range), &x, &y, &width, &height); + + gtk_widget_queue_clear_area (GTK_WIDGET (range), + x, y, width, height); } static void @@ -235,13 +302,11 @@ gtk_hscale_size_allocate (GtkWidget *widget, range = GTK_RANGE (widget); scale = GTK_SCALE (widget); - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); - gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &width, &height); - gdk_window_move_resize (range->trough, x, y, width, height); + gdk_window_move_resize (range->trough, + x + widget->allocation.x, + y + widget->allocation.y, width, height); gtk_range_slider_update (GTK_RANGE (widget)); } } @@ -302,10 +367,54 @@ gtk_hscale_pos_trough (GtkHScale *hscale, } static void +gtk_hscale_pos_background (GtkHScale *hscale, + gint *x, + gint *y, + gint *w, + gint *h) +{ + GtkWidget *widget; + GtkScale *scale; + + gint tx, ty, twidth, theight; + + g_return_if_fail (hscale != NULL); + g_return_if_fail (GTK_IS_HSCALE (hscale)); + g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL)); + + gtk_hscale_pos_trough (hscale, &tx, &ty, &twidth, &theight); + + widget = GTK_WIDGET (hscale); + scale = GTK_SCALE (hscale); + + *x = widget->allocation.x; + *y = widget->allocation.y; + *w = widget->allocation.width; + *h = widget->allocation.height; + + switch (scale->value_pos) + { + case GTK_POS_LEFT: + *w -= twidth; + break; + case GTK_POS_RIGHT: + *x = tx; + *w -= twidth; + break; + case GTK_POS_TOP: + *h -= theight; + break; + case GTK_POS_BOTTOM: + *y = ty; + *h -= theight; + break; + } +} + +static void gtk_hscale_draw_slider (GtkRange *range) { GtkStateType state_type; - gint width, height; g_return_if_fail (range != NULL); g_return_if_fail (GTK_IS_HSCALE (range)); @@ -318,16 +427,11 @@ gtk_hscale_draw_slider (GtkRange *range) else state_type = GTK_STATE_NORMAL; - gtk_style_set_background (GTK_WIDGET (range)->style, range->slider, state_type); - gdk_window_clear (range->slider); - - gdk_window_get_size (range->slider, &width, &height); - gtk_draw_vline (GTK_WIDGET (range)->style, range->slider, - state_type, 1, height - 2, width / 2); - - gtk_draw_shadow (GTK_WIDGET (range)->style, range->slider, - state_type, GTK_SHADOW_OUT, - 0, 0, -1, -1); + gtk_paint_slider(GTK_WIDGET (range)->style, range->slider, state_type, + GTK_SHADOW_OUT, + NULL, GTK_WIDGET (range), "hscale", + 0, 0, -1, -1, + GTK_ORIENTATION_HORIZONTAL); } } @@ -335,6 +439,7 @@ static void gtk_hscale_draw_value (GtkScale *scale) { GtkStateType state_type; + GtkWidget *widget; gchar buffer[32]; gint text_width; gint width, height; @@ -343,11 +448,10 @@ gtk_hscale_draw_value (GtkScale *scale) g_return_if_fail (scale != NULL); g_return_if_fail (GTK_IS_HSCALE (scale)); + widget = GTK_WIDGET (scale); + if (scale->draw_value) { - gdk_window_get_size (GTK_WIDGET (scale)->window, &width, &height); - gdk_window_clear_area (GTK_WIDGET (scale)->window, 1, 1, width - 2, height - 2); - sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); text_width = gdk_string_measure (GTK_WIDGET (scale)->style->font, buffer); @@ -379,7 +483,7 @@ gtk_hscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL); gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height); - x += (width - text_width) / 2; + x += widget->allocation.x + (width - text_width) / 2; y -= GTK_WIDGET (scale)->style->font->descent; break; case GTK_POS_BOTTOM: @@ -388,7 +492,7 @@ gtk_hscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL); gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height); - x += (width - text_width) / 2; + x += widget->allocation.x + (width - text_width) / 2; y += height + GTK_WIDGET (scale)->style->font->ascent; break; } @@ -397,9 +501,11 @@ gtk_hscale_draw_value (GtkScale *scale) if (!GTK_WIDGET_IS_SENSITIVE (scale)) state_type = GTK_STATE_INSENSITIVE; - gtk_draw_string (GTK_WIDGET (scale)->style, - GTK_WIDGET (scale)->window, - state_type, x, y, buffer); + gtk_paint_string (GTK_WIDGET (scale)->style, + GTK_WIDGET (scale)->window, + state_type, + NULL, GTK_WIDGET (scale), "hscale", + x, y, buffer); } } diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index c8c1bbc9b5..7b38db6486 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -259,9 +259,11 @@ gtk_hscrollbar_draw_step_forw (GtkRange *range) else shadow_type = GTK_SHADOW_OUT; - gtk_draw_arrow (GTK_WIDGET (range)->style, range->step_forw, - state_type, shadow_type, GTK_ARROW_RIGHT, - TRUE, 0, 0, -1, -1); + gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_forw, + state_type, shadow_type, + NULL, GTK_WIDGET (range), "hscrollbar", + GTK_ARROW_RIGHT, + TRUE, 0, 0, -1, -1); } } @@ -291,9 +293,11 @@ gtk_hscrollbar_draw_step_back (GtkRange *range) else shadow_type = GTK_SHADOW_OUT; - gtk_draw_arrow (GTK_WIDGET (range)->style, range->step_back, - state_type, shadow_type, GTK_ARROW_LEFT, - TRUE, 0, 0, -1, -1); + gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_back, + state_type, shadow_type, + NULL, GTK_WIDGET (range), "hscrollbar", + GTK_ARROW_LEFT, + TRUE, 0, 0, -1, -1); } } diff --git a/gtk/gtkhseparator.c b/gtk/gtkhseparator.c index 88cd4642f9..16b5908a27 100644 --- a/gtk/gtkhseparator.c +++ b/gtk/gtkhseparator.c @@ -83,11 +83,12 @@ gtk_hseparator_expose (GtkWidget *widget, g_return_val_if_fail (event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE (widget)) - gtk_draw_hline (widget->style, widget->window, GTK_STATE_NORMAL, - widget->allocation.x, - widget->allocation.x + widget->allocation.width, - widget->allocation.y + (widget->allocation.height - - widget->style->klass->ythickness) / 2); + gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, + &event->area, widget, "hseparator", + widget->allocation.x, + widget->allocation.x + widget->allocation.width, + widget->allocation.y + (widget->allocation.height - + widget->style->klass->ythickness) / 2); return FALSE; } diff --git a/gtk/gtkinvisible.h b/gtk/gtkinvisible.h index 9abb9ba0f5..0cbe8d1354 100644 --- a/gtk/gtkinvisible.h +++ b/gtk/gtkinvisible.h @@ -26,7 +26,6 @@ #ifdef __cplusplus extern "C" { -#pragma } #endif /* __cplusplus */ diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c index 825614d0b4..9613263442 100644 --- a/gtk/gtkitem.c +++ b/gtk/gtkitem.c @@ -201,6 +201,7 @@ gtk_item_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static gint diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 3c920cd2bc..18a167712e 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -51,12 +51,7 @@ static void gtk_label_size_request (GtkWidget *widget, GtkRequisition *requisition); static gint gtk_label_expose (GtkWidget *widget, GdkEventExpose *event); -static void gtk_label_state_changed (GtkWidget *widget, - guint previous_state); -static void gtk_label_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static void gtk_label_free_rows (GtkLabel *label); - +static void gtk_label_free_rows (GtkLabel *label); static GtkMiscClass *parent_class = NULL; @@ -109,8 +104,6 @@ gtk_label_class_init (GtkLabelClass *class) widget_class->size_request = gtk_label_size_request; widget_class->expose_event = gtk_label_expose; - widget_class->style_set = gtk_label_style_set; - widget_class->state_changed = gtk_label_state_changed; } static void @@ -173,7 +166,6 @@ gtk_label_init (GtkLabel *label) label->row = NULL; label->max_width = 0; label->jtype = GTK_JUSTIFY_CENTER; - label->needs_clear = FALSE; label->pattern = NULL; gtk_label_set (label, ""); @@ -233,12 +225,8 @@ gtk_label_set (GtkLabel *label, if (GTK_WIDGET_VISIBLE (label)) { if (GTK_WIDGET_MAPPED (label)) - gdk_window_clear_area (GTK_WIDGET (label)->window, - GTK_WIDGET (label)->allocation.x, - GTK_WIDGET (label)->allocation.y, - GTK_WIDGET (label)->allocation.width, - GTK_WIDGET (label)->allocation.height); - + gtk_widget_queue_clear (GTK_WIDGET (label)); + gtk_widget_queue_resize (GTK_WIDGET (label)); } } @@ -257,11 +245,7 @@ gtk_label_set_pattern (GtkLabel *label, if (GTK_WIDGET_VISIBLE (label)) { if (GTK_WIDGET_MAPPED (label)) - gdk_window_clear_area (GTK_WIDGET (label)->window, - GTK_WIDGET (label)->allocation.x, - GTK_WIDGET (label)->allocation.y, - GTK_WIDGET (label)->allocation.width, - GTK_WIDGET (label)->allocation.height); + gtk_widget_queue_clear (GTK_WIDGET (label)); gtk_widget_queue_resize (GTK_WIDGET (label)); } @@ -281,12 +265,8 @@ gtk_label_set_justify (GtkLabel *label, if (GTK_WIDGET_VISIBLE (label)) { if (GTK_WIDGET_MAPPED (label)) - gdk_window_clear_area (GTK_WIDGET (label)->window, - GTK_WIDGET (label)->allocation.x, - GTK_WIDGET (label)->allocation.y, - GTK_WIDGET (label)->allocation.width, - GTK_WIDGET (label)->allocation.height); - + gtk_widget_queue_clear (GTK_WIDGET (label)); + gtk_widget_queue_resize (GTK_WIDGET (label)); } } @@ -322,10 +302,11 @@ gtk_label_finalize (GtkObject *object) } static gint -gtk_label_process_row (GtkLabel *label, - GtkLabelRow *row, - gint x, gint y, - gboolean draw) +gtk_label_process_row (GtkLabel *label, + GtkLabelRow *row, + gint x, gint y, + gboolean draw, + GdkRectangle *area) { GtkWidget *widget = GTK_WIDGET (label); @@ -382,16 +363,12 @@ gtk_label_process_row (GtkLabel *label, if (draw) { - if (widget->state == GTK_STATE_INSENSITIVE) - gdk_draw_line (widget->window, - widget->style->white_gc, - offset + x + lbearing, y + descent + 2, - offset + x + rbearing + 1, y + descent + 2); - - gdk_draw_line (widget->window, - widget->style->fg_gc[widget->state], - offset + x + lbearing - 1, y + descent + 1, - offset + x + rbearing, y + descent + 1); + gtk_paint_hline (widget->style, widget->window, + widget->state, area, + widget, "label", + offset + x + lbearing - 1, + offset + x + rbearing, + y + descent + 2); } height = MAX (height, @@ -406,16 +383,12 @@ gtk_label_process_row (GtkLabel *label, if (draw) { - if (widget->state == GTK_STATE_INSENSITIVE) - gdk_draw_text (widget->window, widget->style->font, - widget->style->white_gc, - offset + x + 1, y + 1, - &label->label[row->index+j], i - j); - - gdk_draw_text (widget->window, widget->style->font, - widget->style->fg_gc[widget->state], - offset + x, y, - &label->label[row->index+j], i - j); + char save = label->label[row->index + i]; + label->label[row->index + i] = '\0'; + gtk_paint_string(widget->style, widget->window, widget->state, + area, widget, "label", offset + x, y, + &label->label[row->index+j]); + label->label[row->index + i] = save; } @@ -459,7 +432,7 @@ gtk_label_size_request (GtkWidget *widget, row->len); width = MAX (width, row->width); - requisition->height += gtk_label_process_row (label, row, 0, 0, FALSE) + 2; + requisition->height += gtk_label_process_row (label, row, 0, 0, FALSE, NULL) + 2; tmp_list = tmp_list->next; } @@ -491,24 +464,7 @@ gtk_label_expose (GtkWidget *widget, */ gdk_gc_set_clip_rectangle (widget->style->white_gc, &event->area); gdk_gc_set_clip_rectangle (widget->style->fg_gc[widget->state], &event->area); - - /* We clear the whole allocation here so that if a partial - * expose is triggered we don't just clear part and mess up - * when the queued redraw comes along. (There will always - * be a complete queued redraw when the needs_clear flag - * is set.) - */ - if (label->needs_clear) - { - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); - - label->needs_clear = FALSE; - } - + x = widget->allocation.x + misc->xpad + (widget->allocation.width - (label->max_width + label->misc.xpad * 2)) * misc->xalign + 0.5; @@ -517,7 +473,7 @@ gtk_label_expose (GtkWidget *widget, (widget->allocation.y + widget->allocation.height - (widget->requisition.height - misc->ypad * 2)) * misc->yalign + widget->style->font->ascent) + 1.5; - + /* * COMMENT: we can avoid gdk_text_width() calls here storing in label->row * the widths of the rows calculated in gtk_label_set. @@ -527,13 +483,12 @@ gtk_label_expose (GtkWidget *widget, tmp_list = label->row; while (tmp_list) { - y += gtk_label_process_row (label, tmp_list->data, x, y, TRUE) + 2; + y += gtk_label_process_row (label, tmp_list->data, x, y, TRUE, &event->area) + 2; tmp_list = tmp_list->next; } gdk_gc_set_clip_mask (widget->style->white_gc, NULL); gdk_gc_set_clip_mask (widget->style->fg_gc[widget->state], NULL); - } return TRUE; } @@ -553,22 +508,6 @@ gtk_label_free_rows (GtkLabel *label) label->row = NULL; } -static void -gtk_label_state_changed (GtkWidget *widget, - guint previous_state) -{ - if (GTK_WIDGET_DRAWABLE (widget)) - GTK_LABEL (widget)->needs_clear = TRUE; -} - -static void -gtk_label_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - if (GTK_WIDGET_DRAWABLE (widget)) - GTK_LABEL (widget)->needs_clear = TRUE; -} - guint gtk_label_parse_uline (GtkLabel *label, const gchar *string) @@ -631,5 +570,3 @@ gtk_label_parse_uline (GtkLabel *label, return accel_key; } - - diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h index eb419625cd..0e1ef61759 100644 --- a/gtk/gtklabel.h +++ b/gtk/gtklabel.h @@ -48,7 +48,6 @@ struct _GtkLabel GSList *row; guint max_width : 16; guint jtype : 2; - guint needs_clear : 1; }; struct _GtkLabelClass diff --git a/gtk/gtklistitem.c b/gtk/gtklistitem.c index bab73bd2c3..b583779826 100644 --- a/gtk/gtklistitem.c +++ b/gtk/gtklistitem.c @@ -380,8 +380,6 @@ gtk_list_item_realize (GtkWidget *widget) gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]); } @@ -457,60 +455,47 @@ gtk_list_item_draw (GtkWidget *widget, { bin = GTK_BIN (widget); - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_style_set_background (widget->style, widget->window, GTK_STATE_INSENSITIVE); - else if (widget->state == GTK_STATE_NORMAL) - gdk_window_set_background (widget->window, - &widget->style->base[GTK_STATE_NORMAL]); + if (widget->state == GTK_STATE_NORMAL) + { + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + } else - gtk_style_set_background (widget->style, widget->window, widget->state); - - gdk_window_clear_area (widget->window, area->x, area->y, - area->width, area->height); + { + gtk_paint_flat_box(widget->style, widget->window, + widget->state, GTK_SHADOW_ETCHED_OUT, + area, widget, "listitem", + 0, 0, -1, -1); + } if (bin->child && gtk_widget_intersect (bin->child, area, &child_area)) gtk_widget_draw (bin->child, &child_area); - gtk_widget_draw_focus (widget); + if (GTK_WIDGET_HAS_FOCUS (widget)) + { + if (GTK_IS_LIST (widget->parent) && GTK_LIST (widget->parent)->add_mode) + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "add-mode", + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); + else + gtk_paint_focus (widget->style, widget->window, + NULL, widget, NULL, + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); + } } } static void gtk_list_item_draw_focus (GtkWidget *widget) { - GdkGC *gc; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_LIST_ITEM (widget)); - - if (GTK_WIDGET_DRAWABLE (widget)) - { - if (GTK_WIDGET_HAS_FOCUS (widget)) - gc = widget->style->black_gc; - else if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gc = widget->style->bg_gc[GTK_STATE_INSENSITIVE]; - else if (widget->state == GTK_STATE_NORMAL) - gc = widget->style->base_gc[GTK_STATE_NORMAL]; - else - gc = widget->style->bg_gc[widget->state]; - - if (GTK_IS_LIST (widget->parent) && GTK_LIST (widget->parent)->add_mode) - { - gdk_gc_set_line_attributes (gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0); - gdk_gc_set_dashes (gc, 0, "\4\4", 2); - - gdk_draw_rectangle (widget->window, gc, FALSE, 0, 0, - widget->allocation.width - 1, - widget->allocation.height - 1); - - gdk_gc_set_line_attributes (gc, 1, GDK_LINE_SOLID, 0, 0); - } - else - gdk_draw_rectangle (widget->window, gc, FALSE, 0, 0, - widget->allocation.width - 1, - widget->allocation.height - 1); - - } + + gtk_widget_draw(widget, NULL); } static gint diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c index f1462b9f2c..663c7c7405 100644 --- a/gtk/gtkmenu.c +++ b/gtk/gtkmenu.c @@ -668,6 +668,7 @@ gtk_menu_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_menu_paint(widget); } static void @@ -788,13 +789,12 @@ gtk_menu_paint (GtkWidget *widget) if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_draw_shadow (widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - 0, 0, - widget->allocation.width, - widget->allocation.height); + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + NULL, widget, "menu", + 0, 0, -1, -1); } } @@ -1086,3 +1086,4 @@ gtk_menu_hide_all (GtkWidget *widget) /* Hide children, but not self. */ gtk_container_foreach (GTK_CONTAINER (widget), (GtkCallback) gtk_widget_hide_all, NULL); } + diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 3f04e5193b..50bb4eecc1 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -33,7 +33,8 @@ static void gtk_menu_bar_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_menu_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void gtk_menu_bar_paint (GtkWidget *widget); +static void gtk_menu_bar_paint (GtkWidget *widget, + GdkRectangle *area); static void gtk_menu_bar_draw (GtkWidget *widget, GdkRectangle *area); static gint gtk_menu_bar_expose (GtkWidget *widget, @@ -262,20 +263,20 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, } static void -gtk_menu_bar_paint (GtkWidget *widget) +gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_BAR (widget)); if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_draw_shadow (widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - 0, 0, - widget->allocation.width, - widget->allocation.height); + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + area, widget, "menubar", + 0, 0, + -1,-1); } } @@ -294,7 +295,7 @@ gtk_menu_bar_draw (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_menu_bar_paint (widget); + gtk_menu_bar_paint (widget, area); menu_shell = GTK_MENU_SHELL (widget); @@ -315,9 +316,9 @@ gtk_menu_bar_expose (GtkWidget *widget, GdkEventExpose *event) { GtkMenuShell *menu_shell; - GtkWidget *child; GdkEventExpose child_event; GList *children; + GtkWidget *child; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU_BAR (widget), FALSE); @@ -325,7 +326,7 @@ gtk_menu_bar_expose (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { - gtk_menu_bar_paint (widget); + gtk_menu_bar_paint (widget, &event->area); menu_shell = GTK_MENU_SHELL (widget); child_event = *event; diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 59abb8bfea..8890a7502b 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -415,21 +415,24 @@ gtk_menu_item_paint (GtkWidget *widget, if (!GTK_WIDGET_IS_SENSITIVE (widget)) state_type = GTK_STATE_INSENSITIVE; - gtk_style_set_background (widget->style, widget->window, state_type); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - x = GTK_CONTAINER (menu_item)->border_width; y = GTK_CONTAINER (menu_item)->border_width; width = widget->allocation.width - x * 2; height = widget->allocation.height - y * 2; - + if ((state_type == GTK_STATE_PRELIGHT) && (GTK_BIN (menu_item)->child)) - gtk_draw_shadow (widget->style, - widget->window, - GTK_STATE_PRELIGHT, - GTK_SHADOW_OUT, - x, y, width, height); + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_PRELIGHT, + GTK_SHADOW_OUT, + area, widget, "menuitem", + x, y, width, height); + else + { + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + } if (menu_item->submenu && menu_item->show_submenu_indicator) { @@ -437,14 +440,17 @@ gtk_menu_item_paint (GtkWidget *widget, if (state_type == GTK_STATE_PRELIGHT) shadow_type = GTK_SHADOW_IN; - gtk_draw_arrow (widget->style, widget->window, - state_type, shadow_type, GTK_ARROW_RIGHT, FALSE, - x + width - 15, y + height / 2 - 5, 10, 10); + gtk_paint_arrow (widget->style, widget->window, + state_type, shadow_type, + area, widget, "menuitem", + GTK_ARROW_RIGHT, TRUE, + x + width - 15, y + height / 2 - 5, 10, 10); } else if (!GTK_BIN (menu_item)->child) { - gtk_draw_hline (widget->style, widget->window, GTK_STATE_NORMAL, - 0, widget->allocation.width, 0); + gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL, + area, widget, "menuitem", + 0, widget->allocation.width, 0); } } } diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c index 0445cf854e..e2fdf50f13 100644 --- a/gtk/gtkmisc.c +++ b/gtk/gtkmisc.c @@ -182,12 +182,7 @@ gtk_misc_set_alignment (GtkMisc *misc, GtkWidget *widget; widget = GTK_WIDGET (misc); - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); - gtk_widget_queue_draw (GTK_WIDGET (misc)); + gtk_widget_queue_clear (widget); } } } diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 71b69cd7e6..e10724624a 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -28,8 +28,8 @@ #define TAB_OVERLAP 2 #define TAB_CURVATURE 1 -#define ARROW_SIZE 11 -#define ARROW_SPACING 3 +#define ARROW_SIZE 12 +#define ARROW_SPACING 0 #define NOTEBOOK_INIT_SCROLL_DELAY (200) #define NOTEBOOK_SCROLL_DELAY (100) @@ -168,7 +168,9 @@ static void gtk_notebook_menu_item_create (GtkNotebook *notebook, static GtkType gtk_notebook_child_type (GtkContainer *container); static gint gtk_notebook_find_page (gconstpointer a, gconstpointer b); - +static void gtk_notebook_set_shape (GtkNotebook *notebook); +static void gtk_notebook_style_set (GtkWidget *widget, + GtkStyle *previous_style); static GtkContainerClass *parent_class = NULL; static guint notebook_signals[LAST_SIGNAL] = { 0 }; @@ -254,7 +256,8 @@ gtk_notebook_class_init (GtkNotebookClass *class) widget_class->focus_in_event = gtk_notebook_focus_in; widget_class->focus_out_event = gtk_notebook_focus_out; widget_class->draw_focus = gtk_notebook_draw_focus; - + widget_class->style_set = gtk_notebook_style_set; + container_class->add = gtk_notebook_add; container_class->remove = gtk_notebook_remove; container_class->forall = gtk_notebook_forall; @@ -643,7 +646,7 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook, page->allocation.height = 0; page->default_menu = FALSE; page->default_tab = FALSE; - + nchildren = g_list_length (notebook->children); if ((position < 0) || (position > nchildren)) position = nchildren; @@ -1182,11 +1185,7 @@ gtk_notebook_set_tab_pos (GtkNotebook *notebook, notebook->tab_pos = pos; if (GTK_WIDGET_VISIBLE (notebook)) - { - gtk_widget_queue_resize (GTK_WIDGET (notebook)); - if (notebook->panel) - gdk_window_clear (notebook->panel); - } + gtk_widget_queue_resize (GTK_WIDGET (notebook)); } } @@ -1275,17 +1274,28 @@ gtk_notebook_set_scrollable (GtkNotebook *notebook, g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); + scrollable = (scrollable != FALSE); + if (scrollable != notebook->scrollable) { - if ( (notebook->scrollable = (scrollable != 0)) ) - gtk_notebook_panel_realize (notebook); - else if (notebook->panel) + notebook->scrollable = scrollable; + + if (GTK_WIDGET_REALIZED (notebook)) { - gdk_window_destroy (notebook->panel); - notebook->panel = NULL; + if (scrollable) + { + gtk_notebook_panel_realize (notebook); + } + else if (notebook->panel) + { + gdk_window_destroy (notebook->panel); + notebook->panel = NULL; + } } - gtk_widget_queue_resize (GTK_WIDGET(notebook)); - } + + if (GTK_WIDGET_VISIBLE (notebook)) + gtk_widget_queue_resize (GTK_WIDGET(notebook)); + } } static void @@ -1361,8 +1371,8 @@ gtk_notebook_realize (GtkWidget *widget) attributes.visual = gtk_widget_get_visual (widget); attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK; + attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; @@ -1372,6 +1382,7 @@ gtk_notebook_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); if (notebook->scrollable) gtk_notebook_panel_realize (notebook); } @@ -1417,6 +1428,7 @@ gtk_notebook_panel_realize (GtkNotebook *notebook) attributes_mask); gtk_style_set_background (widget->style, notebook->panel, GTK_STATE_NORMAL); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); gdk_window_set_user_data (notebook->panel, widget); } @@ -1636,6 +1648,7 @@ gtk_notebook_size_allocate (GtkWidget *widget, gtk_notebook_pages_allocate (notebook, allocation); } + gtk_notebook_set_shape (notebook); } static void @@ -1645,11 +1658,11 @@ gtk_notebook_paint (GtkWidget *widget, GtkNotebook *notebook; GtkNotebookPage *page; GList *children; - GdkPoint points[6]; gint width, height; gint x, y; gint showarrow; - + gint gap_x = 0, gap_width = 0; + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (widget)); g_return_if_fail (area != NULL); @@ -1658,10 +1671,6 @@ gtk_notebook_paint (GtkWidget *widget, { notebook = GTK_NOTEBOOK (widget); - gdk_window_clear_area (widget->window, - area->x, area->y, - area->width, area->height); - if (notebook->show_tabs || notebook->show_border) { x = GTK_CONTAINER (widget)->border_width; @@ -1693,16 +1702,15 @@ gtk_notebook_paint (GtkWidget *widget, case GTK_POS_RIGHT: width -= page->allocation.width + widget->style->klass->xthickness; - break; + break; } - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height); + gtk_paint_box (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + area, widget, "notebook", + x, y, width, height); } else { - gint i = 0; - switch (notebook->tab_pos) { case GTK_POS_TOP: @@ -1716,141 +1724,35 @@ gtk_notebook_paint (GtkWidget *widget, width -= notebook->cur_page->allocation.width; break; } - - switch (notebook->tab_pos) + + switch (notebook->tab_pos) { case GTK_POS_TOP: - if (x != notebook->cur_page->allocation.x) - { - points[i].x = notebook->cur_page->allocation.x; - points[i++].y = y; - } - - points[i].x = x; - points[i++].y = y; - points[i].x = x; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y; - - if ((notebook->cur_page->allocation.x + - notebook->cur_page->allocation.width - - widget->style->klass->xthickness) < - x + width - widget->style->klass->xthickness) - { - points[i].x = (notebook->cur_page->allocation.x + - notebook->cur_page->allocation.width - - widget->style->klass->xthickness); - - if (points[i].x == (x + width)) - points[i].x -= 1; - - points[i++].y = y; - } + gap_x = notebook->cur_page->allocation.x - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.width; break; - case GTK_POS_BOTTOM: - if ((notebook->cur_page->allocation.x + - notebook->cur_page->allocation.width - - widget->style->klass->xthickness) < - x + width - widget->style->klass->xthickness) - { - points[i].x = (notebook->cur_page->allocation.x + - notebook->cur_page->allocation.width - - widget->style->klass->xthickness); - - if (points[i].x == (x + width)) - points[i].x -= 1; - - points[i++].y = y + height - 1; - } - - points[i].x = x + width - 1; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y; - points[i].x = x; - points[i++].y = y; - points[i].x = x; - points[i++].y = y + height - 1; - - if (notebook->cur_page->allocation.x != x) - { - points[i].x = notebook->cur_page->allocation.x; - points[i++].y = y + height - 1; - } + gap_x = notebook->cur_page->allocation.x - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.width; break; - case GTK_POS_LEFT: - if ((notebook->cur_page->allocation.y + - notebook->cur_page->allocation.height - - widget->style->klass->ythickness) < - y + height - widget->style->klass->ythickness) - { - points[i].x = x; - points[i++].y = notebook->cur_page->allocation.y + - notebook->cur_page->allocation.height - - widget->style->klass->ythickness; - - if (points[0].y == (y + height)) - points[0].y -= 1; - } - - points[i].x = x; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y; - points[i].x = x; - points[i++].y = y; - - if (notebook->cur_page->allocation.y != y) - { - points[i].x = x; - points[i++].y = notebook->cur_page->allocation.y; - } + gap_x = notebook->cur_page->allocation.y - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.height; break; - case GTK_POS_RIGHT: - if (notebook->cur_page->allocation.y != y) - { - points[i].x = x + width - 1; - points[i++].y = notebook->cur_page->allocation.y; - } - - points[i].x = x + width - 1; - points[i++].y = y; - points[i].x = x; - points[i++].y = y; - points[i].x = x; - points[i++].y = y + height - 1; - points[i].x = x + width - 1; - points[i++].y = y + height - 1; - - if ((notebook->cur_page->allocation.y + - notebook->cur_page->allocation.height - - widget->style->klass->ythickness) < - y + height - widget->style->klass->ythickness) - { - points[i].x = x + width - 1; - points[i++].y = notebook->cur_page->allocation.y + - notebook->cur_page->allocation.height - - widget->style->klass->ythickness; - - if (points[i - 1].y == (y + height)) - points[i - 1].y -= 1; - } + gap_x = notebook->cur_page->allocation.y - + GTK_CONTAINER(notebook)->border_width; + gap_width = notebook->cur_page->allocation.height; break; - } - - gtk_draw_polygon (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - points, i, FALSE); - + gtk_paint_box_gap(widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + area, widget, "notebook", + x, y, width, height, + notebook->tab_pos, gap_x, gap_width); } children = g_list_last (notebook->children); showarrow = FALSE; @@ -1878,9 +1780,10 @@ gtk_notebook_paint (GtkWidget *widget, } else if (notebook->show_border) { - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - x, y, width, height); + gtk_paint_box(widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + area, widget, "notebook", + x, y, width, height); } } } @@ -1916,7 +1819,8 @@ gtk_notebook_expose (GtkWidget *widget, { GtkNotebook *notebook; GdkEventExpose child_event; - + GdkRectangle child_area; + g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_NOTEBOOK (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -1926,7 +1830,10 @@ gtk_notebook_expose (GtkWidget *widget, notebook = GTK_NOTEBOOK (widget); gtk_notebook_paint (widget, &event->area); - gtk_widget_draw_focus (widget); + if (notebook->cur_page && + gtk_widget_intersect (notebook->cur_page->tab_label, + &event->area, &child_area)) + gtk_widget_draw_focus (widget); child_event = *event; if (notebook->cur_page && @@ -2059,6 +1966,7 @@ gtk_notebook_button_press (GtkWidget *widget, if (!children && !GTK_WIDGET_HAS_FOCUS (widget)) gtk_widget_grab_focus (widget); } + gtk_notebook_set_shape (notebook); return FALSE; } @@ -2277,9 +2185,12 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow) if (notebook->tab_pos == GTK_POS_LEFT || notebook->tab_pos == GTK_POS_RIGHT) arrow = GTK_ARROW_UP; - gtk_draw_arrow (widget->style, notebook->panel, state_type, - shadow_type, arrow, TRUE, - 0, 0, ARROW_SIZE, ARROW_SIZE); + + gdk_window_clear_area (notebook->panel, 0, 0, ARROW_SIZE, ARROW_SIZE); + gtk_paint_arrow (widget->style, notebook->panel, state_type, + shadow_type, NULL, GTK_WIDGET(notebook), "notebook", + arrow, TRUE, + 0, 0, ARROW_SIZE, ARROW_SIZE); } else { @@ -2292,9 +2203,12 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, guint arrow) if (notebook->tab_pos == GTK_POS_LEFT || notebook->tab_pos == GTK_POS_RIGHT) arrow = GTK_ARROW_DOWN; - gtk_draw_arrow (widget->style, notebook->panel, state_type, - shadow_type, arrow, TRUE, ARROW_SIZE + ARROW_SPACING, - 0, ARROW_SIZE, ARROW_SIZE); + gdk_window_clear_area(notebook->panel, ARROW_SIZE + ARROW_SPACING, + 0, ARROW_SIZE, ARROW_SIZE); + gtk_paint_arrow (widget->style, notebook->panel, state_type, + shadow_type, NULL, GTK_WIDGET(notebook), "notebook", + arrow, TRUE, ARROW_SIZE + ARROW_SPACING, + 0, ARROW_SIZE, ARROW_SIZE); } } } @@ -2322,7 +2236,6 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, g_list_find (notebook->children, notebook->cur_page); gtk_notebook_pages_allocate (notebook, >K_WIDGET (notebook)->allocation); - gtk_notebook_expose_tabs (notebook); if (GTK_WIDGET_MAPPED (notebook)) { @@ -2338,6 +2251,7 @@ gtk_notebook_real_switch_page (GtkNotebook *notebook, if (GTK_WIDGET_DRAWABLE (notebook)) gtk_widget_queue_draw (GTK_WIDGET (notebook)); + gtk_notebook_set_shape (notebook); } static void @@ -2348,14 +2262,14 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, GdkRectangle child_area; GdkRectangle page_area; GtkStateType state_type; - GdkPoint points[6]; - gint n = 0; - + GtkPositionType gap_side; + g_return_if_fail (notebook != NULL); g_return_if_fail (page != NULL); g_return_if_fail (area != NULL); - if (!GTK_WIDGET_MAPPED (page->tab_label)) + if (!GTK_WIDGET_MAPPED (page->tab_label) || + (page->allocation.width == 0) || (page->allocation.height == 0)) return; page_area.x = page->allocation.x; @@ -2367,207 +2281,45 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, { GtkWidget *widget; + widget = GTK_WIDGET (notebook); + gap_side = 0; switch (notebook->tab_pos) { case GTK_POS_TOP: - if (child_area.x + child_area.width > - page->allocation.x + page->allocation.width - TAB_OVERLAP) - { - points[0].x = page->allocation.x + page->allocation.width - 1; - points[0].y = page->allocation.y + page->allocation.height - 1; - - points[1].x = page->allocation.x + page->allocation.width - 1; - points[1].y = page->allocation.y + TAB_CURVATURE; - - points[2].x = page->allocation.x + page->allocation.width - - TAB_CURVATURE - 1; - points[2].y = page->allocation.y; - n = 3; - } - else - { - points[0].x = page->allocation.x + page->allocation.width - - TAB_OVERLAP - 1; - points[0].y = page->allocation.y; - n = 1; - } - - if ( (child_area.x < page->allocation.x + TAB_OVERLAP) && - (page == notebook->cur_page || - page == (GtkNotebookPage *)(notebook->children->data) || - (notebook->scrollable && - page == (GtkNotebookPage *)(notebook->first_tab->data))) ) - { - points[n].x = page->allocation.x + TAB_CURVATURE; - points[n++].y = page->allocation.y; - - points[n].x = page->allocation.x; - points[n++].y = page->allocation.y + TAB_CURVATURE; - - points[n].x = page->allocation.x; - points[n++].y = page->allocation.y + page->allocation.height - 1; - } - else - { - points[n].x = page->allocation.x + TAB_OVERLAP; - points[n++].y = page->allocation.y; - } + gap_side = GTK_POS_BOTTOM; break; case GTK_POS_BOTTOM: - if ( (child_area.x < page->allocation.x + TAB_OVERLAP) && - (page == notebook->cur_page || - page == (GtkNotebookPage *)(notebook->children->data) || - (notebook->scrollable && - page == (GtkNotebookPage *)(notebook->first_tab->data))) ) - { - points[0].x = page->allocation.x; - points[0].y = page->allocation.y; - - points[1].x = page->allocation.x; - points[1].y = page->allocation.y + page->allocation.height - - TAB_CURVATURE - 1; - - points[2].x = page->allocation.x + TAB_CURVATURE; - points[2].y = page->allocation.y + page->allocation.height - 1; - n = 3; - } - else - { - points[0].x = page->allocation.x + TAB_OVERLAP; - points[0].y = page->allocation.y + page->allocation.height - 1; - n = 1; - } - - if (child_area.x + child_area.width > - page->allocation.x + page->allocation.width - TAB_OVERLAP) - { - points[n].x = page->allocation.x + page->allocation.width - - TAB_CURVATURE - 1; - points[n++].y = page->allocation.y + page->allocation.height - 1; - - points[n].x = page->allocation.x + page->allocation.width - 1; - points[n++].y = page->allocation.y + page->allocation.height - - TAB_CURVATURE - 1; - - points[n].x = page->allocation.x + page->allocation.width - 1; - points[n++].y = page->allocation.y; - } - else - { - points[n].x = page->allocation.x + page->allocation.width - - TAB_OVERLAP - 1; - points[n++].y = page->allocation.y + page->allocation.height - 1; - } + gap_side = GTK_POS_TOP; break; case GTK_POS_LEFT: - if ( (child_area.y < page->allocation.y + TAB_OVERLAP) && - (page == notebook->cur_page || - page == (GtkNotebookPage *)(notebook->children->data) || - (notebook->scrollable && - page == (GtkNotebookPage *)(notebook->first_tab->data))) ) - { - points[0].x = page->allocation.x + page->allocation.width - 1; - points[0].y = page->allocation.y; - - points[1].x = page->allocation.x + TAB_CURVATURE; - points[1].y = page->allocation.y; - - points[2].x = page->allocation.x; - points[2].y = page->allocation.y + TAB_CURVATURE; - n = 3; - } - else - { - points[0].x = page->allocation.x; - points[0].y = page->allocation.y + TAB_OVERLAP; - n = 1; - } - - if (child_area.y + child_area.height > - page->allocation.y + page->allocation.height - TAB_OVERLAP) - { - points[n].x = page->allocation.x; - points[n++].y = page->allocation.y + page->allocation.height - - TAB_CURVATURE - 1; - - points[n].x = page->allocation.x + TAB_CURVATURE; - points[n++].y = page->allocation.y + page->allocation.height - 1; - - points[n].x = page->allocation.x + page->allocation.width - 1; - points[n++].y = page->allocation.y + page->allocation.height - 1; - } - else - { - points[n].x = page->allocation.x; - points[n++].y = page->allocation.y + page->allocation.height - - TAB_OVERLAP - 1; - } + gap_side = GTK_POS_RIGHT; break; case GTK_POS_RIGHT: - if (child_area.y + child_area.height > - page->allocation.y + page->allocation.height - TAB_OVERLAP) - { - points[0].x = page->allocation.x; - points[0].y = page->allocation.y + page->allocation.height - 1; - - points[1].x = page->allocation.x + page->allocation.width - - TAB_CURVATURE - 1; - points[1].y = page->allocation.y + page->allocation.height - 1; - - points[2].x = page->allocation.x + page->allocation.width - 1; - points[2].y = page->allocation.y + page->allocation.height - - TAB_CURVATURE - 1; - n = 3; - } - else - { - points[0].x = page->allocation.x + page->allocation.width - 1; - points[0].y = page->allocation.y + page->allocation.height - - TAB_OVERLAP - 1; - n = 1; - } - - if ( (child_area.y < page->allocation.y + TAB_OVERLAP) && - (page == notebook->cur_page || - page == (GtkNotebookPage *)(notebook->children->data) || - (notebook->scrollable && - page == (GtkNotebookPage *)(notebook->first_tab->data))) ) - { - points[n].x = page->allocation.x + page->allocation.width - 1; - points[n++].y = page->allocation.y + TAB_CURVATURE; - - points[n].x = page->allocation.x + page->allocation.width - - TAB_CURVATURE - 1; - points[n++].y = page->allocation.y; - - points[n].x = page->allocation.x; - points[n++].y = page->allocation.y; - } - else - { - points[n].x = page->allocation.x + page->allocation.width - 1; - points[n++].y = page->allocation.y + TAB_OVERLAP; - } + gap_side = GTK_POS_RIGHT; break; } - - widget = GTK_WIDGET(notebook); - + if (notebook->cur_page == page) - { - state_type = GTK_STATE_NORMAL; - } + state_type = GTK_STATE_NORMAL; else + state_type = GTK_STATE_ACTIVE; + gtk_paint_extension(widget->style, widget->window, + state_type, GTK_SHADOW_OUT, + area, widget, "tab", + page_area.x, page_area.y, + page_area.width, page_area.height, + gap_side); + if ((GTK_WIDGET_HAS_FOCUS (widget)) && + notebook->focus_tab && (notebook->focus_tab->data == page) && + (page)) { - state_type = GTK_STATE_ACTIVE; - gdk_draw_rectangle (widget->window, widget->style->bg_gc[state_type], - TRUE, child_area.x, child_area.y, - child_area.width, child_area.height); + gtk_paint_focus (widget->style, widget->window, + area, widget, "tab", + page->tab_label->allocation.x - 1, + page->tab_label->allocation.y - 1, + page->tab_label->allocation.width + 1, + page->tab_label->allocation.height + 1); } - - gtk_draw_polygon (widget->style, widget->window, state_type, - GTK_SHADOW_OUT, points, n, FALSE); - if (gtk_widget_intersect (page->tab_label, area, &child_area)) gtk_widget_draw (page->tab_label, &child_area); } @@ -2649,77 +2401,27 @@ gtk_notebook_draw_focus (GtkWidget *widget) if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs && notebook->focus_tab) { - GtkNotebookPage *page; - GdkGC *gc; - - page = notebook->focus_tab->data; - - if (GTK_WIDGET_HAS_FOCUS (widget)) - gc = widget->style->black_gc; - else if (page == notebook->cur_page) - gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - else - gc = widget->style->bg_gc[GTK_STATE_ACTIVE]; - - gdk_draw_rectangle (widget->window, - gc, FALSE, - page->tab_label->allocation.x - 1, - page->tab_label->allocation.y - 1, - page->tab_label->allocation.width + 1, - page->tab_label->allocation.height + 1); + GtkNotebookPage *page; + GdkRectangle area; + + page = notebook->focus_tab->data; + + area.x = widget->allocation.x; + area.y = widget->allocation.y; + area.width = widget->allocation.width; + area.height = widget->allocation.height; + + gtk_notebook_draw_tab(GTK_NOTEBOOK(widget), page, &area); } } static void gtk_notebook_focus_changed (GtkNotebook *notebook, GtkNotebookPage *old_page) { - GtkWidget *widget; - g_return_if_fail (notebook != NULL); g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); - widget = GTK_WIDGET (notebook); - - if (GTK_WIDGET_DRAWABLE (widget) && notebook->show_tabs) - { - GdkGC *gc; - - if (notebook->focus_tab) - { - GtkNotebookPage *page; - - page = notebook->focus_tab->data; - - if (GTK_WIDGET_HAS_FOCUS (widget)) - gc = widget->style->black_gc; - else if (page == notebook->cur_page) - gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - else - gc = widget->style->bg_gc[GTK_STATE_ACTIVE]; - - gdk_draw_rectangle (widget->window, - gc, FALSE, - page->tab_label->allocation.x - 1, - page->tab_label->allocation.y - 1, - page->tab_label->allocation.width + 1, - page->tab_label->allocation.height + 1); - } - - if (old_page) - { - if (old_page == notebook->cur_page) - gc = widget->style->bg_gc[GTK_STATE_NORMAL]; - else - gc = widget->style->bg_gc[GTK_STATE_ACTIVE]; - - gdk_draw_rectangle (widget->window, - gc, FALSE, - old_page->tab_label->allocation.x - 1, - old_page->tab_label->allocation.y - 1, - old_page->tab_label->allocation.width + 1, - old_page->tab_label->allocation.height + 1); - } - } + gtk_notebook_expose_tabs(notebook); } static void @@ -3033,6 +2735,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, gtk_widget_map (page->tab_label); } } + gtk_notebook_set_shape (notebook); } static void @@ -3338,7 +3041,7 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook, old_tab = notebook->focus_tab; notebook->focus_tab = new_child; - if (notebook->scrollable) + if (notebook->scrollable && GTK_WIDGET_DRAWABLE (notebook)) { if ((new_child == NULL) != (old_tab == NULL)) { @@ -3380,6 +3083,8 @@ gtk_notebook_switch_focus_tab (GtkNotebook *notebook, &(GTK_WIDGET (notebook)->allocation)); gtk_notebook_expose_tabs (notebook); } + + gtk_notebook_set_shape (notebook); } static gint @@ -3579,3 +3284,136 @@ gtk_notebook_find_page (gconstpointer a, { return (((GtkNotebookPage *) a)->child != b); } + +static void +gtk_notebook_set_shape (GtkNotebook *notebook) +{ + GtkWidget *widget = NULL; + GdkPixmap *pm = NULL; + GdkGC *pmgc = NULL; + GdkColor col; + gint x, y, width, height, w, h, depth; + GtkNotebookPage *page; + GList *children; + + if (!GTK_WIDGET(notebook)->window) + return; + + widget = GTK_WIDGET(notebook); + + w = widget->allocation.width; + h = widget->allocation.height; + + pm = gdk_pixmap_new (widget->window, w, h, 1); + pmgc = gdk_gc_new (pm); + + /* clear the shape mask */ + col.pixel = 0; + gdk_gc_set_foreground(pmgc, &col); + gdk_draw_rectangle(pm, pmgc, TRUE, 0, 0, w, h); + + col.pixel = 1; + gdk_gc_set_foreground(pmgc, &col); + + /* draw the shape for the notebook page itself */ + x = GTK_CONTAINER(notebook)->border_width; + y = GTK_CONTAINER(notebook)->border_width; + width = widget->allocation.width - x * 2; + height = widget->allocation.height - y * 2; + + if (notebook->show_tabs && notebook->children) + { + if (!(notebook->show_tabs)) + { + page = notebook->first_tab->data; + switch (notebook->tab_pos) + { + case GTK_POS_TOP: + y += page->allocation.height + + widget->style->klass->ythickness; + case GTK_POS_BOTTOM: + height -= page->allocation.height + + widget->style->klass->ythickness; + break; + case GTK_POS_LEFT: + x += page->allocation.width + + widget->style->klass->xthickness; + case GTK_POS_RIGHT: + width -= page->allocation.width + + widget->style->klass->xthickness; + break; + } + } + else + { + page = notebook->cur_page; + if (!GTK_WIDGET_MAPPED (page->tab_label)) + { + if (notebook->tab_pos == GTK_POS_LEFT) + { + x -= widget->style->klass->xthickness * 2; + width += widget->style->klass->xthickness * 2; + } + else if (notebook->tab_pos == GTK_POS_RIGHT) + width += widget->style->klass->xthickness * 2; + } + switch (notebook->tab_pos) + { + case GTK_POS_TOP: + y += page->allocation.height; + case GTK_POS_BOTTOM: + height -= page->allocation.height; + break; + case GTK_POS_LEFT: + x += page->allocation.width; + case GTK_POS_RIGHT: + width -= page->allocation.width; + break; + } + } + } + gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height); + + /* if theres an area for scrollign arrows draw the shape for them */ + if (notebook->panel) + { + gdk_window_get_geometry(notebook->panel, &x, &y, &width, &height, &depth); + gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height); + } + + /* draw the shapes of all the children */ + children = notebook->children; + while (children) + { + page = children->data; + if (GTK_WIDGET_MAPPED (page->tab_label)) + { + x = page->allocation.x; + y = page->allocation.y; + width = page->allocation.width; + height = page->allocation.height; + gdk_draw_rectangle(pm, pmgc, TRUE, x, y, width, height); + } + children = children->next; + } + /* set the mask */ + gdk_window_shape_combine_mask(widget->window, pm, 0, 0); + gdk_pixmap_unref(pm); + gdk_gc_destroy(pmgc); +} + +static void +gtk_notebook_style_set (GtkWidget *widget, + GtkStyle *previous_style) +{ + if (GTK_WIDGET_REALIZED (widget) && + !GTK_WIDGET_NO_WINDOW (widget)) + { + gtk_style_set_background (widget->style, widget->window, widget->state); + if (GTK_WIDGET_DRAWABLE (widget)) + gdk_window_clear (widget->window); + } + + gtk_widget_queue_draw (widget); + gtk_notebook_set_shape (GTK_NOTEBOOK(widget)); +} diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c index 6f520156f3..c92aa879d1 100644 --- a/gtk/gtkoptionmenu.c +++ b/gtk/gtkoptionmenu.c @@ -272,11 +272,11 @@ gtk_option_menu_size_request (GtkWidget *widget, option_menu->width + OPTION_INDICATOR_WIDTH + OPTION_INDICATOR_SPACING * 5 + - CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING); + CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + 2); requisition->height = ((GTK_CONTAINER (widget)->border_width + GTK_WIDGET (widget)->style->klass->ythickness) * 2 + option_menu->height + - CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING); + CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + 2); tmp = (requisition->height - option_menu->height + OPTION_INDICATOR_HEIGHT + OPTION_INDICATOR_SPACING * 2); @@ -304,14 +304,14 @@ gtk_option_menu_size_allocate (GtkWidget *widget, if (child && GTK_WIDGET_VISIBLE (child)) { child_allocation.x = (GTK_CONTAINER (widget)->border_width + - GTK_WIDGET (widget)->style->klass->xthickness); + GTK_WIDGET (widget)->style->klass->xthickness) + 1; child_allocation.y = (GTK_CONTAINER (widget)->border_width + - GTK_WIDGET (widget)->style->klass->ythickness); + GTK_WIDGET (widget)->style->klass->ythickness) + 1; child_allocation.width = (allocation->width - child_allocation.x * 2 - OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 5 - - CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING); + CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING) - 2; child_allocation.height = (allocation->height - child_allocation.y * 2 - - CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING); + CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING) - 2; child_allocation.x += CHILD_LEFT_SPACING; child_allocation.y += CHILD_RIGHT_SPACING; @@ -323,8 +323,7 @@ static void gtk_option_menu_paint (GtkWidget *widget, GdkRectangle *area) { - GdkRectangle restrict_area; - GdkRectangle new_area; + GdkRectangle button_area; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_OPTION_MENU (widget)); @@ -332,30 +331,39 @@ gtk_option_menu_paint (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { - restrict_area.x = GTK_CONTAINER (widget)->border_width; - restrict_area.y = GTK_CONTAINER (widget)->border_width; - restrict_area.width = widget->allocation.width - restrict_area.x * 2; - restrict_area.height = widget->allocation.height - restrict_area.y * 2; - - if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) - { - gtk_style_set_background (widget->style, widget->window, GTK_WIDGET_STATE (widget)); - gdk_window_clear_area (widget->window, - new_area.x, new_area.y, - new_area.width, new_area.height); - - gtk_draw_shadow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, - restrict_area.x, restrict_area.y, - restrict_area.width, restrict_area.height); - - gtk_draw_shadow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, - restrict_area.x + restrict_area.width - restrict_area.x - - OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 4, - restrict_area.y + (restrict_area.height - OPTION_INDICATOR_HEIGHT) / 2, - OPTION_INDICATOR_WIDTH, OPTION_INDICATOR_HEIGHT); - } + button_area.x = GTK_CONTAINER (widget)->border_width + 1; + button_area.y = GTK_CONTAINER (widget)->border_width + 1; + button_area.width = widget->allocation.width - button_area.x * 2; + button_area.height = widget->allocation.height - button_area.y * 2; + + /* This is evil, and should be elimated here and in the button + * code. The point is to clear the focus, and make it + * sort of transparent if it isn't there. + */ + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + + gtk_paint_box(widget->style, widget->window, + GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, + area, widget, "optionmenu", + button_area.x, button_area.y, + button_area.width, button_area.height); + + gtk_paint_tab (widget->style, widget->window, + GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT, + area, widget, "optionmenutab", + button_area.x + button_area.width - button_area.x - + OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 4, + button_area.y + (button_area.height - OPTION_INDICATOR_HEIGHT) / 2, + OPTION_INDICATOR_WIDTH, OPTION_INDICATOR_HEIGHT); + + if (GTK_WIDGET_HAS_FOCUS (widget)) + gtk_paint_focus (widget->style, widget->window, + area, widget, "button", + button_area.x - 1, + button_area.y - 1, + button_area.width + 1, + button_area.height + 1); } } @@ -377,7 +385,6 @@ gtk_option_menu_draw (GtkWidget *widget, child = GTK_BIN (widget)->child; if (child && gtk_widget_intersect (child, area, &child_area)) gtk_widget_draw (child, &child_area); - gtk_widget_draw_focus (widget); } } @@ -440,7 +447,6 @@ gtk_option_menu_expose (GtkWidget *widget, gtk_widget_event (child, (GdkEvent*) &child_event); #endif /* 0 */ - gtk_widget_draw_focus (widget); } return FALSE; diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index e30b9747e2..ae4da2a5e9 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -31,10 +31,10 @@ static void gtk_paned_add (GtkContainer *container, GtkWidget *widget); static void gtk_paned_remove (GtkContainer *container, GtkWidget *widget); -static void gtk_paned_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); +static void gtk_paned_forall (GtkContainer *container, + gboolean include_internals, + GtkCallback callback, + gpointer callback_data); static GtkType gtk_paned_child_type (GtkContainer *container); @@ -167,6 +167,8 @@ gtk_paned_realize (GtkWidget *widget) gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, paned->handle, GTK_STATE_NORMAL); + + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); gdk_window_show (paned->handle); } @@ -252,13 +254,12 @@ gtk_paned_expose (GtkWidget *widget, /* An expose event for the handle */ if (event->window == paned->handle) { - gdk_window_set_background (paned->handle, - &widget->style->bg[widget->state]); - gdk_window_clear (paned->handle); - gtk_draw_shadow (widget->style, paned->handle, - GTK_WIDGET_STATE(widget), - GTK_SHADOW_OUT, 0, 0, - paned->handle_size, paned->handle_size); + gtk_paint_box (widget->style, paned->handle, + GTK_WIDGET_STATE(widget), + GTK_SHADOW_OUT, + &event->area, widget, "paned", + 0, 0, + paned->handle_size, paned->handle_size); } else { diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c index 7a3cfb6848..9cc6ec0076 100644 --- a/gtk/gtkpixmap.c +++ b/gtk/gtkpixmap.c @@ -74,7 +74,6 @@ gtk_pixmap_init (GtkPixmap *pixmap) pixmap->pixmap = NULL; pixmap->mask = NULL; - pixmap->needs_clear = FALSE; } GtkWidget* @@ -82,13 +81,13 @@ gtk_pixmap_new (GdkPixmap *val, GdkBitmap *mask) { GtkPixmap *pixmap; - + g_return_val_if_fail (val != NULL, NULL); - + pixmap = gtk_type_new (gtk_pixmap_get_type ()); - + gtk_pixmap_set (pixmap, val, mask); - + return GTK_WIDGET (pixmap); } @@ -135,20 +134,11 @@ gtk_pixmap_set (GtkPixmap *pixmap, } if (GTK_WIDGET_VISIBLE (pixmap)) { - /* If we aren't drawing the entire area, clear first */ - if (GTK_WIDGET_DRAWABLE (pixmap) && - ((mask != NULL) || - (GTK_WIDGET (pixmap)->requisition.width != oldwidth) || - (GTK_WIDGET (pixmap)->requisition.height != oldheight))) - { - pixmap->needs_clear = TRUE; - } - if ((GTK_WIDGET (pixmap)->requisition.width != oldwidth) || (GTK_WIDGET (pixmap)->requisition.height != oldheight)) gtk_widget_queue_resize (GTK_WIDGET (pixmap)); else - gtk_widget_queue_draw (GTK_WIDGET (pixmap)); + gtk_widget_queue_clear (GTK_WIDGET (pixmap)); } } @@ -194,17 +184,6 @@ gtk_pixmap_expose (GtkWidget *widget, pixmap = GTK_PIXMAP (widget); misc = GTK_MISC (widget); - if (pixmap->needs_clear) - { - gdk_window_clear_area (GTK_WIDGET (pixmap)->window, - GTK_WIDGET (pixmap)->allocation.x, - GTK_WIDGET (pixmap)->allocation.y, - GTK_WIDGET (pixmap)->allocation.width, - GTK_WIDGET (pixmap)->allocation.height); - - pixmap->needs_clear = FALSE; - } - x = (widget->allocation.x * (1.0 - misc->xalign) + (widget->allocation.x + widget->allocation.width - (widget->requisition.width - misc->xpad * 2)) * @@ -231,6 +210,5 @@ gtk_pixmap_expose (GtkWidget *widget, gdk_gc_set_clip_origin (widget->style->black_gc, 0, 0); } } - return FALSE; } diff --git a/gtk/gtkpixmap.h b/gtk/gtkpixmap.h index fa46a3c613..1694579ab4 100644 --- a/gtk/gtkpixmap.h +++ b/gtk/gtkpixmap.h @@ -45,8 +45,6 @@ struct _GtkPixmap GdkPixmap *pixmap; GdkBitmap *mask; - - guint needs_clear : 1; }; struct _GtkPixmapClass diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index 6490fca6da..076310137a 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -423,6 +423,7 @@ gtk_preview_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); } static gint diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index 86ddec1690..429f8a435d 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -379,72 +379,47 @@ gtk_progress_bar_paint (GtkProgress *progress) if (progress->offscreen_pixmap) { - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_NORMAL, GTK_SHADOW_IN, 0, 0, - widget->allocation.width, - widget->allocation.height); - - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_ACTIVE], TRUE, - widget->style->klass->xthickness, - widget->style->klass->ythickness, - widget->allocation.width - - widget->style->klass->xthickness * 2, - widget->allocation.height - - widget->style->klass->ythickness * 2); - + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + NULL, widget, "trough", + 0, 0, + widget->allocation.width, + widget->allocation.height); + if (progress->activity_mode) { if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT || pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT) { size = MAX (2, widget->allocation.width / pbar->activity_blocks); - - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - pbar->activity_pos, - widget->style->klass->ythickness, - size, - widget->allocation.height - - widget->style->klass->ythickness * 2); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - pbar->activity_pos, - widget->style->klass->ythickness, - size, - widget->allocation.height - - widget->style->klass->ythickness * 2); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + pbar->activity_pos, + widget->style->klass->ythickness, + size, + widget->allocation.height - widget->style->klass->ythickness * 2); return; } else { size = MAX (2, widget->allocation.height / pbar->activity_blocks); - - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - pbar->activity_pos, - widget->allocation.width - - widget->style->klass->xthickness * 2, - size); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - pbar->activity_pos, - widget->allocation.width - - widget->style->klass->xthickness * 2, - size); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + pbar->activity_pos, + widget->allocation.width - widget->style->klass->xthickness * 2, + size); return; } } - + amount = percentage * space; if (amount > 0) @@ -456,22 +431,14 @@ gtk_progress_bar_paint (GtkProgress *progress) if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - widget->style->klass->ythickness, - amount, - widget->allocation.height - - widget->style->klass->ythickness * 2); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - widget->style->klass->ythickness, - amount, - widget->allocation.height - - widget->style->klass->ythickness * 2); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->style->klass->ythickness, + amount, + widget->allocation.height - widget->style->klass->ythickness * 2); } else { @@ -482,82 +449,56 @@ gtk_progress_bar_paint (GtkProgress *progress) block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - gdk_draw_rectangle - (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - - widget->style->klass->ythickness * 2); - - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - - widget->style->klass->ythickness * 2); - + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + x, + widget->style->klass->ythickness, + block_delta, + widget->allocation.height - widget->style->klass->ythickness * 2); + x += block_delta; } } break; - + case GTK_PROGRESS_RIGHT_TO_LEFT: - + if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->allocation.width - - widget->style->klass->xthickness - amount, - widget->style->klass->ythickness, - amount, - widget->allocation.height - - widget->style->klass->ythickness * 2); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->allocation.width - - widget->style->klass->xthickness - amount, - widget->style->klass->ythickness, - amount, - widget->allocation.height - - widget->style->klass->ythickness * 2); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->allocation.width - + widget->style->klass->xthickness - amount, + widget->style->klass->ythickness, + amount, + widget->allocation.height - + widget->style->klass->ythickness * 2); } else { x = widget->allocation.width - widget->style->klass->xthickness; - + for (i = 0; i <= pbar->in_block; i++) { block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - + x -= block_delta; - - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - - widget->style->klass->ythickness * 2); - - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - x, - widget->style->klass->ythickness, - block_delta, - widget->allocation.height - - widget->style->klass->ythickness * 2); + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + x, + widget->style->klass->ythickness, + block_delta, + widget->allocation.height - + widget->style->klass->ythickness * 2); } } break; @@ -566,119 +507,86 @@ gtk_progress_bar_paint (GtkProgress *progress) if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - widget->allocation.height - - widget->style->klass->ythickness - amount, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - widget->allocation.height - - widget->style->klass->ythickness - amount, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->allocation.height - + widget->style->klass->ythickness - amount, + widget->allocation.width - + widget->style->klass->xthickness * 2, + amount); } else { y = widget->allocation.height - widget->style->klass->ythickness; - + for (i = 0; i <= pbar->in_block; i++) { block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); y -= block_delta; - - gdk_draw_rectangle - (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); - - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + y, + widget->allocation.width - + widget->style->klass->xthickness * 2, + block_delta); } } break; - + case GTK_PROGRESS_TOP_TO_BOTTOM: - + if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS) { - gdk_draw_rectangle (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - widget->style->klass->ythickness, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - widget->style->klass->ythickness, - widget->allocation.width - - widget->style->klass->xthickness * 2, - amount); + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + widget->style->klass->ythickness, + widget->allocation.width - + widget->style->klass->xthickness * 2, + amount); } else { y = widget->style->klass->ythickness; - + for (i = 0; i <= pbar->in_block; i++) { - + block_delta = (((i + 1) * space) / pbar->blocks) - ((i * space) / pbar->blocks); - - gdk_draw_rectangle - (progress->offscreen_pixmap, - widget->style->bg_gc[GTK_STATE_PRELIGHT], - TRUE, - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); - - gtk_draw_shadow (widget->style, - progress->offscreen_pixmap, - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, - widget->style->klass->xthickness, - y, - widget->allocation.width - - widget->style->klass->xthickness * 2, - block_delta); - + + gtk_paint_box (widget->style, + progress->offscreen_pixmap, + GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, + NULL, widget, "bar", + widget->style->klass->xthickness, + y, + widget->allocation.width - + widget->style->klass->xthickness * 2, + block_delta); + y += block_delta; } } break; - + default: break; } } - + if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE) { gint x; diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index ee1a80f679..33c78e76ea 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -98,6 +98,7 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class) static void gtk_radio_button_init (GtkRadioButton *radio_button) { + GTK_WIDGET_SET_FLAGS (radio_button, GTK_NO_WINDOW); radio_button->group = g_slist_prepend (NULL, radio_button); } @@ -358,7 +359,6 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, GtkShadowType shadow_type; GdkRectangle restrict_area; GdkRectangle new_area; - GdkPoint pts[4]; gint width, height; gint x, y; @@ -376,43 +376,34 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, (state_type != GTK_STATE_PRELIGHT)) state_type = GTK_STATE_NORMAL; - restrict_area.x = GTK_CONTAINER (widget)->border_width; - restrict_area.y = restrict_area.x; - restrict_area.width = widget->allocation.width - restrict_area.x * 2; - restrict_area.height = widget->allocation.height - restrict_area.x * 2; + restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; + restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; + restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width); + restrict_area.height = widget->allocation.height - ( 2 * GTK_CONTAINER (widget)->border_width); if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) { - gtk_style_set_background (widget->style, widget->window, state_type); - gdk_window_clear_area (widget->window, new_area.x, new_area.y, - new_area.width, new_area.height); + if (state_type != GTK_STATE_NORMAL) + gtk_paint_flat_box(widget->style, widget->window, state_type, + GTK_SHADOW_ETCHED_OUT, + area, widget, "radiobutton", + new_area.x, new_area.y, + new_area.width, new_area.height); } - x = CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; - y = (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; + x = widget->allocation.x + CHECK_BUTTON_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width; + y = widget->allocation.y + (widget->allocation.height - CHECK_BUTTON_CLASS (widget)->indicator_size) / 2; width = CHECK_BUTTON_CLASS (widget)->indicator_size; height = CHECK_BUTTON_CLASS (widget)->indicator_size; - + if (GTK_TOGGLE_BUTTON (widget)->active) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - - pts[0].x = x + width / 2; - pts[0].y = y; - pts[1].x = x + width; - pts[1].y = y + height / 2; - pts[2].x = pts[0].x; - pts[2].y = y + height; - pts[3].x = x; - pts[3].y = pts[1].y; - - gdk_draw_polygon (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], - TRUE, pts, 4); - gtk_draw_diamond (widget->style, widget->window, + + gtk_paint_option (widget->style, widget->window, GTK_WIDGET_STATE (widget), shadow_type, + area, widget, "radiobutton", x, y, width, height); } } - diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c index c6cb6d6b2b..482bcdd85d 100644 --- a/gtk/gtkradiomenuitem.c +++ b/gtk/gtkradiomenuitem.c @@ -227,7 +227,6 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, GtkWidget *widget; GtkStateType state_type; GtkShadowType shadow_type; - GdkPoint pts[4]; gint width, height; gint x, y; @@ -244,8 +243,6 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, widget->style->klass->xthickness + 2); y = (widget->allocation.height - height) / 2; - gdk_window_clear_area (widget->window, x, y, width, height); - if (check_menu_item->active || check_menu_item->always_show_toggle || (GTK_WIDGET_STATE (check_menu_item) == GTK_STATE_PRELIGHT)) @@ -257,20 +254,9 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item, else shadow_type = GTK_SHADOW_OUT; - pts[0].x = x + width / 2; - pts[0].y = y; - pts[1].x = x + width; - pts[1].y = y + height / 2; - pts[2].x = pts[0].x; - pts[2].y = y + height; - pts[3].x = x; - pts[3].y = pts[1].y; - - gdk_draw_polygon (widget->window, - widget->style->bg_gc[state_type], - TRUE, pts, 4); - gtk_draw_diamond (widget->style, widget->window, + gtk_paint_option (widget->style, widget->window, state_type, shadow_type, + area, widget, "option", x, y, width, height); } } diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index ae79bb6ef5..b3affe3da8 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -142,6 +142,7 @@ gtk_range_class_init (GtkRangeClass *class) class->step_forw = 3; class->step_back = 4; class->draw_background = NULL; + class->clear_background = NULL; class->draw_trough = gtk_real_range_draw_trough; class->draw_slider = gtk_real_range_draw_slider; class->draw_step_forw = NULL; @@ -245,6 +246,16 @@ gtk_range_draw_background (GtkRange *range) } void +gtk_range_clear_background (GtkRange *range) +{ + g_return_if_fail (range != NULL); + g_return_if_fail (GTK_IS_RANGE (range)); + + if (range->trough && RANGE_CLASS (range)->clear_background) + (* RANGE_CLASS (range)->clear_background) (range); +} + +void gtk_range_draw_trough (GtkRange *range) { g_return_if_fail (range != NULL); @@ -532,7 +543,7 @@ gtk_range_default_hmotion (GtkRange *range, else { gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); if (range->policy == GTK_UPDATE_DELAYED) { @@ -597,7 +608,7 @@ gtk_range_default_vmotion (GtkRange *range, else { gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); if (range->policy == GTK_UPDATE_DELAYED) { @@ -717,7 +728,6 @@ gtk_range_expose (GtkWidget *widget, * trough-drawing handler. (Probably should really pass another * argument - the redrawn area to all the drawing functions) */ - gint xt = widget->style->klass->xthickness; gint yt = widget->style->klass->ythickness; @@ -983,7 +993,7 @@ gtk_range_key_press (GtkWidget *widget, "value_changed"); gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); } } } @@ -1108,23 +1118,16 @@ gtk_real_range_draw_trough (GtkRange *range) g_return_if_fail (GTK_IS_RANGE (range)); if (range->trough) - { - gtk_draw_shadow (GTK_WIDGET (range)->style, range->trough, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - 0, 0, -1, -1); - - if (GTK_WIDGET_HAS_FOCUS (range)) - gdk_draw_rectangle (GTK_WIDGET (range)->window, - GTK_WIDGET (range)->style->black_gc, - FALSE, 0, 0, - GTK_WIDGET (range)->allocation.width - 1, - GTK_WIDGET (range)->allocation.height - 1); - else if (range->trough != GTK_WIDGET (range)->window) - gdk_draw_rectangle (GTK_WIDGET (range)->window, - GTK_WIDGET (range)->style->bg_gc[GTK_STATE_NORMAL], - FALSE, 0, 0, - GTK_WIDGET (range)->allocation.width - 1, - GTK_WIDGET (range)->allocation.height - 1); + { + gtk_paint_box (GTK_WIDGET (range)->style, range->trough, + GTK_STATE_ACTIVE, GTK_SHADOW_IN, + NULL, GTK_WIDGET(range), "trough", + 0, 0, -1, -1); + if (GTK_WIDGET_HAS_FOCUS (range)) + gtk_paint_focus (GTK_WIDGET (range)->style, + range->trough, + NULL, GTK_WIDGET(range), "trough", + 0, 0, -1, -1); } } @@ -1132,10 +1135,10 @@ static void gtk_real_range_draw_slider (GtkRange *range) { GtkStateType state_type; - + g_return_if_fail (range != NULL); g_return_if_fail (GTK_IS_RANGE (range)); - + if (range->slider) { if ((range->in_child == RANGE_CLASS (range)->slider) || @@ -1143,13 +1146,10 @@ gtk_real_range_draw_slider (GtkRange *range) state_type = GTK_STATE_PRELIGHT; else state_type = GTK_STATE_NORMAL; - - gtk_style_set_background (GTK_WIDGET (range)->style, range->slider, state_type); - gdk_window_clear (range->slider); - - gtk_draw_shadow (GTK_WIDGET (range)->style, range->slider, - state_type, GTK_SHADOW_OUT, - 0, 0, -1, -1); + gtk_paint_box (GTK_WIDGET (range)->style, range->slider, + state_type, GTK_SHADOW_OUT, + NULL, GTK_WIDGET (range), "slider", + 0, 0, -1, -1); } } @@ -1289,7 +1289,7 @@ gtk_range_scroll (GtkRange *range, else { gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); } } @@ -1356,7 +1356,7 @@ gtk_range_adjustment_changed (GtkAdjustment *adjustment, (range->old_page_size != adjustment->page_size)) { gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); range->old_value = adjustment->value; range->old_lower = adjustment->lower; @@ -1379,7 +1379,7 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment, if (range->old_value != adjustment->value) { gtk_range_slider_update (range); - gtk_range_draw_background (range); + gtk_range_clear_background (range); range->old_value = adjustment->value; } @@ -1474,7 +1474,7 @@ gtk_range_style_set (GtkWidget *widget, if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) { - if (range->trough) + if (range->trough) { gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE); if (GTK_WIDGET_DRAWABLE (widget)) @@ -1494,5 +1494,6 @@ gtk_range_style_set (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) gdk_window_clear (range->step_back); } + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); } } diff --git a/gtk/gtkrange.h b/gtk/gtkrange.h index f51491b1d8..48da24c659 100644 --- a/gtk/gtkrange.h +++ b/gtk/gtkrange.h @@ -82,7 +82,8 @@ struct _GtkRangeClass guint8 step_forw; guint8 step_back; - void (* draw_background) (GtkRange *range); + void (* draw_background) (GtkRange *range); + void (* clear_background) (GtkRange *range); void (* draw_trough) (GtkRange *range); void (* draw_slider) (GtkRange *range); void (* draw_step_forw) (GtkRange *range); @@ -111,6 +112,7 @@ void gtk_range_set_adjustment (GtkRange *range, GtkAdjustment *adjustment); void gtk_range_draw_background (GtkRange *range); +void gtk_range_clear_background (GtkRange *range); void gtk_range_draw_trough (GtkRange *range); void gtk_range_draw_slider (GtkRange *range); void gtk_range_draw_step_forw (GtkRange *range); diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 84b24c24ec..0f3767a03a 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -25,29 +25,12 @@ #include <stdio.h> #include "gtkrc.h" #include "gtkbindings.h" +#include "gtkthemes.h" - -typedef struct _GtkRcStyle GtkRcStyle; typedef struct _GtkRcSet GtkRcSet; typedef struct _GtkRcNode GtkRcNode; typedef struct _GtkRcFile GtkRcFile; -struct _GtkRcNode -{ - GdkColormap *cmap; - GtkStyle *style; -}; - -struct _GtkRcStyle -{ - char *name; - char *font_name; - char *fontset_name; - char *bg_pixmap_name[5]; - GtkStyle *proto_style; - GList *styles; -}; - struct _GtkRcSet { GtkPatternSpec pspec; @@ -65,13 +48,17 @@ struct _GtkRcFile static guint gtk_rc_style_hash (const char *name); static gint gtk_rc_style_compare (const char *a, const char *b); +static guint gtk_rc_styles_hash (const GSList *rc_styles); +static gint gtk_rc_styles_compare (const GSList *a, + const GSList *b); static GtkRcStyle* gtk_rc_style_find (const char *name); -static GtkRcStyle* gtk_rc_styles_match (GSList *sets, - guint path_length, - gchar *path, - gchar *path_reversed); -static GtkStyle* gtk_rc_style_init (GtkRcStyle *rc_style, - GdkColormap *cmap); +static GSList * gtk_rc_styles_match (GSList *rc_styles, + GSList *sets, + guint path_length, + gchar *path, + gchar *path_reversed); +static GtkStyle * gtk_rc_style_to_style (GtkRcStyle *rc_style); +static GtkStyle* gtk_rc_style_init (GSList *rc_styles); static void gtk_rc_parse_file (const gchar *filename, gboolean reload); @@ -81,29 +68,33 @@ static void gtk_rc_parse_any (const gchar *input_name, static guint gtk_rc_parse_statement (GScanner *scanner); static guint gtk_rc_parse_style (GScanner *scanner); static guint gtk_rc_parse_base (GScanner *scanner, - GtkStyle *style); + GtkRcStyle *style); static guint gtk_rc_parse_bg (GScanner *scanner, - GtkStyle *style); + GtkRcStyle *style); static guint gtk_rc_parse_fg (GScanner *scanner, - GtkStyle *style); + GtkRcStyle *style); static guint gtk_rc_parse_text (GScanner *scanner, - GtkStyle *style); + GtkRcStyle *style); static guint gtk_rc_parse_bg_pixmap (GScanner *scanner, GtkRcStyle *rc_style); static guint gtk_rc_parse_font (GScanner *scanner, GtkRcStyle *rc_style); static guint gtk_rc_parse_fontset (GScanner *scanner, GtkRcStyle *rc_style); +static guint gtk_rc_parse_engine (GScanner *scanner, + GtkRcStyle *rc_style); static guint gtk_rc_parse_pixmap_path (GScanner *scanner); static void gtk_rc_parse_pixmap_path_string (gchar *pix_path); -static char* gtk_rc_find_pixmap_in_path (GScanner *scanner, - gchar *pixmap_file); +static guint gtk_rc_parse_module_path (GScanner *scanner); +static void gtk_rc_parse_module_path_string (gchar *mod_path); static guint gtk_rc_parse_path_pattern (GScanner *scanner); static void gtk_rc_clear_hash_node (gpointer key, gpointer data, gpointer user_data); -static void gtk_rc_clear_styles (void); - +static void gtk_rc_clear_styles (void); +static void gtk_rc_append_default_pixmap_path (void); +static void gtk_rc_append_default_module_path (void); +static void gtk_rc_append_pixmap_path (gchar *dir); static GScannerConfig gtk_rc_scanner_config = @@ -177,28 +168,150 @@ static struct { "application", GTK_RC_TOKEN_APPLICATION }, { "rc", GTK_RC_TOKEN_RC }, { "highest", GTK_RC_TOKEN_HIGHEST }, + { "engine", GTK_RC_TOKEN_ENGINE }, + { "module_path", GTK_RC_TOKEN_MODULE_PATH }, }; static guint n_symbols = sizeof (symbols) / sizeof (symbols[0]); static GHashTable *rc_style_ht = NULL; +static GHashTable *realized_style_ht = NULL; static GSList *gtk_rc_sets_widget = NULL; static GSList *gtk_rc_sets_widget_class = NULL; static GSList *gtk_rc_sets_class = NULL; #define GTK_RC_MAX_PIXMAP_PATHS 128 static gchar *pixmap_path[GTK_RC_MAX_PIXMAP_PATHS]; +#define GTK_RC_MAX_MODULE_PATHS 128 +static gchar *module_path[GTK_RC_MAX_MODULE_PATHS]; /* The files we have parsed, to reread later if necessary */ GSList *rc_files = NULL; static GtkImageLoader image_loader = NULL; +/* RC file handling */ + + +gchar * +gtk_rc_get_theme_dir(void) +{ + gchar *var, *path; + + var = getenv("GTK_DATA_PREFIX"); + if (var) + { + path = g_malloc(strlen(var) + strlen("/share/themes") +1); + sprintf(path, "%s%s", var, "/share/themes"); + } + else + { + path = g_malloc(strlen(GTK_DATA_PREFIX) + strlen("/share/themes") +1); + sprintf(path, "%s%s", GTK_DATA_PREFIX, "/share/themes"); + } + return path; +} + +gchar * +gtk_rc_get_module_dir(void) +{ + gchar *var, *path; + + var = getenv("GTK_EXE_PREFIX"); + if (var) + { + path = g_malloc(strlen(var) + strlen("/lib/gtk/themes/engines") +1); + sprintf(path, "%s%s", var, "/lib/gtk/themes/engines"); + } + else + { + path = g_malloc(strlen(GTK_EXE_PREFIX) + strlen("/lib/gtk/themes/engines") +1); + sprintf(path, "%s%s", GTK_EXE_PREFIX, "/lib/gtk/themes/engines"); + } + return path; +} + +static void +gtk_rc_append_default_pixmap_path(void) +{ + gchar *var, *path; + gint n; + + var = getenv("GTK_DATA_PREFIX"); + if (var) + { + path = g_malloc(strlen(var) + strlen("/share/gtk/themes") +1); + sprintf(path, "%s%s", var, "/share/gtk/themes"); + } + else + { + path = g_malloc(strlen(GTK_DATA_PREFIX) + strlen("/share/gtk/themes") +1); + sprintf(path, "%s%s", GTK_DATA_PREFIX, "/share/gtk/themes"); + } + + for (n = 0; pixmap_path[n]; n++) ; + if (n >= GTK_RC_MAX_PIXMAP_PATHS - 1) + return; + pixmap_path[n++] = g_strdup(path); + pixmap_path[n] = NULL; + g_free(path); +} + +static void +gtk_rc_append_pixmap_path(gchar *dir) +{ + gint n; + + for (n = 0; pixmap_path[n]; n++) ; + if (n >= GTK_RC_MAX_MODULE_PATHS - 1) + return; + pixmap_path[n++] = g_strdup(dir); + pixmap_path[n] = NULL; +} + +static void +gtk_rc_append_default_module_path(void) +{ + gchar *var, *path; + gint n; + + for (n = 0; module_path[n]; n++) ; + if (n >= GTK_RC_MAX_MODULE_PATHS - 1) + return; + + var = getenv("GTK_EXE_PREFIX"); + if (var) + { + path = g_malloc(strlen(var) + strlen("/lib/gtk/themes/engines") +1); + sprintf(path, "%s%s", var, "/lib/gtk/themes/engines"); + } + else + { + path = g_malloc(strlen(GTK_EXE_PREFIX) + strlen("/lib/gtk/themes/engines") +1); + sprintf(path, "%s%s", GTK_EXE_PREFIX, "/lib/gtk/themes/engines"); + } + module_path[n++] = g_strdup(path); + g_free(path); + var = getenv("HOME"); + if (var) + { + path = g_malloc(strlen(var) + strlen(".gtk/lib/themes/engines") +1); + sprintf(path, "%s%s", var, ".gtk/lib/themes/engines"); + } + module_path[n++] = g_strdup(path); + module_path[n] = NULL; + g_free(path); +} + void gtk_rc_init (void) { rc_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_style_hash, (GCompareFunc) gtk_rc_style_compare); + pixmap_path[0] = NULL; + module_path[0] = NULL; + gtk_rc_append_default_pixmap_path(); + gtk_rc_append_default_module_path(); } void @@ -272,6 +385,16 @@ gtk_rc_parse_file (const gchar *filename, gboolean reload) if (fd < 0) return; + { + gint i; + gchar *dir; + + dir = g_strdup(rc_file->canonical_name); + for (i = strlen(dir) - 1; (i >= 0) && (dir[i] != '/'); i--) + dir[i] = 0; + gtk_rc_append_pixmap_path(dir); + g_free(dir); + } gtk_rc_parse_any (filename, fd, NULL); close (fd); @@ -286,37 +409,73 @@ gtk_rc_parse (const gchar *filename) gtk_rc_parse_file (filename, TRUE); } -static void -gtk_rc_clear_hash_node (gpointer key, - gpointer data, - gpointer user_data) +/* Handling of RC styles */ + +GtkRcStyle * +gtk_rc_style_new (void) { - int i; - GtkRcStyle *rc_style = data; - GList *tmp_list; + GtkRcStyle *new_style; - g_free (rc_style->name); - g_free (rc_style->font_name); - g_free (rc_style->fontset_name); + new_style = g_new0 (GtkRcStyle, 1); + new_style->ref_count = 1; - for (i=0 ; i<5 ; i++) - g_free (rc_style->bg_pixmap_name[i]); + return new_style; +} - gtk_style_unref (rc_style->proto_style); +void +gtk_rc_style_ref (GtkRcStyle *rc_style) +{ + g_return_if_fail (rc_style != NULL); - tmp_list = rc_style->styles; - while (tmp_list) - { - GtkRcNode *node = tmp_list->data; + rc_style->ref_count++; +} - gdk_colormap_unref (node->cmap); - gtk_style_unref (node->style); +void +gtk_rc_style_unref (GtkRcStyle *rc_style) +{ + gint i; - g_free (node); - tmp_list = tmp_list->next; + g_return_if_fail (rc_style != NULL); + + rc_style->ref_count--; + + if (rc_style->ref_count == 0) + { + if (rc_style->engine) + { + rc_style->engine->destroy_rc_style (rc_style); + gtk_theme_engine_unref (rc_style->engine); + } + + if (rc_style->name) + g_free (rc_style->name); + if (rc_style->fontset_name) + g_free (rc_style->fontset_name); + if (rc_style->font_name) + g_free (rc_style->font_name); + + for (i=0 ; i<5 ; i++) + if (rc_style->bg_pixmap_name[i]) + g_free (rc_style->bg_pixmap_name[i]); + + g_free (rc_style); } +} - g_free (rc_style); +static void +gtk_rc_clear_realized_node (gpointer key, + gpointer data, + gpointer user_data) +{ + gtk_style_unref (data); +} + +static void +gtk_rc_clear_hash_node (gpointer key, + gpointer data, + gpointer user_data) +{ + gtk_rc_style_unref (data); } static void @@ -339,9 +498,19 @@ gtk_rc_clear_styles (void) { /* Clear out all old rc_styles */ - g_hash_table_foreach (rc_style_ht, gtk_rc_clear_hash_node, NULL); - g_hash_table_destroy (rc_style_ht); - rc_style_ht = NULL; + if (rc_style_ht) + { + g_hash_table_foreach (rc_style_ht, gtk_rc_clear_hash_node, NULL); + g_hash_table_destroy (rc_style_ht); + rc_style_ht = NULL; + } + + if (realized_style_ht) + { + g_hash_table_foreach (realized_style_ht, gtk_rc_clear_realized_node, NULL); + g_hash_table_destroy (realized_style_ht); + realized_style_ht = NULL; + } gtk_rc_free_rc_sets (gtk_rc_sets_widget); g_slist_free (gtk_rc_sets_widget); @@ -403,11 +572,13 @@ gtk_rc_reparse_all (void) return mtime_modified; } -static GtkRcStyle* -gtk_rc_styles_match (GSList *sets, +static GSList * +gtk_rc_styles_match (GSList *rc_styles, + GSList *sets, guint path_length, gchar *path, gchar *path_reversed) + { GtkRcSet *rc_set; @@ -417,16 +588,31 @@ gtk_rc_styles_match (GSList *sets, sets = sets->next; if (gtk_pattern_match (&rc_set->pspec, path_length, path, path_reversed)) - return rc_set->rc_style; + rc_styles = g_slist_append (rc_styles, rc_set->rc_style); } - return NULL; + return rc_styles; } GtkStyle* gtk_rc_get_style (GtkWidget *widget) { - GtkRcStyle *rc_style; + GtkRcStyle *widget_rc_style; + GSList *rc_styles = NULL; + + static guint rc_style_key_id = 0; + + /* We allow the specification of a single rc style to be bound + * tightly to a widget, for application modifications + */ + if (!rc_style_key_id) + rc_style_key_id = g_quark_from_static_string ("gtk-rc-style"); + + widget_rc_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), + rc_style_key_id); + + if (widget_rc_style) + rc_styles = g_list_prepend (rc_styles, widget_rc_style); if (gtk_rc_sets_widget) { @@ -434,12 +620,10 @@ gtk_rc_get_style (GtkWidget *widget) guint path_length; gtk_widget_path (widget, &path_length, &path, &path_reversed); - rc_style = gtk_rc_styles_match (gtk_rc_sets_widget, path_length, path, path_reversed); + rc_styles = gtk_rc_styles_match (rc_styles, gtk_rc_sets_widget, path_length, path, path_reversed); g_free (path); g_free (path_reversed); - if (rc_style) - return gtk_rc_style_init (rc_style, gtk_widget_get_colormap (widget)); } if (gtk_rc_sets_widget_class) @@ -448,12 +632,9 @@ gtk_rc_get_style (GtkWidget *widget) guint path_length; gtk_widget_class_path (widget, &path_length, &path, &path_reversed); - rc_style = gtk_rc_styles_match (gtk_rc_sets_widget_class, path_length, path, path_reversed); + rc_styles = gtk_rc_styles_match (rc_styles, gtk_rc_sets_widget_class, path_length, path, path_reversed); g_free (path); g_free (path_reversed); - - if (rc_style) - return gtk_rc_style_init (rc_style, gtk_widget_get_colormap (widget)); } if (gtk_rc_sets_class) @@ -471,40 +652,37 @@ gtk_rc_get_style (GtkWidget *widget) path_reversed = g_strdup (path); g_strreverse (path_reversed); - rc_style = gtk_rc_styles_match (gtk_rc_sets_class, path_length, path, path_reversed); + rc_styles = gtk_rc_styles_match (rc_styles, gtk_rc_sets_class, path_length, path, path_reversed); g_free (path_reversed); - if (rc_style) - return gtk_rc_style_init (rc_style, gtk_widget_get_colormap (widget)); - type = gtk_type_parent (type); } } + if (rc_styles) + return gtk_rc_style_init (rc_styles); + return NULL; } static GSList* gtk_rc_add_rc_sets (GSList *slist, - GtkStyle *style, + GtkRcStyle *rc_style, const char *pattern) { - GtkRcStyle *rc_style; + GtkRcStyle *new_style; GtkRcSet *rc_set; guint i; - gtk_style_ref (style); - - rc_style = g_new (GtkRcStyle, 1); - rc_style->name = NULL; - rc_style->font_name = NULL; - rc_style->fontset_name = NULL; + new_style = gtk_rc_style_new (); + *new_style = *rc_style; + new_style->name = g_strdup (rc_style->name); + new_style->font_name = g_strdup (rc_style->font_name); + new_style->fontset_name = g_strdup (rc_style->fontset_name); for (i = 0; i < 5; i++) - rc_style->bg_pixmap_name[i] = NULL; + new_style->bg_pixmap_name[i] = g_strdup (rc_style->bg_pixmap_name[i]); - rc_style->styles = g_list_append (NULL, style); - rc_set = g_new (GtkRcSet, 1); gtk_pattern_spec_init (&rc_set->pspec, pattern); rc_set->rc_style = rc_style; @@ -513,33 +691,33 @@ gtk_rc_add_rc_sets (GSList *slist, } void -gtk_rc_add_widget_name_style (GtkStyle *style, +gtk_rc_add_widget_name_style (GtkRcStyle *rc_style, const gchar *pattern) { - g_return_if_fail (style != NULL); + g_return_if_fail (rc_style != NULL); g_return_if_fail (pattern != NULL); - gtk_rc_sets_widget = gtk_rc_add_rc_sets (gtk_rc_sets_widget, style, pattern); + gtk_rc_sets_widget = gtk_rc_add_rc_sets (gtk_rc_sets_widget, rc_style, pattern); } void -gtk_rc_add_widget_class_style (GtkStyle *style, +gtk_rc_add_widget_class_style (GtkRcStyle *rc_style, const gchar *pattern) { - g_return_if_fail (style != NULL); + g_return_if_fail (rc_style != NULL); g_return_if_fail (pattern != NULL); - gtk_rc_sets_widget_class = gtk_rc_add_rc_sets (gtk_rc_sets_widget_class, style, pattern); + gtk_rc_sets_widget_class = gtk_rc_add_rc_sets (gtk_rc_sets_widget_class, rc_style, pattern); } void -gtk_rc_add_class_style (GtkStyle *style, +gtk_rc_add_class_style (GtkRcStyle *rc_style, const gchar *pattern) { - g_return_if_fail (style != NULL); + g_return_if_fail (rc_style != NULL); g_return_if_fail (pattern != NULL); - gtk_rc_sets_class = gtk_rc_add_rc_sets (gtk_rc_sets_class, style, pattern); + gtk_rc_sets_class = gtk_rc_add_rc_sets (gtk_rc_sets_class, rc_style, pattern); } static void @@ -631,6 +809,36 @@ gtk_rc_parse_any (const gchar *input_name, g_scanner_destroy (scanner); } +static guint +gtk_rc_styles_hash (const GSList *rc_styles) +{ + guint result; + + result = 0; + while (rc_styles) + { + result += (result << 9) + GPOINTER_TO_UINT (rc_styles->data); + rc_styles = rc_styles->next; + } + + return result; +} + +static gint +gtk_rc_styles_compare (const GSList *a, + const GSList *b) +{ + while (a && b) + { + if (a->data != b->data) + return FALSE; + a = a->next; + b = b->next; + } + + return (a == b); +} + static guint gtk_rc_style_hash (const char *name) { @@ -660,94 +868,145 @@ gtk_rc_style_find (const char *name) return rc_style; } +/* Assumes ownership of rc_style */ static GtkStyle * -gtk_rc_style_init (GtkRcStyle *rc_style, GdkColormap *cmap) +gtk_rc_style_to_style (GtkRcStyle *rc_style) { + GtkStyle *style; GdkFont *old_font; - gboolean match_cmap = FALSE; gint i; - GList *tmp_list; - GtkStyle *style = NULL; - GtkRcNode *node; + style = gtk_style_new (); - tmp_list = rc_style->styles; + style->rc_style = rc_style; + + if (rc_style->fontset_name) + { + old_font = style->font; + style->font = gdk_fontset_load (rc_style->fontset_name); + if (style->font) + gdk_font_unref (old_font); + else + style->font = old_font; + } + else if (rc_style->font_name) + { + old_font = style->font; + style->font = gdk_font_load (rc_style->font_name); + if (style->font) + gdk_font_unref (old_font); + else + style->font = old_font; + } + + for (i = 0; i < 5; i++) + { + if (rc_style->color_flags[i] & GTK_RC_FG) + style->fg[i] = rc_style->fg[i]; + if (rc_style->color_flags[i] & GTK_RC_BG) + style->bg[i] = rc_style->bg[i]; + if (rc_style->color_flags[i] & GTK_RC_TEXT) + style->text[i] = rc_style->text[i]; + if (rc_style->color_flags[i] & GTK_RC_BASE) + style->base[i] = rc_style->base[i]; + } - for (i=0; i<5; i++) - if (rc_style->bg_pixmap_name[i]) - match_cmap = TRUE; - - while (tmp_list) + if (rc_style->engine) { - node = (GtkRcNode *)tmp_list->data; + style->engine = rc_style->engine; + gtk_theme_engine_ref (style->engine); + rc_style->engine->rc_style_to_style (style, rc_style); + } - if (!match_cmap || (node->cmap == cmap)) - { - style = node->style; - break; - } + return style; +} + +/* Reuses or frees rc_styles */ +static GtkStyle * +gtk_rc_style_init (GSList *rc_styles) +{ + gint i; + + GtkStyle *style = NULL; + GtkRcStyle *proto_style; + + if (!realized_style_ht) + realized_style_ht = g_hash_table_new ((GHashFunc)gtk_rc_styles_hash, + (GCompareFunc)gtk_rc_styles_compare); + + style = g_hash_table_lookup (realized_style_ht, rc_styles); - tmp_list = tmp_list->next; - } - if (!style) { - node = g_new (GtkRcNode, 1); - style = gtk_style_copy (rc_style->proto_style); - - /* FIXME, this leaks colormaps, but if we don't do this, then we'll - * be screwed, because we identify colormaps by address equality - */ - gdk_colormap_ref (cmap); - - node->style = style; - node->cmap = cmap; + GSList *tmp_styles = rc_styles; - if (rc_style->fontset_name) - { - old_font = style->font; - style->font = gdk_fontset_load (rc_style->fontset_name); - if (style->font) - gdk_font_unref (old_font); - else - style->font = old_font; - } - else if (rc_style->font_name) + proto_style = gtk_rc_style_new (); + + while (tmp_styles) { - old_font = style->font; - style->font = gdk_font_load (rc_style->font_name); - if (style->font) - gdk_font_unref (old_font); - else - style->font = old_font; + GtkRcStyle *rc_style = tmp_styles->data; + + for (i=0; i<5; i++) + { + if (!proto_style->bg_pixmap_name[i] && rc_style->bg_pixmap_name[i]) + proto_style->bg_pixmap_name[i] = g_strdup (rc_style->bg_pixmap_name[i]); + + if (!(proto_style->color_flags[i] & GTK_RC_FG) && + rc_style->color_flags[i] & GTK_RC_FG) + { + proto_style->fg[i] = rc_style->fg[i]; + proto_style->color_flags[i] |= GTK_RC_FG; + } + if (!(proto_style->color_flags[i] & GTK_RC_BG) && + rc_style->color_flags[i] & GTK_RC_BG) + { + proto_style->bg[i] = rc_style->bg[i]; + proto_style->color_flags[i] |= GTK_RC_BG; + } + if (!(proto_style->color_flags[i] & GTK_RC_TEXT) && + rc_style->color_flags[i] & GTK_RC_TEXT) + { + proto_style->text[i] = rc_style->text[i]; + proto_style->color_flags[i] |= GTK_RC_TEXT; + } + if (!(proto_style->color_flags[i] & GTK_RC_BASE) && + rc_style->color_flags[i] & GTK_RC_BASE) + { + proto_style->base[i] = rc_style->base[i]; + proto_style->color_flags[i] |= GTK_RC_BASE; + } + } + + if (!proto_style->font_name && rc_style->font_name) + proto_style->font_name = g_strdup (rc_style->font_name); + if (!proto_style->fontset_name && rc_style->fontset_name) + proto_style->fontset_name = g_strdup (rc_style->fontset_name); + + if (!proto_style->engine && rc_style->engine) + { + proto_style->engine = rc_style->engine; + gtk_theme_engine_ref (proto_style->engine); + } + + if (proto_style->engine && + (proto_style->engine == rc_style->engine)) + proto_style->engine->merge_rc_style (proto_style, rc_style); + + tmp_styles = tmp_styles->next; } - - for (i = 0; i < 5; i++) - if (rc_style->bg_pixmap_name[i]) - { - if (strcmp (rc_style->bg_pixmap_name[i], "<parent>") == 0) - style->bg_pixmap[i] = (GdkPixmap*) GDK_PARENT_RELATIVE; - else - { - if(image_loader) - style->bg_pixmap[i] = image_loader(NULL, cmap, NULL, - &style->bg[i], - rc_style->bg_pixmap_name[i]); - else - style->bg_pixmap[i] = - gdk_pixmap_colormap_create_from_xpm (NULL, cmap, - NULL, - &style->bg[i], - rc_style->bg_pixmap_name[i]); - } - } - - rc_style->styles = g_list_append (rc_style->styles, node); + + style = gtk_rc_style_to_style (proto_style); + + g_hash_table_insert (realized_style_ht, rc_styles, style); } return style; } +/********************* + * Parsing functions * + *********************/ + static guint gtk_rc_parse_statement (GScanner *scanner) { @@ -787,6 +1046,9 @@ gtk_rc_parse_statement (GScanner *scanner) case GTK_RC_TOKEN_CLASS: return gtk_rc_parse_path_pattern (scanner); + case GTK_RC_TOKEN_MODULE_PATH: + return gtk_rc_parse_module_path (scanner); + default: g_scanner_get_next_token (scanner); return /* G_TOKEN_SYMBOL */ GTK_RC_TOKEN_STYLE; @@ -816,16 +1078,17 @@ gtk_rc_parse_style (GScanner *scanner) if (!rc_style) { insert = TRUE; - rc_style = g_new (GtkRcStyle, 1); + rc_style = gtk_rc_style_new (); rc_style->name = g_strdup (scanner->value.v_string); - rc_style->font_name = NULL; - rc_style->fontset_name = NULL; for (i = 0; i < 5; i++) rc_style->bg_pixmap_name[i] = NULL; - rc_style->proto_style = gtk_style_new(); - rc_style->styles = NULL; + for (i = 0; i < 5; i++) + rc_style->color_flags[i] = 0; + + rc_style->engine = NULL; + rc_style->engine_data = NULL; } token = g_scanner_peek_next_token (scanner); @@ -837,10 +1100,8 @@ gtk_rc_parse_style (GScanner *scanner) if (token != G_TOKEN_STRING) { if (insert) - { - gtk_style_unref (rc_style->proto_style); - g_free (rc_style); - } + g_free (rc_style); + return G_TOKEN_STRING; } @@ -849,18 +1110,13 @@ gtk_rc_parse_style (GScanner *scanner) { for (i = 0; i < 5; i++) { - rc_style->proto_style->fg[i] = parent_style->proto_style->fg[i]; - rc_style->proto_style->bg[i] = parent_style->proto_style->bg[i]; - rc_style->proto_style->light[i] = parent_style->proto_style->light[i]; - rc_style->proto_style->dark[i] = parent_style->proto_style->dark[i]; - rc_style->proto_style->mid[i] = parent_style->proto_style->mid[i]; - rc_style->proto_style->text[i] = parent_style->proto_style->text[i]; - rc_style->proto_style->base[i] = parent_style->proto_style->base[i]; + rc_style->color_flags[i] = parent_style->color_flags[i]; + rc_style->fg[i] = parent_style->fg[i]; + rc_style->bg[i] = parent_style->bg[i]; + rc_style->text[i] = parent_style->text[i]; + rc_style->base[i] = parent_style->base[i]; } - rc_style->proto_style->black = parent_style->proto_style->black; - rc_style->proto_style->white = parent_style->proto_style->white; - if (rc_style->fontset_name) { g_free (rc_style->fontset_name); @@ -885,10 +1141,8 @@ gtk_rc_parse_style (GScanner *scanner) if (token != G_TOKEN_LEFT_CURLY) { if (insert) - { - gtk_style_unref (rc_style->proto_style); - g_free (rc_style); - } + g_free (rc_style); + return G_TOKEN_LEFT_CURLY; } @@ -898,16 +1152,16 @@ gtk_rc_parse_style (GScanner *scanner) switch (token) { case GTK_RC_TOKEN_BASE: - token = gtk_rc_parse_base (scanner, rc_style->proto_style); + token = gtk_rc_parse_base (scanner, rc_style); break; case GTK_RC_TOKEN_BG: - token = gtk_rc_parse_bg (scanner, rc_style->proto_style); + token = gtk_rc_parse_bg (scanner, rc_style); break; case GTK_RC_TOKEN_FG: - token = gtk_rc_parse_fg (scanner, rc_style->proto_style); + token = gtk_rc_parse_fg (scanner, rc_style); break; case GTK_RC_TOKEN_TEXT: - token = gtk_rc_parse_text (scanner, rc_style->proto_style); + token = gtk_rc_parse_text (scanner, rc_style); break; case GTK_RC_TOKEN_BG_PIXMAP: token = gtk_rc_parse_bg_pixmap (scanner, rc_style); @@ -918,6 +1172,9 @@ gtk_rc_parse_style (GScanner *scanner) case GTK_RC_TOKEN_FONTSET: token = gtk_rc_parse_fontset (scanner, rc_style); break; + case GTK_RC_TOKEN_ENGINE: + token = gtk_rc_parse_engine (scanner, rc_style); + break; default: g_scanner_get_next_token (scanner); token = G_TOKEN_RIGHT_CURLY; @@ -935,7 +1192,6 @@ gtk_rc_parse_style (GScanner *scanner) for (i = 0; i < 5; i++) if (rc_style->bg_pixmap_name[i]) g_free (rc_style->bg_pixmap_name[i]); - gtk_style_unref (rc_style->proto_style); g_free (rc_style); } return token; @@ -957,7 +1213,6 @@ gtk_rc_parse_style (GScanner *scanner) if (rc_style->bg_pixmap_name[i]) g_free (rc_style->bg_pixmap_name[i]); - gtk_style_unref (rc_style->proto_style); g_free (rc_style); } return G_TOKEN_RIGHT_CURLY; @@ -970,8 +1225,8 @@ gtk_rc_parse_style (GScanner *scanner) } static guint -gtk_rc_parse_base (GScanner *scanner, - GtkStyle *style) +gtk_rc_parse_base (GScanner *scanner, + GtkRcStyle *style) { GtkStateType state; guint token; @@ -987,13 +1242,14 @@ gtk_rc_parse_base (GScanner *scanner, token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_EQUAL_SIGN) return G_TOKEN_EQUAL_SIGN; - + + style->color_flags[state] |= GTK_RC_BASE; return gtk_rc_parse_color (scanner, &style->base[state]); } static guint -gtk_rc_parse_bg (GScanner *scanner, - GtkStyle *style) +gtk_rc_parse_bg (GScanner *scanner, + GtkRcStyle *style) { GtkStateType state; guint token; @@ -1009,13 +1265,14 @@ gtk_rc_parse_bg (GScanner *scanner, token = g_scanner_get_next_token (scanner); if (token != G_TOKEN_EQUAL_SIGN) return G_TOKEN_EQUAL_SIGN; - + + style->color_flags[state] |= GTK_RC_BG; return gtk_rc_parse_color (scanner, &style->bg[state]); } static guint -gtk_rc_parse_fg (GScanner *scanner, - GtkStyle *style) +gtk_rc_parse_fg (GScanner *scanner, + GtkRcStyle *style) { GtkStateType state; guint token; @@ -1032,12 +1289,13 @@ gtk_rc_parse_fg (GScanner *scanner, if (token != G_TOKEN_EQUAL_SIGN) return G_TOKEN_EQUAL_SIGN; + style->color_flags[state] |= GTK_RC_FG; return gtk_rc_parse_color (scanner, &style->fg[state]); } static guint -gtk_rc_parse_text (GScanner *scanner, - GtkStyle *style) +gtk_rc_parse_text (GScanner *scanner, + GtkRcStyle *style) { GtkStateType state; guint token; @@ -1054,6 +1312,7 @@ gtk_rc_parse_text (GScanner *scanner, if (token != G_TOKEN_EQUAL_SIGN) return G_TOKEN_EQUAL_SIGN; + style->color_flags[state] |= GTK_RC_TEXT; return gtk_rc_parse_color (scanner, &style->text[state]); } @@ -1096,7 +1355,7 @@ gtk_rc_parse_bg_pixmap (GScanner *scanner, return G_TOKEN_NONE; } -static gchar* +gchar* gtk_rc_find_pixmap_in_path (GScanner *scanner, gchar *pixmap_file) { @@ -1118,10 +1377,47 @@ gtk_rc_find_pixmap_in_path (GScanner *scanner, g_free (buf); } + + if (scanner) + g_warning ("Unable to locate image file in pixmap_path: \"%s\" line %d", + pixmap_file, scanner->line); + else + g_warning ("Unable to locate image file in pixmap_path: \"%s\"", + pixmap_file); + + return NULL; +} + +gchar* +gtk_rc_find_module_in_path (GScanner *scanner, + gchar *module_file) +{ + gint i; + gint fd; + gchar *buf; - g_warning ("Unable to locate image file in pixmap_path: \"%s\" line %d", - pixmap_file, scanner->line); + for (i = 0; (i < GTK_RC_MAX_MODULE_PATHS) && (module_path[i] != NULL); i++) + { + buf = g_malloc (strlen (module_path[i]) + strlen (module_file) + 2); + sprintf (buf, "%s%c%s", module_path[i], '/', module_file); + + fd = open (buf, O_RDONLY); + if (fd >= 0) + { + close (fd); + return buf; + } + + g_free (buf); + } + if (scanner) + g_warning ("Unable to locate loadable module in module_path: \"%s\" line %d", + module_file, scanner->line); + else + g_warning ("Unable to locate loadable module in module_path: \"%s\",", + module_file); + return NULL; } @@ -1175,6 +1471,48 @@ gtk_rc_parse_fontset (GScanner *scanner, return G_TOKEN_NONE; } +static guint +gtk_rc_parse_engine (GScanner *scanner, + GtkRcStyle *rc_style) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != GTK_RC_TOKEN_ENGINE) + return GTK_RC_TOKEN_ENGINE; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + rc_style->engine = gtk_theme_engine_get (scanner->value.v_string); + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_LEFT_CURLY) + return G_TOKEN_LEFT_CURLY; + + if (rc_style->engine) + return rc_style->engine->parse_rc_style (scanner, rc_style); + else + { + /* Skip over remainder, looking for nested {}'s */ + guint count = 1; + + while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF) + { + if (token == G_TOKEN_LEFT_CURLY) + count++; + else if (token == G_TOKEN_RIGHT_CURLY) + count--; + + if (count == 0) + return G_TOKEN_NONE; + } + + return G_TOKEN_RIGHT_CURLY; + } +} + guint gtk_rc_parse_state (GScanner *scanner, GtkStateType *state) @@ -1443,6 +1781,63 @@ gtk_rc_parse_pixmap_path_string (gchar *pix_path) } } g_free (buf); + gtk_rc_append_default_pixmap_path(); +} + +static guint +gtk_rc_parse_module_path (GScanner *scanner) +{ + guint token; + + token = g_scanner_get_next_token (scanner); + if (token != GTK_RC_TOKEN_MODULE_PATH) + return GTK_RC_TOKEN_MODULE_PATH; + + token = g_scanner_get_next_token (scanner); + if (token != G_TOKEN_STRING) + return G_TOKEN_STRING; + + gtk_rc_parse_module_path_string (scanner->value.v_string); + + return G_TOKEN_NONE; +} + +static void +gtk_rc_parse_module_path_string (gchar *mod_path) +{ + gchar *buf; + gint end_offset; + gint start_offset = 0; + gint path_len; + gint path_num; + + /* free the old one, or just add to the old one ? */ + for (path_num=0; module_path[path_num]; path_num++) + { + g_free (module_path[path_num]); + module_path[path_num] = NULL; + } + + path_num = 0; + + path_len = strlen (mod_path); + + buf = g_strdup (mod_path); + + for (end_offset = 0; end_offset <= path_len; end_offset++) + { + if ((buf[end_offset] == ':') || + (end_offset == path_len)) + { + buf[end_offset] = '\0'; + module_path[path_num] = g_strdup (buf + start_offset); + path_num++; + module_path[path_num] = NULL; + start_offset = end_offset + 1; + } + } + g_free (buf); + gtk_rc_append_default_module_path(); } static guint @@ -1557,6 +1952,25 @@ typedef GdkPixmap * (*GtkImageLoader) (GdkWindow *window, void gtk_rc_set_image_loader(GtkImageLoader loader) { - image_loader = loader; + image_loader = loader; } +GdkPixmap * +gtk_rc_load_image (GdkColormap *colormap, + GdkColor *transparent_color, + const gchar *filename) +{ + if (strcmp (filename, "<parent>") == 0) + return (GdkPixmap*) GDK_PARENT_RELATIVE; + else + { + if(image_loader) + return image_loader(NULL, colormap, NULL, + transparent_color, + filename); + else + return gdk_pixmap_colormap_create_from_xpm (NULL, colormap, NULL, + transparent_color, + filename); + } +} diff --git a/gtk/gtkrc.h b/gtk/gtkrc.h index 39bb324f08..8600f2138e 100644 --- a/gtk/gtkrc.h +++ b/gtk/gtkrc.h @@ -23,25 +23,52 @@ #include <gtk/gtkstyle.h> #include <gtk/gtkwidget.h> - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +typedef enum { + GTK_RC_FG = 1 << 0, + GTK_RC_BG = 1 << 1, + GTK_RC_TEXT = 1 << 2, + GTK_RC_BASE = 1 << 3 +} GtkRcFlags; + +struct _GtkRcStyle +{ + char *name; + char *font_name; + char *fontset_name; + char *bg_pixmap_name[5]; + + GtkRcFlags color_flags[5]; + GdkColor fg[5]; + GdkColor bg[5]; + GdkColor text[5]; + GdkColor base[5]; + + GtkThemeEngine *engine; + gpointer engine_data; + + /* Private */ + guint ref_count; +}; void gtk_rc_init (void); void gtk_rc_parse (const gchar *filename); void gtk_rc_parse_string (const gchar *rc_string); gboolean gtk_rc_reparse_all (void); GtkStyle* gtk_rc_get_style (GtkWidget *widget); -void gtk_rc_add_widget_name_style (GtkStyle *style, +void gtk_rc_add_widget_name_style (GtkRcStyle *rc_style, const gchar *pattern); -void gtk_rc_add_widget_class_style (GtkStyle *style, +void gtk_rc_add_widget_class_style (GtkRcStyle *rc_style, const gchar *pattern); -void gtk_rc_add_class_style (GtkStyle *style, +void gtk_rc_add_class_style (GtkRcStyle *rc_style, const gchar *pattern); - +GtkRcStyle *gtk_rc_style_new (void); +void gtk_rc_style_ref (GtkRcStyle *rc_style); +void gtk_rc_style_unref (GtkRcStyle *rc_style); /* Tell gtkrc to use a custom routine to load images specified in rc files instead of * the default xpm-only loader @@ -53,6 +80,15 @@ typedef GdkPixmap * (*GtkImageLoader) (GdkWindow *window, const gchar *filename); void gtk_rc_set_image_loader(GtkImageLoader loader); +GdkPixmap *gtk_rc_load_image (GdkColormap *colormap, + GdkColor *transparent_color, + const gchar *filename); +gchar *gtk_rc_find_pixmap_in_path (GScanner *scanner, + gchar *pixmap_file); +gchar *gtk_rc_find_module_in_path (GScanner *scanner, + gchar *module_file); +gchar *gtk_rc_get_theme_dir(void); +gchar *gtk_rc_get_module_dir(void); /* private functions/definitions */ typedef enum { @@ -82,6 +118,8 @@ typedef enum { GTK_RC_TOKEN_APPLICATION, GTK_RC_TOKEN_RC, GTK_RC_TOKEN_HIGHEST, + GTK_RC_TOKEN_ENGINE, + GTK_RC_TOKEN_MODULE_PATH, GTK_RC_TOKEN_LAST } GtkRcTokenType; diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index c43d7ed9d7..2b25500f04 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -249,26 +249,20 @@ gtk_ruler_expose (GtkWidget *widget, { ruler = GTK_RULER (widget); - gdk_draw_rectangle (ruler->backing_store, - widget->style->bg_gc[GTK_STATE_NORMAL], - TRUE, 0, 0, - widget->allocation.width, - widget->allocation.height); - + gtk_paint_box (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "ruler", + 0, 0, -1, -1); + gtk_ruler_draw_ticks (ruler); - - gtk_draw_shadow (widget->style, ruler->backing_store, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, 0, 0, - widget->allocation.width, - widget->allocation.height); - + gdk_draw_pixmap (widget->window, ruler->non_gr_exp_gc, ruler->backing_store, 0, 0, 0, 0, widget->allocation.width, widget->allocation.height); - + gtk_ruler_draw_pos (ruler); } diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index 7592f1aecf..9992160a44 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -26,6 +26,9 @@ static void gtk_scale_class_init (GtkScaleClass *klass); static void gtk_scale_init (GtkScale *scale); +static void gtk_scale_map (GtkWidget *widget); +static void gtk_scale_unmap (GtkWidget *widget); + static void gtk_scale_draw_background (GtkRange *range); @@ -61,13 +64,18 @@ static void gtk_scale_class_init (GtkScaleClass *class) { GtkObjectClass *object_class; + GtkWidgetClass *widget_class; GtkRangeClass *range_class; object_class = (GtkObjectClass*) class; range_class = (GtkRangeClass*) class; + widget_class = (GtkWidgetClass*) class; parent_class = gtk_type_class (gtk_range_get_type ()); + widget_class->map = gtk_scale_map; + widget_class->unmap = gtk_scale_unmap; + range_class->draw_background = gtk_scale_draw_background; class->slider_length = 31; @@ -79,11 +87,46 @@ static void gtk_scale_init (GtkScale *scale) { GTK_WIDGET_SET_FLAGS (scale, GTK_CAN_FOCUS); + GTK_WIDGET_SET_FLAGS (scale, GTK_NO_WINDOW); GTK_RANGE (scale)->digits = 1; scale->draw_value = TRUE; scale->value_pos = GTK_POS_TOP; } +static void +gtk_scale_map (GtkWidget *widget) +{ + GtkRange *range; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_SCALE (widget)); + + GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); + range = GTK_RANGE (widget); + + if (GTK_WIDGET_NO_WINDOW (widget)) + gtk_widget_queue_draw (widget); + + gdk_window_show (range->trough); +} + +static void +gtk_scale_unmap (GtkWidget *widget) +{ + GtkRange *range; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_SCALE (widget)); + + GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); + range = GTK_RANGE (widget); + + if (GTK_WIDGET_NO_WINDOW (widget)) + gtk_widget_queue_clear (widget); + + gdk_window_hide (range->trough); +} + void gtk_scale_set_digits (GtkScale *scale, gint digits) diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index c4dcf5168a..3cb6889f31 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -499,15 +499,21 @@ gtk_spin_button_paint (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) { if (spin->shadow_type != GTK_SHADOW_NONE) - gtk_draw_shadow (widget->style, spin->panel, - GTK_STATE_NORMAL, spin->shadow_type, - 0, 0, - ARROW_SIZE + 2 * widget->style->klass->xthickness, - widget->requisition.height); - gtk_spin_button_draw_arrow (spin, GTK_ARROW_UP); - gtk_spin_button_draw_arrow (spin, GTK_ARROW_DOWN); - - GTK_WIDGET_CLASS (parent_class)->draw (widget, area); + gtk_paint_box (widget->style, spin->panel, + GTK_STATE_NORMAL, spin->shadow_type, + area, widget, "spinbutton", + 0, 0, + ARROW_SIZE + 2 * widget->style->klass->xthickness, + widget->requisition.height); + else + { + gdk_window_set_back_pixmap (spin->panel, NULL, TRUE); + gdk_window_clear_area (spin->panel, area->x, area->y, area->width, area->height); + } + gtk_spin_button_draw_arrow (spin, GTK_ARROW_UP); + gtk_spin_button_draw_arrow (spin, GTK_ARROW_DOWN); + + GTK_WIDGET_CLASS (parent_class)->draw (widget, area); } } @@ -581,10 +587,12 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, x = widget->style->klass->xthickness - 1; y = widget->style->klass->ythickness - 1; } - gtk_draw_arrow (widget->style, spin_button->panel, - state_type, shadow_type, arrow, TRUE, - x, y, ARROW_SIZE, widget->requisition.height / 2 - - widget->style->klass->ythickness); + gtk_paint_arrow (widget->style, spin_button->panel, + state_type, shadow_type, + NULL, widget, "spinbutton", + arrow, TRUE, + x, y, ARROW_SIZE, widget->requisition.height / 2 + - widget->style->klass->ythickness); } else { @@ -598,10 +606,12 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, x = widget->style->klass->xthickness - 1; y = widget->requisition.height / 2 + 1; } - gtk_draw_arrow (widget->style, spin_button->panel, - state_type, shadow_type, arrow, TRUE, - x, y, ARROW_SIZE, widget->requisition.height / 2 - - widget->style->klass->ythickness); + gtk_paint_arrow (widget->style, spin_button->panel, + state_type, shadow_type, + NULL, widget, "spinbutton", + arrow, TRUE, + x, y, ARROW_SIZE, widget->requisition.height / 2 + - widget->style->klass->ythickness); } } } diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 98fe667589..8f4fc5f614 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -18,57 +18,38 @@ */ #include <math.h> #include "gtkgc.h" +#include "gtkrc.h" #include "gtkstyle.h" +#include "gtkthemes.h" #include "gtkwidget.h" +#include "gtkthemes.h" +#include "gtkprivate.h" +#include "gdk/gdkprivate.h" #define LIGHTNESS_MULT 1.3 #define DARKNESS_MULT 0.7 - -typedef struct _GtkStyleKey GtkStyleKey; - -struct _GtkStyleKey -{ - GdkColor fg[5]; - GdkColor bg[5]; - GdkColor text[5]; - GdkColor base[5]; - - GdkPixmap *bg_pixmap[5]; - - GdkFont *font; - - gint depth; - GdkColormap *colormap; - GtkStyleClass *klass; -}; - - -static void gtk_style_init (GtkStyle *style); -static void gtk_styles_init (void); -static void gtk_style_remove (GtkStyle *style); -static GtkStyle* gtk_style_find (GtkStyle *style, - GdkColormap *cmap, +static void gtk_style_init (GtkStyle *style, + GdkColormap *colormap, gint depth); -static GtkStyle* gtk_style_new_from_key (GtkStyleKey *key); -static GtkStyleKey* gtk_style_key_dup (GtkStyleKey *key); static void gtk_style_destroy (GtkStyle *style); -static void gtk_style_key_destroy (GtkStyleKey *key); -static guint gtk_style_key_hash (GtkStyleKey *key); -static guint gtk_style_value_hash (GtkStyle *style); -static gint gtk_style_key_compare (GtkStyleKey *a, - GtkStyleKey *b); static void gtk_default_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x1, gint x2, gint y); static void gtk_default_draw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint y1, gint y2, gint x); @@ -76,6 +57,20 @@ static void gtk_default_draw_shadow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -84,15 +79,21 @@ static void gtk_default_draw_polygon (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GdkPoint *points, gint npoints, - gint fill); + gboolean fill); static void gtk_default_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -101,6 +102,9 @@ static void gtk_default_draw_diamond (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -109,6 +113,9 @@ static void gtk_default_draw_oval (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -116,28 +123,200 @@ static void gtk_default_draw_oval (GtkStyle *style, static void gtk_default_draw_string (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, const gchar *string); +static void gtk_default_draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +static void gtk_default_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +static void gtk_default_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); +static void gtk_default_draw_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +static void gtk_default_draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +static void gtk_default_draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); + static void gtk_style_shade (GdkColor *a, GdkColor *b, gdouble k); static void rgb_to_hls (gdouble *r, gdouble *g, gdouble *b); static void hls_to_rgb (gdouble *h, gdouble *l, gdouble *s); +static void gtk_reset_window_and_children(GtkWidget *widget, + GdkWindow *window); + -static GtkStyleClass default_class = +GtkStyleClass default_class = { - 2, - 2, - gtk_default_draw_hline, - gtk_default_draw_vline, - gtk_default_draw_shadow, - gtk_default_draw_polygon, - gtk_default_draw_arrow, - gtk_default_draw_diamond, - gtk_default_draw_oval, - gtk_default_draw_string, + 2, + 2, + gtk_default_draw_hline, + gtk_default_draw_vline, + gtk_default_draw_shadow, + gtk_default_draw_polygon, + gtk_default_draw_arrow, + gtk_default_draw_diamond, + gtk_default_draw_oval, + gtk_default_draw_string, + gtk_default_draw_box, + gtk_default_draw_flat_box, + gtk_default_draw_check, + gtk_default_draw_option, + gtk_default_draw_cross, + gtk_default_draw_ramp, + gtk_default_draw_tab, + gtk_default_draw_shadow_gap, + gtk_default_draw_box_gap, + gtk_default_draw_extension, + gtk_default_draw_focus, + gtk_default_draw_slider, + gtk_default_draw_handle }; +GdkFont *default_font = NULL; static GdkColor gtk_default_normal_fg = { 0, 0, 0, 0 }; static GdkColor gtk_default_active_fg = { 0, 0, 0, 0 }; @@ -151,13 +330,43 @@ static GdkColor gtk_default_prelight_bg = { 0, 0xea60, 0xea60, 0xea60 }; static GdkColor gtk_default_selected_bg = { 0, 0, 0, 0x9c40 }; static GdkColor gtk_default_insensitive_bg = { 0, 0xd6d6, 0xd6d6, 0xd6d6 }; -static GdkFont *default_font = NULL; +static void +gtk_reset_window_and_children(GtkWidget *widget, GdkWindow *window) +{ + GdkWindowPrivate *private; + guint i, num; + GList *list; + gpointer data; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate *)window; + + if (private->destroyed) + return; + gdk_window_get_user_data(window, &data); + if ((data) && (data != widget)) + return; + gdk_window_shape_combine_mask(window, NULL, 0, 0); + if (private->children) + { + num = g_list_length(private->children); + for(i = 0; i < num; i++) + { + list = g_list_nth(private->children, i); + gtk_reset_window_and_children(widget, (GdkWindow *)list->data); + } + } +} -static gint initialize = TRUE; -static GCache *style_cache = NULL; -static GSList *unattached_styles = NULL; +void +gtk_reset_widget_shapes(GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); -static GMemChunk *key_mem_chunk = NULL; + if (!GTK_WIDGET_HAS_SHAPE_MASK(GTK_OBJECT(widget))) + gtk_reset_window_and_children(widget, widget->window); +} GtkStyle* gtk_style_copy (GtkStyle *style) @@ -185,6 +394,33 @@ gtk_style_copy (GtkStyle *style) return new_style; } +static GtkStyle* +gtk_style_duplicate (GtkStyle *style) +{ + GtkStyle *new_style; + + g_return_val_if_fail (style != NULL, NULL); + + new_style = gtk_style_copy (style); + + style->styles = g_slist_append (style->styles, new_style); + new_style->styles = style->styles; + + if (style->rc_style) + { + new_style->rc_style = style->rc_style; + gtk_rc_style_ref (style->rc_style); + } + + if (style->engine) + { + new_style->engine = style->engine; + new_style->engine->duplicate_style (new_style, style); + } + + return new_style; +} + GtkStyle* gtk_style_new (void) { @@ -241,6 +477,11 @@ gtk_style_new (void) for (i = 0; i < 5; i++) style->bg_pixmap[i] = NULL; + style->engine = NULL; + style->engine_data = NULL; + + style->rc_style = NULL; + for (i = 0; i < 5; i++) { style->fg_gc[i] = NULL; @@ -252,16 +493,15 @@ gtk_style_new (void) style->base_gc[i] = NULL; } - unattached_styles = g_slist_prepend (unattached_styles, style); - return style; } -GtkStyle* +GtkStyle * gtk_style_attach (GtkStyle *style, GdkWindow *window) { - GtkStyle *new_style; + GSList *styles; + GtkStyle *new_style = NULL; GdkColormap *colormap; gint depth; @@ -271,21 +511,41 @@ gtk_style_attach (GtkStyle *style, colormap = gdk_window_get_colormap (window); depth = gdk_window_get_visual (window)->depth; - new_style = gtk_style_find (style, colormap, depth); + if (!style->styles) + style->styles = g_slist_append (NULL, style); - if (new_style && (new_style != style)) + styles = style->styles; + while (styles) { - gtk_style_unref (style); - style = new_style; - gtk_style_ref (style); + new_style = styles->data; + + if (new_style->attach_count == 0) + { + gtk_style_init (new_style, colormap, depth); + break; + } + else if ((new_style->colormap == colormap) && + (new_style->depth == depth)) + break; + + new_style = NULL; + styles = styles->next; } - if (style->attach_count == 0) - unattached_styles = g_slist_remove (unattached_styles, style); + if (!new_style) + { + new_style = gtk_style_duplicate (style); + gtk_style_init (new_style, colormap, depth); + } - style->attach_count += 1; + if (new_style->attach_count == 0) + gtk_style_ref (new_style); - return style; + + + new_style->attach_count++; + + return new_style; } void @@ -298,14 +558,12 @@ gtk_style_detach (GtkStyle *style) style->attach_count -= 1; if (style->attach_count == 0) { - unattached_styles = g_slist_prepend (unattached_styles, style); + if (style->engine) + style->engine->unrealize_style (style); gtk_gc_release (style->black_gc); gtk_gc_release (style->white_gc); - - style->black_gc = NULL; - style->white_gc = NULL; - + for (i = 0; i < 5; i++) { gtk_gc_release (style->fg_gc[i]); @@ -315,21 +573,10 @@ gtk_style_detach (GtkStyle *style) gtk_gc_release (style->mid_gc[i]); gtk_gc_release (style->text_gc[i]); gtk_gc_release (style->base_gc[i]); - - style->fg_gc[i] = NULL; - style->bg_gc[i] = NULL; - style->light_gc[i] = NULL; - style->dark_gc[i] = NULL; - style->mid_gc[i] = NULL; - style->text_gc[i] = NULL; - style->base_gc[i] = NULL; } - style->depth = -1; - style->colormap = NULL; + gtk_style_unref (style); } - - gtk_style_remove (style); } GtkStyle* @@ -351,6 +598,137 @@ gtk_style_unref (GtkStyle *style) gtk_style_destroy (style); } +static void +gtk_style_init (GtkStyle *style, + GdkColormap *colormap, + gint depth) +{ + GdkGCValues gc_values; + GdkGCValuesMask gc_values_mask; + gint i; + + g_return_if_fail (style != NULL); + + style->colormap = colormap; + style->depth = depth; + + for (i = 0; i < 5; i++) + { + gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT); + gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT); + + style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2; + style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2; + style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2; + } + + gdk_color_black (colormap, &style->black); + gdk_color_white (colormap, &style->white); + + gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT; + if (style->font->type == GDK_FONT_FONT) + { + gc_values.font = style->font; + } + else if (style->font->type == GDK_FONT_FONTSET) + { + gc_values.font = default_font; + } + + gc_values.foreground = style->black; + style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->white; + style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + for (i = 0; i < 5; i++) + { + if (style->rc_style && style->rc_style->bg_pixmap_name[i]) + style->bg_pixmap[i] = gtk_rc_load_image (style->colormap, + &style->bg[i], + style->rc_style->bg_pixmap_name[i]); + + if (!gdk_color_alloc (colormap, &style->fg[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->fg[i].red, style->fg[i].green, style->fg[i].blue); + if (!gdk_color_alloc (colormap, &style->bg[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->bg[i].red, style->bg[i].green, style->bg[i].blue); + if (!gdk_color_alloc (colormap, &style->light[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->light[i].red, style->light[i].green, style->light[i].blue); + if (!gdk_color_alloc (colormap, &style->dark[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->dark[i].red, style->dark[i].green, style->dark[i].blue); + if (!gdk_color_alloc (colormap, &style->mid[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->mid[i].red, style->mid[i].green, style->mid[i].blue); + if (!gdk_color_alloc (colormap, &style->text[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->text[i].red, style->text[i].green, style->text[i].blue); + if (!gdk_color_alloc (colormap, &style->base[i])) + g_warning ("unable to allocate color: ( %d %d %d )", + style->base[i].red, style->base[i].green, style->base[i].blue); + + gc_values.foreground = style->fg[i]; + style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->bg[i]; + style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->light[i]; + style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->dark[i]; + style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->mid[i]; + style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->text[i]; + style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + + gc_values.foreground = style->base[i]; + style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); + } + if (style->engine) + style->engine->realize_style (style); +} + +static void +gtk_style_destroy (GtkStyle *style) +{ + g_return_if_fail (style->attach_count == 0); + + if (style->styles) + { + if (style->styles->data != style) + g_slist_remove (style->styles, style); + else + { + GSList *tmp_list = style->styles->next; + while (tmp_list) + { + ((GtkStyle *)tmp_list->data)->styles = style->styles->next; + tmp_list = tmp_list->next; + } + g_slist_free_1 (style->styles); + } + } + + if (style->engine) + { + style->engine->destroy_style (style); + gtk_theme_engine_unref (style->engine); + } + + gdk_font_unref (style->font); + if (style->rc_style) + gtk_rc_style_unref (style->rc_style); + + g_free (style); +} + void gtk_style_set_background (GtkStyle *style, GdkWindow *window, @@ -359,8 +737,14 @@ gtk_style_set_background (GtkStyle *style, GdkPixmap *pixmap; gint parent_relative; - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); + if (style->engine && style->engine->set_background) + { + (*style->engine->set_background) (style, window, state_type); + return; + } + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); if (style->bg_pixmap[state_type]) { @@ -394,7 +778,7 @@ gtk_draw_hline (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_hline != NULL); - (*style->klass->draw_hline) (style, window, state_type, x1, x2, y); + (*style->klass->draw_hline) (style, window, state_type, NULL, NULL, NULL, x1, x2, y); } @@ -410,7 +794,7 @@ gtk_draw_vline (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_vline != NULL); - (*style->klass->draw_vline) (style, window, state_type, y1, y2, x); + (*style->klass->draw_vline) (style, window, state_type, NULL, NULL, NULL, y1, y2, x); } @@ -428,7 +812,7 @@ gtk_draw_shadow (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_shadow != NULL); - (*style->klass->draw_shadow) (style, window, state_type, shadow_type, x, y, width, height); + (*style->klass->draw_shadow) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } void @@ -438,13 +822,13 @@ gtk_draw_polygon (GtkStyle *style, GtkShadowType shadow_type, GdkPoint *points, gint npoints, - gint fill) + gboolean fill) { g_return_if_fail (style != NULL); g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_shadow != NULL); - (*style->klass->draw_polygon) (style, window, state_type, shadow_type, points, npoints, fill); + (*style->klass->draw_polygon) (style, window, state_type, shadow_type, NULL, NULL, NULL, points, npoints, fill); } void @@ -453,7 +837,7 @@ gtk_draw_arrow (GtkStyle *style, GtkStateType state_type, GtkShadowType shadow_type, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -463,7 +847,7 @@ gtk_draw_arrow (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_arrow != NULL); - (*style->klass->draw_arrow) (style, window, state_type, shadow_type, arrow_type, fill, x, y, width, height); + (*style->klass->draw_arrow) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, fill, x, y, width, height); } @@ -481,7 +865,7 @@ gtk_draw_diamond (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_diamond != NULL); - (*style->klass->draw_diamond) (style, window, state_type, shadow_type, x, y, width, height); + (*style->klass->draw_diamond) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } @@ -499,7 +883,7 @@ gtk_draw_oval (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_oval != NULL); - (*style->klass->draw_oval) (style, window, state_type, shadow_type, x, y, width, height); + (*style->klass->draw_oval) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } void @@ -514,466 +898,345 @@ gtk_draw_string (GtkStyle *style, g_return_if_fail (style->klass != NULL); g_return_if_fail (style->klass->draw_oval != NULL); - (*style->klass->draw_string) (style, window, state_type, x, y, string); + (*style->klass->draw_string) (style, window, state_type, NULL, NULL, NULL, x, y, string); } - -static void -gtk_style_init (GtkStyle *style) +void +gtk_draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - GdkGCValues gc_values; - GdkGCValuesMask gc_values_mask; - GdkColormap *colormap; - gint i; - - g_return_if_fail (style != NULL); - - if (style->attach_count == 0) - { - for (i = 0; i < 5; i++) - { - gtk_style_shade (&style->bg[i], &style->light[i], LIGHTNESS_MULT); - gtk_style_shade (&style->bg[i], &style->dark[i], DARKNESS_MULT); - - style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2; - style->mid[i].green = (style->light[i].green + style->dark[i].green) / 2; - style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2; - } - - colormap = style->colormap; + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box != NULL); - gdk_color_black (colormap, &style->black); - gdk_color_white (colormap, &style->white); - - gc_values_mask = GDK_GC_FOREGROUND | GDK_GC_FONT; - if (style->font->type == GDK_FONT_FONT) - { - gc_values.font = style->font; - } - else if (style->font->type == GDK_FONT_FONTSET) - { - gc_values.font = default_font; - } - - gc_values.foreground = style->black; - style->black_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->white; - style->white_gc = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - for (i = 0; i < 5; i++) - { - if (!gdk_color_alloc (colormap, &style->fg[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->fg[i].red, style->fg[i].green, style->fg[i].blue); - if (!gdk_color_alloc (colormap, &style->bg[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->bg[i].red, style->bg[i].green, style->bg[i].blue); - if (!gdk_color_alloc (colormap, &style->light[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->light[i].red, style->light[i].green, style->light[i].blue); - if (!gdk_color_alloc (colormap, &style->dark[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->dark[i].red, style->dark[i].green, style->dark[i].blue); - if (!gdk_color_alloc (colormap, &style->mid[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->mid[i].red, style->mid[i].green, style->mid[i].blue); - if (!gdk_color_alloc (colormap, &style->text[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->text[i].red, style->text[i].green, style->text[i].blue); - if (!gdk_color_alloc (colormap, &style->base[i])) - g_warning ("unable to allocate color: ( %d %d %d )", - style->base[i].red, style->base[i].green, style->base[i].blue); - - gc_values.foreground = style->fg[i]; - style->fg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->bg[i]; - style->bg_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->light[i]; - style->light_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->dark[i]; - style->dark_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->mid[i]; - style->mid_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->text[i]; - style->text_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - - gc_values.foreground = style->base[i]; - style->base_gc[i] = gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); - } - } + (*style->klass->draw_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } -static void -gtk_styles_init (void) +void +gtk_draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - if (initialize) - { - initialize = FALSE; - - style_cache = g_cache_new ((GCacheNewFunc) gtk_style_new_from_key, - (GCacheDestroyFunc) gtk_style_unref, - (GCacheDupFunc) gtk_style_key_dup, - (GCacheDestroyFunc) gtk_style_key_destroy, - (GHashFunc) gtk_style_key_hash, - (GHashFunc) gtk_style_value_hash, - (GCompareFunc) gtk_style_key_compare); - } + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_flat_box != NULL); + + (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } -static void -gtk_style_remove (GtkStyle *style) +void +gtk_draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - if (initialize) - gtk_styles_init (); - g_cache_remove (style_cache, style); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_check != NULL); + + (*style->klass->draw_check) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } -static GtkStyle* -gtk_style_find (GtkStyle *style, - GdkColormap *cmap, - gint depth) +void +gtk_draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - GtkStyleKey key; - gint i; - - if (initialize) - gtk_styles_init (); - - for (i = 0; i < 5; i++) - { - key.fg[i] = style->fg[i]; - key.bg[i] = style->bg[i]; - key.text[i] = style->text[i]; - key.base[i] = style->base[i]; - key.bg_pixmap[i] = style->bg_pixmap[i]; - } - - key.font = style->font; - key.klass = style->klass; - key.depth = depth; - key.colormap = cmap; - - style = g_cache_insert (style_cache, &key); - - return style; + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_option != NULL); + + (*style->klass->draw_option) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); } -static GtkStyle* -gtk_style_new_from_key (GtkStyleKey *key) +void +gtk_draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - GtkStyle *style; - GSList *list; - gint i; - - style = NULL; - list = unattached_styles; - - while (list) - { - style = list->data; - list = list->next; - - if ((style->depth != -1) && (style->depth != key->depth)) - { - style = NULL; - continue; - } - if (style->colormap && (style->colormap != key->colormap)) - { - style = NULL; - continue; - } - if (style->klass != key->klass) - { - style = NULL; - continue; - } - if (!gdk_font_equal (style->font, key->font)) - { - style = NULL; - continue; - } - - for (i = 0; style && (i < 5); i++) - { - if (style->bg_pixmap[i] != key->bg_pixmap[i]) - { - style = NULL; - continue; - } - - if ((style->fg[i].red != key->fg[i].red) || - (style->fg[i].green != key->fg[i].green) || - (style->fg[i].blue != key->fg[i].blue)) - { - style = NULL; - continue; - } - - if ((style->bg[i].red != key->bg[i].red) || - (style->bg[i].green != key->bg[i].green) || - (style->bg[i].blue != key->bg[i].blue)) - { - style = NULL; - continue; - } - - if ((style->text[i].red != key->text[i].red) || - (style->text[i].green != key->text[i].green) || - (style->text[i].blue != key->text[i].blue)) - { - style = NULL; - continue; - } - - if ((style->base[i].red != key->base[i].red) || - (style->base[i].green != key->base[i].green) || - (style->base[i].blue != key->base[i].blue)) - { - style = NULL; - continue; - } - } - - if (style) - { - gtk_style_ref (style); - break; - } - } + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_cross != NULL); - if (!style) - { - style = g_new0 (GtkStyle, 1); - - style->ref_count = 1; - style->attach_count = 0; - - style->font = key->font; - gdk_font_ref (style->font); - - style->depth = key->depth; - style->colormap = key->colormap; - style->klass = key->klass; - - style->black.red = 0; - style->black.green = 0; - style->black.blue = 0; - - style->white.red = 65535; - style->white.green = 65535; - style->white.blue = 65535; - - style->black_gc = NULL; - style->white_gc = NULL; - - for (i = 0; i < 5; i++) - { - style->fg[i] = key->fg[i]; - style->bg[i] = key->bg[i]; - style->text[i] = key->text[i]; - style->base[i] = key->base[i]; - } - - for (i = 0; i < 5; i++) - style->bg_pixmap[i] = key->bg_pixmap[i]; - - for (i = 0; i < 5; i++) - { - style->fg_gc[i] = NULL; - style->bg_gc[i] = NULL; - style->light_gc[i] = NULL; - style->dark_gc[i] = NULL; - style->mid_gc[i] = NULL; - style->text_gc[i] = NULL; - style->base_gc[i] = NULL; - } - } - - if (style->depth == -1) - style->depth = key->depth; - if (!style->colormap) - style->colormap = key->colormap; + (*style->klass->draw_cross) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); +} - gtk_style_init (style); +void +gtk_draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_ramp != NULL); - return style; + (*style->klass->draw_ramp) (style, window, state_type, shadow_type, NULL, NULL, NULL, arrow_type, x, y, width, height); } -static GtkStyleKey* -gtk_style_key_dup (GtkStyleKey *key) +void +gtk_draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height) { - GtkStyleKey *new_key; - - if (!key_mem_chunk) - key_mem_chunk = g_mem_chunk_new ("key mem chunk", sizeof (GtkStyleKey), - 1024, G_ALLOC_AND_FREE); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_tab != NULL); - new_key = g_chunk_new (GtkStyleKey, key_mem_chunk); + (*style->klass->draw_tab) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height); +} - *new_key = *key; +void +gtk_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow_gap != NULL); - return new_key; + (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width); } -static void -gtk_style_destroy (GtkStyle *style) +void +gtk_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) { - gint i; - - if (style->attach_count > 0) - { - gtk_gc_release (style->black_gc); - gtk_gc_release (style->white_gc); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box_gap != NULL); - for (i = 0; i < 5; i++) - { - gtk_gc_release (style->fg_gc[i]); - gtk_gc_release (style->bg_gc[i]); - gtk_gc_release (style->light_gc[i]); - gtk_gc_release (style->dark_gc[i]); - gtk_gc_release (style->mid_gc[i]); - gtk_gc_release (style->text_gc[i]); - gtk_gc_release (style->base_gc[i]); - } - } + (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side, gap_x, gap_width); +} - unattached_styles = g_slist_remove (unattached_styles, style); +void +gtk_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_extension != NULL); - gdk_font_unref (style->font); - g_free (style); + (*style->klass->draw_extension) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, gap_side); } -static void -gtk_style_key_destroy (GtkStyleKey *key) +void +gtk_draw_focus (GtkStyle *style, + GdkWindow *window, + gint x, + gint y, + gint width, + gint height) { - g_mem_chunk_free (key_mem_chunk, key); + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_focus != NULL); + + (*style->klass->draw_focus) (style, window, NULL, NULL, NULL, x, y, width, height); } -static guint -gtk_style_key_hash (GtkStyleKey *key) +void +gtk_draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { - guint hash_val; - gint i; - - hash_val = 0; + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_slider != NULL); - for (i = 0; i < 5; i++) - { - hash_val += key->fg[i].red + key->fg[i].green + key->fg[i].blue; - hash_val += key->bg[i].red + key->bg[i].green + key->bg[i].blue; - hash_val += key->text[i].red + key->text[i].green + key->text[i].blue; - hash_val += key->base[i].red + key->base[i].green + key->base[i].blue; - } - - hash_val += (guint) gdk_font_id (key->font); - hash_val += (guint) key->depth; - hash_val += (gulong) key->colormap; - hash_val += (gulong) key->klass; - - return hash_val; + (*style->klass->draw_slider) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation); } -static guint -gtk_style_value_hash (GtkStyle *style) +void +gtk_draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) { - guint hash_val; - gint i; - - hash_val = 0; - - for (i = 0; i < 5; i++) - { - hash_val += style->fg[i].red + style->fg[i].green + style->fg[i].blue; - hash_val += style->bg[i].red + style->bg[i].green + style->bg[i].blue; - hash_val += style->text[i].red + style->text[i].green + style->text[i].blue; - hash_val += style->base[i].red + style->base[i].green + style->base[i].blue; - } - - hash_val += (guint) gdk_font_id (style->font); - hash_val += (gulong) style->klass; - - return hash_val; + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_handle != NULL); + + (*style->klass->draw_handle) (style, window, state_type, shadow_type, NULL, NULL, NULL, x, y, width, height, orientation); } -static gint -gtk_style_key_compare (GtkStyleKey *a, - GtkStyleKey *b) +/* Default functions */ +void +gtk_style_apply_default_pixmap(GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + gint x, + gint y, + gint width, + gint height) { - gint i; + GdkRectangle new_rect, old_rect; + GdkGC *gc; - if (a->depth != b->depth) - return FALSE; - if (a->colormap != b->colormap) - return FALSE; - if (a->klass != b->klass) - return FALSE; - if (!gdk_font_equal (a->font, b->font)) - return FALSE; - - for (i = 0; i < 5; i++) + if ((!style->bg_pixmap[state_type]) || + (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP)) { - if (a->bg_pixmap[i] != b->bg_pixmap[i]) - return FALSE; - - if ((a->fg[i].red != b->fg[i].red) || - (a->fg[i].green != b->fg[i].green) || - (a->fg[i].blue != b->fg[i].blue)) - return FALSE; - if ((a->bg[i].red != b->bg[i].red) || - (a->bg[i].green != b->bg[i].green) || - (a->bg[i].blue != b->bg[i].blue)) - return FALSE; - if ((a->text[i].red != b->text[i].red) || - (a->text[i].green != b->text[i].green) || - (a->text[i].blue != b->text[i].blue)) - return FALSE; - if ((a->base[i].red != b->base[i].red) || - (a->base[i].green != b->base[i].green) || - (a->base[i].blue != b->base[i].blue)) - return FALSE; + gc = style->bg_gc[state_type]; + + old_rect.x = x; + old_rect.y = y; + old_rect.width = width; + old_rect.height = height; + + if (area) + { + if (gdk_rectangle_intersect(area, &old_rect, &new_rect)) + gdk_draw_rectangle(window, gc, TRUE, + new_rect.x, new_rect.y, new_rect.width, new_rect.height); + } + else + gdk_draw_rectangle(window, gc, TRUE, + x, y, width, height); + } + else + { + if (style->bg_pixmap[state_type] == (GdkPixmap*) GDK_PARENT_RELATIVE) + gdk_window_set_back_pixmap(window, NULL, TRUE); + else + gdk_window_set_back_pixmap(window, style->bg_pixmap[state_type], FALSE); + + old_rect.x = x; + old_rect.y = y; + old_rect.width = width; + old_rect.height = height; + + if ((area) && (gdk_rectangle_intersect(area, &old_rect, &new_rect))) + gdk_window_clear_area(window, new_rect.x, new_rect.y, new_rect.width, new_rect.height); + else + gdk_window_clear_area(window, x, y, width, height); } - - return TRUE; } - static void gtk_default_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x1, gint x2, gint y) { - gint thickness_light; - gint thickness_dark; - gint i; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - thickness_light = style->klass->ythickness / 2; - thickness_dark = style->klass->ythickness - thickness_light; - - for (i = 0; i < thickness_dark; i++) - { - gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); - gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i); - } - - y += thickness_dark; - for (i = 0; i < thickness_light; i++) - { - gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); - gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); - } + gint thickness_light; + gint thickness_dark; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + thickness_light = style->klass->ythickness / 2; + thickness_dark = style->klass->ythickness - thickness_light; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); + } + + if (detail && !strcmp (detail, "label")) + { + if (state_type == GTK_STATE_INSENSITIVE) + gdk_draw_line (window, style->white_gc, x1 + 1, y + 1, x2 + 1, y + 1); + gdk_draw_line (window, style->fg_gc[state_type], x1, y, x2, y); + } + else + { + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, style->light_gc[state_type], x2 - i - 1, y + i, x2, y + i); + gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x2 - i - 1, y + i); + } + + y += thickness_dark; + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, style->dark_gc[state_type], x1, y + i, x1 + thickness_light - i - 1, y + i); + gdk_draw_line (window, style->light_gc[state_type], x1 + thickness_light - i - 1, y + i, x2, y + i); + } + } + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); + } } @@ -981,32 +1244,45 @@ static void gtk_default_draw_vline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint y1, gint y2, gint x) { - gint thickness_light; - gint thickness_dark; - gint i; - - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - thickness_light = style->klass->xthickness / 2; - thickness_dark = style->klass->xthickness - thickness_light; - - for (i = 0; i < thickness_dark; i++) - { - gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); + gint thickness_light; + gint thickness_dark; + gint i; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + thickness_light = style->klass->xthickness / 2; + thickness_dark = style->klass->xthickness - thickness_light; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); + } + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, style->light_gc[state_type], x + i, y2 - i - 1, x + i, y2); gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y2 - i - 1); - } - - x += thickness_dark; - for (i = 0; i < thickness_light; i++) - { - gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i); - gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); - } + } + + x += thickness_dark; + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, style->dark_gc[state_type], x + i, y1, x + i, y1 + thickness_light - i); + gdk_draw_line (window, style->light_gc[state_type], x + i, y1 + thickness_light - i, x + i, y2); + } + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); + } } @@ -1015,13 +1291,16 @@ gtk_default_draw_shadow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, gint height) { - GdkGC *gc1; - GdkGC *gc2; + GdkGC *gc1 = NULL; + GdkGC *gc2 = NULL; gint thickness_light; gint thickness_dark; gint i; @@ -1039,9 +1318,7 @@ gtk_default_draw_shadow (GtkStyle *style, switch (shadow_type) { case GTK_SHADOW_NONE: - gc1 = NULL; - gc2 = NULL; - break; + return; case GTK_SHADOW_IN: case GTK_SHADOW_ETCHED_IN: gc1 = style->light_gc[state_type]; @@ -1054,7 +1331,18 @@ gtk_default_draw_shadow (GtkStyle *style, break; } - switch (shadow_type) + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + if ((shadow_type == GTK_SHADOW_IN) || + (shadow_type == GTK_SHADOW_OUT)) + { + gdk_gc_set_clip_rectangle (style->black_gc, area); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + } + } + switch (shadow_type) { case GTK_SHADOW_NONE: break; @@ -1159,6 +1447,17 @@ gtk_default_draw_shadow (GtkStyle *style, } break; } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + if ((shadow_type == GTK_SHADOW_IN) || + (shadow_type == GTK_SHADOW_OUT)) + { + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + } + } } @@ -1167,9 +1466,12 @@ gtk_default_draw_polygon (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GdkPoint *points, gint npoints, - gint fill) + gboolean fill) { #ifndef M_PI #define M_PI 3.14159265358979323846 @@ -1202,17 +1504,37 @@ gtk_default_draw_polygon (GtkStyle *style, gc3 = style->light_gc[state_type]; gc4 = style->black_gc; break; + case GTK_SHADOW_ETCHED_IN: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->light_gc[state_type]; + break; case GTK_SHADOW_OUT: gc1 = style->dark_gc[state_type]; gc2 = style->light_gc[state_type]; gc3 = style->black_gc; gc4 = style->bg_gc[state_type]; break; + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->dark_gc[state_type]; + break; default: return; } - if (fill) + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } + + if (fill) gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, npoints); npoints--; @@ -1271,6 +1593,13 @@ gtk_default_draw_polygon (GtkStyle *style, points[i+1].x, points[i+1].y); } } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } } static void @@ -1278,346 +1607,1187 @@ gtk_default_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, gint height) { - GdkGC *gc1; - GdkGC *gc2; - GdkGC *gc3; - GdkGC *gc4; - gint half_width; - gint half_height; - GdkPoint points[3]; + GdkGC *gc1; + GdkGC *gc2; + GdkGC *gc3; + GdkGC *gc4; + gint half_width; + gint half_height; + GdkPoint points[3]; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + switch (shadow_type) + { + case GTK_SHADOW_IN: + gc1 = style->bg_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->black_gc; + break; + case GTK_SHADOW_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->black_gc; + gc4 = style->bg_gc[state_type]; + break; + case GTK_SHADOW_ETCHED_IN: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = NULL; + gc4 = NULL; + break; + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = NULL; + gc4 = NULL; + break; + default: + return; + } + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + half_width = width / 2; + half_height = height / 2; + + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + if ((gc3) && (gc4)) + { + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } + } + + switch (arrow_type) + { + case GTK_ARROW_UP: + if (fill) + { + points[0].x = x + half_width; + points[0].y = y; + points[1].x = x; + points[1].y = y + height - 1; + points[2].x = x + width - 1; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + } + + switch (shadow_type) + { + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, + x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + 0, y + height - 1, + x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + width - 2, y + height - 1, + x + half_width, y + 1); + gdk_draw_line (window, gc3, + x + width - 1, y + height - 1, + x + half_width, y); + + gdk_draw_line (window, gc4, + x + half_width, y + 1, + x + 1, y + height - 1); + gdk_draw_line (window, gc2, + x + half_width, y, + x, y + height - 1); + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + gdk_draw_line (window, gc1, + x + half_width, y + 1, + x + 1, y + height - 1); + gdk_draw_line (window, gc1, + x + 1, y + height - 1, + x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y + height - 1, + x + half_width + 1, y + 1); + + points[0].x = x + half_width; + points[0].y = y; + points[1].x = x; + points[1].y = y + height - 2; + points[2].x = x + width - 2; + points[2].y = y + height - 2; + + gdk_draw_polygon (window, gc2, FALSE, points, 3); + break; + + default: + break; + } + break; + + case GTK_ARROW_DOWN: + if (fill) + { + points[0].x = x + width - 1; + points[0].y = y; + points[1].x = x; + points[1].y = y; + points[2].x = x + half_width; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + } + switch (shadow_type) + { + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + gdk_draw_line (window, gc4, + x + width - 2, + y + 1, x + 1, y + 1); + gdk_draw_line (window, gc2, + x + width - 1, y, + x, y); + + gdk_draw_line (window, gc4, + x + 1, y, + x + half_width, y + height - 2); + gdk_draw_line (window, gc2, + x, y, + x + half_width, y + height - 1); + + gdk_draw_line (window, gc1, + x + half_width, y + height - 2, + x + width - 2, y); + gdk_draw_line (window, gc3, + x + half_width, y + height - 1, + x + width - 1, y); + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + gdk_draw_line (window, gc1, + x + width - 1, y + 1, + x + 1, y + 1); + gdk_draw_line (window, gc1, + x + 1, y + 1, + x + half_width + 1, y + height - 1); + gdk_draw_line (window, gc1, + x + half_width + 1, y + height - 2, + x + width - 1, y); + + points[0].x = x + width - 2; + points[0].y = y; + points[1].x = x; + points[1].y = y; + points[2].x = x + half_width; + points[2].y = y + height - 2; + + gdk_draw_polygon (window, gc2, FALSE, points, 3); + break; + + default: + break; + } + break; + case GTK_ARROW_LEFT: + if (fill) + { + points[0].x = x; + points[0].y = y + half_height; + points[1].x = x + width - 1; + points[1].y = y + height - 1; + points[2].x = x + width - 1; + points[2].y = y; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + } + + switch (shadow_type) + { + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + gdk_draw_line (window, gc1, + x + 1, y + half_height, + x + width - 1, y + height - 1); + gdk_draw_line (window, gc3, + x, y + half_height, + x + width - 1, y + height - 1); + + gdk_draw_line (window, gc1, + x + width - 2, y + height - 1, + x + width - 2, y + 1); + gdk_draw_line (window, gc3, + x + width - 1, y + height - 1, + x + width - 1, y); + + gdk_draw_line (window, gc4, + x + width - 1, y + 1, + x + 1, y + half_height); + gdk_draw_line (window, gc2, + x + width - 1, y, + x, y + half_height); + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + gdk_draw_line (window, gc1, + x + width - 1, y + 1, + x + 1, y + half_height); + gdk_draw_line (window, gc1, + x + 1, y + half_height + 1, + x + width - 1, y + height - 1); + gdk_draw_line (window, gc1, + x + width - 1, y + height - 1, + x + width - 1, y + 1); + + points[0].x = x + width - 2; + points[0].y = y; + points[1].x = x; + points[1].y = y + half_height; + points[2].x = x + width - 2; + points[2].y = y + height - 2; + + gdk_draw_polygon (window, gc2, FALSE, points, 3); + break; + + default: + break; + } + break; + case GTK_ARROW_RIGHT: + if (fill) + { + points[0].x = x + width - 1; + points[0].y = y + half_height; + points[1].x = x; + points[1].y = y; + points[2].x = x; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); + } + + switch (shadow_type) + { + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + gdk_draw_line (window, gc4, + x + width - 1, y + half_height, + x + 1, y + 1); + gdk_draw_line (window, gc2, + x + width - 1, y + half_height, + x, y); + gdk_draw_line (window, gc4, + x + 1, y + 1, + x + 1, y + height - 2); + gdk_draw_line (window, gc2, + x, y, + x, y + height - 1); + + gdk_draw_line (window, gc1, + x + 1, y + height - 2, + x + width - 1, y + half_height); + gdk_draw_line (window, gc3, + x, y + height - 1, + x + width - 1, y + half_height); + break; + + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + gdk_draw_line (window, gc1, + x + width - 1, y + half_height + 1, + x + 1, y + 1); + gdk_draw_line (window, gc1, + x + 1, y + 1, + x + 1, y + height - 1); + gdk_draw_line (window, gc1, + x + 1, y + height - 1, + x + width - 1, y + half_height + 1); + + points[0].x = x + width - 2; + points[0].y = y + half_height; + points[1].x = x; + points[1].y = y; + points[2].x = x; + points[2].y = y + height - 1; + + gdk_draw_polygon (window, gc2, FALSE, points, 3); + break; + + default: + break; + } + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + if (gc3) + { + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } + } +} + +static void +gtk_default_draw_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + gint half_width; + gint half_height; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + half_width = width / 2; + half_height = height / 2; + + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->black_gc, area); + } + switch (shadow_type) + { + case GTK_SHADOW_IN: + gdk_draw_line (window, style->bg_gc[state_type], + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->black_gc, + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->black_gc, + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y, + x + width, y + half_height); + break; + case GTK_SHADOW_OUT: + gdk_draw_line (window, style->dark_gc[state_type], + x + 2, y + half_height, + x + half_width, y + height - 2); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + height - 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->dark_gc[state_type], + x + 1, y + half_height, + x + half_width, y + height - 1); + gdk_draw_line (window, style->dark_gc[state_type], + x + half_width, y + height - 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->black_gc, + x, y + half_height, + x + half_width, y + height); + gdk_draw_line (window, style->black_gc, + x + half_width, y + height, + x + width, y + half_height); + + gdk_draw_line (window, style->bg_gc[state_type], + x + 2, y + half_height, + x + half_width, y + 2); + gdk_draw_line (window, style->bg_gc[state_type], + x + half_width, y + 2, + x + width - 2, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x + 1, y + half_height, + x + half_width, y + 1); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y + 1, + x + width - 1, y + half_height); + gdk_draw_line (window, style->light_gc[state_type], + x, y + half_height, + x + half_width, y); + gdk_draw_line (window, style->light_gc[state_type], + x + half_width, y, + x + width, y + half_height); + break; + default: + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + } +} + + +static void +gtk_default_draw_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} +static void +gtk_default_draw_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string) +{ g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); - switch (shadow_type) + if (area) + { + gdk_gc_set_clip_rectangle (style->white_gc, area); + gdk_gc_set_clip_rectangle (style->fg_gc[state_type], area); + } + if (state_type == GTK_STATE_INSENSITIVE) + gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string); + gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string); + if (area) + { + gdk_gc_set_clip_rectangle (style->white_gc, NULL); + gdk_gc_set_clip_rectangle (style->fg_gc[state_type], NULL); + } +} + +static void +gtk_default_draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + if ((!style->bg_pixmap[state_type]) || + (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP)) { - case GTK_SHADOW_IN: - gc1 = style->bg_gc[state_type]; - gc2 = style->dark_gc[state_type]; - gc3 = style->light_gc[state_type]; - gc4 = style->black_gc; - break; - case GTK_SHADOW_OUT: - gc1 = style->dark_gc[state_type]; - gc2 = style->light_gc[state_type]; - gc3 = style->black_gc; - gc4 = style->bg_gc[state_type]; - break; - case GTK_SHADOW_ETCHED_IN: - gc1 = style->light_gc[state_type]; - gc2 = style->dark_gc[state_type]; - gc3 = NULL; - gc4 = NULL; - break; - case GTK_SHADOW_ETCHED_OUT: - gc1 = style->dark_gc[state_type]; - gc2 = style->light_gc[state_type]; - gc3 = NULL; - gc4 = NULL; - break; - default: - return; + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); + } + gdk_draw_rectangle(window, style->bg_gc[state_type], TRUE, + x, y, width, height); + if (area) + { + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); + } } + else + gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height); + gtk_paint_shadow (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} +static void +gtk_default_draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + GdkGC *gc1; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + if ((width == -1) && (height == -1)) gdk_window_get_size (window, &width, &height); else if (width == -1) gdk_window_get_size (window, &width, NULL); else if (height == -1) gdk_window_get_size (window, NULL, &height); + + if ((detail) && (!strcmp("text",detail)) && (state_type == GTK_STATE_SELECTED)) + gc1 = style->bg_gc[GTK_STATE_SELECTED]; + else if ((detail) && (!strcmp("viewportbin",detail))) + gc1 = style->bg_gc[GTK_STATE_NORMAL]; + else if ((detail) && (!strcmp("entry_bg",detail))) + gc1 = style->base_gc[state_type]; + else + gc1 = style->bg_gc[state_type]; - half_width = width / 2; - half_height = height / 2; - - switch (arrow_type) + if ((!style->bg_pixmap[state_type]) || (gc1 != style->bg_gc[state_type]) || + (gdk_window_get_type(window) == GDK_WINDOW_PIXMAP)) { - case GTK_ARROW_UP: - if (fill) - { - points[0].x = x + half_width; - points[0].y = y; - points[1].x = x; - points[1].y = y + height - 1; - points[2].x = x + width - 1; - points[2].y = y + height - 1; + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + } + gdk_draw_rectangle (window, gc1, TRUE, + x, y, width, height); + if ((detail) && (!strcmp("tooltip",detail))) + gdk_draw_rectangle (window, style->black_gc, FALSE, + x, y, width - 1, height - 1); + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + } + } + else + gtk_style_apply_default_pixmap(style, window, state_type, area, x, y, width, height); +} - gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); - } +static void +gtk_default_draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} + +static void +gtk_default_draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + gtk_paint_diamond (style, window, state_type, shadow_type, area, widget, + detail, x, y, width, height); +} + +static void +gtk_default_draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} - switch (shadow_type) +static void +gtk_default_draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); +} + +static void gtk_default_draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + gtk_paint_box (style, window, state_type, shadow_type, area, widget, detail, + x, y, width, height); +} + +static void +gtk_default_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) +{ + GdkGC *gc1 = NULL; + GdkGC *gc2 = NULL; + GdkGC *gc3 = NULL; + GdkGC *gc4 = NULL; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + case GTK_SHADOW_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->black_gc; + gc3 = style->bg_gc[state_type]; + gc4 = style->light_gc[state_type]; + break; + case GTK_SHADOW_ETCHED_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->light_gc[state_type]; + break; + case GTK_SHADOW_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->bg_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->black_gc; + break; + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->dark_gc[state_type]; + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + switch (gap_side) { - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: - + case GTK_POS_TOP: gdk_draw_line (window, gc1, - x + 1, y + height - 2, - x + width - 2, y + height - 2); - gdk_draw_line (window, gc3, - x + 0, y + height - 1, - x + width - 1, y + height - 1); + x, y, x, y + height - 1); + gdk_draw_line (window, gc2, + x + 1, y, x + 1, y + height - 2); - gdk_draw_line (window, gc1, - x + width - 2, y + height - 1, - x + half_width, y + 1); gdk_draw_line (window, gc3, - x + width - 1, y + height - 1, - x + half_width, y); - + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y, x + width - 2, y + height - 2); gdk_draw_line (window, gc4, - x + half_width, y + 1, - x + 1, y + height - 1); - gdk_draw_line (window, gc2, - x + half_width, y, - x, y + height - 1); + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc1, + x, y, x + gap_x - 1, y); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + gap_x - 1, y + 1); + gdk_draw_line (window, gc2, + x + gap_x, y, x + gap_x, y); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc1, + x + gap_x + gap_width, y, x + width - 2, y); + gdk_draw_line (window, gc2, + x + gap_x + gap_width, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y); + } break; - - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: + case GTK_POS_BOTTOM: gdk_draw_line (window, gc1, - x + half_width, y + 1, - x + 1, y + height - 1); + x, y, x + width - 1, y); gdk_draw_line (window, gc1, - x + 1, y + height - 1, - x + width - 1, y + height - 1); - gdk_draw_line (window, gc1, - x + width - 1, y + height - 1, - x + half_width + 1, y + 1); - - points[0].x = x + half_width; - points[0].y = y; - points[1].x = x; - points[1].y = y + height - 2; - points[2].x = x + width - 2; - points[2].y = y + height - 2; - - gdk_draw_polygon (window, gc2, FALSE, points, 3); - break; + x, y, x, y + height - 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 1); - default: + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc4, + x, y + height - 1, x + gap_x - 1, y + height - 1); + gdk_draw_line (window, gc3, + x + 1, y + height - 2, x + gap_x - 1, y + height - 2); + gdk_draw_line (window, gc3, + x + gap_x, y + height - 1, x + gap_x, y + height - 1); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc4, + x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1); + gdk_draw_line (window, gc3, + x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1); + } break; - } - break; - - case GTK_ARROW_DOWN: - if (fill) - { - points[0].x = x + width - 1; - points[0].y = y; - points[1].x = x; - points[1].y = y; - points[2].x = x + half_width; - points[2].y = y + height - 1; + case GTK_POS_LEFT: + gdk_draw_line (window, gc1, + x, y, x + width - 1, y); + gdk_draw_line (window, gc2, + x, y + 1, x + width - 2, y + 1); - gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); - } - switch (shadow_type) - { - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: + gdk_draw_line (window, gc3, + x, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + height - 2); gdk_draw_line (window, gc4, - x + width - 2, - y + 1, x + 1, y + 1); - gdk_draw_line (window, gc2, - x + width - 1, y, - x, y); - + x, y + height - 1, x + width - 1, y + height - 1); gdk_draw_line (window, gc4, - x + 1, y, - x + half_width, y + height - 2); + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc1, + x, y, x, y + gap_x - 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + gap_x - 1); + gdk_draw_line (window, gc2, + x, y + gap_x, x, y + gap_x); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc1, + x, y + gap_x + gap_width, x, y + height - 2); + gdk_draw_line (window, gc2, + x + 1, y + gap_x + gap_width, x + 1, y + height - 2); + gdk_draw_line (window, gc2, + x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1); + } + break; + case GTK_POS_RIGHT: + gdk_draw_line (window, gc1, + x, y, x + width - 1, y); + gdk_draw_line (window, gc1, + x, y, x, y + height - 1); gdk_draw_line (window, gc2, - x, y, - x + half_width, y + height - 1); + x + 1, y + 1, x + width - 1, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); - gdk_draw_line (window, gc1, - x + half_width, y + height - 2, - x + width - 2, y); gdk_draw_line (window, gc3, - x + half_width, y + height - 1, - x + width - 1, y); + x + 1, y + height - 2, x + width - 1, y + height - 2); + gdk_draw_line (window, gc4, + x, y + height - 1, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + gap_x - 1); + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + gap_x - 1); + gdk_draw_line (window, gc3, + x + width - 1, y + gap_x, x + width - 1, y + gap_x); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc4, + x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1); + } break; + } + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } +} - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - gdk_draw_line (window, gc1, - x + width - 1, y + 1, - x + 1, y + 1); - gdk_draw_line (window, gc1, - x + 1, y + 1, - x + half_width + 1, y + height - 1); - gdk_draw_line (window, gc1, - x + half_width + 1, y + height - 2, - x + width - 1, y); - - points[0].x = x + width - 2; - points[0].y = y; - points[1].x = x; - points[1].y = y; - points[2].x = x + half_width; - points[2].y = y + height - 2; +static void +gtk_default_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) +{ + GdkGC *gc1 = NULL; + GdkGC *gc2 = NULL; + GdkGC *gc3 = NULL; + GdkGC *gc4 = NULL; - gdk_draw_polygon (window, gc2, FALSE, points, 3); - break; + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); - default: - break; - } + gtk_style_apply_default_pixmap(style, window, state_type, area, + x, y, width, height); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + switch (shadow_type) + { + case GTK_SHADOW_NONE: + return; + case GTK_SHADOW_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->black_gc; + gc3 = style->bg_gc[state_type]; + gc4 = style->light_gc[state_type]; break; - case GTK_ARROW_LEFT: - if (fill) - { - points[0].x = x; - points[0].y = y + half_height; - points[1].x = x + width - 1; - points[1].y = y + height - 1; - points[2].x = x + width - 1; - points[2].y = y; - - gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); - } + case GTK_SHADOW_ETCHED_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->light_gc[state_type]; + break; + case GTK_SHADOW_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->bg_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->black_gc; + break; + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->dark_gc[state_type]; + break; + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } - switch (shadow_type) + switch (shadow_type) + { + case GTK_SHADOW_NONE: + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + if (gap_side == 0) + /* top */ { - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: gdk_draw_line (window, gc1, - x + 1, y + half_height, - x + width - 1, y + height - 1); - gdk_draw_line (window, gc3, - x, y + half_height, - x + width - 1, y + height - 1); + x, y, x, y + height - 1); + gdk_draw_line (window, gc2, + x + 1, y, x + 1, y + height - 2); - gdk_draw_line (window, gc1, - x + width - 2, y + height - 1, - x + width - 2, y + 1); gdk_draw_line (window, gc3, - x + width - 1, y + height - 1, - x + width - 1, y); - + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y, x + width - 2, y + height - 2); gdk_draw_line (window, gc4, - x + width - 1, y + 1, - x + 1, y + half_height); - gdk_draw_line (window, gc2, - x + width - 1, y, - x, y + half_height); - break; - - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - gdk_draw_line (window, gc1, - x + width - 1, y + 1, - x + 1, y + half_height); - gdk_draw_line (window, gc1, - x + 1, y + half_height + 1, - x + width - 1, y + height - 1); - gdk_draw_line (window, gc1, - x + width - 1, y + height - 1, - x + width - 1, y + 1); - - points[0].x = x + width - 2; - points[0].y = y; - points[1].x = x; - points[1].y = y + half_height; - points[2].x = x + width - 2; - points[2].y = y + height - 2; - - gdk_draw_polygon (window, gc2, FALSE, points, 3); - break; - - default: - break; + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc1, + x, y, x + gap_x - 1, y); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + gap_x - 1, y + 1); + gdk_draw_line (window, gc2, + x + gap_x, y, x + gap_x, y); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc1, + x + gap_x + gap_width, y, x + width - 2, y); + gdk_draw_line (window, gc2, + x + gap_x + gap_width, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + gap_x + gap_width - 1, y, x + gap_x + gap_width - 1, y); + } } - break; - case GTK_ARROW_RIGHT: - if (fill) - { - points[0].x = x + width - 1; - points[0].y = y + half_height; - points[1].x = x; - points[1].y = y; - points[2].x = x; - points[2].y = y + height - 1; - - gdk_draw_polygon (window, style->bg_gc[state_type], TRUE, points, 3); - } - - switch (shadow_type) + else if (gap_side == 1) + /* bottom */ { - case GTK_SHADOW_IN: - case GTK_SHADOW_OUT: - gdk_draw_line (window, gc4, - x + width - 1, y + half_height, - x + 1, y + 1); + gdk_draw_line (window, gc1, + x, y, x + width - 1, y); + gdk_draw_line (window, gc1, + x, y, x, y + height - 1); gdk_draw_line (window, gc2, - x + width - 1, y + half_height, - x, y); + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 1); + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + height - 1); gdk_draw_line (window, gc4, - x + 1, y + 1, - x + 1, y + height - 2); + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc4, + x, y + height - 1, x + gap_x - 1, y + height - 1); + gdk_draw_line (window, gc3, + x + 1, y + height - 2, x + gap_x - 1, y + height - 2); + gdk_draw_line (window, gc3, + x + gap_x, y + height - 1, x + gap_x, y + height - 1); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc4, + x + gap_x + gap_width, y + height - 1, x + width - 2, y + height - 1); + gdk_draw_line (window, gc3, + x + gap_x + gap_width, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + gap_x + gap_width - 1, y + height - 1, x + gap_x + gap_width - 1, y + height - 1); + } + } + else if (gap_side == 2) + /* left */ + { + gdk_draw_line (window, gc1, + x, y, x + width - 1, y); gdk_draw_line (window, gc2, - x, y, - x, y + height - 1); + x, y + 1, x + width - 2, y + 1); - gdk_draw_line (window, gc1, - x + 1, y + height - 2, - x + width - 1, y + half_height); gdk_draw_line (window, gc3, - x, y + height - 1, - x + width - 1, y + half_height); - break; - - case GTK_SHADOW_ETCHED_IN: - case GTK_SHADOW_ETCHED_OUT: - gdk_draw_line (window, gc1, - x + width - 1, y + half_height + 1, - x + 1, y + 1); + x, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + height - 2); + gdk_draw_line (window, gc4, + x, y + height - 1, x + width - 1, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc1, + x, y, x, y + gap_x - 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + gap_x - 1); + gdk_draw_line (window, gc2, + x, y + gap_x, x, y + gap_x); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc1, + x, y + gap_x + gap_width, x, y + height - 2); + gdk_draw_line (window, gc2, + x + 1, y + gap_x + gap_width, x + 1, y + height - 2); + gdk_draw_line (window, gc2, + x, y + gap_x + gap_width - 1, x, y + gap_x + gap_width - 1); + } + } + else if (gap_side == 3) + /* right */ + { gdk_draw_line (window, gc1, - x + 1, y + 1, - x + 1, y + height - 1); + x, y, x + width - 1, y); gdk_draw_line (window, gc1, - x + 1, y + height - 1, - x + width - 1, y + half_height + 1); - - points[0].x = x + width - 2; - points[0].y = y + half_height; - points[1].x = x; - points[1].y = y; - points[2].x = x; - points[2].y = y + height - 1; - - gdk_draw_polygon (window, gc2, FALSE, points, 3); - break; + x, y, x, y + height - 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 1, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); - default: - break; + gdk_draw_line (window, gc3, + x + 1, y + height - 2, x + width - 1, y + height - 2); + gdk_draw_line (window, gc4, + x, y + height - 1, x + width - 1, y + height - 1); + if (gap_x > 0) + { + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + gap_x - 1); + gdk_draw_line (window, gc3, + x + width - 2, y + 1, x + width - 2, y + gap_x - 1); + gdk_draw_line (window, gc3, + x + width - 1, y + gap_x, x + width - 1, y + gap_x); + } + if ((width - (gap_x + gap_width)) > 0) + { + gdk_draw_line (window, gc4, + x + width - 1, y + gap_x + gap_width, x + width - 1, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y + gap_x + gap_width, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 1, y + gap_x + gap_width - 1, x + width - 1, y + gap_x + gap_width - 1); + } } - break; + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); } } -static void -gtk_default_draw_diamond (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height) +static void +gtk_default_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) { - gint half_width; - gint half_height; + GdkGC *gc1 = NULL; + GdkGC *gc2 = NULL; + GdkGC *gc3 = NULL; + GdkGC *gc4 = NULL; g_return_if_fail (style != NULL); g_return_if_fail (window != NULL); + gtk_style_apply_default_pixmap(style, window, GTK_STATE_NORMAL, area, + x, y, width, height); + if ((width == -1) && (height == -1)) gdk_window_get_size (window, &width, &height); else if (width == -1) @@ -1625,125 +2795,293 @@ gtk_default_draw_diamond (GtkStyle *style, else if (height == -1) gdk_window_get_size (window, NULL, &height); - half_width = width / 2; - half_height = height / 2; - switch (shadow_type) { - case GTK_SHADOW_IN: - gdk_draw_line (window, style->bg_gc[state_type], - x + 2, y + half_height, - x + half_width, y + height - 2); - gdk_draw_line (window, style->bg_gc[state_type], - x + half_width, y + height - 2, - x + width - 2, y + half_height); - gdk_draw_line (window, style->light_gc[state_type], - x + 1, y + half_height, - x + half_width, y + height - 1); - gdk_draw_line (window, style->light_gc[state_type], - x + half_width, y + height - 1, - x + width - 1, y + half_height); - gdk_draw_line (window, style->light_gc[state_type], - x, y + half_height, - x + half_width, y + height); - gdk_draw_line (window, style->light_gc[state_type], - x + half_width, y + height, - x + width, y + half_height); - - gdk_draw_line (window, style->black_gc, - x + 2, y + half_height, - x + half_width, y + 2); - gdk_draw_line (window, style->black_gc, - x + half_width, y + 2, - x + width - 2, y + half_height); - gdk_draw_line (window, style->dark_gc[state_type], - x + 1, y + half_height, - x + half_width, y + 1); - gdk_draw_line (window, style->dark_gc[state_type], - x + half_width, y + 1, - x + width - 1, y + half_height); - gdk_draw_line (window, style->dark_gc[state_type], - x, y + half_height, - x + half_width, y); - gdk_draw_line (window, style->dark_gc[state_type], - x + half_width, y, - x + width, y + half_height); + case GTK_SHADOW_NONE: + return; + case GTK_SHADOW_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->black_gc; + gc3 = style->bg_gc[state_type]; + gc4 = style->light_gc[state_type]; break; - case GTK_SHADOW_OUT: - gdk_draw_line (window, style->dark_gc[state_type], - x + 2, y + half_height, - x + half_width, y + height - 2); - gdk_draw_line (window, style->dark_gc[state_type], - x + half_width, y + height - 2, - x + width - 2, y + half_height); - gdk_draw_line (window, style->dark_gc[state_type], - x + 1, y + half_height, - x + half_width, y + height - 1); - gdk_draw_line (window, style->dark_gc[state_type], - x + half_width, y + height - 1, - x + width - 1, y + half_height); - gdk_draw_line (window, style->black_gc, - x, y + half_height, - x + half_width, y + height); - gdk_draw_line (window, style->black_gc, - x + half_width, y + height, - x + width, y + half_height); - - gdk_draw_line (window, style->bg_gc[state_type], - x + 2, y + half_height, - x + half_width, y + 2); - gdk_draw_line (window, style->bg_gc[state_type], - x + half_width, y + 2, - x + width - 2, y + half_height); - gdk_draw_line (window, style->light_gc[state_type], - x + 1, y + half_height, - x + half_width, y + 1); - gdk_draw_line (window, style->light_gc[state_type], - x + half_width, y + 1, - x + width - 1, y + half_height); - gdk_draw_line (window, style->light_gc[state_type], - x, y + half_height, - x + half_width, y); - gdk_draw_line (window, style->light_gc[state_type], - x + half_width, y, - x + width, y + half_height); + case GTK_SHADOW_ETCHED_IN: + gc1 = style->dark_gc[state_type]; + gc2 = style->light_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->light_gc[state_type]; break; - default: + case GTK_SHADOW_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->bg_gc[state_type]; + gc3 = style->dark_gc[state_type]; + gc4 = style->black_gc; + break; + case GTK_SHADOW_ETCHED_OUT: + gc1 = style->light_gc[state_type]; + gc2 = style->dark_gc[state_type]; + gc3 = style->light_gc[state_type]; + gc4 = style->dark_gc[state_type]; break; } -} + if (area) + { + gdk_gc_set_clip_rectangle (gc1, area); + gdk_gc_set_clip_rectangle (gc2, area); + gdk_gc_set_clip_rectangle (gc3, area); + gdk_gc_set_clip_rectangle (gc4, area); + } + switch (shadow_type) + { + case GTK_SHADOW_NONE: + case GTK_SHADOW_IN: + case GTK_SHADOW_OUT: + case GTK_SHADOW_ETCHED_IN: + case GTK_SHADOW_ETCHED_OUT: + switch (gap_side) + { + case GTK_POS_TOP: + gtk_style_apply_default_pixmap(style, window, state_type, area, + x + style->klass->xthickness, + y, + width - (2 * style->klass->xthickness), + height - (style->klass->ythickness)); + gdk_draw_line (window, gc1, + x, y, x, y + height - 2); + gdk_draw_line (window, gc2, + x + 1, y, x + 1, y + height - 2); + gdk_draw_line (window, gc3, + x + 2, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y, x + width - 2, y + height - 2); + gdk_draw_line (window, gc4, + x + 1, y + height - 1, x + width - 2, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y, x + width - 1, y + height - 2); + break; + case GTK_POS_BOTTOM: + gtk_style_apply_default_pixmap(style, window, state_type, area, + x + style->klass->xthickness, + y + style->klass->ythickness, + width - (2 * style->klass->xthickness), + height - (style->klass->ythickness)); + gdk_draw_line (window, gc1, + x + 1, y, x + width - 2, y); + gdk_draw_line (window, gc1, + x, y + 1, x, y + height - 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 1); -static void -gtk_default_draw_oval (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height) + gdk_draw_line (window, gc3, + x + width - 2, y + 2, x + width - 2, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y + 1, x + width - 1, y + height - 1); + break; + case GTK_POS_LEFT: + gtk_style_apply_default_pixmap(style, window, state_type, area, + x, + y + style->klass->ythickness, + width - (style->klass->xthickness), + height - (2 * style->klass->ythickness)); + gdk_draw_line (window, gc1, + x, y, x + width - 2, y); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 2, y + 1); + + gdk_draw_line (window, gc3, + x, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc3, + x + width - 2, y + 2, x + width - 2, y + height - 2); + gdk_draw_line (window, gc4, + x, y + height - 1, x + width - 2, y + height - 1); + gdk_draw_line (window, gc4, + x + width - 1, y + 1, x + width - 1, y + height - 2); + break; + case GTK_POS_RIGHT: + gtk_style_apply_default_pixmap(style, window, state_type, area, + x + style->klass->xthickness, + y + style->klass->ythickness, + width - (style->klass->xthickness), + height - (2 * style->klass->ythickness)); + gdk_draw_line (window, gc1, + x + 1, y, x + width - 1, y); + gdk_draw_line (window, gc1, + x, y + 1, x, y + height - 2); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + width - 1, y + 1); + gdk_draw_line (window, gc2, + x + 1, y + 1, x + 1, y + height - 2); + + gdk_draw_line (window, gc3, + x + 2, y + height - 2, x + width - 1, y + height - 2); + gdk_draw_line (window, gc4, + x + 1, y + height - 1, x + width - 1, y + height - 1); + break; + } + } + if (area) + { + gdk_gc_set_clip_rectangle (gc1, NULL); + gdk_gc_set_clip_rectangle (gc2, NULL); + gdk_gc_set_clip_rectangle (gc3, NULL); + gdk_gc_set_clip_rectangle (gc4, NULL); + } +} + +static void +gtk_default_draw_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) { - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + { + gdk_window_get_size (window, &width, &height); + width -= 1; + height -= 1; + } + else if (width == -1) + { + gdk_window_get_size (window, &width, NULL); + width -= 1; + } + else if (height == -1) + { + gdk_window_get_size (window, NULL, &height); + height -= 1; + } + if (area) + { + gdk_gc_set_clip_rectangle (style->black_gc, area); + } + if (detail && !strcmp (detail, "add-mode")) + { + gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_ON_OFF_DASH, 0, 0); + gdk_gc_set_dashes (style->black_gc, 0, "\4\4", 2); + + gdk_draw_rectangle (window, + style->black_gc, FALSE, + x, y, width, height); + + gdk_gc_set_line_attributes (style->black_gc, 1, GDK_LINE_SOLID, 0, 0); + } + else + { + gdk_draw_rectangle (window, + style->black_gc, FALSE, + x, y, width, height); + } + if (area) + { + gdk_gc_set_clip_rectangle (style->black_gc, NULL); + } } -static void -gtk_default_draw_string (GtkStyle *style, +static void +gtk_default_draw_slider (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, - const gchar *string) + gint width, + gint height, + GtkOrientation orientation) { - g_return_if_fail (style != NULL); - g_return_if_fail (window != NULL); - - if (state_type == GTK_STATE_INSENSITIVE) - gdk_draw_string (window, style->font, style->white_gc, x + 1, y + 1, string); - gdk_draw_string (window, style->font, style->fg_gc[state_type], x, y, string); + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + gtk_paint_box (style, window, state_type, shadow_type, + area, widget, detail, x, y, width, height); + if (orientation == GTK_ORIENTATION_HORIZONTAL) + gtk_paint_vline (style, window, state_type, area, widget, detail, + style->klass->ythickness, + height - style->klass->ythickness - 1, width / 2); + else + gtk_paint_hline (style, window, state_type, area, widget, detail, + style->klass->xthickness, + width - style->klass->xthickness - 1, height / 2); } +static void +gtk_default_draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) +{ + gint xx, yy; + gint xthick, ythick; + GdkGC *light_gc, *dark_gc; + GdkRectangle dest; + + g_return_if_fail (style != NULL); + g_return_if_fail (window != NULL); + + if ((width == -1) && (height == -1)) + gdk_window_get_size (window, &width, &height); + else if (width == -1) + gdk_window_get_size (window, &width, NULL); + else if (height == -1) + gdk_window_get_size (window, NULL, &height); + + gtk_paint_box (style, window, state_type, shadow_type, area, widget, + detail, x, y, width, height); + + light_gc = style->light_gc[state_type]; + dark_gc = style->dark_gc[state_type]; + + xthick = style->klass->xthickness; + ythick = style->klass->ythickness; + + dest.x = x + xthick; + dest.y = y + ythick; + dest.width = width - (xthick * 2); + dest.height = height - (ythick * 2); + + gdk_gc_set_clip_rectangle (light_gc, &dest); + gdk_gc_set_clip_rectangle (dark_gc, &dest); + + for (yy = y + ythick; yy < (y + height - ythick); yy += 3) + for (xx = x + xthick; xx < (x + width - xthick); xx += 6) + { + gdk_draw_point (window, light_gc, xx, yy); + gdk_draw_point (window, dark_gc, xx + 1, yy + 1); + + gdk_draw_point (window, light_gc, xx + 3, yy + 1); + gdk_draw_point (window, dark_gc, xx + 4, yy + 2); + } + gdk_gc_set_clip_rectangle (light_gc, NULL); + gdk_gc_set_clip_rectangle (dark_gc, NULL); +} static void gtk_style_shade (GdkColor *a, @@ -1928,3 +3266,427 @@ hls_to_rgb (gdouble *h, *s = b; } } + +void +gtk_paint_hline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x1, + gint x2, + gint y) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_hline != NULL); + + (*style->klass->draw_hline) (style, window, state_type, area, widget, detail, x1, x2, y); +} + +void +gtk_paint_vline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint y1, + gint y2, + gint x) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_vline != NULL); + + (*style->klass->draw_vline) (style, window, state_type, area, widget, detail, y1, y2, x); +} + +void +gtk_paint_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow != NULL); + + (*style->klass->draw_shadow) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_polygon (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GdkPoint *points, + gint npoints, + gboolean fill) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow != NULL); + + (*style->klass->draw_polygon) (style, window, state_type, shadow_type, area, widget, detail, points, npoints, fill); +} + +void +gtk_paint_arrow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gboolean fill, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_arrow != NULL); + + (*style->klass->draw_arrow) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, fill, x, y, width, height); +} + +void +gtk_paint_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_diamond != NULL); + + (*style->klass->draw_diamond) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_oval != NULL); + + (*style->klass->draw_oval) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_oval != NULL); + + (*style->klass->draw_string) (style, window, state_type, area, widget, detail, x, y, string); +} + +void +gtk_paint_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box != NULL); + + (*style->klass->draw_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_flat_box != NULL); + + (*style->klass->draw_flat_box) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_check != NULL); + + (*style->klass->draw_check) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_option != NULL); + + (*style->klass->draw_option) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_cross != NULL); + + (*style->klass->draw_cross) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_ramp != NULL); + + (*style->klass->draw_ramp) (style, window, state_type, shadow_type, area, widget, detail, arrow_type, x, y, width, height); +} + +void +gtk_paint_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_tab != NULL); + + (*style->klass->draw_tab) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_shadow_gap != NULL); + + (*style->klass->draw_shadow_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); +} + + +void +gtk_paint_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_box_gap != NULL); + + (*style->klass->draw_box_gap) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side, gap_x, gap_width); +} + +void +gtk_paint_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_extension != NULL); + + (*style->klass->draw_extension) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, gap_side); +} + +void +gtk_paint_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_focus != NULL); + + (*style->klass->draw_focus) (style, window, area, widget, detail, x, y, width, height); +} + +void +gtk_paint_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_slider != NULL); + + (*style->klass->draw_slider) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); +} + +void +gtk_paint_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation) +{ + g_return_if_fail (style != NULL); + g_return_if_fail (style->klass != NULL); + g_return_if_fail (style->klass->draw_handle != NULL); + + (*style->klass->draw_handle) (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height, orientation); +} diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h index 0def4b5c52..556722475c 100644 --- a/gtk/gtkstyle.h +++ b/gtk/gtkstyle.h @@ -23,7 +23,6 @@ #include <gdk/gdk.h> #include <gtk/gtkenums.h> - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -31,6 +30,18 @@ extern "C" { typedef struct _GtkStyle GtkStyle; typedef struct _GtkStyleClass GtkStyleClass; +/* Some forward declarations needed to rationalize the header + * files. + */ + +typedef struct _GtkThemeEngine GtkThemeEngine; +typedef struct _GtkRcStyle GtkRcStyle; + +/* We make this forward declaration here, since we pass + * GtkWidgt's to the draw functions. + */ +typedef struct _GtkWidget GtkWidget; + /* This is used for having dynamic style changing stuff */ /* fg, bg, light, dark, mid, text, base */ #define GTK_STYLE_NUM_STYLECOLORS() 7*5 @@ -63,13 +74,21 @@ struct _GtkStyle GdkPixmap *bg_pixmap[5]; + /* Private */ gint ref_count; gint attach_count; gint depth; GdkColormap *colormap; - GtkStyleClass *klass; + GtkStyleClass *klass; /* Not private - reorder me */ + GtkThemeEngine *engine; + + gpointer engine_data; + + GtkRcStyle *rc_style; /* the Rc style from which this style + * was created */ + GSList *styles; }; struct _GtkStyleClass @@ -80,12 +99,18 @@ struct _GtkStyleClass void (*draw_hline) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x1, gint x2, gint y); void (*draw_vline) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint y1, gint y2, gint x); @@ -93,6 +118,9 @@ struct _GtkStyleClass GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -101,15 +129,21 @@ struct _GtkStyleClass GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GdkPoint *point, gint npoints, - gint fill); + gboolean fill); void (*draw_arrow) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -118,6 +152,9 @@ struct _GtkStyleClass GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -126,6 +163,9 @@ struct _GtkStyleClass GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, gint width, @@ -133,12 +173,165 @@ struct _GtkStyleClass void (*draw_string) (GtkStyle *style, GdkWindow *window, GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, gint x, gint y, const gchar *string); + void (*draw_box) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_flat_box) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_check) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_option) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_cross) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_ramp) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height); + void (*draw_tab) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_shadow_gap) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); + void (*draw_box_gap) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); + void (*draw_extension) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); + void (*draw_focus) (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); + void (*draw_slider) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); + void (*draw_handle) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); }; - GtkStyle* gtk_style_new (void); GtkStyle* gtk_style_copy (GtkStyle *style); GtkStyle* gtk_style_attach (GtkStyle *style, @@ -149,8 +342,15 @@ void gtk_style_unref (GtkStyle *style); void gtk_style_set_background (GtkStyle *style, GdkWindow *window, GtkStateType state_type); - - +void gtk_style_apply_default_pixmap(GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + gint x, + gint y, + gint width, + gint height); + void gtk_draw_hline (GtkStyle *style, GdkWindow *window, GtkStateType state_type, @@ -177,13 +377,13 @@ void gtk_draw_polygon (GtkStyle *style, GtkShadowType shadow_type, GdkPoint *points, gint npoints, - gint fill); + gboolean fill); void gtk_draw_arrow (GtkStyle *style, GdkWindow *window, GtkStateType state_type, GtkShadowType shadow_type, GtkArrowType arrow_type, - gint fill, + gboolean fill, gint x, gint y, gint width, @@ -210,8 +410,376 @@ void gtk_draw_string (GtkStyle *style, gint x, gint y, const gchar *string); +void gtk_draw_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_draw_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_draw_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); +void gtk_draw_focus (GtkStyle *style, + GdkWindow *window, + gint x, + gint y, + gint width, + gint height); +void gtk_draw_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +void gtk_draw_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +/* + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + * NEW API CALLS + * + */ + + +void gtk_paint_hline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x1, + gint x2, + gint y); +void gtk_paint_vline (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint y1, + gint y2, + gint x); +void gtk_paint_shadow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_polygon (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GdkPoint *points, + gint npoints, + gboolean fill); +void gtk_paint_arrow (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gboolean fill, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_diamond (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_oval (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_string (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + const gchar *string); +void gtk_paint_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_flat_box (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_check (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_option (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_cross (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_ramp (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + GtkArrowType arrow_type, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_tab (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_shadow_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_paint_box_gap (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side, + gint gap_x, + gint gap_width); +void gtk_paint_extension (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkPositionType gap_side); +void gtk_paint_focus (GtkStyle *style, + GdkWindow *window, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height); +void gtk_paint_slider (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +void gtk_paint_handle (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type, + GtkShadowType shadow_type, + GdkRectangle *area, + GtkWidget *widget, + gchar *detail, + gint x, + gint y, + gint width, + gint height, + GtkOrientation orientation); +void gtk_reset_widget_shapes(GtkWidget *widget); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c index 432754d5be..fb76f1010b 100644 --- a/gtk/gtktearoffmenuitem.c +++ b/gtk/gtktearoffmenuitem.c @@ -134,9 +134,6 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget, menu_item = GTK_MENU_ITEM (widget); tearoff_item = GTK_TEAROFF_MENU_ITEM (widget); - gtk_style_set_background (widget->style, widget->window, widget->state); - gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); - x = GTK_CONTAINER (menu_item)->border_width; y = GTK_CONTAINER (menu_item)->border_width; width = widget->allocation.width - x * 2; @@ -144,11 +141,14 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget, right_max = x + width; if (widget->state == GTK_STATE_PRELIGHT) - gtk_draw_shadow (widget->style, - widget->window, - GTK_STATE_PRELIGHT, - GTK_SHADOW_OUT, - x, y, width, height); + gtk_paint_box (widget->style, + widget->window, + GTK_STATE_PRELIGHT, + GTK_SHADOW_OUT, + area, widget, "menuitem", + x, y, width, height); + else + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); if (tearoff_item->torn_off) { diff --git a/gtk/gtktext.c b/gtk/gtktext.c index b07e3b98af..4ab73c7b94 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -1350,18 +1350,19 @@ gtk_text_draw_focus (GtkWidget *widget) height -= 2; xextra -= 1; yextra -= 1; - - gdk_draw_rectangle (widget->window, - widget->style->fg_gc[GTK_STATE_NORMAL], - FALSE, 0, 0, - widget->allocation.width - 1, - widget->allocation.height - 1); + + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "text", + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); } - - gtk_draw_shadow (widget->style, widget->window, - GTK_STATE_NORMAL, GTK_SHADOW_IN, - x, y, width, height); - + + gtk_paint_shadow (widget->style, widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_IN, + NULL, widget, "text", + x, y, width, height); + x += xthick; y += ythick; width -= 2 * xthick; @@ -1380,14 +1381,6 @@ gtk_text_draw_focus (GtkWidget *widget) /* bottom rect */ clear_focus_area (text, x, x + height - yextra, width, yextra); } - else if (!GTK_WIDGET_HAS_FOCUS (widget)) - { - gdk_draw_rectangle (widget->window, - widget->style->base_gc[GTK_STATE_NORMAL], FALSE, - x, y, - width - 1, - height - 1); - } } else { @@ -4571,32 +4564,48 @@ expand_scratch_buffer (GtkText* text, guint len) } } -/* Returns a GC to draw a background for the text at a mark, - * or NULL, if the mark's background is NULL - * - * Side effect: modifies text->gc +/* Side effect: modifies text->gc */ -static GdkGC * -mark_bg_gc (GtkText* text, const GtkPropertyMark *mark) + +static void +draw_bg_rect (GtkText* text, GtkPropertyMark *mark, + gint x, gint y, gint width, gint height, + gboolean already_cleared) { GtkEditable *editable = GTK_EDITABLE(text); - + if ((mark->index >= MIN(editable->selection_start_pos, editable->selection_end_pos) && mark->index < MAX(editable->selection_start_pos, editable->selection_end_pos))) { - if (editable->has_selection) - return GTK_WIDGET(text)->style->bg_gc[GTK_STATE_SELECTED]; - else - return GTK_WIDGET(text)->style->bg_gc[GTK_STATE_ACTIVE]; + gtk_paint_flat_box(GTK_WIDGET(text)->style, text->text_area, + editable->has_selection ? + GTK_STATE_SELECTED : GTK_STATE_ACTIVE, + GTK_SHADOW_NONE, + NULL, GTK_WIDGET(text), "text", + x, y, width, height); } else if (!gdk_color_equal(MARK_CURRENT_BACK (text, mark), >K_WIDGET(text)->style->base[GTK_STATE_NORMAL])) - { gdk_gc_set_foreground (text->gc, MARK_CURRENT_BACK (text, mark)); - return text->gc; + + gdk_draw_rectangle (text->text_area, + text->gc, + TRUE, x, y, width, height); + } + else if (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL]) + { + GdkRectangle rect; + + rect.x = x; + rect.y = y; + rect.width = width; + rect.height = height; + + clear_area (text, &rect); } - return NULL; + else if (!already_cleared) + gdk_window_clear_area (text->text_area, x, y, width, height); } static void @@ -4609,7 +4618,7 @@ draw_line (GtkText* text, gint len = 0; guint running_offset = lp->tab_cont.pixel_offset; guchar* buffer; - GdkGC *fg_gc, *bg_gc; + GdkGC *fg_gc; GtkEditable *editable = GTK_EDITABLE(text); @@ -4645,27 +4654,8 @@ draw_line (GtkText* text, if (running_offset > 0) { - bg_gc = mark_bg_gc (text, &mark); - - if (bg_gc) - gdk_draw_rectangle (text->text_area, - bg_gc, - TRUE, - 0, - pixel_start_height, - running_offset, - LINE_HEIGHT (*lp)); - else if (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL]) - { - GdkRectangle rect; - - rect.x = 0; - rect.y = pixel_start_height; - rect.width = running_offset; - rect.height = LINE_HEIGHT (*lp); - - clear_area (text, &rect); - } + draw_bg_rect (text, &mark, 0, pixel_start_height, running_offset, + LINE_HEIGHT (*lp), TRUE); } for (; chars > 0; chars -= len, buffer += len, len = 0) @@ -4697,26 +4687,8 @@ draw_line (GtkText* text, else pixel_width = gdk_text_width (font, (gchar*) buffer, len); - bg_gc = mark_bg_gc (text, &mark); - if (bg_gc) - gdk_draw_rectangle (text->text_area, - bg_gc, - TRUE, - running_offset, - pixel_start_height, - pixel_width, - LINE_HEIGHT(*lp)); - else if (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL]) - { - GdkRectangle rect; - - rect.x = running_offset; - rect.y = pixel_start_height; - rect.width = pixel_width; - rect.height = LINE_HEIGHT (*lp); - - clear_area (text, &rect); - } + draw_bg_rect (text, &mark, running_offset, pixel_start_height, + pixel_width, LINE_HEIGHT (*lp), TRUE); if ((mark.index >= selection_start_pos) && (mark.index < selection_end_pos)) @@ -4745,32 +4717,23 @@ draw_line (GtkText* text, } else { + gint pixels_remaining; + gint space_width; + gint spaces_avail; + len = 1; - bg_gc = mark_bg_gc (text, &mark); - if (bg_gc) - { - gint pixels_remaining; - gint space_width; - gint spaces_avail; - - gdk_window_get_size (text->text_area, &pixels_remaining, NULL); - pixels_remaining -= (LINE_WRAP_ROOM + running_offset); + gdk_window_get_size (text->text_area, &pixels_remaining, NULL); + pixels_remaining -= (LINE_WRAP_ROOM + running_offset); + + space_width = MARK_CURRENT_TEXT_FONT(text, &mark)->char_widths[' ']; + + spaces_avail = pixels_remaining / space_width; + spaces_avail = MIN (spaces_avail, tab_mark.to_next_tab); - space_width = MARK_CURRENT_TEXT_FONT(text, &mark)->char_widths[' ']; + draw_bg_rect (text, &mark, running_offset, pixel_start_height, + spaces_avail * space_width, LINE_HEIGHT (*lp), TRUE); - spaces_avail = pixels_remaining / space_width; - spaces_avail = MIN (spaces_avail, tab_mark.to_next_tab); - - gdk_draw_rectangle (text->text_area, - bg_gc, - TRUE, - running_offset, - pixel_start_height, - spaces_avail * space_width, - LINE_HEIGHT (*lp)); - } - running_offset += tab_mark.to_next_tab * MARK_CURRENT_TEXT_FONT(text, &mark)->char_widths[' ']; @@ -4833,7 +4796,6 @@ static void undraw_cursor (GtkText* text, gint absolute) { GtkEditable *editable = (GtkEditable *)text; - GdkGC *gc; TDEBUG (("in undraw_cursor\n")); @@ -4849,30 +4811,11 @@ undraw_cursor (GtkText* text, gint absolute) g_assert(text->cursor_mark.property); font = MARK_CURRENT_FONT(text, &text->cursor_mark); - gc = mark_bg_gc (text, &text->cursor_mark); - if (!gc && (GTK_WIDGET (text)->style->bg_pixmap[GTK_STATE_NORMAL])) - { - GdkRectangle rect; - - rect.x = text->cursor_pos_x; - rect.y = text->cursor_pos_y - text->cursor_char_offset - font->ascent; - rect.width = 1; - rect.height = font->ascent + 1; /* @@@ I add one here because draw_line is inclusive, right? */ - - clear_area (text, &rect); - } - else - { - if (!gc) - { - gdk_gc_set_foreground (text->gc, MARK_CURRENT_BACK (text, &text->cursor_mark)); - gc = text->gc; - } - gdk_draw_line (text->text_area, gc, text->cursor_pos_x, - text->cursor_pos_y - text->cursor_char_offset, text->cursor_pos_x, - text->cursor_pos_y - text->cursor_char_offset - font->ascent); - } + draw_bg_rect (text, &text->cursor_mark, + text->cursor_pos_x, + text->cursor_pos_y - text->cursor_char_offset - font->ascent, + 1, font->ascent + 1, FALSE); if (text->cursor_char) { diff --git a/gtk/gtkthemes.c b/gtk/gtkthemes.c new file mode 100644 index 0000000000..d2482a0af9 --- /dev/null +++ b/gtk/gtkthemes.c @@ -0,0 +1,138 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * Themes added by The Rasterman <raster@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include <stdio.h> +#include <stdlib.h> +#include <gmodule.h> +#include "gtkthemes.h" +#include "gtkmain.h" +#include "gtkrc.h" +#include "gtkselection.h" +#include "gtksignal.h" +#include "gtkwidget.h" +#include "gtkprivate.h" +#include "config.h" + +typedef struct _GtkThemeEnginePrivate GtkThemeEnginePrivate; + +struct _GtkThemeEnginePrivate { + GtkThemeEngine engine; + + GModule *library; + void *name; + + void (*init) (GtkThemeEngine *); + void (*exit) (void); + + guint refcount; +}; + +static GHashTable *engine_hash = NULL; + +GtkThemeEngine * +gtk_theme_engine_get (gchar *name) +{ + GtkThemeEnginePrivate *result; + + if (!engine_hash) + engine_hash = g_hash_table_new (g_str_hash, g_str_equal); + + /* get the library name for the theme */ + + result = g_hash_table_lookup (engine_hash, name); + + if (!result) + { + gchar fullname[1024]; + gchar *engine_path; + GModule *library; + + g_snprintf (fullname, 1024, "lib%s.so", name); + engine_path = gtk_rc_find_module_in_path(NULL, fullname); + + if (!engine_path) + return NULL; + + /* load the lib */ + + printf ("Loading Theme %s\n", engine_path); + + library = g_module_open (engine_path, 0); + g_free(engine_path); + if (!library) + g_error(g_module_error()); + else + { + result = g_new (GtkThemeEnginePrivate, 1); + + result->refcount = 1; + result->name = g_strdup (name); + result->library = library; + + /* extract symbols from the lib */ + if (!g_module_symbol (library, "theme_init", + (gpointer *)&result->init) || + !g_module_symbol (library, "theme_exit", + (gpointer *)&result->exit)) + { + g_error (g_module_error()); + g_free (result); + return NULL; + } + + /* call the theme's init (theme_init) function to let it */ + /* setup anything it needs to set up. */ + result->init((GtkThemeEngine *)result); + + g_hash_table_insert (engine_hash, result->name, result); + } + } + else + result->refcount++; + + return (GtkThemeEngine *)result; +} + +void +gtk_theme_engine_ref (GtkThemeEngine *engine) +{ + g_return_if_fail (engine != NULL); + + ((GtkThemeEnginePrivate *)engine)->refcount++; +} + +void +gtk_theme_engine_unref (GtkThemeEngine *engine) +{ + GtkThemeEnginePrivate *private; + + g_return_if_fail (engine != NULL); + + private = (GtkThemeEnginePrivate *)engine; + private->refcount--; + + if (private->refcount == 0) + { + g_hash_table_remove (engine_hash, private->name); + + g_module_close (private->library); + g_free (private->name); + g_free (private); + } +} diff --git a/gtk/gtkthemes.h b/gtk/gtkthemes.h new file mode 100644 index 0000000000..135b17ed9d --- /dev/null +++ b/gtk/gtkthemes.h @@ -0,0 +1,95 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * Themes added by The Rasterman <raster@redhat.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#ifndef __GTK_THEMES_H__ +#define __GTK_THEMES_H__ + + +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <gdk/gdk.h> +#include <gtk/gtkstyle.h> +#include <gtk/gtkwidget.h> + +struct _GtkThemeEngine { + /* Fill in engine_data pointer in a GtkRcStyle by parsing contents + * of brackets. Returns G_TOKEN_NONE if succesfull, otherwise returns + * the token it expected but didn't get. + */ + guint (*parse_rc_style) (GScanner *scanner, GtkRcStyle *rc_style); + + /* Combine RC style data from src into dest. If + * dest->engine_data is NULL, it should be initialized to default + * values. + */ + void (*merge_rc_style) (GtkRcStyle *dest, GtkRcStyle *src); + + /* Fill in style->engine_data from rc_style->engine_data */ + void (*rc_style_to_style) (GtkStyle *style, GtkRcStyle *rc_style); + + /* Duplicate engine_data from src to dest. The engine_data will + * not subsequently be modified except by a call to realize_style() + * so if realize_style() does nothing, refcounting is appropriate. + */ + void (*duplicate_style) (GtkStyle *dest, GtkStyle *src); + + /* If style needs to initialize for a particular colormap/depth + * combination, do it here. style->colormap/style->depth will have + * been set at this point, and style itself initialized for + * the colormap + */ + void (*realize_style) (GtkStyle *new_style); + + /* If style needs to clean up for a particular colormap/depth + * combination, do it here. + */ + void (*unrealize_style) (GtkStyle *new_style); + + /* Clean up rc_style->engine_data before rc_style is destroyed */ + void (*destroy_rc_style) (GtkRcStyle *rc_style); + + /* Clean up style->engine_data before style is destroyed */ + void (*destroy_style) (GtkStyle *style); + + void (*set_background) (GtkStyle *style, + GdkWindow *window, + GtkStateType state_type); +}; + +GtkThemeEngine *gtk_theme_engine_get (gchar *name); +void gtk_theme_engine_ref (GtkThemeEngine *engine); +void gtk_theme_engine_unref (GtkThemeEngine *engine); + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Initialization, exit, mainloop and miscellaneous routines + */ +void gtk_themes_init (int *argc, + char ***argv); +void gtk_themes_exit (gint error_code); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __GTK_THEMES_H__ */ diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 2c5b67eafc..cd8e6e04e2 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -52,10 +52,12 @@ static void gtk_toggle_button_set_arg (GtkObject *object, static void gtk_toggle_button_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - +static void gtk_toggle_button_leave (GtkButton *button); +static void gtk_toggle_button_realize (GtkWidget *widget); +static void gtk_toggle_button_unrealize (GtkWidget *widget); static guint toggle_button_signals[LAST_SIGNAL] = { 0 }; - +static GtkContainerClass *parent_class = NULL; GtkType gtk_toggle_button_get_type (void) @@ -95,6 +97,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class) container_class = (GtkContainerClass*) class; button_class = (GtkButtonClass*) class; + parent_class = gtk_type_class (GTK_TYPE_BUTTON); + gtk_object_add_arg_type ("GtkToggleButton::active", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ACTIVE); gtk_object_add_arg_type ("GtkToggleButton::draw_indicator", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_INDICATOR); @@ -112,6 +116,8 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class) object_class->get_arg = gtk_toggle_button_get_arg; widget_class->draw_focus = gtk_toggle_button_draw_focus; + widget_class->realize = gtk_toggle_button_realize; + widget_class->unrealize = gtk_toggle_button_unrealize; button_class->pressed = gtk_toggle_button_pressed; button_class->released = gtk_toggle_button_released; @@ -208,7 +214,15 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button, if (toggle_button->draw_indicator != draw_indicator) { - toggle_button->draw_indicator = draw_indicator; + if (GTK_WIDGET_REALIZED(toggle_button)) + { + gtk_widget_unrealize(GTK_WIDGET(toggle_button)); + toggle_button->draw_indicator = draw_indicator; + gtk_widget_realize(GTK_WIDGET(toggle_button)); + gtk_widget_show(GTK_WIDGET(toggle_button)); + } + else + toggle_button->draw_indicator = draw_indicator; if (GTK_WIDGET_VISIBLE (toggle_button)) gtk_widget_queue_resize (GTK_WIDGET (toggle_button)); @@ -272,26 +286,16 @@ gtk_toggle_button_draw_focus (GtkWidget *widget) width -= 2; height -= 2; } - else - { - if (GTK_WIDGET_STATE (toggle_button) == GTK_STATE_ACTIVE) - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE, - x + 1, y + 1, width - 4, height - 4); - else - gdk_draw_rectangle (widget->window, - widget->style->bg_gc[GTK_WIDGET_STATE (widget)], FALSE, - x + 2, y + 2, width - 5, height - 5); - } if (toggle_button->active) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - gtk_draw_shadow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), shadow_type, - x, y, width, height); + gtk_paint_box (widget->style, widget->window, + GTK_WIDGET_STATE (widget), shadow_type, + NULL, widget, "togglebutton", + x, y, width, height); if (GTK_WIDGET_HAS_FOCUS (widget)) { @@ -300,10 +304,11 @@ gtk_toggle_button_draw_focus (GtkWidget *widget) width += 2; height += 2; - gdk_draw_rectangle (widget->window, - widget->style->black_gc, FALSE, - x, y, width - 1, height - 1); + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "togglebutton", + x, y, width - 1, height - 1); } + gtk_widget_draw (GTK_BIN (widget)->child, NULL); } } @@ -433,3 +438,80 @@ gtk_toggle_button_leave (GtkButton *button) gtk_widget_queue_draw (GTK_WIDGET (button)); } } + +static void +gtk_toggle_button_realize (GtkWidget *widget) +{ + GtkToggleButton *toggle_button; + GdkWindowAttr attributes; + gint attributes_mask; + gint border_width; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget)); + + toggle_button = GTK_TOGGLE_BUTTON (widget); + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + + border_width = GTK_CONTAINER (widget)->border_width; + + attributes.window_type = GDK_WINDOW_CHILD; + attributes.x = widget->allocation.x + border_width; + attributes.y = widget->allocation.y + border_width; + attributes.width = widget->allocation.width - border_width * 2; + attributes.height = widget->allocation.height - border_width * 2; + attributes.event_mask = gtk_widget_get_events (widget); + attributes.event_mask |= (GDK_EXPOSURE_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_ENTER_NOTIFY_MASK | + GDK_LEAVE_NOTIFY_MASK); + + if (toggle_button->draw_indicator) + { + GTK_WIDGET_SET_FLAGS (toggle_button, GTK_NO_WINDOW); + attributes.wclass = GDK_INPUT_ONLY; + attributes_mask = GDK_WA_X | GDK_WA_Y; + + widget->window = gtk_widget_get_parent_window(widget); + gdk_window_ref(widget->window); + + toggle_button->event_window = + gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + gdk_window_show(toggle_button->event_window); + gdk_window_set_user_data (toggle_button->event_window, toggle_button); + } + else + { + GTK_WIDGET_UNSET_FLAGS (toggle_button, GTK_NO_WINDOW); + attributes.wclass = GDK_INPUT_OUTPUT; + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + widget->window = + gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + gdk_window_set_user_data (widget->window, toggle_button); + } + widget->style = gtk_style_attach (widget->style, widget->window); +} + +static void +gtk_toggle_button_unrealize (GtkWidget *widget) +{ + GtkToggleButton *toggle_button; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget)); + + toggle_button = GTK_TOGGLE_BUTTON (widget); + + if (toggle_button->draw_indicator) + { + gdk_window_set_user_data (toggle_button->event_window, NULL); + gdk_window_destroy (toggle_button->event_window); + toggle_button->event_window = NULL; + } + + if (GTK_WIDGET_CLASS (parent_class)->unrealize) + (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); +} diff --git a/gtk/gtktogglebutton.h b/gtk/gtktogglebutton.h index 56dd1c3630..bd216758d1 100644 --- a/gtk/gtktogglebutton.h +++ b/gtk/gtktogglebutton.h @@ -45,6 +45,8 @@ struct _GtkToggleButton guint active : 1; guint draw_indicator : 1; + + GdkWindow *event_window; }; struct _GtkToggleButtonClass diff --git a/gtk/gtktooltips.c b/gtk/gtktooltips.c index d74d5f6f9e..74cdcbc92b 100644 --- a/gtk/gtktooltips.c +++ b/gtk/gtktooltips.c @@ -22,7 +22,7 @@ #include "gtkmain.h" #include "gtkwidget.h" -#include "gtkwindow.h" +#include "gtkdrawwindow.h" #include "gtksignal.h" #include "gtkstyle.h" #include "gtktooltips.h" @@ -43,6 +43,9 @@ static void gtk_tooltips_widget_remove (GtkWidget *widget, static void gtk_tooltips_set_active_widget (GtkTooltips *tooltips, GtkWidget *widget); static gint gtk_tooltips_timeout (gpointer data); +static gint gtk_tooltips_expose (GtkTooltips *tooltips, + GdkEventExpose *event); + static void gtk_tooltips_draw_tips (GtkTooltips *tooltips); static GtkDataClass *parent_class; @@ -171,9 +174,15 @@ gtk_tooltips_force_window (GtkTooltips *tooltips) if (!tooltips->tip_window) { - tooltips->tip_window = gtk_window_new (GTK_WINDOW_POPUP); + tooltips->tip_window = gtk_draw_window_new (GTK_WINDOW_POPUP); + gtk_widget_ref (tooltips->tip_window); gtk_window_set_policy (GTK_WINDOW (tooltips->tip_window), FALSE, FALSE, TRUE); - gtk_widget_realize (tooltips->tip_window); + + gtk_signal_connect_object (GTK_OBJECT (tooltips->tip_window), + "expose_event", + GTK_SIGNAL_FUNC (gtk_tooltips_expose), + GTK_OBJECT (tooltips)); + gtk_signal_connect (GTK_OBJECT (tooltips->tip_window), "destroy", gtk_widget_destroyed, @@ -378,6 +387,49 @@ gtk_tooltips_set_colors (GtkTooltips *tooltips, tooltips->background = background; } +static gint +gtk_tooltips_expose (GtkTooltips *tooltips, GdkEventExpose *event) +{ + GtkStyle *style; + gint y, baseline_skip, gap; + GtkTooltipsData *data; + GList *el; + + style = tooltips->tip_window->style; + + gap = (style->font->ascent + style->font->descent) / 4; + if (gap < 2) + gap = 2; + baseline_skip = style->font->ascent + style->font->descent + gap; + + data = tooltips->active_tips_data; + if (!data) + return FALSE; + + gtk_paint_flat_box(style, tooltips->tip_window->window, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, GTK_WIDGET(tooltips->tip_window), "tooltip", + 0, 0, -1, -1); + + y = style->font->ascent + 4; + + for (el = data->row; el; el = el->next) + { + if (el->data) + { + gtk_paint_string (style, tooltips->tip_window->window, + GTK_STATE_NORMAL, + NULL, GTK_WIDGET(tooltips->tip_window), "tooltip", + 4, y, el->data); + y += baseline_skip; + } + else + y += baseline_skip / 2; + } + + return FALSE; +} + static void gtk_tooltips_draw_tips (GtkTooltips * tooltips) { @@ -407,6 +459,7 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips) if (gap < 2) gap = 2; baseline_skip = style->font->ascent + style->font->descent + gap; + w = data->width; h = 8 - gap; for (el = data->row; el; el = el->next) @@ -432,51 +485,8 @@ gtk_tooltips_draw_tips (GtkTooltips * tooltips) else y = y + widget->allocation.height + 4; - gtk_widget_set_usize (tooltips->tip_window, w + 1, h + 1); + gtk_widget_set_usize (tooltips->tip_window, w, h); gtk_widget_popup (tooltips->tip_window, x, y); - - if (tooltips->gc == NULL) - tooltips->gc = gdk_gc_new (tooltips->tip_window->window); - - if (tooltips->background != NULL) - { - gdk_gc_set_foreground (tooltips->gc, tooltips->background); - gdk_gc_set_background (tooltips->gc, tooltips->foreground); - } - else - { - gdk_gc_set_foreground (tooltips->gc, &style->bg[GTK_STATE_NORMAL]); - gdk_gc_set_background (tooltips->gc, &style->fg[GTK_STATE_NORMAL]); - } - - gdk_gc_set_font (tooltips->gc, style->font); - gdk_draw_rectangle (tooltips->tip_window->window, tooltips->gc, TRUE, 0, 0, w, h); - - if (tooltips->foreground != NULL) - { - gdk_gc_set_foreground (tooltips->gc, tooltips->foreground); - gdk_gc_set_background (tooltips->gc, tooltips->background); - } - else - { - gdk_gc_set_foreground (tooltips->gc, &style->fg[GTK_STATE_NORMAL]); - gdk_gc_set_background (tooltips->gc, &style->bg[GTK_STATE_NORMAL]); - } - - gdk_draw_rectangle (tooltips->tip_window->window, tooltips->gc, FALSE, 0, 0, w, h); - y = style->font->ascent + 4; - - for (el = data->row; el; el = el->next) - { - if (el->data) - { - gdk_draw_string (tooltips->tip_window->window, style->font, - tooltips->gc, 4, y, el->data); - y += baseline_skip; - } - else - y += baseline_skip / 2; - } } static gint diff --git a/gtk/gtktreeitem.c b/gtk/gtktreeitem.c index aa7a112983..a4f57e3d5f 100644 --- a/gtk/gtktreeitem.c +++ b/gtk/gtktreeitem.c @@ -648,23 +648,28 @@ gtk_tree_item_draw (GtkWidget *widget, GTK_TREE (widget->parent)->current_indent + 2); item_area.height = widget->allocation.height; - if (gdk_rectangle_intersect (&item_area, area, &child_area)) + if (gdk_rectangle_intersect(&item_area, area, &child_area)) { - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_style_set_background (widget->style, widget->window, - GTK_STATE_INSENSITIVE); - else if(GTK_TREE(widget->parent)->view_mode == GTK_TREE_VIEW_LINE && - widget->state == GTK_STATE_SELECTED) - gtk_style_set_background (widget->style, widget->window, widget->state); - else - gdk_window_set_background (widget->window, - &widget->style->base[GTK_STATE_NORMAL]); - - gdk_window_clear_area (widget->window, - child_area.x, child_area.y, - child_area.width, child_area.height); - - /* gtk_tree_item_draw_lines(widget); */ + if (widget->state == GTK_STATE_NORMAL) + { + gdk_window_set_back_pixmap (widget->window, NULL, TRUE); + gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height); + } + else + { + if (!GTK_WIDGET_IS_SENSITIVE (widget)) + gtk_paint_flat_box(widget->style, widget->window, + widget->state, GTK_STATE_INSENSITIVE, + area, widget, "treeitem", + 0, 0, -1, -1); + else + gtk_paint_flat_box(widget->style, widget->window, + widget->state, GTK_SHADOW_ETCHED_OUT, + area, widget, "treeitem", + 0, 0, -1, -1); + } + + gtk_tree_item_draw_lines(widget); if (tree_item->pixmaps_box && GTK_WIDGET_VISIBLE(tree_item->pixmaps_box) && @@ -673,66 +678,31 @@ gtk_tree_item_draw (GtkWidget *widget, } /* draw right side */ - if (gtk_widget_intersect (bin->child, area, &child_area)) + if (gtk_widget_intersect (bin->child, area, &child_area)) { - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gtk_style_set_background (widget->style, widget->window, - GTK_STATE_INSENSITIVE); - else if (widget->state == GTK_STATE_NORMAL) - gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]); - else - gtk_style_set_background (widget->style, widget->window, widget->state); - - gdk_window_clear_area (widget->window, child_area.x, child_area.y, - child_area.width+1, child_area.height); - - if (bin->child && - GTK_WIDGET_VISIBLE(bin->child) && - gtk_widget_intersect (bin->child, area, &child_area)) - gtk_widget_draw (bin->child, &child_area); - } + if (bin->child && + GTK_WIDGET_VISIBLE(bin->child) && + gtk_widget_intersect (bin->child, area, &child_area)) + gtk_widget_draw (bin->child, &child_area); + } + + if (GTK_WIDGET_HAS_FOCUS (widget)) + gtk_paint_focus (widget->style, widget->window, + NULL, widget, "treeitem", + 0, 0, + widget->allocation.width - 1, + widget->allocation.height - 1); - gtk_widget_draw_focus (widget); } } static void gtk_tree_item_draw_focus (GtkWidget *widget) { - GdkGC *gc; - int dx; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TREE_ITEM (widget)); - if (GTK_WIDGET_DRAWABLE (widget)) - { - if (GTK_WIDGET_HAS_FOCUS (widget)) - gc = widget->style->black_gc; - else if (!GTK_WIDGET_IS_SENSITIVE (widget)) - gc = widget->style->bg_gc[GTK_STATE_INSENSITIVE]; - else if (widget->state == GTK_STATE_NORMAL) - gc = widget->style->base_gc[GTK_STATE_NORMAL]; - else - gc = widget->style->bg_gc[widget->state]; - - dx = 0; - - if (GTK_TREE(widget->parent)->view_mode == GTK_TREE_VIEW_ITEM) - dx = (GTK_TREE_ITEM(widget)->pixmaps_box->allocation.width + DEFAULT_DELTA + - GTK_TREE(widget->parent)->current_indent + 1); - - gdk_draw_rectangle (widget->window, gc, FALSE, dx, 0, - widget->allocation.width - 1 - dx, - widget->allocation.height - 1); - - if (GTK_TREE (widget->parent)->view_line && - (!GTK_IS_ROOT_TREE (widget->parent) || - (GTK_IS_ROOT_TREE (widget->parent) && GTK_TREE_ITEM(widget)->subtree))) - { - gtk_tree_item_draw_lines(widget); - } - } + gtk_widget_draw(widget, NULL); } static gint @@ -848,7 +818,7 @@ gtk_real_tree_item_toggle (GtkItem *item) { /* Should we really bother with this bit? A listitem not in a list? * -Johannes Keukelaar - * yes, always be on the save side! + * yes, always be on the safe side! * -timj */ if (GTK_WIDGET (item)->state == GTK_STATE_SELECTED) diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index 1baf3a8874..0ef84889bc 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -57,6 +57,8 @@ static void gtk_viewport_adjustment_changed (GtkAdjustment *adjustment, gpointer data); static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data); +static void gtk_viewport_style_set (GtkWidget *widget, + GtkStyle *previous_style); static GtkBinClass *parent_class; @@ -122,7 +124,8 @@ gtk_viewport_class_init (GtkViewportClass *class) widget_class->expose_event = gtk_viewport_expose; widget_class->size_request = gtk_viewport_size_request; widget_class->size_allocate = gtk_viewport_size_allocate; - + widget_class->style_set = gtk_viewport_style_set; + container_class->add = gtk_viewport_add; } @@ -438,7 +441,12 @@ gtk_viewport_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL); - + + gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + NULL, widget, "viewportbin", + 0, 0, -1, -1); + gdk_window_show (viewport->bin_window); gdk_window_show (viewport->view_window); } @@ -641,6 +649,10 @@ gtk_viewport_size_allocate (GtkWidget *widget, child_allocation.y, child_allocation.width, child_allocation.height); + gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + NULL, widget, "viewportbin", + 0, 0, -1, -1); } viewport->hadjustment->page_size = child_allocation.width; @@ -757,3 +769,28 @@ gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, child_allocation.y); } } + +static void +gtk_viewport_style_set (GtkWidget *widget, + GtkStyle *previous_style) +{ + GtkViewport *viewport; + + if (GTK_WIDGET_REALIZED (widget) && + !GTK_WIDGET_NO_WINDOW (widget)) + { + viewport = GTK_VIEWPORT (widget); + + gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL); + gtk_style_set_background (widget->style, widget->window, widget->state); + gtk_paint_flat_box(widget->style, viewport->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + NULL, widget, "viewportbin", + 0, 0, -1, -1); + if (GTK_WIDGET_DRAWABLE (widget)) + { + gdk_window_clear (widget->window); + gdk_window_clear (viewport->bin_window); + } + } +} diff --git a/gtk/gtkvpaned.c b/gtk/gtkvpaned.c index 32bebd5f40..55cd2b9bf4 100644 --- a/gtk/gtkvpaned.c +++ b/gtk/gtkvpaned.c @@ -229,6 +229,8 @@ gtk_vpaned_draw (GtkWidget *widget, paned = GTK_PANED (widget); border_width = GTK_CONTAINER (paned)->border_width; + gdk_window_clear_area (widget->window, + area->x, area->y, area->width, area->height); if (paned->child1 && gtk_widget_intersect (paned->child1, area, &child_area)) gtk_widget_draw (paned->child1, &child_area); @@ -236,18 +238,10 @@ gtk_vpaned_draw (GtkWidget *widget, gtk_widget_intersect (paned->child2, area, &child_area)) gtk_widget_draw (paned->child2, &child_area); - gdk_draw_line (widget->window, - widget->style->dark_gc[widget->state], - 0, - border_width + paned->child1_size + paned->gutter_size / 2 - 1, - widget->allocation.width - 1, - border_width + paned->child1_size + paned->gutter_size / 2 - 1); - gdk_draw_line (widget->window, - widget->style->light_gc[widget->state], - 0, - border_width + paned->child1_size + paned->gutter_size / 2, - widget->allocation.width - 1, - border_width + paned->child1_size + paned->gutter_size / 2); + gtk_paint_hline(widget->style, widget->window, GTK_STATE_NORMAL, + area, widget, "vpaned", + 0, widget->allocation.width - 1, + border_width + paned->child1_size + paned->gutter_size / 2 - 1); } } diff --git a/gtk/gtkvruler.c b/gtk/gtkvruler.c index f19e5eab29..3da583548d 100644 --- a/gtk/gtkvruler.c +++ b/gtk/gtkvruler.c @@ -162,7 +162,13 @@ gtk_vruler_draw_ticks (GtkRuler *ruler) width = widget->allocation.height; height = widget->allocation.width - ythickness * 2; - gdk_draw_line (ruler->backing_store, gc, + gtk_paint_box (widget->style, ruler->backing_store, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "vruler", + 0, 0, + widget->allocation.width, widget->allocation.height); + + gdk_draw_line (ruler->backing_store, gc, height + xthickness, ythickness, height + xthickness, @@ -234,12 +240,6 @@ gtk_vruler_draw_ticks (GtkRuler *ruler) for (j = 0; j < (int) strlen (unit_str); j++) { digit_str[0] = unit_str[j]; - gdk_draw_rectangle (ruler->backing_store, - bg_gc, TRUE, - xthickness + 1, - pos + digit_height * j + 1, - gdk_string_width(font, digit_str), - digit_height); gdk_draw_string (ruler->backing_store, font, gc, xthickness + 1, pos + digit_height * (j + 1) + 1, diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index 5fecac3564..2bdc33c11f 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -38,13 +38,20 @@ static void gtk_vscale_pos_trough (GtkVScale *vscale, gint *y, gint *w, gint *h); +static void gtk_vscale_pos_background (GtkVScale *vscale, + gint *x, + gint *y, + gint *w, + gint *h); static void gtk_vscale_draw_slider (GtkRange *range); static void gtk_vscale_draw_value (GtkScale *scale); +static void gtk_vscale_draw (GtkWidget *widget, + GdkRectangle *area); static gint gtk_vscale_trough_keys (GtkRange *range, GdkEventKey *key, GtkScrollType *scroll, GtkTroughType *pos); - +static void gtk_vscale_clear_background (GtkRange *range); guint gtk_vscale_get_type (void) @@ -85,12 +92,14 @@ gtk_vscale_class_init (GtkVScaleClass *class) widget_class->realize = gtk_vscale_realize; widget_class->size_request = gtk_vscale_size_request; widget_class->size_allocate = gtk_vscale_size_allocate; + widget_class->draw = gtk_vscale_draw; range_class->slider_update = gtk_range_default_vslider_update; range_class->trough_click = gtk_range_default_vtrough_click; range_class->motion = gtk_range_default_vmotion; range_class->draw_slider = gtk_vscale_draw_slider; range_class->trough_keys = gtk_vscale_trough_keys; + range_class->clear_background = gtk_vscale_clear_background; scale_class->draw_value = gtk_vscale_draw_value; } @@ -98,6 +107,7 @@ gtk_vscale_class_init (GtkVScaleClass *class) static void gtk_vscale_init (GtkVScale *vscale) { + GTK_WIDGET_SET_FLAGS (vscale, GTK_NO_WINDOW); } GtkWidget* @@ -130,28 +140,26 @@ gtk_vscale_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); range = GTK_RANGE (widget); - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); + widget->window = gtk_widget_get_parent_window (widget); + gdk_window_ref (widget->window); gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &w, &h); + attributes.x = x; attributes.y = y; attributes.width = w; attributes.height = h; - attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK); + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.event_mask = gtk_widget_get_events (widget) | + (GDK_EXPOSURE_MASK | + GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_ENTER_NOTIFY_MASK | + GDK_LEAVE_NOTIFY_MASK); + attributes.visual = gtk_widget_get_visual (widget); + attributes.colormap = gtk_widget_get_colormap (widget); + + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; range->trough = gdk_window_new (widget->window, &attributes, attributes_mask); @@ -164,11 +172,9 @@ gtk_vscale_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); - gdk_window_set_user_data (widget->window, widget); gdk_window_set_user_data (range->trough, widget); gdk_window_set_user_data (range->slider, widget); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_style_set_background (widget->style, range->trough, GTK_STATE_ACTIVE); gtk_style_set_background (widget->style, range->slider, GTK_STATE_NORMAL); @@ -179,6 +185,69 @@ gtk_vscale_realize (GtkWidget *widget) } static void +gtk_vscale_draw (GtkWidget *widget, + GdkRectangle *area) +{ + GtkRange *range; + GdkRectangle tmp_area; + GdkRectangle child_area; + gint x, y, width, height; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_RANGE (widget)); + g_return_if_fail (area != NULL); + + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) + { + range = GTK_RANGE (widget); + + gtk_vscale_pos_background (GTK_VSCALE (widget), &x, &y, &width, &height); + + tmp_area.x = x; + tmp_area.y = y; + tmp_area.width = width; + tmp_area.height = height; + + if (gdk_rectangle_intersect (area, &tmp_area, &child_area)) + gtk_range_draw_background (range); + + gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &width, &height); + + tmp_area.x = x; + tmp_area.y = y; + tmp_area.width = width; + tmp_area.height = height; + + if (gdk_rectangle_intersect (area, &tmp_area, &child_area)) + { + gtk_range_draw_trough (range); + gtk_range_draw_slider (range); + gtk_range_draw_step_forw (range); + gtk_range_draw_step_back (range); + } + } +} + +static void +gtk_vscale_clear_background (GtkRange *range) +{ + GtkWidget *widget; + GtkScale *scale; + gint x, y, width, height; + + g_return_if_fail (range != NULL); + g_return_if_fail (GTK_IS_SCALE (range)); + + widget = GTK_WIDGET (range); + scale = GTK_SCALE (range); + + gtk_vscale_pos_background (GTK_VSCALE (widget), &x, &y, &width, &height); + + gtk_widget_queue_clear_area (GTK_WIDGET (range), + x, y, width, height); +} + +static void gtk_vscale_size_request (GtkWidget *widget, GtkRequisition *requisition) { @@ -236,10 +305,6 @@ gtk_vscale_size_allocate (GtkWidget *widget, range = GTK_RANGE (widget); scale = GTK_SCALE (widget); - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); - gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &width, &height); gdk_window_move_resize (range->trough, x, y, width, height); @@ -300,13 +365,60 @@ gtk_vscale_pos_trough (GtkVScale *vscale, } *y += 1; *h -= 2; + + *x += widget->allocation.x; + *y += widget->allocation.y; +} + +static void +gtk_vscale_pos_background (GtkVScale *vscale, + gint *x, + gint *y, + gint *w, + gint *h) +{ + GtkWidget *widget; + GtkScale *scale; + + gint tx, ty, twidth, theight; + + g_return_if_fail (vscale != NULL); + g_return_if_fail (GTK_IS_VSCALE (vscale)); + g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL)); + + gtk_vscale_pos_trough (vscale, &tx, &ty, &twidth, &theight); + + widget = GTK_WIDGET (vscale); + scale = GTK_SCALE (vscale); + + *x = widget->allocation.x; + *y = widget->allocation.y; + *w = widget->allocation.width; + *h = widget->allocation.height; + + switch (scale->value_pos) + { + case GTK_POS_LEFT: + *w -= twidth; + break; + case GTK_POS_RIGHT: + *x = tx; + *w -= twidth; + break; + case GTK_POS_TOP: + *h -= theight; + break; + case GTK_POS_BOTTOM: + *y = ty; + *h -= theight; + break; + } } static void gtk_vscale_draw_slider (GtkRange *range) { GtkStateType state_type; - gint width, height; g_return_if_fail (range != NULL); g_return_if_fail (GTK_IS_VSCALE (range)); @@ -319,16 +431,11 @@ gtk_vscale_draw_slider (GtkRange *range) else state_type = GTK_STATE_NORMAL; - gtk_style_set_background (GTK_WIDGET (range)->style, range->slider, state_type); - gdk_window_clear (range->slider); - - gdk_window_get_size (range->slider, &width, &height); - gtk_draw_hline (GTK_WIDGET (range)->style, range->slider, - state_type, 1, width - 2, height / 2); - - gtk_draw_shadow (GTK_WIDGET (range)->style, range->slider, - state_type, GTK_SHADOW_OUT, - 0, 0, -1, -1); + gtk_paint_slider(GTK_WIDGET (range)->style, range->slider, state_type, + GTK_SHADOW_OUT, + NULL, GTK_WIDGET (range), "vscale", + 0, 0, -1, -1, + GTK_ORIENTATION_VERTICAL); } } @@ -336,6 +443,7 @@ static void gtk_vscale_draw_value (GtkScale *scale) { GtkStateType state_type; + GtkWidget *widget; gchar buffer[32]; gint text_width; gint width, height; @@ -344,11 +452,10 @@ gtk_vscale_draw_value (GtkScale *scale) g_return_if_fail (scale != NULL); g_return_if_fail (GTK_IS_VSCALE (scale)); + widget = GTK_WIDGET (scale); + if (scale->draw_value) { - gdk_window_get_size (GTK_WIDGET (scale)->window, &width, &height); - gdk_window_clear_area (GTK_WIDGET (scale)->window, 1, 1, width - 3, height - 3); - sprintf (buffer, "%0.*f", GTK_RANGE (scale)->digits, GTK_RANGE (scale)->adjustment->value); text_width = gdk_string_measure (GTK_WIDGET (scale)->style->font, buffer); @@ -361,7 +468,7 @@ gtk_vscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height); x -= SCALE_CLASS (scale)->value_spacing + text_width; - y += ((height - + y += widget->allocation.y + ((height - (GTK_WIDGET (scale)->style->font->ascent + GTK_WIDGET (scale)->style->font->descent)) / 2 + GTK_WIDGET (scale)->style->font->ascent); @@ -373,7 +480,7 @@ gtk_vscale_draw_value (GtkScale *scale) gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height); x += width + SCALE_CLASS (scale)->value_spacing; - y += ((height - + y += widget->allocation.y + ((height - (GTK_WIDGET (scale)->style->font->ascent + GTK_WIDGET (scale)->style->font->descent)) / 2 + GTK_WIDGET (scale)->style->font->ascent); @@ -400,9 +507,11 @@ gtk_vscale_draw_value (GtkScale *scale) if (!GTK_WIDGET_IS_SENSITIVE (scale)) state_type = GTK_STATE_INSENSITIVE; - gtk_draw_string (GTK_WIDGET (scale)->style, - GTK_WIDGET (scale)->window, - state_type, x, y, buffer); + gtk_paint_string (GTK_WIDGET (scale)->style, + GTK_WIDGET (scale)->window, + state_type, + NULL, GTK_WIDGET (scale), "vscale", + x, y, buffer); } } diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index c8b960a319..2e02acf227 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -258,9 +258,11 @@ gtk_vscrollbar_draw_step_forw (GtkRange *range) else shadow_type = GTK_SHADOW_OUT; - gtk_draw_arrow (GTK_WIDGET (range)->style, range->step_forw, - state_type, shadow_type, GTK_ARROW_DOWN, - TRUE, 0, 0, -1, -1); + gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_forw, + state_type, shadow_type, + NULL, GTK_WIDGET (range), "scrollbar", + GTK_ARROW_DOWN, + TRUE, 0, 0, -1, -1); } } @@ -290,9 +292,11 @@ gtk_vscrollbar_draw_step_back (GtkRange *range) else shadow_type = GTK_SHADOW_OUT; - gtk_draw_arrow (GTK_WIDGET (range)->style, range->step_back, - state_type, shadow_type, GTK_ARROW_UP, - TRUE, 0, 0, -1, -1); + gtk_paint_arrow (GTK_WIDGET (range)->style, range->step_back, + state_type, shadow_type, + NULL, GTK_WIDGET (range), "scrollbar", + GTK_ARROW_UP, + TRUE, 0, 0, -1, -1); } } diff --git a/gtk/gtkvseparator.c b/gtk/gtkvseparator.c index eb70f01af0..dac67f20c8 100644 --- a/gtk/gtkvseparator.c +++ b/gtk/gtkvseparator.c @@ -83,11 +83,12 @@ gtk_vseparator_expose (GtkWidget *widget, g_return_val_if_fail (event != NULL, FALSE); if (GTK_WIDGET_DRAWABLE (widget)) - gtk_draw_vline (widget->style, widget->window, GTK_STATE_NORMAL, - widget->allocation.y, - widget->allocation.y + widget->allocation.height, - widget->allocation.x + (widget->allocation.width - - widget->style->klass->xthickness) / 2); + gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL, + &event->area, widget, "vseparator", + widget->allocation.y, + widget->allocation.y + widget->allocation.height, + widget->allocation.x + (widget->allocation.width - + widget->style->klass->xthickness) / 2); return FALSE; } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 234ad3ae03..b8abd70b45 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -150,6 +150,9 @@ static gint gtk_widget_real_key_release_event (GtkWidget *widget, GdkEventKey *event); static void gtk_widget_style_set (GtkWidget *widget, GtkStyle *previous_style); + +static void gtk_widget_redraw_queue_remove (GtkWidget *widget); + static GdkColormap* gtk_widget_peek_colormap (void); static GdkVisual* gtk_widget_peek_visual (void); @@ -199,7 +202,8 @@ static const gchar *shape_info_key = "gtk-shape-info"; static const gchar *colormap_key = "gtk-colormap"; static const gchar *visual_key = "gtk-visual"; - +static const gchar *rc_style_key = "gtk-rc-style"; +static guint rc_style_key_id = 0; /***************************************** * gtk_widget_get_type: @@ -1210,6 +1214,7 @@ gtk_widget_unparent (GtkWidget *widget) * should eventually move into some gtk_window_unparent_branch() or * similar function. */ + toplevel = gtk_widget_get_toplevel (widget); if (GTK_CONTAINER (widget->parent)->focus_child == widget) { @@ -1241,6 +1246,9 @@ gtk_widget_unparent (GtkWidget *widget) gtk_window_set_default (GTK_WINDOW (toplevel), NULL); } + if (GTK_WIDGET_REDRAW_PENDING (widget)) + gtk_widget_redraw_queue_remove (widget); + if (GTK_IS_RESIZE_CONTAINER (widget)) gtk_container_clear_resize_widgets (GTK_CONTAINER (widget)); @@ -1308,15 +1316,10 @@ gtk_widget_unparent (GtkWidget *widget) toplevel = toplevel->parent; } - if (widget->window && GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_DRAWABLE (widget)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); /* Reset the width and height here, to force reallocation if we * get added back to a new parent. This won't work if our new @@ -1605,12 +1608,9 @@ gtk_widget_unrealize (GtkWidget *widget) { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - + if (GTK_WIDGET_REDRAW_PENDING (widget)) - { - gtk_widget_redraw_queue = g_slist_remove (gtk_widget_redraw_queue, widget); - GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING); - } + gtk_widget_redraw_queue_remove (widget); if (GTK_WIDGET_HAS_SHAPE_MASK (widget)) gtk_widget_shape_combine_mask (widget, NULL, -1, -1); @@ -1630,45 +1630,495 @@ gtk_widget_unrealize (GtkWidget *widget) * results: *****************************************/ -static gint -gtk_widget_idle_draw (gpointer data) +typedef struct _GtkDrawData GtkDrawData; +struct _GtkDrawData { + GdkRectangle rect; + GdkWindow *window; +}; + +static GMemChunk *draw_data_mem_chunk = NULL; +static GSList *draw_data_free_list = NULL; +static const gchar *draw_data_key = "gtk-draw-data"; +static guint draw_data_key_id = 0; + +static gint gtk_widget_idle_draw (gpointer data); + +static void +gtk_widget_queue_draw_data (GtkWidget *widget, + gint x, + gint y, + gint width, + gint height, + GdkWindow *window) { - while (gtk_widget_redraw_queue) - gtk_widget_draw (gtk_widget_redraw_queue->data, NULL); + GSList *node; + GtkDrawData *data; + + g_return_if_fail (widget != NULL); - return FALSE; + if ((width != 0) && (height != 0) && GTK_WIDGET_DRAWABLE (widget)) + { + if (!draw_data_key_id) + draw_data_key_id = g_quark_from_static_string (draw_data_key); + + if (draw_data_free_list) + { + node = draw_data_free_list; + data = node->data; + draw_data_free_list = draw_data_free_list->next; + } + else + { + if (!draw_data_mem_chunk) + draw_data_mem_chunk = g_mem_chunk_create (GtkDrawData, 64, + G_ALLOC_ONLY); + data = g_chunk_new (GtkDrawData, draw_data_mem_chunk); + node = g_slist_alloc(); + node->data = data; + } + + data->rect.x = x; + data->rect.y = y; + + if ((width < 0) || (height < 0)) + { + data->rect.width = 0; + data->rect.height = 0; + } + else + { + data->rect.width = width; + data->rect.height = height; + } + data->window = window; + + if ((width < 0) || (height < 0)) + { + GSList *draw_data_list = + gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + if (draw_data_list) + draw_data_free_list = g_slist_concat (draw_data_list, + draw_data_free_list); + node->next = NULL; + } + else + node->next = gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + + if (!GTK_WIDGET_REDRAW_PENDING (widget)) + { + GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_PENDING); + if (gtk_widget_redraw_queue == NULL) + gtk_idle_add_priority (GTK_PRIORITY_INTERNAL, + gtk_widget_idle_draw, + NULL); + gtk_widget_redraw_queue = g_slist_prepend (gtk_widget_redraw_queue, widget); + } + + gtk_object_set_data_by_id (GTK_OBJECT (widget), draw_data_key_id, node); + } } -void +void +gtk_widget_queue_draw_area (GtkWidget *widget, + gint x, + gint y, + gint width, + gint height) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + gtk_widget_queue_draw_data (widget, x, y, width, height, NULL); +} + +void gtk_widget_queue_draw (GtkWidget *widget) { + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + gtk_widget_queue_draw_data (widget, 0, 0, -1, -1, NULL); +} + +void +gtk_widget_queue_clear_area (GtkWidget *widget, + gint x, + gint y, + gint width, + gint height) +{ GtkWidget *parent; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (GTK_WIDGET_DRAWABLE (widget)) + + /* Find the correct widget */ + + if (GTK_WIDGET_NO_WINDOW (widget)) { - /* We queue the redraw if: - * a) the widget is not already queued for redraw and - * b) non of the widgets ancestors are queued for redraw. - */ parent = widget; - while (parent) + while (parent && GTK_WIDGET_NO_WINDOW (parent)) + parent = parent->parent; + + if (parent) + gtk_widget_queue_draw_data (parent, x, y, width, height, widget->window); + } + else + { + gint wx, wy, wwidth, wheight; + /* Translate widget relative to window-relative */ + + gdk_window_get_position (widget->window, &wx, &wy); + x -= wx - widget->allocation.x; + y -= wy - widget->allocation.y; + + gdk_window_get_size (widget->window, &wwidth, &wheight); + + if (x < 0) { - if (GTK_WIDGET_REDRAW_PENDING (parent)) - return; - parent = parent->parent; + width += x; x = 0; } + if (y < 0) + { + height += y; y = 0; + } + if (x + width > wwidth) + width = wwidth - x; + if (y + height > wheight) + height = wheight - y; + + gtk_widget_queue_draw_data (widget, x, y, width, height, NULL); + } +} + +static void +gtk_widget_redraw_queue_remove (GtkWidget *widget) +{ + GSList *draw_data_list; + GSList *tmp_list; + + g_return_if_fail (GTK_WIDGET_REDRAW_PENDING (widget)); + + gtk_widget_redraw_queue = g_slist_remove (gtk_widget_redraw_queue, widget); + + draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + tmp_list = g_slist_last (draw_data_list); + if (tmp_list) + { + tmp_list->next = draw_data_free_list; + draw_data_free_list = draw_data_list; + } + + gtk_object_set_data_by_id (GTK_OBJECT (widget), + draw_data_key_id, + NULL); + + GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING); +} + +void +gtk_widget_queue_clear (GtkWidget *widget) +{ + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); + + if (GTK_WIDGET_NO_WINDOW (widget)) + gtk_widget_queue_clear_area (widget, widget->allocation.x, + widget->allocation.y, + widget->allocation.width, + widget->allocation.height); + else + gtk_widget_queue_clear_area (widget, 0, 0, + widget->allocation.width, + widget->allocation.height); +} + +static gint +gtk_widget_draw_data_combine (GtkDrawData *parent, GtkDrawData *child) +{ + gint parent_x2, parent_y2; + gint child_x2, child_y2; + + /* Check for intersection */ + + parent_x2 = parent->rect.x + parent->rect.width; + child_x2 = child->rect.x + child->rect.width; + parent_y2 = parent->rect.y + parent->rect.height; + child_y2 = child->rect.y + child->rect.height; + + if ((child->rect.x > parent_x2) || (parent->rect.x > child_x2) || + (child->rect.y > parent_y2) || (parent->rect.y > child_y2)) + return FALSE; + else + { + parent->rect.x = MIN (parent->rect.x, child->rect.x); + parent->rect.y = MIN (parent->rect.y, child->rect.y); + parent->rect.width = MAX (parent_x2, child_x2) - parent->rect.x; + parent->rect.height = MAX (parent_y2, child_y2) - parent->rect.y; + } + + return TRUE; +} + +/* Take a rectangle with respect to window, and translate it + * to coordinates relative to widget's allocation, clipping through + * intermediate windows. Returns whether translation failed. If the + * translation failed, we have something like a handlebox, where + * the child widget's GdkWindow is not a child of the parents GdkWindow. + */ +static gboolean +gtk_widget_clip_rect (GtkWidget *widget, + GdkWindow *window, + GdkRectangle *rect, + gint *x_offset, + gint *y_offset) +{ + gint x,y, width, height; + + while (window && (window != widget->window)) + { + gdk_window_get_position (window, &x, &y); + rect->x += x; + if (x_offset) + *x_offset += x; + rect->y += y; + if (y_offset) + *y_offset += y; - GTK_PRIVATE_SET_FLAG (widget, GTK_REDRAW_PENDING); - if (gtk_widget_redraw_queue == NULL) - gtk_idle_add_priority (GTK_PRIORITY_INTERNAL, - gtk_widget_idle_draw, - NULL); + window = gdk_window_get_parent (window); + if (!window) + return FALSE; - gtk_widget_redraw_queue = g_slist_prepend (gtk_widget_redraw_queue, widget); + gdk_window_get_size (window, &width, &height); + + if (rect->x < 0) + { + rect->width += rect->x; + rect->x = 0; + } + if (rect->y < 0) + { + rect->height += rect->y; + rect->y = 0; + } + if (rect->x + rect->width > width) + rect->width = width - rect->x; + if (rect->y + rect->height > height) + rect->height = height - rect->y; } + + if (!window) + return FALSE; + + if (!GTK_WIDGET_NO_WINDOW (widget)) + { + if (gdk_window_get_toplevel (window) != window) + { + gdk_window_get_position (window, &x, &y); + rect->x += x - widget->allocation.x; + if (x_offset) + *x_offset += x - widget->allocation.x; + rect->y += y - widget->allocation.y; + if (y_offset) + *y_offset += y - widget->allocation.y; + } + } + + return TRUE; +} + +static gint +gtk_widget_idle_draw (gpointer data) +{ + GSList *widget_list; + GSList *draw_data_list; + GtkWidget *widget; + + /* Translate all draw requests to be allocation-relative */ + widget_list = gtk_widget_redraw_queue; + while (widget_list) + { + widget = widget_list->data; + draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + + while (draw_data_list) + { + gboolean full_allocation = FALSE; + GtkDrawData *data = draw_data_list->data; + + if (data->window) + { + /* If the translation fails, we have a handlebox, + * so redraw the whole widget. Could be done better? + */ + full_allocation = !gtk_widget_clip_rect (widget, + data->window, + &data->rect, + NULL, NULL); + data->window = NULL; + } + else + { + if ((data->rect.width == 0) && (data->rect.height == 0)) + { + if (GTK_WIDGET_NO_WINDOW (widget)) + { + data->rect.x = widget->allocation.x; + data->rect.y = widget->allocation.y; + } + else + { + data->rect.x = 0; + data->rect.y = 0; + } + data->rect.width = widget->allocation.width; + data->rect.height = widget->allocation.height; + } + } + + draw_data_list = draw_data_list->next; + } + + widget_list = widget_list->next; + } + + /* Coalesce redraws + */ + widget_list = gtk_widget_redraw_queue; + while (widget_list) + { + GSList *prev_node = NULL; + widget = widget_list->data; + draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + + while (draw_data_list) + { + gint x_offset, y_offset; + GtkDrawData *data = draw_data_list->data; + GSList *parent_list = draw_data_list->next; + GtkWidget *parent; + GdkWindow *window; + + x_offset = 0; + y_offset = 0; + + parent = widget; + while (parent) + { + while (parent_list) + { + if (gtk_widget_draw_data_combine (parent_list->data, data)) + { + GSList *tmp; + if (prev_node) + prev_node->next = draw_data_list->next; + else + gtk_object_set_data_by_id (GTK_OBJECT (widget), + draw_data_key_id, + draw_data_list->next); + + tmp = draw_data_list->next; + draw_data_list->next = draw_data_free_list; + draw_data_free_list = draw_data_list; + draw_data_list = tmp; + + goto next_rect; + } + + parent_list = parent_list->next; + } + + window = parent->window; + + if (parent->parent && parent->parent->window != window) + { + if (!GTK_WIDGET_NO_WINDOW (parent)) + { + gint x, y; + gdk_window_get_position (window, &x, &y); + data->rect.x -= x - parent->allocation.x; + x_offset -= x - parent->allocation.x; + data->rect.y -= y - parent->allocation.y; + y_offset -= y - parent->allocation.y; + } + /* If we can't translate the rectangle, stop trying to + * merge. (This occurs for a handlebox) + */ + if (!gtk_widget_clip_rect (parent->parent, window, &data->rect, + &x_offset, &y_offset)) + parent = NULL; + } + + if (parent) + parent = parent->parent; + + if (parent && GTK_WIDGET_REDRAW_PENDING (parent)) + parent_list = gtk_object_get_data_by_id (GTK_OBJECT (parent), + draw_data_key_id); + else + parent_list = NULL; + } + + /* OK, this rectangle stays around. But take advantage + * of the work we've done to clip it to the visible area - + * rect.width/height have already been appropriately + * decreased + */ + data->rect.x -= x_offset; + data->rect.y -= y_offset; + + + prev_node = draw_data_list; + + draw_data_list = draw_data_list->next; + next_rect: + continue; + } + widget_list = widget_list->next; + } + + /* Process the draws */ + + widget_list = gtk_widget_redraw_queue; + + while (widget_list) + { + widget = widget_list->data; + draw_data_list = gtk_object_get_data_by_id (GTK_OBJECT (widget), + draw_data_key_id); + gtk_object_set_data_by_id (GTK_OBJECT (widget), + draw_data_key_id, + NULL); + + GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING); + + while (draw_data_list) + { + GtkDrawData *data = draw_data_list->data; + gtk_widget_draw (widget, &data->rect); + + if (draw_data_list->next) + draw_data_list = draw_data_list->next; + else + { + draw_data_list->next = draw_data_free_list; + draw_data_free_list = draw_data_list; + break; + } + } + + widget_list = widget_list->next; + } + + g_slist_free (gtk_widget_redraw_queue); + gtk_widget_redraw_queue = NULL; + + return FALSE; } void @@ -1703,14 +2153,6 @@ gtk_widget_draw (GtkWidget *widget, g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - if (GTK_WIDGET_REDRAW_PENDING (widget)) - { - gtk_widget_redraw_queue = g_slist_remove (gtk_widget_redraw_queue, widget); - GTK_PRIVATE_UNSET_FLAG (widget, GTK_REDRAW_PENDING); - - area = NULL; - } - if (GTK_WIDGET_DRAWABLE (widget)) { if (!area) @@ -2139,9 +2581,13 @@ gtk_widget_event (GtkWidget *widget, signal_num = CLIENT_EVENT; break; case GDK_EXPOSE: - /* there is no sense in providing a widget with bogus expose events + /* there is no sense in providing a widget with bogus expose events. + * Widgets that are going to be resized don't need to be + * exposed, since they will be redrawn anyways. */ - if (!event->any.window) + if (!event->any.window || + GTK_WIDGET_RESIZE_NEEDED (widget) || + (widget->parent && GTK_WIDGET_RESIZE_NEEDED (widget->parent))) { gtk_widget_unref (widget); return TRUE; @@ -2534,7 +2980,9 @@ gtk_widget_set_state (GtkWidget *widget, data.parent_sensitive = TRUE; gtk_widget_propagate_state (widget, &data); - gtk_widget_queue_draw (widget); + + if (GTK_WIDGET_DRAWABLE (widget)) + gtk_widget_queue_clear (widget); } } @@ -2581,7 +3029,8 @@ gtk_widget_set_sensitive (GtkWidget *widget, data.parent_sensitive = TRUE; gtk_widget_propagate_state (widget, &data); - gtk_widget_queue_draw (widget); + if (GTK_WIDGET_DRAWABLE (widget)) + gtk_widget_queue_clear (widget); } /***************************************** @@ -2745,6 +3194,24 @@ gtk_widget_get_style (GtkWidget *widget) return widget->style; } +void +gtk_widget_modify_style (GtkWidget *widget, + GtkRcStyle *style) +{ + GtkRcStyle *old_style; + + if (!rc_style_key_id) + rc_style_key_id = g_quark_from_static_string (rc_style_key); + + old_style = gtk_object_get_data_by_id (GTK_OBJECT (widget), rc_style_key_id); + + if (style != old_style) + gtk_object_set_data_by_id_full (GTK_OBJECT (widget), + rc_style_key_id, + style, + (GtkDestroyNotify)gtk_rc_style_unref); +} + static void gtk_widget_style_set (GtkWidget *widget, GtkStyle *previous_style) @@ -2764,6 +3231,7 @@ gtk_widget_set_style_internal (GtkWidget *widget, gboolean initial_emission) { g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (style != NULL); if (widget->style != style) @@ -2771,6 +3239,8 @@ gtk_widget_set_style_internal (GtkWidget *widget, GtkStyle *previous_style; if (GTK_WIDGET_REALIZED (widget)) + gtk_reset_widget_shapes(widget); + if (GTK_WIDGET_REALIZED (widget)) gtk_style_detach (widget->style); previous_style = widget->style; @@ -2796,7 +3266,7 @@ gtk_widget_set_style_internal (GtkWidget *widget, (old_requisition.height != widget->requisition.height)) gtk_widget_queue_resize (widget); else if (GTK_WIDGET_DRAWABLE (widget)) - gtk_widget_queue_draw (widget); + gtk_widget_queue_clear (widget); } } else if (initial_emission) @@ -3699,11 +4169,7 @@ gtk_widget_real_unmap (GtkWidget *widget) GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); if (GTK_WIDGET_NO_WINDOW (widget)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); else gdk_window_hide (widget->window); } @@ -3825,7 +4291,7 @@ gtk_widget_real_size_allocate (GtkWidget *widget, { g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); - + if (GTK_WIDGET_NO_WINDOW (widget) && GTK_WIDGET_MAPPED (widget) && ((widget->allocation.x != allocation->x) || @@ -3834,19 +4300,17 @@ gtk_widget_real_size_allocate (GtkWidget *widget, (widget->allocation.height != allocation->height)) && (widget->allocation.width != 0) && (widget->allocation.height != 0)) - gdk_window_clear_area (widget->window, - widget->allocation.x, - widget->allocation.y, - widget->allocation.width, - widget->allocation.height); + gtk_widget_queue_clear (widget); widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) - gdk_window_move_resize (widget->window, - allocation->x, allocation->y, - allocation->width, allocation->height); + { + gdk_window_move_resize (widget->window, + allocation->x, allocation->y, + allocation->width, allocation->height); + } } /***************************************** diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index c2e74f9f8d..24bbda0be4 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -19,7 +19,6 @@ #ifndef __GTK_WIDGET_H__ #define __GTK_WIDGET_H__ - #include <gdk/gdk.h> #include <gtk/gtkaccelgroup.h> #include <gtk/gtkobject.h> @@ -100,7 +99,6 @@ typedef enum typedef struct _GtkRequisition GtkRequisition; typedef struct _GtkAllocation GtkAllocation; typedef struct _GtkSelectionData GtkSelectionData; -typedef struct _GtkWidget GtkWidget; typedef struct _GtkWidgetClass GtkWidgetClass; typedef struct _GtkWidgetAuxInfo GtkWidgetAuxInfo; typedef struct _GtkWidgetShapeInfo GtkWidgetShapeInfo; @@ -419,7 +417,22 @@ void gtk_widget_map (GtkWidget *widget); void gtk_widget_unmap (GtkWidget *widget); void gtk_widget_realize (GtkWidget *widget); void gtk_widget_unrealize (GtkWidget *widget); + +/* Queuing draws */ void gtk_widget_queue_draw (GtkWidget *widget); +void gtk_widget_queue_draw_area (GtkWidget *widget, + gint x, + gint y, + gint width, + gint height); +void gtk_widget_queue_clear (GtkWidget *widget); +void gtk_widget_queue_clear_area (GtkWidget *widget, + gint x, + gint y, + gint width, + gint height); + + void gtk_widget_queue_resize (GtkWidget *widget); void gtk_widget_draw (GtkWidget *widget, GdkRectangle *area); @@ -520,6 +533,9 @@ void gtk_widget_ensure_style (GtkWidget *widget); GtkStyle* gtk_widget_get_style (GtkWidget *widget); void gtk_widget_restore_default_style (GtkWidget *widget); +void gtk_widget_modify_style (GtkWidget *widget, + GtkRcStyle *style); + /* Descend recursively and set rc-style on all widgets without user styles */ void gtk_widget_reset_rc_styles (GtkWidget *widget); diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 6c44b79b93..97ec38c05c 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -89,6 +89,14 @@ static void gtk_window_set_hints (GtkWidget *widget, static void gtk_window_read_rcfiles (GtkWidget *widget, GdkEventClient *event); +static void gtk_window_draw (GtkWidget *widget, + GdkRectangle *area); +static gint gtk_window_expose (GtkWidget *widget, + GdkEventExpose *event); +static void gtk_window_style_set (GtkWidget *widget, + GtkStyle *previous_style); + + static GtkBinClass *parent_class = NULL; @@ -173,7 +181,11 @@ gtk_window_class_init (GtkWindowClass *klass) widget_class->focus_in_event = gtk_window_focus_in_event; widget_class->focus_out_event = gtk_window_focus_out_event; widget_class->client_event = gtk_window_client_event; + widget_class->style_set = gtk_window_style_set; + widget_class->draw = gtk_window_draw; + widget_class->expose_event = gtk_window_expose; + container_class->check_resize = gtk_window_check_resize; klass->set_focus = gtk_real_window_set_focus; @@ -567,13 +579,13 @@ gtk_window_realize (GtkWidget *widget) GtkWindow *window; GdkWindowAttr attributes; gint attributes_mask; - + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WINDOW (widget)); - + GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); window = GTK_WINDOW (widget); - + switch (window->type) { case GTK_WINDOW_TOPLEVEL: @@ -586,7 +598,7 @@ gtk_window_realize (GtkWidget *widget) attributes.window_type = GDK_WINDOW_TEMP; break; } - + attributes.title = window->title; attributes.wmclass_name = window->wmclass_name; attributes.wmclass_class = window->wmclass_class; @@ -602,16 +614,17 @@ gtk_window_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK); - + attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP; attributes_mask |= (window->title ? GDK_WA_TITLE : 0); attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0); - + widget->window = gdk_window_new (NULL, &attributes, attributes_mask); gdk_window_set_user_data (widget->window, window); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_window_paint (widget, NULL); } static void @@ -949,25 +962,49 @@ gtk_window_focus_out_event (GtkWidget *widget, return FALSE; } +static GdkAtom atom_rcfiles = GDK_NONE; + static void gtk_window_read_rcfiles (GtkWidget *widget, GdkEventClient *event) { - GList *toplevels; - + GList *embedded_windows; + + embedded_windows = gtk_object_get_data (GTK_OBJECT (widget), "gtk-embedded"); + if (embedded_windows) + { + GdkEventClient sev; + int i; + + for(i = 0; i < 5; i++) + sev.data.l[i] = 0; + sev.data_format = 32; + sev.message_type = atom_rcfiles; + + while (embedded_windows) + { + guint xid = GPOINTER_TO_UINT (embedded_windows->data); + gdk_event_send_client_message ((GdkEvent *) &sev, xid); + embedded_windows = embedded_windows->next; + } + } + if (gtk_rc_reparse_all ()) { - toplevels = gdk_window_get_toplevels(); + /* If the above returned true, some of our RC files are out + * of date, so we need to reset all our widgets. Our other + * toplevel windows will also get the message, but by + * then, the RC file will up to date, so we have to tell + * them now. + */ + GList *toplevels; + + toplevels = gtk_container_get_toplevels(); while (toplevels) { - gdk_window_get_user_data (toplevels->data, (gpointer*) &widget); - - if (widget) - gtk_widget_reset_rc_styles (widget); - + gtk_widget_reset_rc_styles (toplevels->data); toplevels = toplevels->next; } - g_list_free (toplevels); } } @@ -975,7 +1012,6 @@ static gint gtk_window_client_event (GtkWidget *widget, GdkEventClient *event) { - static GdkAtom atom_rcfiles = GDK_NONE; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); @@ -1136,7 +1172,7 @@ gtk_window_move_resize (GtkWindow *window) * keep track of what changed */ GtkAllocation allocation; - + allocation.x = 0; allocation.y = 0; allocation.width = widget->requisition.width; @@ -1148,7 +1184,7 @@ gtk_window_move_resize (GtkWindow *window) { if ((x != -1) && (y != -1)) gdk_window_move (widget->window, x, y); - + gtk_container_resize_children (GTK_CONTAINER (window)); } } @@ -1235,3 +1271,59 @@ gtk_window_set_hints (GtkWidget *widget, } } } + +static void +gtk_window_paint (GtkWidget *widget, + GdkRectangle *area) +{ + gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, area, widget, "base", 0, 0, -1, -1); +} + +static gint +gtk_window_expose (GtkWidget *widget, + GdkEventExpose *event) +{ + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE); + g_return_val_if_fail (event != NULL, FALSE); + + gtk_window_paint (widget, &event->area); + + if (GTK_WIDGET_CLASS (parent_class)->expose_event) + return (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); + + return FALSE; +} + +static void +gtk_window_draw (GtkWidget *widget, + GdkRectangle *area) +{ + gtk_window_paint (widget, area); + + if (GTK_WIDGET_CLASS (parent_class)->draw) + (* GTK_WIDGET_CLASS (parent_class)->draw) (widget, area); +} + +static void +gtk_window_style_set (GtkWidget *widget, + GtkStyle *previous_style) +{ + GdkRectangle area; + + if (GTK_WIDGET_REALIZED (widget) && + !GTK_WIDGET_NO_WINDOW (widget)) + { + gtk_style_set_background (widget->style, widget->window, widget->state); + + area.x = 0; + area.y = 0; + area.width = widget->allocation.width; + area.height = widget->allocation.height; + gtk_window_draw(widget, &area); + + if (GTK_WIDGET_DRAWABLE (widget)) + gdk_window_clear (widget->window); + } +} diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 1aafdbc2c2..e16ee72b65 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -1867,10 +1867,7 @@ create_pixmap (void) button = gtk_button_new (); gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0); - style = gtk_widget_get_style(button); - - pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, - &style->bg[GTK_STATE_NORMAL], + pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, NULL, "test.xpm"); pixmapwid = gtk_pixmap_new (pixmap, mask); gdk_pixmap_unref (pixmap); diff --git a/gtk/testgtkrc b/gtk/testgtkrc index e4e6ba72c7..36bb124642 100644 --- a/gtk/testgtkrc +++ b/gtk/testgtkrc @@ -10,96 +10,15 @@ # widget <widget_set> style <style_name> # widget_class <widget_class_set> style <style_name> -# testgtkrc2 sets all the buttons in the main window to blue by default -include "testgtkrc2" +include "/opt/themes/share/themes/Metal/gtk/gtkrc" +#include "/home/otaylor/.themes/Ignorant/gtk/gtkrc" -pixmap_path "." - -style "default" -{ +style "defaultfont" { +# font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*" # fontset = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*" - font = "-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*" -} - -style "window" -{ -# bg_pixmap[NORMAL] = "warning.xpm" -} - -style "scale" -{ - fg[NORMAL] = { 1.0, 0, 0 } - bg_pixmap[NORMAL] = "<parent>" -} - -style "button" = "default" -{ -# fg[PRELIGHT] = { 1.0, 1.0, 1.0 } -# bg[PRELIGHT] = { 0, 0, 0.75 } -# bg[PRELIGHT] = { 0.75, 0, 0x00 } -} - -style "toggle_button" = "button" -{ - fg[NORMAL] = { 1.0, 0, 0 } - fg[ACTIVE] = { 1.0, 0, 0 } - bg_pixmap[NORMAL] = "<parent>" -} - -style "text" -{ - bg_pixmap[NORMAL] = "marble.xpm" - text[NORMAL] = { 1.0, 1.0, 1.0 } - fg[NORMAL] = { 1.0, 1.0, 1.0 } - base[NORMAL] = { 0.0, 0.0, 0.0 } } -style "slider" -{ - fg[NORMAL] = { 1.0, 1.0, 1.0 } - bg[NORMAL] = { 0.0, 0.0, 1.0 } - bg[ACTIVE] = { 0.0 ,0.0, 0.5 } - bg[PRELIGHT] = { 0.75 ,0.75, 1.0 } -} - -style "ruler" -{ - font = '-adobe-helvetica-medium-r-normal--*-80-*-*-*-*-*-*' -} - -style "curve" -{ - fg[NORMAL] = { 58000, 0, 0 } # red -} - -style "red-bar" -{ - bg[PRELIGHT] = { 0.95, .55, 0.55 } -} - -# override testgtk2, introduce the green color in the button list -style 'button_list' = 'button' -{ - font = "-adobe-helvetica-medium-r-normal--*-100-*-*-*-*-*-*" - bg[PRELIGHT] = { 0, 0.75, 0x00 } -} -widget "main window.*GtkScrolledWindow.*GtkButton*" style "button_list" - -# common default -class "GtkWidget" style "default" - -class "GtkScrollbar" style "red-bar" - -widget_class "GtkWindow" style "window" -widget_class "GtkDialog" style "window" -widget_class "GtkFileSelection" style "window" -widget_class "*Gtk*Scale" style "scale" -widget_class "*GtkCheckButton*" style "toggle_button" -widget_class "*GtkRadioButton*" style "toggle_button" -widget_class "*GtkButton*" style "button" -widget_class "*Ruler" style "ruler" -widget_class "*GtkText" style "text" -widget "*GtkCurve" style "curve" +class "GtkWidget" style "defaultfont" binding "test1" { @@ -120,7 +39,7 @@ binding "test2" # lowest # gtk (used by gtk for internal class bindings) # application (for hard coded bindings on application basis) -# rc (used implicitel by rc files) +# rc (used implicitly by rc files) # highest class "GtkButton" binding "test1" # implicit : rc class "GtkButton" binding : highest "test2" # override "rc" priority @@ -136,4 +55,3 @@ binding "clist-test" } class "GtkCList" binding "clist-test" - |