Commit 621c5832 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/display/Makefile.am app/display/display-types.h added GimpCanvas,

2003-11-10  Sven Neumann  <sven@gimp.org>

	* app/display/Makefile.am
	* app/display/display-types.h
	* app/display/gimpcanvas.[ch]: added GimpCanvas, derived from
	GtkDrawingArea.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-render.c
	* app/display/gimpdisplayshell.[ch]
parent dfa405ef
2003-11-10 Sven Neumann <sven@gimp.org>
* app/display/Makefile.am
* app/display/display-types.h
* app/display/gimpcanvas.[ch]: added GimpCanvas, derived from
GtkDrawingArea.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell.[ch]
2003-11-09 Michael Natterer <mitch@gimp.org>
 
* plug-ins/FractalExplorer/Dialogs.c
......@@ -16,6 +16,8 @@ noinst_LIBRARIES = libappdisplay.a
libappdisplay_a_sources = \
display-enums.h \
display-types.h \
gimpcanvas.c \
gimpcanvas.h \
gimpdisplay.c \
gimpdisplay.h \
gimpdisplayoptions.c \
......
......@@ -25,6 +25,8 @@
#include "display/display-enums.h"
typedef struct _GimpCanvas GimpCanvas;
typedef struct _GimpDisplay GimpDisplay;
typedef struct _GimpDisplayShell GimpDisplayShell;
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "display-types.h"
#include "gimpcanvas.h"
/* local function prototypes */
static void gimp_canvas_class_init (GimpCanvasClass *klass);
static void gimp_canvas_init (GimpCanvas *gdisp);
static void gimp_canvas_realize (GtkWidget *widget);
static void gimp_canvas_unrealize (GtkWidget *widget);
static GtkDrawingAreaClass *parent_class = NULL;
GType
gimp_canvas_get_type (void)
{
static GType canvas_type = 0;
if (! canvas_type)
{
static const GTypeInfo canvas_info =
{
sizeof (GimpCanvasClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_canvas_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpCanvas),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_canvas_init,
};
canvas_type = g_type_register_static (GTK_TYPE_DRAWING_AREA,
"GimpCanvas",
&canvas_info, 0);
}
return canvas_type;
}
static void
gimp_canvas_class_init (GimpCanvasClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
widget_class->realize = gimp_canvas_realize;
widget_class->unrealize = gimp_canvas_unrealize;
}
static void
gimp_canvas_init (GimpCanvas *canvas)
{
canvas->render_gc = NULL;
}
static void
gimp_canvas_realize (GtkWidget *widget)
{
GimpCanvas *canvas = GIMP_CANVAS (widget);
GTK_WIDGET_CLASS (parent_class)->realize (widget);
canvas->render_gc = gdk_gc_new (widget->window);
gdk_gc_set_exposures (canvas->render_gc, TRUE);
}
static void
gimp_canvas_unrealize (GtkWidget *widget)
{
GimpCanvas *canvas = GIMP_CANVAS (widget);
if (canvas->render_gc)
{
g_object_unref (canvas->render_gc);
canvas->render_gc = NULL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
GtkWidget *
gimp_canvas_new (void)
{
return GTK_WIDGET (g_object_new (GIMP_TYPE_CANVAS,
"name", "gimp-canvas",
NULL));
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_CANVAS_H__
#define __GIMP_CANVAS_H__
#include <gtk/gtkdrawingarea.h>
#define GIMP_TYPE_CANVAS (gimp_canvas_get_type ())
#define GIMP_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS, GimpCanvas))
#define GIMP_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS, GimpCanvasClass))
#define GIMP_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS))
#define GIMP_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS))
#define GIMP_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS, GimpCanvasClass))
typedef struct _GimpCanvasClass GimpCanvasClass;
struct _GimpCanvas
{
GtkDrawingArea parent_instance;
GdkGC *render_gc; /* GC for rendering the image */
};
struct _GimpCanvasClass
{
GtkDrawingAreaClass parent_class;
};
GType gimp_canvas_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_canvas_new (void);
#endif /* __GIMP_CANVAS_H__ */
......@@ -273,10 +273,6 @@ gimp_display_shell_canvas_realize (GtkWidget *canvas,
shell->disp_width = canvas->allocation.width;
shell->disp_height = canvas->allocation.height;
/* create GC for rendering */
shell->render_gc = gdk_gc_new (shell->canvas->window);
gdk_gc_set_exposures (shell->render_gc, TRUE);
/* set up the scrollbar observers */
g_signal_connect (shell->hsbdata, "value_changed",
G_CALLBACK (gimp_display_shell_hscrollbar_update),
......
......@@ -64,6 +64,7 @@
#include "tools/tool_manager.h"
#include "gimpcanvas.h"
#include "gimpdisplay.h"
#include "gimpdisplayoptions.h"
#include "gimpdisplayshell.h"
......@@ -242,7 +243,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
3);
shell->render_gc = NULL;
shell->icon_size = 32;
shell->icon_idle_id = 0;
......@@ -389,12 +389,6 @@ gimp_display_shell_destroy (GtkObject *object)
shell->render_buf = NULL;
}
if (shell->render_gc)
{
g_object_unref (shell->render_gc);
shell->render_gc = NULL;
}
if (shell->title_idle_id)
{
g_source_remove (shell->title_idle_id);
......@@ -723,7 +717,7 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gimp_help_set_help_data (shell->origin, NULL, "#origin_button");
/* EEK */
shell->canvas = gtk_drawing_area_new ();
shell->canvas = gimp_canvas_new ();
/* the horizontal ruler */
shell->hrule = gtk_hruler_new ();
......@@ -754,7 +748,6 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gimp_help_set_help_data (shell->vrule, NULL, "#ruler");
/* the canvas */
gtk_widget_set_name (shell->canvas, "gimp-canvas");
gtk_widget_set_size_request (shell->canvas, n_width, n_height);
gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
......
......@@ -99,7 +99,7 @@ struct _GimpDisplayShell
GtkAdjustment *hsbdata; /* adjustments */
GtkAdjustment *vsbdata;
GtkWidget *canvas; /* canvas widget */
GtkWidget *canvas; /* GimpCanvas widget */
GtkWidget *hsb; /* scroll bars */
GtkWidget *vsb;
......@@ -111,8 +111,6 @@ struct _GimpDisplayShell
GtkWidget *statusbar; /* statusbar */
guchar *render_buf; /* buffer for rendering the image */
GdkGC *render_gc; /* GC for rendering the image */
guint title_idle_id; /* title update idle ID */
gint icon_size; /* size of the icon pixmap */
......
......@@ -35,6 +35,7 @@
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-projection.h"
#include "gimpcanvas.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-filter.h"
......@@ -361,7 +362,7 @@ gimp_display_shell_render (GimpDisplayShell *shell,
/* put it to the screen */
gdk_draw_rgb_image_dithalign (shell->canvas->window,
shell->render_gc,
GIMP_CANVAS (shell->canvas)->render_gc,
x + shell->disp_xoffset,
y + shell->disp_yoffset,
w, h,
......
......@@ -64,6 +64,7 @@
#include "tools/tool_manager.h"
#include "gimpcanvas.h"
#include "gimpdisplay.h"
#include "gimpdisplayoptions.h"
#include "gimpdisplayshell.h"
......@@ -242,7 +243,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->render_buf = g_malloc (GIMP_DISPLAY_SHELL_RENDER_BUF_WIDTH *
GIMP_DISPLAY_SHELL_RENDER_BUF_HEIGHT *
3);
shell->render_gc = NULL;
shell->icon_size = 32;
shell->icon_idle_id = 0;
......@@ -389,12 +389,6 @@ gimp_display_shell_destroy (GtkObject *object)
shell->render_buf = NULL;
}
if (shell->render_gc)
{
g_object_unref (shell->render_gc);
shell->render_gc = NULL;
}
if (shell->title_idle_id)
{
g_source_remove (shell->title_idle_id);
......@@ -723,7 +717,7 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gimp_help_set_help_data (shell->origin, NULL, "#origin_button");
/* EEK */
shell->canvas = gtk_drawing_area_new ();
shell->canvas = gimp_canvas_new ();
/* the horizontal ruler */
shell->hrule = gtk_hruler_new ();
......@@ -754,7 +748,6 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gimp_help_set_help_data (shell->vrule, NULL, "#ruler");
/* the canvas */
gtk_widget_set_name (shell->canvas, "gimp-canvas");
gtk_widget_set_size_request (shell->canvas, n_width, n_height);
gtk_widget_set_events (shell->canvas, GIMP_DISPLAY_SHELL_CANVAS_EVENT_MASK);
gtk_widget_set_extension_events (shell->canvas, GDK_EXTENSION_EVENTS_ALL);
......
......@@ -99,7 +99,7 @@ struct _GimpDisplayShell
GtkAdjustment *hsbdata; /* adjustments */
GtkAdjustment *vsbdata;
GtkWidget *canvas; /* canvas widget */
GtkWidget *canvas; /* GimpCanvas widget */
GtkWidget *hsb; /* scroll bars */
GtkWidget *vsb;
......@@ -111,8 +111,6 @@ struct _GimpDisplayShell
GtkWidget *statusbar; /* statusbar */
guchar *render_buf; /* buffer for rendering the image */
GdkGC *render_gc; /* GC for rendering the image */
guint title_idle_id; /* title update idle ID */
gint icon_size; /* size of the icon pixmap */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment