/* Copyright (C) 2001-2002 Kenichi Suto
*
* 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 "defs.h"
#include "global.h"
gint shadow_height = 4;
gboolean create_pixmap(CANVAS *canvas)
{
if(canvas->pixmap)
gdk_pixmap_unref(canvas->pixmap);
canvas->pixmap = gdk_pixmap_new( window->window,
// canvas->width,
canvas->max_width,
canvas->height,
-1 );
return(TRUE);
}
gboolean destroy_canvas(CANVAS *canvas)
{
g_assert(canvas != NULL);
if(canvas->pixmap)
gdk_pixmap_unref(canvas->pixmap);
gdk_gc_destroy(canvas->gc);
free(canvas);
return(TRUE);
}
gboolean fill_canvas(CANVAS *canvas)
{
GdkGC *gc=NULL;
g_assert(canvas != NULL);
gc = gdk_gc_new(canvas->window->window);
gdk_gc_set_foreground(gc, &canvas->window->style->bg[GTK_STATE_NORMAL]);
gdk_gc_set_background(gc, &canvas->window->style->bg[GTK_STATE_NORMAL]);
gdk_draw_rectangle( canvas->pixmap,
gc,
TRUE, 0,0,
// canvas->width, canvas->height);
canvas->max_width, canvas->height);
gdk_gc_destroy(gc);
}
CANVAS *create_canvas(GtkWidget *window)
{
CANVAS *canvas;
g_assert(window != NULL);
canvas = (CANVAS *)calloc(sizeof(CANVAS), 1);
g_assert(canvas != NULL);
canvas->window = window;
canvas->pixmap = NULL;
canvas->x = h_border;
canvas->y = font_height + v_border;
canvas->width = 0;
canvas->height = 0;
canvas->max_width = 0;
canvas->font = font_normal;
canvas->indent = 0;
canvas->line_height = font_height;
canvas->gc = gdk_gc_new(canvas->window->window);
gdk_gc_set_foreground(canvas->gc, &canvas->window->style->fg[GTK_STATE_NORMAL]);
gdk_gc_set_background(canvas->gc, &canvas->window->style->bg[GTK_STATE_NORMAL]);
return(canvas);
}
gboolean clear_canvas(CANVAS *canvas)
{
canvas->x = h_border;
canvas->y = font_height + v_space + v_border;
// canvas->max_width = 0;
canvas->indent = 0;
}
gboolean simulate_canvas(CANVAS *canvas, BOOK_INFO *binfo, gchar *text, gint max_width, gint max_height)
{
DRAW_TEXT l_text;
canvas->width = max_width;
canvas->height = max_height;
canvas->max_width = max_width;
l_text.text = text;
l_text.length = strlen(text);
draw_content(canvas, &l_text, binfo, NULL);
canvas->height = canvas->y;
canvas->height += 10; // ちょっと大きめにしないと文字が切れてしまう
if(canvas->height < max_height)
canvas->height = max_height - shadow_height;
if(canvas->width < max_width)
canvas->width = max_width;
return(TRUE);
}
gboolean draw_canvas(CANVAS *canvas, BOOK_INFO *binfo, gchar *text)
{
DRAW_TEXT l_text;
l_text.text = text;
l_text.length = strlen(text);
draw_content(canvas, &l_text, binfo, NULL);
}
syntax highlighted by Code2HTML, v. 0.9.1