2006-12-03 Dimitris Glezos <dimitris@glezos.com>
[dia.git] / lib / diagtkfontsel.h
blob539f750915557948430d412ffa69b18cc450b582
1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * GtkFontSelection widget for Gtk+, by Damon Chaplin, May 1998.
5 * Based on the GnomeFontSelector widget, by Elliot Lee, but major changes.
6 * The GnomeFontSelector was derived from app/text_tool.c in the GIMP.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
25 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
26 * file for a list of people on the GTK+ Team. See the ChangeLog
27 * files for a list of changes. These files are distributed with
28 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
31 #ifndef __DIA_GTK_FONTSEL_H__
32 #define __DIA_GTK_FONTSEL_H__
35 #include <gdk/gdk.h>
36 #include <gtk/gtkdialog.h>
37 #include <gtk/gtkvbox.h>
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
43 #define DIA_GTK_TYPE_FONT_SELECTION (dia_gtk_font_selection_get_type ())
44 #define DIA_GTK_FONT_SELECTION(obj) (GTK_CHECK_CAST ((obj), DIA_GTK_TYPE_FONT_SELECTION, DiaGtkFontSelection))
45 #define DIA_GTK_FONT_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), DIA_GTK_TYPE_FONT_SELECTION, DiaGtkFontSelectionClass))
46 #define DIA_GTK_IS_FONT_SELECTION(obj) (GTK_CHECK_TYPE ((obj), DIA_GTK_TYPE_FONT_SELECTION))
47 #define DIA_GTK_IS_FONT_SELECTION_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), DIA_GTK_TYPE_FONT_SELECTION))
48 #define DIA_GTK_FONT_SELECTION_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), DIA_GTK_TYPE_FONT_SELECTION, DiaGtkFontSelectionClass))
51 #define DIA_GTK_TYPE_FONT_SELECTION_DIALOG (dia_gtk_font_selection_dialog_get_type ())
52 #define DIA_GTK_FONT_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), DIA_GTK_TYPE_FONT_SELECTION_DIALOG, DiaGtkFontSelectionDialog))
53 #define DIA_GTK_FONT_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), DIA_GTK_TYPE_FONT_SELECTION_DIALOG, DiaGtkFontSelectionDialogClass))
54 #define DIA_GTK_IS_FONT_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), DIA_GTK_TYPE_FONT_SELECTION_DIALOG))
55 #define DIA_GTK_IS_FONT_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), DIA_GTK_TYPE_FONT_SELECTION_DIALOG))
56 #define DIA_GTK_FONT_SELECTION_DIALOG_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), DIA_GTK_TYPE_FONT_SELECTION_DIALOG, DiaGtkFontSelectionDialogClass))
59 typedef struct _DiaGtkFontSelection DiaGtkFontSelection;
60 typedef struct _DiaGtkFontSelectionClass DiaGtkFontSelectionClass;
62 typedef struct _DiaGtkFontSelectionDialog DiaGtkFontSelectionDialog;
63 typedef struct _DiaGtkFontSelectionDialogClass DiaGtkFontSelectionDialogClass;
65 struct _DiaGtkFontSelection
67 GtkVBox parent_instance;
69 GtkWidget *font_entry;
70 GtkWidget *family_list;
71 GtkWidget *font_style_entry;
72 GtkWidget *face_list;
73 GtkWidget *size_entry;
74 GtkWidget *size_list;
75 GtkWidget *pixels_button;
76 GtkWidget *points_button;
77 GtkWidget *filter_button;
78 GtkWidget *preview_entry;
80 const PangoContext *context;
82 PangoFontFamily *family; /* Current family */
83 PangoFontFace *face; /* Current face */
85 gint size;
88 struct _DiaGtkFontSelectionClass
90 GtkVBoxClass parent_class;
92 /* Padding for future expansion */
93 void (*_gtk_reserved1) (void);
94 void (*_gtk_reserved2) (void);
95 void (*_gtk_reserved3) (void);
96 void (*_gtk_reserved4) (void);
100 struct _DiaGtkFontSelectionDialog
102 GtkDialog parent_instance;
104 GtkWidget *fontsel;
106 GtkWidget *main_vbox;
107 GtkWidget *action_area;
108 GtkWidget *ok_button;
109 /* The 'Apply' button is not shown by default but you can show/hide it. */
110 GtkWidget *apply_button;
111 GtkWidget *cancel_button;
113 /* If the user changes the width of the dialog, we turn auto-shrink off. */
114 gint dialog_width;
115 gboolean auto_resize;
118 struct _DiaGtkFontSelectionDialogClass
120 GtkDialogClass parent_class;
122 /* Padding for future expansion */
123 void (*_gtk_reserved1) (void);
124 void (*_gtk_reserved2) (void);
125 void (*_gtk_reserved3) (void);
126 void (*_gtk_reserved4) (void);
131 /*****************************************************************************
132 * DiaGtkFontSelection functions.
133 * see the comments in the DiaGtkFontSelectionDialog functions.
134 *****************************************************************************/
136 GtkType dia_gtk_font_selection_get_type (void) G_GNUC_CONST;
137 GtkWidget* dia_gtk_font_selection_new (void);
138 gchar* dia_gtk_font_selection_get_font_name (DiaGtkFontSelection *fontsel);
141 gboolean dia_gtk_font_selection_set_font_name (DiaGtkFontSelection *fontsel,
142 const gchar *fontname);
143 G_CONST_RETURN gchar* dia_gtk_font_selection_get_preview_text (DiaGtkFontSelection *fontsel);
144 void dia_gtk_font_selection_set_preview_text (DiaGtkFontSelection *fontsel,
145 const gchar *text);
146 /* This sets the Pango context used for listing fonts */
147 void dia_gtk_font_selection_set_context (DiaGtkFontSelection *fs,
148 const PangoContext *context);
150 /*****************************************************************************
151 * DiaGtkFontSelectionDialog functions.
152 * most of these functions simply call the corresponding function in the
153 * DiaGtkFontSelection.
154 *****************************************************************************/
156 GtkType dia_gtk_font_selection_dialog_get_type (void) G_GNUC_CONST;
157 GtkWidget* dia_gtk_font_selection_dialog_new (const gchar *title);
159 /* This returns the X Logical Font Description fontname, or NULL if no font
160 is selected. Note that there is a slight possibility that the font might not
161 have been loaded OK. You should call dia_gtk_font_selection_dialog_get_font()
162 to see if it has been loaded OK.
163 You should g_free() the returned font name after you're done with it. */
164 gchar* dia_gtk_font_selection_dialog_get_font_name (DiaGtkFontSelectionDialog *fsd);
166 /* This sets the currently displayed font. It should be a valid X Logical
167 Font Description font name (anything else will be ignored), e.g.
168 "-adobe-courier-bold-o-normal--25-*-*-*-*-*-*-*"
169 It returns TRUE on success. */
170 gboolean dia_gtk_font_selection_dialog_set_font_name (DiaGtkFontSelectionDialog *fsd,
171 const gchar *fontname);
173 /* This returns the text in the preview entry. You should copy the returned
174 text if you need it. */
175 G_CONST_RETURN gchar* dia_gtk_font_selection_dialog_get_preview_text (DiaGtkFontSelectionDialog *fsd);
177 /* This sets the text in the preview entry. It will be copied by the entry,
178 so there's no need to g_strdup() it first. */
179 void dia_gtk_font_selection_dialog_set_preview_text (DiaGtkFontSelectionDialog *fsd,
180 const gchar *text);
182 /* This sets the Pango context used for listing fonts */
183 void dia_gtk_font_selection_dialog_set_context (DiaGtkFontSelectionDialog *fsd,
184 const PangoContext *context);
187 #ifdef __cplusplus
189 #endif /* __cplusplus */
192 #endif /* __DIA_GTK_FONTSEL_H__ */