File: gtk-extra-font_combo.adb

package info (click to toggle)
libgtkada2 2.8.1-6lenny3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,496 kB
  • ctags: 3,886
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,169; xml: 19
file content (155 lines) | stat: -rw-r--r-- 5,218 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--      Copyright (C) 2000 E. Briot, J. Brobecker and A. Charlet     --
--                Copyright (C) 2000-2006 AdaCore                    --
--                                                                   --
-- This library 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 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 --
-- General Public License for more details.                          --
--                                                                   --
-- You should have received a copy of the GNU 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.                                       --
--                                                                   --
-----------------------------------------------------------------------

with System;
with Pango.Font; use Pango.Font;

package body Gtk.Extra.Font_Combo is

   -----------------------
   -- Font_Combo_Select --
   -----------------------

   procedure Font_Combo_Select
     (Font_Combo : access Gtk_Font_Combo_Record;
      Family     : String;
      Bold       : Boolean;
      Italic     : Boolean;
      Height     : Gint)
   is
      procedure Internal
        (Font_Combo : System.Address;
         Family     : String;
         Bold       : Gint;
         Italic     : Gint;
         Height     : Gint);
      pragma Import (C, Internal, "gtk_font_combo_select");

   begin
      Internal
        (Get_Object (Font_Combo),
         Family & ASCII.NUL,
         Boolean'Pos (Bold),
         Boolean'Pos (Italic),
         Height);
   end Font_Combo_Select;

   ---------------------------
   -- Font_Combo_Select_Nth --
   ---------------------------

   procedure Font_Combo_Select_Nth
     (Font_Combo : access Gtk_Font_Combo_Record;
      N          : Gint;
      Bold       : Boolean;
      Italic     : Boolean;
      Height     : Gint)
   is
      procedure Internal
        (Font_Combo : System.Address;
         N          : Gint;
         Bold       : Gint;
         Italic     : Gint;
         Height     : Gint);
      pragma Import (C, Internal, "gtk_font_combo_select_nth");

   begin
      Internal
        (Get_Object (Font_Combo),
         N,
         Boolean'Pos (Bold),
         Boolean'Pos (Italic),
         Height);
   end Font_Combo_Select_Nth;

   -------------
   -- Gtk_New --
   -------------

   procedure Gtk_New (Widget : out Gtk_Font_Combo) is
   begin
      Widget := new Gtk_Font_Combo_Record;
      Gtk.Extra.Font_Combo.Initialize (Widget);
   end Gtk_New;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize (Widget : access Gtk_Font_Combo_Record'Class) is
      function Internal return System.Address;
      pragma Import (C, Internal, "gtk_font_combo_new");

      procedure Psfont_Init;
      pragma Import (C, Psfont_Init, "gtk_psfont_init");

   begin
      --  gtk_psfont needs to be initialized. Since we no longer provide
      --  a binding for it (it is replaced by pango), this needs to be done
      --  automatically. Subsequent calls to Psfont_Init are ignored.

      Psfont_Init;
      Set_Object (Widget, Internal);
   end Initialize;

   -----------------
   -- Get_GdkFont --
   -----------------

   function Get_GdkFont
     (Font_Combo : access Gtk_Font_Combo_Record) return Gdk.Font.Gdk_Font
   is
      function Internal (Font_Combo : System.Address) return Gdk.Font.Gdk_Font;
      pragma Import (C, Internal, "gtk_font_combo_get_gdkfont");
   begin
      return Internal (Get_Object (Font_Combo));
   end Get_GdkFont;

   ---------------------
   -- Get_Font_Height --
   ---------------------

   function Get_Font_Height
     (Font_Combo : access Gtk_Font_Combo_Record)  return Glib.Gint
   is
      function Internal (Combo : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_font_combo_get_font_height");
   begin
      return Internal (Get_Object (Font_Combo));
   end Get_Font_Height;

   --------------------------
   -- Get_Font_Description --
   --------------------------

   function Get_Font_Description
     (Font_Combo : access Gtk_Font_Combo_Record)
      return Pango.Font.Pango_Font_Description
   is
      function Internal (Combo : System.Address) return Pango_Font_Description;
      pragma Import (C, Internal, "gtk_font_combo_get_font_description");
   begin
      return Internal (Get_Object (Font_Combo));
   end Get_Font_Description;

end Gtk.Extra.Font_Combo;