File: gtk-extra-plot_canvas.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 (512 lines) | stat: -rw-r--r-- 16,215 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
-----------------------------------------------------------------------
--          GtkAda - Ada95 binding for the Gimp Toolkit              --
--                                                                   --
--                     Copyright (C) 2000                            --
--        Emmanuel Briot, Joel Brobecker and Arnaud Charlet          --
--               Copyright (C) 2001-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 Gdk.Color;           use Gdk.Color;
with Gtk.Extra.Plot_Data; use Gtk.Extra.Plot_Data;
with Glib.Type_Conversion_Hooks;
pragma Elaborate_All (Glib.Type_Conversion_Hooks);

package body Gtk.Extra.Plot_Canvas is

   function Type_Conversion (Type_Name : String) return GObject;
   --  Used to implement an automatic type conversion for objects returned
   --  from C.

   -------------------
   -- Cancel_Action --
   -------------------

   procedure Cancel_Action (Plot_Canvas : access Gtk_Plot_Canvas_Record)
   is
      procedure Internal (Plot_Canvas : in System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_cancel_action");
   begin
      Internal (Get_Object (Plot_Canvas));
   end Cancel_Action;

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

   procedure Gtk_New
     (Widget        : out Gtk_Plot_Canvas;
      Width         : in Gint;
      Height        : in Gint;
      Magnification : in Gdouble := 1.0)
   is
   begin
      Widget := new Gtk_Plot_Canvas_Record;
      Initialize (Widget, Width, Height, Magnification);
   end Gtk_New;

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

   procedure Initialize
     (Widget        : access Gtk_Plot_Canvas_Record'Class;
      Width         : in Gint;
      Height        : in Gint;
      Magnification : in Gdouble := 1.0)
   is
      function Internal (Width         : in Gint;
                         Height        : in Gint;
                         Magnification : in Gdouble)
                        return      System.Address;
      pragma Import (C, Internal, "gtk_plot_canvas_new");
   begin
      Set_Object (Widget, Internal (Width, Height, Magnification));
   end Initialize;

   -----------------------------
   -- Plot_Canvas_Flag_Is_Set --
   -----------------------------

   function Plot_Canvas_Flag_Is_Set
     (Plot_Canvas : access Gtk_Plot_Canvas_Record;
      Flag        : in Guint16)
     return Boolean
   is
      function Internal (Canvas : System.Address;
                         Flag   : Guint16)
                        return Guint16;
      pragma Import (C, Internal, "ada_gtk_plot_canvas_flag_is_set");
   begin
      return Internal (Get_Object (Plot_Canvas), Flag) /= 0;
   end Plot_Canvas_Flag_Is_Set;

   ---------------------------
   -- Set_Plot_Canvas_Flags --
   ---------------------------

   procedure Plot_Canvas_Set_Flags
     (Plot_Canvas  : access Gtk_Plot_Canvas_Record;
      Flags        : in Guint16)
   is
      procedure Internal (Canvas : System.Address;
                          Flags  : Guint16);
      pragma Import (C, Internal, "ada_gtk_plot_canvas_set_flags");
   begin
      Internal (Get_Object (Plot_Canvas), Flags);
   end Plot_Canvas_Set_Flags;

   -----------------------------
   -- Plot_Canvas_Unset_Flags --
   -----------------------------

   procedure Plot_Canvas_Unset_Flags
     (Plot_Canvas  : access Gtk_Plot_Canvas_Record;
      Flags        : in Guint16)
   is
      procedure Internal (Canvas : System.Address;
                          Flags  : Guint16);
      pragma Import (C, Internal, "ada_gtk_plot_canvas_unset_flags");
   begin
      Internal (Get_Object (Plot_Canvas), Flags);
   end Plot_Canvas_Unset_Flags;

   --------------
   -- Set_Size --
   --------------

   procedure Set_Size (Canvas  : access Gtk_Plot_Canvas_Record;
                       Width   : in Gint;
                       Height  : in Gint)
   is
      procedure Internal (Canvas : System.Address;
                          Width  : Gint;
                          Height : Gint);
      pragma Import (C, Internal, "gtk_plot_canvas_set_size");
   begin
      Internal (Get_Object (Canvas), Width, Height);
   end Set_Size;

   -------------
   -- Refresh --
   -------------

   procedure Refresh (Canvas : access Gtk_Plot_Canvas_Record) is
      procedure Internal (Canvas : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_refresh");
   begin
      Internal (Get_Object (Canvas));
   end Refresh;

   --------------
   -- Unselect --
   --------------

   procedure Unselect (Canvas : access Gtk_Plot_Canvas_Record) is
      procedure Internal (Canvas : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_unselect");
   begin
      Internal (Get_Object (Canvas));
   end Unselect;

   ---------------------
   -- Get_Active_Item --
   ---------------------

   function Get_Active_Item (Canvas  : access Gtk_Plot_Canvas_Record)
                            return Gtk_Plot_Canvas_Child
   is
      function Internal (Canvas : System.Address) return System.Address;
      pragma Import (C, Internal, "gtk_plot_canvas_get_active_item");
      Stub : Gtk_Plot_Canvas_Child_Record;
   begin
      return Gtk_Plot_Canvas_Child
        (Get_User_Data (Internal (Get_Object (Canvas)), Stub));
   end Get_Active_Item;

   ----------------------
   -- Grid_Set_Visible --
   ----------------------

   procedure Grid_Set_Visible (Canvas  : access Gtk_Plot_Canvas_Record;
                               Visible : Boolean)
   is
      procedure Internal (Canvas  : System.Address;
                          Visible : Gint);
      pragma Import (C, Internal, "gtk_plot_canvas_grid_set_visible");
   begin
      Internal (Get_Object (Canvas), Boolean'Pos (Visible));
   end Grid_Set_Visible;

   -------------------
   -- Grid_Set_Step --
   -------------------

   procedure Grid_Set_Step (Canvas : access Gtk_Plot_Canvas_Record;
                            Step   : Gdouble)
   is
      procedure Internal (Canvas : System.Address;
                          Step   : Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_grid_set_step");
   begin
      Internal (Get_Object (Canvas), Step);
   end Grid_Set_Step;

   -------------------------
   -- Grid_Set_Attributes --
   -------------------------

   procedure Grid_Set_Attributes
     (Canvas : access Gtk_Plot_Canvas_Record;
      Style  : in Gtk.Extra.Plot_Data.Plot_Line_Style;
      Width  : in Gint;
      Color  : in Gdk.Color.Gdk_Color)
   is
      procedure Internal
        (Canvas : System.Address;
         Style  : Gtk.Extra.Plot_Data.Plot_Line_Style;
         Width  : Gint;
         Color  : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_grid_set_attributes");

      Col : aliased Gdk.Color.Gdk_Color := Color;
      Cola : System.Address := Col'Address;

   begin
      if Color = Gdk.Color.Null_Color then
         Cola := System.Null_Address;
      end if;
      Internal (Get_Object (Canvas), Style, Width, Cola);
   end Grid_Set_Attributes;

   -----------------------
   -- Set_Magnification --
   -----------------------

   procedure Set_Magnification
     (Canvas        : access Gtk_Plot_Canvas_Record;
      Magnification : Gdouble := 1.0)
   is
      procedure Internal (Canvas : System.Address;
                          Magnification : Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_set_magnification");
   begin
      Internal (Get_Object (Canvas), Magnification);
   end Set_Magnification;

   --------------------
   -- Set_Background --
   --------------------

   procedure Set_Background
     (Canvas     : access Gtk_Plot_Canvas_Record;
      Background : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Canvas : System.Address; Color  : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_set_background");
      Col : aliased Gdk.Color.Gdk_Color := Background;
      Cola : System.Address := Col'Address;
   begin
      if Background = Gdk.Color.Null_Color then
         Cola := System.Null_Address;
      end if;
      Internal (Get_Object (Canvas), Cola);
   end Set_Background;

   ---------------
   -- Get_Pixel --
   ---------------

   procedure Get_Pixel
     (Canvas : access Gtk_Plot_Canvas_Record;
      Px     : Gdouble;
      Py     : Gdouble;
      X      : out Gint;
      Y      : out Gint)
   is
      procedure Internal (Canvas : in System.Address;
                          Px     : in Gdouble;
                          Py     : in Gdouble;
                          X      : out Gint;
                          Y      : out Gint);
      pragma Import (C, Internal, "gtk_plot_canvas_get_pixel");
   begin
      Internal (Get_Object (Canvas), Px, Py, X, Y);
   end Get_Pixel;

   ------------------
   -- Get_Position --
   ------------------

   procedure Get_Position
      (Canvas : access Gtk_Plot_Canvas_Record;
       X      : Gint;
       Y      : Gint;
       Px     : out Gdouble;
       Py     : out Gdouble)
   is
      procedure Internal
         (Canvas : System.Address;
          X      : Gint;
          Y      : Gint;
          Px     : out Gdouble;
          Py     : out Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_get_position");
   begin
      Internal (Get_Object (Canvas), X, Y, Px, Py);
   end Get_Position;

   ---------------
   -- Put_Child --
   ---------------

   procedure Put_Child
     (Canvas : access Gtk_Plot_Canvas_Record;
      Child  : access Gtk_Plot_Canvas_Child_Record'Class;
      X1     : Gdouble;
      Y1     : Gdouble;
      X2     : Gdouble := 0.0;
      Y2     : Gdouble := 0.0)
   is
      procedure Internal
        (Canvas : System.Address;
         Child  : System.Address;
         X1, Y1, X2, Y2 : Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_put_child");
   begin
      Internal (Get_Object (Canvas), Get_Object (Child), X1, Y1, X2, Y2);
   end Put_Child;

   ----------------
   -- Child_Move --
   ----------------

   procedure Child_Move
     (Canvas : access Gtk_Plot_Canvas_Record;
      Child  : access Gtk_Plot_Canvas_Child_Record'Class;
      X1     : Gdouble;
      Y1     : Gdouble)
   is
      procedure Internal
        (Canvas : System.Address;
         Child  : System.Address;
         X1, Y1 : Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_child_move");
   begin
      Internal (Get_Object (Canvas), Get_Object (Child), X1, Y1);
   end Child_Move;

   -----------------------
   -- Child_Move_Resize --
   -----------------------

   procedure Child_Move_Resize
     (Canvas : access Gtk_Plot_Canvas_Record;
      Child  : access Gtk_Plot_Canvas_Child_Record'Class;
      X1     : Gdouble;
      Y1     : Gdouble;
      X2     : Gdouble;
      Y2     : Gdouble)
   is
      procedure Internal
        (Canvas : System.Address;
         Child  : System.Address;
         X1, Y1, X2, Y2 : Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_child_move_resize");
   begin
      Internal (Get_Object (Canvas), Get_Object (Child), X1, Y1, X2, Y2);
   end Child_Move_Resize;

   -----------
   -- Paint --
   -----------

   procedure Paint (Canvas : access Gtk_Plot_Canvas_Record) is
      procedure Internal (Canvas : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_paint");
   begin
      Internal (Get_Object (Canvas));
   end Paint;

   ------------
   -- Freeze --
   ------------

   procedure Freeze (Canvas : access Gtk_Plot_Canvas_Record) is
      procedure Internal (Canvas : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_freeze");
   begin
      Internal (Get_Object (Canvas));
   end Freeze;

   ----------
   -- Thaw --
   ----------

   procedure Thaw (Canvas : access Gtk_Plot_Canvas_Record) is
      procedure Internal (Canvas : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_thaw");
   begin
      Internal (Get_Object (Canvas));
   end Thaw;

   ---------------------
   -- Set_Transparent --
   ---------------------

   procedure Set_Transparent
     (Canvas : access Gtk_Plot_Canvas_Record; Transparent : Boolean)
   is
      procedure Internal (Canvas : System.Address; Transparent : Integer);
      pragma Import (C, Internal, "gtk_plot_canvas_set_transparent");
   begin
      Internal (Get_Object (Canvas), Boolean'Pos (Transparent));
   end Set_Transparent;

   -----------------
   -- Transparent --
   -----------------

   function Transparent
     (Canvas : access Gtk_Plot_Canvas_Record) return Boolean
   is
      function Internal (Canvas : System.Address) return Integer;
      pragma Import (C, Internal, "gtk_plot_canvas_transparent");
   begin
      return Boolean'Val (Internal (Get_Object (Canvas)));
   end Transparent;

   ------------------
   -- Remove_Child --
   ------------------

   procedure Remove_Child
     (Canvas : access Gtk_Plot_Canvas_Record;
      Child  : access Gtk_Plot_Canvas_Child_Record'Class)
   is
      procedure Internal (C : System.Address; Child : System.Address);
      pragma Import (C, Internal, "gtk_plot_canvas_remove_child");
   begin
      Internal (Get_Object (Canvas), Get_Object (Child));
   end Remove_Child;

   -------------------
   -- Set_Selection --
   -------------------

   procedure Set_Selection
     (Child     : access Gtk_Plot_Canvas_Child_Record;
      Selection : Plot_Canvas_Selection)
   is
      procedure Internal
        (Child : System.Address; Selection : Plot_Canvas_Selection);
      pragma Import (C, Internal, "gtk_plot_canvas_child_set_selection");
   begin
      Internal (Get_Object (Child), Selection);
   end Set_Selection;

   ------------------------
   -- Set_Selection_Mode --
   ------------------------

   procedure Set_Selection_Mode
     (Child     : access Gtk_Plot_Canvas_Child_Record;
      Mode      : Plot_Canvas_Selection_Mode)
   is
      procedure Internal
        (Child : System.Address; Selection : Plot_Canvas_Selection_Mode);
      pragma Import (C, Internal, "gtk_plot_canvas_child_set_selection_mode");
   begin
      Internal (Get_Object (Child), Mode);
   end Set_Selection_Mode;

   ------------------
   -- Get_Position --
   ------------------

   procedure Get_Position
     (Canvas    : access Gtk_Plot_Canvas_Record;
      Child     : access Gtk_Plot_Canvas_Child_Record'Class;
      X1, Y1    : out Gdouble;
      X2, Y2    : out Gdouble)
   is
      procedure Internal
        (Canvas, Child : System.Address;
         X1, Y1, X2, Y2 : out Gdouble);
      pragma Import (C, Internal, "gtk_plot_canvas_child_get_position");
   begin
      Internal (Get_Object (Canvas), Get_Object (Child), X1, Y1, X2, Y2);
   end Get_Position;

   ---------------------
   -- Type_Conversion --
   ---------------------

   function Type_Conversion (Type_Name : String) return GObject is
   begin
      if Type_Name = "GtkPlotCanvasChild" then
         return new Gtk_Plot_Canvas_Child_Record;
      else
         return null;
      end if;
   end Type_Conversion;

begin
   Glib.Type_Conversion_Hooks.Add_Hook (Type_Conversion'Access);
end Gtk.Extra.Plot_Canvas;