]> Pileus Git - ~andy/gtk/blob - gdk/directfb/gdkfont-directfb.c
[GtkStyle] Remove deprecated GdkFont usage
[~andy/gtk] / gdk / directfb / gdkfont-directfb.c
1 /* GDK - The GIMP Drawing Kit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.
23  */
24
25 /*
26  * GTK+ DirectFB backend
27  * Copyright (C) 2001-2002  convergence integrated media GmbH
28  * Copyright (C) 2002-2004  convergence GmbH
29  * Written by Denis Oliver Kropp <dok@convergence.de> and
30  *            Sven Neumann <sven@convergence.de>
31  */
32
33 #undef GDK_DISABLE_DEPRECATED
34
35 #include "config.h"
36 #include "gdk.h"
37
38 #include <string.h>
39
40 #include "gdkdirectfb.h"
41 #include "gdkprivate-directfb.h"
42
43 #include "gdkinternals.h"
44
45 #include "gdkfont.h"
46 #include "gdkalias.h"
47
48
49 typedef struct _GdkFontDirectFB  GdkFontDirectFB;
50
51 struct _GdkFontDirectFB
52 {
53   GdkFontPrivate    base;
54   gint              size;
55   IDirectFBFont    *dfbfont;
56 };
57
58
59 static GdkFont *
60 gdk_directfb_bogus_font (gint height)
61 {
62   GdkFont         *font;
63   GdkFontDirectFB *private;
64
65   private = g_new0 (GdkFontDirectFB, 1);
66   font = (GdkFont *)private;
67
68   font->type = GDK_FONT_FONT;
69   font->ascent = height*3/4;
70   font->descent = height/4;
71   private->size = height;
72   private->base.ref_count = 1;
73   return font;
74 }
75
76
77 /* ********************* */
78
79 GdkFont*
80 gdk_fontset_load (const gchar *fontset_name)
81 {
82   return gdk_directfb_bogus_font (10);
83 }
84
85 GdkFont *
86 gdk_fontset_load_for_display (GdkDisplay *display,const gchar *font_name) {
87   return gdk_directfb_bogus_font (10);
88 }
89
90 void
91 _gdk_font_destroy (GdkFont *font)
92 {
93   switch (font->type)
94     {
95     case GDK_FONT_FONT:
96       break;
97     case GDK_FONT_FONTSET:
98       break;
99     default:
100       g_error ("unknown font type.");
101       break;
102     }
103
104   g_free (font);
105 }
106
107 gint
108 _gdk_font_strlen (GdkFont     *font,
109                   const gchar *str)
110 {
111   GdkFontDirectFB *font_private;
112   gint length = 0;
113
114   g_return_val_if_fail (font != NULL, -1);
115   g_return_val_if_fail (str != NULL, -1);
116
117   font_private = (GdkFontDirectFB*) font;
118
119   if (font->type == GDK_FONT_FONT)
120     {
121       guint16 *string_2b = (guint16 *)str;
122
123       while (*(string_2b++))
124         length++;
125     }
126   else if (font->type == GDK_FONT_FONTSET)
127     {
128       length = strlen (str);
129     }
130   else
131     g_error("undefined font type\n");
132
133   return length;
134 }
135
136 gint
137 gdk_font_id (const GdkFont *font)
138 {
139   const GdkFontDirectFB *font_private;
140
141   g_return_val_if_fail (font != NULL, 0);
142
143   font_private = (const GdkFontDirectFB*) font;
144
145   if (font->type == GDK_FONT_FONT)
146     {
147       return -1;
148     }
149   else
150     {
151       return 0;
152     }
153 }
154
155 gint
156 gdk_font_equal (const GdkFont *fonta,
157                 const GdkFont *fontb)
158 {
159   const GdkFontDirectFB *privatea;
160   const GdkFontDirectFB *privateb;
161
162   g_return_val_if_fail (fonta != NULL, FALSE);
163   g_return_val_if_fail (fontb != NULL, FALSE);
164
165   privatea = (const GdkFontDirectFB*) fonta;
166   privateb = (const GdkFontDirectFB*) fontb;
167
168   if(fonta == fontb)
169     return TRUE;
170
171   return FALSE;
172 }
173
174
175 #define __GDK_FONT_X11_C__
176 #include "gdkaliasdef.c"