Commit a3c1e86f authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Added gdk_text_extents_wc()

Tue Dec 15 14:30:35 1998  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()

        * Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
	  to label. (Based on patch from Jeff Dairiki
	  <dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)

	- Adds new function gtk_label_set_line_wrap()
	- implement GTK_JUSTIFY_FILL.
	- rename gtk_label_set to gtk_label_set_text() add
	   gtk_label_set() to gtkcompat.h.

	* Use an internal wc representation in the label, so
	  that we handle underlining and line breaks correctly
	  for multi-byte strings.
parent 7eec796c
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.
......
......@@ -604,6 +604,14 @@ void gdk_text_extents (GdkFont *font,
gint *width,
gint *ascent,
gint *descent);
void gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent);
void gdk_string_extents (GdkFont *font,
const gchar *string,
gint *lbearing,
......
......@@ -503,6 +503,80 @@ gdk_text_extents (GdkFont *font,
}
void
gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
gint i;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
{
gchar *text_8bit;
gint i;
xfont = (XFontStruct *) private->xfont;
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
XTextExtents (xfont, text_8bit, text_length,
&direction, &font_ascent, &font_descent,
&overall);
g_free (text_8bit);
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XwcTextExtents (fontset, text, text_length, &ink, &logical);
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
}
void
gdk_string_extents (GdkFont *font,
const gchar *string,
......
......@@ -503,6 +503,80 @@ gdk_text_extents (GdkFont *font,
}
void
gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
gint i;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
{
gchar *text_8bit;
gint i;
xfont = (XFontStruct *) private->xfont;
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
XTextExtents (xfont, text_8bit, text_length,
&direction, &font_ascent, &font_descent,
&overall);
g_free (text_8bit);
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XwcTextExtents (fontset, text, text_length, &ink, &logical);
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
}
void
gdk_string_extents (GdkFont *font,
const gchar *string,
......
......@@ -172,7 +172,7 @@ gtk_accel_label_new (const gchar *string)
accel_label = gtk_type_new (GTK_TYPE_ACCEL_LABEL);
gtk_label_set (GTK_LABEL (accel_label), string);
gtk_label_set_text (GTK_LABEL (accel_label), string);
return GTK_WIDGET (accel_label);
}
......
......@@ -244,7 +244,7 @@ gtk_button_set_arg (GtkObject *object,
"parent", button,
NULL);
if (GTK_IS_LABEL (child))
gtk_label_set (GTK_LABEL (child),
gtk_label_set_text (GTK_LABEL (child),
GTK_VALUE_STRING (*arg) ? GTK_VALUE_STRING (*arg) : "");
break;
case ARG_RELIEF:
......
......@@ -36,7 +36,7 @@ extern "C" {
#define gtk_paned_handle_size gtk_paned_set_handle_size
#define gtk_scale_value_width gtk_scale_get_value_width
#define gtk_window_position gtk_window_set_position
#define gtk_label_set gtk_label_set_text
#ifdef __cplusplus
}
......
/* 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)
{
static const 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);
}
/* 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__ */
......@@ -499,7 +499,7 @@ gtk_file_selection_init (GtkFileSelection *filesel)
sprintf (err_buf, _("Directory unreadable: %s"), cmpl_strerror (cmpl_errno));
gtk_label_set (GTK_LABEL (filesel->selection_text), err_buf);
gtk_label_set_text (GTK_LABEL (filesel->selection_text), err_buf);
}
else
{
......@@ -1435,7 +1435,7 @@ gtk_file_selection_populate (GtkFileSelection *fs,
strcpy (sel_text, "Selection: ");
strcat (sel_text, cmpl_reference_position (cmpl_state));
gtk_label_set (GTK_LABEL (fs->selection_text), sel_text);
gtk_label_set_text (GTK_LABEL (fs->selection_text), sel_text);
g_free (sel_text);
}
......@@ -1457,7 +1457,7 @@ gtk_file_selection_abort (GtkFileSelection *fs)
/* BEEP gdk_beep(); */
if (fs->selection_entry)
gtk_label_set (GTK_LABEL (fs->selection_text), err_buf);
gtk_label_set_text (GTK_LABEL (fs->selection_text), err_buf);
}
/**********************************************************************/
......
......@@ -1752,19 +1752,19 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel)
it's necessary as it results in a resize of the whole window! */
gtk_label_get(GTK_LABEL(fontsel->message_label), &label_text);
if (strcmp(label_text, ""))
gtk_label_set(GTK_LABEL(fontsel->message_label), "");
gtk_label_set_text(GTK_LABEL(fontsel->message_label), "");
gtk_font_selection_update_preview (fontsel);
return TRUE;
}
else
{
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"The selected font is not available.");
}
}
else
{
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"The selected font is not a valid font.");
}
......@@ -1822,7 +1822,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
displayed properly. */
xfs = GDK_FONT_XFONT(fontsel->font);
if (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"This is a 2-byte font and may not be displayed correctly.");
}
......@@ -2135,12 +2135,12 @@ gtk_font_selection_update_filter (GtkFontSelection *fontsel)
if (default_filter)
{
gtk_widget_set_sensitive(fontsel->filter_button, FALSE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font:");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font:");
}
else
{
gtk_widget_set_sensitive(fontsel->filter_button, TRUE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font: (Filter Applied)");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font: (Filter Applied)");
}
gtk_font_selection_show_available_fonts(fontsel);
}
......@@ -2365,7 +2365,7 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel)
/* Update the main notebook page. */
gtk_widget_set_sensitive(fontsel->filter_button, FALSE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font:");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font:");